From 5156daa5ab1232447f622a387df085c4737d4e7c Mon Sep 17 00:00:00 2001 From: nesbox Date: Wed, 5 Sep 2018 13:10:14 +0300 Subject: [PATCH] disabled banks for the code section --- config.tic | Bin 22427 -> 22425 bytes src/config.c | 6 +----- src/console.c | 22 ++++------------------ src/run.c | 6 +++--- src/studio.c | 2 +- src/tic.c | 22 +++++++++------------- src/tic.h | 11 +++-------- 7 files changed, 21 insertions(+), 48 deletions(-) diff --git a/config.tic b/config.tic index 100417b6333094c7a7e56c102eca0a2ea0ad86e6..362aa0ae3908fe656dda03567593c831e7db82fd 100644 GIT binary patch delta 30 mcmbQeo^j@S#toBPnXU_Lp5nTJiHVDAbE&5q-)0vNT}A-7lnQGA delta 32 ocmbQao^kei#toBPnbtFHp5nTJX>(4PE+dPo8Xv=EHxD&F0L--tf&c&j diff --git a/src/config.c b/src/config.c index 30a27a6..f132175 100644 --- a/src/config.c +++ b/src/config.c @@ -259,7 +259,7 @@ static void readConfig(Config* config) if(lua) { - if(luaL_loadstring(lua, config->cart.bank0.code.data) == LUA_OK && lua_pcall(lua, 0, LUA_MULTRET, 0) == LUA_OK) + if(luaL_loadstring(lua, config->cart.code.data) == LUA_OK && lua_pcall(lua, 0, LUA_MULTRET, 0) == LUA_OK) { readConfigVideoLength(config, lua); readConfigVideoScale(config, lua); @@ -269,10 +269,6 @@ static void readConfig(Config* config) readConfigCrtMonitor(config, lua); readConfigUiScale(config, lua); readTheme(config, lua); - } - - if(luaL_loadstring(lua, config->cart.bank1.code.data) == LUA_OK && lua_pcall(lua, 0, LUA_MULTRET, 0) == LUA_OK) - { readConfigCrtShader(config, lua); } diff --git a/src/console.c b/src/console.c index 8755eef..adaaf1b 100644 --- a/src/console.c +++ b/src/console.c @@ -428,7 +428,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) case 0: memcpy(&tic->cart.cover, &cart->cover, sizeof cart->cover); break; case 1: memcpy(&tic->cart.bank0.tiles, &cart->bank0.tiles, sizeof(tic_tiles)*2); break; case 2: memcpy(&tic->cart.bank0.map, &cart->bank0.map, sizeof(tic_map)); break; - case 3: memcpy(&tic->cart.bank0.code, &cart->bank0.code, sizeof(tic_code)); break; + case 3: memcpy(&tic->cart.code, &cart->code, sizeof(tic_code)); break; case 4: memcpy(&tic->cart.bank0.sfx, &cart->bank0.sfx, sizeof(tic_sfx)); break; case 5: memcpy(&tic->cart.bank0.music, &cart->bank0.music, sizeof(tic_music)); break; case 6: memcpy(&tic->cart.bank0.palette, &cart->bank0.palette, sizeof(tic_palette)); break; @@ -779,15 +779,9 @@ static s32 saveProject(Console* console, void* buffer, const char* comment) tic_mem* tic = console->tic; char* stream = buffer; - char* ptr = saveTextSection(stream, tic->cart.bank0.code.data); + char* ptr = saveTextSection(stream, tic->cart.code.data); char tag[16]; - for(s32 b = 1; b < TIC_BANKS; b++) - { - makeTag("CODE", tag, b); - ptr = saveTextSectionBank(ptr, comment, tag, tic->cart.banks[b].code.data); - } - for(s32 i = 0; i < COUNT_OF(BinarySections); i++) { const BinarySection* section = &BinarySections[i]; @@ -946,17 +940,9 @@ static bool loadProject(Console* console, const char* name, const char* data, s3 const char* comment = projectComment(name); char tag[16]; - if(loadTextSection(project, comment, cart->bank0.code.data, sizeof(tic_code))) + if(loadTextSection(project, comment, cart->code.data, sizeof(tic_code))) done = true; - for(s32 b = 1; b < TIC_BANKS; b++) - { - makeTag("CODE", tag, b); - - if(loadTextSectionBank(project, comment, tag, cart->banks[b].code.data, sizeof(tic_code))) - done = true; - } - for(s32 i = 0; i < COUNT_OF(BinarySections); i++) { const BinarySection* section = &BinarySections[i]; @@ -2894,7 +2880,7 @@ static bool cmdInjectCode(Console* console, const char* param, const char* name) bool watch = strcmp(param, "-code-watch") == 0; if(watch || strcmp(param, "-code") == 0) { - bool loaded = loadFileIntoBuffer(console, console->embed.file->bank0.code.data, name); + bool loaded = loadFileIntoBuffer(console, console->embed.file->code.data, name); if(loaded) { diff --git a/src/run.c b/src/run.c index ef47f7c..29c750b 100644 --- a/src/run.c +++ b/src/run.c @@ -79,7 +79,7 @@ static const char* data2md5(const void* data, s32 length) static void initPMemName(Run* run) { - const char* data = strlen(run->tic->saveid) ? run->tic->saveid : run->tic->cart.bank0.code.data; + const char* data = strlen(run->tic->saveid) ? run->tic->saveid : run->tic->cart.code.data; const char* md5 = data2md5(data, strlen(data)); strcpy(run->saveid, TIC_LOCAL); strcat(run->saveid, md5); @@ -113,9 +113,9 @@ static void processDoFile(void* data, char* dst) static const char DoFileTag[] = "dofile("; enum {Size = sizeof DoFileTag - 1}; - if (memcmp(tic->cart.bank0.code.data, DoFileTag, Size) == 0) + if (memcmp(tic->cart.code.data, DoFileTag, Size) == 0) { - const char* start = tic->cart.bank0.code.data + Size; + const char* start = tic->cart.code.data + Size; const char* end = strchr(start, ')'); if(end && *start == *(end-1) && (*start == '"' || *start == '\'')) diff --git a/src/studio.c b/src/studio.c index a080c93..dc67ec9 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1099,7 +1099,7 @@ static void initModules() for(s32 i = 0; i < TIC_EDITOR_BANKS; i++) { - initCode(impl.editor[i].code, impl.studio.tic, &tic->cart.banks[i].code); + initCode(impl.editor[i].code, impl.studio.tic, &tic->cart.code); initSprite(impl.editor[i].sprite, impl.studio.tic, &tic->cart.banks[i].tiles); initMap(impl.editor[i].map, impl.studio.tic, &tic->cart.banks[i].map); initSfx(impl.editor[i].sfx, impl.studio.tic, &tic->cart.banks[i].sfx); diff --git a/src/tic.c b/src/tic.c index 28f5299..f99b5ed 100644 --- a/src/tic.c +++ b/src/tic.c @@ -1599,13 +1599,13 @@ static const tic_script_config* getScriptConfig(const char* code) static const tic_script_config* api_get_script_config(tic_mem* memory) { - return getScriptConfig(memory->cart.bank0.code.data); + return getScriptConfig(memory->cart.code.data); } static void updateSaveid(tic_mem* memory) { memset(memory->saveid, 0, sizeof memory->saveid); - const char* saveid = readMetatag(memory->cart.bank0.code.data, "saveid", api_get_script_config(memory)->singleComment); + const char* saveid = readMetatag(memory->cart.code.data, "saveid", api_get_script_config(memory)->singleComment); if(saveid) { strncpy(memory->saveid, saveid, TIC_SAVEID_SIZE-1); @@ -1621,20 +1621,13 @@ static void api_tick(tic_mem* tic, tic_tick_data* data) if(!machine->state.initialized) { - enum{CodeSize = sizeof(tic_code) * TIC_BANKS}; + enum{CodeSize = sizeof(tic_code)}; char* code = malloc(CodeSize); if(code) { memset(code, 0, CodeSize); - - for(s32 i = TIC_BANKS - 1; i >= 0; i--) - { - const char* bankCode = tic->cart.banks[i].code.data; - - if(strlen(bankCode)) - strcat(code, bankCode); - } + strcpy(code, tic->cart.code.data); if(data->preprocessor) data->preprocessor(data->data, code); @@ -1802,12 +1795,15 @@ static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palet case CHUNK_TILES: LOAD_CHUNK(cart->banks[chunk.bank].tiles); break; case CHUNK_SPRITES: LOAD_CHUNK(cart->banks[chunk.bank].sprites); break; case CHUNK_MAP: LOAD_CHUNK(cart->banks[chunk.bank].map); break; - case CHUNK_CODE: LOAD_CHUNK(cart->banks[chunk.bank].code); break; case CHUNK_SAMPLES: LOAD_CHUNK(cart->banks[chunk.bank].sfx.samples); break; case CHUNK_WAVEFORM: LOAD_CHUNK(cart->banks[chunk.bank].sfx.waveform); break; case CHUNK_MUSIC: LOAD_CHUNK(cart->banks[chunk.bank].music.tracks); break; case CHUNK_PATTERNS: LOAD_CHUNK(cart->banks[chunk.bank].music.patterns); break; case CHUNK_PALETTE: LOAD_CHUNK(cart->banks[chunk.bank].palette); break; + case CHUNK_CODE: + if(chunk.bank == 0) + LOAD_CHUNK(cart->code); + break; case CHUNK_COVER: LOAD_CHUNK(cart->cover.data); cart->cover.size = chunk.size; @@ -1870,7 +1866,6 @@ static s32 api_save(const tic_cartridge* cart, u8* buffer) buffer = SAVE_CHUNK(CHUNK_TILES, cart->banks[i].tiles, i); buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->banks[i].sprites, i); buffer = SAVE_CHUNK(CHUNK_MAP, cart->banks[i].map, i); - buffer = SAVE_CHUNK(CHUNK_CODE, cart->banks[i].code, i); buffer = SAVE_CHUNK(CHUNK_SAMPLES, cart->banks[i].sfx.samples, i); buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->banks[i].sfx.waveform, i); buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->banks[i].music.patterns, i); @@ -1878,6 +1873,7 @@ static s32 api_save(const tic_cartridge* cart, u8* buffer) buffer = SAVE_CHUNK(CHUNK_PALETTE, cart->banks[i].palette, i); } + buffer = SAVE_CHUNK(CHUNK_CODE, cart->code, 0); buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size, 0); #undef SAVE_CHUNK diff --git a/src/tic.h b/src/tic.h index 19b5738..741d9a4 100644 --- a/src/tic.h +++ b/src/tic.h @@ -337,7 +337,6 @@ typedef struct tic_map map; tic_sfx sfx; tic_music music; - tic_code code; tic_palette palette; } tic_bank; @@ -345,15 +344,11 @@ typedef struct { union { - struct - { - tic_bank bank0; - tic_bank bank1; - }; - + tic_bank bank0; tic_bank banks[TIC_BANKS]; }; - + + tic_code code; tic_cover_image cover; } tic_cartridge;