Hmm...
Now when I try and add it to the shim it fails to compile.
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <pspuser.h>
#include <pikeylib.h>
#define VERS 1
#define REVS 0
#define MAX_ARGS 2048
PSP_MODULE_INFO("PikeyLibShim", 0x1006, VERS, REVS);
PSP_MAIN_THREAD_ATTR(0);
void putNextCharW_3xx(int ch)
{
unsigned int k1 = pspSdkSetK1(0);
putNextCharW(ch);
pspSdkSetK1(k1);
}
void putNextChar_3xx(char ch)
{
unsigned int k1 = pspSdkSetK1(0);
putNextChar(ch);
pspSdkSetK1(k1);
}
int numCharsAvailable_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = numCharsAvailable();
pspSdkSetK1(k1);
return retv;
}
void flushBuffer_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
flushBuffer();
pspSdkSetK1(k1);
}
int getNextCharW_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = getNextCharW();
pspSdkSetK1(k1);
return retv;
}
char getNextChar_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
char retv = getNextChar();
pspSdkSetK1(k1);
return retv;
}
int peekNChars_3xx(int n, int *buffer)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = peekNChars(n, buffer);
pspSdkSetK1(k1);
return retv;
}
void throwAwayInput_3xx(int numchars)
{
unsigned int k1 = pspSdkSetK1(0);
throwAwayInput(numchars);
pspSdkSetK1(k1);
}
void sioPrint_3xx(const char * str)
{
unsigned int k1 = pspSdkSetK1(0);
sioPrint(str);
pspSdkSetK1(k1);
}
void sioPrintHex_3xx(char ch)
{
unsigned int k1 = pspSdkSetK1(0);
sioPrintHex(ch);
pspSdkSetK1(k1);
}
void sioPrintWord_3xx(int word)
{
unsigned int k1 = pspSdkSetK1(0);
sioPrintWord(word);
pspSdkSetK1(k1);
}
int waitForModule_3xx(const char *name)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = waitForModule(name);
pspSdkSetK1(k1);
return retv;
}
int requestExclusive_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = requestExclusive();
pspSdkSetK1(k1);
return retv;
}
void releaseExclusive_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
releaseExclusive();
pspSdkSetK1(k1);
}
u32 apiHookByNid_3xx(const char *modname, const char *libname, u32 nid, void *func)
{
unsigned int k1 = pspSdkSetK1(0);
u32 retv = apiHookByNid(modname, libname, nid, func);
pspSdkSetK1(k1);
return retv;
}
u32 callApiHook_3xx(u32 hookid, ...)
{
unsigned int k1 = pspSdkSetK1(0);
u32 retv = callApiHook(hookid);
pspSdkSetK1(k1);
return retv;
}
void unHookApi_3xx(u32 hookid)
{
unsigned int k1 = pspSdkSetK1(0);
unHookApi(hookid);
pspSdkSetK1(k1);
}
int registerDisplayCallback_3xx(SceUID callback)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = registerDisplayCallback(callback);
pspSdkSetK1(k1);
return retv;
}
void drawKeyboardInfo_3xx(DRAWINFO *drawinfo)
{
unsigned int k1 = pspSdkSetK1(0);
drawKeyboardInfo(drawinfo);
pspSdkSetK1(k1);
}
void displayStatusText_3xx(const char *text)
{
unsigned int k1 = pspSdkSetK1(0);
displayStatusText(text);
pspSdkSetK1(k1);
}
int isVshMode_3xx()
{
unsigned int k1 = pspSdkSetK1(0);
int retv = isVshMode();
pspSdkSetK1(k1);
return retv;
}
void sendKeyPress_3xx(int a,int b,int c,int d,int e)
{
unsigned int k1 = pspSdkSetK1(0);
sendKeyPress(a,b,c,d,e);
pspSdkSetK1(k1);
}
void flushKeyPresses_3xx(void )
{
unsigned int k1 = pspSdkSetK1(0);
flushKeyPresses();
pspSdkSetK1(k1);
}
int setMode_3xx(int a)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = setMode(a);
pspSdkSetK1(k1);
return retv;
}
int getMode_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = getMode();
pspSdkSetK1(k1);
return retv;
}
int isKeyPressed_3xx(int a)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = isKeyPressed(a);
pspSdkSetK1(k1);
return retv;
}
void getMetaKeys_3xx(int *alt, int *ctrl, int *shift)
{
unsigned int k1 = pspSdkSetK1(0);
getMetaKeys(alt, ctrl, shift);
pspSdkSetK1(k1);
}
int numKeysPressed_3xx(void)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = numKeysPressed();
pspSdkSetK1(k1);
return retv;
}
int configOpen_3xx(const char *filename)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = configOpen(filename);
pspSdkSetK1(k1);
return retv;
}
int configRead_3xx(int cfgHandle, char *token, char *value)
{
unsigned int k1 = pspSdkSetK1(0);
int retv = configRead(cfgHandle, token, value);
pspSdkSetK1(k1);
return retv;
}
void configClose_3xx(int cfgHandle)
{
unsigned int k1 = pspSdkSetK1(0);
configClose(cfgHandle);
pspSdkSetK1(k1);
}
int isPikeyLoaded_3xx()
{
unsigned int k1 = pspSdkSetK1(0);
int retv = isPikeyLoaded();
pspSdkSetK1(k1);
return retv;
}
SceUID myLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[])
{
SceKernelLMOption option;
SceUID modid = 0;
int retVal = 0, mresult;
char args[MAX_ARGS];
int argpos = 0;
memset(args, 0, MAX_ARGS);
strcpy(args, filename);
argpos += strlen(args) + 1;
// for(i = 0; (i < argc) && (argpos < MAX_ARGS); i++)
// {
// int len;
//
// snprintf(&args[argpos], MAX_ARGS-argpos, "%s", argv[i]);
// len = strlen(&args[argpos]);
// argpos += len + 1;
// }
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
retVal = sceKernelLoadModule(filename, 0, &option);
if(retVal < 0){
return retVal;
}
modid = retVal;
retVal = sceKernelStartModule(modid, argpos, args, &mresult, NULL);
if(retVal < 0){
return retVal;
}
return modid;
}
int initPikey_3xx()
{
int retv;
unsigned int k1 = pspSdkSetK1(0);
SceUID mod = myLoadStartModuleWithArgs("flash0:/kd/irda.prx", PSP_MEMORY_PARTITION_USER, 0, NULL);
if (mod < 0)
retv = mod;
else
retv = initPikey();
pspSdkSetK1(k1);
return retv;
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
The error:
Code: Select all
> "make"
psp-gcc -I/c/devkitPro/devkitPSP/psp/sdk/include/libc -I. -I/c/devkitPro/devkitPSP/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -c -o main.o main.c
main.c: In function 'sioPrintWord_3xx':
main.c:116: warning: implicit declaration of function 'sioPrintWord'
psp-build-exports -b pikeylibshim.exp > pikeylibshim.c
psp-gcc -I/c/devkitPro/devkitPSP/psp/sdk/include/libc -I. -I/c/devkitPro/devkitPSP/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -c -o pikeylibshim.o pikeylibshim.c
psp-gcc -I/c/devkitPro/devkitPSP/psp/sdk/include/libc -I. -I/c/devkitPro/devkitPSP/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -L/c/devkitPro/devkitPSP/psp/sdk/lib -specs=/c/devkitPro/devkitPSP/psp/sdk/lib/prxspecs -Wl,-q,-T/c/devkitPro/devkitPSP/psp/sdk/lib/linkfile.prx -mno-crt0 -nostartfiles main.o pikeylibshim.o -lpspkernel -lpikey -lpspdebug -lpspdisplay_driver -lpspctrl_driver -lpspsdk -lpspkernel -o pikeylibshim.elf
psp-fixup-imports pikeylibshim.elf
Error, could not fixup imports, stubs out of order.
Ensure the SDK libraries are linked in last to correct this error
"make": *** [pikeylibshim.elf] Error 1
rm pikeylibshim.c
> Process Exit Code: 2
> Time Taken: 00:03
But then when I make again, it compiles the ELF into a PRX:
Code: Select all
> "make"
psp-prxgen pikeylibshim.elf pikeylibshim.prx
> Process Exit Code: 0
> Time Taken: 00:00
I test the PRX and as suspected it fails!
Any ideas?
If you want more code, let me know!
Angelo