From b13fc33aed2561c07a0d1f665ddec2b23fbdc77a Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Mon, 11 Dec 2017 11:59:14 +0300 Subject: [PATCH] no message --- src/console.c | 26 +++++++++++--------------- src/tic.c | 27 ++++++++++++++++----------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/console.c b/src/console.c index 61917e7..4a6280f 100644 --- a/src/console.c +++ b/src/console.c @@ -357,16 +357,15 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) loadCart(console->tic, cart, data, size, true); tic_mem* tic = console->tic; - // TODO: should load to the currena bank switch(i) { 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 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.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; + case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof(tic_palette)); break; } studioRomLoaded(); @@ -603,15 +602,14 @@ static char* saveBinarySection(char* ptr, const char* comment, const char* tag, typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySection; 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, 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}, + {"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false}, + {"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) @@ -1332,7 +1330,6 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v tic_rgb rgb = {c->r, c->g, c->b}; u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb); - // TODO: should be current bank setSpritePixel(console->tic->cart.bank.tiles.data, x, y, color); } @@ -1355,7 +1352,6 @@ 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.bank.map, 0, Size); SDL_memcpy(&console->tic->cart.bank.map, buffer, SDL_min(size, Size)); } diff --git a/src/tic.c b/src/tic.c index 32e1d66..61164cb 100644 --- a/src/tic.c +++ b/src/tic.c @@ -1539,17 +1539,22 @@ static double api_time(tic_mem* memory) static void api_sync(tic_mem* tic, bool toCart) { - // TODO: fix this - // if(toCart) - // { - // memcpy(&tic->cart.gfx, &tic->ram.gfx, sizeof tic->cart.gfx); - // memcpy(&tic->cart.sound, &tic->ram.sound, sizeof tic->cart.sound); - // } - // else - // { - // memcpy(&tic->ram.gfx, &tic->cart.gfx, sizeof tic->cart.gfx); - // memcpy(&tic->ram.sound, &tic->cart.sound, sizeof tic->cart.sound); - // } + if(toCart) + { + memcpy(&tic->cart.bank.tiles, &tic->ram.tiles, sizeof(tic_tiles)); + memcpy(&tic->cart.bank.sprites, &tic->ram.sprites, sizeof(tic_tiles)); + memcpy(&tic->cart.bank.map, &tic->ram.map, sizeof(tic_map)); + memcpy(&tic->cart.bank.sfx, &tic->ram.sfx, sizeof(tic_sfx)); + memcpy(&tic->cart.bank.music, &tic->ram.music, sizeof(tic_music)); + } + else + { + memcpy(&tic->ram.tiles, &tic->cart.bank.tiles, sizeof(tic_tiles)); + memcpy(&tic->ram.sprites, &tic->cart.bank.sprites, sizeof(tic_tiles)); + memcpy(&tic->ram.map, &tic->cart.bank.map, sizeof(tic_map)); + memcpy(&tic->ram.sfx, &tic->cart.bank.sfx, sizeof(tic_sfx)); + memcpy(&tic->ram.music, &tic->cart.bank.music, sizeof(tic_music)); + } } static u32 api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)