diff --git a/include/tic80/tic80.h b/include/tic80/tic80.h index 1f4be68..0cf3d6f 100644 --- a/include/tic80/tic80.h +++ b/include/tic80/tic80.h @@ -31,7 +31,8 @@ extern "C" { #define TIC80_WIDTH 240 #define TIC80_HEIGHT 136 -#define TIC80_FULLWIDTH 256 +#define TIC80_FULLWIDTH_BITS 8 +#define TIC80_FULLWIDTH (1 << TIC80_FULLWIDTH_BITS) #define TIC80_FULLHEIGHT (TIC80_FULLWIDTH*9/16) typedef struct diff --git a/src/studio.c b/src/studio.c index a0d36ed..306322f 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1862,7 +1862,7 @@ static void drawRecordLabel(u32* frame, s32 pitch, s32 sx, s32 sy, const u32* co for(s32 x = 0; x < sizeof RecLabel[0]*BITS_IN_BYTE; x++) { if(RecLabel[y] & (1 << x)) - memcpy(&frame[sx + 15 - x + (y+sy)*TIC80_FULLWIDTH], color, sizeof *color); + memcpy(&frame[sx + 15 - x + ((y+sy) << TIC80_FULLWIDTH_BITS)], color, sizeof *color); } } } diff --git a/src/tic.c b/src/tic.c index 97ae82a..94db161 100644 --- a/src/tic.c +++ b/src/tic.c @@ -149,9 +149,14 @@ static void resetPalette(tic_mem* memory) memory->ram.vram.vars.mask.data = TIC_GAMEPAD_MASK; } +static inline u8 mapColor(tic_mem* tic, u8 color) +{ + return tic_tool_peek4(tic->ram.vram.mapping, color & 0xf); +} + static void dmaPixel(tic_mem* tic, s32 x, s32 y, u8 color) { - tic_tool_poke4(tic->ram.vram.screen.data, y * TIC80_WIDTH + x, tic_tool_peek4(tic->ram.vram.mapping, color & 0xf)); + tic_tool_poke4(tic->ram.vram.screen.data, y * TIC80_WIDTH + x, mapColor(tic, color)); } static void ovrPixel(tic_mem* tic, s32 x, s32 y, u8 color) @@ -161,7 +166,7 @@ static void ovrPixel(tic_mem* tic, s32 x, s32 y, u8 color) enum {Top = (TIC80_FULLHEIGHT-TIC80_HEIGHT)/2}; enum {Left = (TIC80_FULLWIDTH-TIC80_WIDTH)/2}; - tic->screen[x + y * TIC80_FULLWIDTH + (Left + Top * TIC80_FULLWIDTH)] = machine->state.ovr.palette[color & 0xf]; + *(tic->screen + x + (y << TIC80_FULLWIDTH_BITS) + (Left + Top * TIC80_FULLWIDTH)) = *(machine->state.ovr.palette + mapColor(tic, color)); } static void setPixel(tic_machine* machine, s32 x, s32 y, u8 color)