no message
This commit is contained in:
parent
f578428381
commit
e3ad17f609
|
@ -142,7 +142,7 @@ int main(int argc, char **argv)
|
||||||
void* pixels = NULL;
|
void* pixels = NULL;
|
||||||
int pitch = 0;
|
int pitch = 0;
|
||||||
SDL_LockTexture(texture, NULL, &pixels, &pitch);
|
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_UnlockTexture(texture);
|
||||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ typedef struct
|
||||||
s32 count;
|
s32 count;
|
||||||
} sound;
|
} sound;
|
||||||
|
|
||||||
u32 screen[TIC80_FULLWIDTH * TIC80_FULLHEIGHT];
|
u32* screen;
|
||||||
|
|
||||||
} tic80;
|
} tic80;
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,11 @@ typedef struct
|
||||||
} music;
|
} music;
|
||||||
|
|
||||||
tic_scanline scanline;
|
tic_scanline scanline;
|
||||||
|
|
||||||
tic_overlap overlap;
|
tic_overlap overlap;
|
||||||
|
void (*pixel)(tic_mem* memory, s32 x, s32 y, u8 color);
|
||||||
|
u32 overlapPalette[TIC_PALETTE_SIZE];
|
||||||
|
|
||||||
bool initialized;
|
bool initialized;
|
||||||
} MachineState;
|
} MachineState;
|
||||||
|
|
||||||
|
|
31
src/studio.c
31
src/studio.c
|
@ -1448,29 +1448,23 @@ static void setCoverImage()
|
||||||
if(studio.mode == TIC_RUN_MODE)
|
if(studio.mode == TIC_RUN_MODE)
|
||||||
{
|
{
|
||||||
enum {Pitch = TIC80_FULLWIDTH*sizeof(u32)};
|
enum {Pitch = TIC80_FULLWIDTH*sizeof(u32)};
|
||||||
u32* pixels = SDL_malloc(Pitch * TIC80_FULLHEIGHT);
|
|
||||||
|
|
||||||
if(pixels)
|
tic->api.blit(tic, tic->api.scanline, tic->api.overlap);
|
||||||
|
|
||||||
|
u32* buffer = SDL_malloc(TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32));
|
||||||
|
|
||||||
|
if(buffer)
|
||||||
{
|
{
|
||||||
tic->api.blit(tic, pixels, tic->api.scanline, tic->api.overlap);
|
SDL_Rect rect = {OFFSET_LEFT, OFFSET_TOP, TIC80_WIDTH, TIC80_HEIGHT};
|
||||||
|
|
||||||
u32* buffer = SDL_malloc(TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32));
|
screen2buffer(buffer, tic->screen, rect);
|
||||||
|
|
||||||
if(buffer)
|
gif_write_animation(studio.tic->cart.cover.data, &studio.tic->cart.cover.size,
|
||||||
{
|
TIC80_WIDTH, TIC80_HEIGHT, (const u8*)buffer, 1, TIC_FRAMERATE, 1);
|
||||||
SDL_Rect rect = {OFFSET_LEFT, OFFSET_TOP, TIC80_WIDTH, TIC80_HEIGHT};
|
|
||||||
|
|
||||||
screen2buffer(buffer, pixels, rect);
|
SDL_free(buffer);
|
||||||
|
|
||||||
gif_write_animation(studio.tic->cart.cover.data, &studio.tic->cart.cover.size,
|
showPopupMessage("COVER IMAGE SAVED :)");
|
||||||
TIC80_WIDTH, TIC80_HEIGHT, (const u8*)buffer, 1, TIC_FRAMERATE, 1);
|
|
||||||
|
|
||||||
SDL_free(buffer);
|
|
||||||
|
|
||||||
showPopupMessage("COVER IMAGE SAVED :)");
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_free(pixels);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1950,7 +1944,8 @@ static void blitTexture()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
tic->api.blit(tic, pixels, scanline, overlap);
|
tic->api.blit(tic, scanline, overlap);
|
||||||
|
SDL_memcpy(pixels, tic->screen, sizeof tic->screen);
|
||||||
|
|
||||||
recordFrame(pixels);
|
recordFrame(pixels);
|
||||||
|
|
||||||
|
|
24
src/tic.c
24
src/tic.c
|
@ -149,11 +149,26 @@ static void resetPalette(tic_mem* memory)
|
||||||
memory->ram.vram.vars.mask.data = TIC_GAMEPAD_MASK;
|
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;
|
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)
|
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.scanline = NULL;
|
||||||
machine->state.overlap = NULL;
|
machine->state.overlap = NULL;
|
||||||
|
|
||||||
|
machine->state.pixel = dmaPixel;
|
||||||
|
|
||||||
updateSaveid(memory);
|
updateSaveid(memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,8 +1672,9 @@ static u32* paletteBlit(tic_mem* tic)
|
||||||
return pal;
|
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);
|
const u32* pal = paletteBlit(tic);
|
||||||
|
|
||||||
if(scanline)
|
if(scanline)
|
||||||
|
|
|
@ -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.count = tic80->memory->samples.size/sizeof(s16);
|
||||||
tic80->tic.sound.samples = tic80->memory->samples.buffer;
|
tic80->tic.sound.samples = tic80->memory->samples.buffer;
|
||||||
|
|
||||||
|
tic80->tic.screen = tic80->memory->screen;
|
||||||
|
|
||||||
{
|
{
|
||||||
tic80->tickData.error = onError;
|
tic80->tickData.error = onError;
|
||||||
tic80->tickData.trace = onTrace;
|
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(tic80->memory, &tic80->tickData);
|
||||||
tic80->memory->api.tick_end(tic80->memory);
|
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++;
|
TickCounter++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ typedef struct
|
||||||
|
|
||||||
void (*tick_start) (tic_mem* memory, const tic_sound* src);
|
void (*tick_start) (tic_mem* memory, const tic_sound* src);
|
||||||
void (*tick_end) (tic_mem* memory);
|
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_script_lang (*get_script)(tic_mem* memory);
|
||||||
} tic_api;
|
} tic_api;
|
||||||
|
@ -131,6 +131,8 @@ struct tic_mem
|
||||||
s16* buffer;
|
s16* buffer;
|
||||||
s32 size;
|
s32 size;
|
||||||
} samples;
|
} samples;
|
||||||
|
|
||||||
|
u32 screen[TIC80_FULLWIDTH * TIC80_FULLHEIGHT];
|
||||||
};
|
};
|
||||||
|
|
||||||
tic_mem* tic_create(s32 samplerate);
|
tic_mem* tic_create(s32 samplerate);
|
||||||
|
|
Loading…
Reference in New Issue