[SOLVED] Home button troubles on 5.xx m33

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

Moderators: cheriff, TyRaNiD

Post Reply
justin
Posts: 15
Joined: Wed Oct 17, 2007 7:34 pm

[SOLVED] Home button troubles on 5.xx m33

Post by justin »

I've been struggling to get the exit game screen callbacks working in a game I'm working on. I've got the callbacks in there, and it works in psplink (using the 1.5 kernel). But when I copy the game to the memory stick and run it through the xmb (using the 5.xx kernel), the home button doesn't do anything - but the same build works on my friends psp, he's running 3.52-MM3-4 or something.

I moved the callbacks to an external kernel mode prx, and it worked through both psplink and the xmb. But I'm figuring I shouldn't have to do this, there must be something I'm missing and its driving me insane.

code for sanity check.

Code: Select all

#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspmoduleinfo.h>
#include <pspthreadman.h>
#include <pspfpu.h>
#include <psppower.h>


PSP_MODULE_INFO&#40;"Test", 0, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
PSP_HEAP_SIZE_MAX&#40;&#41;;

// Exit callback
int ExitCallback&#40;int arg1, int arg2, void *common&#41; &#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

// Callback thread
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
	int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", ExitCallback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	
	return 0;
&#125;

// Sets up the callback thread and returns its thread id
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41; &#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;
	
	return thid;
&#125;

int main&#40;int argc, char** args&#41;
&#123;
	SetupCallbacks&#40;&#41;;
	// etc
&#125;
Last edited by justin on Fri Feb 06, 2009 6:19 pm, edited 1 time in total.
ctszy
Posts: 18
Joined: Sat Apr 12, 2008 11:18 pm

Post by ctszy »

seems your homebrew is still based on 1.50 firmware, and thus you need to do some porting work.
check this:http://forums.ps2dev.org/viewtopic.php?t=9130
justin
Posts: 15
Joined: Wed Oct 17, 2007 7:34 pm

Post by justin »

Thnx for your reply.

I've followed all of the steps in the thread you've linked before - the app runs perfectly using the 5.xx kernel - no errors or anything the only thing that doesn't work is pushing the home button. Setting the callbacks up shouldn't need to use kernal mode should it? prxtool shows no kernal mode libraries used. But when I move the callbacks into a kernel mode external prx, it works. I'm assuming I'm doing something stupid in my callback setup that is making it require kernel mode, I just can't figure out what.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Is the update thread actually being created? You are using PSP_HEAP_SIZE_MAX which in the past has caused in certain situations to totally drain all of user memory which then makes it impossible to create a new thread because you don't have any free stack. It might work in kernel mode because it will allocate the stack in kernel memory but any heap allocations will be in user mode.

Try adding PSP_HEAP_SIZE_KB(-1024) instead of PSP_HEAP_MAX() (yes -1024) which will use all memory minus 1MB which should give you space for a thread stack.
justin
Posts: 15
Joined: Wed Oct 17, 2007 7:34 pm

Post by justin »

Thnx, I'll give it a go when I get home and report back. Probably should have thought of that...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Another thought - is this a C++ app? If so, you have to wrap the callbacks in extern C {} thingys or they won't work.
justin
Posts: 15
Joined: Wed Oct 17, 2007 7:34 pm

Post by justin »

PSP_HEAP_SIZE_KB(-1024) did it. The callbacks work now, and I feel sane again. Thanks everyone :)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You might play with the value a bit. I rarely leave more free than 256K. Of course, if your app doesn't need much memory, you could always leave more free. :)
justin
Posts: 15
Joined: Wed Oct 17, 2007 7:34 pm

Post by justin »

It's a pretty greedy app, memory wise :) I'll give it a whirl at -256.
Post Reply