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.

Beginners > Reset of GBA

#18522 - punchy - Sun Mar 28, 2004 12:26 pm

Hi,
i want to add a menu option in my program to exit back to menu so users don't have to reset the gba to access other things on the flashcard. I thought it would be really simple, just set the PC to 0x8000000, but i guess i'm missing something. I tried the BIOS reset functions too, but they just seem to lock up the machine.

Any ideas?

#18545 - tepples - Sun Mar 28, 2004 7:49 pm

To reset the GBA and the flash cart, do the following in code loaded into EWRAM:
  • Reset the cart's bankswitch register to 0. This is different on Visoly, F2A Ultra, EZF, and EFA type carts. (F2A classic has the same bankswitch register as Visoly.)
  • Clear the registers and video RAM by calling BIOS RegisterRamReset(0xfc).
  • Jump to 0x08000000 in ARM mode.

This has to be done in code loaded into EWRAM because if you write to bankswitching registers from ROM, your code will disappear out from under the program counter.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#18552 - Lupin - Sun Mar 28, 2004 9:46 pm

Do we really need to reset Bankswitch? I thought it's only necesarry when using carts that are >256 mbit. How can i set the bankswitch?

An reset function sounds quite interesting...
_________________
Team Pokeme
My blog and PM ASM tutorials

#18554 - tepples - Sun Mar 28, 2004 10:04 pm

Lupin wrote:
Do we really need to reset Bankswitch? I thought it's only necesarry when using carts that are >256 mbit.

Each commercial game is compiled to assume that it starts at 0x08000000, so flash carts have to bankswitch them. If you're just running a RAM based (__gba_multiboot) program, you don't need to bankswitch because those are copied to 0x02000000 before being run.

Quote:
How can i set the bankswitch?

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

#18557 - punchy - Sun Mar 28, 2004 10:17 pm

Thanks for the reply. I had tried searching for previous topics before, but "bankswitching" turned out to be the magic word. I found your old post complete with reset code and it works beautifully.

Thanks again.

#18566 - dagamer34 - Mon Mar 29, 2004 12:52 am

Could you post a link to which topic that was. I can't seem to find it.
_________________
Little kids and Playstation 2's don't mix. :(

#18589 - punchy - Mon Mar 29, 2004 9:56 am

http://forum.gbadev.org/viewtopic.php?t=352

#18616 - dagamer34 - Mon Mar 29, 2004 11:24 pm

That code doesn't really help me since I use an EZFA, but it already has an exit-hacking option.
_________________
Little kids and Playstation 2's don't mix. :(