gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Some questions about graphics

#10711 - floppy942 - Sat Sep 13, 2003 3:39 am

Im a newbie to gba c++ programming. I have a few questions about graphics. If someone could help me out, I would be very greatfull.

First off, can you plot a pixel in tile modes? I don't think its possible, but I figured it wouldn't hurt to ask.

Second question. I'm using a simple method to display images in bitmap mode, with for loops to load the palette and the image data directly to video memory. This is a little slow. I can see the image being painted on. Is there faster way?

Question three. I'm using the particle engine from the Pern Project to make a starfield in my intro. When I run it the starfield looks fine, but I get a lot of garbage near the bottom of the screen. After I played around a bit I figured out that its the DMAClearScreen function (from graphics.h) thats doing this. I dont know much about DMA yet, so if someone could let me know how to prevent this. If you need to look at a screenshot or some of the code, just ask me. I'll post it.

Thanks to anyone that can help.

#10712 - tepples - Sat Sep 13, 2003 3:51 am

floppy942 wrote:
First off, can you plot a pixel in tile modes? I don't think its possible, but I figured it wouldn't hurt to ask.

All the original Game Boy has is tile modes, yet Faceball 2000, Qix, and the Game Boy Camera seem to plot pixels easily enough. To do this, modify the tile data in real time.

Quote:
I'm using a simple method to display images in bitmap mode, with for loops to load the palette and the image data directly to video memory. This is a little slow. I can see the image being painted on. Is there faster way?

Unless you're using some sort of decompression to VRAM, try DMA-copying the image data into memory.

Another option: try double buffering with a hardware page flip. Draw to one surface and display the other; then switch once you're done drawing. If you're willing to give up some horizontal resolution, try pixel-doubling the mode 3 map (BGAFFINE[2].pa = 0x80) and then scrolling by changing the X origin. Or if you're willing to give up some color depth and ease of plotting individual pixels, go to mode 4.

Quote:
I get a lot of garbage near the bottom of the screen. After I played around a bit I figured out that its the DMAClearScreen function (from graphics.h) thats doing this.

DMA can't always clear all the screen. You may have to break up the screen clearing into several smaller DMA transfers. Besides, for setting memory to a constant value (such as clearing the screen to a solid color), an 'stmia' loop can be faster than DMA because it doesn't have to repeatedly re-read the stack.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#10714 - floppy942 - Sat Sep 13, 2003 7:15 am

Ive got everything working right. Thanks for the help!