go back to "vbank1 is always on top"
@@ -541,12 +541,12 @@ static inline void memset4(void* dst, u32 val, u32 dwords)
static inline tic_vram* vbank0(tic_core* core)
{
- return &core->memory.ram.vram;
+ 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.mem;
+ 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)
@@ -617,10 +617,12 @@ void tic_core_blit_ex(tic_mem* tic, tic_blit_callback clb)
enum{OffsetY = TIC80_HEIGHT - TIC80_MARGIN_TOP};
s32 start0 = (row - vbank0(core)->vars.offset.y + OffsetY) % TIC80_HEIGHT * TIC80_WIDTH;
s32 start1 = (row - vbank1(core)->vars.offset.y + OffsetY) % TIC80_HEIGHT * TIC80_WIDTH;
+ s32 offsetX0 = vbank0(core)->vars.offset.x;
+ s32 offsetX1 = vbank1(core)->vars.offset.x;
for(s32 x = TIC80_WIDTH; x != 2 * TIC80_WIDTH; ++x)
- *rowPtr++ = blitpix(tic, (x - vbank0(core)->vars.offset.x) % TIC80_WIDTH + start0,
- (x - vbank1(core)->vars.offset.x) % TIC80_WIDTH + start1, &pal0, &pal1);
+ *rowPtr++ = blitpix(tic, (x - offsetX0) % TIC80_WIDTH + start0,
+ (x - offsetX1) % TIC80_WIDTH + start1, &pal0, &pal1);
}
rowPtr += TIC80_MARGIN_RIGHT;
