Callmenu()


plfx

Still Fresh
Joined
Oct 4, 2010
Messages
26
Alright guys, I'm brand spankin' new to homebrew on the caanoo, and getting into it is a pretty opaque matter, it seems. I wrote a small, totally air-headed helloworld to test the compiler:

#include <stdio.h>
int main()
{
freopen(stdout,"hello.out","w");
printf("Hello, world!");
fclose(stdout);
return 0;​
}

It runs and correctly writes to the file, but it doesn't return me to the caanoo menu afterward. It just sticks on the "Loading" screen.

I see the function "gp2xCallMenu()" or something like that, but there must be some easier way to get back to the menu (without using the SDK). This part of the DGE comes as compiled object code ready for the linker, rather than as source, so there's no looking at the function to see how it works.
 
What we usually do is make a wrapper script for your app. Here is an example:

Code:
#!/bin/sh
./helloworld.bin
sync
cd /usr/gp2x
exec /usr/gp2x/gp2xmenu
Call this script helloworld.gpe (or anything ending with gpe). As you can see, it calls the menu for you after your app finishes.

Hope it helps

/Uni
 
Excellent, I'll give it a try.

EDIT:

Right on, that worked (of course). As a follow-up question, I have compiled and tried running the example (2DTutorial) that comes with the SDK, but it won't run on the caanoo. I momentarily get a flash of palette-scrambled graphics and then the system freezes on black.

Any special comments on what I need to do to get that running? Or else confirmation that the example simply won't work for caanoo? (Though I don't see why that should be...)
 
I have not tried the 2D tutorial, so i don't know about it. But try changing your .gpe script to:

./helloworld.bin > ./log.txt 2>&1

This will log stdout and errout to log.txt file. You might find an error message there.

/Uni
 
I just wanna say welcome to you! Do keep us updated on your what your doing and learning!
 
I have compiled and run 2D tutorial - it works. Make sure you have copied all the files it needs to load (font, sounds & gfx I think) as well as the binary.
 
gc8839 said:
I have compiled and run 2D tutorial - it works. Make sure you have copied all the files it needs to load (font, sounds & gfx I think) as well as the binary.

I did, but I had to guess as to the directory structure. IO just put the binary in the 2DTutorial folder and the media resources in their own folders as they were named in the source folder, so:
2dtutorial (binary)
sound (folder)
gfx (...or whatever it was named.... folder)

This is what you did too, right?

Maybe I don't have some the includes correct, so it's using some host includes? Would this cause problems?

EDIT:
I redirected stdout and stderr; both streams are empty.
 
Last edited by a moderator:
Case closed, thanks to some helpful comparison files from gc8839. Thanks!

The culprit was simply the gnome file manager and gvfs, which was not correctly syncing the files placed on the device.

Check out the new thread for the fruits of my MIGHTY LABOR.
 
Back
Top