GP2X Hello Everyone


JonHolland

Still Fresh
Joined
Dec 17, 2006
Messages
26
Hey all,

I just discovered the Gp2x as a friend has purchased one. As a programmer, I'm excited to start developing for it.

I love 2d games, and miss the era when they were king, so its encouraging to see a platform I can develop for that has a good following.

You'll be seeing more of me,

Jon
 
sehs33 posted on Dec 17 2006 at 12:46 PM said:
Welcome to the community Jon :)

So far, in my few hours of reading and programming, I've written up a program that displays a string on the display (quickie SDL custom font routines) and plays a mp3.

Theres a lot to learn, as I'm not all that used SDL, but I'm excited.

Now to wake my friend up to test it on his GP2x, it works fine on my pc.

Thanks for the warm welcome.
 
Last edited by a moderator:
Jonathan Holland posted on Dec 17 2006 at 12:53 PM said:
Now to wake my friend up to test it on his GP2x, it works fine on my pc.

Well it doesn't work at all on his gp2x, despite working on my pc. I believe the issue is with SDL_Mixer crashing when it tries to initilize.

Is there a trick I should know?

EDIT: This is my code:

Code:
if (!Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4048)) 
	{
	
	   SDL_Quit();
	   clean_program_shutdown();
	   }

It doesn't even get to SDL_Quit(); it hangs on the Mix_OpenAudio function. Works fine under XP, and when I remove all the sound functions, it works fine on the gp2x.
 
Last edited by a moderator:
Jonathan Holland posted on Dec 17 2006 at 07:00 PM said:
Hey all,

I just discovered the Gp2x as a friend has purchased one. As a programmer, I'm excited to start developing for it.

I love 2d games, and miss the era when they were king, so its encouraging to see a platform I can develop for that has a good following.

You'll be seeing more of me,

Jon
If you need any webspace for hosting a site for your GP2x projects, just ask.

Jonathan Holland posted on Dec 17 2006 at 10:08 PM said:
Jonathan Holland posted on Dec 17 2006 at 12:53 PM said:
Now to wake my friend up to test it on his GP2x, it works fine on my pc.

Well it doesn't work at all on his gp2x, despite working on my pc. I believe the issue is with SDL_Mixer crashing when it tries to initilize.

Is there a trick I should know?

EDIT: This is my code:

Code:
if (!Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4048)) 
	{
	
	   SDL_Quit();
	   clean_program_shutdown();
	   }

It doesn't even get to SDL_Quit(); it hangs on the Mix_OpenAudio function. Works fine under XP, and when I remove all the sound functions, it works fine on the gp2x.
Due to the fact i am soon going to learn SDL, I read about this. I don't know if it was ever solved. All I know is that there are different GP2x builds of SDL with a working SDL _Mixer, the SDL included with the GP2x firmware does not.
 
Last edited by a moderator:
Well, it doesn't seem like a good idea to use SDL_Mixer then as you want people to play your product without any difficulty.

I suppose if I statically linked SDL_Mixer with the GPE file, then it would work at the cost of ballooning the executable size.

I suppose I should look into MikMod then?

By the way Sam, are you Ben Heck? Because I've been a big fan of the projects he has done.
 
Jonathan Holland posted on Dec 18 2006 at 01:36 AM said:
Well, it doesn't seem like a good idea to use SDL_Mixer then as you want people to play your product without any difficulty.

I suppose if I statically linked SDL_Mixer with the GPE file, then it would work at the cost of ballooning the executable size.

I suppose I should look into MikMod then?

By the way Sam, are you Ben Heck? Because I've been a big fan of the projects he has done.
No, i'm not him. I just really like his film and am one of the official download mirrors. I'm on his site, banned under this name though, I told someone off for making up a tall tale. So I now have a different name. Meh.

Static linking may be the only way to go, but once a proper gp2x developer stumbles in, I am sure they will tell you.
 
Last edited by a moderator:
Well it doesn't work at all on his gp2x, despite working on my pc. I believe the issue is with SDL_Mixer crashing when it tries to initilize.
Is there a trick I should know?

Of course, all the obvious questions apply:

1. Are you calling SDL_Init with SDL_INIT_AUDIO bit set in the flags?
2. Are you sure your MP3 file is a standard MP3 file?
3. Do you have the volume set properly?
4. etc.

Welcome to the GP2X community, btw .. looking forward to your progress!
 
1. Are you calling SDL_Init with SDL_INIT_AUDIO bit set in the flags?
Yes
2. Are you sure your MP3 file is a standard MP3 file?
Yes
3. Do you have the volume set properly?
According to the SDL docs, volume presets automaticly, however since it hangs on the Mix_OpenAudio, I wouldn't be able to get far enough to alter the volume anyways.
Welcome to the GP2X community, btw .. looking forward to your progress!

Thanks for the warm welcome :)
 
Jonathan Holland posted on Dec 18 2006 at 01:36 AM said:
I suppose if I statically linked SDL_Mixer with the GPE file, then it would work at the cost of ballooning the executable size.
If you're not static linking at the moment then you must be using an old version of gcc with the GPH version of the libs, which is usually considered to be a bad idea. Almost all homebrew on the 2x is static linked because it generally makes thing easier for both the developer and the end user, and most people use gcc 4.x and alternative SDL libs too.

