no message

This commit is contained in:
BADIM-PC\Vadim 2017-11-30 13:10:20 +03:00
parent f578428381
commit e3ad17f609
7 changed files with 46 additions and 25 deletions

View File

@ -142,7 +142,7 @@ int main(int argc, char **argv)
void* pixels = NULL;
int pitch = 0;
SDL_LockTexture(texture, NULL, &pixels, &pitch);
SDL_memcpy(pixels, tic->screen, sizeof tic->screen);
SDL_memcpy(pixels, tic->screen, TIC80_FULLWIDTH * TIC80_FULLHEIGHT);
SDL_UnlockTexture(texture);
SDL_RenderCopy(renderer, texture, NULL, NULL);
}

View File

@ -49,7 +49,7 @@ typedef struct
s32 count;
} sound;
u32 screen[TIC80_FULLWIDTH * TIC80_FULLHEIGHT];
u32* screen;
} tic80;

View File

@ -83,7 +83,11 @@ typedef struct
} music;
tic_scanline scanline;
tic_overlap overlap;
void (*pixel)(tic_mem* memory, s32 x, s32 y, u8 color);
u32 overlapPalette[TIC_PALETTE_SIZE];
bool initialized;
} MachineState;

View File

@ -1448,11 +1448,8 @@ static void setCoverImage()
if(studio.mode == TIC_RUN_MODE)
{
enum {Pitch = TIC80_FULLWIDTH*sizeof(u32)};
u32* pixels = SDL_malloc(Pitch * TIC80_FULLHEIGHT);
if(pixels)
{
tic->api.blit(tic, pixels, tic->api.scanline, tic->api.overlap);
tic->api.blit(tic, tic->api.scanline, tic->api.overlap);
u32* buffer = SDL_malloc(TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32));
@ -1460,7 +1457,7 @@ static void setCoverImage()
{
SDL_Rect rect = {OFFSET_LEFT, OFFSET_TOP, TIC80_WIDTH, TIC80_HEIGHT};
screen2buffer(buffer, pixels, rect);
screen2buffer(buffer, tic->screen, rect);
gif_write_animation(studio.tic->cart.cover.data, &studio.tic->cart.cover.size,
TIC80_WIDTH, TIC80_HEIGHT, (const u8*)buffer, 1, TIC_FRAMERATE, 1);
@ -1469,9 +1466,6 @@ static void setCoverImage()
showPopupMessage("COVER IMAGE SAVED :)");
}
SDL_free(pixels);
}
}
}
@ -1950,7 +1944,8 @@ static void blitTexture()
break;
}
tic->api.blit(tic, pixels, scanline, overlap);
tic->api.blit(tic, scanline, overlap);
SDL_memcpy(pixels, tic->screen, sizeof tic->screen);
recordFrame(pixels);

View File

@ -149,11 +149,26 @@ static void resetPalette(tic_mem* memory)
memory->ram.vram.vars.mask.data = TIC_GAMEPAD_MASK;
}
static inline void setPixel(tic_machine* machine, s32 x, s32 y, u8 color)
static void dmaPixel(tic_mem* tic, s32 x, s32 y, u8 color)
{
tic_tool_poke4(tic->ram.vram.screen.data, y * TIC80_WIDTH + x, tic_tool_peek4(tic->ram.vram.mapping, color & 0xf));
}
static void overlapPixel(tic_mem* tic, s32 x, s32 y, u8 color)
{
tic_machine* machine = (tic_machine*)tic;
enum {Top = (TIC80_FULLHEIGHT-TIC80_HEIGHT)/2, Bottom = Top};
enum {Left = (TIC80_FULLWIDTH-TIC80_WIDTH)/2, Right = Left};
tic->screen[x + Left + (y + Top) * TIC80_FULLWIDTH] = machine->state.overlapPalette[tic_tool_peek4(tic->ram.vram.mapping, color & 0xf)];
}
static void setPixel(tic_machine* machine, s32 x, s32 y, u8 color)
{
if(x < machine->state.clip.l || y < machine->state.clip.t || x >= machine->state.clip.r || y >= machine->state.clip.b) return;
tic_tool_poke4(machine->memory.ram.vram.screen.data, y * TIC80_WIDTH + x, tic_tool_peek4(machine->memory.ram.vram.mapping, color & 0xf));
machine->state.pixel(&machine->memory, x, y, color);
}
static u8 getPixel(tic_machine* machine, s32 x, s32 y)
@ -432,6 +447,8 @@ static void api_reset(tic_mem* memory)
machine->state.scanline = NULL;
machine->state.overlap = NULL;
machine->state.pixel = dmaPixel;
updateSaveid(memory);
}
@ -1655,8 +1672,9 @@ static u32* paletteBlit(tic_mem* tic)
return pal;
}
static void api_blit(tic_mem* tic, u32* out, tic_scanline scanline, tic_overlap overlap)
static void api_blit(tic_mem* tic, tic_scanline scanline, tic_overlap overlap)
{
u32* out = tic->screen;
const u32* pal = paletteBlit(tic);
if(scanline)

View File

@ -93,6 +93,8 @@ TIC80_API void tic80_load(tic80* tic, void* cart, s32 size)
tic80->tic.sound.count = tic80->memory->samples.size/sizeof(s16);
tic80->tic.sound.samples = tic80->memory->samples.buffer;
tic80->tic.screen = tic80->memory->screen;
{
tic80->tickData.error = onError;
tic80->tickData.trace = onTrace;
@ -121,7 +123,7 @@ TIC80_API void tic80_tick(tic80* tic, tic80_input input)
tic80->memory->api.tick(tic80->memory, &tic80->tickData);
tic80->memory->api.tick_end(tic80->memory);
tic80->memory->api.blit(tic80->memory, tic->screen, tic80->memory->api.scanline, tic80->memory->api.overlap);
tic80->memory->api.blit(tic80->memory, tic80->memory->api.scanline, tic80->memory->api.overlap);
TickCounter++;
}

View File

@ -109,7 +109,7 @@ typedef struct
void (*tick_start) (tic_mem* memory, const tic_sound* src);
void (*tick_end) (tic_mem* memory);
void (*blit) (tic_mem* tic, u32* out, tic_scanline scanline, tic_overlap overlap);
void (*blit) (tic_mem* tic, tic_scanline scanline, tic_overlap overlap);
tic_script_lang (*get_script)(tic_mem* memory);
} tic_api;
@ -131,6 +131,8 @@ struct tic_mem
s16* buffer;
s32 size;
} samples;
u32 screen[TIC80_FULLWIDTH * TIC80_FULLHEIGHT];
};
tic_mem* tic_create(s32 samplerate);