PDA

View Full Version : GP2X Issues...



savage
21-02-2007, 09:02 AM
I have fixed my program.

Here are my SDL_getenv findings:

Call SDL_getenv but don't store the result - works
call SDL_getenv and store the result in either PChar or AnsiString - doesn't work (hangs the GP2X...)

Does this help?

cheers,
Paul.

I have the feeling that under GP2X the FPC version of getenv may be broken or that SDL should be using the C getenv and not the FPC fpgetenv. Could you try the following just to be sure where the commented code is...
{$IFDEF UNIX}
{$IFDEF FPC}
{$IFDEF GP2X}
result := getenv(......);
{$ELSE}
result := fpcgetenv(......);
{$ENDIF}
{$ENDIF}
{$ENDIF}

paul_nicholls
21-02-2007, 10:21 AM
I have the feeling that under GP2X the FPC version of getenv may be broken or that SDL should be using the C getenv and not the FPC fpgetenv. Could you try the following just to be sure where the commented code is...
{$IFDEF UNIX}
{$IFDEF FPC}
{$IFDEF GP2X}
result := getenv(name);
{$ELSE}
result := fpcgetenv(name);
{$ENDIF}
{$ENDIF}
{$ENDIF}

I tried that and freepascal borked at the line


result := getenv(name);

with Identifier not found "getenv"

So it looks like I can't use getenv under the GP2X.

cheers,
Paul.

savage
21-02-2007, 10:50 AM
Is there a GP2X forum where we can confirm that getenv is definitely broken?

Sly
21-02-2007, 11:39 AM
I did a small test in C.

char *path = getenv("PATH");
if (path)
printf(path);
printf("\n");
produced the following

[root@gp2x dev]$./test2
/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
getenv() definitely works on the GP2X. I don't know what FPC might be doing wrong.

savage
21-02-2007, 12:30 PM
getenv() definitely works on the GP2X. I don't know what FPC might be doing wrong.

Thanks for the test Steve. As you said we just need to find out what FPC is doing.

savage
21-02-2007, 12:40 PM
Paul do you know if libc.genenv() is available under GP2X?

Actually I would have thought the fpgetenv() should work as well. Maybe what is required is a fix in FPC to get fpgetenv() working.

paul_nicholls
21-02-2007, 09:59 PM
Paul do you know if libc.genenv() is available under GP2X?

Actually I would have thought the fpgetenv() should work as well. Maybe what is required is a fix in FPC to get fpgetenv() working.

There is a libc.so.6 file in the devkitGP2X that may contain getenv, but I am unsure.

I did find a libc.pas file on a freepascal site that referes to the libc.so.6 file


const
libcmodulename = 'libc.so.6';


and this file has the function getenv in it which comes from the libc.so.6 file.

I hope this helps,
cheers,
Paul.

savage
22-02-2007, 09:05 PM
Could you change the code in your version of sdl.pas to look like this.

{$IFDEF GP2X}
result := libc.getenv(name);
{$ELSE}
result := fpcgetenv(name);
{$ENDIF}

You may have to change the uses clause at the top to include libc for GP2X.

savage
27-02-2007, 06:42 PM
Hi Paul or Steve,
Any joy in getting FPC to recognise either fpcgetenv() or the libc.getenv()?

paul_nicholls
27-02-2007, 08:37 PM
Hi Paul or Steve,
Any joy in getting FPC to recognise either fpcgetenv() or the libc.getenv()?

Sorry, I was away for a bit...I will try this shortly.

cheers,
Paul.

Sly
27-02-2007, 08:42 PM
I haven't tried it. I haven't tried making FPC for ARM since my last attempt almost a year ago when it was failing to build the runtime libraries due to an internal error.

paul_nicholls
08-03-2007, 12:12 AM
Hi Paul or Steve,
Any joy in getting FPC to recognise either fpcgetenv() or the libc.getenv()?

Hi savage, I was quite busy but I am back to testing the libc.getenv right now...I will let you know how it goes.

cheers,
Paul

paul_nicholls
08-03-2007, 01:09 AM
I didn't have any luck with the libc.getenv but I have gotten it working using fpgetenv!!!

