Saturday, March 3, 2007

Nice! jojo's 1st program on psp~~!

Saturday, 24. February 2007, 00:24:06

C, PSP, 随手记

it really works on my psp~~!:D


按照http://www.psp-programming.com上的tutorials手动完成了自己的第一个psp程序!

hello_psp.c

#include
#include

PSP_MODULE_INFO("hello psp",0,1,1);

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback(int arg1,int arg2,void *common){
sceKernelExitGame();
return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp){
int cbid;

cbid=sceKernelCreateCallback("Exit Callback",exit_callback,NULL);
sceKernelRegisterExitCallback(cbid);

sceKernelSleepThreadCB();

return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void){
int thid=0;

thid=sceKernelCreateThread("update_thread",CallbackThread,0x11,0xFA0,0,0);
if(thid>=0){
sceKernelStartThread(thid,0,0);
}

return thid;
}

int main(){
pspDebugScreenInit();
SetupCallbacks();

printf("hello psp!jojo's 1st psp program!");

sceKernelSleepThread();

return 0;
}





这个是Makefile

TARGET = hello_psp
OBJS = hello_psp.o

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

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = hello psp

PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak



ok,之后运行#gmake kxploit,编译连接成功后就产生了包含能运行在psp1.5firmware上的程序的两个文件夹hello_psp和hello_psp%。nice~~!:beer: (对于1.0 firmware,只要gmake就能产生直接在psp上运行的程序了,我没试过,应该可以。)

No comments: