******************************************************************* * contribution for #amycoders shortest circle-compo * * (we think it's also the slowest ;)) * * * * written by r.a.y & sniper/Lightstorm Inc. * * * * length: 44 bytes w/o rts * * with clipping ! ;) * * * * This routine is *very* slow - it need 4-5 seconds * * to draw 1 circle ! ( 030/50 ) * * * * how it works: * * * * It goes linear trough a 256x256 chunkybuffer * * and calculates for each offset the distance to the centre of * * the circle (with pythagoras ( a=sqrt(b2+c2) ) and if the * * distance is equal to the radian it plots the given color .. * * * ******************************************************************* _circletest ; testparameter ..... move.l #128,d0 ;x move.l #128,d1 ;y move.l #18,d2 ;rad ; move.l #138,d2 ;rad move.b #100,d3 ;color lea chunkyscreen,a0 c ;a0 chunkybuffer.l ;d0/d1 x.l/y.l ;d2 rad.l ;d3 color.b circle moveq #0,d7 ; clr [bufx.b,bufy.b] bigloop bfextu d7{24:8},d6 ; bufy.l bfextu d7{16:8},d5 ; bufx.l sub.l d0,d5 ; x.l sub.l d1,d6 ; y.l muls d6,d6 ; y.l2 muls d5,d5 ; x.l2 add.l d5,d6 ; x.l2+y.l2 ; 12 bytes sqrt .... the slowest around :) moveq #-1,d5 sqloop addq.l #1,d5 ; inc sqrt move d5,d4 ; muls d4,d4 ; sqrt2 cmp.l d4,d6 ; equal ? bge.s sqloop ; nope ...... loop cmp.l d5,d2 ; distance equal to radian ? bne.s nopix ; nope ...... skip plot move.b d3,(a0,d7.l) ; yepp... plot nopix addq #1,d7 ; inc [bufx.b,bufy.b] bne.s bigloop ; end of buffer ? -> then quit d rts printt "--------------------" printt "lenght of code:" printt "--------------------" printv d-c .