PSP2: Savestate viewing
Jeffrey Pfau jeffrey@endrift.com
Tue, 15 Sep 2015 23:00:02 -0700
3 files changed,
25 insertions(+),
1 deletions(-)
M
src/platform/psp2/main.c
→
src/platform/psp2/main.c
@@ -94,6 +94,7 @@ .gameLoaded = GBAPSP2LoadROM,
.gameUnloaded = GBAPSP2UnloadROM, .prepareForFrame = GBAPSP2PrepareForFrame, .drawFrame = GBAPSP2Draw, + .drawScreenshot = GBAPSP2DrawScreenshot, .paused = 0, .unpaused = 0, .incrementScreenMode = GBAPSP2IncrementScreenMode,
M
src/platform/psp2/psp2-context.c
→
src/platform/psp2/psp2-context.c
@@ -38,6 +38,7 @@ } screenMode;
static struct GBAVideoSoftwareRenderer renderer; static vita2d_texture* tex; +static vita2d_texture* screenshot; static Thread audioThread; static struct GBASceRotationSource { struct GBARotationSource d;@@ -159,6 +160,7 @@ desc = (struct GBAAxis) { GBA_KEY_RIGHT, GBA_KEY_LEFT, 192, 64 };
GBAInputBindAxis(&runner->context.inputMap, PSP2_INPUT, 1, &desc); tex = vita2d_create_empty_texture_format(256, 256, SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR); + screenshot = vita2d_create_empty_texture_format(256, 256, SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1BGR); GBAVideoSoftwareRendererCreate(&renderer); renderer.outputBuffer = vita2d_texture_get_datap(tex);@@ -220,7 +222,7 @@
void GBAPSP2Teardown(struct GBAGUIRunner* runner) { UNUSED(runner); vita2d_free_texture(tex); - vita2d_free_texture(backdrop); + vita2d_free_texture(screenshot); } void GBAPSP2Draw(struct GBAGUIRunner* runner, bool faded) {@@ -234,6 +236,26 @@ vita2d_draw_texture_tint_part_scale(tex, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF);
break; case SM_FULL: vita2d_draw_texture_tint_scale(tex, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + break; + } +} + +void GBAPSP2DrawScreenshot(struct GBAGUIRunner* runner, const uint32_t* pixels, bool faded) { + UNUSED(runner); + uint32_t* texpixels = vita2d_texture_get_datap(screenshot); + int y; + for (y = 0; y < VIDEO_VERTICAL_PIXELS; ++y) { + memcpy(&texpixels[256 * y], &pixels[VIDEO_HORIZONTAL_PIXELS * y], VIDEO_HORIZONTAL_PIXELS * 4); + } + switch (screenMode) { + case SM_BACKDROP: + vita2d_draw_texture_tint(backdrop, 0, 0, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + // Fall through + case SM_PLAIN: + vita2d_draw_texture_tint_part_scale(screenshot, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); + break; + case SM_FULL: + vita2d_draw_texture_tint_scale(screenshot, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f, (faded ? 0 : 0xC0000000) | 0x3FFFFFFF); break; } }
M
src/platform/psp2/psp2-context.h
→
src/platform/psp2/psp2-context.h
@@ -17,6 +17,7 @@ void GBAPSP2LoadROM(struct GBAGUIRunner* runner);
void GBAPSP2UnloadROM(struct GBAGUIRunner* runner); void GBAPSP2PrepareForFrame(struct GBAGUIRunner* runner); void GBAPSP2Draw(struct GBAGUIRunner* runner, bool faded); +void GBAPSP2DrawScreenshot(struct GBAGUIRunner* runner, const uint32_t* pixels, bool faded); void GBAPSP2IncrementScreenMode(struct GBAGUIRunner* runner); uint16_t GBAPSP2PollInput(struct GBAGUIRunner* runner);