PDA

View Full Version : FPC4GP2X status?



pstudio
25-10-2007, 08:23 PM
I'm expecting to recieve my GP2X F200 in the folllowing days and is ofcourse excited to start coding for it.
However I'm wondering what the status of Pascal GP2X development is?
How much of SDL can I use with Pascal?
Are there any games (or demos) made with Pascal for the GP2X at this time?
Can I use HW-SDL instead of the normal SDL you get withthe console?
Would I be better of using the forbidden language (C++)?

paul_nicholls
26-10-2007, 03:39 AM
Hi pstudio,
congratulations on purchasing a GP2X F200 - I would like to buy one of those versions one day (read: not anytime soon due to lack of money <G>)

When you get yours, let us know if the "d-pad" works ok, and how the touchscreen goes :-)

I have used the standard SDL functions ok (including loading BMP files, etc), but things I have had trouble with is the SDL_Mixer and loading PNG files using SDL_Image :(

I can load and play WAV files ok not using the SDL_Mixer routines.

I am working on the PNG files and SDL_Mixer problems to see if I can get around these issues.

I am going to try making my own separate library using a C compiler to make a library I can use from freepascal to try loading PNG files and try to use the mixer routines.

The only game I know of made with pascal for the GP2X is the one called blocks by Eugene Proshkin (http://www.gp32x.com/board/lofiversion/index.php/t34048.html) but I am sure there are other pascal games elsewhere already made.

There is a hardware-accelerated version of SDL - I downloaded one to try with the devkitGP2X...I haven't done much testing yet. One issue with this version is that because it has libmad included for mp3 playing, I think it can't be used for commercial projects, and the projects bust be open source?

cheers,
Paul.

jasonf
26-10-2007, 08:17 AM
Talk about shooting themselves in the foot then... including GPL (I'm assuming here) code in a library so anything statically linked with it becomes GPL..

Unless you can dynamically link to it, in which case, there's no problem.

But they should be making it easier for commercial projects to move to the GP2X, not harder.

How much support have you had from the GP2X forums?

it would be a real shame if this cool device went down in the annuls of history as a cute device for playing emulators... and that's all...

It needs real, commercial games now. That would quash one of the biggest criticisms it has from users outside of the circle.

pstudio
26-10-2007, 08:45 PM
When you get yours, let us know if the "d-pad" works ok, and how the touchscreen goes
My oppinion probably wouldn't help. I'm one of the few guys who thought that the PSP D-pad was ok. One of my friends nearly hit me in the head for saying that ;)

Ok so it's possible to make a 'real' game, but your kind of limited regarding what image and sound file type to use.

Do the problems with SDL, Mixer and Image only occur when using Pascal or do they also happen when coding C?

Unfortunately I couldn't download Blocks (Got a SQL error :?). I would have liked to see it run on my GP2X as one of the first games.

I guess there are still some issues to be dealt with before Pascal GP2X development will be truly easy and smooth, but that just makes it more interesting ;)
Can't wait to get my fingers on it :D

paul_nicholls
27-10-2007, 11:02 PM
When you get yours, let us know if the "d-pad" works ok, and how the touchscreen goes
My oppinion probably wouldn't help. I'm one of the few guys who thought that the PSP D-pad was ok. One of my friends nearly hit me in the head for saying that ;)

haha!! fair enough :)


Ok so it's possible to make a 'real' game, but your kind of limited regarding what image and sound file type to use.

Do the problems with SDL, Mixer and Image only occur when using Pascal or do they also happen when coding C?

People seem to have less issues when using C/C++ to do GP2X programs, but I am not sure if there are pascal ]Unfortunately I couldn't download Blocks (Got a SQL error :?). I would have liked to see it run on my GP2X as one of the first games.[/quote]

have you tried from this site?
http://www.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,25,2030

This site has loads of games, useful libraries, tools, etc. :)


I guess there are still some issues to be dealt with before Pascal GP2X development will be truly easy and smooth, but that just makes it more interesting ;)
Can't wait to get my fingers on it :D

:) It is fun regardless of the current hiccups :-)

cheers,
Paul.

jasonf
30-10-2007, 07:51 PM
Hi Paul,

I was wondering wether you'd had any luck with the mixer and png issues. Sounded like you had a plan earlier..

I'd really like to get something up and running (as you know :))

paul_nicholls
30-10-2007, 08:57 PM
Hi Paul,

I was wondering wether you'd had any luck with the mixer and png issues. Sounded like you had a plan earlier..

I'd really like to get something up and running (as you know :))

Sorry Jason, I hadn't gotten around to trying my separate library idea yet :(
I will try and see if I can get it going in the next couple of days if that is ok.

cheers,
Paul

WILL
31-10-2007, 03:38 AM
Hey Paul. I've sort of been following the GP2X/JEDI-SDL development from the side-lines. For clarification, are the programs crashing/popping up errors because of the sdl_mixer code in the sdl_mixer.so file it's self?

For PNG what exactly is the Linux solution for this anyhow? I know that for Windows I use PNG with a series of DLL files such as; libpng13.dll, jpeg.dll and of course SDL_image.dll.

Now I'm assuming the PNG issue is directly with SDL_image or is it less obvious than this?


I too am interested in GP2X dev as a portable platform for anything I might release, but like Jason I use PNG for all my graphics and sdl_mixer to play music.

So one more guy routing for ya! ;)

paul_nicholls
01-11-2007, 02:59 AM
Hey Paul. I've sort of been following the GP2X/JEDI-SDL development from the side-lines. For clarification, are the programs crashing/popping up errors because of the sdl_mixer code in the sdl_mixer.so file it's self?

For PNG what exactly is the Linux solution for this anyhow? I know that for Windows I use PNG with a series of DLL files such as; libpng13.dll, jpeg.dll and of course SDL_image.dll.

Now I'm assuming the PNG issue is directly with SDL_image or is it less obvious than this?


I too am interested in GP2X dev as a portable platform for anything I might release, but like Jason I use PNG for all my graphics and sdl_mixer to play music.

So one more guy routing for ya! ;)

thanks for the encouragement Will :)

I am experimenting with a simple c library that I am compiling to .o format so I can ]Linking sdlibltest
sdlibltest.o&#58; In function `P$SDLTEST_SHUTDOWN'&#58;
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_shutdown+0x24&#41;&#58; undefined reference to `gp2x_Mix_FreeMusic'
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_shutdown+0x28&#41;&#58; undefined reference to `gp2x_Mix_CloseAudio'
sdlibltest.o&#58; In function `P$SDLTEST_OPENAUDIO$$BOOLEAN'&#58;
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_openaudio$$boole an+0x50&#41;&#58; undefined reference to `gp2x_Mix_OpenAudio'
sdlibltest.o&#58; In function `P$SDLTEST_LOADMUSIC$ANSISTRING$$POINTER'&#58;
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_loadmusic$ansist ring$$pointer+0x28&#41;&#58; undefined reference to `gp2x_Mix_LoadMUS'
sdlibltest.o&#58; In function `P$SDLTEST_PLAYMUSIC$POINTER$LONGINT$$LONGINT'&#58;
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_playmusic$pointe r$longint$$longint+0x20&#41;&#58; undefined reference to `gp2x_Mix_PlayMusic'
sdlibltest.o&#58; In function `P$SDLTEST_PLAYINGMUSIC$$BOOLEAN'&#58;
sdlibltest.dpr&#58;&#40;.text.n_p$sdltest_playingmusic$$bo olean+0x10&#41;&#58; undefined reference to `gp2x_Mix_PlayingMusic'[/code]

my c library header file (gp2x_sdl_mixer.h)

#ifndef GP2X_SDL_MIXER
#define GP2X_SDL_MIXER

#include "SDL_mixer.h"

int gp2x_Mix_OpenAudio&#40;int frequency, Uint16 format, int channels, int chunksize&#41;;
void gp2x_Mix_CloseAudio&#40;void&#41;;
Mix_Music *gp2x_Mix_LoadMUS&#40;const char *file&#41;;
int gp2x_Mix_PlayMusic&#40;Mix_Music *music, int loops&#41;;
int gp2x_Mix_PlayingMusic&#40;void&#41;;
void gp2x_Mix_FreeMusic &#40;Mix_Music *music&#41;;

#endif


my c library definitions (gp2x_sdl_mixer.c)


#include "gp2x_sdl_mixer.h"

int gp2x_Mix_OpenAudio&#40;int frequency, Uint16 format, int channels, int chunksize&#41;
&#123;
return Mix_OpenAudio&#40;frequency,format,channels,chunksize&#41; ;
&#125;;
void gp2x_Mix_CloseAudio&#40;void&#41;
&#123;
Mix_CloseAudio&#40;&#41;;
&#125;;
Mix_Music *gp2x_Mix_LoadMUS&#40;const char *file&#41;
&#123;
return Mix_LoadMUS&#40;file&#41;;
&#125;;
int gp2x_Mix_PlayMusic&#40;Mix_Music *music, int loops&#41;
&#123;
return Mix_PlayMusic&#40;music,loops&#41;;
&#125;;
int gp2x_Mix_PlayingMusic&#40;void&#41;
&#123;
return Mix_PlayingMusic&#40;&#41;;
&#125;;
void gp2x_Mix_FreeMusic &#40;Mix_Music *music&#41;
&#123;
Mix_FreeMusic&#40;music&#41;;
&#125;;


My pascal unit that includes the c library (gp2x_sdl_mixer.pas)



