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 > Mode 5 Question

#8538 - Sckuz - Sun Jul 13, 2003 9:48 am

Does anyone know how mode 5 looks on an actual gameboy? Does it stretch to fill the whole screen or is it windowed like it is in the emulator?
_________________
"There is no right and wrong. There's only fun and boring." - The Plague

#8540 - Sweex - Sun Jul 13, 2003 1:38 pm

You can decide yourself as you can rotate and scale it. I think most people scale it to fullscreen though, as the GBA screen is already tiny enough!:-)

#8547 - Sckuz - Sun Jul 13, 2003 7:42 pm

So, how do I scale it then?
_________________
"There is no right and wrong. There's only fun and boring." - The Plague

#8549 - tepples - Sun Jul 13, 2003 9:35 pm

To scale the display of a bitmapped graphics mode, use the background 2 affine matrix registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8554 - Sckuz - Mon Jul 14, 2003 3:32 am

Sorry if this is a stupid quesiton.. but how do i do that?
_________________
"There is no right and wrong. There's only fun and boring." - The Plague

#8556 - Sweex - Mon Jul 14, 2003 9:22 am

Tepples' reply is really straightforward, so I assume you didn't do very much programming for the GBA yet.

Why don't you read some tutorials, and then write a simple example program for each of the videomodes? I believe it's much better to see these things for yourself than to ask everybody at the forum.

#8574 - Sckuz - Tue Jul 15, 2003 3:15 am

Yeah.. Im very new to the GBA. Anyway, I figured it out. I took tepples suggestion and looked up some stuff on rotating/scaling backgrounds. All that work just to discover that scaled mode 5 looks pretty sad. I might have to use a tweaked mode 4. Anyway, thanks for the help & sorry I'm lazy.
_________________
"There is no right and wrong. There's only fun and boring." - The Plague

#9586 - Derek - Sat Aug 09, 2003 2:39 pm

Sometimes its just better to give the code and move on. I didn't have time to work read hardware doc's either, since I knew after the mode is set then its all standard C/C++ coding.

This is the code that I use to setup a mode 5 rotated/stretched to 120x160. You will lose 8 pixels.

*(unsigned int*)0x04000000 = 0x405;
*(unsigned short*)0x4000020 = 0;
*(unsigned short*)0x4000022 = (-1 << 8);
*(unsigned short*)0x4000024 = 128;
*(unsigned short*)0x4000026 = 0;
*(unsigned short*)0x4000028 = 159 << 8;

Play with the 128 to adjust the stretch. Heres a demo of a mode 5 3D engine.

http://www.theteahouse.com.au/gba/index.html

Derek Evans

#19599 - corranga - Thu Apr 22, 2004 5:46 pm

Been trying to find a way to switch between 'fullscreen' and normal sized mode 5 by using input, but I can't get it to work properly. I presume that I have to reset particular register values in order to switch between the different versions of mode 5 but I can't find which / what I need to do, can someone help?

Chris
_________________
If virtual reality is ever on a par with reality, I want to be Bomberman! :D

#19600 - tepples - Thu Apr 22, 2004 6:21 pm

Look over this:
Code:
struct BGAFFINEREC
{
  unsigned short pa;  /* map_x increment per pixel */
  unsigned short pb;  /* map_x increment per scanline */
  unsigned short pc;  /* map_y increment per pixel */
  unsigned short pd;  /* map_y increment per scanline */
  unsigned int x_origin, y_origin;
};

#define BGAFFINE ((volatile struct BGAFFINEREC *)0x04000000)

const struct BGAFFINEREC identity = {256, 0, 0, 256,  0, 0};
const struct BGAFFINEREC mode3paged = {128, 0, 0, 256,  0, 0};
const struct BGAFFINEREC mode5fullscreen = {0, -256, 128, 0,  319 << 7, 0};

/* To turn off rot/scale */
BGAFFINE[2] = identity;

/* To display Mode 5 in rotated/scaled fullscreen */
BGAFFINE[2] = mode5fullscreen;

/* To display half of Mode 3 in scaled fullscreen */
BGAFFINE[2] = mode3paged;

/* To switch "pages" of Mode 3 */
BGAFFINE[2].x_origin = page ? 120 << 8 : 0;

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.