 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Flip333
Joined: 20 Oct 2008 Posts: 7
|
Posted: Mon Oct 27, 2008 6:56 am Post subject: How to call native thingies |
|
|
| How would someone call a native message box or Yes/No question in their own game in C? |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Oct 27, 2008 8:10 am Post subject: |
|
|
| I use the native stuff like that in the init code of my TV version of SDL and PSPGL. Look for the recent thread on that. |
|
| Back to top |
|
 |
Flip333
Joined: 20 Oct 2008 Posts: 7
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Oct 27, 2008 11:16 am Post subject: |
|
|
Yes, that's the thread. Look at the code added to SDL in src/video/psp/SDL_pspvideo.c. These are the main routines:
| Code: | 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();
}
}
|
and are called like this:
| Code: | 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);
}
} |
|
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Mon Oct 27, 2008 7:44 pm Post subject: |
|
|
There's a sample in the SDK.
samples/utility/msgdialog |
|
| Back to top |
|
 |
Geijer
Joined: 18 Aug 2004 Posts: 3
|
Posted: Mon Oct 27, 2008 11:52 pm Post subject: |
|
|
| J.F. wrote: |
...
| Code: |
...
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();
}
|
...
|
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:
| Code: |
/**
* 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);
|
|
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Tue Oct 28, 2008 4:55 am Post subject: |
|
|
| The sample is the correct, the comment isn't ;) |
|
| Back to top |
|
 |
Flip333
Joined: 20 Oct 2008 Posts: 7
|
Posted: Sat Nov 01, 2008 8:13 am Post subject: |
|
|
Hey, thanks for that.
I tried using the code he gave me and I couldn't get it to work.
I looked myself, but I guess I didn't look hard enough because I never found the sample. Thanks for the directory. I'll have a look at it. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|