Unit gp2x_sdl_mixer;
&#123;$IFDEF fpc
&#123;$MODE Delphi&#125;
&#123;$ENDIF&#125;

&#123;$link gp2x_sdl_mixer.o&#125;
&#123;$linklib c&#125;

Interface

Uses
CTypes;

Type
PMix_Music = Pointer;

Function gp2x_Mix_OpenAudio&#40;frequency &#58; ctypes.cint32; format &#58; ctypes.cuint16; channels,chunksize &#58; ctypes.cint32&#41; &#58; ctypes.cint32; cdecl; external;
Procedure gp2x_Mix_CloseAudio; CDecl; external;
Function gp2x_Mix_LoadMUS&#40;Const filename &#58; PChar&#41; &#58; PMix_Music; CDecl; external;
Function gp2x_Mix_PlayMusic&#40;music &#58; PMix_Music; loops &#58; ctypes.cint32&#41; &#58; ctypes.cint32; CDecl; external;
Function gp2x_Mix_PlayingMusic &#58; ctypes.cint32; CDecl; external;
Procedure gp2x_Mix_FreeMusic&#40;music &#58; PMix_Music&#41;; CDecl; external;

Implementation

End.


I compile the c library to .o by doing this:


arm-linux-gcc.exe -c gp2x_sdl_mixer.c -Ic&#58;\devkitGP2X\include\SDL

When I try and use the unit in a program like so and link in the library I get the errors I posted :(


Uses
SysUtils,
SDL,
&#123;$IFNDEF gp2x&#125;
SDL_Mixer
&#123;$ELSE&#125;
gp2x_sdl_mixer
&#123;$ENDIF&#125;
;



Function OpenAudio &#58; Boolean;
Begin
&#123;$IFDEF gp2x&#125;
Result &#58;= gp2x_Mix_OpenAudio&#40;22050, AUDIO_S16, 2, 4096&#41; = 0; // Initialize SDL_mixer
&#123;$ELSE&#125;
Result &#58;= Mix_OpenAudio&#40;22050, AUDIO_S16, 2, 4096&#41; = 0; // Initialize SDL_mixer
&#123;$ENDIF&#125;
If Not Result Then
Begin
Log&#40;'Mix_OpenAudio failed&#58; ' + SDL_GetError&#41;;
Exit;
End;
Log&#40;'Mix_OpenAudio...'&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure CloseAudio;
Begin
&#123;$IFDEF gp2x&#125;
gp2x_Mix_CloseAudio;
&#123;$ELSE&#125;
Mix_CloseAudio;
&#123;$ENDIF&#125;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function LoadMusic&#40;Const filename &#58; AnsiString&#41; &#58; PMix_Music;
Begin
&#123;$IFDEF gp2x&#125;
Result &#58;= gp2x_Mix_LoadMUS&#40;PChar&#40;filename&#41;&#41;;
&#123;$ELSE&#125;
Result &#58;= Mix_LoadMUS&#40;PChar&#40;filename&#41;&#41;;
&#123;$ENDIF&#125;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function PlayMusic&#40;music &#58; PMix_Music; loops &#58; Integer&#41; &#58; Integer;
Begin
&#123;$IFDEF gp2x&#125;
Result &#58;= gp2x_Mix_PlayMusic&#40;music,loops&#41;;
&#123;$ELSE&#125;
Result &#58;= Mix_PlayMusic&#40;music,loops&#41;;
&#123;$ENDIF&#125;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function PlayingMusic &#58; Boolean;
Begin
&#123;$IFDEF gp2x&#125;
Result &#58;= gp2x_Mix_PlayingMusic = 1;
&#123;$ELSE&#125;
Result &#58;= Mix_PlayingMusic = 1;
&#123;$ENDIF&#125;
End;
&#123;................................................. .............................&#125;

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



any ideas?
cheers,
Paul

dmantione
01-11-2007, 09:10 PM
Do a "nm gp2x_sdl_mixer.o" and compare the symbols displayed with the ones the compiler is looking for. Can you see differences?

paul_nicholls
01-11-2007, 09:23 PM
Do a "nm gp2x_sdl_mixer.o" and compare the symbols displayed with the ones the compiler is looking for. Can you see differences?

Hi dmantione,
I tried that and it said "File format not recognized". I tried both the arm-linux-nm.exe (c:\devkitGP2X\bin\) and the nm.exe (c:\devkitGP2X\arm-linux\bin\).

cheers,
Paul

dmantione
01-11-2007, 09:49 PM
That is not okay, and suggests the .o file is not build correctly. Verify if your C compiler generates the .o files FPC needs.

paul_nicholls
01-11-2007, 10:10 PM
That is not okay, and suggests the .o file is not build correctly. Verify if your C compiler generates the .o files FPC needs.

It works fine when I compile some arm assembly and ]libgp2x_asm.s[/b]


@ 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 CopyScreen
.globl ClearScreen
.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

CopyScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
.CopyScreenLoop&#58;
ldmia r1!, &#123;r3-r10&#125; @ pull in 32 bytes from the source
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .CopyScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return

ClearScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
mov r3, #0 @ load up the registers with zeros
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
.ClearScreenLoop&#58;
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes of zeros to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .ClearScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return



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

cheers,
Paul

dmantione
02-11-2007, 09:49 AM
Any .o file generated by the GNU assembler should be processable by the nm utility belonging to that assembler (regardless wether the compiler calling that assembler is GCC, FPC).

If "nm" cannot process a .o file, either the .o file is corrupt, or it is written in a format "nm" does not understand, but in that case, as and nm do not belong together.

Anyway, the output by "nm" is critical to understand this problem, so you will need to solve this problem in one way or another.

paul_nicholls
04-11-2007, 08:50 PM
Any .o file generated by the GNU assembler should be processable by the nm utility belonging to that assembler (regardless wether the compiler calling that assembler is GCC, FPC).

If "nm" cannot process a .o file, either the .o file is corrupt, or it is written in a format "nm" does not understand, but in that case, as and nm do not belong together.

Anyway, the output by "nm" is critical to understand this problem, so you will need to solve this problem in one way or another.

Ok, thanks for the help, but I dont't know how to proceed now :(

cheers,
Paul

pstudio
07-11-2007, 10:00 PM
Ok - I need help.
I recieved my F200 yesterday (tuesday), and now I want to try and compile something for it, but I can't :(

I've downloaded the guides written by Paul and followed them from the beginning to the end, but when I run the CompileProject batch file I get following error during link stage :

Linking gp2x_tutorial
arm-linux-ld.exe&#58; cannot find -lSDL
An error occured while linking gp2x_tutorial

How do I fix this problem? (It's probably a newb question, but I'm used to use compilers/ide's that works ot of the box)

paul_nicholls
07-11-2007, 11:40 PM
Ok - I need help.
I recieved my F200 yesterday (tuesday), and now I want to try and compile something for it, but I can't :(

I've downloaded the guides written by Paul and followed them from the beginning to the end, but when I run the CompileProject batch file I get following error during ]Linking gp2x_tutorial
arm-linux-ld.exe&#58; cannot find -lSDL
An error occured while linking gp2x_tutorial[/code]

How do I fix this problem? (It's probably a newb question, but I'm used to use compilers/ide's that works ot of the box)

strange, it should work out of the "box"; other people have used it ok...

Sorry about this, I will look into it...

PS In case it helps me, can you post the contents of your batch files that you had to alter to match file paths on your computer?

cheers,
Paul

pstudio
08-11-2007, 12:29 AM
I didn't alter the filepaths since I unzippd the files to the same location as you suggested. The only filepath I changed was in the FPC config file where i changed the g:\... to c:\.

pstudio
08-11-2007, 08:57 PM
Nevermind. I redownloaded the devkit and now it works :)
I've just compiled my first GP2X program and now I'm gonna see if it works :D (probably wont ;))

paul_nicholls
08-11-2007, 09:15 PM
Nevermind. I redownloaded the devkit and now it works :)
I've just compiled my first GP2X program and now I'm gonna see if it works :D (probably wont ;))

Excellent!! :)

So what is your first program, the tutorial I wrote, or one of your own?

cheers,
Paul

pstudio
08-11-2007, 09:30 PM
I took your base code and changed it a bit. I made two sprites. The one could be moved horizontal by pressing d-pad and they other moved vertical using timebased movement. However it moves slower than on my pc, so I may have made something wrong.

Btw. what's going on with the file sizes? The Pc version fills 45 KB while the GP2X fills 0.98 MB :shock:

I've also taken a quick glimpse at Eugenes code, and he uses the mixer. I haven't actually tried the game yet on my GP2X (Out of batteries and it takes so long to recharge them), but if it works correctly I only have to worry about png support.

savage
08-11-2007, 11:49 PM
Sounds good so far guys!

pstudio
11-11-2007, 08:00 PM
I have been away for the weekend on a secluded island which means that I've had some time to fool araound with my GP2X. :)
I've been succesful reading input from the touchscreen*. It even worked at first attempt ;)
If any are interested in it (have a GP2X F200), I've uploaded the code and binaries here (http://host-a.net/pstudio/Test02%20(Touchscreen,%20ttf).7z).
It's not 100 % accurate since it isn't calibrated correct. I know some guys have manged to load the settings from the GP2X, so I'll have to look into that next.

*Thanks to joyrider, hangman etc. @ gp32x.com and their example c code.

@Paul
I've also taken a closer look at Eugenes code and worked a bit with SDL_Mixer. Blocks work fine regarding playing ogg-files via mixer. However when I wrote my own testprogram it worked fine on windows, but crashed on the GP2X. But when I compiled the program I got a warning that said something about static linking versus dynamic linking. Your batchfiles use static linking while Eugenes uses dynamic linking. I'm not an expert at this area, but it could maybe solve the problems with mixer if I used dynamic linking instead. However I couldn't compile it using dynamic linking. How do I use dynamic linking?

savage
11-11-2007, 08:16 PM
JEDI-SDL should dynamic link by default as long as it can find the *.so files for the various SDL libs. Not sure if that helps.

pstudio
11-11-2007, 08:35 PM
Ok, but it couldn't find all the *.so files (well at least on so-ile) when I tried dynamic linking. :( I know the file exists, but I don't know what to do now. The file should be in the search path, but yet it can't be found :?

paul_nicholls
26-11-2007, 09:14 PM
[quote="pstudio"]I have been away for the weekend on a secluded island which means that I've had some time to fool araound with my GP2X. :)
I've been succesful reading input from the touchscreen*. It even worked at first attempt ;)
If any are interested in it (have a GP2X F200), I've uploaded the code and binaries here (http://host-a.net/pstudio/Test02%20(Touchscreen,%20ttf).7z).
It's not 100 % accurate since it isn't calibrated correct. I know some guys have manged to load the settings from the GP2X, so I'll have to look into that next.

*Thanks to joyrider, hangman etc. @ gp32x.com and their example c code.

@Paul
I've also taken a closer look at Eugenes code and worked a bit with SDL_Mixer. Blocks work fine regarding playing ogg-files via mixer. However when I wrote my own testprogram it worked fine on windows, but crashed on the GP2X. But when I compiled the program I got a warning that said something about static ]

Hi pstudio,
Great work with the touch screen stuff :-)

I was 'talking' to Eugene via email and asking him about dynamic linking and he says that he only uses static linking as he can't get a batch file? for dynamic linking...

I also told him about the SDL_Mixer crashes on the gp2x and he suggested I make a small project with sound and send it to him so he can compile and test it. I am going to do this and I will get back to you guys when I know more.

PS
If it helps I had created a pascal unit that links some ARM asm which allows you to use access the gp2x linux system 'files' stuff ('/dev/fb0', etc) in the same way as the C/C++ guys do.

libgp2x_asm.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 CopyScreen
.globl ClearScreen
.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

CopyScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
.CopyScreenLoop&#58;
ldmia r1!, &#123;r3-r10&#125; @ pull in 32 bytes from the source
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .CopyScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return

ClearScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
mov r3, #0 @ load up the registers with zeros
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
.ClearScreenLoop&#58;
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes of zeros to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .ClearScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return


assemble the .s file like so

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

libgp2x.pas

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

Interface

Uses
CTypes;

Const
MREMAP_MAYMOVE = 1;
MREMAP_FIXED = 2;

PROT_READ = $1; // page can be read
PROT_WRITE = $2; // page can be written
PROT_EXEC = $4; // page can be executed
PROT_NONE = $0; // page can not be accessed

MAP_SHARED = $01; // Share changes
MAP_PRIVATE = $02; // Changes are private

&#123;$IFDEF gp2x&#125;
MAP_FIXED = $10; // Interpret addr exactly
MAP_ANONYMOUS = $20; // don't use a file
MAP_GROWSDOWN = $0100; // stack-like segment
MAP_DENYWRITE = $0800; // ETXTBSY
MAP_EXECUTABLE = $1000; // mark it as an executable
MAP_LOCKED = $2000; // pages are locked
MAP_NORESERVE = $4000; // don't check for reservations
MS_ASYNC = 1; // sync memory asynchronously
MS_INVALIDATE = 2; // invalidate the caches
MS_SYNC = 4; // synchronous memory sync
MCL_CURRENT = 1; // lock all current mappings
MCL_FUTURE = 2; // lock all future mappings
MADV_NORMAL = $0; // default page-in behavior
MADV_RANDOM = $1; // page-in minimum required
MADV_SEQUENTIAL = $2; // read-ahead aggressively
MADV_WILLNEED = $3; // pre-fault pages
MADV_DONTNEED = $4; // discard these pages
O_RDWR = 2;
&#123;$ENDIF&#125;

// compatibility flags
MAP_ANON = MAP_ANONYMOUS;
MAP_FILE = 0;

MAP_FAILED = Pointer&#40;-1&#41;;

Type
Tgp2xDevice = Class
Protected
FDev &#58; ctypes.cint32;
FMemData &#58; Pointer;
FMemSize &#58; ctypes.cint32;
Public
Constructor Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
Destructor Destroy; Override;
Procedure MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
Procedure UnmapMem;
Property MemData&#58; Pointer Read FMemData;
End;

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;
Function Ioctl3&#40;fd&#58; ctypes.cint32; ulFunction,ulParameter&#58; ctypes.cushort&#41;&#58; ctypes.cint32; Cdecl; External;
Procedure CopyScreen&#40;pDest,pSrc&#58; ctypes.pcushort&#41;; Cdecl; External;
Procedure ClearScreen&#40;pus&#58; ctypes.pcushort&#41;; Cdecl; External;
Procedure RestartMenu;
Implementation

Constructor Tgp2xDevice.Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
Begin
Inherited Create;

FDev &#58;= 0;
FMemData &#58;= Nil;
FMemSize &#58;= 0;
FDev &#58;= OpenFile&#40;pszFile,nMode&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Destructor Tgp2xDevice.Destroy;
Begin
UnmapMem;
If FDev <> 0 Then
CloseFile&#40;FDev&#41;;

Inherited Destroy;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure Tgp2xDevice.UnmapMem;
Begin
If FMemData <> Nil Then
Begin
MUnmap&#40;FMemData,FMemSize&#41;;
FMemData &#58;= Nil;
FMemSize &#58;= 0;
End;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure Tgp2xDevice.MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
Begin
UnmapMem;

FMemSize &#58;= nLen;
FMemData &#58;= MMap&#40;pAddr, FMemSize, nProtection, nFlags, FDev, nOff&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
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.

usage examples


Const
cRscale = 5;
cGscale = 6;
cBscale = 5;
cRshift = 11;
cGshift = 5;
cBshift = 0;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function RGBTo16Bit&#40;r,g,b&#58; Uint8&#41;&#58; Uint16;
Begin
Result &#58;= &#40;&#40;&#40;r Shl cRscale&#41; Shl 8&#41; Shl cRshift&#41; +
&#40;&#40;&#40;g Shl cGscale&#41; Shl 8&#41; Shl cGshift&#41; +
&#40;&#40;&#40;b Shl cBscale&#41; Shl 8&#41; Shl cBshift&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Ffb0 &#58;= Tgp2xDevice.Create&#40;'/dev/fb0', O_RDWR&#41;;
Ffb1 &#58;= Tgp2xDevice.Create&#40;'/dev/fb1', O_RDWR&#41;;

FWidth &#58;= 320;
FHeight &#58;= 240;
FBitsPerPixel &#58;= 16;
Ffb0.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;
Ffb1.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;

&#123;...&#125;
Procedure TRendererModule_gp2x.ClearScreen&#40;r,g,b&#58; Byte&#41;;
Var
c &#58; Uint32;
i &#58; LongInt;
addr &#58; PUint8;
Begin
c &#58;= RGBTo16Bit&#40;r,g,b&#41;;
addr &#58;= Ffb1.MemData;
i &#58;= FWidth * FHeight;
While i <= 0 Do
Begin
PUint16&#40;addr&#41;^ &#58;= Uint16&#40;c&#41;;
Inc&#40;addr,2&#41;;
Dec&#40;i&#41;;
End;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TRendererModule_gp2x.FlipScreen;
Begin
CopyScreen&#40;Ffb0.MemData,Ffb1.MemData&#41;;
End;
&#123;................................................. .............................&#125;

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

&#123;...&#125;
Ffb0.Free;
Ffb1.Free;


You could use this for your touchscreen code as well by opening up the device using the Tgp2xDevice class.

Enjoy

cheers,
Paul

KidPaddle
27-11-2007, 04:57 AM
Nice work!

Have you done some speed test? Which is faster, SDL or your code?

I have some code for direct access to buttons, now we have some code for display, if we get code for playing sounds / music, we can create small programs without using external libraries.

cheers,
Thomas

dmantione
27-11-2007, 06:33 AM
Note that most routines in the above libgp2x unit are already present in the baseunix unit and you are doing double work.

paul_nicholls
27-11-2007, 08:22 AM
Note that most routines in the above libgp2x unit are already present in the baseunix unit and you are doing double work.

Hi dmantione,
thanks for the info, I didn't realize :-)
Which routines are present in the baseunix unit?

cheers,
Paul.

dmantione
27-11-2007, 01:05 PM
That question is best answered by its documentation:

http://www.freepascal.org/docs-html/rtl/baseunix/index-5.html

dmantione
01-12-2007, 11:17 AM
I can be added to the list of GP2x owners :)

paul_nicholls
02-12-2007, 08:34 PM
Great! welcome to the club ;-)

I hope you enjoy it, it is loads of fun, especially the emulators :)

