PSP2: Triangle suspends instead of quitting

This commit is contained in:
Jeffrey Pfau 2015-08-30 11:58:09 -07:00
parent 908a20856f
commit 1c351d92c7
3 changed files with 32 additions and 8 deletions

View File

@ -12,6 +12,7 @@
#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 @@ int main() {
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 @@ int main() {
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();
}

View File

@ -242,7 +242,7 @@ void GBAPSP2Runloop(void) {
vita2d_start_drawing();
vita2d_clear_screen();
GBAPSP2Draw();
GBAPSP2Draw(0xFF);
vita2d_end_drawing();
vita2d_swap_buffers();
}
@ -263,16 +263,16 @@ void GBAPSP2Teardown(void) {
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;
}
}

View File

@ -15,6 +15,6 @@ bool GBAPSP2LoadROM(const char* path);
void GBAPSP2Runloop(void);
void GBAPSP2UnloadROM(void);
void GBAPSP2Draw(void);
void GBAPSP2Draw(uint8_t alpha);
#endif