#22342 - FPChris - Sat Jun 19, 2004 2:44 am
My first attempt at a 3d floor mapper in Mode 4.
Not bad realtime performance on gba hardware.
Any optimizations are welcome. Like the two divs in the
outer loop area. Enjoy...
Chris
Last edited by FPChris on Sat Jun 19, 2004 5:07 pm; edited 1 time in total
#22349 - sajiimori - Sat Jun 19, 2004 4:47 am
A few suggestions:
Change all the non-pointer variables to 'int'. GCC seems to have an easier time optimizing code that uses register-sized variables.
The divisions can be eliminated with a small reciprocal table.
Let the compiler unroll loops for you.
#22352 - FPChris - Sat Jun 19, 2004 5:24 am
Thanks for the heads up. I'll give it a shot.
I was going to do an LUT for the height but this way made it
portable to anyone that wants to drop it in.
#22357 - FPChris - Sat Jun 19, 2004 5:48 am
Also I just found out in another post that this code is 'invalid'.
I am typecasting the video memory as a u8*. This was not
throwing an error nor failing on the hardware. BUT it is
drawing u16 pixels not u8 as the code will lead you to think.
I was testing with a grassy green texture and I could see that
2 pixels were being drawn regardless of the u8 typecasting.
I'll revise and repost if anyone is interested.
Chris
#22359 - sajiimori - Sat Jun 19, 2004 6:13 am
The compiler doesn't know about the GBA's hardware quirks, so one would not expect it to produce an error. Besides, it's rather impossible for it to detect which code will eventually write something to VRAM at runtime.
Also, the GBA doesn't "fail" the way PCs do with blue screens of death and all that. If you do something undefined, you'll get undefined results.
#22365 - FPChris - Sat Jun 19, 2004 1:31 pm
True. I wasn't expecting gcc to catch it but I did expect the gba
to act is if something wasn't right somewhere.
Your 'int' suggestion also showed an improvement.