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.

Coding > How to change Graphics mode on the fly?

#337 - notron - Mon Jan 06, 2003 5:32 pm

Well, as a newbie here, I was just programming a simple little test program to test out things. Very simple, I just want to set the mode to 3 ( I know, single bitmap mode) and paint a single color into the bg and then display it. That works just fine ( using Devkitadv and Boycottadvance).

Then, wait for an input keystroke and then repaint the background to a different color! Wow, cannot find anyway to do that? Can anybody help me?

Here is my code:
WaitForInput(); // This code works just fine.
WaitForVsync(); // probably don't need this at startup

SetMode(MODE_3 | BG2_ENABLE); // Works just fine
SetBgColor(0,0,31); //! start with blue just so I know that it started

// At this point all is fine, screen display goes from black to blue after the first keypress. Now comes prob!
WaitForInput();
WaitForVsync();
SetBgColor(31,0,0); //! go to red so I know it worked.
WaitForInput();
// Nothing happens when I keypress,i.e. the screen doesn't change color.
//----------------------------------------------------------------------------------

Is there something I am missing here? I expected the display controller to be continuously displaying the blue color ( which it did) while my code waits for the next keypress. However, the next keypress does not change the bg color to red, it stays blue. I have tried Forced_Blank, disabling the BG, etc. Nothing seems to work. THe screen is always blue!

It acts like there is not a way to ever change the background in mode 3. I know I can change it in mode 4 ( done that already), but wanted to use mode 3 just to display a sequence of still bitmaps with a pause between each one.[/code]

Any help would be much appreciated.
_________________
MysticX is The Defender

#341 - notron - Mon Jan 06, 2003 5:55 pm

Sorry everyone, I found the prob!

I plagarized the code for SetBgColor() from another source which just copies a color into SCREEN_BUFFER. However, I failed to notice that it had a While (1) statement in it, so it just sat there forever and re-painted blue and never returned after the first call.

Stupid little Newbie user error. I'll try to be more diligent in the future.
_________________
MysticX is The Defender

#342 - Burre - Mon Jan 06, 2003 6:00 pm

I'm not sure, since I'm also new to GBA coding and don't use the bitmap modes in my game. But I've come up with two possible scenarios:

1. Mode 3 is double buffered (don't know if it is but i remember that one of the bitmap modes were) and you forgot to flip active screens.

2. The new gfx ends up on a different BG than the one with the blue color. A BG with lower priority than the one with blue color. Start you emu (preferably VBA) and check the different BGs.

I'm mostly guessing now but is two probable scenarios that I came up with.

edit: Was still writing when you posted your second message. Anyway, nice to see that solved the problem.
_________________
"The best optimizer is between your ears..."

#378 - Costis - Tue Jan 07, 2003 2:37 am

Hi,

Mode 3 is not double buffered. Instead, Mode 4 is although only 256 BG colors can be used at once without raster effects since it uses a 256 color palette. Also, you might want to use VisualBoy Advance and Mappy for running and debugging your GBA programs. BoyCott Advance is very outdated and cannot run many GBA programs accurately. VisualBoy Advance is currently the closest to the actual hardware, but Mappy has nice debugging features built in.

Costis