Simple PRX work in fat but not in slim.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sbrillon1
Posts: 7
Joined: Sat Mar 15, 2008 4:13 am

Simple PRX work in fat but not in slim.

Post by sbrillon1 »

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: Select all

#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&#40;"EXIT", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
PSP_MAIN_THREAD_STACK_SIZE_KB&#40;0&#41;;

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

int main&#40;&#41;
&#123;
sceKernelDelayThread&#40;3000000&#41;;
sceKernelExitGame&#40;&#41;;
sceKernelDelayThread&#40;1000&#41;;    
return 0;
&#125;

int module_start&#40;SceSize args, void *argp&#41;
&#123;
	main_thid = sceKernelCreateThread&#40;"Exit_main", main, 6, 0x04000, 0, NULL&#41;;
	if&#40;main_thid >= 0&#41; sceKernelStartThread&#40;main_thid, args, argp&#41;;
	return 0;
	sceKernelExitDeleteThread&#40;0&#41;;
&#125;

int module_stop&#40;SceSize args, void *argp&#41;
&#123;
	return 0;
&#125;

Sorry for my not good english.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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
sbrillon1
Posts: 7
Joined: Sat Mar 15, 2008 4:13 am

Post by sbrillon1 »

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

Code: Select all

PSP_MODULE_INFO&#40;"EXIT", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
PSP_MAIN_THREAD_STACK_SIZE_KB&#40;0&#41;; 
to this:

Code: Select all

PSP_MODULE_INFO&#40;"EXIT", 0x1006, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;
Because I try this modification, but don't work.[/code]
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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

Code: Select all

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.
sbrillon1
Posts: 7
Joined: Sat Mar 15, 2008 4:13 am

Post by sbrillon1 »

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

Code: Select all

TARGET = gameReboot
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

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


PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak 
sbrillon1
Posts: 7
Joined: Sat Mar 15, 2008 4:13 am

Post by sbrillon1 »

Does nobody know how to help me? Please :-)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

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.
sbrillon1
Posts: 7
Joined: Sat Mar 15, 2008 4:13 am

Post by sbrillon1 »

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: Select all

#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&#40;"video", 0x1000, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;

SceUID main_thid;

int pspDveMgrCheckVideoOut&#40;&#41;;
int pspDveMgrSetVideoOut&#40;int, int, int, int, int, int, int&#41;;

int threadMain&#40;void&#41;
&#123;
	SceCtrlData pad;
	int cable, i, u, width, height, displaymode;
	u32 *vram; 
	u64 tick;
	SceKernelUtilsMt19937Context ctx;

	while &#40;1&#41;
	&#123;
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

		if &#40;pad.Buttons & PSP_CTRL_SELECT&#41;
		&#123;
				if &#40;pspSdkLoadStartModule&#40;"dvemgr.prx", PSP_MEMORY_PARTITION_KERNEL&#41; < 0&#41;
					&#123;
					   sceKernelExitGame&#40;&#41;;
					&#125;
			
            cable = pspDveMgrCheckVideoOut&#40;&#41;;
	        if &#40;cable == 0&#41;
	        &#123;
		       while &#40;cable == 0&#41;
		       &#123;
			         sceKernelDelayThread&#40;10000&#41;;
                     cable = pspDveMgrCheckVideoOut&#40;&#41;;			
               &#125;
            &#125;

	        if &#40;cable != 1 && cable != 2&#41;
	        &#123;
         		sceKernelExitGame&#40;&#41;;
            &#125;


	        sceKernelDelayThread&#40;5*1000*1000&#41;;

	        if &#40;cable == 1&#41; // composite, sdtv
	        &#123;
		              u = 2;
		              width = 720;
		              height = 503;
		              displaymode = 0x1D1;
            &#125;
	        else // 2, component, &#40;and probably d-terminal too&#41;
	        &#123;
		         u = 0;
		         width = 720;
		         height = 480;
		         displaymode = 0x1D2;
            &#125;

    sceRtcGetCurrentTick&#40;&tick&#41;;
	sceKernelUtilsMt19937Init&#40;&ctx, &#40;u32&#41;tick&#41;;

	vram = &#40;u32 *&#41;&#40;0x40000000 | &#40;u32&#41;sceGeEdramGetAddr&#40;&#41;&#41;;
	
	pspDveMgrSetVideoOut&#40;u, displaymode, width, height, 1, 15, 0&#41;;
	sceDisplaySetFrameBuf&#40;vram, 1024, PSP_DISPLAY_PIXEL_FORMAT_8888, 1&#41;;			
			
	while &#40;1&#41;
	&#123;			
		sceDisplayWaitVblankStart&#40;&#41;;
		sceKernelDelayThread&#40;500000&#41;;
	&#125;

    &#125;//End if premi SELECT
    &#125; //End while

    return 0;
&#125;


int module_start&#40;SceSize args, void *argp&#41;
&#123;
	main_thid = sceKernelCreateThread&#40;"video_main", threadMain, 6, 0x4000, 0, NULL&#41;;
	if&#40;main_thid >= 0&#41; sceKernelStartThread&#40;main_thid, args, argp&#41;;
	return 0;
	sceKernelExitDeleteThread&#40;0&#41;;
&#125;

int module_stop&#40;SceSize args, void *argp&#41;
&#123;
	return 0;
&#125;
Make:

Code: Select all

TARGET = gamevideo
OBJS = main.o pspDveManager.o

BUILD_PRX=1

CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

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

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build_prx.mak
Post Reply