GP2X Hw Accelerated Sdl


Does someone can explain me that ?
Is use this mode
SDL_SetVideoMode(320,240,16,SDL_HWSURFACE|SDL_DOUBLEBUF);
with the SDL_flip().

But with the last firmware 1.4, the framerate change if i change LCD setting in the GPH menu.

Is it possible to lock at ~60FPS for each LCD settings ?
 
When you double buffer, SDL_flip waits for a screen refresh for it to update the screen. Depending on the settings, it will have to wait more or less time.
I guess the only way of getting a constant speed would be not using doublebuf.


Or at least, that's my best guess... I haven't even started coding for the GP2X yet, so I'm not sure. :p
 
The LCD settings in the latest firmware work by setting the clock divider to the display. It ranges from 7 on the far left to 20 on the far right. The clock it divides is UPLL, which runs at 95,846,400 Hz (91.40625 MHz). Oh, add 1 to the divider number, e.g. far left (7) = 91.40625 / (7+1) = 11.426
Multiply this by 9.375 to get the fps (in this case 107).

Estimated screen refresh rates from left to right:

1 -> 107
2 -> 95
3 -> 86
4 -> 78
5 -> 71
6 -> 66
7 -> 61
8 -> 57
9 -> 54
10 -> 50
11 -> 48
12 -> 45
13 -> 43
14 -> 41

I'll test these in a bit, but if they're right, the first two run the LCD faster than what it's designed to cope with. The tech specs rate it for maximum of 90 Hz
 
Hum, still some black screen problems with bigger programs... I was toying around with a few existing ports, and all run on a black screen (but the program runs), reporting at some time SDL_GP2X: No video memory.
Here's the output of pang, for example (I did not touch the code, just tried to recompile it since 1.1.1 hangs as with the older SDL lib):
Code:
SDL: GP2X_CreateDevice
SDL: GP2X_VideoInit
fastioclk = 0, grpclk = 0
real screen = 320x240 (ilace = 0)
SDL_GP2X: Creating cursor 16x16
SDL_GP2X: Allocated WMcursor @ 0x308b78 (32)
GP2X_SurfaceManager: Allocating 256 bytes
SDL_GP2X: No video memory
SDL_GP2X: Showing cursor (nil)
SDL: GP2X_ListModes
SDL: Setting video mode 320x240 16 bpp, flags=40000001
SDL: GP2X_FreeHWSurfaces
SDL: GP2X_InitHWSurfaces 0x4004b000, 4935680
Screen bucket 0x308134
First free bucket 0x308cc0 (size = 4935680)
SDL_GP2X: Creating cursor 16x16
SDL_GP2X: Allocated WMcursor @ 0x308cd8 (32)
GP2X_SurfaceManager: Allocating 256 bytes
SDL: GP2X_CreateDevice
SDL: GP2X_VideoInit
fastioclk = 0, grpclk = 0
real screen = 320x240 (ilace = 0)
SDL_GP2X: Creating cursor 16x16
SDL_GP2X: Allocated WMcursor @ 0x308b78 (32)
GP2X_SurfaceManager: Allocating 256 bytes
SDL_GP2X: No video memory
SDL_GP2X: Showing cursor (nil)
SDL: GP2X_ListModes
SDL: Setting video mode 320x240 16 bpp, flags=40000001
SDL: GP2X_FreeHWSurfaces
SDL: GP2X_InitHWSurfaces 0x4004b000, 4935680
Screen bucket 0x308134
First free bucket 0x308cc0 (size = 4935680)
SDL_GP2X: Creating cursor 16x16
SDL_GP2X: Allocated WMcursor @ 0x308cd8 (32)
GP2X_SurfaceManager: Allocating 256 bytes
GP2X_SurfaceManager: Adding new free bucket of 4935424 bytes @ 0x308cf0
GP2X_SurfaceManager: Allocated 256 bytes at 0x4004b000
SDL_GP2X: Allocated cursor bucket @ 0x308cc0
Writing cursor to 0x4004b000
SDL_GP2X: Showing cursor 0x308cd8
fgr = ffff, fb = ff, bgr = 0, bb = 0
SDL_GP2X: Flip 0x308238
SDL_GP2X: DummyBlit
SDL_GP2X: Flip 0x308238
SDL_GP2X: DummyBlit
SDL_GP2X: Showing cursor 0x308cd8
fgr = ffff, fb = ff, bgr = 0, bb = 0
SDL_GP2X: Showing cursor (nil)
SDL_GP2X: Flip 0x308238
SDL_GP2X: Flip 0x308238
SDL_SYS_JoystickInit
LOAD_LCD_TIMING: 1
GET_LCD_TIMING: 1
VK_RIGHT
VK_LEFT
VK_RIGHT
EXIT

The same line appeared with smsplus2x and duke2x.

The error line comes from deep within SDL_gp2xvideo.c, in GP2X_SurfaceAllocate
 
The NoVideoMemory error happens right at the start as SDL tries to initialize the cursor before you've had chance to call SetVideoMode and I don't start the video memory manager until SetVideoMode is called. I worked around it by failing the initial SDL call to set the default cursor and re-running the initialization at the end of SetVideoMode. I forgot I'd left that debug statement in. It only happens when there is absolutely no video memory free which means either you really have used up every last byte of video mem, or you're calling a function that requires video mem before SetVideoMode.

I'm looking into the black screen further, when I found region 1 was being switched off I couldn't see where so it was just a hack to force it. There's only the cursor routines that (should) touch that register at the moment...
 
OK, so the NoVideoMemory at startup is normal, it made me wonder what was I doing to spend all the memory so quickly ;)

As for the black screen, I commented out my "SDL_ShowCursor(SDL_DISABLE)" line (the only one in the program dealing with cursor), and now I have images. So it does look like the cursor routines are responsible for that.
 
That's the only place where I alter the register responsible. I may just have got the ORing/ANDing wrong... Just checked altering the overlay register, there's a bit that is marked reserved right next to the cursor bit which seems to switch off reading the RGB layer, instead sending what looks to be whatever the first pixel is to the entire screen. So it looks like it's just a typo on my part.

Edit: Hopefully that's fixed it. A case of operator precedence tripping me up.
Again, these are largely untested. An emergency has popped up so the proper update will (hopefully) be tomorrow.
Pre-compiled
Source
 
I've just installed your new precompiled lib paeryn, now it resolve a horizontal line bug, it's very good!
thanks a lot for your work :)
 
It may have affected a bit of code elsewhere and wasn't until this that I realized that ~ binds higher than << (it's been quite a few years since I've done any serious programming.) All the #defines for bit offsets are bracketed now.

Now firmware 1.4 supports querying / changing TV mode in fbcon I'll see about adding a function to let SDL make the switch instead of having to use GPH's menu, though I can't see where it keeps track of the horizontal offset (nor the vertical, but changing that never moves the display for me.)
 
So far so good with this latest version and test programs (including fully working pang at least), great work and thanks Paeryn!

[ Off to hack smsplus2x to use HW scaling and display game gear properly full screen ]
 
Paeryn, can you remove either one or both of the open2x directories, or even rename them? People on case-insensitive filesystems are having problems while unpacking the archive...
 
ooPo posted on Feb 27 2006 at 05:55 PM said:
Paeryn, can you remove either one or both of the open2x directories, or even rename them? People on case-insensitive filesystems are having problems while unpacking the archive...
I didn't realize, I only use Windows for gaming!
Edit: Minor changes.
Source
Pre-compiled
The HW cursor position is hopefully positioned correctly when using display scaling.
Also added a function for setting the cursor colours (SDL assumes b&w). It's still two-colour, but you can pick the colours. Colours are 24bit regardless of display setting, it can be alpha-blended (16 levels), and the foreground colour can have a different alpha-value to the background. See README.GP2X in the source archive for details.
I've added SDL_gp2x.h to the pre-compiled archive, meant to do that ages ago. It belongs with the rest of the SDL includes (in /usr/local/gp2x/arm-linux/include/SDL/ on mine.)
Both the open2x directory and file have been removed from the source archive so there shouldn't be any problems on case-insensitive file systems anymore.
 
Last edited by a moderator:
paeryn posted on Feb 18 2006 at 02:20 AM said:
I default to 16bpp, the only other depth you can ask for is 8. Well, actually if you don't specifically ask for 8 it gives you 16. I know it should really let you ask for 24 & 32 too, but since memory is limited and it'd mean having to down-convert every frame I didn't think it was worth it.

Thanks for the SDL libs Paeryn. I'm trying to compile BasiliskII (a mac emulator) but it uses 1bit screen. (when starting up and also for the older macs). Any way of getting 1 bit screen? At the moment something shows up but its squeezed to 1/8th of the left portion of the screen
 
Last edited by a moderator:
pcklee123 posted on Mar 2 2006 at 08:13 AM said:
Thanks for the SDL libs Paeryn. I'm trying to compile BasiliskII (a mac emulator) but it uses 1bit screen. (when starting up and also for the older macs). Any way of getting 1 bit screen? At the moment something shows up but its squeezed to 1/8th of the left portion of the screen
The display is only capable of 4, 8, 16 and 24 bpp, and I ignore 4 & 24 due to limited support (the blitter doesn't handle them).
Using a 1bpp screen will mean having to support shadow surfaces, I'll have a go when I get some free time though.
<Moves 1bpp higher up the to-do list>
 
Last edited by a moderator:
i just built the libSDL-0301.tar.bz2 source and all seems to work fine apart from the cursor is displayed on the screen even if you disable it with SDL_ShowCursor(SDL_DISABLE);
 
@Guyfawkes
put your SDL_ShowCursor (0);
after SDL_SetVideoMode(.............);
It work for me like that

regards
JYCET
 
JyCet posted on Mar 2 2006 at 06:40 PM said:
@Guyfawkes
put your SDL_ShowCursor (0);
after SDL_SetVideoMode(.............);
It work for me like that

regards
JYCET
Man I wish I knew that a couple of weeks ago, I didn't even realise how I fixed it when I did. :rolleyes:
 
Last edited by a moderator:
Guyfawkes posted on Mar 2 2006 at 06:11 PM said:
i just built the libSDL-0301.tar.bz2 source and all seems to work fine apart from the cursor is displayed on the screen even if you disable it with SDL_ShowCursor(SDL_DISABLE);
Oopps, sorry about that. I think it's a side-effect of how I manage upper memory. SDL tries initializing the cursor within SDL_Init(), but I can't allocate it any memory until after SDL_SetVideoMode(), so I re-call the initialization at the end of SetVideoMode. I'll put a check in to see if the cursor has been disabled and re-disable it.
 
Last edited by a moderator:
Back
Top