in SDL.pas around line 261 (I can't recall if this differs from your new version)

{$IFDEF UNIX}
{$IFDEF FPC}
{$IFDEF Ver1_0}
linux,
{$ELSE}
pthreads,
baseunix,
{$IFNDEF gp2x}
unix,
{$ELSE}
unix;
{$ENDIF}
{$ENDIF}
{$IFNDEF gp2x}
x,
Xlib;
{$ENDIF}
{$ELSE}
Types,
Libc,
Xlib;
{$ENDIF}
{$ENDIF}

Now the SDL_getenv function:

function SDL_getenv(const name: PChar): PChar;
begin
{$IFDEF WIN32}

{$IFDEF __GPC__}
Result := getenv( string( name ) );
{$ELSE}
Result := getenv( name );
{$ENDIF}

{$ELSE}

{$IFDEF UNIX}

{$IFDEF FPC}
Result := fpgetenv(name);
{$ELSE}
Result := libc.getenv(name);
{$ENDIF}

{$ENDIF}

{$ENDIF}
end;

All I had to do was use that, and add the units\arm-linux\rtl folder to my path in my compiler batch file and it now works.
I can get the path environment variable, write it to a file, and look at it using the gp2x E-Book program :)

WooHoo!! :)
cheers,
Paul.

savage
08-03-2007, 05:11 AM
That's great news Paul! It looks like adding units\arm-linux\rtl folder to your path is what did the trick.

The difference between your IFDEF and mine is that mine removes support for v1.x of FPC. Only v2.x of FPC is supported now.

Could you follow the following link...
http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/sdl.pas?revision=1.27
and save this file as sdl.pas and use this one just to confirm 100% that it is the added path is all that is needed for v1.0 of JEDI-SDL to work with GP2X.

paul_nicholls
08-03-2007, 08:59 PM
That's great news Paul! It looks like adding units\arm-linux\rtl folder to your path is what did the trick.

The difference between your IFDEF and mine is that mine removes support for v1.x of FPC. Only v2.x of FPC is supported now.

Could you follow the following ]http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/sdl.pas?revision=1.27[/url]
and save this file as sdl.pas and use this one just to confirm 100% that it is the added path is all that is needed for v1.0 of JEDI-SDL to work with GP2X.

Hi,
I got the version of sdl.pas from above and tried it under Delphi/freepascal/lazarus.

It compiled but when running it it first complained:

The procedure entry point SDL_GetKeyRepeat could not be located in the dynamic link library SDL.dll.


does this mean I have the wrong version of the sdl.dll?

EDIT: I downloaded the new dll and fixed this issue.

Also when compiling it under freepascal arm-linux it had these errors:


SDL.pas(2183,12) Error: Forward type not resolved "PPoint"
SDL.pas(2198,11) Error: Forward type not resolved "PRect"
SDL.pas(3949,1) Fatal: There were 2 errors compiling module, stopping
SDL.pas(3949,1) Fatal: Compilation aborted

I think this one may have something to do with HAS_TYPES...is this defined automatically, or do I have to pass this to the compiler?

cheers,
Paul.

WILL
08-03-2007, 09:35 PM
Very nice work Paul!

You do know that there is got to be a tutorial coming after all this right? ;)

paul_nicholls
08-03-2007, 10:12 PM
Very nice work Paul!

You do know that there is got to be a tutorial coming after all this right? ;)

hehe :-)

Once I have this 'final' issue resolved and the new sdl.pas is working (I am currently building the fpcbuild 2.1.x version of the source code to see if that works better), I will make a web page, tutorials, and downloads :)

cheers,
Paul.

WILL
09-03-2007, 12:40 AM
Shall I go ahead and add GP2X to the Free Pascal Wiki?

paul_nicholls
09-03-2007, 12:43 AM
Shall I go ahead and add GP2X to the Free Pascal Wiki?

Just curious, what are you thinking of writing? :-)
cheers,
Paul.

WILL
09-03-2007, 03:46 AM
This: http://wiki.freepascal.org/GP2X ;)

If you make an account at freepascal.org, you can add information on the GP2X platform yourself.

paul_nicholls
09-03-2007, 04:36 AM
This: http://wiki.freepascal.org/GP2X ;)

If you make an account at freepascal.org, you can add information on the GP2X platform yourself.

Looks good :-)
damn! now I have to do some work and actually put something there!! hehe ;-)

Thanks Will.

cheers,
Paul.

Sly
09-03-2007, 04:52 AM
Psst... it's Gamepark Holdings. Gamepark were the original company that made the GP32, then a group of employees left to form Gamepark Holdings to produce the GP2X. Gamepark has been developing the XGP, but it looks like they may have gone bust before the XGP was released.

paul_nicholls
09-03-2007, 05:03 AM
Psst... it's Gamepark Holdings. Gamepark were the original company that made the GP32, then a group of employees left to form Gamepark Holdings to produce the GP2X. Gamepark has been developing the XGP, but it looks like they may have gone bust before the XGP was released.

hehe, I didn't twig to that error :-)
cheers,
Paul.

savage
09-03-2007, 07:08 AM
SDL.pas(2183,12) Error: Forward type not resolved "PPoint"
SDL.pas(2198,11) Error: Forward type not resolved "PRect"
SDL.pas(3949,1) Fatal: There were 2 errors compiling module, stopping
SDL.pas(3949,1) Fatal: Compilation aborted

I think this one may have something to do with HAS_TYPES...is this defined automatically, or do I have to pass this to the compiler?

cheers,
Paul.

Ah of course, it seems that your version of jedi-sdl.inc is the v0.5 one. Could you please grab this one
http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/jedi-sdl.inc?revision=1.13

Which contains more FPC ( and other ) defines.

paul_nicholls
09-03-2007, 10:20 AM
SDL.pas(2183,12) Error: Forward type not resolved "PPoint"
SDL.pas(2198,11) Error: Forward type not resolved "PRect"
SDL.pas(3949,1) Fatal: There were 2 errors compiling module, stopping
SDL.pas(3949,1) Fatal: Compilation aborted

I think this one may have something to do with HAS_TYPES...is this defined automatically, or do I have to pass this to the compiler?

cheers,
Paul.

Ah of course, it seems that your version of jedi-sdl.inc is the v0.5 one. Could you please grab this one
http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL/Pas/jedi-sdl.inc?revision=1.13

Which contains more FPC ( and other ) defines.

Great!
That one works and compiles under Delphi/Freepascal/Lazarus/gp2x and works for each one!

I am also now running the ppcrossarm.exe and units generated from the 2.1.x branch freepascal source code, for your information :-)

cheers,
Paul.

savage
09-03-2007, 10:26 AM
Woohoo, we have lift off! Great work Phil!

Can we have some screenies?

Ps. Does GP2X support sdl_image and libpng?

paul_nicholls
10-03-2007, 05:15 AM
Woohoo, we have lift off! Great work Phil!

Can we have some screenies?

Ps. Does GP2X support sdl_image and libpng?

GP2X can use sdl_image, and thus load png files...I haven't tried it under freepascal yet, this is my next trick :-)

I will get a screenshot posted soon :-)

cheers,
Paul.

czar
10-03-2007, 05:28 AM
Making programs for the GP2x sounds cool. I own a game console. However, I am not familiar with FPC. Will it fairly simple set it up to make a program for the GP2x? Or will it require a lot of knowledge of libraries etc. Reading the contents of this thread it all sounds complicated :)

i.e. I suppose what I am asking for: will there be a package available that we can install and get started without too much fuss?

paul_nicholls
10-03-2007, 10:36 AM
Making programs for the GP2x sounds cool. I own a game console. However, I am not familiar with FPC. Will it fairly simple set it up to make a program for the GP2x? Or will it require a lot of knowledge of libraries etc. Reading the contents of this thread it all sounds complicated :)

i.e. I suppose what I am asking for: will there be a package available that we can install and get started without too much fuss?

I am planning on hosting somewhere some downloads like compile scripts, and the fpc stuff that I built from the source code (around 20Mb) that contains the arm-linux units, cross-compiler, etc..

One will have to download those, the devkitGP2X, and do some small file modifications, but it shouldn't be TOO complicated.

Once set up it shouldn't be difficult to use.

cheers,
Paul.

savage
10-03-2007, 11:35 PM
GP2X can use sdl_image, and thus load png files...I haven't tried it under freepascal yet, this is my next trick :-)

I will get a screenshot posted soon :-)

Looking forward to the screen shots.

Does libpng exist on GP2X machines?

paul_nicholls
11-03-2007, 11:25 AM
GP2X can use sdl_image, and thus load png files...I haven't tried it under freepascal yet, this is my next trick :-)

I will get a screenshot posted soon :-)

Looking forward to the screen shots.

Does libpng exist on GP2X machines?

I was getting errors when trying to use SDL_Image when compiling for the GP2X :(

[code]]

Also, with the later source code I used to re-create the cross-compiler, I don't seem to now be able to use the SDL_getenv function anymore...returns blank for some reason (not that I need it currently anyway)

On a side note, I have started up a web page (no downloads or screenies yet) here http://fpc4gp2x.eonclash.com/ as my own start for a fpc4gp2x initiative :)

And I have done a small update to the http://wiki.freepascal.org/GP2X page.

cheers,
Paul.

savage
11-03-2007, 12:09 PM
the pow error sounds like a lib or .h file has not been linked in.

Sorry to hear about the loss of GetEnv, but sometimes you take a step back so you can get a better run up to jump over the obstacles :).

I was thinking on Friday that it would be cool to get SoAoS working on GP2X and since we've also added GBA support to JEDI-SDL, that would be nice as well.

Btw, do you own or have you played any GP2X commercial ( http://gp2x.co.uk/commercial.html ) games like Wind & Water: Puzzle Battles ( http://www.yuan-works.com/WindAndWater/ ), or Payback
<object><param name="movie" value="http://www.youtube.com/v/J0M4IcAczQc"></param><embed src="http://www.youtube.com/v/J0M4IcAczQc" type="application/x-shockwave-flash" width="316" height="260"></embed></object>
or
VEKTAR
They all look fairly polished.

Anyway, keep us posted about your progress.

Legolas
11-03-2007, 12:15 PM
pow should come from math lib, so I think you can resolve this issue by linking it by -lm

savage
11-03-2007, 10:31 PM
I've just ordered PayBack on the GBA. As my son has 2 of these I can at least grab one and use that.

Paul, I've added some fpc4gp2x info at http://wiki.gp2x.org/wiki/Alternative_SDKs

If you would like me to change anything there, please let me know.

paul_nicholls
12-03-2007, 12:22 AM
[quote="Legolas"]pow should come from math lib, so I think you can resolve this issue by ]

hmm..I am pretty sure I am already linking in -lm (see below)


arm-linux-ld.exe -static --no-warn-mismatch -s -L. -o%1.gpe link.res -lm -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng -lpng12 -lz -lSDL -ljpeg -lfreetype -lc -lgcc


Paul.

paul_nicholls
12-03-2007, 12:33 AM
the pow error sounds like a lib or .h file has not been ]http://gp2x.co.uk/commercial.html[/url] ) games like Wind & Water: Puzzle Battles ( http://www.yuan-works.com/WindAndWater/ ), or Payback
<object><param name="movie" value="http://www.youtube.com/v/J0M4IcAczQc"></param><embed src="http://www.youtube.com/v/J0M4IcAczQc" type="application/x-shockwave-flash" width="316" height="260"></embed></object>
or
VEKTAR
They all look fairly polished.

Anyway, keep us posted about your progress.

I have played Vektar as it comes with the GP2X installed into the NAND memory. It is pretty cool :-)

What is SoAoS again?
Paul.

WILL
12-03-2007, 02:57 AM
What is SoAoS again?

Siege of Avalon Open Source (http://en.wikipedia.org/wiki/Siege_of_Avalon). ;)

Legolas
12-03-2007, 01:20 PM
[quote="Legolas"]pow should come from math lib, so I think you can resolve this issue by ]

hmm..I am pretty sure I am already linking in -lm (see below)


arm-linux-ld.exe -static --no-warn-mismatch -s -L. -o%1.gpe link.res -lm -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng -lpng12 -lz -lSDL -ljpeg -lfreetype -lc -lgcc


Paul.

Sometimes I had similar issues due to lib linking order. Try moving -lm at the end of the line, but before -lc -lgcc:


arm-linux-ld.exe -static --no-warn-mismatch -s -L. -o%1.gpe link.res -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng -lpng12 -lz -lSDL -ljpeg -lfreetype -lm -lc -lgcc

paul_nicholls
13-03-2007, 02:28 AM
[quote="Legolas"]pow should come from math lib, so I think you can resolve this issue by ]

hmm..I am pretty sure I am already linking in -lm (see below)


arm-linux-ld.exe -static --no-warn-mismatch -s -L. -o%1.gpe link.res -lm -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng -lpng12 -lz -lSDL -ljpeg -lfreetype -lc -lgcc


Paul.

Sometimes I had similar issues due to lib linking order. Try moving -lm at the end of the line, but before -lc -lgcc:


arm-linux-ld.exe -static --no-warn-mismatch -s -L. -o%1.gpe link.res -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lmikmod -lpng -lpng12 -lz -lSDL -ljpeg -lfreetype -lm -lc -lgcc


Thanks Legolas, it now compiles! :)
I can now compile and use SDL_Image under freepascal/delphi, and compile under GP2X (needs testing in the handheld itself yet)

cheers,
Paul.

savage
13-03-2007, 08:05 AM
Wow it really is like magic programming, or am I missing something here? You need to move the -lm flag to a specific place?
Does that also fix the GetEnv issue?

paul_nicholls
13-03-2007, 09:47 AM
Wow it really is like magic programming, or am I missing something here? You need to move the -lm flag to a specific place?
Does that also fix the GetEnv issue?

Funny you should ask :)
Today the getenv worked on my work PC, but not on my home PC, BUT it works on the GP2X when compiling at home (didn't have the handheld to test at work)!!

I must have something different between my work and home configurations, not sure what yet...

I tried loading a .png file using Img_Load() from the SDL_Image, and it works on my home PC but the png does not display when running on my GP2X...

cheers,
Paul

paul_nicholls
13-03-2007, 11:06 AM
Hi Guys,
I have updated my fpc4gp2x site (http://fpc4gp2x.eonclash.com/) to include the cross-compiler download and a link to the required devkitGP2X file. I will put on there a tutorial on how to get it all running soon :-)

cheers,
Paul.

Legolas
13-03-2007, 11:46 AM
Nice to see that it works now :D
Savage: it's matter of dependencies. If I have understood correctly, the linker links the libraries in reverse order, so you need to put first a library and after its dependency :)

savage
13-03-2007, 12:16 PM
Thanks for the explanation Legolas, that makes sense.

paul_nicholls
15-03-2007, 03:02 AM
Hi Savage, I have a question about SDL_Mixer and the GP2X...

According to this page http://wiki.gp2x.org/wiki/SDL_mixer, the version of the SDL_Mixer header has changed and is later than the one in the source control

http://jedi-sdl.cvs.sourceforge.net/*checkout*/jedi-sdl/JEDI-SDLv1.0/SDL_Mixer/Pas/sdl_mixer.pas

Does this mean the JEDI-SDL version needs updating?

cheers,
Paul

savage
15-03-2007, 08:39 AM
The one in sourceforge should be v1.2.7, which I think is the latest stable release.

paul_nicholls
15-03-2007, 08:44 PM
The one in sourceforge should be v1.2.7, which I think is the latest stable release.

Oops, I was looking at the revision number at the top...not the actual version number! hehe :)

cheers,
Paul.

paul_nicholls
19-03-2007, 02:56 AM
Hi all :-)
I have uploaded to my fpc4gp2x site a zip file containing the SDL windows and gp2x (.gpe) executables of a work-in progress that I am using to test the gp2x cross compiler.

It is the start of a conversion for the mario bros. Nintendo game and watch clamshell game I had years ago when I was a kid :)

see http://www.ggdb.com/Picture.aspx?c=Handheld&s=Game+%26+Watch&vid=5802&p=1224

and

http://en.wikipedia.org/wiki/Mario_Bros._(Game_&_Watch)

It doesn't do much yet - has a background and only one sprite (needs sprite graphics cleaned up), and no sound but it is a start! ;-)

On windows use the P and L keys to move mario up and down + escape to exit, and use the gp2x Y and X keys to do the same + Start to exit.

On windows you need the SDL.dll to run it.

Download here (approximately 1.16MB) http://fpc4gp2x.eonclash.com/downloads/Mario_Bros.zip

cheers,
Paul.

paul_nicholls
19-03-2007, 03:56 AM
I have added the SDL.dll to the site so you can download and use it for the windows version:

http://fpc4gp2x.eonclash.com/downloads/SDL.dll

cheers,
Paul.

WILL
19-03-2007, 01:34 PM
Very nice Paul. :) Why not make a seperate thread for the game once you've gotten some screenies?

If you can get some real life video on it too that'd be awesome. (Think webcam!)

Fun idea for a first game project on the GP2X as well. Tbh, I think that I might have played that one when I was a wee one myself. :P

JoeDonth
13-05-2007, 02:36 PM
Paul,

Have you posted the source code to your MB example?

I am new to GP2X programming and have been using C++ (with CodeBlock) and stumbled on a link that pointed me here. As a long-time Pascal (Delphi) programmer, I would much rather learn the GP2X via Pascal than C++ (assuming all other things being equal).

Any suggestions (and code examples) you might want to share to help someone else get started?

Thanks,
Joe Donth

savage
13-05-2007, 07:35 PM
Welcome to the forums Joe. Great to see that someone else is interested in pursuing GP2X with Pascal. Paul was using JEDI-SDL which can be downloaded from SourceForge. You will need to grab the CVS version of the v1.0 branch to be able to make use of the GP2X changes.
You will also need to grab the latest FreePascal compiler. Paul can provide some more detailed information on how to set up both JEDI-SDL and FPC to produce the GP2X executables.

JoeDonth
13-05-2007, 08:15 PM
savage,

Thank you for the welcome. I'm looking forward to trying this.

I am set up to go - I have downloaded the required software and libraries (from Paul's previous post). I am thinking of trying Dev_pascal as my IDE (with Paul's version of FPC).

I am looking for a sample or two of code to get me started. On the GP2X forum I downloaded a couple of simple games to try and convert from C++ to Pascal but I'm not sure where to start. Headers, conditionals, defines, etc.

A couple of source code examples of simple programs that I can compile to run on the gp2x (<name>.gpe) and via Ming (<name>.exe) on Windows would go a long way to getting me started.

Thanks again,
Joe

paul_nicholls
13-05-2007, 10:33 PM
[quote="JoeDonth"]Paul,

Have you posted the source code to your MB example?

I am new to GP2X programming and have been using C++ (with CodeBlock) and stumbled on a ]

Hi Joe,
sorry I haven't uploaded any updates for a while now...life has been keeping me busy :(
I will try and upload the final instructions in the next few days so you can use what I uploaded before to compile programs for the GP2X :-)

cheers,
Paul.

paul_nicholls
14-05-2007, 05:29 AM
WooHoo!!
I have updated the (http://fpc4gp2x.eonclash.com/) site with a simple sdl tutorial that compiles under Win32 and gp2x, and I have also written some documentation on how to set it all up!

I will start a new thread for working gp2x console development stuff like this :-)

Enjoy!!
cheers,
Paul.

paul_nicholls
14-05-2007, 06:44 AM
I have started another post (http://www.pascalgamedevelopment.com/viewtopic.php?p=34045) for all gp2x working stuff.

I will continue to post here if I have actual problems! :-)

Perhaps this would make a good news item or something?
cheers,
Paul.

savage
14-05-2007, 08:12 AM
Great news Paul! Do you know if your changes will be incorporated into the next FPC release? Also it would nice for the FreePascal guys to post a news item and link to your site from their site.

You might also want to post an item into My Projects with a screen shot of the demo running. That way we can promote the post to being a news item. Posts to "Game Console Development" currently can't be news items.

WILL
14-05-2007, 04:24 PM
Hey Paul, looks like you're being put to task this week huh? ;)

Got one more suggestion for you when you have time. On the FPC Wiki there is a GP2X article. I'd recommend making an update to it adding whatever relevant information that you think will be of benefit, including a link to the FPC 4 GP2X project.

It'll help you get a full audience of those that would be interested in your efforts.

paul_nicholls
14-05-2007, 11:04 PM
Hi Will,
I have updated the http://wiki.freepascal.org/GP2X gp2x article on the freepascal wiki.

cheers,
Paul.

paul_nicholls
15-05-2007, 04:37 AM
[quote="savage"]Great news Paul! Do you know if your changes will be incorporated into the next FPC release? Also it would nice for the FreePascal guys to post a news item and ]

Hi savage,
I have posted an item into My Projects http://www.pascalgamedevelopment.com/viewtopic.php?p=34080#34080 but I was not sure how to insert the screenshot except for the external link...

About being included into freepascal, I wouldn't have a clue :-)

cheers,
Paul.

savage
15-05-2007, 08:54 AM
ok I've upgraded you post to be a news item. With regard to being included FreePascal, I think you just need to contact the team and let them now that the port is ready.

Also what theme are you using on PGD? When making a post there should be a "Add Image to post" link just below the message body that you can use to embed images.

paul_nicholls
15-05-2007, 10:23 AM
[quote="savage"]ok I've upgraded you post to be a news item. With regard to being included FreePascal, I think you just need to contact the team and let them now that the port is ready.

Also what theme are you using on PGD? When making a post there should be a "Add Image to post" ]

Thanks for the upgrade :)

I will contact the freepascal team about the port.

I am using board style: subSilver.
Do I need Internet Explorer to get the "Add Image to post" option?
I am using Firefox...

cheers,
Paul

savage
15-05-2007, 11:22 AM
I am using board style: subSilver.


Ah, that would be it then. That did not have the proper code. I have just made a change, so you should be able to see it in subSilver now.

paul_nicholls
15-05-2007, 12:14 PM
I am using board style: subSilver.


Ah, that would be it then. That did not have the proper code. I have just made a change, so you should be able to see it in subSilver now.

Thanks! That was quick! :-)

I have now posted a message on the freepascal community about my work http://community.freepascal.org:10000/bboards/message?message_id=251299&forum_id=24081
cheers,
Paul.

paul_nicholls
18-05-2007, 03:36 AM
Hi all :-)

I need to pick the brains of you freepascal and assembly (ARM) people out there :-)

If I have an assembly file that is in text format like so:

asmlib.s

@ gp2x demo article code by Dzz
@ this code is placed in the public domain. do anything you want with it.

.align 4
.globl OpenFile
.globl CloseFile
.globl WriteFile
.globl MUnmap
.globl ChangeDir
.globl ExecuteFile
.globl MMap
.globl Ioctl3

OpenFile&#58;
swi #0x900005
mov pc, lr

CloseFile&#58;
swi #0x900006
mov pc, lr

WriteFile&#58;
swi #0x900004
mov pc, lr

MUnmap&#58;
swi #0x90005B
mov pc, lr

ChangeDir&#58;
swi #0x90000C
mov pc, lr

ExecuteFile&#58;
swi #0x90000B
mov pc, lr

Ioctl3&#58;
swi #0x900036
mov pc, lr

MMap&#58;
stmdb sp!, &#123;r0, r1, r2, r3&#125;
mov r0, sp
swi #0x90005A
add sp, sp, #16
mov pc, lr


and a c header file like this (Before conversion to pascal)
library.h

extern int OpenFile&#40;char *pszFile, int nMode&#41;;
extern void CloseFile&#40;int nFile&#41;;
extern int WriteFile&#40;int fd, void *pBuffer, int nLen&#41;;
extern void *MMap&#40;void *pAddr, int nLen, int nProtection, int nFlags, int nFD, int nOff&#41;;
extern void MUnmap&#40;void *p, int nSize&#41;;
extern void ChangeDir&#40;char *pszDir&#41;;
extern void ExecuteFile&#40;char *pszFile, int nZero1, int nZero2&#41;;
extern int Ioctl3&#40;int fd, unsigned int ulFunction, unsigned int ulParameter&#41;;


does anyone know how I can compile the asmlib.s file and link the library routines to it so I can call them from freepascal?

