#11966 - SmileyDude - Sat Oct 25, 2003 7:14 am
Hello everyone -- I was playing with some circle drawing code tonight just to see what I could come up with, and I thought that I might as well share it for everyone else to play with as well. It's based on the algorithm from Michael Abrash's Zen Of Graphics Programming book, but now written in ARM assembly. By my calculations, the inner loop takes either 29 or 24 instructions per iteration, and each iteration draws 8 pixels. So, it roughly takes between 3 and 3 1/2 instructions per pixel drawn.
I'm fairly positive that there is room for improvement... for one, in the book, Abrash mentions something about the initial multiplies aren't needed (outside the loop). This would allow 16-bit math to be used -- something that doesn't really make much sense on the ARM.
My code that moves the 8 screen ptrs to their next position is kinda nasty... if a horizontal and vertical move are done at the same time, I do one add/sub for both of them. The problem is that can't simply add 482 or 478 (240 pixels * 2 bytes = 480 for each row, plus or minus 2 for each column), since that's an illegal immediate value. So, if anyone has any ideas on how to make that mess better, please feel free to share.
The code is at http://munsie.dhs.org/gba_code/circle.S -- it's for GAS, and the only thing that you will need that I didn't provide is the gba.h file -- you could just define the value of VRAM yourself, though. I don't use anything else besides that from the gba.h file.
_________________
dennis
I'm fairly positive that there is room for improvement... for one, in the book, Abrash mentions something about the initial multiplies aren't needed (outside the loop). This would allow 16-bit math to be used -- something that doesn't really make much sense on the ARM.
My code that moves the 8 screen ptrs to their next position is kinda nasty... if a horizontal and vertical move are done at the same time, I do one add/sub for both of them. The problem is that can't simply add 482 or 478 (240 pixels * 2 bytes = 480 for each row, plus or minus 2 for each column), since that's an illegal immediate value. So, if anyone has any ideas on how to make that mess better, please feel free to share.
The code is at http://munsie.dhs.org/gba_code/circle.S -- it's for GAS, and the only thing that you will need that I didn't provide is the gba.h file -- you could just define the value of VRAM yourself, though. I don't use anything else besides that from the gba.h file.
_________________
dennis