Little Help Making Myself Clear.


HexDump

Still Fresh
Joined
Nov 15, 2004
Messages
30
Hi all,

I´m just starting development for gp2x. I have developed for gp32 previously.

I have read the wiki site but I still have miss some interesting points. Wiki talks about the official sdk (having SDL built in), devkitpro, etc... I don´t like the idea of using SDL because its inner loop is somehow slow, and doesn´t work the way I like.

I have read too that we can use the minimal lib from rlyeh, it seems to be more what I want but I´m still messed up.

The other thing is the toolchain. Isn´t there any script to build our toolchaing our own? using for example gcc 4.0.x?.

If anyone could give me a piece of advice I would be really happy.


Thanks in advance,
HexDump.
 
Hi all,

I´m just starting development for gp2x. I have developed for gp32 previously.

I have read the wiki site but I still have miss some interesting points. Wiki talks about the official sdk (having SDL built in), devkitpro, etc... I don´t like the idea of using SDL because its inner loop is somehow slow, and doesn´t work the way I like.

I have read too that we can use the minimal lib from rlyeh, it seems to be more what I want but I´m still messed up.

I suggested reading this topic and making your own routines. Direct framebuffer access isn't difficult at all. And doing so you will not need any external lib.

The other thing is the toolchain. Isn´t there any script to build our toolchaing our own? using for example gcc 4.0.x?

http://wiki.gp2x.org/wiki/Getting_started_...P2X_development

There are some scripts... they work.
 
Last edited by a moderator:
I wouldn't write off SDL straight away, it's perfectly adequate for most games/apps (emulators are a different matter).

Take these demos for example. To do stuff like this on a Speccy/BBC micro etc could take some pretty clever assembler to wring every last cycle out for the processor, but on the GP2X they run fine, even real time calculation of trig functions, and the GP2X only has software floating point.
 
I wouldn't write off SDL straight away, it's perfectly adequate for most games/apps (emulators are a different matter).

SDL is a fine API and since we have blitter supported is a quite logical choice. But to do some things direct pixel manipulation is needed and then nothing beats direct framebuffer access.

Take these demos for example. To do stuff like this on a Speccy/BBC micro etc could take some pretty clever assembler to wring every last cycle out for the processor, but on the GP2X they run fine, even real time calculation of trig functions, and the GP2X only has software floating point.

Most of these effects can be done rather easily on Atari800
(except those with texture mapping).

Now thanks to Squidge we can use full power of 2xArm cores and it's 400mips for 32-bit ALU opcodes. And even a single opcode can be very powerfull (thanks to Arm's great traits a like conditional executing).

For 320x240x60Hz it means there can up to 86 machine cycles for a single pixel per every frame. And with some clever trick more than one pixel (or scalars) can be fitted into 32bit ALU at the same time.

For a comparison such machine like Atari ST has 320x200x50Hz and CPU what do 2mips at best. So not even one machine cycle for 1pix/frame.
Results?
http://www.pouet.net/prod.php?which=4631
and
http://www.pouet.net/prod.php?which=109
and many more...
 
Last edited by a moderator:
Just a little more thing, If I choose Official SDK with SDL, am I getting everything to compile for windows and pc?, I mean, could I compile for both machines? or it is only for gp2x?. I want to prototype a fast game and I thing I will go for sdl to do this.

Thanks in advance,
HexDump.
 
hmm radek, are you going to submit an entry to the demo comp? ;)

I try. ;)

HexDump posted on Jul 1 2006 at 01:05 AM said:
Just a little more thing, If I choose Official SDK with SDL, am I getting everything to compile for windows and pc?, I mean, could I compile for both machines? or it is only for gp2x?. I want to prototype a fast game and I thing I will go for sdl to do this.

You can compile for both platforms except situation you would have some inline Arm assembler code. Then it will not compile for x86 obviously. ;)
There is also a resource thing - a PC is much more powerfull than GP2x so limits of target system shouldn't be forgotten.
You might think also about writing some functions to simulate GP2x's buttons on PC too.

There is a chance some small unepected problems will emerge but time saving when prototyping on a PC is great.
 
Last edited by a moderator:
Radek posted on Jul 1 2006 at 10:39 AM said:
You might think also about writing some functions to simulate GP2x's buttons on PC too.
That's not so hard, I've made this header:
Code:
#ifndef KEYS_H
#define KEYS_H