I just wish I had one of the new models with touch screen:(

cheers,
Paul

savage
07-12-2007, 03:29 PM
Is there such thing as a GP2X Emulator for those of us who can't buy a real one just yet, and also for basic development purposes?

pstudio
07-12-2007, 05:40 PM
AFAIK there isn't a emulator.
There probably hasn't been a real need for it since most developers would have a GP2X.

dmantione
07-12-2007, 05:58 PM
Qemu would be really close as emulator. Ok, you miss the second cpu, you miss the 2D accelerator, but for SDL applications it should behave like the real thing.

Legolas
09-12-2007, 07:28 PM
If someone is interested I could write a little step-by-step howto about sharing files'n'folders between an arm linux guest (on qemu) and a windows host via nfs server and tap adapter. I had a lot of troubles to make it working, so I'll be glad to share my 2 cents :)

pstudio
09-12-2007, 08:16 PM
I would be interested in it. It may ease debugging, which you practically can't do on the new GP2X.

paul_nicholls
10-12-2007, 09:44 PM
Any .o file generated by the GNU assembler should be processable by the nm utility belonging to that assembler (regardless wether the compiler calling that assembler is GCC, FPC).

If "nm" cannot process a .o file, either the .o file is corrupt, or it is written in a format "nm" does not understand, but in that case, as and nm do not belong together.

Anyway, the output by "nm" is critical to understand this problem, so you will need to solve this problem in one way or another.

Ok, thanks for the help, but I dont't know how to proceed now :(

cheers,
Paul

Sorry about the delay, but life has kept be busy from getting back to this issue :(

I changed my devkitGP2X back to what I had originally, and can now run the nm.exe program.

The output I got was this:


00000000 D THREADVARLIST_GP2X_SDL_MIXER

This doesn't look good...no wonder it is complaining that it couldn't find the gp2x_Mix_... routines :(

Does this help at all?

cheers,
Paul

dmantione
11-12-2007, 03:58 PM
Okay. This is the output of nm on the .o generated from the Pascal unit. Now, please do a nm on the compiled c code.

paul_nicholls
12-12-2007, 03:31 AM
Okay. This is the output of nm on the .o generated from the Pascal unit. Now, please do a nm on the compiled c code.

That output was from the nm being run on the .o file from the compiled c code...

cheers,
Paul

dmantione
12-12-2007, 06:49 AM
Can you please double check? THREADVARLIST_GP2X_SDL_MIXER is a symbol generated by FPC, GCC does not generate such a symbol. As there are no variables or non-external procedures in your Pascal unit, this is exactly the output you would expect when you use nm on the FPC generated .o file.

paul_nicholls
12-12-2007, 08:57 AM
Can you please double check? THREADVARLIST_GP2X_SDL_MIXER is a symbol generated by FPC, GCC does not generate such a symbol. As there are no variables or non-external procedures in your Pascal unit, this is exactly the output you would expect when you use nm on the FPC generated .o file.

Ok, I will double check...

Paul

paul_nicholls
13-12-2007, 02:18 AM
Hi dmantione, I don't know what happened before, but I am now getting a difference output when I run the nm on the .o file (I am now using the -a option as well):



c&#58;\lazarus\Projects\sdl libs test>arm-linux-nm.exe -a gp2xlibs\gp2x_sdl_mixer.o
00000000 b .bss
00000000 n .comment
00000000 d .data
00000000 t .text
00000048 T gp2x_Mix_CloseAudio
000000d4 T gp2x_Mix_FreeMusic
0000005c T gp2x_Mix_LoadMUS
00000000 T gp2x_Mix_OpenAudio
000000b8 T gp2x_Mix_PlayingMusic
00000084 T gp2x_Mix_PlayMusic
00000000 a gp2x_sdl_mixer.c
U Mix_CloseAudio
U Mix_FreeMusic
U Mix_LoadMUS
U Mix_OpenAudio
U Mix_PlayingMusic
U Mix_PlayMusic

does this help?
cheers,
Paul

dmantione
13-12-2007, 06:37 AM
I think I know what happened :) Reading back I read yout unit is called gp2x_sdl_mixer.pas. That means FPC is writing a file gp2x_sdl_mixer.o. In your post you write the file generated by gcc is gp2x_sdl_mixer.o.

You start to see where this is going?

Yup, we have a name clash, FPC is either overwriting the file generated by GCC or (in case they are in differend directories) finds the file it generated itself when processing the {$l gp2x_sdl_mixer.o}

paul_nicholls
13-12-2007, 10:43 AM
I think I know what happened :) Reading back I read yout unit is called gp2x_sdl_mixer.pas. That means FPC is writing a file gp2x_sdl_mixer.o. In your post you write the file generated by gcc is gp2x_sdl_mixer.o.

You start to see where this is going?

Yup, we have a name clash, FPC is either overwriting the file generated by GCC or (in case they are in differend directories) finds the file it generated itself when processing the {$l gp2x_sdl_mixer.o}

hehe, ok...I should try renaming either the gp2x_sdl_mixer.c or the gp2x_sdl_mixer.pas files and try again :-)

I will let you know how it goes!

Thanks,
Paul

paul_nicholls
13-12-2007, 09:37 PM
I think I know what happened :) Reading back I read yout unit is called gp2x_sdl_mixer.pas. That means FPC is writing a file gp2x_sdl_mixer.o. In your post you write the file generated by gcc is gp2x_sdl_mixer.o.

You start to see where this is going?

Yup, we have a name clash, FPC is either overwriting the file generated by GCC or (in case they are in differend directories) finds the file it generated itself when processing the {$l gp2x_sdl_mixer.o}

That was the problem!!

I renamed the gp2x_sdl_mixer.c to gp2x_sdl_mixer_c.c

Now I get an error about undefined references



C&#58;\devkitGP2X\lib\\libmikmod.a&#40;mdriver.o&#41;&#58; In function `MD_DropPrivileges'&#58;
../playercode/mdriver.c&#58;919&#58; warning&#58; Using 'getpwnam' in statically ]

Could I be missing a lib or have something in the wrong order in the linking section?

[code]
arm-linux-ld.exe -static --no-warn-mismatch --reduce-memory-overheads --gc-sections -s -L. -o%1.gpe link.res -lpng -lm -lstdc++ -lgcc_eh -lpthread -lvorbisidec -lSDL_mixer -lmikmod -smpeg -lpng12 -lz -lSDL -ljpeg -lfreetype -lc -lgcc


At least I am getting somewhere! :)

cheers,
Paul

savage
13-12-2007, 09:59 PM
Hi Paul, it looks like you are missing both smpeg ( libsmpeg ) for mp3 playback you choice are either remove the reference to smpeg or statically link smpeg into libSDL_mixer. The latter is what the Mac OS X guys did so that libSDL_Mixer supports everything out of the box. You may have to build smpeg from source.

paul_nicholls
13-12-2007, 10:49 PM
[quote="savage"]Hi Paul, it looks like you are missing both smpeg ( libsmpeg ) for mp3 playback you choice are either remove the reference to smpeg or statically ]

ok...

If it helps, I do have these files:

C:\devkitGP2X\bin\smpeg-config
C:\devkitGP2X\include\smpeg\smpeg.h
C:\devkitGP2X\lib\libsmpeg.a
C:\devkitGP2X\lib\libsmpeg.la
C:\devkitGP2X\share\aclocal\smpeg.m4

PS If I did want to remove the reference to smpeg, what should I do?

cheers,
Paul.

savage
13-12-2007, 11:43 PM
Could you try this command line...


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

you seemed to be missing the
-l in front of the
smpeg in the one you posted.

If you can I would leave it in, because loads of people need mp3 support.

paul_nicholls
13-12-2007, 11:51 PM
I tried that, but I still get these errors:



C&#58;\devkitGP2X\lib\\libmikmod.a&#40;mdriver.o&#41;&#58; In function `MD_DropPrivileges'&#58;
../playercode/mdriver.c&#58;919&#58; warning&#58; Using 'getpwnam' in statically linked appl
ications requires at runtime the shared libraries from the glibc version used fo
r linking
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;music_ogg.o&#41;&#58; In function `OGG_new'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;74&#58; undefined refer
ence to `ov_open'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;music_ogg.o&#41;&#58; In function `OGG_new_RW'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;126&#58; undefined refe
rence to `ov_open_callbacks'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;music_ogg.o&#41;&#58; In function `OGG_getsome'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;158&#58; undefined refe
rence to `ov_read'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;169&#58; undefined refe
rence to `ov_info'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;music_ogg.o&#41;&#58; In function `OGG_delete'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;233&#58; undefined refe
rence to `ov_clear'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;music_ogg.o&#41;&#58; In function `OGG_jump_to_time'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/music_ogg.c&#58;241&#58; undefined refe
rence to `ov_time_seek'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;load_ogg.o&#41;&#58; In function `Mix_LoadOGG_RW'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;89&#58; undefined refere
nce to `ov_open_callbacks'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;97&#58; undefined refere
nce to `ov_info'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;108&#58; undefined refer
ence to `ov_pcm_total'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;117&#58; undefined refer
ence to `ov_read'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;128&#58; undefined refer
ence to `ov_clear'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/load_ogg.c&#58;119&#58; undefined refer
ence to `ov_read'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;instrum.o&#41;&#58; In function `load_instrument'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/instrum.c&#58;524&#58; undefin
ed reference to `pow'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;mix.o&#41;&#58; In function `update_tremolo'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/mix.c&#58;188&#58; undefined r
eference to `sin'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;resample.o&#41;&#58; In function `update_vibrato'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/resample.c&#58;349&#58; undefi
ned reference to `sin'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;filter.o&#41;&#58; In function `designfir'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/filter.c&#58;88&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/filter.c&#58;92&#58; undefined
reference to `log'
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/filter.c&#58;92&#58; undefined
reference to `exp'
C&#58;\devkitGP2X\lib\\libSDL_mixer.a&#40;filter.o&#41;&#58; In function `kaiser'&#58;
/home/Administrator/newtoolchain/SDL_mixer-1.2.6/timidity/filter.c&#58;70&#58; undefined
reference to `sqrt'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;smpeg.o&#41;&#58; In function `SMPEG_new_rwops'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;100&#58; undefined reference
to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;101&#58; undefined reference
to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;smpeg.o&#41;&#58; In function `SMPEG_new_data'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;85&#58; undefined reference t
o `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;86&#58; undefined reference t
o `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;smpeg.o&#41;&#58; In function `SMPEG_new_descr'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;65&#58; undefined reference t
o `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;smpeg.o&#41;&#58;/home/Administrator/newtoolchain/smpeg-0.
4.4/smpeg.cpp&#58;66&#58; more undefined references to `operator new&#40;unsigned int&#41;' foll
ow
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;smpeg.o&#41;&#58; In function `SMPEG_delete'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/smpeg.cpp&#58;173&#58; undefined reference
to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;mpegtoraw.lo&#41;&#58; In function `MPEGaudio&#58;&#58;initialize&#40;
&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpegtoraw.cpp&#58;109&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpegtoraw.cpp&#58;111&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpegtoraw.cpp&#58;113&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpegtoraw.cpp&#58;115&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpegtoraw.cpp&#58;116&#58; undefined
reference to `cos'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEG.o&#41;&#58; In function `~MPEG'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;156&#58; undefined reference t
o `operator delete&#91;&#93;&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;157&#58; undefined reference t
o `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;156&#58; undefined reference t
o `operator delete&#91;&#93;&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;156&#58; undefined reference t
o `operator delete&#91;&#93;&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEG.o&#41;&#58; In function `MPEG&#58;&#58;parse_stream_list&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;490&#58; undefined reference t
o `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;498&#58; undefined reference t
o `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEG.o&#41;&#58; In function `MPEG&#58;&#58;Init&#40;SDL_RWops*, bool&#41;
'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;91&#58; undefined reference to
`operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEG.o&#41;&#58; In function `MPEG'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;66&#58; undefined reference to
`operator new&#91;&#93;&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEG.cpp&#58;66&#58; undefined reference to
`operator new&#91;&#93;&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGring.o&#41;&#58; In function `~MPEG_ring'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGring.cpp&#58;124&#58; undefined referen
ce to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `MPEGstream'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;35&#58; undefined refere
nce to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;35&#58; undefined refere
nce to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `MPEGstream&#58;&#58;delete_mar
ker&#40;MPEGstream_marker*&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;223&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `~MPEGstream'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;59&#58; undefined refere
nce to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;61&#58; undefined refere
nce to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;59&#58; undefined refere
nce to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;61&#58; undefined refere
nce to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58;/home/Administrator/newtoolchain/smp
eg-0.4.4/MPEGstream.cpp&#58;77&#58; more undefined references to `operator delete&#40;void*&#41;
' follow
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `MPEGstream&#58;&#58;reset_stre
am&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;81&#58; undefined refere
nce to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `MPEGstream&#58;&#58;garbage_co
llect&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;332&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGstream.o&#41;&#58; In function `MPEGstream&#58;&#58;new_marker
&#40;int&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGstream.cpp&#58;180&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGsystem.o&#41;&#58; In function `~MPEGsystem'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;485&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;490&#58; undefined refer
ence to `operator delete&#91;&#93;&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;491&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;485&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;490&#58; undefined refer
ence to `operator delete&#91;&#93;&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;485&#58; undefined refer
ence to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;490&#58; undefined refer
ence to `operator delete&#91;&#93;&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGsystem.o&#41;&#58; In function `MPEGsystem'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;403&#58; undefined refer
ence to `operator new&#91;&#93;&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;425&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;403&#58; undefined refer
ence to `operator new&#91;&#93;&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;425&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGsystem.o&#41;&#58; In function `MPEGsystem&#58;&#58;FillBuffer
&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;820&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;855&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;828&#58; undefined refer
ence to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGsystem.o&#41;&#58; In function `MPEGsystem&#58;&#58;TotalTime&#40;
&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;976&#58; undefined refer
ence to `operator new&#91;&#93;&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;1074&#58; undefined refe
rence to `operator delete&#91;&#93;&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGsystem.o&#41;&#58; In function `MPEGsystem&#58;&#58;TimeElapse
dAudio&#40;int&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;1120&#58; undefined refe
rence to `operator new&#91;&#93;&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGsystem.cpp&#58;1168&#58; undefined refe
rence to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGaudio.lo&#41;&#58; In function `MPEGaudio&#58;&#58;StartDecodi
ng&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/MPEGaudio.cpp&#58;153&#58; undefined
reference to `operator new&#40;unsigned int&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGaudio.lo&#41;&#58; In function `~MPEGaudio'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/MPEGaudio.cpp&#58;90&#58; undefined r
eference to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;mpeglayer3.lo&#41;&#58; In function `MPEGaudio&#58;&#58;layer3init
ialize&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;124&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;124&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;126&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;126&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;130&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;131&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;132&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;132&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;134&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;134&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;137&#58; undefined
reference to `sin'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;137&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;141&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;143&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;145&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;148&#58; undefined
reference to `pow'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;156&#58; undefined
reference to `pow'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;160&#58; undefined
reference to `pow'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;163&#58; undefined
reference to `pow'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;196&#58; undefined
reference to `pow'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;mpeglayer3.lo&#41;&#58;/home/Administrator/newtoolchain/sm
peg-0.4.4/audio/mpeglayer3.cpp&#58;197&#58; more undefined references to `pow' follow
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;mpeglayer3.lo&#41;&#58; In function `MPEGaudio&#58;&#58;layer3init
ialize&#40;&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;207&#58; undefined
reference to `sqrtf'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;mpeglayer3.lo&#41;&#58; In function `__static_initializati
on_and_destruction_0'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;79&#58; undefined
reference to `cos'
/home/Administrator/newtoolchain/smpeg-0.4.4/audio/mpeglayer3.cpp&#58;80&#58; undefined
reference to `cos'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGvideo.lo&#41;&#58; In function `~MPEGvideo'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/video/MPEGvideo.cpp&#58;227&#58; undefined
reference to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGlist.o&#41;&#58; In function `~MPEGlist'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGlist.cpp&#58;19&#58; undefined referenc
e to `operator delete&#40;void*&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGlist.cpp&#58;19&#58; undefined referenc
e to `operator delete&#40;void*&#41;'
C&#58;\devkitGP2X\lib\\libsmpeg.a&#40;MPEGlist.o&#41;&#58; In function `MPEGlist&#58;&#58;Alloc&#40;unsigned
int&#41;'&#58;
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGlist.cpp&#58;31&#58; undefined referenc
e to `operator new&#40;unsigned int&#41;'
/home/Administrator/newtoolchain/smpeg-0.4.4/MPEGlist.cpp&#58;35&#58; undefined referenc
e to `operator new&#91;&#93;&#40;unsigned int&#41;'

cheers,
Paul

dmantione
14-12-2007, 07:59 AM
Apparently you have to link in some libraries. Seems at least libstdc++ and some kind of library related to Ogg Vorbis.

savage
14-12-2007, 09:19 AM
Can you link directly to the *.a file without the need for the .cpp?

dmantione
14-12-2007, 10:43 AM
Yes, you can.

If the amount of dependencies is high I would consider to dlopen the library rather than linking to it; since a high number of direct dependencies makes you vulnerable to incompatibilities versions between those libraries.

paul_nicholls
15-12-2007, 05:19 AM
[quote="dmantione"]Apparently you have to ]

If it helps, I have a makefile for a C code demo that compiles using the devkitGP2X which uses most of the SDL libs including SDL_mixer...



CROSS_COMPILE = C&#58;/devkitGP2X/bin/arm-linux-
SDL_BASE = C&#58;/devkitGP2X/bin/arm-linux-
LDFLAGS = -static

CXX = $&#40;CROSS_COMPILE&#41;g++
STRIP = $&#40;CROSS_COMPILE&#41;strip

CXXFLAGS = -I"C&#58;/devkitGP2X/include" -I"C&#58;/devkitGP2X/include/SDL" -DTARGET_GP2X -O2 -Wall
LIBS = -L"C&#58;/devkitGP2X/lib" -lSDL -lSDL_gfx --start-group -lSDL_ttf -lfreetype -lSDL --end-group -lSDL_image -ljpeg -lpng12 -lz --start-group -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL --end-group -lgcc -lm -lc -lexpat -lpthread -ldl

TARGET = sdltest.gpe
OBJS = sdltest.o

ALL_TARGETS = $&#40;TARGET&#41;

all&#58; $&#40;ALL_TARGETS&#41;

$&#40;TARGET&#41;&#58; $&#40;OBJS&#41;
$&#40;CXX&#41; $&#40;LDFLAGS&#41; -o $&#40;TARGET&#41; $&#40;OBJS&#41; $&#40;LIBS&#41;
$&#40;STRIP&#41; $&#40;TARGET&#41;

clean&#58;
rm *.o
rm $&#40;TARGET&#41;


So I assume I already have all the libs I need...I must not be linking correctly or something

cheers,
Paul

dmantione
15-12-2007, 06:35 AM
Yes, you might have them, but did you $linklib them?

paul_nicholls
16-12-2007, 10:28 AM
[quote="dmantione"]Yes, you might have them, but did you $]

I assume I would use $linklib in the .pas file?

I already do this for my own c library:


&#123;$link gp2x_sdl_mixer_c.o&#125;
&#123;$linklib c&#125;

How would I use $linklib for other libraries to this as well?

cheers,
Paul

savage
16-12-2007, 10:40 AM
Maybe something like


&#123;$linklib smpeg&#125;

inside the smpeg.pas unit, and similar directives in the other units.

paul_nicholls
30-12-2007, 11:10 AM
Maybe something like

[code]&#123;$]

inside the smpeg.pas unit, and similar directives in the other units.

I have tried adding that and similar into the gp2x_sdl_mixer.pas but to no avail :(

I am trying to get around using the smpeg.pas and sdl_mixer.pas units as a test and use the c library (gp2x_sdl_mixer_c.o) instead via the gp2x_sdl_mixer.pas file.

cheers,
Pau;

Legolas
30-12-2007, 11:47 AM
For nds I use static linking in this way:

{$linklib libsmpeg.a}

Of course I added the path of these libs on my fpc.cfg


-FlE&#58;\devkitpro\libnds\lib
-FlE&#58;\devkitpro\devkitARM\lib\gcc\arm-eabi\4.1.2
-FlE&#58;\devkitpro\devkitARM\lib\gcc\arm-eabi\4.1.2\thumb
-FlE&#58;\devkitpro\devkitARM\arm-eabi\lib
-FlE&#58;\devkitpro\devkitARM\arm-eabi\lib\thumb

Some times I need to link some other libs, like

{$linklib libc.a}
{$linklib libgcc.a}
{$linklib libsysbase.a}

and never had problems.
I hope it could do the trick on gp2x too :)

paul_nicholls
31-12-2007, 10:26 AM
Thanks for the info Legolas, I will try this :-)
cheers,
Paul

HenrikE
29-03-2008, 01:34 PM
Regarding the thread topic, the FPC4GP2x page seems to not have been updated for a while. Does that mean the links to downloads are still viable to get stuff working?

Reason I'm asking is cos I'm having trouble coding inline asm and accessing vars/simply adding labels. ppcrossarm complains.

I would like to code and debug asm (and perhaps pascal) on pc for GP2x - at least find syntax errors. Possible? I'm still looking for a doc that tells me the exact syntax of the assembler code I can use. Also, I'd like to just use pascal, no delphi and sdl.

Thankful for any help!

paul_nicholls
30-03-2008, 10:02 PM
Hi Henrik,
All the downloads are still valid on the fpc4gp2x page, it is just I haven't had any updates to put on the page for a while now (as you noticed).

I haven't done much in the way of ARM assembly myself yet, but if you want to learn ARM assembly programming, this site may help

http://www.heyrick.co.uk/assembler/

If you scroll down a bit you will see a An introduction to assembler link that you can follow, and right below that link is the ARM instruction set information.

Even though it is for the ARM processor in the BBC computer, quit a bit should still be relevant to GP2X programming :-)

On this topic of ARM assembly, I did manage to get a small assembler library file off the internet to compile to an .o file using the devkitGP2X arm-linux-gcc.exe program.


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

libgp2x_asm.s file


@ 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 CopyScreen
.globl ClearScreen
.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

CopyScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
.CopyScreenLoop&#58;
ldmia r1!, &#123;r3-r10&#125; @ pull in 32 bytes from the source
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .CopyScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return

ClearScreen&#58;
stmfd sp!, &#123;r4-r10&#125; @ remember registers 4-10
mov r2, #4800 @ we will run the loop 4800 times to copy the screen
mov r3, #0 @ load up the registers with zeros
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
.ClearScreenLoop&#58;
stmia r0!, &#123;r3-r10&#125; @ write the 32 bytes of zeros to the destination
subs r2, r2, #1 @ decrement the loop counter
bne .ClearScreenLoop @ if we're not done, do it again
ldmfd sp!, &#123;r4-r10&#125; @ restore the registers
mov pc, lr @ return


I was then able to link it into my FPC gp2x code, and with a header file I whipped up, use the routines in it. Some of the stuff below is duplicated in various FPC files already, but at the time I didn't know that <G> It is still usefull though :-)


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

Interface

Uses
CTypes;

Const
MREMAP_MAYMOVE = 1;
MREMAP_FIXED = 2;

PROT_READ = $1; // page can be read
PROT_WRITE = $2; // page can be written
PROT_EXEC = $4; // page can be executed
PROT_NONE = $0; // page can not be accessed

MAP_SHARED = $01; // Share changes
MAP_PRIVATE = $02; // Changes are private

&#123;$IFDEF gp2x&#125;
MAP_FIXED = $10; // Interpret addr exactly
MAP_ANONYMOUS = $20; // don't use a file
MAP_GROWSDOWN = $0100; // stack-like segment
MAP_DENYWRITE = $0800; // ETXTBSY
MAP_EXECUTABLE = $1000; // mark it as an executable
MAP_LOCKED = $2000; // pages are locked
MAP_NORESERVE = $4000; // don't check for reservations
MS_ASYNC = 1; // sync memory asynchronously
MS_INVALIDATE = 2; // invalidate the caches
MS_SYNC = 4; // synchronous memory sync
MCL_CURRENT = 1; // lock all current mappings
MCL_FUTURE = 2; // lock all future mappings
MADV_NORMAL = $0; // default page-in behavior
MADV_RANDOM = $1; // page-in minimum required
MADV_SEQUENTIAL = $2; // read-ahead aggressively
MADV_WILLNEED = $3; // pre-fault pages
MADV_DONTNEED = $4; // discard these pages
O_RDWR = 2;
&#123;$ENDIF&#125;

// compatibility flags
MAP_ANON = MAP_ANONYMOUS;
MAP_FILE = 0;

MAP_FAILED = Pointer&#40;-1&#41;;

Type
Tgp2xDevice = Class
Protected
FDev &#58; ctypes.cint32;
FMemData &#58; Pointer;
FMemSize &#58; ctypes.cint32;
Public
Constructor Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
Destructor Destroy; Override;
Procedure MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
Procedure UnmapMem;
Property MemData&#58; Pointer Read FMemData;
End;

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;
Function Ioctl3&#40;fd&#58; ctypes.cint32; ulFunction,ulParameter&#58; ctypes.cushort&#41;&#58; ctypes.cint32; Cdecl; External;
Procedure CopyScreen&#40;pDest,pSrc&#58; ctypes.pcushort&#41;; Cdecl; External;
//Procedure ClearScreen&#40;pus&#58; ctypes.pcushort; color&#58; ctypes.cuint16&#41;; Cdecl; External;
Procedure ClearScreen&#40;pus&#58; ctypes.pcushort&#41;; Cdecl; 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 int Ioctl3&#40;int fd, unsigned int ulFunction, unsigned int ulParameter&#41;;
extern void CopyScreen&#40;unsigned short *pDest, unsigned short *pSrc&#41;;
extern void ClearScreen&#40;unsigned short *pus&#41;;
extern void RestartMenu&#40;&#41;;
&#125;
Implementation

Constructor Tgp2xDevice.Create&#40;pszFile&#58; PChar; nMode&#58; ctypes.cint32&#41;;
Begin
Inherited Create;

FDev &#58;= 0;
FMemData &#58;= Nil;
FMemSize &#58;= 0;
FDev &#58;= OpenFile&#40;pszFile,nMode&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Destructor Tgp2xDevice.Destroy;
Begin
UnmapMem;
If FDev <> 0 Then
CloseFile&#40;FDev&#41;;

Inherited Destroy;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure Tgp2xDevice.UnmapMem;
Begin
If FMemData <> Nil Then
Begin
MUnmap&#40;FMemData,FMemSize&#41;;
FMemData &#58;= Nil;
FMemSize &#58;= 0;
End;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure Tgp2xDevice.MapMem&#40;pAddr&#58; Pointer; nLen,nProtection,nFlags,nOff&#58; ctypes.cint32&#41;;
Begin
UnmapMem;

FMemSize &#58;= nLen;
FMemData &#58;= MMap&#40;pAddr, FMemSize, nProtection, nFlags, FDev, nOff&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
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.


Using the above code I was able to write directly to the GP2X framebuffer pixels like so:



Function RGBTo16Bit&#40;r,g,b&#58; Uint8&#41;&#58; Uint16;
Begin
Result &#58;= &#40;&#40;&#40;r Shl cRscale&#41; Shr 8&#41; Shl cRshift&#41; +
&#40;&#40;&#40;g Shl cGscale&#41; Shr 8&#41; Shl cGshift&#41; +
&#40;&#40;&#40;b Shl cBscale&#41; Shr 8&#41; Shl cBshift&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TRendererModule_gp2x.ClearScreen&#40;r,g,b&#58; Byte&#41;;
Var
c &#58; Uint32;
i &#58; LongInt;
addr &#58; PUint8;
Begin
c &#58;= RGBTo16Bit&#40;r,g,b&#41;;
addr &#58;= Ffb1.MemData;
i &#58;= FWidth * FHeight;
While i <= 0 Do
Begin
PUint16&#40;addr&#41;^ &#58;= Uint16&#40;c&#41;;
Inc&#40;addr,2&#41;;
Dec&#40;i&#41;;
End;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TRendererModule_gp2x.FlipScreen;
Begin
CopyScreen&#40;Ffb0.MemData,Ffb1.MemData&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
// open the frame buffers
Ffb0 &#58;= Tgp2xDevice.Create&#40;'/dev/fb0', O_RDWR&#41;;
Ffb1 &#58;= Tgp2xDevice.Create&#40;'/dev/fb1', O_RDWR&#41;;

