Random Homebrew: PSP Tetris for FW 2.7
A tetris game for 2.7s!

open source recovery menu

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

open source recovery menu

Postby devshelper » Thu Mar 24, 2011 9:33 am

Advertising
menu peolpe have complained about some bugs of the recovery menus on 6.20 tn-d permanent.
these bugs appear because these menus are not designed for 6.20.
so lets all create a menu that will be compatible with tn hen -d perm.
here is the source code of the menu:
Code: Select all
#include <pspkernel.h>
#include <pspcallbacks.h>
#include <pspctrl.h>
#include <graphics.h>
#include <pspdebug.h>

#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO("Menu Example",0,1,1);

//colors used later
Color green = RGB(0,255,0), red = RGB(255,0,0), black = RGB(0,0,0), blue = RGB (0,0,255);

char menuItems[10][25] = {
   {"USB"},
   {"RECOVERY"},
   {"F0 BACKUP"},
   {"F1 BACKUP"},
   {"CPU GAME"},
   {"CPU XMB"},
   {"PLUGINS"},
   {"FAKE REGION"},
   {"RESET DEVICE"},
   {"RESET VSH"},
};

int timer,select,foo;
SceCtrlData pad;

int main() {
    pspDebugScreenInit();
    pspDebugScreenClear();
   initGraphics();
   SetupCallbacks();
   while(1) {
      sceCtrlReadBufferPositive(&pad,1);
      fillScreenRect(black,0,0,480,272);
      timer++;
      for(foo=0;foo<10;foo++) {
         printTextScreen(200,foo*10+70,menuItems[foo],red);
      }
      
      printTextScreen(200,select*10+70,menuItems[select],green);   

   if((pad.Buttons & PSP_CTRL_UP) && (timer > 10) && (select > 0)) {
         select--;
         timer = 0;
      } else if ((pad.Buttons & PSP_CTRL_DOWN) && (timer > 10) && (select < 9)) {
         select++;
         timer = 0;
      }   

      
      flipScreen();
   }
   return 0;
}      


i will edit the code so that this menu becomes perfect.
i would also like you to make suggestions on how to improve it!!!
thnx
devshelper
 
Posts: 136
Joined: Sat Mar 19, 2011 12:09 pm

Re: open source recovery menu

Postby m0skit0 » Thu Mar 24, 2011 9:42 am

Advertising
There's no such thing as perfect software.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: open source recovery menu

Postby devshelper » Thu Mar 24, 2011 9:53 am

no.
but looking for perfection improves everything.
i know that this library:
Code: Select all
sceKernelExitVSHVSH(NULL);

restarts the vsh.
but when i put this code:
Code: Select all
      if((pad.Buttons & PSP_CTRL_CROSS) && (select == 9)) {
      sceKernelExitVSHVSH(NULL);
      }

the homebrew crashes without even reaching the menu.
whats wrong?
devshelper
 
Posts: 136
Joined: Sat Mar 19, 2011 12:09 pm

Re: open source recovery menu

Postby m0skit0 » Thu Mar 24, 2011 9:59 am

That line is correct. Put the whole code, the problem is elsewhere.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: open source recovery menu

Postby devshelper » Thu Mar 24, 2011 10:00 am

Code: Select all
#include <pspkernel.h>
#include <pspcallbacks.h>
#include <pspctrl.h>
#include <graphics.h>
#include <pspdebug.h>
#include <psploadexec_kernel.h>

#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))

#define printf pspDebugScreenPrintf

PSP_MODULE_INFO("Menu Example",0,1,1);

//colors used later
Color green = RGB(0,255,0), red = RGB(255,0,0), black = RGB(0,0,0), blue = RGB (0,0,255);

char menuItems[10][25] = {
   {"USB"},
   {"RECOVERY"},
   {"F0 BACKUP"},
   {"F1 BACKUP"},
   {"CPU GAME"},
   {"CPU XMB"},
   {"PLUGINS"},
   {"FAKE REGION"},
   {"RESET DEVICE"},
   {"RESET VSH"},
};

int timer,select,foo;
SceCtrlData pad;

int main() {
    pspDebugScreenInit();
    pspDebugScreenClear();
   initGraphics();
   SetupCallbacks();
   while(1) {
      sceCtrlReadBufferPositive(&pad,1);
      fillScreenRect(black,0,0,480,272);
      timer++;
      for(foo=0;foo<10;foo++) {
         printTextScreen(200,foo*10+70,menuItems[foo],red);
      }
      
      printTextScreen(200,select*10+70,menuItems[select],green);   

   if((pad.Buttons & PSP_CTRL_UP) && (timer > 10) && (select > 0)) {
         select--;
         timer = 0;
      } else if ((pad.Buttons & PSP_CTRL_DOWN) && (timer > 10) && (select < 9)) {
         select++;
         timer = 0;
      }   
      
        flipScreen();
      
      if((pad.Buttons & PSP_CTRL_CROSS) && (select == 9)) {
      sceKernelExitVSHVSH(NULL);
      }
      
   }
   return 0;
}      




      
devshelper
 
Posts: 136
Joined: Sat Mar 19, 2011 12:09 pm

Re: open source recovery menu

Postby m0skit0 » Thu Mar 24, 2011 10:49 am

You cannot put a while(1) without a delay, Syscon will detect that as a hang/crash and power off the PSP. You need to leave other code (specially kernel code) execute, using sceKernelDelayThread inside your loop.

FYI PSP has no real multitasking, it's preemptive multitasking (tasks should release CPU themselves, kernel does not enforce that).
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Re: open source recovery menu

Postby JJS » Thu Mar 24, 2011 10:56 am

The while(1) loop is ok in this case because sceCtrlReadBufferPositive waits for vsync. So it doesn't run more than 60 times a second.

But I am wondering if this thread is not a rehash of the last one with the same code in it.
JJS
Big Beholder
 
Posts: 1516
Joined: Mon Sep 27, 2010 2:18 pm

Re: open source recovery menu

Postby devshelper » Thu Mar 24, 2011 12:56 pm

can you practically show me what should i do?
devshelper
 
Posts: 136
Joined: Sat Mar 19, 2011 12:09 pm

Re: open source recovery menu

Postby waratte » Thu Mar 24, 2011 9:17 pm

Try moving a return statement down your main loop as way to find the problem. Compile, run on psp, then wait a few seconds. Push the home button to check if the grey screen appears, the one that asks you if you want to exit the game. If it does, move the return statement down one line until, the grey screen doesn't appear anymore. The line above your return statement could be the problem. This is a way I check for crashing errors in my programme, there may be better methods but I like this one. :D Also as a suggestion, you could have your "foo" variable in your for loop instead of outside your main unless you plan on using it throughout the code.
waratte
 
Posts: 4066
Joined: Wed Oct 20, 2010 12:03 am

Re: open source recovery menu

Postby m0skit0 » Thu Mar 24, 2011 10:58 pm

Of course there are better methods. They are called "debugging", which is almost as important as programming.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

Friends

Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita