[Solved] Running a homebrew from a homebrew

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

Moderators: cheriff, TyRaNiD

Post Reply
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

[Solved] Running a homebrew from a homebrew

Post by Beuc »

Hi,

I'd like to run my FreeDink(.org) homebrew with some additional parameters, so it can run a given addon instead of the main game. In another words I need to write a simple frontend to do the job.

What's the best way to run the game engine from the frontend - that is, run an homebrew from another one? In the psplink code I found that "ldstart" is implemented using "sceKernelLoadModule", but I'm not sure that's what I need.
Last edited by Beuc on Fri Apr 17, 2009 6:21 am, edited 1 time in total.
arnie
Posts: 11
Joined: Sat Apr 11, 2009 6:32 pm

Post by arnie »

Code: Select all

int k1 = pspSdkSetK1(0);
	
	SceUID mod = sceKernelLoadModule(path, 0, NULL);
	if (mod >= 0)
	{
		mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
		if &#40;mod < 0&#41;
			//Error
	&#125;
	pspSdkSetK1&#40;k1&#41;;
Replace path with the module you want to load.

-Arnie
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

Post by Beuc »

arnie wrote:

Code: Select all

int k1 = pspSdkSetK1&#40;0&#41;;
	
	SceUID mod = sceKernelLoadModule&#40;path, 0, NULL&#41;;
	if &#40;mod >= 0&#41;
	&#123;
		mod = sceKernelStartModule&#40;mod, 0, NULL, NULL, NULL&#41;;
		if &#40;mod < 0&#41;
			//Error
	&#125;
	pspSdkSetK1&#40;k1&#41;;
Replace path with the module you want to load.

-Arnie
It looks it doesn't want to start the application if the front-end is already running (mod == 0x800200d9). Do I need to unload it first somehow?

I tried with running an eboot (0x80020148/unsupported_prx_type) and a .prx (0x800200D9/same as when trying to run a program twice from psplink).

I'm not very familiar with the PSP constraints (like, you can run two programs at once?).

Thanks!
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

Post by Beuc »

OK, apparently something going wrong (800200d9) if I run an SDL app from another SDL app - even if I unloaded everything:

Works:
- run text-mode app 1
- user chooses app to launch
- call pspSdkLoadStartModule(SDL App 2)
- SDL App 2 is run

Doesn't work:
- run SDL app 1
- user chooses app to launch (graphically)
- quit SDL
- call pspSdkLoadStartModule(SDL App 2)
- SDL App 2 is not run (800200d9)

Do you have an idea about what blocks starting SDL App 2 from SDL App 1?
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

800200d9 in loadmodule means non enough memory to load.

You probably haven't freed the heap.
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

Post by Beuc »

Thanks - what function should I use to free the heap?
I didn't manipulate it directly.
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

Post by Beuc »

I confirm that the heap is not freed - sadly __psp_free_heap() doesn't seem to be public, and it's the only function with access to the memory blockid used by newlib AFAICS.
Is there another way?
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Simply add the prototype for it in your source and it will work.
Beuc
Posts: 33
Joined: Thu Mar 26, 2009 5:04 am
Location: holland

Post by Beuc »

Torch wrote:Simply add the prototype for it in your source and it will work.
Cool. I did but actually I had forgotten an "extern C" somewhere (I'm using Guichan so the program is C++), hence I thought I didn't work. It works fine now - only using '__' functions is probably a bit ugly.
Thanks :)
Post Reply