From 948072341894322ed9d9c8bab6bbbd2c7b721ddc Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 20 Oct 2017 09:36:54 +0300 Subject: [PATCH] no message --- src/sprite.c | 6 ++++++ src/sprite.h | 3 ++- src/studio.c | 40 ++++++++++++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/sprite.c b/src/sprite.c index 290cc14..52fb9d6 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1483,6 +1483,11 @@ static void onStudioEvent(Sprite* sprite, StudioEvent event) } } +static void scanline(tic_mem* tic, s32 row) +{ + memcpy(tic->ram.vram.palette.data, row < (TOOLBAR_SIZE-1) ? tic->config.palette.data : tic->cart.palette.data, sizeof(tic_palette)); +} + void initSprite(Sprite* sprite, tic_mem* tic) { if(sprite->select.back == NULL) sprite->select.back = (u8*)SDL_malloc(CANVAS_SIZE*CANVAS_SIZE); @@ -1511,5 +1516,6 @@ void initSprite(Sprite* sprite, tic_mem* tic) .mode = SPRITE_DRAW_MODE, .history = history_create(tic->cart.gfx.tiles, TIC_SPRITES * sizeof(tic_tile)), .event = onStudioEvent, + .scanline = scanline, }; } \ No newline at end of file diff --git a/src/sprite.h b/src/sprite.h index 815781b..f12bba5 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -60,7 +60,8 @@ struct Sprite struct History* history; void (*tick)(Sprite*); - void(*event)(Sprite*, StudioEvent); + void (*event)(Sprite*, StudioEvent); + void (*scanline)(tic_mem* tic, s32 row); }; void initSprite(Sprite*, tic_mem*); \ No newline at end of file diff --git a/src/studio.c b/src/studio.c index a7b6242..ab5b7a0 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1413,20 +1413,33 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch) u32* row = out; const u32* pal = srcPaletteBlit(studio.tic->cart.palette.data); + void(*scanline)(tic_mem* memory, s32 row) = NULL; + + switch(studio.mode) + { + case TIC_RUN_MODE: + scanline = studio.tic->api.scanline; + break; + case TIC_SPRITE_MODE: + scanline = studio.sprite.scanline; + break; + default: + break; + } + for(s32 r = 0, pos = 0; r < TIC80_HEIGHT; r++, row += pitchWidth) { - - if(studio.mode == TIC_RUN_MODE || studio.mode == TIC_MENU_MODE) + if(scanline) { - studio.tic->api.scanline(studio.tic, r); - pal = paletteBlit(); + scanline(studio.tic, r); + pal = paletteBlit(); + } - if(bgOut) - { - u8 border = tic_tool_peek4(studio.tic->ram.vram.mapping, studio.tic->ram.vram.vars.border & 0xf); - SDL_memset4(bgOut, pal[border], TIC80_WIDTH); - bgOut += bgPitchWidth; - } + if(bgOut) + { + u8 border = tic_tool_peek4(studio.tic->ram.vram.mapping, studio.tic->ram.vram.vars.border & 0xf); + SDL_memset4(bgOut, pal[border], TIC80_WIDTH); + bgOut += bgPitchWidth; } SDL_memset4(row, 0, pitchWidth); @@ -2022,6 +2035,13 @@ static void renderStudio() } studio.tic->api.tick_start(studio.tic, src); + + switch(studio.mode) + { + case TIC_RUN_MODE: break; + default: + memcpy(studio.tic->ram.vram.palette.data, studio.tic->config.palette.data, sizeof(tic_palette)); + } } switch(studio.mode)