PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

gx.dll replacement

As the designated porter for just about every open-source project that doesn't run on the monochrome iPAQs, I've been getting a little sick of waiting for source releases, and I don't have nearly as much time as I used to for this kind of thing. Therefore, I'm trying to use Daniel Jackson's Aero 2100 gx.dll source and create a GAPI implementation that will fool applications into running on greyscale. To do so, I'm allocating a color screen buffer and giving its address to apps, then running a very fast conversion (4 bytes at a time) on it at GXEndDraw(). What I need is information to make sure that I'm accurately duplicating the 3600 series video setup. To that end, I'd really appreciate it if someone could post the results they get when they run the GAPI Properties applet from PocketSNES.com (found in the download section). If I get this working, and it shouldn't be hard, it will mean that anything running on a color ARM machine will run on a black and white machine, finally giving these machines the leg up they need to truly compete with color.

And I'll be able to play RocketElite. <grin>

Thanks in advance,

Thomas
A problem that I can see with your idea is that there are some existing games that never call GXEndDraw. The call GXBeginDraw once at the start of their game and then cache the frame pointer address.

They might heed the value returned from your implementation of GXIsDisplayDRAMBuffer. If you return TRUE (which you should be) they might not cache the pointer.

Also, I don't think anyone is making gray scale devices anymore. Thus your audience is fixed and will only get smaller over time. All new Pocket PC devices must be ARM-based and have 16-bpp color screens. Still, I think it's cool you're doing this and it shouldn't be a lot of work to prove your concept. Good luck.
First, many programs do not indeed call gxEndDraw, but many of the most popular ones do, especially those that are cross-platform. It doesn't hurt to try.

Second, I will likely implement the GXIsDisplayDRAMBuffer() modification, but I think it's far more likely that programs do not call this as opposed to GXEndDraw.

Finally, I assume you're new to the forums. If you weren't, you'd know that I've done several ports due to the suprising demand that exists. Because they're cheap and have fantastic battery life, the greyscale devices are often popular among a certain class of people, as well as being used in many Stinger devices. The community on Brighthand is nigh-fanatical, and even if they weren't, I'd want something like this myself. As someone once said, 99% of programs are written to satisfy a programmer's personal itch. The inability to run many games just because no-one will take the extra time to code for them is my personal pet peeve.
Okay, I think I really need that information, so I'd appreciate someone posting it. Right now, two crashes are happening. I'm using PQ as a test app because it does call EndDraw and its implementation is the one I'm most familiar with. It's dropping out either at address 0006c3a4 when I feed it my buffer's pointer (adjusted forward by 2*320 to fake the iPAQ's landscape orientation), or later on when I try to copy my video buffer to the standard greyscale screen. The latter is probably just a mistake in my loop, and I won't have a problem fixing it later, but I'm a little upset that just writing to my malloc'ed 320*240*4 (just to be safe, I know it's supposed to be 320*240*2) buffer is causing some sort of invalid error. I'm not sure if it's an alignment problem or not. Anyone have any ideas?
Oh, and in case it helps, PQ does run perfectly (albeit with no video, but sound) when I pass NULL as the video pointer from GXBeginDraw.
< forgot to login before - I'm "Anonymous">

Well I'm not too new here, but I have no idea of what work you've done. Probably because I don't play that many games these days and I don't recall seeing your name here in the dev forums.

Anyone who is writing a game that doesn't heed the return value from GXIsDisplayDRAMBuffer is blind when it comes to graphics performance.

I do salute your enthusiam and I'm sure that the people who have gray scale devices are elated that someone is thinking about them. If this makes you and your Brighthand friends happy and you enjoy coding it, I say go ahead and do it. I was just saying that the market is stagnant and will only decrease going forward. It would be similar to developing a game for the Dreamcast right now.
Code:

GXDLL_API void * GXBeginDraw()
{
if (initialize() && (pGXBeginDraw != NULL))
{
grey_vid = (char *) pGXBeginDraw();
grey_vid -= 160;
return color_start;
//return NULL;
//return pGXBeginDraw();
}
else
{
return NULL;
}
}

GXDLL_API int GXOpenDisplay(HWND hWnd, DWORD dwFlags)
{
if (initialize() && (pGXOpenDisplay != NULL))
{
color_vid = malloc(320*240*4);
color_start = (short *)color_vid;
color_start += 2*320;
return pGXOpenDisplay(hWnd, dwFlags);
}
else
{
return 0;
}
}

Here's what I'm trying so far. color_vid is a void*, color_start is a short* that tries to adjust for the rotation. Changing the underlined code to use the "return NULL" gets Quake running, but there's no video--as it should be. Advice?
The name has changed in the forums since they moved over. I'm ThomasWilburn, but I always logged in as TBone. And I'm pretty sure I don't remember PQ checking for DRAM buffers. I know for a fact GNUBoyCE doesn't.
Kzinti · 21 Jan 2002, 21:47 UTC — GAPI video address
Your video address seems wrong to me...

You should add 638 bytes, not 640 (2x320) as you are trying to do.

By the way, you are actually adding 1280 bytes because you video pointer is a short*...

Take care!
I think I've tried all of those. At one point, earlier today, I was casting color_vid into a char* and adding 638 bytes to it in order to manually produce that effect. I also intentionally over-allocated for color_vid in order to hopefully counter that kind of error. I'll try it again though.
Try this:

Code:

GXDLL_API int GXOpenDisplay(HWND hWnd, DWORD dwFlags)
{
if (initialize() && (pGXOpenDisplay != NULL))
{
color_vid = malloc(320*240*2);
if (NULL == color_vid)
return 0;
color_start = (WORD*)color_vid + 319;
return pGXOpenDisplay(hWnd, dwFlags);
}
else
{
return 0;
}
}


You might consider allocating the memory via VirtualAlloc instead of malloc, or at a minimum make sure the returned address is 32-byte aligned. Works better with the StrongARM cache that way.

The reason that apps should take notice of the return value from GXIsDisplayDRAMBuffer is that if the API returns TRUE, they should not create their own back buffer, but instead use the returned value from GXBeginDraw. This avoids a 150K copy operation each frame. The DRAM buffer also allows for another optimization in that you can specify a dirty rectangle if you only update a portion of the buffer. This allows the driver to minimize what it has to copy from the DRAM buffer to display memory.
use the [ code ] and [ /code ] tags next time, TBone. It makes your code and posts easier to read.
It appears TBone released a beta of this yesterday:

http://mason.gmu.edu/~twilbur1/downloads/gx.zip

Dan East