forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Load Eboot from usermode and controlling it

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Oct 20, 2008 6:09 am    Post subject: Load Eboot from usermode and controlling it Reply with quote

first of all how do i take control of the psp like a shell does when my program is started and also how do i load an eboot from usermode and run it then if they press a key like select be able to put that eboot in the background and come back to my program like irshell does
Back to top
View user's profile Send private message MSN Messenger
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Mon Oct 20, 2008 6:15 am    Post subject: Reply with quote

See the sdk provide with the 4.01M33 firmware there is a sample to launch
a cso,iso,ps1 game from a shell program when the program end it comes back
to your shell.

Code:
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psploadexec_kernel.h>
#include <kubridge.h>
#include <systemctrl.h>
#include <systemctrl_se.h>

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

#include "rdriver.h"


PSP_MODULE_INFO("BootLoad Test", 0x200, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_MAX();

#define printf    pspDebugScreenPrintf

void ErrorExit(int milisecs, char *fmt, ...)
{
   va_list list;
   char msg[256];   

   va_start(list, fmt);
   vsprintf(msg, fmt, list);
   va_end(list);
   printf(msg);

   sceKernelDelayThread(milisecs*1000);
   sceKernelExitGame();
   asm("break\n");
   while (1);
}

int WriteFile(char *file, void *buf, int size)
{

   SceUID fd = sceIoOpen(file, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);

   if (fd < 0)
   {
      return fd;
   }
   int written = sceIoWrite(fd, buf, size);
   sceIoClose(fd);
   return written;
}



int Dialog(char *msg)

{
   printf("%s", msg);
   while (1)
   {
      SceCtrlData pad;
      sceCtrlReadBufferPositive(&pad, 1);
      if (pad.Buttons & PSP_CTRL_CROSS)
         return 1;

      if (pad.Buttons & PSP_CTRL_RTRIGGER)
         return 0;
      sceKernelDelayThread(50000);
   }
   return -1;
}



int main(int argc, char *argv[])
{

   struct SceKernelLoadExecVSHParam param;
   int apitype = 0;
   char *program = NULL;
   char *mode = NULL;
   
   pspDebugScreenInit();

   SceUID mod = sceKernelLoadModule("rdriver.prx", 0, NULL);
       if (mod >= 0)
   {
      mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
      if (mod < 0)
         ErrorExit(5000, "Error 0x%08X starting module.\n", mod);
   }
   else
   {
      if (mod == SCE_KERNEL_ERROR_EXCLUSIVE_LOAD)
      {
         // Ignore this error, it means the module loaded on reboot
      }

      else
      {
         ErrorExit(5000, "Error 0x%08X loading module.\n",  mod);
      }
   }


    printf("Press X to run homebrew at ms0:/PSP/GAME/HOMEBREW/EBOOT.PBP\n");
   printf("Press O to run UMD.\n");
   printf("Press triangle to run iso at ms0:/ISO/iso.iso in current M33 config mode.\n");
   printf("Press square to run pops game at ms0:/PSP/GAME/PSX/EBOOT.PBP.\n");
   printf("Press select to run updater at ms0:/PSP/GAME/UPDATE/EBOOT.PBP.\n");
   printf("Press start to exit.\n\n");
   printf("Note: when you exit in one of these programs, you will return here.\n");
   while (1)
   {
      SceCtrlData pad;
      sceCtrlReadBufferPositive(&pad, 1);
      if (pad.Buttons & PSP_CTRL_CROSS)
      {
         apitype = 0x141;
         program = "ms0:/PSP/GAME/HOMEBREW/EBOOT.PBP";
         mode = "game";
         break;
      }
      else if (pad.Buttons & PSP_CTRL_CIRCLE)
      {
         apitype = 0x120;
         program = "disc0:/PSP_GAME/SYSDIR/EBOOT.BIN";
         mode = "game";
         break;
      }
      else if (pad.Buttons & PSP_CTRL_TRIANGLE)
      {
         SEConfig config;      
         apitype = 0x120;
         program = "disc0:/PSP_GAME/SYSDIR/EBOOT.BIN";
         mode = "game";
         SetUmdFile("ms0:/ISO/iso.iso");
         sctrlSEGetConfigEx(&config, sizeof(config));
         if (config.umdmode == MODE_MARCH33)
         {
            SetConfFile(1);
         }
         else if (config.umdmode == MODE_NP9660)
         {
            SetConfFile(2);
         }
         else
         {
            // Assume this is is normal umd mode, as isofs will be deleted soon
            SetConfFile(0);
         }
         break;
      }
      else if (pad.Buttons & PSP_CTRL_SQUARE)
      {
         apitype = 0x143;
         program = "ms0:/PSP/GAME/PSX/EBOOT.PBP";
         mode = "pops";
         break;
      }
      else if (pad.Buttons & PSP_CTRL_SELECT)
      {
         apitype = 0x140;
         program = "ms0:/PSP/GAME/UPDATE/EBOOT.PBP";
         mode = "updater";
         break;
      }
      else if (pad.Buttons & PSP_CTRL_START)
      {
         RestoreExitGame();
         sceKernelExitGame();
      }
      sceKernelDelayThread(50000);
   }
   sceDisplaySetHoldMode(1);
   pspDebugScreenSetTextColor(0x0000FF00);
   printf("\n\nLoading selection...\n");

   memset(&param, 0, sizeof(param));
   param.size = sizeof(param);
   param.args = strlen(program)+1;
   param.argp = program;
   param.key = mode;

   sctrlKernelLoadExecVSHWithApitype(apitype, program, &param);
    return 0;

}
Back to top
View user's profile Send private message Send e-mail MSN Messenger
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Oct 21, 2008 10:48 pm    Post subject: Reply with quote

thanks this is great but what i was asking about was like how irshell has it to where you can press L + Select to go back and forth between the loaded program how can i do that in my program
Back to top
View user's profile Send private message MSN Messenger
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Wed Oct 22, 2008 3:39 am    Post subject: Reply with quote

See google for pluggin for m33 active him for vhs,game and psx1
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Wed Oct 22, 2008 11:08 am    Post subject: Reply with quote

Try to reverse the irshell prx files. Thats if you cant find the way todo so. Its not that easy todo so, including on what you are trying todo.
Back to top
View user's profile Send private message AIM Address
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Wed Oct 22, 2008 11:48 am    Post subject: Reply with quote

Wasn't irshell a kernel mode program?
It supposedly runs in kernel memory, which I guess is why some larger 1.50 kernel mode programs caused it to crash.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Wed Oct 22, 2008 9:41 pm    Post subject: Reply with quote

Yes it run in kernel mode. Ill post a example later then on how to run programs in the back ground. Its not that hard unless you want it to switch back and forth without and changes to happen. You can also output a file with some data on what or where it should be at.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Wed Nov 19, 2008 7:55 am    Post subject: Reply with quote

ok now i got it to load an eboot and come back too it but i was wondering using the bootload sample can some explain how it works like does the original game where the second game was launched stay in memory or exit and will it crash the psp if the original one was using alot of memory

also how can i restart the game and have it come back to it or shutdown the psp and have it come back to the game
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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