added cover saving
This commit is contained in:
parent
af7469a2d7
commit
9442d59243
|
@ -1651,8 +1651,6 @@ static const BinarySection BinarySections[] =
|
||||||
{"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true},
|
{"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true},
|
||||||
{"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true},
|
{"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true},
|
||||||
{"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, sound.music.tracks), sizeof(tic_track), true},
|
{"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, sound.music.tracks), sizeof(tic_track), true},
|
||||||
|
|
||||||
// TODO: add cover
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static CartSaveResult saveProject(Console* console, const char* name)
|
static CartSaveResult saveProject(Console* console, const char* name)
|
||||||
|
@ -1675,6 +1673,8 @@ static CartSaveResult saveProject(Console* console, const char* name)
|
||||||
ptr = saveBinarySection(ptr, section->tag, section->count, (u8*)&tic->cart + section->offset, section->size, section->flip);
|
ptr = saveBinarySection(ptr, section->tag, section->count, (u8*)&tic->cart + section->offset, section->size, section->flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveBinarySection(ptr, "COVER", 1, &tic->cart.cover, tic->cart.cover.size + sizeof(s32), true);
|
||||||
|
|
||||||
name = getProjectName(name);
|
name = getProjectName(name);
|
||||||
|
|
||||||
s32 size = strlen(stream);
|
s32 size = strlen(stream);
|
||||||
|
@ -1776,19 +1776,27 @@ static void loadBinarySection(const char* project, const char* tag, s32 count, v
|
||||||
{
|
{
|
||||||
const char* ptr = start;
|
const char* ptr = start;
|
||||||
|
|
||||||
while(ptr < end)
|
if(size > 0)
|
||||||
{
|
{
|
||||||
char lineStr[] = "999";
|
while(ptr < end)
|
||||||
memcpy(lineStr, ptr + strlen("-- "), strlen(lineStr));
|
|
||||||
|
|
||||||
s32 index = SDL_atoi(lineStr);
|
|
||||||
|
|
||||||
if(index < count)
|
|
||||||
{
|
{
|
||||||
ptr += strlen("-- 999:");
|
static char lineStr[] = "999";
|
||||||
str2buf(ptr, size*2, (u8*)dst + size*index, flip);
|
memcpy(lineStr, ptr + sizeof("-- ") - 1, sizeof lineStr - 1);
|
||||||
ptr += size*2 + 1;
|
|
||||||
}
|
s32 index = SDL_atoi(lineStr);
|
||||||
|
|
||||||
|
if(index < count)
|
||||||
|
{
|
||||||
|
ptr += sizeof("-- 999:") - 1;
|
||||||
|
str2buf(ptr, size*2, (u8*)dst + size*index, flip);
|
||||||
|
ptr += size*2 + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ptr += sizeof("-- 999:") - 1;
|
||||||
|
str2buf(ptr, end - ptr, (u8*)dst, flip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1821,6 +1829,8 @@ static bool loadProject(Console* console, const char* data, s32 size)
|
||||||
const BinarySection* section = &BinarySections[i];
|
const BinarySection* section = &BinarySections[i];
|
||||||
loadBinarySection(project, section->tag, section->count, (u8*)cart + section->offset, section->size, section->flip);
|
loadBinarySection(project, section->tag, section->count, (u8*)cart + section->offset, section->size, section->flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadBinarySection(project, "COVER", 1, &cart->cover, -1, true);
|
||||||
|
|
||||||
SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge));
|
SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue