This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Doom and gapi


Doom and gapi

Postby Gautam » Jul 7, 2002 @ 10:47pm

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby Dan East » Jul 8, 2002 @ 3:14am

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Gautam » Jul 8, 2002 @ 4:42am

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby Gautam » Jul 8, 2002 @ 5:09am

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby Dan East » Jul 8, 2002 @ 7:35am

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Gautam » Jul 8, 2002 @ 2:27pm

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby Dan East » Jul 8, 2002 @ 4:54pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby superman » Jul 8, 2002 @ 5:21pm

"Kittens give Morbo gas." - Morbo the News Monster
User avatar
superman
pm Member
 
Posts: 99
Joined: Nov 3, 2001 @ 1:09am


Postby simonjacobs » Jul 8, 2002 @ 5:27pm

This file contains source code for adding HP 525 support to GAPI games. It should work fine on any 256 color palette based pocket pc as far as I know, but it has only been tested on the following machines:

HP Jornada 525
HP Jornada 545 set to 256 color mode

If you test on any other machines please let me know the results.

Overview:

The code uses GDI functions to set up the palette, but this does not affect game speed as it only needs doing at:

1) Start up after grabbing the screen with GAPI
2) If the game is hidden then reactivated in the WM_SETFOCUS message
3) If you want to change the palette

so it doesnt need to be done each update. You can set the palette to anything you like, but to save trouble you might find it easier to just set up a RGB 332 palette and convert from the standard RGB 565 you would normally be using with shift and mask operations. The example code below uses a RGB 332 palette but it is obvious how to set up your own custom colors if you like.

General code changes:

You can detect that you are running on a 256 color machine with the GXGetDisplayProperties function. If you find:

g_gxdp.cBPP == 8 && (g_gxdp.ffFormat & kfPalette) != 0

then you should use the code for palette based machines.

YOU MUST TAKE INTO ACCOUNT that each pixel in the GAPI buffer is an unsigned char instead of an unsigned short and alter your screen update code accordingly.

Setting up the palette.

This should be done in the 3 situations mentioned above, and the code is:

struct {
LOGPALETTE lp;
PALETTEENTRY ape[255];
} pal;

LOGPALETTE *pLP = (LOGPALETTE*) &pal;
pLP->palVersion = 0x300;
pLP->palNumEntries = 256;

for (int i=0; i<256; i++)
{
pLP->palPalEntry[i].peRed = ((i&0xE0)>>5)<<5;
pLP->palPalEntry[i].peGreen = ((i&0x1C)>>2)<<5;
pLP->palPalEntry[i].peBlue = (i&0x03)<<6;
pLP->palPalEntry[i].peFlags = 0;
}

HPALETTE mypal = CreatePalette(pLP);
if (mypal)
{
HDC screenDC = GetDC(NULL);
if (screenDC)
{
SelectPalette(screenDC,mypal,FALSE);
RealizePalette(screenDC);

ReleaseDC(NULL,screenDC);
}
DeleteObject(mypal);
}

This creates an RGB 332 palette, you can do your own colors by altering the red/green/blue settings for each color in the for (int i=0; i<256; i++) loop.

Writing to the screen.

Exactly the same as normal, but remember each pixel is one byte long! If you write the number 1 to a pixel you will get the color in palette entry 1. If you set up the palette as above you will have the equivalent of a RGB 332 palette, that is writing 0x03 will give you pure blue. The code to convert an RGB 565 color to RGB 332 is:

unsigned short rgb565col = whatever;
int rval = (rgb565col&0xE000)>>8;
int gval = (rgb565col&0x0700)>>6;
int bval = (rgb565col&0x0018)>>3;
unsigned char rgb332col = rval|gval|bval;
User avatar
simonjacobs
pm Insider
 
Posts: 311
Joined: Nov 27, 2001 @ 4:51pm
Location: London, UK


Postby gamefreaks » Jul 8, 2002 @ 8:21pm

The quickest easiest way to get doom on a 525 is to use Bruce Lewis's DoomCE as a base.

Dump the GDI code for GAPI and your away.

I got the basic version of HPC Doom up and running in about 2 hours!

Your device is a 256 color which should be very easy. Make a lookup table of the colors from the Doom frame buffer (screens[0]) and map them to the jornada's pallette. Blit them using
*fb = pallete[*source]
Look at the PocketQuake code. (Vid_ppc.c)

I was considering porting HPC DOOM to the PPC, but if your going to, I wont bother and I'll do Hexen & Heritic instead.

If you need more detailed help, ask me. I think im pretty well-aquanited with the Doom code! :D
What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. -Woody Allen
User avatar
gamefreaks
pm Insider
 
Posts: 466
Joined: Oct 20, 2001 @ 8:52pm
Location: Leicester, England


Postby Gautam » Jul 8, 2002 @ 9:06pm

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby Dan East » Jul 8, 2002 @ 11:51pm

You need to link to gx.lib.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby Gautam » Jul 8, 2002 @ 11:56pm

At first glance, that would seem like the problem, but I was not stupid enough to forget to include gx.lib in the link. *phew* What else could be wrong?
User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Postby gamefreaks » Jul 9, 2002 @ 8:26pm

That'll be because you are calling GAPI functions from C code. I think we sussed that one last night. Its hard to help unless I can see the code. Post a snippet.
Maybe you should forget GAPI and compile it 'as-is' first. Don't forget to define WAVEOUT and DIRECT_COLOR in the project settings.
That way we can see whats what.

Dump the code from CreateSurface() and just allocate 320*200 bytes of memory and assign screens[0] to that pointer. Thats your surface.

Drop BlitScreen and replace it with code that blits screens[0] using the pallette array to your vid memory.
Maybe screens[0] could be assigned directly to vram saving a blit? That wouldnt work with my port, because of the centering and stretching code...But maybe on your port.
What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. -Woody Allen
User avatar
gamefreaks
pm Insider
 
Posts: 466
Joined: Oct 20, 2001 @ 8:52pm
Location: Leicester, England


Postby Gautam » Jul 9, 2002 @ 9:58pm

User avatar
Gautam
pm Member
 
Posts: 44
Joined: Jul 7, 2002 @ 9:38pm
Location: Acton, MA


Next

Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron