no message

This commit is contained in:
BADIM-PC\Vadim 2017-11-02 22:29:31 +03:00
parent 20f7e6a437
commit eb1352256d
4 changed files with 59 additions and 31 deletions

View File

@ -1775,7 +1775,7 @@ static void onConsoleRamCommand(Console* console, const char* param)
ADDR_RECORD(console->tic->ram.vram.screen, "SCREEN"), ADDR_RECORD(console->tic->ram.vram.screen, "SCREEN"),
ADDR_RECORD(console->tic->ram.vram.palette, "PALETTE"), ADDR_RECORD(console->tic->ram.vram.palette, "PALETTE"),
ADDR_RECORD(console->tic->ram.vram.mapping, "PALETTE MAP"), ADDR_RECORD(console->tic->ram.vram.mapping, "PALETTE MAP"),
ADDR_RECORD(console->tic->ram.vram.vars.border, "BORDER COLOR"), ADDR_RECORD(console->tic->ram.vram.vars.colors, "BORDER/BG COLOR"),
ADDR_RECORD(console->tic->ram.vram.vars.offset, "SCREEN OFFSET"), ADDR_RECORD(console->tic->ram.vram.vars.offset, "SCREEN OFFSET"),
ADDR_RECORD(console->tic->ram.vram.vars.mask, "GAMEPAD MASK"), ADDR_RECORD(console->tic->ram.vram.vars.mask, "GAMEPAD MASK"),
ADDR_RECORD(console->tic->ram.vram.input.gamepad, "GAMEPAD"), ADDR_RECORD(console->tic->ram.vram.input.gamepad, "GAMEPAD"),

View File

@ -52,8 +52,6 @@
#define MAX_CONTROLLERS 4 #define MAX_CONTROLLERS 4
#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888 #define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888
#define MAX_OFFSET 128
#define FULL_WIDTH (TIC80_WIDTH + MAX_OFFSET*2)
#define FRAME_SIZE (TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32)) #define FRAME_SIZE (TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32))
typedef struct typedef struct
@ -1401,10 +1399,20 @@ static u32* paletteBlit()
return srcPaletteBlit(studio.tic->ram.vram.palette.data); return srcPaletteBlit(studio.tic->ram.vram.palette.data);
} }
inline s32 clamp(s32 a, s32 b, s32 val)
{
if(val < a) return a;
if(val > b) return b;
return val;
}
static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch) static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
{ {
tic_mem* tic = studio.tic;
const s32 pitchWidth = pitch/sizeof *out; const s32 pitchWidth = pitch/sizeof *out;
const s32 bgPitchWidth = bgPitch/sizeof *bgOut; // const s32 bgPitchWidth = bgPitch/sizeof *bgOut;
u32* row = out; u32* row = out;
const u32* pal = paletteBlit(); const u32* pal = paletteBlit();
@ -1413,7 +1421,7 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
switch(studio.mode) switch(studio.mode)
{ {
case TIC_RUN_MODE: case TIC_RUN_MODE:
scanline = studio.tic->api.scanline; scanline = tic->api.scanline;
break; break;
case TIC_SPRITE_MODE: case TIC_SPRITE_MODE:
scanline = studio.sprite.scanline; scanline = studio.sprite.scanline;
@ -1425,25 +1433,42 @@ static void blit(u32* out, u32* bgOut, s32 pitch, s32 bgPitch)
break; break;
} }
for(s32 r = 0, pos = 0; r < TIC80_HEIGHT; r++, row += pitchWidth) for(s32 r = 0; r < TIC80_HEIGHT; r++, row += pitchWidth)
{ {
if(scanline) if(scanline)
{ {
scanline(studio.tic, r); scanline(tic, r);
pal = paletteBlit(); pal = paletteBlit();
} }
if(bgOut) // if(bgOut)
// {
// u8 border = tic_tool_peek4(tic->ram.vram.mapping, tic->ram.vram.vars.border & 0xf);
// SDL_memset4(bgOut, pal[border], TIC80_WIDTH);
// bgOut += bgPitchWidth;
// }
SDL_memset4(row, pal[tic->ram.vram.vars.bg], pitchWidth);
s32 actualRow = r - tic->ram.vram.vars.offset.y;
if(actualRow >= TIC80_HEIGHT || actualRow < 0)
continue;
s32 pos = actualRow * TIC80_WIDTH;
if(tic->ram.vram.vars.offset.x == 0)
for(u32* ptr = row, c = 0; c < TIC80_WIDTH; c++, ptr++)
*ptr = pal[tic_tool_peek4(tic->ram.vram.screen.data, pos++)];
else
for(u32* ptr = row, c = 0; c < TIC80_WIDTH; c++, ptr++)
{ {
u8 border = tic_tool_peek4(studio.tic->ram.vram.mapping, studio.tic->ram.vram.vars.border & 0xf); s32 x = c + tic->ram.vram.vars.offset.x;
SDL_memset4(bgOut, pal[border], TIC80_WIDTH);
bgOut += bgPitchWidth; if(x < 0 || x >= TIC80_WIDTH) continue;
*ptr = pal[tic_tool_peek4(tic->ram.vram.screen.data, x + pos)];
} }
SDL_memset4(row, 0, pitchWidth);
for(u32* ptr = row + MAX_OFFSET + studio.tic->ram.vram.vars.offset.x, c = 0; c < TIC80_WIDTH; c++, ptr++)
*ptr = pal[tic_tool_peek4(studio.tic->ram.vram.screen.data, pos++)];
} }
} }
@ -1451,7 +1476,7 @@ static void screen2buffer(u32* buffer, const u8* pixels, s32 pitch)
{ {
for(s32 i = 0; i < TIC80_HEIGHT; i++) for(s32 i = 0; i < TIC80_HEIGHT; i++)
{ {
SDL_memcpy(buffer, pixels+MAX_OFFSET * sizeof(u32), TIC80_WIDTH * sizeof(u32)); SDL_memcpy(buffer, pixels, TIC80_WIDTH * sizeof(u32));
pixels += pitch; pixels += pitch;
buffer += TIC80_WIDTH; buffer += TIC80_WIDTH;
} }
@ -1461,7 +1486,7 @@ static void setCoverImage()
{ {
if(studio.mode == TIC_RUN_MODE) if(studio.mode == TIC_RUN_MODE)
{ {
enum {Pitch = FULL_WIDTH*sizeof(u32)}; enum {Pitch = TIC80_WIDTH*sizeof(u32)};
u32* pixels = SDL_malloc(Pitch * TIC80_HEIGHT); u32* pixels = SDL_malloc(Pitch * TIC80_HEIGHT);
if(pixels) if(pixels)
@ -1863,7 +1888,7 @@ static void drawRecordLabel(u8* frame, s32 pitch, s32 sx, s32 sy, const u32* col
for(s32 x = 0; x < sizeof RecLabel[0]*BITS_IN_BYTE; x++) for(s32 x = 0; x < sizeof RecLabel[0]*BITS_IN_BYTE; x++)
{ {
if(RecLabel[y] & (1 << x)) if(RecLabel[y] & (1 << x))
memcpy(&frame[((MAX_OFFSET + sx) + 15 - x + (y+sy)*(pitch/4))*4], color, sizeof *color); memcpy(&frame[(sx + 15 - x + (y+sy)*(pitch/4))*4], color, sizeof *color);
} }
} }
} }
@ -1897,9 +1922,7 @@ static void blitTexture()
SDL_Rect rect = {0, 0, 0, 0}; SDL_Rect rect = {0, 0, 0, 0};
calcTextureRect(&rect); calcTextureRect(&rect);
const s32 Pixel = rect.w / TIC80_WIDTH; rect.w = rect.w * TIC80_WIDTH / TIC80_WIDTH;
rect.x -= MAX_OFFSET * Pixel;
rect.w = rect.w * FULL_WIDTH / TIC80_WIDTH;
void* pixels = NULL; void* pixels = NULL;
s32 pitch = 0; s32 pitch = 0;
@ -1907,8 +1930,6 @@ static void blitTexture()
if(studio.mode == TIC_RUN_MODE) if(studio.mode == TIC_RUN_MODE)
{ {
rect.y += studio.tic->ram.vram.vars.offset.y * Pixel;
{ {
void* bgPixels = NULL; void* bgPixels = NULL;
s32 bgPitch = 0; s32 bgPitch = 0;
@ -1929,7 +1950,7 @@ static void blitTexture()
SDL_UnlockTexture(studio.texture); SDL_UnlockTexture(studio.texture);
{ {
SDL_Rect srcRect = {0, 0, FULL_WIDTH, TIC80_HEIGHT}; SDL_Rect srcRect = {0, 0, TIC80_WIDTH, TIC80_HEIGHT};
SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect); SDL_RenderCopy(studio.renderer, studio.texture, &srcRect, &rect);
} }
} }
@ -2371,11 +2392,7 @@ static void onFSInitialized(FileSystem* fs)
studio.renderer = SDL_CreateRenderer(studio.window, -1, renderFlags); studio.renderer = SDL_CreateRenderer(studio.window, -1, renderFlags);
studio.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING, studio.texture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
textureLog2(FULL_WIDTH), textureLog2(TIC80_HEIGHT)); textureLog2(TIC80_WIDTH), textureLog2(TIC80_HEIGHT));
#if !defined(__ARM_LINUX__)
SDL_SetTextureBlendMode(studio.texture, SDL_BLENDMODE_BLEND);
#endif
studio.borderTexture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING, studio.borderTexture = SDL_CreateTexture(studio.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING,
textureLog2(TIC80_WIDTH), textureLog2(TIC80_HEIGHT)); textureLog2(TIC80_WIDTH), textureLog2(TIC80_HEIGHT));

View File

@ -493,6 +493,8 @@ static void api_clear(tic_mem* memory, u8 color)
{ {
api_rect(memory, machine->state.clip.l, machine->state.clip.t, machine->state.clip.r - machine->state.clip.l, machine->state.clip.b - machine->state.clip.t, color); api_rect(memory, machine->state.clip.l, machine->state.clip.t, machine->state.clip.r - machine->state.clip.l, machine->state.clip.b - machine->state.clip.t, color);
} }
memory->ram.vram.vars.bg = color & 0xf;
} }
static s32 drawChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale) static s32 drawChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale)

View File

@ -355,7 +355,16 @@ typedef union
struct struct
{ {
u8 border; union
{
u8 colors;
struct
{
u8 border:TIC_PALETTE_BPP;
u8 bg:TIC_PALETTE_BPP;
};
};
struct struct
{ {