my prx doesn't printf

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
rus_pa
Posts: 13
Joined: Mon Jan 07, 2008 9:42 am

my prx doesn't printf

Post by rus_pa »

hy, I just managed to compile & load successfully a prx :D (got troubles.. anyway)
I exported some functions, the first returns an integer, another writes to screen a junkie text.

calling from the main program, the first writes my integer to screen, the second doesn't do anything, seems to just skip.

the prx code is this

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdisplay_kernel.h> 
#include <stdio.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>

PSP_MODULE_INFO&#40;"myLib", 0x1006, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

u32 k1;

void write_me&#40;int number&#41;&#123;
    k1 = pspSdkSetK1&#40;0&#41;;
    printf&#40;"&#40;%d&#41;",number&#41;;
    
//next line blows up the compile &#58;P    
//pspDebugScreenPrintf&#40;"&#40;%d&#41;", number&#41;;
    
    pspSdkSetK1&#40;k1&#41;;
&#125;

int module_start&#40;SceSize args, void *argp&#41;
&#123;
    printf&#40;"PRX module starting...\n"&#41;;
   return 0;
&#125;

int module_stop&#40;&#41;
&#123;
   return 0;
&#125; 

int give_me&#40;&#41;&#123;

    return 5;
&#125;
neither the "module starting..." is displayed.
Why?
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Re: my prx doesn't printf

Post by Hellcat »

rus_pa wrote://next line blows up the compile :P
//pspDebugScreenPrintf("(%d)", number);
Because you can't link user functions into kernel mode modules.
Make your kernel PRX return the value to the usermode PRX and output it from there.

I currently don't know how the standard C "printf" is defined on the PSP, but you need to call pspDebugScreenPrintf() to output anything.
Don't forget to init the debug screen first!
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Re: my prx doesn't printf

Post by PSPfreak! »

Hellcat wrote: I currently don't know how the standard C "printf" is defined on the PSP, but you need to call pspDebugScreenPrintf() to output anything.
Don't forget to init the debug screen first!
isnt it

Code: Select all

#define printf  pspDebugScreenPrintf

printf&#40;"blah blah blah"&#41;;
/*prints blah blah blah to the psp screen*/
that works??, isnt that how its defined? or were you meaning something else? lol
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

isnt it ...
Yeah....rus_pa didn't quoted it from its source, but i guess it was understood. Anyway, even if printf was defined, initialized and allowed in a kernel prx like that, it's not a good practice to use it that way... return a string and do whatever you want with it in your usermode code
Post Reply