PocketMatrix forums

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

Newbie questions...

Hi,
I'm trying to write my first game for PPC (I have already coded some apps on win32 with C & API). The way I have choosen is the hard one (at least it seem so to me), use C and GAPI, without any library/framework. I have read Larry Bank's tutorial and some other docs from the web (and your old posts). Now here is my list of questions:

1. Which is the correct procedure to draw scene on the screen?
I mean:
create a video memory buffer ->
load background and sprites from files ->
paste them on video backbuffer ->
flip it
Is this procedure correct?

2. The video memory back buffer should be the same format as the real video memory? Can it be a standard 565 format and make the conversion at memcopy step?

3. If the display use only 8 bit, I have to load and set my own game color palette shared between all my graphics objects?

Almost done...

4. Which is the best way (size, fast to load and fast to code :) ) to store graphics? 24bit BMP? 16bit BMP? 16bit RAW data? Other?
OK, finish (for now)... It will be funny when I will start the sound engine...
flood me with informations and links :).
Thankyou all.

Loopback
1. That would work
2. I believe that you can set that with the GAPI, but the default is 565
3. The easiest way would be a table with lookup values for each color used in your images. Or you could estimate and do a quick change from 16 t0 8, but that usually looks really bad.
4. I'm not sure, but I would image that 16 bit bmp's would be the fastest. Also, it is probably quicker to include the images in your exec, although I am not positive about this either.
1. My answer:
Your method is fine.

a. Grab a buffer(s) the same size as the screen.

b. Plot into the buffer(s).

c. Blit/memcpy a buffer to the screen.

d. goto b


2. My answers:
a) Yes it should be.
b) Yes it could be... but..


Personally, I'd make sure the back-buffer was the same as the destination and have a custom plot routine for each type of output you anticipate (8bpp palettised, 16bpp, etc).

You should know what you're plotting, and how you're going to plot it, so you should be able to pre-process all of your data to fit the destination *once* (bitmaps, etc). Mangle the data once, don't try and do it every frame on the copy, 'cos that's going to be *slow*.

That's what I'd do, anyway, but then I'm a little twisted when it comes to low-level stuff (I like getting my hands dirty with assembler :twisted: ).

Another thing to watch is the orientation of the screen buffer - that's come up here before - I think it was Digby (him again :) ) who thought it was best to pre-rotate the data/bitmaps, and I agree with him). Rotating a buffer onto the screen each frame is *nuts* (IMHO).

3. My answer: Pass.

I don't know that one, sorry. It'll probably depend on how the hardware sets out its palette (the GBA, for example has two 256-colour palettes for 8-bit mode - one for sprites, one for the tiles).

As before, if you can, pre-process your data into a palette, don't munge every pixel at runtime.

4. My answer: Define "best"

Fastest to code...
... is to generate raw data the same as your output.

Size is going to suck though, without compression. There are compression routines at <a href="http://www.devrs.com/gba/">http://www.devrs.com/gba</a>

Fastest to load...
... who cares - you're probably loading from RAM; it's going to be zippy. I'd stick the graphics in an external file rather than building it in (same for "levels").

Size...
bitmaps and raw data are costly size-wise. Compression is your friend. RLE bitmaps may help a bit, but it depends on your source data.

If you're doing one EXE to fit all pocket devices, then it's probably "best" to store the bitmaps (compressed) at 24bpp, then you'll be ok when devices with 24-bit displays come out.

The main concern for me with pocket devices is to keep the size down. If somebody writes a game but the memory footprint is huge, then I'm not interested. I think that's a general attitude, but I may (as always) be wrong.

If I were you, I'd target the device you own, get everything working with raw data, then add compression, etc to the mix.

Hope that helps,

Refractor.
Thankou very much for your answers, now I hope to point to the right direction :).