Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!cs.umu.se!dvljrt From: dvljrt@cs.umu.se (Joakim Rosqvist) Newsgroups: comp.sys.amiga.programmer Subject: Re: 3D stuff & quick line drawing Message-ID: <1991Apr22.122442.25505@cs.umu.se> Date: 22 Apr 91 12:24:42 GMT References: <1991Apr21.081925.4722@lynx.CS.ORST.EDU> Sender: news@cs.umu.se (News Administrator) Organization: Dep. of Info.Proc, Umea Univ., Sweden Lines: 122 In article <1991Apr21.081925.4722@lynx.CS.ORST.EDU> divineg@prism.CS.ORST.EDU writes: > > Here's my situation: > >I've coded and coded and coded and finally found a way to crudely rotate >3 dimensional objects ... now all of you wizards out there, what's the >quickest way to draw a line? I'd like to do it with the Blitter (I can >use the processer to calculate while I draw lines) or is it better to use >the 68'? By the way, I'm using C & asm (pretty original, huh?). > Please post your responses, I'm interested in what kind of >discussion follows..... > Here is a part of the source i use when i want *fast* lines. It uses the blitter and writes directly to the DFF regs (no flames please, i *did* call Ownblitter first) There are som things left out, like where how to find the address of the bitplane to draw in, and where the coordinates comes from, but that should be easy to fill in. /$DR.HEX$ DMACONR=2 BLTCON0=$40 BLTCON1=$42 BLTAMOD=$64 BLTBMOD=$62 BLTCMOD=$60 BLTAPT=$50 BLTCPT=$48 BLTDPT=$54 BLTADAT=$74 BLTBDAT=$72 BLTAFWM=$44 BLTSIZE=$58 OwnBlitter=-456 DisownBlitter=-462 width=80 ;80 bytes = 640 pixels Draw_all_lines: move.l 4.w,a6 move.l (a6),a6 move.l (a6),a6 ;get base of Gfxlib jsr OwnBlitter(a6) lea $dff000,a6 move #$8000,BLTADAT(a6) move #-1,BLTAFWM(a6) move #width,BLTCMOD(a6) move #$FFFF,BLTBDAT(a6) ;$FFFF=draw , $0000=clear ;These values are the same for all lines, no need to tell ;the blitter about them more than once move.l ,a0 moveq #,d7 bsr.s drawem move.l 4.w,a6 move.l (a6),a6 move.l (a6),a6 jmp DisOwnBlitter(a6) drawem: move ,d0 move ,d1 move ,d2 move ,d3 moveq #width,d4 mulu d1,d4 ;This could be sped up by reading a table with values ;0,width,width*2,width*3 etc. moveq #-16,d5 and d0,d5 lsr #3,d5 add d5,d4 add.l a0,d4 moveq #0,d5 sub d1,d3 roxl.b #1,d5 tst d3 bge.s y2gy1 neg d3 y2gy1: sub d0,d2 roxl.b #1,d5 tst d2 bge.s x2gx1 neg d2 x2gx1: move d3,d1 sub d2,d1 bge.s dygdx exg d2,d3 dygdx: roxl.b #1,d5 move.b table(pc,d5.w),d5 add d2,d2 wait: btst #6,DMACONR(a6) bne.s wait move d2,BLTBMOD(a6) sub d3,d2 bge.s signn1 or.b #$40,d5 signn1: move d2,BLTAPT+2(a6) sub d3,d2 move d2,BLTAMOD(a6) and #15,d0 ror #4,d0 or #$bca,d0 move d0,BLTCON0(a6) move d5,BLTCON1(a6) move.l d4,BLTCPT(a6) move.l d4,BLTDPT(a6) addq #1,d3 lsl #6,d3 addq #2,d3 move d3,BLTSIZE(a6) ;GO! dbra d7,drawem ;do next line rts table: dc.b 1,17,9,21,5,25,13,29