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 

Simple PRX work in fat but not in slim.

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



Joined: 15 Mar 2008
Posts: 7

PostPosted: Sat Mar 15, 2008 4:28 am    Post subject: Simple PRX work in fat but not in slim. Reply with quote

Hi to all!

I have write a simple prx to exit from the game after 1 second, after the game it's started.

The problem it's this: the PRX work in PSP FAT but not in PSP SLIM, why?
I need to do some change to the code for PSP SLIM?

This is the code:
Code:

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psppower.h>
#include <psploadexec.h>
#include <pspimpose_driver.h>

PSP_MODULE_INFO("EXIT", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(0);

SceCtrlData pad;
unsigned int pad_old;
SceUID main_thid;
SceUID display_thid;
int pausa;

int main()
{
sceKernelDelayThread(3000000);
sceKernelExitGame();
sceKernelDelayThread(1000);   
return 0;
}

int module_start(SceSize args, void *argp)
{
   main_thid = sceKernelCreateThread("Exit_main", main, 6, 0x04000, 0, NULL);
   if(main_thid >= 0) sceKernelStartThread(main_thid, args, argp);
   return 0;
   sceKernelExitDeleteThread(0);
}

int module_stop(SceSize args, void *argp)
{
   return 0;
}



Sorry for my not good english.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Mar 15, 2008 5:36 am    Post subject: Reply with quote

That's a kernel mode prx. You have to meet specific guidelines to use kernel mode prx's on the Slim. Look at the example code from HEN - you'll find my explanation about what is being done here:
http://forums.ps2dev.org/viewtopic.php?p=58653#58653
Back to top
View user's profile Send private message AIM Address
sbrillon1



Joined: 15 Mar 2008
Posts: 7

PostPosted: Sat Mar 15, 2008 6:50 am    Post subject: Reply with quote

The difference it's only in the header?
from this:

Code:
PSP_MODULE_INFO("EXIT", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(0);


to this:

Code:
PSP_MODULE_INFO("EXIT", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);


Because I try this modification, but don't work.[/code]
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Mar 15, 2008 8:13 am    Post subject: Reply with quote

There's also a BIG difference in the main program's makefile: it builds the app as a prx.

Code:
BUILD_PRX = 1


You cannot load kernel prxs from an app unless the app is also a prx. If you don't build the main app as a prx, any attempts to load/start a kernel prx just fail.
Back to top
View user's profile Send private message AIM Address
sbrillon1



Joined: 15 Mar 2008
Posts: 7

PostPosted: Sat Mar 15, 2008 8:16 am    Post subject: Reply with quote

In the make file i have builds the app as a prx:

Code:
TARGET = gameReboot
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BUILD_PRX = 1
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS =


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Back to top
View user's profile Send private message
sbrillon1



Joined: 15 Mar 2008
Posts: 7

PostPosted: Wed Mar 19, 2008 6:48 am    Post subject: Reply with quote

Does nobody know how to help me? Please :-)
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Mar 19, 2008 7:40 am    Post subject: Reply with quote

Do both the phat and the slim have the same firmware? You are calling the exit game function as a kernel function, and the kernel function NIDs changed starting with 3.70. At a guess, I'd say the NID is wrong for the slim. I also doubt that D_A put the kernel version of exit in the NID resolver for 3.80/3.90 since only an idiot would call exit from kernel mode on 3.xx software.

Which brings me to the real point - why are you trying to make the game exit from a kernel prx? You should just have the exit in the game itself, not a prx. Is this a plugin that FORCES a game to quit under certain circumstances? If so, it's a completely different ball of wax, and probably the problem is the one mentioned above about the NIDs.
Back to top
View user's profile Send private message AIM Address
sbrillon1



Joined: 15 Mar 2008
Posts: 7

PostPosted: Thu Mar 20, 2008 5:01 am    Post subject: Reply with quote

Both the psp have the 3.90 M33.

The PRX that I have inserted was only an example to understand whether to make to go it on slim, the true prx that I would like to do it is this (don't run in slim):

Code:
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <psprtc.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

#include <kubridge.h>

#include "main.h"


PSP_MODULE_INFO("video", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);

SceUID main_thid;

int pspDveMgrCheckVideoOut();
int pspDveMgrSetVideoOut(int, int, int, int, int, int, int);

int threadMain(void)
{
   SceCtrlData pad;
   int cable, i, u, width, height, displaymode;
   u32 *vram;
   u64 tick;
   SceKernelUtilsMt19937Context ctx;

   while (1)
   {
      sceCtrlReadBufferPositive(&pad, 1);

      if (pad.Buttons & PSP_CTRL_SELECT)
      {
            if (pspSdkLoadStartModule("dvemgr.prx", PSP_MEMORY_PARTITION_KERNEL) < 0)
               {
                  sceKernelExitGame();
               }
         
            cable = pspDveMgrCheckVideoOut();
           if (cable == 0)
           {
             while (cable == 0)
             {
                  sceKernelDelayThread(10000);
                     cable = pspDveMgrCheckVideoOut();         
               }
            }

           if (cable != 1 && cable != 2)
           {
               sceKernelExitGame();
            }


           sceKernelDelayThread(5*1000*1000);

           if (cable == 1) // composite, sdtv
           {
                    u = 2;
                    width = 720;
                    height = 503;
                    displaymode = 0x1D1;
            }
           else // 2, component, (and probably d-terminal too)
           {
               u = 0;
               width = 720;
               height = 480;
               displaymode = 0x1D2;
            }

    sceRtcGetCurrentTick(&tick);
   sceKernelUtilsMt19937Init(&ctx, (u32)tick);

   vram = (u32 *)(0x40000000 | (u32)sceGeEdramGetAddr());
   
   pspDveMgrSetVideoOut(u, displaymode, width, height, 1, 15, 0);
   sceDisplaySetFrameBuf(vram, 1024, PSP_DISPLAY_PIXEL_FORMAT_8888, 1);         
         
   while (1)
   {         
      sceDisplayWaitVblankStart();
      sceKernelDelayThread(500000);
   }

    }//End if premi SELECT
    } //End while

    return 0;
}


int module_start(SceSize args, void *argp)
{
   main_thid = sceKernelCreateThread("video_main", threadMain, 6, 0x4000, 0, NULL);
   if(main_thid >= 0) sceKernelStartThread(main_thid, args, argp);
   return 0;
   sceKernelExitDeleteThread(0);
}

int module_stop(SceSize args, void *argp)
{
   return 0;
}


Make:
Code:
TARGET = gamevideo
OBJS = main.o pspDveManager.o

BUILD_PRX=1

CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

INCDIR = ../include
LIBDIR = ../lib
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspkubridge -lpspsysmem_kernel -lpspsystemctrl_kernel -lpsprtc

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
Back to top
View user's profile Send private message
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