diff --git a/src/studio.c b/src/studio.c index f76ac42..90ab75a 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1430,29 +1430,47 @@ static void blit(u32* out) break; } + if(scanline) + { + scanline(tic, 0); + pal = paletteBlit(); + } + + enum {Top = (TIC80_FULLHEIGHT-TIC80_HEIGHT)/2, Bottom = Top}; + enum {Left = (TIC80_FULLWIDTH-TIC80_WIDTH)/2, Right = Left}; + + SDL_memset4(&out[0 * TEXTURE_SIZE], pal[tic->ram.vram.vars.border], TEXTURE_SIZE*Top); + for(s32 r = 0; r < TIC80_HEIGHT; r++) { - if(scanline) + SDL_memset4(&out[(r+Top) * TEXTURE_SIZE], pal[tic->ram.vram.vars.border], Left); + SDL_memset4(&out[(r+Top) * TEXTURE_SIZE + Left], pal[tic->ram.vram.vars.bg], TIC80_WIDTH); + { - scanline(tic, r); + s32 y = r + tic->ram.vram.vars.offset.y; + + if(y < 0 || y >= TIC80_HEIGHT) continue; + + for(s32 c = 0; c < TIC80_WIDTH; c++) + { + s32 x = c + tic->ram.vram.vars.offset.x; + + if(x < 0 || x >= TIC80_WIDTH) continue; + + out[(c + Left) + (r+Top) * TEXTURE_SIZE] = pal[tic_tool_peek4(tic->ram.vram.screen.data, x + y * TIC80_WIDTH)]; + } + } + + SDL_memset4(&out[(r+Top) * TEXTURE_SIZE + (TIC80_FULLWIDTH-Right)], pal[tic->ram.vram.vars.border], Right); + + if(scanline && (r < TIC80_HEIGHT-1)) + { + scanline(tic, r+1); pal = paletteBlit(); } - - SDL_memset4(&out[r * TEXTURE_SIZE], pal[tic->ram.vram.vars.bg], TEXTURE_SIZE); - - s32 y = r + tic->ram.vram.vars.offset.y; - - if(y < 0 || y >= TIC80_HEIGHT) continue; - - for(s32 c = 0; c < TIC80_WIDTH; c++) - { - s32 x = c + tic->ram.vram.vars.offset.x; - - if(x < 0 || x >= TIC80_WIDTH) continue; - - out[c + r * TEXTURE_SIZE] = pal[tic_tool_peek4(tic->ram.vram.screen.data, x + y * TIC80_WIDTH)]; - } } + + SDL_memset4(&out[(TIC80_FULLHEIGHT-Bottom) * TEXTURE_SIZE], pal[tic->ram.vram.vars.border], TEXTURE_SIZE*Bottom); } static void screen2buffer(u32* buffer, const u8* pixels, s32 pitch)