Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
sauron_le_noir
Posts: 203 Joined: Sat Jul 05, 2008 8:03 am
Post
by sauron_le_noir » Wed Sep 10, 2008 5:26 am
I try to port a Nintendo DS emulator to the psp it compile now without error
generating a EBOOT.BPB but when starting the emulator i've got this
0x80020148 ----> ,unsupportedPRXtype
My psp is a slim running CF4.01M33-2
here is my makefile
Code: Select all
TARGET = pspds
OBJS = armcpu.o fs-linux.o opengl_collector_3Demu.o arm_instructions.o render3D.o bios.o gl_vertex.o ROMReader.o cflash.o GPU.o saves.o cp15.o matrix.o sndsdl.o ctrlssdl.o mc.o SPU.o debug.o MMU.o thumb_instructions.o Disassembler.o NDSSystem.o wifi.o FIFO.o main.o psp_main.o
PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
INCDIR =
CFLAGS = -O2 -G0 -Wall $(DEFAULT_CFLAGS)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PSP_FW_VERSION = 401
PSP_LARGE_MEMORY = 1
DS_EMULATOR_VERSION=1.0.0
LIBDIR =
LIBS += -lpspwlan -lpsppower -lSDL_image -lSDL -lpng -ljpeg -lpspaudio -lpspgu -lpsphprm -lz -lm -lstdc++ -lGL -lpspirkeyb -lpsppower -lpspvfpu -lpsprtc
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = DS-EMULATOR-v$(DS_EMULATOR_VERSION)
PSP_EBOOT_ICON= ds-emulator.png
PSP_EBOOT_PIC1 = ds-emulator-pic.png
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
J.F.
Posts: 2906 Joined: Sun Feb 22, 2004 11:41 am
Post
by J.F. » Wed Sep 10, 2008 7:42 am
Make sure you main file has the module info/et all set for a user-mode prx, like this
Code: Select all
PSP_MODULE_INFO("MyProgram", 0, PSP_VERS, PSP_REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-256);
sauron_le_noir
Posts: 203 Joined: Sat Jul 05, 2008 8:03 am
Post
by sauron_le_noir » Wed Sep 10, 2008 4:37 pm
it has
Code: Select all
#include <stdio.h>
#include <zlib.h>
#include "SDL.h"
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <pspthreadman.h>
#include <pspwlan.h>
#include <pspkernel.h>
#include <psppower.h>
#include <stdlib.h>
#include <stdio.h>
extern int SDL_main(int argc, char *argv[]);
PSP_MODULE_INFO("PSPNDS", PSP_MODULE_USER, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(-256);
;
int sdl_psp_exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
int sdl_psp_callback_thread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback",
sdl_psp_exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int sdl_psp_setup_callbacks(void)
{
int thid = 0;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
thid = sceKernelCreateThread("update_thread",
sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
extern void _fini(void);
#ifdef main
#undef main
#endif
void
user_thread(SceSize argss, void *argp)
{
char *ptr[] = { "emul","ms0:/PSP/GAME/DS/TEST.NDS",NULL };
int args = 2;
sdl_psp_setup_callbacks();
pspDebugScreenPrintf("\nBefore SDL !\n");
// SDL_main(args, ptr);
}
int
main(int argc, char *argv[])
{
int user_thid;
pspDebugScreenInit();
/* Functions registered with atexit() are called in reverse order, so make
sure that we register sceKernelExitGame() first, so that it's called last. */
atexit(sceKernelExitGame);
/* Make sure that _fini() is called before returning to the OS. */
atexit(_fini);
pspDebugScreenPrintf("\nLaunch main thread !\n");
sceKernelDelayThread(1000000);
user_thid = sceKernelCreateThread( "user_thread",
(SceKernelThreadEntry)user_thread, 0x11, 256*1024, PSP_THREAD_ATTR_USER, 0 );
if(user_thid >= 0) {
sceKernelStartThread(user_thid, 0, 0);
sceKernelWaitThreadEnd(user_thid, NULL);
}
/* Delay 2.5 seconds before returning to the OS. */
sceKernelDelayThread(2500000);
return 0;
}
J.F.
Posts: 2906 Joined: Sun Feb 22, 2004 11:41 am
Post
by J.F. » Thu Sep 11, 2008 6:00 am
You don't need to create a user thread - you ARE a user thread. Remove that code. That code was clearly from a project that used to run in kernel mode, so I'd guess the error is due to some other kernel-mode function still in the code. One common one you saw in a lot of older apps set the general exception vector to trap crashes. That doesn't work in 3.xx/4.xx without a special kernel-mode prx. If you look at the dosbox thread, you'll find such a prx if you want exception trapping in your app.