 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Thu Sep 21, 2006 11:36 pm Post subject: Simple PRX Problem |
|
|
I've been trying to make a simple prx that just writes to a file when you press X but when I load it with DevHook it crashes the PSP when the Playstation animation comes up...
I copied my test.prx file to the root of the memstick ms0:/test.prx and then added that line to the following DevHook files (after the /kd/isofs.prx line),
ms0://dh/260/flash0/kd/pspbtcnf.txt
ms0://dh/260/flash0/kd/pspbtcnf_game.txt
My prx did nothing before I added this to the top of the source and after I did that it started crashing...
PSP_MODULE_INFO("PRX Test", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
Can anyone see what i'm doing wrong here... Here's the main.c file,
| Code: | #include <pspctrl.h>
#include <pspkernel.h>
#include <stdio.h>
PSP_MODULE_INFO("PRX Test", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
int MainThread (SceSize args, void *argp) {
SceCtrlData pad;
int i;
FILE* fp;
while (1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS) {
fp = fopen("ms0:/test.txt","w+");
if (fp) {
fprintf(fp,"Pressed X");
}
fclose(fp);
}
for (i=0; i<5; i++) {
sceDisplayWaitVblankStart();
}
}
return 0;
}
int module_start(SceSize args, void *argp) {
SceUID thid;
thid = sceKernelCreateThread("PRX_Test", MainThread, 0x18, 0x1000, 0, NULL);
if (thid >= 0) sceKernelStartThread(thid, args, argp);
return 0;
}
int module_stop(void) {
return 0;
} |
Here's the makefile,
| Code: | TARGET = test
OBJS = main.o
BUILD_PRX=1
USE_PSPSDK_LIBC=1
USE_PSPSDK_LIBS=1
#USE_KERNEL_LIBC=1
#USE_KERNEL_LIBS=1
PRX_EXPORTS=exports.exp
INCDIR =
CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
and here's the exports.exp,
| Code: | # Define the exports for the prx
PSP_BEGIN_EXPORTS
# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC(module_start)
PSP_EXPORT_VAR(module_info)
PSP_EXPORT_FUNC(module_stop)
PSP_EXPORT_END
PSP_END_EXPORTS |
|
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Fri Sep 22, 2006 3:54 am Post subject: |
|
|
Use sceIO* commands for file manipulation...
Here's a stripped down example of devhook prx:
Makefile:
| Code: | TARGET = controls
OBJS = crt0_prx.o
# Define to build this as a prx (instead of a static elf)
BUILD_PRX=1
# Define the name of our custom exports (minus the .exp extension)
PRX_EXPORTS=exports.exp
USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
#LIBS =
LDFLAGS = -nostdlib -nodefaultlibs
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
crt0_prx.c:
| Code: | /*
based by
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* crt0_prx.c - Pure PRX startup code.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
*
* $Id: crt0.c 1526 2005-12-06 21:56:06Z tyranid $
*/
#include <pspkerneltypes.h>
#include <pspmoduleinfo.h>
#include <pspiofilemgr.h>
#include <pspthreadman.h>
#include <stdlib.h>
#include <string.h>
PSP_MODULE_INFO("TESTPLUGIN", 0x3007, 1, 2);
PSP_MAIN_THREAD_ATTR(0); // 0 for kernel mode too
int module_start(SceSize args, void *argp) __attribute__((alias("_start")));
int _start(SceSize args, void *argp)
{
int x,ret;
char *done="\nLOADED module!!!\n";
int afd;
afd = sceIoOpen("ms0:/test.txt", PSP_O_WRONLY|PSP_O_CREAT|PSP_O_APPEND, 0777);
sceIoWrite(afd, done, strlen(done)*sizeof(char));
sceIoClose(afd);
//
// ADD YOUR THREAD STARTING HERE
//
return 0;
}
|
exports.exp:
| Code: | # Define the exports for the prx
PSP_BEGIN_EXPORTS
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
PSP_END_EXPORTS
|
|
|
| Back to top |
|
 |
|
|
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
|