diff --git a/src/studio.c b/src/studio.c index a760fd1..837435a 100644 --- a/src/studio.c +++ b/src/studio.c @@ -74,6 +74,15 @@ typedef struct } MouseState; +static const EditorMode Modes[] = +{ + TIC_CODE_MODE, + TIC_SPRITE_MODE, + TIC_MAP_MODE, + TIC_SFX_MODE, + TIC_MUSIC_MODE, +}; + static struct { tic80_local* tic80local; @@ -147,7 +156,21 @@ static struct struct { bool show; - s32 index; + + union + { + struct + { + s32 code; + s32 tiles; + s32 map; + s32 sfx; + s32 music; + } index; + + s32 indexes[COUNT_OF(Modes)]; + }; + } bank; struct @@ -260,7 +283,6 @@ static struct .bank = { .show = false, - .index = 0, }, .popup = @@ -288,6 +310,41 @@ static struct .floatSamples = NULL, }; +tic_tiles* getBankTiles() +{ + return &studio.tic->cart.banks[studio.bank.index.tiles].tiles; +} + +tic_tiles* getBankSprites() +{ + return &studio.tic->cart.banks[studio.bank.index.tiles].sprites; +} + +tic_map* getBankMap() +{ + return &studio.tic->cart.banks[studio.bank.index.map].map; +} + +tic_sfx* getBankSfx() +{ + return &studio.tic->cart.banks[studio.bank.index.sfx].sfx; +} + +tic_music* getBankMusic() +{ + return &studio.tic->cart.banks[studio.bank.index.music].music; +} + +tic_code* getBankCode() +{ + return &studio.tic->cart.banks[studio.bank.index.code].code; +} + +tic_palette* getBankPalette() +{ + return &studio.tic->cart.banks[studio.bank.index.tiles].palette; +} + void playSystemSfx(s32 id) { const tic_sound_effect* effect = &studio.tic->config.sfx.data[id]; @@ -429,15 +486,6 @@ void showTooltip(const char* text) strcpy(studio.tooltip.text, text); } -static const EditorMode Modes[] = -{ - TIC_CODE_MODE, - TIC_SPRITE_MODE, - TIC_MAP_MODE, - TIC_SFX_MODE, - TIC_MUSIC_MODE, -}; - static void drawExtrabar(tic_mem* tic) { enum {Size = 7}; @@ -553,6 +601,14 @@ static void drawBankIcon(s32 x, s32 y) }; bool over = false; + s32 mode = 0; + + for(s32 i = 0; i < COUNT_OF(Modes); i++) + if(Modes[i] == studio.mode) + { + mode = i; + break; + } if(checkMousePos(&rect)) { @@ -583,15 +639,15 @@ static void drawBankIcon(s32 x, s32 y) over = true; if(checkMouseClick(&rect, SDL_BUTTON_LEFT)) - studio.bank.index = i; + studio.bank.indexes[mode] = i; } - if(i == studio.bank.index) + if(i == studio.bank.indexes[mode]) { tic->api.rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red); } - tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == studio.bank.index ? tic_color_white : over ? tic_color_red : tic_color_peach); + tic->api.draw_char(tic, '0' + i, rect.x+1, rect.y+1, i == studio.bank.indexes[mode] ? tic_color_white : over ? tic_color_red : tic_color_peach); } } else diff --git a/src/studio.h b/src/studio.h index 73b43e5..33f7bae 100644 --- a/src/studio.h +++ b/src/studio.h @@ -199,3 +199,11 @@ void gotoCode(); void gotoSurf(); void exitFromGameMenu(); void runProject(); + +tic_tiles* getBankTiles(); +tic_tiles* getBankSprites(); +tic_map* getBankMap(); +tic_sfx* getBankSfx(); +tic_music* getBankMusic(); +tic_code* getBankCode(); +tic_palette* getBankPalette();