From: "Henrik Magnusson (RayLight /PowerLine)" Send reply to: "Henrik Magnusson (RayLight /PowerLine)" To: azure@hamburg.roses.de Date sent: Wed, 08 Oct 1997 23:40:48 +0100 Organization: PowerLine Subject: Contribution to Circle-Compo (Fastest) Hi again Azure! Here's my contribution to the (Fastest) Circle-Drawer Compo.. :) See you! :) * Contribution for the Circle Drawer Compo (Fastest Routine) * *********************************************************** * Coded by Raylight of PowerLine (Henrik Magnusson) * E-Mail: raylight@ramses.ml.org * * Routine Speed (On 030-28MHz) * ---------------------------- * Min: 3700 circles/s * Avg: 7000 circles/s * Max: Many circles/s * * Applies to following rules: * --------------------------- * * *No hardware hacking. * *No system calls etc. * *No assumptions of register state are made, except for inputregisters. * *Input: d0.l/d1.l - x/y-center * d2.l - radius * d3.b - colour * *Size of Buffer: 256x256 (256 Colours,8bit-Chunky). * *Register a7 not trashed * *Circle is nearly perfect circular. * *Should work on 020-> * *Circle is 100% closed. * * Additional considerations * ------------------------- * * *Much memory is used. * *Since I don't know if CacheClearU() is allowed, I've skipped it. It * really SHOULD be done after the init routine, since it uses SMC technique. * * * Theory Behind The Routine * ------------------------- * * This routine uses a Bresenham-like routine for generating the circle * drawers. On code is generated for each radius. Hence, the circle routine * is able to draw circles with as little as 1 instruction per pixel: * * move.b d3,bufferoffset(a0) * * (Note that this routine could be further optimized by using word and * longword writes, where possible. Also, it could utilize the (a0)+ syntax * where possible. I don't bother about that now since it's really fast * anyway.. :) ..) * ********************************************************************* * * Here you put all your code. * ********************************************************************* sectionyourcode,code ********************************************************************* * * Your init code comes here. * ********************************************************************* _initcode a leaCircleCode,a0 move.l a0,a1 move.l#0,d1 .circleloop move.la0,a1 move.ld1,d2 subq.l#1,d2 bgt.ok moveq#1,d2 .ok moveq#0,d4;x move.ld2,d5 add.ld5,d5;dy moveq#0,d6;dx ;(d2 = y) moveq#0,d7;q .loop tst.ld7 bge.skip1 addq.l#1,d4 add.ld6,d7 addq.l#2,d6 .skip1 tst.ld7 blt.skip2 subq.l#1,d2 sub.ld5,d7 subq.l#2,d5 .skip2 move.ld2,d0 lsl.l#8,d0 add.ld4,d0 move.w#$1143,(a1)+ ;OPCODE: move.b d3,????(a0) move.wd0,(a1)+ add.l#256-2,d0 neg.ld0 move.w#$1143,(a1)+ ;OPCODE: move.b d3,????(a0) move.wd0,(a1)+ add.ld4,d0 add.ld4,d0 subq.l#2,d0 move.w#$1143,(a1)+ ;OPCODE: move.b d3,????(a0) move.wd0,(a1)+ neg.ld0 sub.l#256,d0 addq.l#2,d0 move.w#$1143,(a1)+ ;OPCODE: move.b d3,????(a0) move.wd0,(a1)+ tst.ld2 bne.b.loop move.w#$4e75,(a1)+ add.l#1024*4,a0 addq.l#1,d1 cmp.l#129,d1 blt.circleloop b rts ********************************************************************* * * Your main routine. * * Every time you are given: A0 : Chunky Screen (256x256x8) * D0.l : Center (X) * D1.l : Center (Y) * D2.l : Radius (1-127) * D3.b : Colour * ********************************************************************* _circle c lsl.l#8,d1 add.ld0,d1 add.ld1,a0 LeaCircleCode,a1 lsl.l#8,d2 lsl.l#4,d2 add.ld2,a1 jsr(a1) d rts printt"Length of your code:" printv((b-a)+(d-c)) ********************************************************************** * * Put your tables here * ********************************************************************** section yourbss,bss CircleCode:ds.l1024*130 .