example of stub to firmware:
pspUtility.S(assembly):
Code: Select all
.set noreorder
#include "pspstub.s" //included in pspsdk
STUB_START "sceUtility",0x40010000,0x00240005
STUB_FUNC 0xc492f751,sceUtilityGameSharingInitStart
STUB_FUNC 0xefc6f80f,sceUtilityGameSharingShutdownStart
STUB_FUNC 0x7853182d,sceUtilityGameSharingUpdate
STUB_FUNC 0x946963f3,sceUtilityGameSharingGetStatus
STUB_FUNC 0x3ad50ae7,sceNetplayDialogInitStart
STUB_FUNC 0xbc6b6296,sceNetplayDialogShutdownStart
STUB_FUNC 0x417bed54,sceKernelAutomagicallyPlaybackDevice
... //rest of stubbed functions
STUB_END
pspUtility.h (C code):
Code: Select all
#ifndef PSP_UTILITY_H
#define PSP_UTILITY_H
//preprocessor macros, defines, includes etc..;
//some structures for osk use
typedef struct SceUtilityOskInputFieldInfo_s {
unsigned int input_method_type;
unsigned int input_method_attributes;
unsigned int writing_language_type;
int hide_mode;
int input_character_type;
int num_lines;
int kinsoku;
SceWChar16 *message;
SceWChar16 *init_text;
int result_text_buffer_size;
SceWChar16 *result_text_buffer;
int result;
int limit_length;
} SceUtilityOskInputFieldInfo;
typedef struct SceUtilityOskParam_s {
SceUtilityParamBase base;
unsigned int num_input_fields;
SceUtilityOskInputFieldInfo *input_field_info;
int local_status;
int error;
} SceUtilityOskParam;
//prototypes for stub functions from pspUtility.S
int sceUtilityOskInitStart(SceUtilityOskParam* param);
int sceUtilityOskShutdownStart(void);
int sceUtilityOskUpdate(int animation_speed);
int sceUtilityOskGetStatus(void);
Makefile:
Code: Select all
... //lets skip to important lines
OBJS = \
main.o \
draw.o \
pspUtility.o \ //the above pspUtility.S will be created into a object
//so we can use those stub functions
... //etc...
and thats all you need to use your stubs
Note: HOW to create your stubs you will have to
figure that on your own ...its too simple and clues
are plentiful on this thread for example
to get the prototypes you will have to learn Mips Asm :P
of course if you learn that first then you would not
need help from examples like this post ...so go learn!
Example of Use:
Code: Select all
#include "pspUtility.h"
//lets use an above function ....say sceUtilityOskInitStart();
//so we can use the sony osk...all this is done in the osk sample if
//youd like to see complete source of use
...
...
//function to handle users input
int getOskInput(const char* name, const char* input, char* output, unsigned int len){
...
//variable for osk data
SceUtilityOskParam osk;
memset(&osk, 0, sizeof(osk));
osk.base.size = sizeof(osk);
osk.base.message_lang = 2;
osk.base.ctrl_assign = GetEnterButton();
osk.base.main_thread_priority = 17;
osk.base.sub_thread_priority = 19;
osk.base.font_thread_priority = 18;
osk.base.sound_thread_priority = 16;
//also setup input field info
SceUtilityOskInputFieldInfo inparam;
memset(&inparam, 0, sizeof(inparam));
inparam.input_method_type = 0x000D;
inparam.input_method_attributes = 0;
inparam.writing_language_type = 0x0005;
inparam.hide_mode = 0;
inparam.input_character_type = 0;
inparam.num_lines = 4;
inparam.kinsoku = 1;
inparam.message = name16;
inparam.init_text = input16;
inparam.result_text_buffer = output16;
inparam.result_text_buffer_size = 512;
inparam.result = 0;
inparam.limit_length = len;
//everything is setup lets init osk
int rc = sceUtilityOskInitStart(&osk);
if(rc) {
return 1;
}
//main loop ...infinite
for(;;){
drawFrame();
//use another stub
int status = sceUtilityOskGetStatus();
switch(state) {
//... do what you will
}
drawFlip();
}
return 1;
} //end of getOskInput()
...//continue source