|
@@ -39,11 +39,11 @@
|
|
|
#include "SDL_pspvideo.h"
|
|
|
#include "SDL_pspevents_c.h"
|
|
|
#include "SDL_pspgl_c.h"
|
|
|
-#include "SDL_pspmessagebox.h"
|
|
|
|
|
|
#include <psputility.h>
|
|
|
#include <pspgu.h>
|
|
|
#include <pspdisplay.h>
|
|
|
+#include <vram.h>
|
|
|
#include "../../render/psp/SDL_render_psp.h"
|
|
|
|
|
|
#define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData"
|
|
@@ -65,7 +65,7 @@ int PSP_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint
|
|
|
|
|
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
|
|
|
|
|
- if (w != 480) {
|
|
|
+ if (w != PSP_SCREEN_WIDTH) {
|
|
|
return SDL_SetError("Unexpected window size");
|
|
|
}
|
|
|
|
|
@@ -257,6 +257,146 @@ static SDL_VideoDevice *PSP_Create()
|
|
|
return device;
|
|
|
}
|
|
|
|
|
|
+static void configure_dialog(pspUtilityMsgDialogParams *dialog, size_t dialog_size)
|
|
|
+{
|
|
|
+ /* clear structure and setup size */
|
|
|
+ SDL_memset(dialog, 0, dialog_size);
|
|
|
+ dialog->base.size = dialog_size;
|
|
|
+
|
|
|
+ /* set language */
|
|
|
+ sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &dialog->base.language);
|
|
|
+
|
|
|
+ /* set X/O swap */
|
|
|
+ sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &dialog->base.buttonSwap);
|
|
|
+
|
|
|
+ /* set thread priorities */
|
|
|
+ /* TODO: understand how these work */
|
|
|
+ dialog->base.soundThread = 0x10;
|
|
|
+ dialog->base.graphicsThread = 0x11;
|
|
|
+ dialog->base.fontThread = 0x12;
|
|
|
+ dialog->base.accessThread = 0x13;
|
|
|
+}
|
|
|
+
|
|
|
+static void *setup_temporal_gu(void *list)
|
|
|
+{
|
|
|
+ // Using GU_PSM_8888 for the framebuffer
|
|
|
+ int bpp = 4;
|
|
|
+
|
|
|
+ void *doublebuffer = vramalloc(PSP_FRAME_BUFFER_SIZE * bpp * 2);
|
|
|
+ void *backbuffer = doublebuffer;
|
|
|
+ void *frontbuffer = ((uint8_t *)doublebuffer) + PSP_FRAME_BUFFER_SIZE * bpp;
|
|
|
+
|
|
|
+ sceGuInit();
|
|
|
+
|
|
|
+ sceGuStart(GU_DIRECT,list);
|
|
|
+ sceGuDrawBuffer(GU_PSM_8888, vrelptr(frontbuffer), PSP_FRAME_BUFFER_WIDTH);
|
|
|
+ sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, vrelptr(backbuffer), PSP_FRAME_BUFFER_WIDTH);
|
|
|
+
|
|
|
+ sceGuOffset(2048 - (PSP_SCREEN_WIDTH >> 1), 2048 - (PSP_SCREEN_HEIGHT >> 1));
|
|
|
+ sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
|
|
|
+
|
|
|
+ sceGuDisable(GU_DEPTH_TEST);
|
|
|
+
|
|
|
+ /* Scissoring */
|
|
|
+ sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
|
|
|
+ sceGuEnable(GU_SCISSOR_TEST);
|
|
|
+
|
|
|
+ sceGuFinish();
|
|
|
+ sceGuSync(0,0);
|
|
|
+
|
|
|
+ sceDisplayWaitVblankStart();
|
|
|
+ sceGuDisplay(GU_TRUE);
|
|
|
+
|
|
|
+ return doublebuffer;
|
|
|
+}
|
|
|
+
|
|
|
+static void term_temporal_gu(void *guBuffer)
|
|
|
+{
|
|
|
+ sceGuTerm();
|
|
|
+ vfree(guBuffer);
|
|
|
+ sceDisplayWaitVblankStart();
|
|
|
+}
|
|
|
+
|
|
|
+int PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|
|
+{
|
|
|
+ unsigned char list[64] __attribute__((aligned(64)));
|
|
|
+ pspUtilityMsgDialogParams dialog;
|
|
|
+ int status;
|
|
|
+ void *guBuffer = NULL;
|
|
|
+
|
|
|
+ /* check if it's possible to use existing video context */
|
|
|
+ if (SDL_GetFocusWindow() == NULL) {
|
|
|
+ guBuffer = setup_temporal_gu(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* configure dialog */
|
|
|
+ configure_dialog(&dialog, sizeof(dialog));
|
|
|
+
|
|
|
+ /* setup dialog options for text */
|
|
|
+ dialog.mode = PSP_UTILITY_MSGDIALOG_MODE_TEXT;
|
|
|
+ dialog.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT;
|
|
|
+
|
|
|
+ /* copy the message in, 512 bytes max */
|
|
|
+ SDL_snprintf(dialog.message, sizeof(dialog.message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message);
|
|
|
+
|
|
|
+ /* too many buttons */
|
|
|
+ if (messageboxdata->numbuttons > 2)
|
|
|
+ return SDL_SetError("messageboxdata->numbuttons valid values are 0, 1, 2");
|
|
|
+
|
|
|
+ /* we only have two options, "yes/no" or "ok" */
|
|
|
+ if (messageboxdata->numbuttons == 2)
|
|
|
+ dialog.options |= PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS | PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO;
|
|
|
+
|
|
|
+ /* start dialog */
|
|
|
+ if (sceUtilityMsgDialogInitStart(&dialog) != 0)
|
|
|
+ return SDL_SetError("sceUtilityMsgDialogInitStart() failed for some reason");
|
|
|
+
|
|
|
+ /* loop while the dialog is active */
|
|
|
+ status = PSP_UTILITY_DIALOG_NONE;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ sceGuStart(GU_DIRECT, list);
|
|
|
+ sceGuClearColor(0);
|
|
|
+ sceGuClearDepth(0);
|
|
|
+ sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
|
|
|
+ sceGuFinish();
|
|
|
+ sceGuSync(0,0);
|
|
|
+
|
|
|
+ status = sceUtilityMsgDialogGetStatus();
|
|
|
+
|
|
|
+ switch (status)
|
|
|
+ {
|
|
|
+ case PSP_UTILITY_DIALOG_VISIBLE:
|
|
|
+ sceUtilityMsgDialogUpdate(1);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case PSP_UTILITY_DIALOG_QUIT:
|
|
|
+ sceUtilityMsgDialogShutdownStart();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ sceDisplayWaitVblankStart();
|
|
|
+ sceGuSwapBuffers();
|
|
|
+
|
|
|
+ } while (status != PSP_UTILITY_DIALOG_NONE);
|
|
|
+
|
|
|
+ /* cleanup */
|
|
|
+ if (guBuffer)
|
|
|
+ {
|
|
|
+ term_temporal_gu(guBuffer);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* success */
|
|
|
+ if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES)
|
|
|
+ *buttonid = messageboxdata->buttons[0].buttonid;
|
|
|
+ else if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO)
|
|
|
+ *buttonid = messageboxdata->buttons[1].buttonid;
|
|
|
+ else
|
|
|
+ *buttonid = messageboxdata->buttons[0].buttonid;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
VideoBootStrap PSP_bootstrap = {
|
|
|
"PSP",
|
|
|
"PSP Video Driver",
|
|
@@ -278,8 +418,8 @@ int PSP_VideoInit(_THIS)
|
|
|
|
|
|
SDL_zero(current_mode);
|
|
|
|
|
|
- current_mode.w = 480;
|
|
|
- current_mode.h = 272;
|
|
|
+ current_mode.w = PSP_SCREEN_WIDTH;
|
|
|
+ current_mode.h = PSP_SCREEN_HEIGHT;
|
|
|
|
|
|
current_mode.refresh_rate = 60;
|
|
|
/* 32 bpp for default */
|