As for your actual problem, can't see anything that should be causing it to lock up (unless it is just the compiler/libs you're currently using), but I must admit I've never tried AUDIO_S16SYS (usually use AUDIO_S16 or MIX_DEFAULT_FORMAT). Once you get it working, I'd advise getting rid of the mp3 and using an ogg instead as SDL_Mixer uses a floating point lib for mp3s but fixed point for oggs. You may also need to drop the buffer size too, especially if you're using sound effects and not just music. 1024 and upwards is usually used on desktop machines, but for some reason the gp2x needs around 256 otherwise you get a very noticable delay on sounds.
 
Last edited by a moderator:
woogal posted on Dec 18 2006 at 06:03 AM said:
Jonathan Holland posted on Dec 18 2006 at 01:36 AM said:
I suppose if I statically linked SDL_Mixer with the GPE file, then it would work at the cost of ballooning the executable size.
If you're not static linking at the moment then you must be using an old version of gcc with the GPH version of the libs, which is usually considered to be a bad idea. Almost all homebrew on the 2x is static linked because it generally makes thing easier for both the developer and the end user, and most people use gcc 4.x and alternative SDL libs too.

As for your actual problem, can't see anything that should be causing it to lock up (unless it is just the compiler/libs you're currently using), but I must admit I've never tried AUDIO_S16SYS (usually use AUDIO_S16 or MIX_DEFAULT_FORMAT). Once you get it working, I'd advise getting rid of the mp3 and using an ogg instead as SDL_Mixer uses a floating point lib for mp3s but fixed point for oggs. You may also need to drop the buffer size too, especially if you're using sound effects and not just music. 1024 and upwards is usually used on desktop machines, but for some reason the gp2x needs around 256 otherwise you get a very noticable delay on sounds.

Thanks for your advice, I'm using that prebuilt Dev-C++ environment that is already set to go for the gp2x.

I just typed gcc-v and it said v. 3.4.2

I'm assuming its not static linking, because my GPE is about 35k :)

I think the problem is differences between the SDL libraries installed on the gp2k and the ones I have.

Anyone know how to set Dev-C++ to static link? I know how to do it in the command line, but the GUI makes it so convienant :)

Btw, the only reason I used a mp3 as I just was playing around SDL_mixer. In an actual game, I'd probably go with a tracker format.
 
Last edited by a moderator:
Add "-static" into the linker options. I wish they'd just sort out the whole linking thing - statically linked programs are huge and take at least a second longer to load than the same thing dynamically linked.
 
Orkie posted on Dec 18 2006 at 09:06 AM said:
Add "-static" into the linker options. I wish they'd just sort out the whole linking thing - statically linked programs are huge and take at least a second longer to load than the same thing dynamically linked.

Thanks, 35k became 405k, so I think it worked :p

Really though, considering the non-standarization of libraries across the GP2x's, having a slightly larger executable is a small price to pay for the ability to let everyone play your game without difficulty.
 
Last edited by a moderator:
Jonathan Holland posted on Dec 18 2006 at 06:54 PM said:
Orkie posted on Dec 18 2006 at 09:06 AM said:
Add "-static" into the linker options. I wish they'd just sort out the whole linking thing - statically linked programs are huge and take at least a second longer to load than the same thing dynamically linked.

Thanks, 35k became 405k, so I think it worked :p

Really though, considering the non-standarization of libraries across the GP2x's, having a slightly larger executable is a small price to pay for the ability to let everyone play your game without difficulty.

I take all that back, when I add -static and attempt to link for the gp2x I get this error, it staticly links fine when creating a x86 executable.

Code:
In Function 'SDL_SYS_CreateThread'
[Linker Error] Undefined reference to: 'pthread_create'

Blah....

Seems like something simple.
 
Last edited by a moderator:
Jonathan Holland posted on Dec 19 2006 at 04:13 AM said:
I take all that back, when I add -static and attempt to link for the gp2x I get this error, it staticly links fine when creating a x86 executable.

Code:
In Function 'SDL_SYS_CreateThread'
[Linker Error] Undefined reference to: 'pthread_create'

Blah....

Seems like something simple.
You probably need to tell the linker to link with the pthread lib as well... (-lpthread)
 
Last edited by a moderator:
You probably need to tell the linker to link with the pthread lib as well... (-lpthread)

Your right, now I'm having different link errors. I think I might have to link every single SDL library even though I'm not using them all?
 
The order of the libraries you link to may matter, try the following taking out the libraries you don't need:
Code:
-static -lSDL_gfx -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL -lgcc -lm -lc -lexpat -lpthread
 
Jonathan Holland posted on Dec 19 2006 at 02:54 AM said:
Orkie posted on Dec 18 2006 at 09:06 AM said:
Add "-static" into the linker options. I wish they'd just sort out the whole linking thing - statically linked programs are huge and take at least a second longer to load than the same thing dynamically linked.

Thanks, 35k became 405k, so I think it worked :p

Really though, considering the non-standarization of libraries across the GP2x's, having a slightly larger executable is a small price to pay for the ability to let everyone play your game without difficulty.

Yes, and one of the main reasons shared libraries are so prevelant is because on a normal computer, multiple processes are running, often needing access to some of the same library code. Having every program statically-linked not only wastes RAM, but it also forces the CPU cache to deal with two or more copies of the same function, which obviously can slow things down.

On the GP2X, however, these problems hardly exist, as one app is meant to run at a time, so static library linking is just fine.
 
Last edited by a moderator:
Back
Top