syncing vbank1 palette
@@ -175,6 +175,16 @@ static inline void sync(void* dst, void* src, s32 size, bool rev)
memcpy(dst, src, size);
}
+static inline tic_vram* vbank0(tic_core* core)
+{
+ return core->state.vbank.id ? &core->state.vbank.mem : &core->memory.ram->vram;
+}
+
+static inline tic_vram* vbank1(tic_core* core)
+{
+ return core->state.vbank.id ? &core->memory.ram->vram : &core->state.vbank.mem;
+}
+
void tic_api_sync(tic_mem* tic, u32 mask, s32 bank, bool toCart)
{
tic_core* core = (tic_core*)tic;
@@ -195,8 +205,25 @@ void tic_api_sync(tic_mem* tic, u32 mask, s32 bank, bool toCart)
assert(bank >= 0 && bank < TIC_BANKS);
for (s32 i = 0; i < Count; i++)
- if(mask & Sections[i].mask)
- sync((u8*)tic->ram + Sections[i].ram, (u8*)&tic->cart.banks[bank] + Sections[i].bank, Sections[i].size, toCart);
+ {
+ u32 sectionMask = Sections[i].mask;
+ if(mask & sectionMask)
+ {
+ tic_bank* bankPtr = &tic->cart.banks[bank];
+ s32 size = Sections[i].size;
+
+ if(sectionMask == tic_sync_palette)
+ {
+ // palette syncing is a special case where we copy both vbank0 and vbank1 palettes
+ sync(vbank0(core)->palette.data, bankPtr->palette.vbank0.data, size, toCart);
+ sync(vbank1(core)->palette.data, bankPtr->palette.vbank1.data, size, toCart);
+ }
+ else
+ {
+ sync(tic->ram->data + Sections[i].ram, (u8*)bankPtr + Sections[i].bank, size, toCart);
+ }
+ }
+ }
core->state.synced |= mask;
}
@@ -595,16 +622,6 @@ static inline void memset4(void* dst, u32 val, u32 dwords)
#endif
}
-static inline tic_vram* vbank0(tic_core* core)
-{
- return core->state.vbank.id ? &core->state.vbank.mem : &core->memory.ram->vram;
-}
-
-static inline tic_vram* vbank1(tic_core* core)
-{
- return core->state.vbank.id ? &core->memory.ram->vram : &core->state.vbank.mem;
-}
-
static inline void updpal(tic_mem* tic, tic_blitpal* pal0, tic_blitpal* pal1)
{
tic_core* core = (tic_core*)tic;
