PDA

View Full Version : fpc4gp2x: GP2X Console Development



paul_nicholls
14-05-2007, 06:39 AM
Hi Guys and Gals :)

If you are interested, I have had success with compiling SDL programs for the GP2X handheld console using the devkitGP2X and a freepascal cross-compiler program that I built from the freepascal source code.

At the site (http://fpc4gp2x.eonclash.com/) I have uploaded a simple sdl tutorial that compiles under Win32 and gp2x, and I have also written some documentation on how to set it all up!

The site also says where to get the devkitGP2X and freepascal cross-compiler stuff from that is required.

Enjoy!!
cheers,
Paul.

JoeDonth
14-05-2007, 01:55 PM
Paul,

Thank you very much for your response and information.

I have just finished downloading the documentation and sample program. I hope to spend time studying them later this afternoon.

I'm really looking forward to working on the gp2x with Pascal.

Thanks again,
Joe

JoeDonth
14-05-2007, 05:54 PM
I'm trying to understand Paul's configuration information and have a question.

There are two locations for arm-linux-ar.exe (as an example):
C:\devkitGP2X\bin
and
C:\FPC_win32_arm-linux\bin\arm-linux

They have different dates (and different sizes). Which directory is the correct one to use (and why are there two -- I'm just trying to understand the pieces)?

Thanks,
Joe

paul_nicholls
14-05-2007, 10:52 PM
I'm trying to understand Paul's configuration information and have a question.

There are two locations for arm-linux-ar.exe (as an example):
C:\devkitGP2X\bin
and
C:\FPC_win32_arm-linux\bin\arm-linux

They have different dates (and different sizes). Which directory is the correct one to use (and why are there two -- I'm just trying to understand the pieces)?

Thanks,
Joe

So the downloaded cross-compiler file also contains arm-linux-ar.exe?

I must have deleted it from my local copy...it isn't needed and I should update the uploaded file. Sorry about that.

You should delete all the arm-linux-*.exe files in your cross-compiler \FPC_win32_arm-linux\bin\arm-linux folder.

The ppcrossarm.exe file in the cross-compiler folder is used as well as the arm-linux-*.exe files in the C:\devkitGP2X\bin folder.

Hope this helps :-)
cheers,
Paul.

paul_nicholls
15-05-2007, 04:23 AM
I'm trying to understand Paul's configuration information and have a question.

There are two locations for arm-linux-ar.exe (as an example):
C:\devkitGP2X\bin
and
C:\FPC_win32_arm-linux\bin\arm-linux

They have different dates (and different sizes). Which directory is the correct one to use (and why are there two -- I'm just trying to understand the pieces)?

Thanks,
Joe

So the downloaded cross-compiler file also contains arm-linux-ar.exe?

I must have deleted it from my local copy...it isn't needed and I should update the uploaded file. Sorry about that.

You should delete all the arm-linux-*.exe files in your cross-compiler \FPC_win32_arm-linux\bin\arm-linux folder.

The ppcrossarm.exe file in the cross-compiler folder is used as well as the arm-linux-*.exe files in the C:\devkitGP2X\bin folder.

Hope this helps :-)
cheers,
Paul.

I have updated my fpc4gp2x site with a note about removing the arm-linux-*.exe files from the cross-compiler folder.

cheers,
Paul.

Legolas
15-05-2007, 10:27 AM
In order to be fpc-compliant, I think that should be better to put binutils and compiler in %fpc%/bin/arm-gp2x. However, do you have contacted Florian for releasing your port in the SVN server?

JoeDonth
15-05-2007, 07:27 PM
Paul,

I hope this question does not fall into the category of "Is he kidding!?", but I am having trouble compiling your gp2x_tutorial program from the command line into a WIN32 exe. It can't find the system unit.

Do I need to install a different version of the FPC or can I use the one that you provided?

What compiler command would you issue to compile the dpr program?

I'm issuing the following:
ppc -FiC:\GP2X\FPC\units\arm-linux\rtl C:\GP2X\Projects\gp2x_tutorial\gp2x_tutorial.dpr

Also, would it change if I was compiling a support unit like SDL.pas?

Thanks,
Joe

paul_nicholls
16-05-2007, 02:55 AM
Paul,

I hope this question does not fall into the category of "Is he kidding!?", but I am having trouble compiling your gp2x_tutorial program from the command line into a WIN32 exe. It can't find the system unit.

Do I need to install a different version of the FPC or can I use the one that you provided?

What compiler command would you issue to compile the dpr program?

I'm issuing the following:
ppc -FiC:\GP2X\FPC\units\arm-linux\rtl C:\GP2X\Projects\gp2x_tutorial\gp2x_tutorial.dpr

Also, would it change if I was compiling a support unit like SDL.pas?

Thanks,
Joe

I normally use Lazarus (www.lazarus.freepascal.org) to compile the project for Win32, so I haven't had a problem.

I am not sure what the pcc.exe would be used for, but I don't think it is for creating Win32 programs (but don't quote me on this :wink: )

Have you managed to make Win32 programs using ppc.exe?

I am pretty sure that to compile a Win32 version of the project you either need a Win32 version of Lazarus or freepascal (or Delphi of course)...

When using Delphi, Lazarus or freepascal to compile a project, the 'support' units like sdl.pas should be compiled just fine...it is only when doing the cross-compile to GP2X using the batch file that this should be an issue.

cheers,
Paul.

savage
16-05-2007, 09:17 AM
ppc -FiC:\GP2X\FPC\units\arm-linux\rtl C:\GP2X\Projects\gp2x_tutorial\gp2x_tutorial.dpr

I prefer using the command line to Lazarus. Unless you have edited the fpc.cfg file to point to the jedi-sdl directory, you will need to pass the directories where the sdl.pas and jedi-sdl.inc file are as well via the command line. I would tend to use...


fpc -FiC:\GP2X\FPC\units\arm-linux\rtl -FiC:\{path to jedi-sdl} -FuC:\{path to jedi-sdl} C:\GP2X\Projects\gp2x_tutorial\gp2x_tutorial.dpr

JoeDonth
16-05-2007, 05:29 PM
savage,

Thank you for your suggestion. I was able to compile Paul's tutorial program and run it on my Windows box!

Joe

JoeDonth
16-05-2007, 08:29 PM
Paul,

I have your tutorial program running on the GP2X console but can only exit with the START key. Is that normal or should the program exit with any other keys? (X?)

Thanks,
Joe

savage
16-05-2007, 10:15 PM
Hi Joe,
in Paul's example there is the following procedure

Procedure ProcessJoyButtonUp(JoyButtonEvent: TSDL_JoyButtonEvent; Var AFinished: Boolean);
Begin
Case JoyButtonEvent.button Of
// exit program if gp2x 'Start' key is pressed
VK_START : AFinished := True;
Else
End;
End;

if you change VK_START to one of the other keys defined at the top of the dpr, it should react to that to exit.

savage
16-05-2007, 10:26 PM
Paul, should those VK_* constants be included in sdl.pas? If I moved them there, inside a GP2X IFDEF, would that be ok? Also should they follow some kind of SDL naming convention? possibly SDLK_*?

paul_nicholls
16-05-2007, 10:55 PM
Paul,

I have your tutorial program running on the GP2X console but can only exit with the START key. Is that normal or should the program exit with any other keys? (X?)

Thanks,
Joe

That is great news!
Sorry about the trouble you had compiling it for Win32...

Using the START key seems to be a 'standard'? I think for the GP2X, at least for the built in programs...

Of course you could use anything really :-)

