How to call native thingies
How to call native thingies
How would someone call a native message box or Yes/No question in their own game in C?
This thread?
http://forums.ps2dev.org/viewtopic.php? ... t=sdl+pspg
I didn't see anything in it.
What would I need to include and what are the functions?
http://forums.ps2dev.org/viewtopic.php? ... t=sdl+pspg
I didn't see anything in it.
What would I need to include and what are the functions?
Yes, that's the thread. Look at the code added to SDL in src/video/psp/SDL_pspvideo.c. These are the main routines:
and are called like this:
Code: Select all
static pspUtilityMsgDialogParams dialog;
static void SetupGu(void)
{
sceGuInit();
sceGuStart(GU_DIRECT, list);
sceGuDrawBuffer(GU_PSM_8888, (void*)0, 512);
sceGuDispBuffer(480, 272, (void*)0x88000, 512);
sceGuDepthBuffer((void*)0x110000, 512);
sceGuOffset(2048 - (480/2), 2048 - (272/2));
sceGuViewport(2048, 2048, 480, 272);
sceGuDepthRange(0xc350, 0x2710);
sceGuScissor(0, 0, 480, 272);
sceGuEnable(GU_SCISSOR_TEST);
sceGuDepthFunc(GU_GEQUAL);
sceGuEnable(GU_DEPTH_TEST);
sceGuFrontFace(GU_CW);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_CULL_FACE);
sceGuEnable(GU_CLIP_PLANES);
sceGuFinish();
sceGuSync(0, 0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
}
static void ConfigureDialog(pspUtilityMsgDialogParams *dialog, size_t dialog_size)
{
memset(dialog, 0, dialog_size);
dialog->base.size = dialog_size;
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE,
&dialog->base.language); // Prompt language
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN,
&dialog->base.buttonSwap); // X/O button swap
dialog->base.graphicsThread = 0x11;
dialog->base.accessThread = 0x13;
dialog->base.fontThread = 0x12;
dialog->base.soundThread = 0x10;
}
static void ShowMessageDialog(const char *message, int enableYesno)
{
ConfigureDialog(&dialog, sizeof(dialog));
dialog.mode = PSP_UTILITY_MSGDIALOG_MODE_TEXT;
dialog.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT;
if(enableYesno)
dialog.options |= PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS|PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO;
strcpy(dialog.message, message);
sceUtilityMsgDialogInitStart(&dialog);
for(;;)
{
sceGuStart(GU_DIRECT,list);
// clear screen
sceGuClearColor(0xff554433);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);
switch(sceUtilityMsgDialogGetStatus()) {
case 2:
sceUtilityMsgDialogUpdate(1);
break;
case 3:
sceUtilityMsgDialogShutdownStart();
break;
case 0:
return;
}
//sceDisplayWaitVblankStart();
sceDisplayWaitVblankStart();
sceGuSwapBuffers();
}
}
Code: Select all
if (pad.Buttons & PSP_CTRL_TRIANGLE)
{
SetupGu();
if (PSP_TV_CABLE > 0)
{
ShowMessageDialog("Use TV output?", 1);
if(dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO)
{
PSP_TV_CABLE = 0;
PSP_TV_LACED = 0;
PSP_DSP_ASPECT = 1;
PSP_DSP_WIDE = 1;
}
else
{
if (PSP_TV_CABLE == 2)
{
ShowMessageDialog("Use interlaced output?", 1);
if(dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES)
PSP_TV_LACED = 1;
}
ShowMessageDialog("Using 16:9 (HDTV) display?", 1);
if(dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO)
PSP_DSP_ASPECT = 0;
}
}
ShowMessageDialog("Display as Widescreen?", 1);
if(dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO)
PSP_DSP_WIDE = 0;
/* write preferences */
FILE *fd;
char temp[256];
fd = fopen("SDL_VID_PREFS", "w");
if (fd != NULL)
{
fwrite ("-vmode", 1, 6, fd);
fwrite ("\n", 1, 1, fd);
sprintf(temp, "%d", PSP_TV_CABLE);
fwrite (temp, 1, strlen(temp), fd);
fwrite ("\n", 1, 1, fd);
fwrite ("-laced", 1, 6, fd);
fwrite ("\n", 1, 1, fd);
sprintf(temp, "%d", PSP_TV_LACED);
fwrite (temp, 1, strlen(temp), fd);
fwrite ("\n", 1, 1, fd);
fwrite ("-aspect", 1, 7, fd);
fwrite ("\n", 1, 1, fd);
sprintf(temp, "%d", PSP_DSP_ASPECT);
fwrite (temp, 1, strlen(temp), fd);
fwrite ("\n", 1, 1, fd);
fwrite ("-wide", 1, 5, fd);
fwrite ("\n", 1, 1, fd);
sprintf(temp, "%d", PSP_DSP_WIDE);
fwrite (temp, 1, strlen(temp), fd);
fwrite ("\n", 1, 1, fd);
fclose(fd);
}
}
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
Just recently experimented a little with the dialogs and found a potential problem with this code and the code in samples/utility/msgdialog if the comment in the SDK is correct:J.F. wrote: ......Code: Select all
... for(;;) { sceGuStart(GU_DIRECT,list); // clear screen sceGuClearColor(0xff554433); sceGuClearDepth(0); sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); sceGuFinish(); sceGuSync(0,0); switch(sceUtilityMsgDialogGetStatus()) { case 2: sceUtilityMsgDialogUpdate(1); break; case 3: sceUtilityMsgDialogShutdownStart(); break; case 0: return; } //sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); }
Code: Select all
/**
* Remove a message dialog currently active. After calling this
* function you need to keep calling GetStatus and Update until
* you get a status of 4.
*/
void sceUtilityMsgDialogShutdownStart(void);
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm