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 > Just a simple question...
#9340 - yaustar - Sat Aug 02, 2003 1:26 am
I know that the GBA cannot handle mods, how is it with square rooting?
_________________
[Blog] [Portfolio]
#9344 - slip - Sat Aug 02, 2003 2:42 am
The GBA can handle mods and square roots. In order to do so in asm you make a software interrupt with swi. But you probably don't want to use assembler to do that. What you can do however is download Andrew P. Bilyk's SWI library from http://www.gbadev.org/download.php?section=demos&filename=swi_libraries.zip
One thing you might have to add to the file is at the start
#ifndef SWI_H
#define SWI_H
and at the end
#endif
You may also need to add:
extern "C"{
just after #define SWI_H then a closing brace before #endif.
You'll only need to do this if your trying to compile g++ AFAIK, though I havn't tried compiling with gcc.
You can look in the swi.h file to see what functions are avalible, also check out the GBATEK or COWBITE documents for more info about the SWI interrupts, I thought I'd looked at them properly but it took me a later look to understand some of the functions.
When you include swi.h and providing you link the library with your project, you can make the simple calls:
SWI_Mod(u32 numerator, u32 denominator);
SWI_Sqrt(u32 number);
You can check these out in swi.h ;)
Thanks to Andrew for making this library for us =)
hope that helps
_________________
[url="http://www.ice-d.com"]www.ice-d.com[/url]