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 > Is there any advantage using mode 4 over mode 0

#177826 - Bregalad - Sun Mar 24, 2013 12:56 pm

I mean, if you want full screen 256-colours graphics, it is POSSIBLE with mode 0 (just use a dummy tile-map and 30x20 256 colour tiles), and you get 3 extra BGs for other stuff, while in mode 4 you only have one BG.

It uses a LITTLE mode VRAM because of the need of the dummy tilemap unfortunately, but that's really the only disadvantage I see.

The only real inconvenient I'd see is that it would be slightly harder to address pixels. Instead of doing
Code:
screen[240*y + x] = pixel;


You'd have to do :

Code:
coarse_x = x & ~7;
fine_x = x & 7;
coarse_y = y & ~7;
finy_y = y & 7;
screen[64 * (30 * coarse_y + coarse_x) + 8*fine_y + fine_x] = pixel;


Slightly more complicated, but considering the ARM processor and all it's barrelshift instructions, it won't hurt performance all that much.

The fact that you could still use 3 BGs for other 2D graphics that don't have to be rendered in soft can be a huge plus.

#177827 - Dwedit - Sun Mar 24, 2013 3:02 pm

The only advantage is that you get two independent screen buffers to switch between. Mode 0 only gives you 1 screen buffer worth of graphics, plus 26.5k of additional graphics memory for other uses. (Plus the cost of the tilemap)

Mode 0 is better because you can use another layer for overlays and you can also use sprites, but only mode 4 gives you two complete 8-bit buffers to page flip between, even though you lose sprites.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#177828 - Bregalad - Sun Mar 24, 2013 3:19 pm

DMA is your friend, just have one (or 2) buffers in RAM, and send them to the screen by DMA.

Also I'm pretty sure I saw demoes use mode 4 and sprites at the same time.

#177829 - sverx - Mon Mar 25, 2013 10:43 am

According to GBATek:
Quote:
OBJ Tiles are stored in a separate area in VRAM: 06010000-06017FFF (32 KBytes) in BG Mode 0-2, or 06014000-06017FFF (16 KBytes) in BG Mode 3-5.

so I guess you can have sprites even when using mode 4.
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177845 - Bregalad - Sat Apr 06, 2013 3:57 pm

If the tiles are laid out vertically (that is, tiles 0-19 are column 0, 20-39 are column 1, etc...) instead of horizontally, the pixel access can be simplified further, as there is no need to separate file and coarse Y scroll :
Code:

coarse_x = x & ~7;
fine_x = x & 7;
screen[64 * 20 * coarse_x + 8*y + fine_x] = pixel;