I assume I would need to use the arm-linux-ld.exe, arm-linux-as.exe, etc. programs somehow...

or possibly the pccrossarm.exe cross-compiler?

cheers,
Paul.

paul_nicholls
18-05-2007, 05:01 AM
I have figured it out (mostly).

I need to assembly the .s file first


arm-linux-gcc.exe -c libgp2x_asm.s

this creates the .o file.

I then have my unit I translated from the header file:


Unit libgp2x;
&#123;$link libgp2x_asm.o&#125;
&#123;$linklib c&#125;

Interface

Uses
CTypes;

Function OpenFile&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;&#58; Integer; External;
Procedure CloseFile&#40;nFile&#58; ctypes.cint32&#41;; External;
Function MMap&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nFD,nOff&#58; ctypes.cint32&#41;&#58; Pointer; External;
Procedure MUnmap&#40;p&#58; Pointer; nSize&#58; ctypes.cint32&#41;; External;
Procedure ChangeDir&#40;pszDir&#58; PChar&#41;; External;
Procedure ExecuteFile&#40;pszFile&#58; PChar; nZero1,nZero2&#58; ctypes.cint32&#41;; External;
Procedure RestartMenu;
&#123;
extern int OpenFile&#40;char *pszFile, int nMode&#41;;
extern void CloseFile&#40;int nFile&#41;;
extern void *MMap&#40;void *pAddr, int nLen, int nProtection, int nFlags, int nFD, int nOff&#41;;
extern void MUnmap&#40;void *p, int nSize&#41;;
extern void ChangeDir&#40;char *pszDir&#41;;
extern void ExecuteFile&#40;char *pszFile, int nZero1, int nZero2&#41;;
extern void RestartMenu&#40;&#41;;
&#125;
Implementation

Procedure RestartMenu;
Begin
ChangeDir &#40;PChar&#40;'/usr/gp2x'&#41;&#41;;
ExecuteFile&#40;PChar&#40;'/usr/gp2x/gp2xmenu'&#41;, 0, 0&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
End.

The problem I now have is when I try and link in my libgp2x unit I get this error:


Assembling engine3dtest
Linking engine3dtest
libgp2x.o&#58; In function `LIBGP2X_RESTARTMENU'&#58;
libgp2x.pas&#58;&#40;.text+0x14&#41;&#58; undefined reference to `LIBGP2X_CHANGEDIR$PCHAR'
libgp2x.pas&#58;&#40;.text+0x24&#41;&#58; undefined reference to `LIBGP2X_EXECUTEFILE$PCHAR$LONG
INT$LONGINT'
An error occured while linking engine3dtest
Press any key to continue . . .

For some reason the linker doesn't like my references in the RestartMenu procedure to the ChangeDir and ExecuteFile external routines...

Any ideas?
cheers,
Paul.

paul_nicholls
18-05-2007, 05:39 AM
It looks like I have figured it out :)


Function OpenFile&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;&#58; ctypes.cint32; Cdecl; External;
Procedure CloseFile&#40;nFile&#58; ctypes.cint32&#41;; Cdecl; External;
Function MMap&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nFD,nOff&#58; ctypes.cint32&#41;&#58; Pointer; Cdecl; External;
Procedure MUnmap&#40;p&#58; Pointer; nSize&#58; ctypes.cint32&#41;; Cdecl; External;
Procedure ChangeDir&#40;pszDir&#58; PChar&#41;; Cdecl; External;
Procedure ExecuteFile&#40;pszFile&#58; PChar; nZero1,nZero2&#58; ctypes.cint32&#41;; Cdecl; External;

I was missing the Cdecl declaration for the external routines!

I will now be playing around with accessing the hardware of the gp2x directly using the above routines to see if I can get some graphics working faster on the gp2x :)

cheers,
Paul.

Legolas
18-05-2007, 10:02 AM
You could take a look to my gba and/or nds port. I have resolved issues like that, so you could save alot of time :)

paul_nicholls
18-05-2007, 12:26 PM
You could take a look to my gba and/or nds port. I have resolved issues like that, so you could save alot of time :)

Thanks!
I will take a look...I have already downloaded the fpc4nds stuff before but I hadn't had much of a look yet.

cheers,
Paul.