home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src6.dms / in.adf / BOUNCHSRCS.LZH / vector2.S < prev    next >
Encoding:
Text File  |  1987-05-18  |  7.6 KB  |  392 lines

  1. ; Vector routine starts here
  2.  
  3. ;····················································
  4.  
  5. Vector:                ;Jump to this every VB
  6. move.b $dff00b,vector_a2
  7. move.b $dff00a,vector_a3
  8. bsr fixplane1
  9. move.l vector_show,d0
  10. move.w d0,vectorplane+6        ;Fix the right screen!
  11. swap d0                ;(Show that one that the gfx
  12. move.w d0,vectorplane+2        ;NOT is going to be drawed on!)
  13.  
  14. bsr vanta            ;Wait for blitter to be ready
  15.  
  16. bsr Vector_Clear        ;Clear workscreen while calculating
  17.  
  18.                 ;the cordinates! (Blitter clear)
  19. bsr Vector_Rotate        ;Rotate values in:    (Note: Byte)
  20.                 ;Vector_A1, Vector_A2, Vector_A3
  21.  
  22. move.w #vector_points-1,d2
  23. lea Vector_Cords(pc),a0        ;Load A0 with adr. of cord. data
  24. lea Vector_Cords1(pc),a1    ;Load A1 with adr of calc. cord. data
  25. Calc_Cords:
  26. move.w (a0)+,Vector_OX        ;X Pos
  27. move.w (a0)+,Vector_OY        ;Y Pos
  28. move.w (a0)+,Vector_OZ        ;Z Pos
  29. bsr VectorCalc
  30. move.w Vector_xxx,(a1)+        ;Calculated X Pos
  31. move.w Vector_yyy,(a1)+        ;Calculated Y Pos
  32. dbf d2,Calc_Cords        ;Loop until all cordinates are done
  33.  
  34. bsr vanta            ;Wait for blitter to finnish
  35.                 ;the Screen Clearing
  36. move.w #Vector_Lines-1,d6
  37. lea Vector_Cords1(pc),a1
  38. lea vector_Connects(pc),a2
  39. bsr lineinit
  40.  
  41. DrawLines:
  42. clr.l d0
  43. clr.l d1
  44. clr.l d2
  45. clr.l d3
  46. move.w (a2)+,d4            ;Point 1
  47. move.w (a2)+,d5            ;Point 2
  48. asl #2,d4
  49. asl #2,d5
  50.  
  51. move.w (a1,d4.w),d0        ;X1
  52. move.w 2(a1,d4.w),d1        ;Y1
  53. move.w (a1,d5.w),d2        ;X2
  54. move.w 2(a1,d5.w),d3        ;Y2
  55.  
  56. bsr line_draw            ;Draw the line
  57. dbf d6,DrawLines
  58. rts                ;Ready
  59.  
  60. fixplane1:
  61. bchg #1,vector_mode
  62. beq Fix_Planes
  63. move.l #plane1,vector_show
  64. move.l #plane2,vector_not_show
  65. rts
  66.  
  67. Fix_Planes:
  68. move.l #plane2,vector_show
  69. move.l #plane1,vector_not_show
  70. rts
  71.  
  72. Vector_Clear: 
  73. move.l vector_not_show,$dff054
  74. clr.w $dff066
  75. clr.w $dff042
  76. move.w #$100,$dff040
  77. move.w #200*64+20,$dff058
  78. rts
  79.  
  80. * Vector formula origanally coded in C by COKE compiled code improved
  81. * by The Cracker (Better will come?)
  82.  
  83. Vector_Rotate:
  84.    clr.l   d0
  85.    move.b   Vector_a1,d0
  86.    move.w d0,d1
  87.    add.w   #64,d1
  88.    and.w   #255,d1
  89.    asl.w   #1,d0
  90.    asl.w   #1,d1
  91.    lea   Vector_sin,a0
  92.    move.w   (a0,d0.w),Vector_kx1
  93.    move.w   (a0,d1.w),Vector_ky1
  94.    clr.l   d0
  95.    move.b   Vector_a2,d0
  96.    move.l d0,d1
  97.    add.w #64,d1
  98.    and.w #255,d1
  99.    asl.w   #1,d0
  100.    asl.w   #1,d1
  101.    lea   Vector_sin,a0
  102.    move.w   (a0,d0.w),Vector_kx2
  103.    move.w   (a0,d1.w),Vector_ky2
  104.    clr.l   d0
  105.    move.b   Vector_a3,d0
  106.    move.w   d0,d1
  107.    add.w   #64,d1
  108.    and.w   #255,d1
  109.    asl.w   #1,d1
  110.    asl.w   #1,d0
  111.    lea   Vector_sin,a0
  112.    move.w   (a0,d0.w),Vector_kx3
  113.    move.w   (a0,d1.w),Vector_ky3
  114.    rts
  115.  
  116. VectorCalc:
  117. ;px=(ox*kx1+oy*ky1)/128;
  118.    move.w   Vector_ox,d0
  119.    muls   Vector_kx1,d0
  120.    move.w   Vector_oy,d1
  121.    muls   Vector_ky1,d1
  122.    add.w   d1,d0
  123.    ext.l   d0
  124.    asr #7,d0
  125.    move.w   d0,Vector_px
  126. ;py=(ox*ky1-oy*kx1)/128;
  127.    move.w   Vector_ox,d0
  128.    muls   Vector_ky1,d0
  129.    move.w   Vector_oy,d1
  130.    muls   Vector_kx1,d1
  131.    sub.w   d1,d0
  132.    ext.l   d0
  133.    asr #7,d0
  134.    move.w   d0,Vector_py
  135. ;pz=oz;
  136. ;   move.w   Vector_oz,Vector_pz
  137. ;qx=px;
  138. ;   move.w   Vector_px,Vector_qx
  139. ;qy=(py*kx2+pz*ky2)/128;
  140.    move.w   Vector_py,d0
  141.    muls   Vector_kx2,d0
  142.    move.w   Vector_oz,d1        ;pz
  143.    muls   Vector_ky2,d1
  144.    add.w   d1,d0
  145.    ext.l   d0
  146.    asr #7,d0
  147.    move.w   d0,Vector_qy
  148. ;qz=(py*ky2-pz*kx2)/128;
  149.    move.w   Vector_py,d0
  150.    muls   Vector_ky2,d0
  151.    move.w   Vector_oz,d1        ;pz
  152.    muls   Vector_kx2,d1
  153.    sub.w   d1,d0
  154.    ext.l   d0
  155.    asr #7,d0
  156.    move.w   d0,Vector_qz
  157. ;rx=(qz*ky3-qx*kx3)/128;
  158.    move.w   Vector_qz,d0
  159.    muls   Vector_ky3,d0
  160.    move.w   Vector_px,d1    ;qx
  161.    muls   Vector_kx3,d1
  162.    sub.w   d1,d0
  163.    ext.l   d0
  164.    asr #7,d0
  165.    move.w   d0,Vector_rx
  166. ;ry=qy;
  167. ;   move.w   Vector_qy,Vector_ry
  168. ;rz=(qz*kx3+qx*ky3)/128;
  169.    move.w   Vector_qz,d0
  170.    muls   Vector_kx3,d0
  171.    move.w   Vector_px,d1    ;qx
  172.    muls   Vector_ky3,d1
  173.    add.w   d1,d0
  174.    ext.l   d0
  175.    asr #7,d0
  176.    move.w   d0,Vector_rz
  177. ;xxx=(128*rx/(rz+256))+128;
  178.    move.w   Vector_rx,d0
  179.    asl.w   #7,d0
  180.    move.w   Vector_rz,d1
  181.    add.w   #256,d1
  182.    ext.l   d0
  183.    divs   d1,d0
  184.    add.w   #128,d0
  185.    move.w   d0,Vector_xxx
  186. ;yyy=(128*ry/(rz+256))+128;
  187.    move.w   Vector_qy,d0        ;ry
  188.    asl.w   #7,d0
  189.    move.w   Vector_rz,d1
  190.    add.w   #256,d1
  191.    ext.l   d0
  192.    divs   d1,d0
  193.    add.w   #128,d0
  194.    move.w   d0,Vector_yyy
  195.    rts
  196.  
  197. line_bredd=40
  198.  
  199. Vanta:
  200. btst    #14,$dff002
  201. bne.s    vanta
  202. rts
  203.  
  204. LineInit:
  205.     lea    $dff000,a6    ;required for
  206.                 ;the Draw-routine
  207.     move    #$8000,$74(a6)    ;standard values
  208.                 ;for line-drawing
  209.     move    #-1,$44(a6)
  210.     move    #line_bredd,$60(a6)
  211. Texture:
  212.     move    #$FFFF,$72(a6)    ;linepattern :
  213.                 ;1=affect this bit
  214.                 ;0=not this bit
  215.     rts
  216.  
  217. Line_Draw:
  218.     move.l    vector_not_show,a0    ;start of bitmap
  219.     moveq    #line_bredd,d4
  220.     mulu    d1,d4
  221.     moveq    #-16,d5
  222.     and    d0,d5
  223.     lsr    #3,d5
  224.     add    d5,d4
  225.     add.l    a0,d4
  226.     moveq    #0,d5
  227.     sub    d1,d3
  228.     roxl.b    #1,d5
  229.     tst    d3
  230.     bge.s    line_y2gy1
  231.     neg    d3
  232. line_y2gy1:
  233.     sub    d0,d2
  234.     roxl.b    #1,d5
  235.     tst    d2
  236.     bge.s    line_x2gx1
  237.     neg    d2
  238. line_x2gx1:
  239.     move    d3,d1
  240.     sub    d2,d1
  241.     bge.s    line_dygdx
  242.     exg    d2,d3
  243. line_dygdx:
  244.     roxl.b    #1,d5
  245.     move.b    line_table(pc,d5),d5
  246.     add    d2,d2
  247. line_Bwait:
  248.     btst    #6,2(a6)    ;wait for blitter    ?
  249.     bne.s    line_Bwait    ;            ?
  250.     move    d2,$62(a6)
  251.     sub    d3,d2
  252.     bge.s    line_signn1
  253.     or.b    #$40,d5
  254. line_signn1:
  255.     move    d2,$52(a6)
  256.     sub    d3,d2
  257.     move    d2,$64(a6)
  258.     and    #15,d0
  259.     ror    #4,d0
  260.     or    #$bca,d0    ;#$BEA= OR  line mode
  261.                 ;#$B2A= NOR
  262.                 ;#$B6A= XOR
  263.  
  264.     move    d0,$40(a6)
  265.     move    d5,$42(a6)
  266.     move.l    d4,$48(a6)
  267.     move.l    d4,$54(a6)
  268.     addq    #1,d3
  269.     lsl    #6,d3
  270.     addq    #2,d3
  271.     move    d3,$58(a6)    ;Action!
  272.     rts
  273.  
  274. line_table:    dc.b 1,17,9,21,5,25,13,29    
  275.  
  276. Plane1: blk 200*40,0
  277. plane2: blk 200*40,0
  278.  
  279. vector_mode: dc.w 0
  280. vector_show: dc.l 0
  281. Vector_not_show: dc.l 0
  282.  
  283. Vector_Sin:
  284. dc.w 0,3,6,9,12,15,18,21,24,28,31,34,37,40,43,46,48
  285. dc.w 51,54,57,60,63,65,68,71,73,76,78,81,83,85,88,90
  286. dc.w 92,94,96,98,100,102,104,106,108,109,111,112,114
  287. dc.w 115,117,118,119,120,121,122,123,124,124,125,126
  288. dc.w 126,127,127,127,127,127,127,127,127,127,127,127
  289. dc.w 126,126,125,124,124,123,122,121,120,119,118,117
  290. dc.w 115,114,112,111,109,108,106,104,102,100,98,96,94
  291. dc.w 92,90,88,85,83,81,78,76,73,71,68,65,63,60,57,54
  292. dc.w 51,48,46,43,40,37,34,31,28,24,21,18,15,12,9,6,3
  293. dc.w 0,-3,-6,-9,-12,-15,-18,-21,-24,-28,-31,-34,-37
  294. dc.w -40,-43,-46,-48,-51,-54,-57,-60,-63,-65,-68,-71
  295. dc.w -73,-76,-78,-81,-83,-85,-88,-90,-92,-94,-96,-98
  296. dc.w -100,-102,-104,-106,-108,-109,-111,-112,-114,-115
  297. dc.w -117,-118,-119,-120,-121,-122,-123,-124,-124,-125
  298. dc.w -126,-126,-127,-127,-127,-127,-127,-127,-127,-127
  299. dc.w -127,-127,-127,-126,-126,-125,-124,-124,-123,-122
  300. dc.w -121,-120,-119,-118,-117,-115,-114,-112,-111,-109
  301. dc.w -108,-106,-104,-102,-100,-98,-96,-94,-92,-90,-88
  302. dc.w -85,-83,-81,-78,-76,-73,-71,-68,-65,-63,-60,-57
  303. dc.w -54,-51,-48,-46,-43,-40,-37,-34,-31,-28,-24,-21
  304. dc.w -18,-15,-12,-9,-6,-3
  305.  
  306. Vector_kx1:
  307.    dc.w  0 
  308. Vector_ky1:
  309.    dc.w  0 
  310. Vector_kx2:
  311.    dc.w  0
  312. Vector_ky2:
  313.    dc.w  0
  314. Vector_kx3:
  315.    dc.w  0
  316. Vector_ky3:
  317.    dc.w  0
  318. Vector_xxx:
  319.    dc.w  0
  320. Vector_yyy:
  321.    dc.w  0
  322. Vector_a1:
  323.    dc.w  0
  324. Vector_a2:
  325.    dc.w  0
  326. Vector_a3:
  327.    dc.w  0
  328. Vector_ox:
  329.    dc.w  0 
  330. Vector_oy:
  331.    dc.w  0
  332. Vector_oz:
  333.    dc.w  0
  334. Vector_px:
  335.    dc.w  0
  336. Vector_py:
  337.    dc.w  0
  338. Vector_pz:
  339.    dc.w  0
  340. Vector_qx:
  341.    dc.w  0
  342. Vector_qy:
  343.    dc.w  0
  344. Vector_qz:
  345.    dc.w  0
  346. Vector_rx:
  347.    dc.w  0
  348. Vector_ry:
  349.    dc.w  0
  350. Vector_rz:
  351.    dc.w  0
  352.  
  353. Vector_Cords:
  354. ; Cordinates of the object:
  355. ; X,Y,Z
  356. Vector_Points:= 8    ;Numbers of points
  357.  
  358. dc.w -50,-50,50
  359. dc.w 50,-50,50
  360. dc.w 50,50,50
  361. dc.w -50,50,50
  362. dc.w -50,-50,-50
  363. dc.w 50,-50,-50
  364. dc.w 50,50,-50
  365. dc.w -50,50,-50
  366. ;-------------------------------------
  367.  
  368. Vector_Connects:
  369. ; List of connecting points:
  370. ; P1,P2
  371. Vector_Lines:= 12    ;Numbers of lines
  372.  
  373. dc.w 0,3
  374. dc.w 3,2
  375. dc.w 2,1
  376. dc.w 1,0
  377. dc.w 4,5
  378. dc.w 5,6
  379. dc.w 6,7
  380. dc.w 7,4
  381. dc.w 0,4
  382. dc.w 1,5
  383. dc.w 2,6
  384. dc.w 3,7
  385.  
  386. Vector_Cords1: blk.l vector_points,0 ;(Data in order X.w Y.w Etc)
  387.  
  388. Vectorplane:            ;Add this 
  389. dc.l $00e00006,$00e20000    ;To your copperlist
  390.  
  391. ; Vector routine ends here!
  392.