diff --git a/user/Makefile b/user/Makefile index ee7c149..833f63b 100644 --- a/user/Makefile +++ b/user/Makefile @@ -9,9 +9,7 @@ PSP_EBOOT_ICON = $(UMDREGIONROOT)/res/ICON0.PNG #PSP_EBOOT_UNKPNG = $(UMDREGIONROOT)/res/matrix_new.png PSP_EBOOT_PIC1 = $(UMDREGIONROOT)/res/PIC1_BLUR.PNG PSP_FW_VERSION = 660 -#BUILD_PRX = 1 - - +BUILD_PRX = 1 OBJS = main.o \ mp3player.o \ @@ -22,7 +20,7 @@ OBJS = main.o \ INCDIR = $(UMDREGIONROOT)/libs/libpng $(UMDREGIONROOT)/libs/libmad/include $(UMDREGIONROOT)/common/include include LIBDIR= $(UMDREGIONROOT)/libs -LIBS = -lpng -lz -lc -lm -lmad -lpspgu -lpspgum -lpspdebug -lpspdisplay -lpspsystemctrl_user -lpspkubridge -lpspaudiolib -lpspaudio +LIBS = -lpng -lz -lc -lm -lmad -lpspgu -lpspgum -lpspdebug -lpspdisplay -lpspsystemctrl_user -lpspkubridge -lpspaudiolib -lpspaudio -lpsputility -lpspvfpu LDFLAGS = -L libs diff --git a/user/main.c b/user/main.c index 9fd9405..fcccfc9 100644 --- a/user/main.c +++ b/user/main.c @@ -9,6 +9,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -23,13 +27,17 @@ #include #include -PSP_MODULE_INFO("UMD_REGION_CHANGER", 0, 1, 6); -PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER); +PSP_MODULE_INFO("UMD_REGION_CHANGER", 0, 1, 8); +PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH|PSP_THREAD_ATTR_VFPU); +PSP_HEAP_SIZE_KB(17*1024); #define printf pspDebugScreenPrintf #define BUF_WIDTH 512 #define SCR_WIDTH 480 #define SCR_HEIGHT 272 +#define NUM_INPUT_FIELDS (3) +#define TEXT_LENGTH (128) + static char arrow[] = "-> "; static int dir = 0; @@ -39,15 +47,22 @@ static int region; static int i = -1; static char selected[64]; static char check_path[64]; +static unsigned int __attribute__((aligned(16))) list[262144]; +unsigned short custom[4] = {0}; +unsigned short custom_ret[4] = {0}; +volatile bool debug = false; +volatile bool init = true; -static char *regions[4] = { +static char *regions[5] = { "Default", "Japan", "America", "Europe", - }; + "Custom", +}; + #define nums (sizeof(regions)/sizeof(regions[0]))-1 @@ -68,7 +83,8 @@ static void playSound(bool type) { static void updateScreen(Image* bg, int dir, int type) { blitImageToScreen(0, 0, 480, 272, bg, 0, 0); for(i = 0; i= 80000) { + debug = !debug; + lastClick = currentTime; + } + } + updateScreen(background, dir, trueType); printTextScreen(0, 5, "##########################", 0xFFFF0000); printTextScreen(0, 10, "# #", 0xFFFF0000); printTextScreen(0, 20, "# Please choose a Region #", 0xFFFF0000); printTextScreen(0, 30, "# #", 0xFFFF0000); printTextScreen(0, 40, "##########################", 0xFFFF0000); - + // BUTTON DOWN if(pad.Buttons & PSP_CTRL_DOWN) { - dir++; - if(dir>nums) dir = 0; - region = dir; - trueType = 0; + if(elapsedTime >= 80000) { + dir++; + if(!debug && dir>nums-1) dir = 0; + else if(dir>nums) dir = 0; + region = dir; + trueType = 0; + lastClick = currentTime; + } } // BUTTON UP if(pad.Buttons & PSP_CTRL_UP) { - dir--; - if(dir<0) dir = nums; - region = dir; - trueType = 0; + if(elapsedTime >= 80000) { + dir--; + if(!debug && dir<0) dir = nums-1; + else if(dir<0) dir = nums; + region = dir; + trueType = 0; + lastClick = currentTime; + } } // ACCEPT BUTTON if(pad.Buttons & PSP_CTRL_CROSS) { + if(dir == 4) { + unsigned short desc[] = {'C', 'u', 's', 't', 'o', 'm', ' ', 'R', 'e', 'g', 'i', 'o', 'n', '\0'}; + unsigned short intext[] = {'0', '\0'}; + + SceUtilityOskData oskData; + memset(&oskData, 0, sizeof(SceUtilityOskData)); + + oskData.language = PSP_UTILITY_OSK_LANGUAGE_ENGLISH; + oskData.lines = 1; + oskData.unk_24 = 1; + oskData.inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT; + oskData.desc = desc; + oskData.intext = intext; + oskData.outtextlength = 2; + oskData.outtextlimit = 2; + oskData.outtext = custom; + + + SceUtilityOskParams oskParams; + memset(&oskParams, 0, sizeof(SceUtilityOskParams)); + + oskParams.base.size = sizeof(SceUtilityOskParams); + oskParams.base.language = PSP_UTILITY_OSK_LANGUAGE_ENGLISH; + oskParams.base.buttonSwap = PSP_UTILITY_ACCEPT_CROSS; + oskParams.base.graphicsThread = 17; + oskParams.base.accessThread = 19; + oskParams.base.fontThread = 18; + oskParams.base.soundThread = 16; + oskParams.datacount = 1; + oskParams.data = &oskData; + int done = 0; + + + sceUtilityOskInitStart(&oskParams); + while(!done) { + sceGuStart(GU_DIRECT,list); + sceGuClear(GU_COLOR_BUFFER_BIT); + + sceGuFinish(); + sceGuSync(0,0); + + sceGuClear(GU_COLOR_BUFFER_BIT); + + switch(sceUtilityOskGetStatus()) + { + case PSP_UTILITY_DIALOG_INIT: + sceKernelDelayThread(100000); + break; + case PSP_UTILITY_DIALOG_VISIBLE: + sceUtilityOskUpdate(1); + break; + case PSP_UTILITY_DIALOG_QUIT: + sceUtilityOskShutdownStart(); + break; + case PSP_UTILITY_DIALOG_FINISHED: + break; + case PSP_UTILITY_DIALOG_NONE: + done = 1; + default : + break; + } + + sceDisplayWaitVblankStart(); + sceGuSwapBuffers(); + } + + custom_ret[0] = oskParams.data[0].outtext[0]; + + } + sceUtilityOskShutdownStart(); sceDisplayWaitVblankStart(); updateScreen(background, dir, 1); // Need to not hardcode this for category lite reasons. @@ -190,15 +294,20 @@ int main(int argc, char *args[]) { //3 // Japan //4 // America //5 // Europe (Australia) - - if(region==1) - region = 3; - else if(region==2) - region = 4; - else if(region==3) - region = 5; - else - region = 0; + if(custom_ret) { + int custom_convert = custom_ret[0] - '0'; + region = custom_convert; + } + else { + if(region==1) + region = 3; + else if(region==2) + region = 4; + else if(region==3) + region = 5; + else + region = 0; + } SceUID save_region = sceIoOpen(region_path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);