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 > Emulator

#21161 - Mephisto - Tue May 25, 2004 4:41 am

the Program i compiled is 3x slower on a real gba than on Virtualboyadvance ...
Some advice ?

#21164 - tepples - Tue May 25, 2004 5:30 am

VisualBoyAdvance doesn't emulate wait-states. Here are things to do:
  • If you're running code off a flash cart (i.e. not __gba_multiboot or gba_mb.specs), use the WAITCNT register to set the wait-state to 3n 1s rather than the default 4n 2s. This will give you a bit of a speed boost.
  • Put speed-sensitive code in IWRAM. This will give you a bigger boost. Code in IWRAM runs just as fast on hardware as on a GBA.
  • Compile speed-sensitive code as ARM instead of Thumb. ARM code is bigger and thus runs slower from 16-bit memory such as ROM or EWRAM. However, from 32-bit memory such as IWRAM, ARM instructions run faster than the equivalent Thumb instructions.

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

#21181 - Mephisto - Tue May 25, 2004 1:53 pm

Can i have som simple code please ? (for the 3N 1S thing)
If not i will search for weeks in vain ^^

#21194 - tepples - Tue May 25, 2004 5:52 pm

Provided that your flash cart is fast enough (anything but early Visoly carts), you can safely overclock ROM access thus:
Code:
#define WAITCNT           *(volatile unsigned short *)0x04000204
#define WAITCNT_ROM31     0x0014

int main(void)
{
  WAITCNT = WAITCNT_ROM31;  /* set ROM wait state to 3n 1s */

  /* rest of code */
}

It's also possible to overclock EWRAM access to 1n 1s (from the default 2n 2s) using an undocumented register, but I wouldn't recommend it because it might fail after the GBA heats up a bit or in hot weather.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#21195 - Mephisto - Tue May 25, 2004 6:03 pm

thx a lot i try it now !

EDIT : Cool it works !! ^^