cheers,
Paul.

paul_nicholls
16-05-2007, 10:59 PM
Paul, should those VK_* constants be included in sdl.pas? If I moved them there, inside a GP2X IFDEF, would that be ok? Also should they follow some kind of SDL naming convention? possibly SDLK_*?

Hi :-)
Putting the GP2X keys into the SDL sounds like a good idea :-)

I have renamed them for you already to make them more readable as well as more SDL-like.

SDLK_GP2X_UP = 0;
SDLK_GP2X_UPLEFT = 1;
SDLK_GP2X_LEFT = 2;
SDLK_GP2X_DOWNLEFT = 3;
SDLK_GP2X_DOWN = 4;
SDLK_GP2X_DOWNRIGHT = 5;
SDLK_GP2X_RIGHT = 6;
SDLK_GP2X_UPRIGHT = 7;
SDLK_GP2X_START = 8;
SDLK_GP2X_SELECT = 9;
SDLK_GP2X_L = 10;
SDLK_GP2X_R = 11;
SDLK_GP2X_A = 12;
SDLK_GP2X_B = 13;
SDLK_GP2X_Y = 14;
SDLK_GP2X_X = 15;
SDLK_GP2X_VOLUP = 16;
SDLK_GP2X_VOLDOWN = 17;
SDLK_GP2X_CLICK = 18;

