all repos — mgba @ 1c351d92c74faf2ed8ebbdc493de359383a79414

mGBA Game Boy Advance Emulator

PSP2: Triangle suspends instead of quitting
Jeffrey Pfau jeffrey@endrift.com
Sun, 30 Aug 2015 11:58:09 -0700
commit

1c351d92c74faf2ed8ebbdc493de359383a79414

parent

908a20856f43e56a49b47d04a88c4d2213e9a528

3 files changed, 32 insertions(+), 8 deletions(-)

jump to
M src/platform/psp2/main.csrc/platform/psp2/main.c

@@ -12,6 +12,7 @@ #include "util/gui/file-select.h"

#include <psp2/ctrl.h> #include <psp2/kernel/processmgr.h> +#include <psp2/kernel/threadmgr.h> #include <psp2/moduleinfo.h> #include <vita2d.h>

@@ -65,11 +66,14 @@ struct GUIFont* font = GUIFontCreate();

GBAPSP2Setup(); struct GUIParams params = { PSP2_HORIZONTAL_PIXELS, PSP2_VERTICAL_PIXELS, - font, "cache0:", _drawStart, _drawEnd, _pollInput + font, "cache0:", _drawStart, _drawEnd, _pollInput, + + GUI_PARAMS_TRAIL }; GUIInit(&params); while (true) { + bool running = true; char path[256]; if (!GUISelectFile(&params, path, sizeof(path), GBAIsROM)) { break;

@@ -77,7 +81,27 @@ }

if (!GBAPSP2LoadROM(path)) { continue; } - GBAPSP2Runloop(); + while (running) { + GBAPSP2Runloop(); + GUIInvalidateKeys(&params); + while (true) { + int keys = 0; + _drawStart(); + GBAPSP2Draw(0x80); + _drawEnd(); + GUIPollInput(&params, &keys, 0); + if (keys & (1 << GUI_INPUT_CANCEL)) { + running = false; + break; + } + if (keys & (1 << GUI_INPUT_SELECT)) { + while (keys & (1 << GUI_INPUT_SELECT)) { + GUIPollInput(&params, 0, &keys); + } + break; + } + } + } GBAPSP2UnloadROM(); }
M src/platform/psp2/psp2-context.csrc/platform/psp2/psp2-context.c

@@ -242,7 +242,7 @@ MutexUnlock(&audioContext.mutex);

vita2d_start_drawing(); vita2d_clear_screen(); - GBAPSP2Draw(); + GBAPSP2Draw(0xFF); vita2d_end_drawing(); vita2d_swap_buffers(); }

@@ -263,16 +263,16 @@ vita2d_free_texture(tex);

vita2d_free_texture(backdrop); } -void GBAPSP2Draw(void) { +void GBAPSP2Draw(uint8_t alpha) { switch (screenMode) { case SM_BACKDROP: - vita2d_draw_texture(backdrop, 0, 0); + vita2d_draw_texture_tint(backdrop, 0, 0, (alpha << 24) | 0xFFFFFF); // Fall through case SM_PLAIN: - vita2d_draw_texture_part_scale(tex, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f); + vita2d_draw_texture_tint_part_scale(tex, 120, 32, 0, 0, 240, 160, 3.0f, 3.0f, (alpha << 24) | 0xFFFFFF); break; case SM_FULL: - vita2d_draw_texture_scale(tex, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f); + vita2d_draw_texture_tint_scale(tex, 0, 0, 960.0f / 240.0f, 544.0f / 160.0f, (alpha << 24) | 0xFFFFFF); break; } }
M src/platform/psp2/psp2-context.hsrc/platform/psp2/psp2-context.h

@@ -15,6 +15,6 @@ bool GBAPSP2LoadROM(const char* path);

void GBAPSP2Runloop(void); void GBAPSP2UnloadROM(void); -void GBAPSP2Draw(void); +void GBAPSP2Draw(uint8_t alpha); #endif