#ifdef GP2X
#define GP2X_EVENT_DOWN	SDL_JOYBUTTONDOWN
#define GP2X_EVENT_UP	  SDL_JOYBUTTONUP
#define GP2X_EVENT_VAR	 jbutton.button
//Numbers because some sources say some SDL headers are wrong in the button layout.
#define GP2X_KEY_UP		0
#define GP2X_KEY_UPLEFT	1
#define GP2X_KEY_LEFT	  2
#define GP2X_KEY_DOWNLEFT  3
#define GP2X_KEY_DOWN	  4
#define GP2X_KEY_DOWNRIGHT 5
#define GP2X_KEY_RIGHT	 6
#define GP2X_KEY_UPRIGHT   7
#define GP2X_KEY_START	 8
#define GP2X_KEY_SELECT	9
#define GP2X_KEY_TOPL	  10
#define GP2X_KEY_TOPR	  11
#define GP2X_KEY_A		 12
#define GP2X_KEY_B		 13
#define GP2X_KEY_X		 14
#define GP2X_KEY_Y		 15
#else
#define GP2X_EVENT_DOWN	SDL_KEYDOWN
#define GP2X_EVENT_UP	  SDL_KEYUP
#define GP2X_EVENT_VAR	 key.keysym.sym
#define GP2X_KEY_UP		SDLK_KP8
#define GP2X_KEY_UPLEFT	SDLK_KP7
#define GP2X_KEY_LEFT	  SDLK_KP4
#define GP2X_KEY_DOWNLEFT  SDLK_KP1
#define GP2X_KEY_DOWN	  SDLK_KP2
#define GP2X_KEY_DOWNRIGHT SDLK_KP3
#define GP2X_KEY_RIGHT	 SDLK_KP6
#define GP2X_KEY_UPRIGHT   SDLK_KP9
#define GP2X_KEY_START	 SDLK_ESCAPE
#define GP2X_KEY_SELECT	SDLK_TAB
#define GP2X_KEY_TOPL	  SDLK_q
#define GP2X_KEY_TOPR	  SDLK_w
#define GP2X_KEY_A		 SDLK_a
#define GP2X_KEY_B		 SDLK_x
#define GP2X_KEY_X		 SDLK_z
#define GP2X_KEY_Y		 SDLK_s
#endif

#endif//KEYS_H
And an event loop like this:
Code:
		SDL_Event event;
		while (SDL_PollEvent (&event))
		{
		switch (event.type)
			{
			case GP2X_EVENT_DOWN:
				switch(event.GP2X_EVENT_VAR)
				{
				case GP2X_KEY_UP:	   Player->Action |= ACT_MOVE_UP; break;
				case GP2X_KEY_UPLEFT:   Player->Action |= ACT_MOVE_UPLEFT; break;
				case GP2X_KEY_LEFT:	 Player->Action |= ACT_MOVE_LEFT; break;
				case GP2X_KEY_DOWNLEFT: Player->Action |= ACT_MOVE_DOWNLEFT; break;
				case GP2X_KEY_DOWN:	 Player->Action |= ACT_MOVE_DOWN; break;
				case GP2X_KEY_DOWNRIGHT:Player->Action |= ACT_MOVE_DOWNRIGHT; break;
				case GP2X_KEY_RIGHT:	Player->Action |= ACT_MOVE_RIGHT; break;
				case GP2X_KEY_UPRIGHT:  Player->Action |= ACT_MOVE_UPRIGHT; break;
				case GP2X_KEY_B:	  Item->Use(0); break;
				case GP2X_KEY_X:	  Item->Use(1); break;
				case GP2X_KEY_START:	bRunGame = 0; break;
				}
				break;
			case GP2X_EVENT_UP:
				switch(event.GP2X_EVENT_VAR)
				{
				case GP2X_KEY_UP:	   Player->Action &=~ACT_MOVE_UP; break;
				case GP2X_KEY_UPLEFT:   Player->Action &=~ACT_MOVE_UPLEFT; break;
				case GP2X_KEY_LEFT:	 Player->Action &=~ACT_MOVE_LEFT; break;
				case GP2X_KEY_DOWNLEFT: Player->Action &=~ACT_MOVE_DOWNLEFT; break;
				case GP2X_KEY_DOWN:	 Player->Action &=~ACT_MOVE_DOWN; break;
				case GP2X_KEY_DOWNRIGHT:Player->Action &=~ACT_MOVE_DOWNRIGHT; break;
				case GP2X_KEY_RIGHT:	Player->Action &=~ACT_MOVE_RIGHT; break;
				case GP2X_KEY_UPRIGHT:  Player->Action &=~ACT_MOVE_UPRIGHT; break;
				}
				break;
			}
		}
Works great for both i86 and GP2x :)
(feel free to use the code)
 
Last edited by a moderator:
hehehe, yes I know. I got a layer on my PsP 2D engine in order to hide all propietary hardware problems, yes, there exist some #ifdef but it is nice to have everything compiled for both platforms PC/PsP, but for gp2x everything is easier because both use sdl.


Thanks for the answers,
HexDump.
 
I don't bother conditionally compiling for key or joystick events, I put both bits of code in. I don't have joysticks on my PC so I only get key events on the PC and joystick events on the GP2X.
 
Parkydr posted on Jul 2 2006 at 11:32 PM said:
I don't bother conditionally compiling for key or joystick events, I put both bits of code in. I don't have joysticks on my PC so I only get key events on the PC and joystick events on the GP2X.
I didn't do that for 2 reasons:
-More code inside the GP2x that does nothing. The keyboard reaction code sits around eating a few cycles and a few bytes. (I come from a place where every byte counts ;))
-Easier to make the mistake to ajust your keyboard code and forget to ajust your joystick code.
 
Last edited by a moderator:
Back
Top