PDA

View Full Version : Low level library for FreePascal and GP2X



KidPaddle
01-02-2009, 09:03 PM
Last days i wrote an low level library for FreePascal and GP2X. I got the blitter, joystick and double buffering working. Only one function, SDL_GetTicks(), is used from SDL, all other is done with own functions.

A simple demo is available from: http://www.seban.de/download/fpc4gp2x.zip

Usage:

X - Exit

Volume- = disable "wait for sync"
Volume+ = enable "wait for sync"

Joystick Left - ClearScreen without blitter support
Joystick Right - ClearScreen with blitter support
Joystick Up - Show single image with transparent color (fuchsia)
Joystick Up - Show 400 Image per frame (25.500 Frames) with transparent color (fuchsia)

This is only for testing, don't expect too much. Next days i will implement a simple font library, so i can make complexer samples.

Regards,
Thomas

03.02.2009 Added Screenshot (done with demo program)

Main menu
http://www.seban.de/download/fpc4gp2x_main.jpg

1000 sprites
http://www.seban.de/download/fpc4gp2x_blit.jpg

Button testing
http://www.seban.de/download/fpc4gp2x_button.jpg

KidPaddle
02-02-2009, 03:23 PM
I have changed the sample. Now a menu is displayed.

So, how fast is it?

1000 sprites with transparent color and V-Sync enabled needs 33ms per frame. The size of this sprite is 33x34x2 bytes, this means in 33ms around 2.2 MB are painted. Per second we have around 66MB/S, not so bad i think.

Thomas

czar
02-02-2009, 05:21 PM
I might just have to dust off my gp2x and have a go

paul_nicholls
02-02-2009, 08:45 PM
Great work Thomas, the only problem is that it didn't work on my GP2X-F100 (B) (2.0 firmware)...

the menu appears, but apart from that, only the toggling on and off of v-sync works...the joystick doesn't do any onscreen changes for me :(

KidPaddle
03-02-2009, 08:03 PM
Thanks for respone, i have a GP2X F100 first edition with same firmware like you.

I have upload a new version, which have a test menu for joystick and all other buttons. Please test it and report me the your values.

My Values are:
Buttons: 0000
Volume: C004
Joystick: FE00

Cheers,
Thomas

KidPaddle
03-02-2009, 08:49 PM
I add support for making screenshots in main menue, button menue and mass blitting. It is a 24 bit window bitmap, this format was simple to write.

Press both shoulder buttons, the battery led switched on and when file is written, it needs about 20 seconds, the battery is switched off.

Cheers,
Thomas

paul_nicholls
03-02-2009, 09:08 PM
Hi Thomas,
I tried the new version and the only things that work for me are the screenshot (makes a .bmp file containing a corrupted image), and the vsync on/off :(

The menu still looks the same as before.

I hope you don't mind, but I looked at your source code and I'm not sure where the new values are supposed to appear in the code.

I won't use the code without your permission, but I was just trying to see what you meant with regards to the joystick values, etc.

PS. you have put a lot of work into the uGP2X.pas file, well done :)

cheers,
Paul

KidPaddle
03-02-2009, 09:31 PM
Where you got the uGP2X.pas? I looked at last zip file and there are only 2 files, fpc4gp2x (unpacked 275KB) and fpc4fp2x.gpe. This file is not ready for use, so be careful.

You see the menu,
did you see the new option Y) ?
with X you can exit the program?

Bitmap is corrupt, maybe you have downloaded the older file from 9pm clock, in this the RGB 565 to 888 conversions was wrong.


Thomas

paul_nicholls
03-02-2009, 10:42 PM
erm...I got the uGP2X.pas from your website (fpc4gp2x_src.zip)...perhaps I shouldn't have but I looked at your downloads folder as I was curious.

Sorry about that :(

ahh..I didn't see the new Y option, after selecting that I can see the joystick movement values and 'keys' working now :)

So where do I find the newest version?

In the fpc4gp2x.zip file, the date/time of the 'executable' is

3-feb-2009, 10:41pm

EDIT: oh yeah, my button values are:



Buttons: 0004
Volumes: D00C
Joystick: FF00

and the screenshot seems to work with both menus now :)

cheers,
Paul

KidPaddle
04-02-2009, 05:21 AM
Hi Paul,

no problem, the mistake is mine. The server is not well configured, i must disable directory listing.

I have upload a new version, which correct the joystick bug. It is strange, that i have small different values, but ok, i change the bit mask.

The new version has a displayed version, 20090304.1, in right lower corner.

Thanks for your help,
Thomas

Ñuño Martínez
04-02-2009, 05:06 PM
I've posted a message about your library at GP32Spain forum (http://gp32spain.com/foros/showthread.php?p=844164#post844164).

I don't have a GP2X but seems nice. :thumbup:

KidPaddle
07-02-2009, 12:32 PM
I made a new sample http://www.seban.de/download/memtest.zip

- Loading and scrolling a image with 700x800 Pixel
- Playing an ogg music file

Image and music is loaded using sdl, music played with SDL_Mixer, but image is copied into non used memory area by linux and blitted manually. I have no solution found, getting a physical memory address from given pointer SDL_Surface.Pixels, which is needed by the blitter.

Button are:
- A and B - enable/disable v-sync
- x for exit

Next is writting a simple framework for windows and gp2x development.

Thomas

paul_nicholls
08-02-2009, 05:29 AM
I made a new sample http://www.seban.de/download/memtest.zip

- Loading and scrolling a image with 700x800 Pixel
- Playing an ogg music file

Image and music is loaded using sdl, music played with SDL_Mixer, but image is copied into non used memory area by linux and blitted manually. I have no solution found, getting a physical memory address from given pointer SDL_Surface.Pixels, which is needed by the blitter.

Button are:
- A and B - enable/disable v-sync
- x for exit

Next is writting a simple framework for windows and gp2x development.

Thomas

Hi Thomas,
I tried the new memtest program on my GP2X and it works nicely :)
The image scrolls perfectly, and with v-sync on I get around 43 FPS, and with it off I get around 340 FPS!!

:D

cheers,
Paul

KidPaddle
08-02-2009, 06:18 AM
Only 43 FPS? I have, with v-sync, around 83 FPS and without v-sync 360 FPS.

Thanks for testing.

Thomas