added OVR palette
This commit is contained in:
parent
a2e97b018a
commit
68a89c7421
|
@ -291,7 +291,7 @@ static s32 writeGifData(const tic_mem* tic, u8* dst, const u8* src, s32 width, s
|
|||
|
||||
if(palette)
|
||||
{
|
||||
const tic_rgb* pal = tic->cart.palette.colors;
|
||||
const tic_rgb* pal = tic->cart.palettes.bg.colors;
|
||||
for(s32 i = 0; i < TIC_PALETTE_SIZE; i++, pal++)
|
||||
palette[i].r = pal->r, palette[i].g = pal->g, palette[i].b = pal->b;
|
||||
|
||||
|
@ -308,7 +308,10 @@ static void loadCart(tic_mem* tic, tic_cartridge* cart, const u8* buffer, s32 si
|
|||
tic->api.load(cart, buffer, size, palette);
|
||||
|
||||
if(!palette)
|
||||
memcpy(cart->palette.data, tic->config.palette.data, sizeof(tic_palette));
|
||||
{
|
||||
memcpy(cart->palettes.bg.data, tic->config.palettes.bg.data, sizeof(tic_palette));
|
||||
memcpy(cart->palettes.ovr.data, tic->config.palettes.ovr.data, sizeof(tic_palette));
|
||||
}
|
||||
}
|
||||
|
||||
static bool loadRom(tic_mem* tic, const void* data, s32 size, bool palette)
|
||||
|
@ -367,7 +370,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param)
|
|||
case 3: memcpy(&tic->cart.code, &cart->code, sizeof cart->code); break;
|
||||
case 4: memcpy(&tic->cart.sound.sfx, &cart->sound.sfx, sizeof cart->sound.sfx); break;
|
||||
case 5: memcpy(&tic->cart.sound.music, &cart->sound.music, sizeof cart->sound.music); break;
|
||||
case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof cart->palette); break;
|
||||
case 6: memcpy(&tic->cart.palettes, &cart->palettes, sizeof cart->palettes); break;
|
||||
}
|
||||
|
||||
studioRomLoaded();
|
||||
|
@ -604,7 +607,7 @@ static char* saveBinarySection(char* ptr, const char* comment, const char* tag,
|
|||
typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySection;
|
||||
static const BinarySection BinarySections[] =
|
||||
{
|
||||
{"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false},
|
||||
{"PALETTE", 2, offsetof(tic_cartridge, palettes), sizeof(tic_palette), false},
|
||||
{"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.tiles), sizeof(tic_tile), true},
|
||||
{"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.sprites), sizeof(tic_tile), true},
|
||||
{"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, gfx.map), TIC_MAP_WIDTH, true},
|
||||
|
@ -735,7 +738,8 @@ static bool loadProject(Console* console, const char* name, const char* data, s3
|
|||
if(cart)
|
||||
{
|
||||
SDL_memset(cart, 0, sizeof(tic_cartridge));
|
||||
SDL_memcpy(&cart->palette, &tic->config.palette.data, sizeof(tic_palette));
|
||||
SDL_memcpy(&cart->palettes.bg, &tic->config.palettes.bg, sizeof cart->palettes.bg);
|
||||
SDL_memcpy(&cart->palettes.ovr, &tic->config.palettes.ovr, sizeof cart->palettes.ovr);
|
||||
|
||||
const char* comment = projectComment(name);
|
||||
|
||||
|
@ -1329,7 +1333,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
|
|||
u8 src = image->buffer[x + y * image->width];
|
||||
const gif_color* c = &image->palette[src];
|
||||
tic_rgb rgb = {c->r, c->g, c->b};
|
||||
u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb);
|
||||
u8 color = tic_tool_find_closest_color(console->tic->cart.palettes.bg.colors, &rgb);
|
||||
|
||||
setSpritePixel(console->tic->cart.gfx.tiles, x, y, color);
|
||||
}
|
||||
|
@ -2741,7 +2745,7 @@ static void cmdInjectSprites(Console* console, const char* param, const char* na
|
|||
u8 src = image->buffer[x + y * image->width];
|
||||
const gif_color* c = &image->palette[src];
|
||||
tic_rgb rgb = {c->r, c->g, c->b};
|
||||
u8 color = tic_tool_find_closest_color(embed.file.palette.colors, &rgb);
|
||||
u8 color = tic_tool_find_closest_color(embed.file.palettes.bg.colors, &rgb);
|
||||
|
||||
setSpritePixel(embed.file.gfx.tiles, x, y, color);
|
||||
}
|
||||
|
@ -2847,7 +2851,7 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
|||
|
||||
if(argc > 1)
|
||||
{
|
||||
memcpy(embed.file.palette.data, tic->config.palette.data, sizeof(tic_palette));
|
||||
memcpy(&embed.file.palettes, &tic->config.palettes, sizeof embed.file.palettes);
|
||||
|
||||
if (argc == 2) cmdLoadCart(console, argv[1]);
|
||||
else if (argc == 3)
|
||||
|
|
|
@ -116,7 +116,7 @@ typedef struct
|
|||
|
||||
struct
|
||||
{
|
||||
MachineState state;
|
||||
MachineState state;
|
||||
tic_sound_register registers[TIC_SOUND_CHANNELS];
|
||||
tic_music_pos music_pos;
|
||||
tic_vram vram;
|
||||
|
|
|
@ -1133,7 +1133,7 @@ static void onStudioEvent(Map* map, StudioEvent event)
|
|||
|
||||
static void scanline(tic_mem* tic, s32 row)
|
||||
{
|
||||
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette));
|
||||
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palettes.bg.data : tic->cart.palettes.bg.data, sizeof(tic_palette));
|
||||
}
|
||||
|
||||
void initMap(Map* map, tic_mem* tic)
|
||||
|
|
10
src/sprite.c
10
src/sprite.c
|
@ -639,8 +639,8 @@ static void drawRGBSlider(Sprite* sprite, s32 x, s32 y, u8* value)
|
|||
|
||||
static void pasteColor(Sprite* sprite)
|
||||
{
|
||||
fromClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false);
|
||||
fromClipboard(&sprite->tic->cart.palette.colors[sprite->color], sizeof(tic_rgb), false);
|
||||
fromClipboard(sprite->tic->cart.palettes.bg.data, sizeof(tic_palette), false);
|
||||
fromClipboard(&sprite->tic->cart.palettes.bg.colors[sprite->color], sizeof(tic_rgb), false);
|
||||
}
|
||||
|
||||
static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
|
||||
|
@ -675,7 +675,7 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y)
|
|||
down = true;
|
||||
|
||||
if(checkMouseClick(&rect, SDL_BUTTON_LEFT))
|
||||
toClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false);
|
||||
toClipboard(sprite->tic->cart.palettes.bg.data, sizeof(tic_palette), false);
|
||||
}
|
||||
|
||||
if(down)
|
||||
|
@ -739,7 +739,7 @@ static void drawRGBSliders(Sprite* sprite, s32 x, s32 y)
|
|||
{
|
||||
enum{Gap = 6, Count = sizeof(tic_rgb)};
|
||||
|
||||
u8* data = &sprite->tic->cart.palette.data[sprite->color * Count];
|
||||
u8* data = &sprite->tic->cart.palettes.bg.data[sprite->color * Count];
|
||||
|
||||
for(s32 i = 0; i < Count; i++)
|
||||
drawRGBSlider(sprite, x, y + Gap*i, &data[i]);
|
||||
|
@ -1482,7 +1482,7 @@ static void onStudioEvent(Sprite* sprite, StudioEvent event)
|
|||
|
||||
static void scanline(tic_mem* tic, s32 row)
|
||||
{
|
||||
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette));
|
||||
memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palettes.bg.data : tic->cart.palettes.bg.data, sizeof(tic_palette));
|
||||
}
|
||||
|
||||
void initSprite(Sprite* sprite, tic_mem* tic)
|
||||
|
|
|
@ -1801,7 +1801,7 @@ static void transparentBlit(u32* out, s32 pitch)
|
|||
{
|
||||
const u8* in = studio.tic->ram.vram.screen.data;
|
||||
const u8* end = in + sizeof(studio.tic->ram.vram.screen);
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palette);
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palettes.bg);
|
||||
const u32 Delta = (pitch/sizeof *out - TIC80_WIDTH);
|
||||
|
||||
s32 col = 0;
|
||||
|
@ -1878,7 +1878,7 @@ static void recordFrame(u32* pixels)
|
|||
|
||||
if(studio.video.frame % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
||||
{
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palette);
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palettes.bg);
|
||||
drawRecordLabel(pixels, TIC80_FULLWIDTH, TIC80_WIDTH-24, 8, &pal[tic_color_red]);
|
||||
}
|
||||
|
||||
|
@ -2041,7 +2041,7 @@ static void renderCursor()
|
|||
|
||||
static void useSystemPalette()
|
||||
{
|
||||
memcpy(studio.tic->ram.vram.palette.data, studio.tic->config.palette.data, sizeof(tic_palette));
|
||||
memcpy(studio.tic->ram.vram.palette.data, studio.tic->config.palettes.bg.data, sizeof(tic_palette));
|
||||
}
|
||||
|
||||
static void renderStudio()
|
||||
|
@ -2298,7 +2298,7 @@ static void setWindowIcon()
|
|||
|
||||
u32* pixels = SDL_malloc(Size * Size * sizeof(u32));
|
||||
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palette);
|
||||
const u32* pal = tic_palette_blit(&studio.tic->config.palettes.bg);
|
||||
|
||||
for(s32 j = 0, index = 0; j < Size; j++)
|
||||
for(s32 i = 0; i < Size; i++, index++)
|
||||
|
|
|
@ -508,7 +508,7 @@ static void updateMenuItemCover(Surf* surf, const u8* cover, s32 size)
|
|||
{
|
||||
const gif_color* c = &image->palette[image->buffer[i]];
|
||||
tic_rgb rgb = { c->r, c->g, c->b };
|
||||
u8 color = tic_tool_find_closest_color(tic->config.palette.colors, &rgb);
|
||||
u8 color = tic_tool_find_closest_color(tic->config.palettes.bg.colors, &rgb);
|
||||
tic_tool_poke4(item->cover->data, i, color);
|
||||
}
|
||||
}
|
||||
|
|
24
src/tic.c
24
src/tic.c
|
@ -53,8 +53,8 @@ typedef enum
|
|||
CHUNK_TEMP3, // 8
|
||||
CHUNK_SOUND, // 9
|
||||
CHUNK_WAVEFORM, // 10
|
||||
CHUNK_TEMP4, // 11
|
||||
CHUNK_PALETTE, // 12
|
||||
CHUNK_OVR_PAL, // 11
|
||||
CHUNK_BG_PAL, // 12
|
||||
CHUNK_PATTERNS, // 13
|
||||
CHUNK_MUSIC, // 14
|
||||
|
||||
|
@ -143,7 +143,7 @@ static void runNoise(blip_buffer_t* blip, tic_sound_register* reg, tic_sound_reg
|
|||
static void resetPalette(tic_mem* memory)
|
||||
{
|
||||
static const u8 DefaultMapping[] = {16, 50, 84, 118, 152, 186, 220, 254};
|
||||
memcpy(memory->ram.vram.palette.data, memory->cart.palette.data, sizeof(tic_palette));
|
||||
memcpy(memory->ram.vram.palette.data, memory->cart.palettes.bg.data, sizeof(tic_palette));
|
||||
memcpy(memory->ram.vram.mapping, DefaultMapping, sizeof DefaultMapping);
|
||||
memset(&memory->ram.vram.vars, 0, sizeof memory->ram.vram.vars);
|
||||
memory->ram.vram.vars.mask.data = TIC_GAMEPAD_MASK;
|
||||
|
@ -1208,7 +1208,7 @@ static void api_tick_end(tic_mem* memory)
|
|||
blip_read_samples(machine->blip, machine->memory.samples.buffer, machine->samplerate / TIC_FRAMERATE);
|
||||
|
||||
machine->state.pixel = ovrPixel;
|
||||
memcpy(machine->state.ovr.palette, tic_palette_blit(&memory->cart.palette), sizeof machine->state.ovr.palette);
|
||||
memcpy(machine->state.ovr.palette, tic_palette_blit(&memory->cart.palettes.ovr), sizeof machine->state.ovr.palette);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ static void initCover(tic_mem* tic)
|
|||
{
|
||||
const gif_color* c = &image->palette[image->buffer[i]];
|
||||
tic_rgb rgb = { c->r, c->g, c->b };
|
||||
u8 color = tic_tool_find_closest_color(tic->cart.palette.colors, &rgb);
|
||||
u8 color = tic_tool_find_closest_color(tic->cart.palettes.bg.colors, &rgb);
|
||||
tic_tool_poke4(tic->ram.vram.screen.data, i, color);
|
||||
}
|
||||
}
|
||||
|
@ -1529,7 +1529,8 @@ static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palet
|
|||
if(palette)
|
||||
{
|
||||
static const u8 DB16[] = {0x14, 0x0c, 0x1c, 0x44, 0x24, 0x34, 0x30, 0x34, 0x6d, 0x4e, 0x4a, 0x4e, 0x85, 0x4c, 0x30, 0x34, 0x65, 0x24, 0xd0, 0x46, 0x48, 0x75, 0x71, 0x61, 0x59, 0x7d, 0xce, 0xd2, 0x7d, 0x2c, 0x85, 0x95, 0xa1, 0x6d, 0xaa, 0x2c, 0xd2, 0xaa, 0x99, 0x6d, 0xc2, 0xca, 0xda, 0xd4, 0x5e, 0xde, 0xee, 0xd6};
|
||||
memcpy(cart->palette.data, DB16, sizeof(tic_palette));
|
||||
memcpy(cart->palettes.bg.data, DB16, sizeof(tic_palette));
|
||||
memcpy(cart->palettes.ovr.data, DB16, sizeof(tic_palette));
|
||||
}
|
||||
|
||||
#define LOAD_CHUNK(to) memcpy(&to, buffer, min(sizeof(to), chunk.size))
|
||||
|
@ -1550,9 +1551,13 @@ static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palet
|
|||
case CHUNK_WAVEFORM: LOAD_CHUNK(cart->sound.sfx.waveform); break;
|
||||
case CHUNK_MUSIC: LOAD_CHUNK(cart->sound.music.tracks.data); break;
|
||||
case CHUNK_PATTERNS: LOAD_CHUNK(cart->sound.music.patterns.data); break;
|
||||
case CHUNK_PALETTE:
|
||||
case CHUNK_BG_PAL:
|
||||
if(palette)
|
||||
LOAD_CHUNK(cart->palette);
|
||||
LOAD_CHUNK(cart->palettes.bg);
|
||||
break;
|
||||
case CHUNK_OVR_PAL:
|
||||
if(palette)
|
||||
LOAD_CHUNK(cart->palettes.ovr);
|
||||
break;
|
||||
case CHUNK_COVER:
|
||||
LOAD_CHUNK(cart->cover.data);
|
||||
|
@ -1619,7 +1624,8 @@ static s32 api_save(const tic_cartridge* cart, u8* buffer)
|
|||
buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->sound.sfx.waveform);
|
||||
buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->sound.music.patterns.data);
|
||||
buffer = SAVE_CHUNK(CHUNK_MUSIC, cart->sound.music.tracks.data);
|
||||
buffer = SAVE_CHUNK(CHUNK_PALETTE, cart->palette);
|
||||
buffer = SAVE_CHUNK(CHUNK_BG_PAL, cart->palettes.bg);
|
||||
buffer = SAVE_CHUNK(CHUNK_OVR_PAL, cart->palettes.ovr);
|
||||
|
||||
buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue