diff --git a/src/console.c b/src/console.c index 60ef368..61917e7 100644 --- a/src/console.c +++ b/src/console.c @@ -360,12 +360,12 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) // TODO: should load to the currena bank switch(i) { - case 0: memcpy(&tic->cart.banks[0].tiles, &cart->banks[0].tiles, sizeof(tic_tiles)*2); break; - case 1: memcpy(&tic->cart.banks[0].map, &cart->banks[0].map, sizeof(tic_map)); break; + case 0: memcpy(&tic->cart.bank.tiles, &cart->bank.tiles, sizeof(tic_tiles)*2); break; + case 1: memcpy(&tic->cart.bank.map, &cart->bank.map, sizeof(tic_map)); break; case 2: memcpy(&tic->cart.cover, &cart->cover, sizeof cart->cover); break; case 3: memcpy(&tic->cart.code, &cart->code, sizeof cart->code); break; - case 4: memcpy(&tic->cart.banks[0].sfx, &cart->banks[0].sfx, sizeof(tic_sfx)); break; - case 5: memcpy(&tic->cart.banks[0].music, &cart->banks[0].music, sizeof(tic_music)); break; + case 4: memcpy(&tic->cart.bank.sfx, &cart->bank.sfx, sizeof(tic_sfx)); break; + case 5: memcpy(&tic->cart.bank.music, &cart->bank.music, sizeof(tic_music)); break; case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof(tic_palette)); break; } @@ -605,13 +605,13 @@ static const BinarySection BinarySections[] = { // TODO: fix banks loading here {"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false}, - {"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, banks->tiles), sizeof(tic_tile), true}, - {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, banks->sprites), sizeof(tic_tile), true}, - {"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, banks->map), TIC_MAP_WIDTH, true}, - {"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge, banks->sfx.waveform.envelopes), sizeof(tic_waveform), true}, - {"SFX", SFX_COUNT, offsetof(tic_cartridge, banks->sfx.data), sizeof(tic_sound_effect), true}, - {"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, banks->music.patterns), sizeof(tic_track_pattern), true}, - {"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, banks->music.tracks), sizeof(tic_track), true}, + {"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, bank.tiles), sizeof(tic_tile), true}, + {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, bank.sprites), sizeof(tic_tile), true}, + {"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, bank.map), TIC_MAP_WIDTH, true}, + {"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge, bank.sfx.waveform.envelopes), sizeof(tic_waveform), true}, + {"SFX", SFX_COUNT, offsetof(tic_cartridge, bank.sfx.data), sizeof(tic_sound_effect), true}, + {"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, bank.music.patterns), sizeof(tic_track_pattern), true}, + {"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, bank.music.tracks), sizeof(tic_track), true}, }; static s32 saveProject(Console* console, void* buffer, const char* comment) @@ -1333,7 +1333,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb); // TODO: should be current bank - setSpritePixel(console->tic->cart.banks[0].tiles.data, x, y, color); + setSpritePixel(console->tic->cart.bank.tiles.data, x, y, color); } gif_close(image); @@ -1356,8 +1356,8 @@ static void injectMap(Console* console, const void* buffer, s32 size) enum {Size = sizeof(tic_map)}; // TODO: should be current bank - SDL_memset(&console->tic->cart.banks[0].map, 0, Size); - SDL_memcpy(&console->tic->cart.banks[0].map, buffer, SDL_min(size, Size)); + SDL_memset(&console->tic->cart.bank.map, 0, Size); + SDL_memcpy(&console->tic->cart.bank.map, buffer, SDL_min(size, Size)); } static void onImportMap(const char* name, const void* buffer, size_t size, void* data) @@ -1457,7 +1457,7 @@ static void exportSprites(Console* console) { for (s32 y = 0; y < Height; y++) for (s32 x = 0; x < Width; x++) - data[x + y * Width] = getSpritePixel(console->tic->cart.banks[0].tiles.data, x, y); + data[x + y * Width] = getSpritePixel(console->tic->cart.bank.tiles.data, x, y); s32 size = 0; if((size = writeGifData(console->tic, buffer, data, Width, Height))) @@ -1497,7 +1497,7 @@ static void exportMap(Console* console) if(buffer) { - SDL_memcpy(buffer, console->tic->cart.banks[0].map.data, Size); + SDL_memcpy(buffer, console->tic->cart.bank.map.data, Size); fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console); } } @@ -2768,7 +2768,7 @@ static bool cmdInjectSprites(Console* console, const char* param, const char* na tic_rgb rgb = {c->r, c->g, c->b}; u8 color = tic_tool_find_closest_color(embed.file.palette.colors, &rgb); - setSpritePixel(embed.file.banks[0].tiles.data, x, y, color); + setSpritePixel(embed.file.bank.tiles.data, x, y, color); } gif_close(image); diff --git a/src/dialog.c b/src/dialog.c index 2912be3..a61c16b 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -170,7 +170,7 @@ static void drawDialog(Dialog* dlg) { u8 chromakey = 14; - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 2, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 2, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); } { diff --git a/src/map.c b/src/map.c index 855cdea..d9600ce 100644 --- a/src/map.c +++ b/src/map.c @@ -314,7 +314,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y) { s32 tx = 0, ty = 0; getMouseMap(map, &tx, &ty); - index = map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].map, tx, ty); + index = map->tic->api.map_get(map->tic, &map->tic->cart.bank.map, tx, ty); } } @@ -397,7 +397,7 @@ static void drawSheetOvr(Map* map, s32 x, s32 y) for(s32 j = 0, index = 0; j < rect.h; j += TIC_SPRITESIZE) for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++) - map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].tiles, index, x + i, y + j, NULL, 0); + map->tic->api.sprite(map->tic, &map->tic->cart.bank.tiles, index, x + i, y + j, NULL, 0); { s32 bx = map->sheet.rect.x * TIC_SPRITESIZE - 1 + x; @@ -437,7 +437,7 @@ static void setMapSprite(Map* map, s32 x, s32 y) for(s32 j = 0; j < map->sheet.rect.h; j++) for(s32 i = 0; i < map->sheet.rect.w; i++) - map->tic->api.map_set(map->tic, &map->tic->cart.banks[0].map, (x+i)%TIC_MAP_WIDTH, (y+j)%TIC_MAP_HEIGHT, (mx+i) + (my+j) * SHEET_COLS); + map->tic->api.map_set(map->tic, &map->tic->cart.bank.map, (x+i)%TIC_MAP_WIDTH, (y+j)%TIC_MAP_HEIGHT, (mx+i) + (my+j) * SHEET_COLS); history_add(map->history); } @@ -470,7 +470,7 @@ static void drawTileCursor(Map* map) for(s32 j = 0, ty=my; j < map->sheet.rect.h; j++, ty+=TIC_SPRITESIZE) for(s32 i = 0, tx=mx; i < map->sheet.rect.w; i++, tx+=TIC_SPRITESIZE) - map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].tiles, (sx+i) + (sy+j) * SHEET_COLS, tx, ty, NULL, 0); + map->tic->api.sprite(map->tic, &map->tic->cart.bank.tiles, (sx+i) + (sy+j) * SHEET_COLS, tx, ty, NULL, 0); } drawCursorPos(map, mx, my); @@ -512,7 +512,7 @@ static void processMouseDrawMode(Map* map) { s32 tx = 0, ty = 0; getMouseMap(map, &tx, &ty); - s32 index = map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].map, tx, ty); + s32 index = map->tic->api.map_get(map->tic, &map->tic->cart.bank.map, tx, ty); map->sheet.rect = (SDL_Rect){index % SHEET_COLS, index / SHEET_COLS, 1, 1}; } @@ -593,7 +593,7 @@ static void drawPasteData(Map* map) for(s32 j = 0; j < h; j++) for(s32 i = 0; i < w; i++) - map->tic->api.map_set(map->tic, &map->tic->cart.banks[0].map, (mx+i)%TIC_MAP_WIDTH, (my+j)%TIC_MAP_HEIGHT, data[i + j * w]); + map->tic->api.map_set(map->tic, &map->tic->cart.bank.map, (mx+i)%TIC_MAP_WIDTH, (my+j)%TIC_MAP_HEIGHT, data[i + j * w]); history_add(map->history); @@ -612,7 +612,7 @@ static void drawPasteData(Map* map) for(s32 j = 0; j < h; j++) for(s32 i = 0; i < w; i++) - map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].tiles, data[i + j * w], mx + i*TIC_SPRITESIZE, my + j*TIC_SPRITESIZE, NULL, 0); + map->tic->api.sprite(map->tic, &map->tic->cart.bank.tiles, data[i + j * w], mx + i*TIC_SPRITESIZE, my + j*TIC_SPRITESIZE, NULL, 0); } } @@ -764,7 +764,7 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile) { for(s32 j = 0; j < map->sheet.rect.h; j++) for(s32 i = 0; i < map->sheet.rect.w; i++) - map->tic->api.map_set(map->tic, &map->tic->cart.banks[0].map, x+i, y+j, (mx+i) + (my+j) * SHEET_COLS); + map->tic->api.map_set(map->tic, &map->tic->cart.bank.map, x+i, y+j, (mx+i) + (my+j) * SHEET_COLS); for(s32 i = 0; i < COUNT_OF(dx); i++) { @@ -776,7 +776,7 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile) bool match = true; for(s32 j = 0; j < map->sheet.rect.h; j++) for(s32 i = 0; i < map->sheet.rect.w; i++) - if(map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].map, nx+i, ny+j) != tile) + if(map->tic->api.map_get(map->tic, &map->tic->cart.bank.map, nx+i, ny+j) != tile) match = false; if(match) @@ -801,7 +801,7 @@ static void processMouseFillMode(Map* map) s32 tx = 0, ty = 0; getMouseMap(map, &tx, &ty); - fillMap(map, tx, ty, map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].map, tx, ty)); + fillMap(map, tx, ty, map->tic->api.map_get(map->tic, &map->tic->cart.bank.map, tx, ty)); history_add(map->history); } } @@ -864,7 +864,7 @@ static void drawMapOvr(Map* map) s32 scrollX = map->scroll.x % TIC_SPRITESIZE; s32 scrollY = map->scroll.y % TIC_SPRITESIZE; - map->tic->api.map(map->tic, &map->tic->cart.banks[0].map, &map->tic->cart.banks[0].tiles, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE, + map->tic->api.map(map->tic, &map->tic->cart.bank.map, &map->tic->cart.bank.tiles, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE, TIC_MAP_SCREEN_WIDTH + 1, TIC_MAP_SCREEN_HEIGHT + 1, -scrollX, -scrollY, -1, 1); if(map->canvas.grid || map->scroll.active) @@ -950,7 +950,7 @@ static void copySelectionToClipboard(Map* map) normalizeMapRect(&x, &y); s32 index = x + y * TIC_MAP_WIDTH; - *ptr++ = map->tic->cart.banks[0].map.data[index]; + *ptr++ = map->tic->cart.bank.map.data[index]; } toClipboard(buffer, size, true); @@ -978,7 +978,7 @@ static void deleteSelection(Map* map) normalizeMapRect(&x, &y); s32 index = x + y * TIC_MAP_WIDTH; - map->tic->cart.banks[0].map.data[index] = 0; + map->tic->cart.bank.map.data[index] = 0; } history_add(map->history); @@ -1185,7 +1185,7 @@ void initMap(Map* map, tic_mem* tic) .gesture = false, .start = {0, 0}, }, - .history = history_create(&tic->cart.banks[0].map, sizeof(tic_map)), + .history = history_create(&tic->cart.bank.map, sizeof(tic_map)), .event = onStudioEvent, .overlap = overlap, }; diff --git a/src/menu.c b/src/menu.c index c81612b..935ce3a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -124,7 +124,7 @@ static void drawDialog(Menu* menu) { u8 chromakey = 14; - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 0, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 0, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); } } @@ -209,7 +209,7 @@ static void drawPlayerButtons(Menu* menu, s32 x, s32 y) if(menu->gamepad.selected == index && menu->ticks % TIC_FRAMERATE < TIC_FRAMERATE / 2) continue; - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); s32 code = codes[index]; char label[32]; diff --git a/src/music.c b/src/music.c index 6fa2eed..620b128 100644 --- a/src/music.c +++ b/src/music.c @@ -215,7 +215,7 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value, static tic_track* getTrack(Music* music) { - return &music->tic->cart.banks[0].music.tracks.data[music->track]; + return &music->tic->cart.bank.music.tracks.data[music->track]; } static s32 getRows(Music* music) @@ -368,7 +368,7 @@ static tic_track_pattern* getPattern(Music* music, s32 channel) { s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel); - return patternId ? &music->tic->cart.banks[0].music.patterns.data[patternId - PATTERN_START] : NULL; + return patternId ? &music->tic->cart.bank.music.patterns.data[patternId - PATTERN_START] : NULL; } static tic_track_pattern* getChannelPattern(Music* music) @@ -1327,7 +1327,7 @@ static void drawTumbler(Music* music, s32 x, s32 y, s32 index) } u8 color = Chroma; - tic->api.sprite(tic, &tic->config.banks[0].tiles, music->tracker.patterns[index] ? On : Off, x, y, &color, 1); + tic->api.sprite(tic, &tic->config.bank.tiles, music->tracker.patterns[index] ? On : Off, x, y, &color, 1); } static void drawTracker(Music* music, s32 x, s32 y) @@ -1643,7 +1643,7 @@ void initMusic(Music* music, tic_mem* tic) }, .tab = MUSIC_TRACKER_TAB, - .history = history_create(&tic->cart.banks[0].music, sizeof(tic_music)), + .history = history_create(&tic->cart.bank.music, sizeof(tic_music)), .event = onStudioEvent, }; diff --git a/src/sfx.c b/src/sfx.c index bc3a371..b8efdba 100644 --- a/src/sfx.c +++ b/src/sfx.c @@ -106,7 +106,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi static tic_sound_effect* getEffect(Sfx* sfx) { - return sfx->tic->cart.banks[0].sfx.data + sfx->index; + return sfx->tic->cart.bank.sfx.data + sfx->index; } static void setIndex(Sfx* sfx, s32 delta) @@ -169,7 +169,7 @@ static void drawLoopPanel(Sfx* sfx, s32 x, s32 y) static tic_waveform* getWaveformById(Sfx* sfx, s32 i) { - return &sfx->tic->cart.banks[0].sfx.waveform.envelopes[i]; + return &sfx->tic->cart.bank.sfx.waveform.envelopes[i]; } static tic_waveform* getWaveform(Sfx* sfx) @@ -1058,8 +1058,8 @@ void initSfx(Sfx* sfx, tic_mem* tic) .tab = SFX_ENVELOPES_TAB, .history = { - .envelope = history_create(&tic->cart.banks[0].sfx.data, sizeof tic->cart.banks[0].sfx.data), - .waveform = history_create(&tic->cart.banks[0].sfx.waveform, sizeof tic->cart.banks[0].sfx.waveform), + .envelope = history_create(&tic->cart.bank.sfx.data, sizeof tic->cart.bank.sfx.data), + .waveform = history_create(&tic->cart.bank.sfx.waveform, sizeof tic->cart.bank.sfx.waveform), }, .event = onStudioEvent, }; diff --git a/src/sprite.c b/src/sprite.c index 6c7dc2f..6366f36 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -33,12 +33,12 @@ static u8 getSheetPixel(Sprite* sprite, s32 x, s32 y) { - return getSpritePixel(sprite->tic->cart.banks[0].tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y); + return getSpritePixel(sprite->tic->cart.bank.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y); } static void setSheetPixel(Sprite* sprite, s32 x, s32 y, u8 color) { - setSpritePixel(sprite->tic->cart.banks[0].tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y, color); + setSpritePixel(sprite->tic->cart.bank.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y, color); } static s32 getIndexPosX(Sprite* sprite) @@ -940,7 +940,7 @@ static void drawSheetOvr(Sprite* sprite, s32 x, s32 y) for(s32 j = 0, index = (sprite->index - sprite->index % TIC_BANK_SPRITES); j < rect.h; j += TIC_SPRITESIZE) for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++) - sprite->tic->api.sprite(sprite->tic, &sprite->tic->cart.banks[0].tiles, index, x + i, y + j, NULL, 0); + sprite->tic->api.sprite(sprite->tic, &sprite->tic->cart.bank.tiles, index, x + i, y + j, NULL, 0); { s32 bx = getIndexPosX(sprite) + x - 1; s32 by = getIndexPosY(sprite) + y - 1; @@ -1551,7 +1551,7 @@ void initSprite(Sprite* sprite, tic_mem* tic) .front = sprite->select.front, }, .mode = SPRITE_DRAW_MODE, - .history = history_create(&tic->cart.banks[0].tiles, TIC_SPRITES * sizeof(tic_tile)), + .history = history_create(&tic->cart.bank.tiles, TIC_SPRITES * sizeof(tic_tile)), .event = onStudioEvent, .overlap = overlap, }; diff --git a/src/studio.c b/src/studio.c index cff9da7..c8eb9e8 100644 --- a/src/studio.c +++ b/src/studio.c @@ -278,7 +278,7 @@ static struct void playSystemSfx(s32 id) { - const tic_sound_effect* effect = &studio.tic->config.banks[0].sfx.data[id]; + const tic_sound_effect* effect = &studio.tic->config.bank.sfx.data[id]; studio.tic->api.sfx_ex(studio.tic, id, effect->note, effect->octave, -1, 0, MAX_VOLUME, 0); } @@ -2049,7 +2049,7 @@ static void renderCursor() SDL_ShowCursor(getConfig()->theme.cursor.sprite >= 0 ? SDL_DISABLE : SDL_ENABLE); if(getConfig()->theme.cursor.sprite >= 0) - blitCursor(studio.tic->config.banks[0].tiles.data[getConfig()->theme.cursor.sprite].data); + blitCursor(studio.tic->config.bank.tiles.data[getConfig()->theme.cursor.sprite].data); } static void useSystemPalette() @@ -2104,12 +2104,12 @@ static void renderStudio() case TIC_DIALOG_MODE: case TIC_MENU_MODE: case TIC_SURF_MODE: - sfx = &studio.tic->config.banks[0].sfx; - music = &studio.tic->config.banks[0].music; + sfx = &studio.tic->config.bank.sfx; + music = &studio.tic->config.bank.music; break; default: - sfx = &studio.tic->cart.banks[0].sfx; - music = &studio.tic->cart.banks[0].music; + sfx = &studio.tic->cart.bank.sfx; + music = &studio.tic->cart.bank.music; } studio.tic->api.tick_start(studio.tic, sfx, music); @@ -2283,7 +2283,7 @@ static void initTouchGamepad() if (!studio.renderer) return; - studio.tic->api.map(studio.tic, &studio.tic->config.banks[0].map, &studio.tic->config.banks[0].tiles, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, -1, 1); + studio.tic->api.map(studio.tic, &studio.tic->config.bank.map, &studio.tic->config.bank.tiles, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, -1, 1); if(!studio.gamepad.texture) { @@ -2310,7 +2310,7 @@ static void updateSystemFont() for(s32 i = 0; i < TIC_FONT_CHARS; i++) for(s32 y = 0; y < TIC_SPRITESIZE; y++) for(s32 x = 0; x < TIC_SPRITESIZE; x++) - if(tic_tool_peek4(&studio.tic->config.banks[0].sprites.data[i], TIC_SPRITESIZE*(y+1) - x-1)) + if(tic_tool_peek4(&studio.tic->config.bank.sprites.data[i], TIC_SPRITESIZE*(y+1) - x-1)) studio.tic->font.data[i*BITS_IN_BYTE+y] |= 1 << x; } @@ -2335,7 +2335,7 @@ static void setWindowIcon() for(s32 j = 0, index = 0; j < Size; j++) for(s32 i = 0; i < Size; i++, index++) { - u8 color = getSpritePixel(studio.tic->config.banks[0].tiles.data, i/Scale, j/Scale); + u8 color = getSpritePixel(studio.tic->config.bank.tiles.data, i/Scale, j/Scale); pixels[index] = color == ColorKey ? 0 : pal[color]; } diff --git a/src/surf.c b/src/surf.c index 07b3605..83083fd 100644 --- a/src/surf.c +++ b/src/surf.c @@ -202,14 +202,14 @@ static void drawTopToolbar(Surf* surf, s32 x, s32 y) enum{Gap = 10, TipX = 150, SelectWidth = 54}; u8 colorkey = 0; - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); { static const char Label[] = "SELECT"; tic->api.text(tic, Label, TipX + Gap, y+3, tic_color_black); tic->api.text(tic, Label, TipX + Gap, y+2, tic_color_white); } - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); { static const char Label[] = "BACK"; tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black); @@ -244,7 +244,7 @@ static void drawBottomToolbar(Surf* surf, s32 x, s32 y) u8 colorkey = 0; - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); { static const char Label[] = "WEBSITE"; tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black); @@ -355,7 +355,7 @@ static void drawBG(Surf* surf) for(s32 j = 0; j < Height + 1; j++) for(s32 i = 0; i < Width + 1; i++) if(counter++ % 2) - tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 34, i*Size - offset, j*Size - offset, 2, 2, 0, 0, 1, tic_no_flip, tic_no_rotate); + tic->api.sprite_ex(tic, &tic->config.bank.tiles, 34, i*Size - offset, j*Size - offset, 2, 2, 0, 0, 1, tic_no_flip, tic_no_rotate); } static void replace(char* src, const char* what, const char* with) diff --git a/src/tic.c b/src/tic.c index 3dc63e8..32e1d66 100644 --- a/src/tic.c +++ b/src/tic.c @@ -1325,12 +1325,12 @@ static void initCover(tic_mem* tic) static void cart2ram(tic_mem* memory) { - memcpy(&memory->ram.tiles, &memory->cart.banks[0].tiles, sizeof(tic_tiles)); - memcpy(&memory->ram.sprites, &memory->cart.banks[0].sprites, sizeof(tic_tiles)); - memcpy(&memory->ram.map, &memory->cart.banks[0].map, sizeof(tic_tiles)); + memcpy(&memory->ram.tiles, &memory->cart.bank.tiles, sizeof(tic_tiles)); + memcpy(&memory->ram.sprites, &memory->cart.bank.sprites, sizeof(tic_tiles)); + memcpy(&memory->ram.map, &memory->cart.bank.map, sizeof(tic_tiles)); - memcpy(&memory->ram.sfx, &memory->cart.banks[0].sfx, sizeof(tic_sfx)); - memcpy(&memory->ram.music, &memory->cart.banks[0].music, sizeof(tic_music)); + memcpy(&memory->ram.sfx, &memory->cart.bank.sfx, sizeof(tic_sfx)); + memcpy(&memory->ram.music, &memory->cart.bank.music, sizeof(tic_music)); initCover(memory); } @@ -1595,14 +1595,14 @@ static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palet switch(chunk.type) { - case CHUNK_TILES: LOAD_CHUNK(cart->banks[0].tiles); break; - case CHUNK_SPRITES: LOAD_CHUNK(cart->banks[0].sprites); break; - case CHUNK_MAP: LOAD_CHUNK(cart->banks[0].map); break; + case CHUNK_TILES: LOAD_CHUNK(cart->bank.tiles); break; + case CHUNK_SPRITES: LOAD_CHUNK(cart->bank.sprites); break; + case CHUNK_MAP: LOAD_CHUNK(cart->bank.map); break; case CHUNK_CODE: LOAD_CHUNK(cart->code); break; - case CHUNK_SOUND: LOAD_CHUNK(cart->banks[0].sfx.data); break; - case CHUNK_WAVEFORM: LOAD_CHUNK(cart->banks[0].sfx.waveform); break; - case CHUNK_MUSIC: LOAD_CHUNK(cart->banks[0].music.tracks.data); break; - case CHUNK_PATTERNS: LOAD_CHUNK(cart->banks[0].music.patterns.data); break; + case CHUNK_SOUND: LOAD_CHUNK(cart->bank.sfx.data); break; + case CHUNK_WAVEFORM: LOAD_CHUNK(cart->bank.sfx.waveform); break; + case CHUNK_MUSIC: LOAD_CHUNK(cart->bank.music.tracks.data); break; + case CHUNK_PATTERNS: LOAD_CHUNK(cart->bank.music.patterns.data); break; case CHUNK_PALETTE: if(palette) LOAD_CHUNK(cart->palette); @@ -1664,14 +1664,14 @@ static s32 api_save(const tic_cartridge* cart, u8* buffer) #define SAVE_CHUNK(id, from) saveChunk(buffer, id, &from, sizeof(from)) - buffer = SAVE_CHUNK(CHUNK_TILES, cart->banks[0].tiles); - buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->banks[0].sprites); - buffer = SAVE_CHUNK(CHUNK_MAP, cart->banks[0].map); + buffer = SAVE_CHUNK(CHUNK_TILES, cart->bank.tiles); + buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->bank.sprites); + buffer = SAVE_CHUNK(CHUNK_MAP, cart->bank.map); buffer = SAVE_CHUNK(CHUNK_CODE, cart->code); - buffer = SAVE_CHUNK(CHUNK_SOUND, cart->banks[0].sfx.data); - buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->banks[0].sfx.waveform); - buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->banks[0].music.patterns.data); - buffer = SAVE_CHUNK(CHUNK_MUSIC, cart->banks[0].music.tracks.data); + buffer = SAVE_CHUNK(CHUNK_SOUND, cart->bank.sfx.data); + buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->bank.sfx.waveform); + buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->bank.music.patterns.data); + buffer = SAVE_CHUNK(CHUNK_MUSIC, cart->bank.music.tracks.data); 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 c91dc8c..d02e7bf 100644 --- a/src/tic.h +++ b/src/tic.h @@ -337,7 +337,12 @@ typedef struct typedef struct { - tic_bank banks[TIC_BANKS]; + union + { + tic_bank bank; + tic_bank banks[TIC_BANKS]; + }; + tic_code code; tic_cover_image cover; tic_palette palette; diff --git a/src/world.c b/src/world.c index 89c7587..614a32a 100644 --- a/src/world.c +++ b/src/world.c @@ -105,13 +105,13 @@ void initWorld(World* world, tic_mem* tic, Map* map) for(s32 i = 0; i < TIC80_WIDTH * TIC80_HEIGHT; i++) { - u8 index = tic->cart.banks[0].map.data[i]; + u8 index = tic->cart.bank.map.data[i]; if(index) { SDL_memset(colors, 0, sizeof colors); - tic_tile* tile = &tic->cart.banks[0].tiles.data[index]; + tic_tile* tile = &tic->cart.bank.tiles.data[index]; for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++) {