// map the memory so you can read/write to the frame buffers
FWidth &#58;= 320;
FHeight &#58;= 240;
FBitsPerPixel &#58;= 16;
Ffb0.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;
Ffb1.MapMem&#40;Nil, FWidth * FHeight * &#40;FBitsPerPixel Div 8&#41;, PROT_WRITE, MAP_SHARED, 0&#41;;


Var
dstAddr &#58; Puint8;
c &#58; Uint16;

// how to write to the frame buffer
c &#58;= RGBTo16Bit&#40;r,g,b&#41;
dstAddr &#58;= Ffb1.MemData;
Inc&#40;dstAddr,x + y * FWidth * 2&#41;;
PUint16&#40;dstAddr&#41;^ &#58;= c;



It might not be inline assembler, but I hope this helps :-)
cheers,
Paul

HenrikE
30-03-2008, 10:23 PM
That's very helpful! I'm awed :)

I should learn to trust my detective skills... Making inline asm was simplest with Delphi 7.2 / Free Pascal 2.3.1, the hard part was fiddling with the toolchain to make my own .bat for a minimum .gpe.

All done now, minimum size with just the RTL is 28K. I'm looking at sdk2x now, hoping to use their code to make my .gpe with only my asm + minimum "padding". :)

I know ARM from Archimedes, so the main goal is to absorb what happened since, including any MMU/multicore shananigans ;)

Still looking for the last version 6b of the framework in the Demo Dev thread http://www.gp32x.com/board/index.php?showtopic=27433&st=105

The links in the thread were dead, probably on the Wiki somewhere, will look.

Thanks a lot for the lengthy reply, some juicy MMAP stuff. I did hw reg. access with mmap today and translated gp2x_joystick_read from rlyeh's minimal lib 0.B. Still not in asm tho, since I don't know the physical address or how to take over the machine temporarily in a friendly way.

paul_nicholls
30-03-2008, 10:52 PM
Hi Henrik,
I'm glad my post helped you :-)

BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! :oops:

It is now included in the post...

And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the link to :)

cheers,
Paul

savage
30-03-2008, 11:20 PM
Legolas, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there links out there already show this?

I noticed that none of the examples in the zip file had a SDL example, hence the reason for this post.

HenrikE
30-03-2008, 11:37 PM
[quote="paul_nicholls"]Hi Henrik,
I'm glad my post helped you :-)

BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! :oops:

It is now included in the post...

And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the ]

Lovely! All this helps jump-start me.

Haven't been doing much asm this evening, still search for the last version zip from that demo dev thread on gp32x forums... do you have it, since you have other sources by Dzz? (/me heads over to archive.org)

paul_nicholls
31-03-2008, 12:03 AM
[quote="savage"]Paul, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there ]

Hi Dom,
I have never done any programming for the DS or GBA, so I can't help you there, sorry :(

I did see some posts about using SDL on the DS floating around on these forums, but I can't recall where without searching...

EDIT: Perhaps this can help you http://www.pascalgamedevelopment.com/viewtopic.php?t=3949&highlight=sdl

cheers,
Paul.

paul_nicholls
31-03-2008, 12:05 AM
[quote="paul_nicholls"]Hi Henrik,
I'm glad my post helped you :-)

BTW, I just edited my previous post as I just realized I hadn't included the libgp2x_asm.s file!! :oops:

It is now included in the post...

And if you look at the very top of the libgp2x_asm.s file you may notice that it was written by Dzz from the gp32x.com posts you gave the ]

Lovely! All this helps jump-start me.

Haven't been doing much asm this evening, still search for the last version zip from that demo dev thread on gp32x forums... do you have it, since you have other sources by Dzz? (/me heads over to archive.org)

Hi Henrik,
I couldn't get hold of the latest version of Dzz's demo (version 6) either, even through http://www.archive.org

I do have versions 2, 2a, 3, 4, 5 available though...I could email them to you?

I just uploaded a zip file containing all the demo zip files that I had previously downloaded: http://fpc4gp2x.eonclash.com/downloads/Dzz_Demos_(2-5).zip

cheers,
Paul

HenrikE
31-03-2008, 12:12 AM
I have those, but thanks! It's elusive since gp2xgamer.com seems to have been replaced by the standard 'find what you want' portal package :oops:

savage
31-03-2008, 07:00 AM
[quote="savage"]Paul, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there ]

Hi Dom,
I have never done any programming for the DS or GBA, so I can't help you there, sorry :(

I did see some posts about using SDL on the DS floating around on these forums, but I can't recall where without searching...

EDIT: Perhaps this can help you http://www.pascalgamedevelopment.com/viewtopic.php?t=3949&highlight=sdl

cheers,
Paul.


Oops the post was supposed to be directed at Legolas, but I'll check out that other thread, thanks.

Legolas
01-04-2008, 02:20 PM
[quote="savage"]Legolas, any chance you can throw together some instructions on getting FPC and SDL running on DS or GBA. Or are there ]

Finally got my laptop repaired. Give me some time to reorganize it and I'll try :)

HenrikE
05-04-2008, 04:54 PM
ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

