refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "pxl8_dither.h"
|
|
|
|
|
#include "pxl8_types.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
#define PXL8_LIGHT_COLORS 8
|
|
|
|
|
#define PXL8_LIGHT_LEVELS 8
|
|
|
|
|
#define PXL8_LIGHT_ROWS (PXL8_LIGHT_COLORS * PXL8_LIGHT_LEVELS)
|
|
|
|
|
#define PXL8_BLEND_ROWS 256
|
|
|
|
|
#define PXL8_COLORMAP_ROWS (PXL8_LIGHT_ROWS + PXL8_BLEND_ROWS)
|
|
|
|
|
#define PXL8_COLORMAP_SIZE (256 * PXL8_COLORMAP_ROWS)
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
|
|
|
|
|
#define PXL8_FULLBRIGHT_START 240
|
|
|
|
|
#define PXL8_TRANSPARENT 0
|
|
|
|
|
#define PXL8_DYNAMIC_RANGE_START 144
|
|
|
|
|
#define PXL8_DYNAMIC_RANGE_COUNT 16
|
|
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
typedef enum {
|
|
|
|
|
PXL8_LIGHT_WHITE = 0,
|
|
|
|
|
PXL8_LIGHT_RED = 1,
|
|
|
|
|
PXL8_LIGHT_ORANGE = 2,
|
|
|
|
|
PXL8_LIGHT_YELLOW = 3,
|
|
|
|
|
PXL8_LIGHT_GREEN = 4,
|
|
|
|
|
PXL8_LIGHT_CYAN = 5,
|
|
|
|
|
PXL8_LIGHT_BLUE = 6,
|
|
|
|
|
PXL8_LIGHT_PURPLE = 7,
|
|
|
|
|
} pxl8_light_color;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
u8 r, g, b;
|
|
|
|
|
} pxl8_rgb;
|
|
|
|
|
|
|
|
|
|
static const pxl8_rgb pxl8_light_colors[PXL8_LIGHT_COLORS] = {
|
|
|
|
|
{255, 255, 255},
|
|
|
|
|
{255, 64, 64},
|
2026-02-05 03:27:35 -06:00
|
|
|
{255, 192, 64},
|
2026-01-21 23:19:50 -06:00
|
|
|
{255, 255, 64},
|
|
|
|
|
{64, 255, 64},
|
|
|
|
|
{64, 255, 255},
|
|
|
|
|
{64, 64, 255},
|
|
|
|
|
{255, 64, 255},
|
|
|
|
|
};
|
|
|
|
|
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
typedef struct {
|
|
|
|
|
u8 table[PXL8_COLORMAP_SIZE];
|
|
|
|
|
} pxl8_colormap;
|
|
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
void pxl8_colormap_generate(pxl8_colormap* cm, const u32* palette);
|
|
|
|
|
void pxl8_set_colormap(pxl8_colormap* cm, const u8* data, u32 size);
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
static inline u8 pxl8_colormap_lookup(const pxl8_colormap* cm, u8 pal_idx, pxl8_light_color light_color, u8 intensity) {
|
|
|
|
|
u32 light_row = ((u32)light_color << 3) + (intensity >> 5);
|
|
|
|
|
return cm->table[(light_row << 8) + pal_idx];
|
|
|
|
|
}
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
static inline u8 pxl8_colormap_lookup_dithered(const pxl8_colormap* cm, u8 pal_idx, pxl8_light_color light_color, u8 intensity, u32 x, u32 y) {
|
2026-02-02 17:48:25 -06:00
|
|
|
u8 dithered = pxl8_gfx_dither((f32)intensity + 0.5f, x, y);
|
2026-01-21 23:19:50 -06:00
|
|
|
u32 light_row = ((u32)light_color << 3) + (dithered >> 5);
|
|
|
|
|
return cm->table[(light_row << 8) + pal_idx];
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
}
|
|
|
|
|
|
2026-01-21 23:19:50 -06:00
|
|
|
static inline u8 pxl8_colormap_blend(const pxl8_colormap* cm, u8 src, u8 dst) {
|
|
|
|
|
u32 blend_row = PXL8_LIGHT_ROWS + src;
|
|
|
|
|
return cm->table[(blend_row << 8) + dst];
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|