home *** CD-ROM | disk | FTP | other *** search
- ; Vector routine starts here
-
- ;····················································
-
- Vector: ;Jump to this every VB
- move.b $dff00b,vector_a2
- move.b $dff00a,vector_a3
- bsr fixplane1
- move.l vector_show,d0
- move.w d0,vectorplane+6 ;Fix the right screen!
- swap d0 ;(Show that one that the gfx
- move.w d0,vectorplane+2 ;NOT is going to be drawed on!)
-
- bsr vanta ;Wait for blitter to be ready
-
- bsr Vector_Clear ;Clear workscreen while calculating
-
- ;the cordinates! (Blitter clear)
- bsr Vector_Rotate ;Rotate values in: (Note: Byte)
- ;Vector_A1, Vector_A2, Vector_A3
-
- move.w #vector_points-1,d2
- lea Vector_Cords(pc),a0 ;Load A0 with adr. of cord. data
- lea Vector_Cords1(pc),a1 ;Load A1 with adr of calc. cord. data
- Calc_Cords:
- move.w (a0)+,Vector_OX ;X Pos
- move.w (a0)+,Vector_OY ;Y Pos
- move.w (a0)+,Vector_OZ ;Z Pos
- bsr VectorCalc
- move.w Vector_xxx,(a1)+ ;Calculated X Pos
- move.w Vector_yyy,(a1)+ ;Calculated Y Pos
- dbf d2,Calc_Cords ;Loop until all cordinates are done
-
- bsr vanta ;Wait for blitter to finnish
- ;the Screen Clearing
- move.w #Vector_Lines-1,d6
- lea Vector_Cords1(pc),a1
- lea vector_Connects(pc),a2
- bsr lineinit
-
- DrawLines:
- clr.l d0
- clr.l d1
- clr.l d2
- clr.l d3
- move.w (a2)+,d4 ;Point 1
- move.w (a2)+,d5 ;Point 2
- asl #2,d4
- asl #2,d5
-
- move.w (a1,d4.w),d0 ;X1
- move.w 2(a1,d4.w),d1 ;Y1
- move.w (a1,d5.w),d2 ;X2
- move.w 2(a1,d5.w),d3 ;Y2
-
- bsr line_draw ;Draw the line
- dbf d6,DrawLines
- rts ;Ready
-
- fixplane1:
- bchg #1,vector_mode
- beq Fix_Planes
- move.l #plane1,vector_show
- move.l #plane2,vector_not_show
- rts
-
- Fix_Planes:
- move.l #plane2,vector_show
- move.l #plane1,vector_not_show
- rts
-
- Vector_Clear:
- move.l vector_not_show,$dff054
- clr.w $dff066
- clr.w $dff042
- move.w #$100,$dff040
- move.w #200*64+20,$dff058
- rts
-
- * Vector formula origanally coded in C by COKE compiled code improved
- * by The Cracker (Better will come?)
-
- Vector_Rotate:
- clr.l d0
- move.b Vector_a1,d0
- move.w d0,d1
- add.w #64,d1
- and.w #255,d1
- asl.w #1,d0
- asl.w #1,d1
- lea Vector_sin,a0
- move.w (a0,d0.w),Vector_kx1
- move.w (a0,d1.w),Vector_ky1
- clr.l d0
- move.b Vector_a2,d0
- move.l d0,d1
- add.w #64,d1
- and.w #255,d1
- asl.w #1,d0
- asl.w #1,d1
- lea Vector_sin,a0
- move.w (a0,d0.w),Vector_kx2
- move.w (a0,d1.w),Vector_ky2
- clr.l d0
- move.b Vector_a3,d0
- move.w d0,d1
- add.w #64,d1
- and.w #255,d1
- asl.w #1,d1
- asl.w #1,d0
- lea Vector_sin,a0
- move.w (a0,d0.w),Vector_kx3
- move.w (a0,d1.w),Vector_ky3
- rts
-
- VectorCalc:
- ;px=(ox*kx1+oy*ky1)/128;
- move.w Vector_ox,d0
- muls Vector_kx1,d0
- move.w Vector_oy,d1
- muls Vector_ky1,d1
- add.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_px
- ;py=(ox*ky1-oy*kx1)/128;
- move.w Vector_ox,d0
- muls Vector_ky1,d0
- move.w Vector_oy,d1
- muls Vector_kx1,d1
- sub.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_py
- ;pz=oz;
- ; move.w Vector_oz,Vector_pz
- ;qx=px;
- ; move.w Vector_px,Vector_qx
- ;qy=(py*kx2+pz*ky2)/128;
- move.w Vector_py,d0
- muls Vector_kx2,d0
- move.w Vector_oz,d1 ;pz
- muls Vector_ky2,d1
- add.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_qy
- ;qz=(py*ky2-pz*kx2)/128;
- move.w Vector_py,d0
- muls Vector_ky2,d0
- move.w Vector_oz,d1 ;pz
- muls Vector_kx2,d1
- sub.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_qz
- ;rx=(qz*ky3-qx*kx3)/128;
- move.w Vector_qz,d0
- muls Vector_ky3,d0
- move.w Vector_px,d1 ;qx
- muls Vector_kx3,d1
- sub.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_rx
- ;ry=qy;
- ; move.w Vector_qy,Vector_ry
- ;rz=(qz*kx3+qx*ky3)/128;
- move.w Vector_qz,d0
- muls Vector_kx3,d0
- move.w Vector_px,d1 ;qx
- muls Vector_ky3,d1
- add.w d1,d0
- ext.l d0
- asr #7,d0
- move.w d0,Vector_rz
- ;xxx=(128*rx/(rz+256))+128;
- move.w Vector_rx,d0
- asl.w #7,d0
- move.w Vector_rz,d1
- add.w #256,d1
- ext.l d0
- divs d1,d0
- add.w #128,d0
- move.w d0,Vector_xxx
- ;yyy=(128*ry/(rz+256))+128;
- move.w Vector_qy,d0 ;ry
- asl.w #7,d0
- move.w Vector_rz,d1
- add.w #256,d1
- ext.l d0
- divs d1,d0
- add.w #128,d0
- move.w d0,Vector_yyy
- rts
-
- line_bredd=40
-
- Vanta:
- btst #14,$dff002
- bne.s vanta
- rts
-
- LineInit:
- lea $dff000,a6 ;required for
- ;the Draw-routine
- move #$8000,$74(a6) ;standard values
- ;for line-drawing
- move #-1,$44(a6)
- move #line_bredd,$60(a6)
- Texture:
- move #$FFFF,$72(a6) ;linepattern :
- ;1=affect this bit
- ;0=not this bit
- rts
-
- Line_Draw:
- move.l vector_not_show,a0 ;start of bitmap
- moveq #line_bredd,d4
- mulu d1,d4
- 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 line_y2gy1
- neg d3
- line_y2gy1:
- sub d0,d2
- roxl.b #1,d5
- tst d2
- bge.s line_x2gx1
- neg d2
- line_x2gx1:
- move d3,d1
- sub d2,d1
- bge.s line_dygdx
- exg d2,d3
- line_dygdx:
- roxl.b #1,d5
- move.b line_table(pc,d5),d5
- add d2,d2
- line_Bwait:
- btst #6,2(a6) ;wait for blitter ?
- bne.s line_Bwait ; ?
- move d2,$62(a6)
- sub d3,d2
- bge.s line_signn1
- or.b #$40,d5
- line_signn1:
- move d2,$52(a6)
- sub d3,d2
- move d2,$64(a6)
- and #15,d0
- ror #4,d0
- or #$bca,d0 ;#$BEA= OR line mode
- ;#$B2A= NOR
- ;#$B6A= XOR
-
- move d0,$40(a6)
- move d5,$42(a6)
- move.l d4,$48(a6)
- move.l d4,$54(a6)
- addq #1,d3
- lsl #6,d3
- addq #2,d3
- move d3,$58(a6) ;Action!
- rts
-
- line_table: dc.b 1,17,9,21,5,25,13,29
-
- Plane1: blk 200*40,0
- plane2: blk 200*40,0
-
- vector_mode: dc.w 0
- vector_show: dc.l 0
- Vector_not_show: dc.l 0
-
- Vector_Sin:
- dc.w 0,3,6,9,12,15,18,21,24,28,31,34,37,40,43,46,48
- dc.w 51,54,57,60,63,65,68,71,73,76,78,81,83,85,88,90
- dc.w 92,94,96,98,100,102,104,106,108,109,111,112,114
- dc.w 115,117,118,119,120,121,122,123,124,124,125,126
- dc.w 126,127,127,127,127,127,127,127,127,127,127,127
- dc.w 126,126,125,124,124,123,122,121,120,119,118,117
- dc.w 115,114,112,111,109,108,106,104,102,100,98,96,94
- dc.w 92,90,88,85,83,81,78,76,73,71,68,65,63,60,57,54
- dc.w 51,48,46,43,40,37,34,31,28,24,21,18,15,12,9,6,3
- dc.w 0,-3,-6,-9,-12,-15,-18,-21,-24,-28,-31,-34,-37
- dc.w -40,-43,-46,-48,-51,-54,-57,-60,-63,-65,-68,-71
- dc.w -73,-76,-78,-81,-83,-85,-88,-90,-92,-94,-96,-98
- dc.w -100,-102,-104,-106,-108,-109,-111,-112,-114,-115
- dc.w -117,-118,-119,-120,-121,-122,-123,-124,-124,-125
- dc.w -126,-126,-127,-127,-127,-127,-127,-127,-127,-127
- dc.w -127,-127,-127,-126,-126,-125,-124,-124,-123,-122
- dc.w -121,-120,-119,-118,-117,-115,-114,-112,-111,-109
- dc.w -108,-106,-104,-102,-100,-98,-96,-94,-92,-90,-88
- dc.w -85,-83,-81,-78,-76,-73,-71,-68,-65,-63,-60,-57
- dc.w -54,-51,-48,-46,-43,-40,-37,-34,-31,-28,-24,-21
- dc.w -18,-15,-12,-9,-6,-3
-
- Vector_kx1:
- dc.w 0
- Vector_ky1:
- dc.w 0
- Vector_kx2:
- dc.w 0
- Vector_ky2:
- dc.w 0
- Vector_kx3:
- dc.w 0
- Vector_ky3:
- dc.w 0
- Vector_xxx:
- dc.w 0
- Vector_yyy:
- dc.w 0
- Vector_a1:
- dc.w 0
- Vector_a2:
- dc.w 0
- Vector_a3:
- dc.w 0
- Vector_ox:
- dc.w 0
- Vector_oy:
- dc.w 0
- Vector_oz:
- dc.w 0
- Vector_px:
- dc.w 0
- Vector_py:
- dc.w 0
- Vector_pz:
- dc.w 0
- Vector_qx:
- dc.w 0
- Vector_qy:
- dc.w 0
- Vector_qz:
- dc.w 0
- Vector_rx:
- dc.w 0
- Vector_ry:
- dc.w 0
- Vector_rz:
- dc.w 0
-
- Vector_Cords:
- ; Cordinates of the object:
- ; X,Y,Z
- Vector_Points:= 8 ;Numbers of points
-
- dc.w -50,-50,50
- dc.w 50,-50,50
- dc.w 50,50,50
- dc.w -50,50,50
- dc.w -50,-50,-50
- dc.w 50,-50,-50
- dc.w 50,50,-50
- dc.w -50,50,-50
- ;-------------------------------------
-
- Vector_Connects:
- ; List of connecting points:
- ; P1,P2
- Vector_Lines:= 12 ;Numbers of lines
-
- dc.w 0,3
- dc.w 3,2
- dc.w 2,1
- dc.w 1,0
- dc.w 4,5
- dc.w 5,6
- dc.w 6,7
- dc.w 7,4
- dc.w 0,4
- dc.w 1,5
- dc.w 2,6
- dc.w 3,7
-
- Vector_Cords1: blk.l vector_points,0 ;(Data in order X.w Y.w Etc)
-
- Vectorplane: ;Add this
- dc.l $00e00006,$00e20000 ;To your copperlist
-
- ; Vector routine ends here!