From b46be919d49321e965d0e65a3608514e30249fa4 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 30 Nov 2017 16:42:06 +0300 Subject: [PATCH] Revert "added OVR palette" This reverts commit 68a89c742142ab9ab5bfc0b4142ed3fba1eedae3. --- src/console.c | 20 ++++++++------------ src/machine.h | 2 +- src/map.c | 2 +- src/sprite.c | 10 +++++----- src/studio.c | 8 ++++---- src/surf.c | 2 +- src/tic.c | 24 +++++++++--------------- src/tic.h | 7 +------ 8 files changed, 30 insertions(+), 45 deletions(-) diff --git a/src/console.c b/src/console.c index d55d8ce..5c6f74c 100644 --- a/src/console.c +++ b/src/console.c @@ -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.palettes.bg.colors; + const tic_rgb* pal = tic->cart.palette.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,10 +308,7 @@ 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->palettes.bg.data, tic->config.palettes.bg.data, sizeof(tic_palette)); - memcpy(cart->palettes.ovr.data, tic->config.palettes.ovr.data, sizeof(tic_palette)); - } + memcpy(cart->palette.data, tic->config.palette.data, sizeof(tic_palette)); } static bool loadRom(tic_mem* tic, const void* data, s32 size, bool palette) @@ -370,7 +367,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.palettes, &cart->palettes, sizeof cart->palettes); break; + case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof cart->palette); break; } studioRomLoaded(); @@ -607,7 +604,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", 2, offsetof(tic_cartridge, palettes), sizeof(tic_palette), false}, + {"PALETTE", 1, offsetof(tic_cartridge, palette.data), 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}, @@ -738,8 +735,7 @@ static bool loadProject(Console* console, const char* name, const char* data, s3 if(cart) { SDL_memset(cart, 0, sizeof(tic_cartridge)); - 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); + SDL_memcpy(&cart->palette, &tic->config.palette.data, sizeof(tic_palette)); const char* comment = projectComment(name); @@ -1333,7 +1329,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.palettes.bg.colors, &rgb); + u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb); setSpritePixel(console->tic->cart.gfx.tiles, x, y, color); } @@ -2745,7 +2741,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.palettes.bg.colors, &rgb); + u8 color = tic_tool_find_closest_color(embed.file.palette.colors, &rgb); setSpritePixel(embed.file.gfx.tiles, x, y, color); } @@ -2851,7 +2847,7 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config, if(argc > 1) { - memcpy(&embed.file.palettes, &tic->config.palettes, sizeof embed.file.palettes); + memcpy(embed.file.palette.data, tic->config.palette.data, sizeof(tic_palette)); if (argc == 2) cmdLoadCart(console, argv[1]); else if (argc == 3) diff --git a/src/machine.h b/src/machine.h index 726112e..060889c 100644 --- a/src/machine.h +++ b/src/machine.h @@ -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; diff --git a/src/map.c b/src/map.c index 4975ea3..4c4538d 100644 --- a/src/map.c +++ b/src/map.c @@ -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.palettes.bg.data : tic->cart.palettes.bg.data, sizeof(tic_palette)); + memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette)); } void initMap(Map* map, tic_mem* tic) diff --git a/src/sprite.c b/src/sprite.c index 1e0957e..fe9b7d1 100644 --- a/src/sprite.c +++ b/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.palettes.bg.data, sizeof(tic_palette), false); - fromClipboard(&sprite->tic->cart.palettes.bg.colors[sprite->color], sizeof(tic_rgb), false); + fromClipboard(sprite->tic->cart.palette.data, sizeof(tic_palette), false); + fromClipboard(&sprite->tic->cart.palette.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.palettes.bg.data, sizeof(tic_palette), false); + toClipboard(sprite->tic->cart.palette.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.palettes.bg.data[sprite->color * Count]; + u8* data = &sprite->tic->cart.palette.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.palettes.bg.data : tic->cart.palettes.bg.data, sizeof(tic_palette)); + memcpy(tic->ram.vram.palette.data, row < TOOLBAR_SIZE ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette)); } void initSprite(Sprite* sprite, tic_mem* tic) diff --git a/src/studio.c b/src/studio.c index 51845a6..a0d36ed 100644 --- a/src/studio.c +++ b/src/studio.c @@ -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.palettes.bg); + const u32* pal = tic_palette_blit(&studio.tic->config.palette); 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.palettes.bg); + const u32* pal = tic_palette_blit(&studio.tic->config.palette); 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.palettes.bg.data, sizeof(tic_palette)); + memcpy(studio.tic->ram.vram.palette.data, studio.tic->config.palette.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.palettes.bg); + const u32* pal = tic_palette_blit(&studio.tic->config.palette); for(s32 j = 0, index = 0; j < Size; j++) for(s32 i = 0; i < Size; i++, index++) diff --git a/src/surf.c b/src/surf.c index 100f9b1..6d8ff81 100644 --- a/src/surf.c +++ b/src/surf.c @@ -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.palettes.bg.colors, &rgb); + u8 color = tic_tool_find_closest_color(tic->config.palette.colors, &rgb); tic_tool_poke4(item->cover->data, i, color); } } diff --git a/src/tic.c b/src/tic.c index f39d5d7..97ae82a 100644 --- a/src/tic.c +++ b/src/tic.c @@ -53,8 +53,8 @@ typedef enum CHUNK_TEMP3, // 8 CHUNK_SOUND, // 9 CHUNK_WAVEFORM, // 10 - CHUNK_OVR_PAL, // 11 - CHUNK_BG_PAL, // 12 + CHUNK_TEMP4, // 11 + CHUNK_PALETTE, // 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.palettes.bg.data, sizeof(tic_palette)); + memcpy(memory->ram.vram.palette.data, memory->cart.palette.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.palettes.ovr), sizeof machine->state.ovr.palette); + memcpy(machine->state.ovr.palette, tic_palette_blit(&memory->cart.palette), 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.palettes.bg.colors, &rgb); + u8 color = tic_tool_find_closest_color(tic->cart.palette.colors, &rgb); tic_tool_poke4(tic->ram.vram.screen.data, i, color); } } @@ -1529,8 +1529,7 @@ 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->palettes.bg.data, DB16, sizeof(tic_palette)); - memcpy(cart->palettes.ovr.data, DB16, sizeof(tic_palette)); + memcpy(cart->palette.data, DB16, sizeof(tic_palette)); } #define LOAD_CHUNK(to) memcpy(&to, buffer, min(sizeof(to), chunk.size)) @@ -1551,13 +1550,9 @@ 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_BG_PAL: + case CHUNK_PALETTE: if(palette) - LOAD_CHUNK(cart->palettes.bg); - break; - case CHUNK_OVR_PAL: - if(palette) - LOAD_CHUNK(cart->palettes.ovr); + LOAD_CHUNK(cart->palette); break; case CHUNK_COVER: LOAD_CHUNK(cart->cover.data); @@ -1624,8 +1619,7 @@ 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_BG_PAL, cart->palettes.bg); - buffer = SAVE_CHUNK(CHUNK_OVR_PAL, cart->palettes.ovr); + buffer = SAVE_CHUNK(CHUNK_PALETTE, cart->palette); buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size); diff --git a/src/tic.h b/src/tic.h index deda730..c68cb35 100644 --- a/src/tic.h +++ b/src/tic.h @@ -338,12 +338,7 @@ typedef struct tic_sound sound; tic_code code; tic_cover_image cover; - - struct - { - tic_palette bg; - tic_palette ovr; - } palettes; + tic_palette palette; } tic_cartridge; typedef struct