| Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita |
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <pspthreadman_kernel.h>
PSP_MODULE_INFO("TEST", PSP_MODULE_KERNEL, 0, 1);
PSP_NO_CREATE_MAIN_THREAD();
int main_thread(SceSize argc, void* argp) {
SceUID thid;
int res;
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
while (1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons != 0) {
if (pad.Buttons & PSP_CTRL_LTRIGGER) {
res = pspSdkReferThreadStatusByName("user_main", &thid, NULL);
res = sceKernelSuspendThread(thid);
pspDebugScreenInit();
pspDebugScreenPrintf("testing...");
}
if (pad.Buttons & PSP_CTRL_RTRIGGER) {
res = pspSdkReferThreadStatusByName("user_main", &thid, NULL);
res = sceKernelResumeThread(thid);
}
}
sceKernelDelayThread(100000);
}
sceKernelExitDeleteThread(0);
return 0;
}
int module_start(SceSize argc, void* argp) {
SceUID thid = sceKernelCreateThread("TEST_main", main_thread, 0x30, 0x10000, 0, NULL);
if (thid >= 0)
sceKernelStartThread(thid, argc, argp);
return 0;
}TARGET = test
OBJS = main.o
#USE_KERNEL_LIBC = 1
#USE_KERNEL_LIBS = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.makI think it is always called user_main.svanheulen wrote:Also I got the thread name "user_main" from the game I'm testing it on, Monster Hunter Portable 3rd, using psplink. I'm not sure if that's the standard main thread for all games.
When the quit option on the exit screen is chosen, the exit callback of the game is called and the kernel waits for the game to quit (while displaying "Please wait..."). So a possibility would be to hook the exit callback of the game and handle it yourself or pass it through depending on the situation.svanheulen wrote:If I select yes to exit to xmb it stalls/crashes and I have to hold down the power switch until it turns off. So, can anyone give any insight on what I need to do to either make it exit correctly or disable the home/playstation button?
This means you are linking with newlib, which will bloat your binary quite a bit. USE_KERNEL_LIBC takes the libc implementation from the kernel, but that is incomplete. You could roll your own text printing, HBL does it too. I don't know why debug screen printing doesn't work with the kernel libc though.svanheulen wrote:I have to comment out USE_KERNEL_LIBC/USE_KERNEL_LIBS in the Makefile to get pspDebugScreenPrintf working. I'm not certain what these do exaclty... Will there be any negative side effects and/or is there a better why of printing text without doing that?
That would be nice, It would make my code much simpler... so long as everything is coded correctly and the other threads don't do funky stuff while user_main is suspended, haha. There are only a limited number of games my plugin is supposed to work on so I guess I could just check them all.JJS wrote:I think it is always called user_main.
Urg, sounds like a pain. Silly me just noticed PSP_CTRL_HOME, It'll probably be fine if I just resume the thread(s) when that's pressed.JJS wrote:When the quit option on the exit screen is chosen, the exit callback of the game is called and the kernel waits for the game to quit (while displaying "Please wait..."). So a possibility would be to hook the exit callback of the game and handle it yourself or pass it through depending on the situation.
I actually figured out how to get debug screen stuff working with the USE_KERNEL_LIBC/LIBS. I had to add -lpspge to LIBS after importing build_prx.mak. Not sure why in that particular place but it works and my prx is 90% smaller so win-win.JJS wrote:This means you are linking with newlib, which will bloat your binary quite a bit. USE_KERNEL_LIBC takes the libc implementation from the kernel, but that is incomplete. You could roll your own text printing, HBL does it too. I don't know why debug screen printing doesn't work with the kernel libc though.
JJS wrote:I think it is always called user_main.


while(pad.Buttons & PSP_CTRL_HOME) {
sceKernelDelayThreadCB(1000000);
sceCtrlReadBufferPositive(&pad,1);
}Thanks, interesting code! Not sure if I'm understanding it correctly, but it looks like the game has a stub for functions and the kernel points them to the correct functions. So you just point it to your own function after the kernel does it's thing? How do you find the stub address?m0skit0 wrote:EDIT: found it, here it is. It's an older version than the one I have in my computer IIRC, but anyway it explains everything you need to know to hook system calls from a plugin. Some stuff is in spanish, although code comments are in english. Good luck
I got it working, thanks! I just made it so that pressing the home button resumes the game and leaves my menu.Nymphaea wrote:Best fix for that I can think of is make leaving the home screen also leave your menu, so inside that loop you can check for cross, circle or home to be pressed(all three always close the home screen I believe), and if they are close your menu and wake up the threads so they can do their thing.
Users browsing this forum: No registered users and 0 guests