#167048 - headspin - Fri Feb 27, 2009 7:47 pm
I need a scanline circle fill alg for creating a window effect. The only one I've found is the following.
The accuracy is not as important as speed as it needs to be calculated during a HBLANK interrupt. I also need to eventually translate it to asm so is there a similar method that doesn't use the sqrt and would be easier to translate to ARM asm? It can be use a sin lut if necessary but needs to be calculated for each VCOUNT.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
Code: |
void circleFill(int r)
{ int x1, x2; for (int y=0; y<r*2; y++) { x1 = ROUND(r + sqrt(SQR(r) - SQR(y - r))); x2 = ROUND(r - sqrt(SQR(r) - SQR(y - r))); line(x1, y, x2, y); } } |
The accuracy is not as important as speed as it needs to be calculated during a HBLANK interrupt. I also need to eventually translate it to asm so is there a similar method that doesn't use the sqrt and would be easier to translate to ARM asm? It can be use a sin lut if necessary but needs to be calculated for each VCOUNT.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game