Any ideas? This is getting annoying. Argh! :(

paul_nicholls
05-04-2008, 11:54 PM
ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

Any ideas? This is getting annoying. Argh! :(

I have to admit I haven't used ExecuteFile myself - I use the code below:


chdir &#40;'/usr/gp2x'&#41;;
ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;

hope this helps,
cheers,
Paul

KidPaddle
06-04-2008, 06:51 AM
Paul,

have you any working sample with playing music/sound und timer? And if, coud you send me this sample?

Best Regards
Thomas

HenrikE
06-04-2008, 11:43 AM
ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

Any ideas? This is getting annoying. Argh! :(

I have to admit I haven't used ExecuteFile myself - I use the code below:


chdir &#40;'/usr/gp2x'&#41;;
ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;

hope this helps,
cheers,
Paul

Well, I'll use anything that results in an Execve kernel call! :) (swi 0x90000b). So if yours uses RTL or libs, it's out I'm afraid. Also, my c notation skills are not (yet? ever?) at the point where I can create an array of pointers. All those * and ) and &... :)

Anyway, made USBnet work, so now USB stays connected and I can compile and test an updated .gpe with 5 button presses. So the problem is not urgent anymore; I have the fastest possible dev setup now.

Thanks for helping me Paul!

paul_nicholls
06-04-2008, 11:33 PM
Paul,

have you any working sample with playing music/sound und timer? And if, coud you send me this sample?

Best Regards
Thomas

Hi Thomas,
The only sound stuff I could get working on the GP2X (and Win32) was using .wav files only and the code below (hacked together from C examples off the web). I still can't get SDL_Mixer working under the GP2X :(

The following code is not complete, but at least it plays .wav sounds...
The StopSound and all music methods don''t do anything yet (I was going to see if I could stream a large .wav file in chunks as music).

You use it like so:

First, you 'register' any sounds you want to load and play later:


FAudioModule.RegisterSound_WAV&#40;'miss_sound' ,FDataPath + 'miss.wav'&#41;;

then later on when you want to play the sound:

FAudioModule.PlaySound_WAV&#40;'miss_sound'&#41;;



Unit EngineAudio_sdl;
&#123;$IFDEF fpc&#125;
&#123;$mode delphi&#125;&#123;$H+&#125;
&#123;$ENDIF&#125;
Interface

Uses
SDL,
Classes;

Type
&#123;................................................. .............................&#125;
TAudioModule_sdl = Class
Private
FSoundNames &#58; TStringList;
FAudioInitialized &#58; Boolean;
Public
Constructor Create;
Destructor Destroy; Override;
Function InitAudio&#58; Boolean;
Procedure RegisterSound_WAV&#40;AName,AFileName&#58; AnsiString&#41;;
Function PlaySound_WAV &#40;AName &#58; AnsiString&#41;&#58; Boolean;
Procedure StopSound_WAV &#40;AChannel&#58; Integer&#41;;
Procedure RegisterMusic_WAV&#40;AName,AFileName&#58; AnsiString&#41;;
Function PlayMusic_WAV &#40;AName &#58; AnsiString&#41;&#58; Boolean;
Procedure StopMusic_WAV;
Procedure CloseAudio;
End;
&#123;................................................. .............................&#125;

Implementation

Uses
SDL_Mixer;

Const
&#123;................................................. .............................&#125;
cMaxSounds = 40;
&#123;................................................. .............................&#125;

Type
&#123;................................................. .............................&#125;
TSound = Class
Public
channel &#58; Integer;
data &#58; PUint8;
dpos &#58; Uint32;
dlen &#58; Uint32;
Constructor Create;
Destructor Destroy; Override;
Procedure Update&#40;stream&#58; PUint8; len&#58; Integer&#41;; Virtual;
Function Playing &#58; Boolean;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
TMusic = Class&#40;TSound&#41;
Public
Procedure Update&#40;stream&#58; PUint8; len&#58; Integer&#41;; Override;
End;
&#123;................................................. .............................&#125;

Var
Sounds &#58; Array&#91;0..cMaxSounds - 1&#93; Of TSound;
Music &#58; TMusic;

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

&#123;................................................. .............................&#125;
Constructor TSound.Create;
Begin
Inherited Create;
data &#58;= Nil;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Destructor TSound.Destroy;
Begin
If data <Nil> len Then
amount &#58;= len;
SDL_MixAudio&#40;stream, @PByteArray&#40;data&#41;^&#91;dpos&#93;, amount, SDL_MIX_MAXVOLUME&#41;;
Inc&#40;dpos,amount&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function TSound.Playing &#58; Boolean;
Begin
Result &#58;= dpos < dlen;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TMusic.Update&#40;stream&#58; PUint8; len&#58; Integer&#41;;
Begin
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure MixAudioProc&#40;unused&#58; Pointer; stream&#58; PUint8; len&#58; Integer&#41;; cdecl;
Var
i &#58; Integer;
Begin
For i &#58;= 0 To cMaxSounds - 1 Do
Begin
If Sounds&#91;i&#93; <> Nil Then
Begin
Sounds&#91;i&#93;.Update&#40;stream,len&#41;;
If Not Sounds&#91;i&#93;.Playing Then
Begin
Sounds&#91;i&#93;.Free;
Sounds&#91;i&#93; &#58;= Nil;
End;
End;
End;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Constructor TAudioModule_sdl.Create;
Begin
Inherited Create;
FSoundNames &#58;= TStringList.Create;
FAudioInitialized &#58;= False;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Destructor TAudioModule_sdl.Destroy;
Begin
FSoundNames.Free;
Inherited Destroy;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function TAudioModule_sdl.InitAudio&#58; Boolean;
Var
fmt &#58; TSDL_AudioSpec;
Begin
Result &#58;= False;
// Set 16-bit stereo audio at 22Khz
fmt.freq &#58;= 22050;
fmt.format &#58;= AUDIO_S16;
fmt.channels &#58;= 2;
fmt.samples &#58;= 512; // A good value for games
fmt.callback &#58;= MixAudioProc;
fmt.userdata &#58;= Nil;

// Open the audio device
If SDL_OpenAudio&#40;@fmt, Nil&#41; < 0 Then
Begin
//fprintf&#40;stderr, "Unable to open audio&#58; %s\n", SDL_GetError&#40;&#41;&#41;;
Exit;
End;
SDL_PauseAudio&#40;0&#41;;
Result &#58;= True;
FAudioInitialized &#58;= True;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TAudioModule_sdl.CloseAudio;
Begin
If FAudioInitialized Then
SDL_CloseAudio;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TAudioModule_sdl.RegisterSound_WAV&#40;AName,AFileName &#58; AnsiString&#41;;
Begin
FSoundNames.Add&#40;AName + '=' + AFileName&#41;;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function TAudioModule_sdl.PlaySound_WAV&#40;AName&#58; AnsiString&#41; &#58; Boolean;
Var
index &#58; Integer;
wave &#58; TSDL_AudioSpec;
data &#58; PUint8;
dlen &#58; Uint32;
cvt &#58; TSDL_AudioCVT;
FileName &#58; AnsiString;
Begin
Result &#58;= False;
If Not FAudioInitialized Then Exit;
// Look for an empty &#40;or finished&#41; sound slot
index &#58;= 0;
While index < cMaxSounds Do
Begin
If sounds&#91;index&#93; = Nil Then Break;
Inc&#40;index&#41;;
End;
If index = cMaxSounds Then Exit;
FileName &#58;= FSoundNames.Values&#91;AName&#93;;
// Load the sound file and convert it to 16-bit stereo at 22kHz
If SDL_LoadWAV&#40;PChar&#40;FileName&#41;, @wave, @data, @dlen&#41; = Nil Then
Begin
// fprintf&#40;stderr, "Couldn't load %s&#58; %s\n", file, SDL_GetError&#40;&#41;&#41;;
// return;
Exit;
End;
SDL_BuildAudioCVT&#40;@cvt,
wave.format,
wave.channels,
wave.freq,
AUDIO_S16,
2,
22050&#41;;
GetMem&#40;cvt.buf,dlen * cvt.len_mult&#41;;
Move&#40;data^,cvt.buf^,dlen&#41;;
cvt.len &#58;= dlen;
SDL_ConvertAudio&#40;@cvt&#41;;
SDL_FreeWAV&#40;data&#41;;

// Put the sound data in the slot &#40;it starts playing immediately&#41;
SDL_LockAudio;
sounds&#91;index&#93; &#58;= TSound.Create;
sounds&#91;index&#93;.channel &#58;= index;
sounds&#91;index&#93;.data &#58;= cvt.buf;
sounds&#91;index&#93;.dlen &#58;= cvt.len_cvt;
sounds&#91;index&#93;.dpos &#58;= 0;
SDL_UnlockAudio;
Result &#58;= True;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TAudioModule_sdl.StopSound_WAV&#40;AChannel &#58; Integer&#41;;
Begin
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TAudioModule_sdl.RegisterMusic_WAV&#40;AName,AFileName &#58; AnsiString&#41;;
Begin
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Function TAudioModule_sdl.PlayMusic_WAV&#40;AName &#58; AnsiString&#41;&#58; Boolean;
Begin
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure TAudioModule_sdl.StopMusic_WAV;
Begin
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Procedure InitSounds;
Var
i &#58; Integer;
Begin
For i &#58;= 0 To cMaxSounds - 1 Do
Sounds&#91;i&#93; &#58;= Nil;
End;
&#123;................................................. .............................&#125;

&#123;................................................. .............................&#125;
Initialization
InitSounds;
&#123;................................................. .............................&#125;

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


I hope this helps,
cheers,
Paul

paul_nicholls
09-04-2008, 12:08 PM
ExecuteFile("gp2xmenu",0,0) (as per above) kills USB, and the only chance to connect it again is to restart the gp2x (or maybe remove/insert the cable). dzz said he'd fixed that in version 6 (demo6b.zip).

I read up on execve() and the second parameter must be an array of strings containing environment variables (for USB to work), but I have no idea what strings to give it.

Any ideas? This is getting annoying. Argh! :(

I have to admit I haven't used ExecuteFile myself - I use the code below:


chdir &#40;'/usr/gp2x'&#41;;
ExecuteProcess&#40;'/usr/gp2x/gp2xmenu',&#91;'/usr/gp2x/gp2xmenu'&#93;&#41;;

hope this helps,
cheers,
Paul

Well, I'll use anything that results in an Execve kernel call! :) (swi 0x90000b). So if yours uses RTL or libs, it's out I'm afraid. Also, my c notation skills are not (yet? ever?) at the point where I can create an array of pointers. All those * and ) and &... :)

Anyway, made USBnet work, so now USB stays connected and I can compile and test an updated .gpe with 5 button presses. So the problem is not urgent anymore; I have the fastest possible dev setup now.

Thanks for helping me Paul!

Glad I could help in any way :-)
Sounds like you are doing nicely so far...would it be possible to see what you have done upto this point?

cheers,
Paul

HenrikE
09-04-2008, 05:23 PM
I optimized senquack's/A_SN's 32bpp to 16bpp asm code yesterday, but it uses R0-R14, so I need to save sp (R13). However, apparently I must first make the asm section writable, since I can't even call an asm routine that stores any register in a declared word in the asm source!

Storing it in any of the areas mmapped in the c startup code doesn't help me, since if I pass the pointer to where to store to the blitter routine, it gets clobbered, and ofc I can't store it temporarily as per above. Being devious and trying to store it "after the pixels" in the physical framebuffer range doesn't help either, since it's the mmapped range that has write permissions I guess...

I'm looking at some clues, will probably have something nice this evening.

KidPaddle
10-04-2008, 05:14 AM
@paul_nicholls

Thanks for source, i will try it at weekend. At the moment, i have problems to connect to my gp2x over USB.

Cheers,
Thomas

paul_nicholls
10-04-2008, 08:14 AM
@paul_nicholls

Thanks for source, i will try it at weekend. At the moment, i have problems to connect to my gp2x over USB.

Cheers,
Thomas

The only connection problems I have had with my GP2X is I could never get the &%*$^#^$!!! samba working.

This means I can't connect via the GP2X samba server (only FTP or telnet), or setup a windows share folder that I am supposed to be able to run gp2x programs from via the gp2x and save on copying my programs to my SD card before I can test them :(

Anyone here been able to do that at all?
If so, perhaps you could help me there :)

cheers,
Paul

HenrikE
10-04-2008, 12:37 PM
As for samba, no. I did a hands-on tutorial on setting up USBnet on XP 64-bit (found out that one existed, but ofc I google for USBnet, never occured to me to search for TCP/IP, since everyone I talked to referred to it as USBnet). It also addresses configuring IPs and Firewall/Antivirus and ... well it doesn't require that you know how to create a driver and set up a new network before. Anyone who has done that could probably go with the wiki article.

http://www.gp32x.com/board/index.php?showtopic=41415

To dev on gp2x, I just run my compile.bat script which copies it to the sd card, and start the .gpe I made. If it hangs, you have to turn off the gp2x, then on, and wait for XP to recognize it again with a beep, but it definitely is a quick hookup, couldn't ask for more.

USBnet isn't perfect, on occasion it uses an old copy (but only if the previous program didn't return to the menu so GP2x could hold hands with USBnet again - upload, unplug the usb and plug it in again, and the new version is the latest one. Seems GP2x reads cached network files before looking at the sd card.

But I'm happy, I can recompile and test in a few seconds, and programs don't hang that often, so it's no real hassle.

@Paul: Here's v1 of the optimized blit:

http://www.scoopex1988.org/article-gp2x-arm-linux-faster-32-bpp-to-16-bpp-blit.html

Will do v2 in the evening.