I think those names are better than what I had...more clear.

cheers,
Paul.

savage
16-05-2007, 11:09 PM
Excellent I'll try and check it into CVS this week-end.

paul_nicholls
16-05-2007, 11:16 PM
Excellent I'll try and check it into CVS this week-end.

You're da man! :)
cheers,
Paul.

JoeDonth
17-05-2007, 03:29 PM
Paul and savage,

I wanted to thank both of you for helping get started programming the GP2X with Pascal. I have a better understanding of how the pieces come together now.

I know that assisting a newbie can be frustrating at times and I really appreciate your kindness as well as your knowledge.

Regards,
Joe

savage
17-05-2007, 03:34 PM
No problem Joe,
Just make sure you keep us posted with what you are up to? We all love screenshots of gameplay videos ;).

savage
17-05-2007, 08:22 PM
SDLK_GP2X_UP = 0;
SDLK_GP2X_UPLEFT = 1;
SDLK_GP2X_LEFT = 2;
SDLK_GP2X_DOWNLEFT = 3;
SDLK_GP2X_DOWN = 4;
SDLK_GP2X_DOWNRIGHT = 5;
SDLK_GP2X_RIGHT = 6;
SDLK_GP2X_UPRIGHT = 7;
SDLK_GP2X_START = 8;
SDLK_GP2X_SELECT = 9;
SDLK_GP2X_L = 10;
SDLK_GP2X_R = 11;
SDLK_GP2X_A = 12;
SDLK_GP2X_B = 13;
SDLK_GP2X_Y = 14;
SDLK_GP2X_X = 15;
SDLK_GP2X_VOLUP = 16;
SDLK_GP2X_VOLDOWN = 17;
SDLK_GP2X_CLICK = 18;


These have now been checked into CVS and can be downloaded from
http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/sdl.pas?revision=1.28

paul_nicholls
17-05-2007, 10:40 PM
Paul and savage,

I wanted to thank both of you for helping get started programming the GP2X with Pascal. I have a better understanding of how the pieces come together now.

I know that assisting a newbie can be frustrating at times and I really appreciate your kindness as well as your knowledge.

Regards,
Joe

You're welcome Joe :-)
cheers,
Paul.

paul_nicholls
17-05-2007, 10:42 PM
SDLK_GP2X_UP = 0;
SDLK_GP2X_UPLEFT = 1;
SDLK_GP2X_LEFT = 2;
SDLK_GP2X_DOWNLEFT = 3;
SDLK_GP2X_DOWN = 4;
SDLK_GP2X_DOWNRIGHT = 5;
SDLK_GP2X_RIGHT = 6;
SDLK_GP2X_UPRIGHT = 7;
SDLK_GP2X_START = 8;
SDLK_GP2X_SELECT = 9;
SDLK_GP2X_L = 10;
SDLK_GP2X_R = 11;
SDLK_GP2X_A = 12;
SDLK_GP2X_B = 13;
SDLK_GP2X_Y = 14;
SDLK_GP2X_X = 15;
SDLK_GP2X_VOLUP = 16;
SDLK_GP2X_VOLDOWN = 17;
SDLK_GP2X_CLICK = 18;


These have now been checked into CVS and can be downloaded from
http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/sdl.pas?revision=1.28

Excellent! Thanks Savage :-)
Just one small thing, after downloading the file I tried compiling it under Delphi 5 and Delphi complains that the very first line is more than 1024 characters!

It works fine under Lazarus...

I can't seem to work it out.
cheers,
Paul.

savage
18-05-2007, 05:26 AM
Delphi can be a bit funny about that. IIRC the problem is that Delphi gets confused about where the end of line characters are. Try opening the sdl.pas file in WordPad, then save it over itself as a text file. Then try it again in Delphi. Hopefully WordPad will sort out the EOL/CR issue.

savage
18-05-2007, 05:27 AM
Hey Paul, so when do we get to see screenies of the GP2X project you've been working on? Or is it all hush hush?

paul_nicholls
18-05-2007, 05:37 AM
Hey Paul, so when do we get to see screenies of the GP2X project you've been working on? Or is it all hush hush?

I don't have much to show yet...

I have that one screenshot that I have already posted of the gp2x tutorial I uploaded.

I have my mario bros game that I haven't done any more on yet...I could post a screen of that I suppose.

I have been working on a 3d engine for SDL/gp2x but it only runs at about 3 frames per second on the gp2x!!

cheers,
Paul.