disabled banks for the code section

This commit is contained in:
nesbox 2018-09-05 13:10:14 +03:00
parent 2bfe213f61
commit 5156daa5ab
7 changed files with 21 additions and 48 deletions

Binary file not shown.

View File

@ -259,7 +259,7 @@ static void readConfig(Config* config)
if(lua) 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); readConfigVideoLength(config, lua);
readConfigVideoScale(config, lua); readConfigVideoScale(config, lua);
@ -269,10 +269,6 @@ static void readConfig(Config* config)
readConfigCrtMonitor(config, lua); readConfigCrtMonitor(config, lua);
readConfigUiScale(config, lua); readConfigUiScale(config, lua);
readTheme(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); readConfigCrtShader(config, lua);
} }

View File

@ -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 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 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 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 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 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; 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; tic_mem* tic = console->tic;
char* stream = buffer; char* stream = buffer;
char* ptr = saveTextSection(stream, tic->cart.bank0.code.data); char* ptr = saveTextSection(stream, tic->cart.code.data);
char tag[16]; 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++) for(s32 i = 0; i < COUNT_OF(BinarySections); i++)
{ {
const BinarySection* section = &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); const char* comment = projectComment(name);
char tag[16]; 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; 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++) for(s32 i = 0; i < COUNT_OF(BinarySections); i++)
{ {
const BinarySection* section = &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; bool watch = strcmp(param, "-code-watch") == 0;
if(watch || strcmp(param, "-code") == 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) if(loaded)
{ {

View File

@ -79,7 +79,7 @@ static const char* data2md5(const void* data, s32 length)
static void initPMemName(Run* run) 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)); const char* md5 = data2md5(data, strlen(data));
strcpy(run->saveid, TIC_LOCAL); strcpy(run->saveid, TIC_LOCAL);
strcat(run->saveid, md5); strcat(run->saveid, md5);
@ -113,9 +113,9 @@ static void processDoFile(void* data, char* dst)
static const char DoFileTag[] = "dofile("; static const char DoFileTag[] = "dofile(";
enum {Size = sizeof DoFileTag - 1}; 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, ')'); const char* end = strchr(start, ')');
if(end && *start == *(end-1) && (*start == '"' || *start == '\'')) if(end && *start == *(end-1) && (*start == '"' || *start == '\''))

View File

@ -1099,7 +1099,7 @@ static void initModules()
for(s32 i = 0; i < TIC_EDITOR_BANKS; i++) 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); 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); 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); initSfx(impl.editor[i].sfx, impl.studio.tic, &tic->cart.banks[i].sfx);

View File

@ -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) 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) static void updateSaveid(tic_mem* memory)
{ {
memset(memory->saveid, 0, sizeof memory->saveid); 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) if(saveid)
{ {
strncpy(memory->saveid, saveid, TIC_SAVEID_SIZE-1); 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) if(!machine->state.initialized)
{ {
enum{CodeSize = sizeof(tic_code) * TIC_BANKS}; enum{CodeSize = sizeof(tic_code)};
char* code = malloc(CodeSize); char* code = malloc(CodeSize);
if(code) if(code)
{ {
memset(code, 0, CodeSize); memset(code, 0, CodeSize);
strcpy(code, tic->cart.code.data);
for(s32 i = TIC_BANKS - 1; i >= 0; i--)
{
const char* bankCode = tic->cart.banks[i].code.data;
if(strlen(bankCode))
strcat(code, bankCode);
}
if(data->preprocessor) if(data->preprocessor)
data->preprocessor(data->data, code); 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_TILES: LOAD_CHUNK(cart->banks[chunk.bank].tiles); break;
case CHUNK_SPRITES: LOAD_CHUNK(cart->banks[chunk.bank].sprites); 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_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_SAMPLES: LOAD_CHUNK(cart->banks[chunk.bank].sfx.samples); break;
case CHUNK_WAVEFORM: LOAD_CHUNK(cart->banks[chunk.bank].sfx.waveform); 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_MUSIC: LOAD_CHUNK(cart->banks[chunk.bank].music.tracks); break;
case CHUNK_PATTERNS: LOAD_CHUNK(cart->banks[chunk.bank].music.patterns); 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_PALETTE: LOAD_CHUNK(cart->banks[chunk.bank].palette); break;
case CHUNK_CODE:
if(chunk.bank == 0)
LOAD_CHUNK(cart->code);
break;
case CHUNK_COVER: case CHUNK_COVER:
LOAD_CHUNK(cart->cover.data); LOAD_CHUNK(cart->cover.data);
cart->cover.size = chunk.size; 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_TILES, cart->banks[i].tiles, i);
buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->banks[i].sprites, 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_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_SAMPLES, cart->banks[i].sfx.samples, i);
buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->banks[i].sfx.waveform, i); buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->banks[i].sfx.waveform, i);
buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->banks[i].music.patterns, 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_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); buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size, 0);
#undef SAVE_CHUNK #undef SAVE_CHUNK

View File

@ -337,23 +337,18 @@ typedef struct
tic_map map; tic_map map;
tic_sfx sfx; tic_sfx sfx;
tic_music music; tic_music music;
tic_code code;
tic_palette palette; tic_palette palette;
} tic_bank; } tic_bank;
typedef struct typedef struct
{ {
union union
{
struct
{ {
tic_bank bank0; tic_bank bank0;
tic_bank bank1;
};
tic_bank banks[TIC_BANKS]; tic_bank banks[TIC_BANKS];
}; };
tic_code code;
tic_cover_image cover; tic_cover_image cover;
} tic_cartridge; } tic_cartridge;