Emu
Posts : 21 Points : 29 Reputation : 0 Join date : 2010-10-04
| Subject: C on psp - Menu's Tabs [My Program so far] Sat Oct 16, 2010 2:07 pm | |
| - Code:
-
unsigned int menuNo = 0; unsigned int menuSelected = 0;
int main(void) { //Setup Menu: function int menuDraw(void) { do { switch(menuSelected) { case 0: pspDebugScreenPuts("Tab 1\n"); break; case 1: pspDebugScreenPuts("Tab 2\n"); break; case 2: pspDebugScreenPuts("Tab 3\n"); break; } menuNo++; }while(menuNo < 3); return 0; }
//menuSwitch: function int menuSwitch(void) { while(1) { sceCtrlPeekBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_RTRIGGER) { if(menuSelected > 0) menuSelected--; else if(menuSelected == 0) menuSelected = 2; menuDraw(); sceKernelDelayThread(1500000); } else if(pad.Buttons & PSP_CTRL_LTRIGGER) { if(menuSelected < 2) menuSelected++; else if(menuSelected == 2) menuSelected = 0; menuDraw(); sceKernelDelayThread(1500000); } } }
This is an example of a menu. If you want to compile this include these at the top of this code: - Code:
-
#include <pspctrl.h> #include <pspumd.h> #include <psppower.h> #include <pspdisplay.h> #include <stdio.h> #include <pspstdio.h> #include <pspdebug.h> #include <pspkernel.h>
PSP_MODULE_INFO("MHFUc", 0, 1, 0); PSP_MAIN_THREAD_ATTR(0); //0 for kernel mode too
#define printf pspDebugScreenPrintf
//GLOBALS SceCtrlData pad; unsigned int lines = 0; unsigned int lineSelected = 0; unsigned int menuNo = 0;
/* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; }
/* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0; }
/* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); }
return thid; } EBOOT is a quick way of testing it. For the make file add this: - Code:
-
TARGET = xxsamuraixx OBJS = main.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) BUILD_PRX = 1 #PRX_EXPORTS = exports.exp LIBS = -lpsppower EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = MHFUc v0.04 (Beta) PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak my eboot so far: http://www.sendspace.com/file/edkjty | |
|
Jellyforme
Posts : 38 Points : 63 Reputation : 1 Join date : 2010-09-30
| Subject: Re: C on psp - Menu's Tabs [My Program so far] Sat Oct 16, 2010 8:49 pm | |
| Nice program Emu! I tested it and its works well(except for the options tab which you know about). It's also very sexy. | |
|
Emu
Posts : 21 Points : 29 Reputation : 0 Join date : 2010-10-04
| Subject: Re: C on psp - Menu's Tabs [My Program so far] Sun Oct 17, 2010 11:18 am | |
| Thank you I have another one with the TABS working now just gotta start adding to the menus | |
|
Jellyforme
Posts : 38 Points : 63 Reputation : 1 Join date : 2010-09-30
| Subject: Re: C on psp - Menu's Tabs [My Program so far] Tue Oct 19, 2010 3:22 pm | |
| Nice! By the way, where did you find the different libraries, what they contain, and what they do(Ex:<pspctrl.h>)? I can't find them anywhere.
Last edited by Jellyforme on Tue Oct 19, 2010 5:25 pm; edited 1 time in total | |
|
-LeetGamer- Admin
Posts : 247 Points : 397 Reputation : 4 Join date : 2010-09-29 Age : 30
| Subject: Re: C on psp - Menu's Tabs [My Program so far] Tue Oct 19, 2010 3:25 pm | |
| - Jellyforme wrote:
- Nice! :DBy the way, where did you find the different libraries, what they contain, and what they do(Ex:<pspctrl.h>)? I can't find them anywhere.
C:\pspsdk\psp\sdk\include\pspctrl.h | |
|
Sponsored content
| Subject: Re: C on psp - Menu's Tabs [My Program so far] | |
| |
|