It's very strange... it freezes and crashes, file in flash0 isn't created...
P.S. I tried also:
- Code: Select all
PSP_MODULE_INFO("EasyDualboot", 0x1000, 1, 2);
But nothing...
Can i post complete source codes in a RAR archive?
Here are my files:
main.c
- Code: Select all
#include <pspkernel.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <pspsdk.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
PSP_MODULE_INFO("TestFlash", 0x1000, 1, 2);
PSP_MAIN_THREAD_ATTR(0);
#define MAX_THREAD 64
int language=0;
FILE *config;
int lingua;
SceCtrlData currentPad, lastPad, Pad;
int setLanguage()
{
config=fopen("flash1:/config.db", "r");
char buffer;
if( config == NULL){
lingua = 0;
}else{
fread ((void *)&buffer,sizeof(char),1,config);
char buffers[100];
sprintf(buffers,"%c",buffer);
if (strcmp(buffers,"1")==0){
lingua = 1;
}else{
lingua = 0;
}
fclose(config);
}
return lingua;
}
char write_buffer[128*1024];
void copyFile(char *basefile,char *nuovofile){
sceIoUnassign("flash0");
sceIoAssign("flash0", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
FILE *from, *to;
char ch;
from = fopen(basefile, "rb");
to = fopen(nuovofile, "wb");
while(!feof(from)) {
ch = fgetc(from);
if(!feof(from)) fputc(ch, to);
}
fclose(from);
fclose(to);
}
int main_thread(SceSize args, void *argp) {
sceKernelDelayThread(3000000);
while(1)
{
sceCtrlPeekBufferPositive(¤tPad,1);
if ((currentPad.Buttons & PSP_CTRL_HOME) && (currentPad.Buttons & PSP_CTRL_LTRIGGER) && (currentPad.Buttons & PSP_CTRL_RTRIGGER)){
language=setLanguage();
if (language == 1){
copyFile("ms0:/test.prx", "flash0:/test.prx");
}else{
copyFile("ms0:/test2.prx", "flash0:/test.prx");
}
fclose(config);
}
sceKernelDelayThread(500);
}
return 0;
}
int module_start(SceSize args, void *argp) {
int thid;
/* Create a high priority thread */
thid = sceKernelCreateThread("TestFlash", main_thread, 0x18, 0x1000, 0, NULL);//8, 64*1024, PSP_THREAD_ATTR_USER, NULL);
if(thid >= 0) sceKernelStartThread(thid, args, argp);
return 0;
}
Makefile
- Code: Select all
TARGET = TestFlash
OBJS = main.o
BUILD_PRX = 1
PRX_EXPORTS = exports.exp
#USE_PSPSDK_LIBC = 1
INCDIR =
LIBDIR =
LIBS = -lz -lm -lpspumd
LDFLAGS =
CFLAGS = -Os -G0 -Wall -g
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
exports:
psp-build-exports -s exports.exp




