home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / DEMOS / MEGADEMO / PASSIONP.ARJ / PASSIONP.MSA / BOTH / BOTH.S next >
Text File  |  1997-03-05  |  15KB  |  698 lines

  1. ; *************************************************************************
  2. ; ****                       ****
  3. ; ****        Shaded - Mapped cube.           ****
  4. ; ****              By Alain BROBECKER           ****
  5. ; ****         Coded Between 22nd and 30th of june 1994.           ****
  6. ; ****                       ****
  7. ; *************************************************************************
  8. nb_brows    equ 8
  9.  
  10. supervisor:
  11.   move.l    #$0,-(sp)
  12.   move.w    #$20,-(sp)
  13.   trap    #$1
  14.   addq.l    #$6,sp
  15.  
  16. initialisations:    
  17.   dc.w    $a00a    ; Fuck the mouse.
  18.   move.b    #$12,$fffffc02.w
  19.   move.b    $484.w,old_conterm
  20.   clr.b    $484.w    ; No bip, no repeat.
  21.   move.l    $114.w,old_timerc ; Unusefull for a demo.
  22.   move.l    #null_timerc,$114.w ; Put a "null" routine.
  23.   move.l    $70.w,old_vbl    ; I have to use my own Vbl.
  24.   move.l    #null_vbl,$70.w    ; A "null" vbl for the moment.
  25.  
  26.   move.w    #$25,-(sp) 
  27.   trap    #$e    ; Vsync
  28.   addq.l    #$2,sp
  29.   move.b    $ffff8260.w,old_rez ; Save screen features.
  30.   move.b    $ffff8201.w,old_screen
  31.   move.b    $ffff8203.w,old_screen+1
  32.   move.b    $ffff820d.w,old_screen+2
  33.  
  34.   move.b    #$0,$ffff8260.w
  35.  
  36.   move.l    #screen1,d0
  37.   move.l    d0,d1
  38.   swap.w    d0
  39.   move.b    d0,$ffff8201.w
  40.   swap.w    d0
  41.   rol.w    #$8,d0
  42.   move.b    d0,$ffff8203.w
  43.   move.b    d1,$ffff820d.w
  44.  
  45. ; Put our colors:
  46.   move.l    #colors,a0
  47.   move.w    #$8240,a1
  48.  rept    8
  49.   move.l    (a0)+,(a1)+
  50.  endr
  51.  
  52. ; *************************************************************************
  53.  
  54. convert_wood:        ; The initial image is planar, so..
  55.   move.l    #bois,a0
  56.   move.l    #wood,a1
  57.   move.w    #1023,d7
  58. .conv_16:
  59.   move.w    (a0)+,d0
  60.  rept    16
  61.   add.w    d0,d0
  62.   addx.b    d4,d4
  63.   lsl.w    #$7,d4
  64.   move.b    d4,(a1)+
  65.  endr
  66.   dbra    d7,.conv_16
  67.   
  68.   
  69. ; *************************************************************************
  70.  
  71.   move.l    #$0,$466.w
  72.  
  73. vbl_one:
  74.   jsr    wait_vbl
  75.   move.l    #screen1,a6
  76.  
  77. .clear_box:
  78.   move.l    a6,a0
  79.   move.l    #old_box1,a1
  80.   move.w    (a1)+,d0    ; Extremities of the box to clear.
  81.   move.w    (a1)+,d1
  82.   move.w    (a1)+,d2
  83.   move.w    (a1)+,d3
  84.   jsr    clear_4_bpl
  85.  
  86. .angles:
  87.   move.w    angle1,d0
  88.   addq.w    #$5,d0
  89.   and.w    #$ff,d0
  90.   move.w    d0,angle1
  91.   move.w    angle2,d1
  92.   addq.w    #$2,d1
  93.   and.w    #$ff,d1
  94.   move.w    d1,angle2
  95.  
  96. .rotation:
  97.   move.l    #object_brows,a0
  98.   move.l    #new_coords,a1
  99.   jsr    rotation
  100.  
  101. .calc_intensities:
  102.   move.l    #new_coords,a0
  103.   move.l    a0,a1
  104.   moveq.l    #nb_brows,d0
  105.   subq.w    #$1,d0
  106.   move.w    #159,d6    ; For recentering.
  107.   move.w    y_pos,d7
  108.   move.l    #y_positions,a2
  109.   move.w    (a2,d7.w),d7
  110.   move.l    #inverses,a2
  111.  
  112. .one_brow:
  113.   move.w    (a0)+,d1    ; d1=x.
  114.   move.w    (a0)+,d2    ; d2=y.
  115.   move.w    (a0)+,d3    ; d3=z.
  116.   move.w    d3,d4
  117.   add.w    #$100,d3    ; d3=z+256.
  118.   add.w    d3,d3
  119.   move.w    (a2,d3.w),d3    ; d3=16384/(z+256).
  120.   muls.w    d3,d1
  121.   lsr.l    #$6,d1    ; d1=x*256/(z+256).
  122.   add.w    d6,d1    ; Recenter.
  123.   move.w    d1,(a1)+    ; Save.
  124.   muls.w    d3,d2
  125.   lsr.l    #$6,d2    ; d2=y*256/(z+256).
  126.   add.w    d7,d2    ; Recenter.
  127.   move.w    d2,(a1)+    ; Save.
  128.   neg.w    d4
  129.   add.w    #8,d4    ; d4=z+8.
  130.   bpl.s    .ok
  131.   moveq.l    #$0,d4
  132. .ok:
  133.   add.w    #%10000,d4
  134.   lsl.w    #$4,d4
  135.   lsl.w    #$5,d4    ; d4=intensity.
  136.   move.w    d4,(a1)+
  137.   dbra    d0,.one_brow
  138.   
  139. .search_box:
  140.   move.l    #new_coords,a0
  141.   move.w    (a0)+,d0
  142.   move.w    d0,d1    ; x1=x2=first x.
  143.   move.w    (a0)+,d2
  144.   move.w    d2,d3    ; y1=y2=first y.
  145.   moveq.l    #nb_brows,d7
  146.   subq.l    #$2,d7
  147. .search:
  148.   move.l    (a0)+,d4    ; d4=x.
  149.   move.w    (a0)+,d5    ; d5=y.
  150.   cmp.w    d0,d4    ; x<x1?
  151.   bge.s    .no_x1
  152.   move.w    d4,d0
  153. .no_x1:
  154.   cmp.w    d1,d4    ; x>x2?
  155.   ble.s    .no_x2
  156.   move.w    d4,d1
  157. .no_x2:
  158.   cmp.w    d2,d5    ; y<y1?
  159.   bge.s    .no_y1
  160.   move.w    d5,d2
  161. .no_y1:
  162.   cmp.w    d3,d5    ; y>y2?
  163.   ble.s    .no_y2
  164.   move.w    d5,d3
  165. .no_y2:
  166.   dbra    d7,.search
  167.   move.l    #old_box1,a0
  168.   movem.w    d0-3,(a0)    ; Save the box.
  169.  
  170. .print_cube:
  171.   move.l    a6,a0
  172.   move.l    #object_faces,a2
  173.   move.l    #new_coords,a3
  174.   move.w    (a2)+,d7    ; Nb of faces.
  175.   subq.w    #$1,d7
  176. .one_face:
  177.   move.w    (a2)+,d6    ; Nb of points for this face.
  178.   move.w    d6,d0
  179.   move.l    #face_coords,a1
  180.   subq.l    #$1,d6
  181. .one_coord:
  182.   move.w    (a2)+,d1
  183.   move.l    (a3,d1.w),(a1)+
  184.   move.w    $4(a3,d1.w),(a1)+
  185.   dbra    d6,.one_coord
  186. .test_visibility:
  187.   move.l    #face_coords,a1
  188.   move.w    (a1)+,d1    ; x1.
  189.   move.w    (a1)+,d2    ; y1.
  190.   addq.w    #$2,a1
  191.   move.w    (a1)+,d3    ; x2.
  192.   move.w    (a1)+,d4    ; y2.
  193.   addq.w    #$2,a1
  194.   move.w    (a1)+,d5    ; x3.
  195.   move.w    (a1)+,d6    ; y3.
  196.   sub.w    d3,d1    ; d1=x1-x2.
  197.   sub.w    d4,d2    ; d2=y1-y2.
  198.   sub.w    d3,d5    ; d5=x3-x2.
  199.   sub.w    d4,d6    ; d6=y3-y2.
  200.   muls.w    d1,d6
  201.   muls.w    d2,d5
  202.   sub.l    d5,d6    ; d6=(x1-x2)*(y3-y2)-(y1-y2)*(x3-x2).
  203.   ble.s    .next_face
  204. .visible:
  205.   move.l    #face_coords,a1
  206.   jsr    shaded_poly
  207. .next_face:
  208.   dbra    d7,.one_face
  209.  
  210. print_cube2:
  211.   move.l    a6,a0
  212.   addq.l    #$6,a0
  213.   move.l    #object_faces2,a4
  214.   move.l    #new_coords,a3
  215.   move.w    (a4)+,d7    ; Nb of faces.
  216.   subq.w    #$1,d7
  217. .one_face:
  218.   moveq.w    #$4,d6    ; Always 4 points per face.
  219.   move.w    d6,d0
  220.   move.l    #face_coords,a1
  221. .copy_coords:
  222.   move.w    (a4)+,d1    ; Nb of the brow.
  223.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  224.   move.l    #$0,(a1)+    ; src_x=0, src_y=0.
  225.   move.w    (a4)+,d1    ; Nb of the brow.
  226.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  227.   move.l    #$7f,(a1)+    ; src_x=0, src_y=128.
  228.   move.w    (a4)+,d1    ; Nb of the brow.
  229.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  230.   move.l    #$7f007f,(a1)+    ; src_x=128, src_y=128.
  231.   move.w    (a4)+,d1    ; Nb of the brow.
  232.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  233.   move.l    #$7f0000,(a1)+    ; src_x=128, src_y=0.
  234. .test_visibility:
  235.   move.l    #face_coords,a1
  236.   move.w    (a1)+,d1    ; x1.
  237.   move.w    (a1)+,d2    ; y1.
  238.   addq.w    #$4,a1
  239.   move.w    (a1)+,d3    ; x2.
  240.   move.w    (a1)+,d4    ; y2.
  241.   addq.w    #$4,a1
  242.   move.w    (a1)+,d5    ; x3.
  243.   move.w    (a1)+,d6    ; y3.
  244.   sub.w    d3,d1    ; d1=x1-x2.
  245.   sub.w    d4,d2    ; d2=y1-y2.
  246.   sub.w    d3,d5    ; d5=x3-x2.
  247.   sub.w    d4,d6    ; d6=y3-y2.
  248.   muls.w    d1,d6
  249.   muls.w    d2,d5
  250.   sub.l    d5,d6    ; d6=(x1-x2)*(y3-y2)-(y1-y2)*(x3-x2).
  251.   ble.s    .next_face
  252. .visible:
  253.   move.l    #face_coords,a1
  254.   move.l    #wood,a2
  255.   jsr    mapped_poly
  256. .next_face:
  257.   dbra    d7,.one_face
  258.  
  259.   addq.w    #$2,y_pos
  260.   
  261.   move.l    a6,d0
  262.   move.l    d0,d1
  263.   swap.w    d0
  264.   move.b    d0,$ffff8201.w
  265.   swap.w    d0
  266.   rol.w    #$8,d0
  267.   move.b    d0,$ffff8203.w
  268.   move.b    d1,$ffff820d.w
  269.  
  270. vbl_two:
  271.   jsr    wait_vbl
  272.   move.l    #screen2,a6
  273.  
  274. .clear_box:
  275.   move.l    a6,a0
  276.   move.l    #old_box2,a1
  277.   move.w    (a1)+,d0    ; Extremities of the box to clear.
  278.   move.w    (a1)+,d1
  279.   move.w    (a1)+,d2
  280.   move.w    (a1)+,d3
  281.   jsr    clear_4_bpl
  282.  
  283. .angles:
  284.   move.w    angle1,d0
  285.   addq.w    #$5,d0
  286.   and.w    #$ff,d0
  287.   move.w    d0,angle1
  288.   move.w    angle2,d1
  289.   addq.w    #$2,d1
  290.   and.w    #$ff,d1
  291.   move.w    d1,angle2
  292.  
  293. .rotation:
  294.   move.l    #object_brows,a0
  295.   move.l    #new_coords,a1
  296.   jsr    rotation
  297.  
  298. .calc_intensities:
  299.   move.l    #new_coords,a0
  300.   move.l    a0,a1
  301.   moveq.l    #nb_brows,d0
  302.   subq.w    #$1,d0
  303.   move.w    #159,d6    ; For recentering.
  304.   move.w    y_pos,d7
  305.   move.l    #y_positions,a2
  306.   move.w    (a2,d7.w),d7
  307.   move.l    #inverses,a2
  308.  
  309. .one_brow:
  310.   move.w    (a0)+,d1    ; d1=x.
  311.   move.w    (a0)+,d2    ; d2=y.
  312.   move.w    (a0)+,d3    ; d3=z.
  313.   move.w    d3,d4
  314.   add.w    #$100,d3    ; d3=z+256.
  315.   add.w    d3,d3
  316.   move.w    (a2,d3.w),d3    ; d3=16384/(z+256).
  317.   muls.w    d3,d1
  318.   lsr.l    #$6,d1    ; d1=x*256/(z+256).
  319.   add.w    d6,d1    ; Recenter.
  320.   move.w    d1,(a1)+    ; Save.
  321.   muls.w    d3,d2
  322.   lsr.l    #$6,d2    ; d2=y*256/(z+256).
  323.   add.w    d7,d2    ; Recenter.
  324.   move.w    d2,(a1)+    ; Save.
  325.   neg.w    d4
  326.   add.w    #8,d4    ; d4=z+8.
  327.   bpl.s    .ok
  328.   moveq.l    #$0,d4
  329. .ok:
  330.   add.w    #%10000,d4
  331.   lsl.w    #$4,d4
  332.   lsl.w    #$5,d4    ; d4=intensity.
  333.   move.w    d4,(a1)+
  334.   dbra    d0,.one_brow
  335.   
  336. .search_box:
  337.   move.l    #new_coords,a0
  338.   move.w    (a0)+,d0
  339.   move.w    d0,d1    ; x1=x2=first x.
  340.   move.w    (a0)+,d2
  341.   move.w    d2,d3    ; y1=y2=first y.
  342.   moveq.l    #nb_brows,d7
  343.   subq.l    #$2,d7
  344. .search:
  345.   move.l    (a0)+,d4    ; d4=x.
  346.   move.w    (a0)+,d5    ; d5=y.
  347.   cmp.w    d0,d4    ; x<x1?
  348.   bge.s    .no_x1
  349.   move.w    d4,d0
  350. .no_x1:
  351.   cmp.w    d1,d4    ; x>x2?
  352.   ble.s    .no_x2
  353.   move.w    d4,d1
  354. .no_x2:
  355.   cmp.w    d2,d5    ; y<y1?
  356.   bge.s    .no_y1
  357.   move.w    d5,d2
  358. .no_y1:
  359.   cmp.w    d3,d5    ; y>y2?
  360.   ble.s    .no_y2
  361.   move.w    d5,d3
  362. .no_y2:
  363.   dbra    d7,.search
  364.   move.l    #old_box2,a0
  365.   movem.w    d0-3,(a0)    ; Save the box.
  366.  
  367. .print_cube:
  368.   move.l    a6,a0
  369.   move.l    #object_faces,a2
  370.   move.l    #new_coords,a3
  371.   move.w    (a2)+,d7    ; Nb of faces.
  372.   subq.w    #$1,d7
  373. .one_face:
  374.   move.w    (a2)+,d6    ; Nb of points for this face.
  375.   move.w    d6,d0
  376.   move.l    #face_coords,a1
  377.   subq.l    #$1,d6
  378. .one_coord:
  379.   move.w    (a2)+,d1
  380.   move.l    (a3,d1.w),(a1)+
  381.   move.w    $4(a3,d1.w),(a1)+
  382.   dbra    d6,.one_coord
  383. .test_visibility:
  384.   move.l    #face_coords,a1
  385.   move.w    (a1)+,d1    ; x1.
  386.   move.w    (a1)+,d2    ; y1.
  387.   addq.w    #$2,a1
  388.   move.w    (a1)+,d3    ; x2.
  389.   move.w    (a1)+,d4    ; y2.
  390.   addq.w    #$2,a1
  391.   move.w    (a1)+,d5    ; x3.
  392.   move.w    (a1)+,d6    ; y3.
  393.   sub.w    d3,d1    ; d1=x1-x2.
  394.   sub.w    d4,d2    ; d2=y1-y2.
  395.   sub.w    d3,d5    ; d5=x3-x2.
  396.   sub.w    d4,d6    ; d6=y3-y2.
  397.   muls.w    d1,d6
  398.   muls.w    d2,d5
  399.   sub.l    d5,d6    ; d6=(x1-x2)*(y3-y2)-(y1-y2)*(x3-x2).
  400.   ble.s    .next_face
  401. .visible:
  402.   move.l    #face_coords,a1
  403.   jsr    shaded_poly
  404. .next_face:
  405.   dbra    d7,.one_face
  406.  
  407. print_cube3:
  408.   move.l    a6,a0
  409.   addq.l    #$6,a0
  410.   move.l    #object_faces2,a4
  411.   move.l    #new_coords,a3
  412.   move.w    (a4)+,d7    ; Nb of faces.
  413.   subq.w    #$1,d7
  414. .one_face:
  415.   moveq.w    #$4,d6    ; Always 4 points per face.
  416.   move.w    d6,d0
  417.   move.l    #face_coords,a1
  418. .copy_coords:
  419.   move.w    (a4)+,d1    ; Nb of the brow.
  420.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  421.   move.l    #$0,(a1)+    ; src_x=0, src_y=0.
  422.   move.w    (a4)+,d1    ; Nb of the brow.
  423.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  424.   move.l    #$7f,(a1)+    ; src_x=0, src_y=128.
  425.   move.w    (a4)+,d1    ; Nb of the brow.
  426.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  427.   move.l    #$7f007f,(a1)+    ; src_x=128, src_y=128.
  428.   move.w    (a4)+,d1    ; Nb of the brow.
  429.   move.l    (a3,d1.w),(a1)+    ; Copy x and y.
  430.   move.l    #$7f0000,(a1)+    ; src_x=128, src_y=0.
  431. .test_visibility:
  432.   move.l    #face_coords,a1
  433.   move.w    (a1)+,d1    ; x1.
  434.   move.w    (a1)+,d2    ; y1.
  435.   addq.w    #$4,a1
  436.   move.w    (a1)+,d3    ; x2.
  437.   move.w    (a1)+,d4    ; y2.
  438.   addq.w    #$4,a1
  439.   move.w    (a1)+,d5    ; x3.
  440.   move.w    (a1)+,d6    ; y3.
  441.   sub.w    d3,d1    ; d1=x1-x2.
  442.   sub.w    d4,d2    ; d2=y1-y2.
  443.   sub.w    d3,d5    ; d5=x3-x2.
  444.   sub.w    d4,d6    ; d6=y3-y2.
  445.   muls.w    d1,d6
  446.   muls.w    d2,d5
  447.   sub.l    d5,d6    ; d6=(x1-x2)*(y3-y2)-(y1-y2)*(x3-x2).
  448.   ble.s    .next_face
  449. .visible:
  450.   move.l    #face_coords,a1
  451.   move.l    #wood,a2
  452.   jsr    mapped_poly
  453. .next_face:
  454.   dbra    d7,.one_face
  455.  
  456.   addq.w    #$2,y_pos
  457.   
  458.   move.l    a6,d0
  459.   move.l    d0,d1
  460.   swap.w    d0
  461.   move.b    d0,$ffff8201.w
  462.   swap.w    d0
  463.   rol.w    #$8,d0
  464.   move.b    d0,$ffff8203.w
  465.   move.b    d1,$ffff820d.w
  466.  
  467.   move.w    y_pos,d0
  468.   cmp.w    #600,d0
  469.   bge.s    the_end
  470.   
  471.   cmpi.b    #$39,$fffffc02.w
  472.   bne    vbl_one
  473.  
  474. the_end:
  475.   move.w    #$25,-(sp) 
  476.   trap    #$e    ; Vsync
  477.   addq.l    #$2,sp
  478.  
  479.   move.b    old_rez,$ffff8260.w ; Restore screen features.
  480.   move.b    old_screen,$ffff8201.w
  481.   move.b    old_screen+1,$ffff8203.w
  482.   move.b    old_screen+2,$ffff820d.w
  483.  
  484.   move.l    old_vbl,$70.w    ; Restore the Vbl.
  485.   move.l    old_timerc,$114.w ; Restore old timerC rout.
  486.   move.b    old_conterm,$484.w
  487.   move.b    #$8,$fffffc02.w ; Restore mouse.
  488.   dc.w    $a009
  489.  
  490.   move.w    #$25,-(sp) 
  491.   trap    #$e    ; Vsync
  492.   addq.l    #$2,sp
  493.  
  494.   move.w    #$000,$ffff8240.w ; Devpac does not restore colors.
  495.   move.w    #$445,$ffff8242.w
  496.   move.w    #$445,$ffff8244.w
  497.   move.w    #$445,$ffff8246.w
  498.     
  499.   clr.w    -(sp)
  500.   trap    #$1
  501.  
  502. ; ************************************************************************
  503. null_timerc:        ; "Null" routine for the timerC.
  504.   addq.l    #$1,$4ba.w    ; Increment interrupt counter.
  505.   bclr.b    #$5,$fffffa11.w    ; Interrupt no more in service.
  506.   rte
  507.  
  508. ; ************************************************************************
  509. null_vbl:        ; "Null" vbl routine.
  510.   addq.l    #$1,$466.w    ; Increment _frclock.
  511.   cmp.l    #$0,$4d2.w    ; A music routine?
  512.   beq.s    .no_music
  513. .music:        ; Yes, so execute it.
  514.   move.l    a0,-(sp)
  515.   move.l    $4d2.w,a0
  516.   jsr    (a0)
  517.   move.l    (sp)+,a0
  518. .no_music:
  519.   rte
  520.  
  521. ; *************************************************************************
  522. ; More or less (Certainly less) interesting routines.
  523. wait_vbl:
  524.   move.w    d0,-(sp)
  525.   move.l    $466.w,d0
  526. .wait:
  527.   cmp.w    $468.w,d0
  528.   beq.s    .wait
  529.   move.w    (sp)+,d0
  530.   rts
  531.  
  532. ; *************************************************************************
  533. ; Routine which clears a box in 4 planes.
  534. ; Parameters:    a0.l = ramvideo adress.
  535. ;    d0.w = x1.
  536. ;    d1.w = x2.
  537. ;    d2.w = y1.
  538. ;    d3.w = y2.
  539.  
  540. clear_4_bpl:        ; First see if the box is visible.
  541.   movem.l    d0-3/a0-1,-(sp)
  542.   tst.w    d3    ; y2<0?
  543.   blt.s    .end
  544.   cmp.w    #199,d2    ; y1>199.
  545.   ble.s    .clipping
  546. .end:
  547.   movem.l    (sp)+,d0-3/a0-1
  548.   rts
  549. .clipping:
  550.   tst.w    d2    ; y1<0?
  551.   bge.s    .no_clip_up
  552.   moveq.l    #$0,d2    ; Then y1=0.
  553. .no_clip_up:
  554.   cmp.w    #199,d3    ; y2>199?
  555.   ble.s    .no_clip_down
  556.   move.w    #199,d3    ; Then y2=199
  557. .no_clip_down:
  558.   sub.w    d2,d3    ; d3=y2-y1=dy.
  559.   addq.w    #$1,d3
  560.   move.w    d3,$ffff8a38.w    ; Lines per bit-block.
  561.   move.l    #y_table,a1    
  562.   add.w    d2,d2
  563.   add.w    (a1,d2.w),a0    ; a0 points on good line.
  564.   move.w    #$fff0,d2
  565.   and.w    d2,d0    ; d0=x1 mod(16).
  566.   and.w    d2,d1    ; d1=x2 mod(16).
  567.   add.w    #$10,d1    ; d1=x2 mod(16)+16.
  568.   sub.w    d0,d1    ; d1=x2 mod(16)+16-x1 mod(16).
  569.   lsr.w    #$1,d0
  570.   add.w    d0,a0    ; a0 points on good word.
  571.   move.l    a0,$ffff8a32.w    ; Dest adress.
  572.   lsr.w    #$2,d1    ; d2=nb of words.
  573.   move.w    d1,$ffff8a36.w    ; Words per line.
  574.   move.w    #$2,$ffff8a2e.w ; Dest x inc.
  575.   add.w    d1,d1
  576.   move.w    #162,d3
  577.   sub.w    d1,d3
  578.   move.w    d3,$ffff8a30.w    ; Dest y inc.
  579.   moveq.l    #-1,d0
  580.   move.l    d0,$ffff8a28.w    ; Endmasks set to ones.
  581.   move.w    d0,$ffff8a2c.w
  582.   move.w    #$200,$ffff8a3a.w ; Fill with zeroes.
  583.   move.b    #$c0,$ffff8a3c.w
  584.   movem.l    (sp)+,d0-3/a0-1
  585.   rts
  586.  
  587. ; *************************************************************************
  588. ; The interesting routines.
  589.  
  590. rotation:
  591.   include    'a:\shading\rotation.s'
  592.  
  593.   Section TEXT
  594.   
  595. shaded_poly:
  596.   include    'a:\both\shade.s'
  597.  
  598.   Section TEXT
  599.  
  600. mapped_poly:
  601.   include    'a:\both\map.s'
  602.     
  603. ; *************************************************************************
  604.   Section DATA
  605.  
  606. object_brows:        ; Definition of the cube.
  607.   dc.w    4,20*256
  608.   dc.w    20*256,20*256
  609.   dc.w    -20*256,20*256
  610.   dc.w    -20*256,-20*256
  611.   dc.w    20*256,-20*256
  612.   dc.w    4,-20*256
  613.   dc.w    20*256,20*256
  614.   dc.w    -20*256,20*256
  615.   dc.w    -20*256,-20*256
  616.   dc.w    20*256,-20*256
  617.   dc.w    0
  618.  
  619. object_faces:
  620.   dc.w    6    ; 6 faces, Clockwise cycle.
  621.   dc.w    4,0*6,1*6,2*6,3*6
  622.   dc.w    4,0*6,3*6,7*6,4*6
  623.   dc.w    4,0*6,4*6,5*6,1*6
  624.   dc.w    4,6*6,7*6,3*6,2*6
  625.   dc.w    4,4*6,7*6,6*6,5*6
  626.   dc.w    4,1*6,5*6,6*6,2*6
  627.  
  628. object_faces2:
  629.   dc.w    6    ; 6 faces, Clockwise cycle.
  630.   dc.w    0*6,1*6,2*6,3*6
  631.   dc.w    0*6,3*6,7*6,4*6
  632.   dc.w    0*6,4*6,5*6,1*6
  633.   dc.w    6*6,7*6,3*6,2*6
  634.   dc.w    4*6,7*6,6*6,5*6
  635.   dc.w    1*6,5*6,6*6,2*6
  636.  
  637. y_table:        ; Convert y->y*160.
  638. N set 0
  639.  rept    200
  640.   dc.w    N
  641. N set N+160
  642.  endr
  643.  
  644. inverses:
  645.   incbin    'a:\shading\inverses.xxx'
  646.  
  647. colors:
  648.   dc.w    $000,$310,$b90,$420
  649.   dc.w    $ca8,$531,$db9,$642
  650.   dc.w    $000,$420,$ca8,$531
  651.   dc.w    $db9,$642,$eca,$753
  652.  
  653. y_positions:
  654.   incbin    'a:\both\y_mov.xxx'
  655.   
  656. y_pos:
  657.   dc.w    0
  658.  
  659. bois:
  660.   incbin    'a:\both\wood.xxx'
  661.       
  662. ; *************************************************************************
  663.   Section BSS
  664.  
  665. angle1:        ; Well...
  666.   ds.w    1
  667. angle2:
  668.   ds.w    1  
  669.  
  670. screen1:
  671.   ds.b    32000
  672. screen2:
  673.   ds.b    32000
  674.  
  675. new_coords:        ; Coords after rotation.
  676.   ds.w    21*3
  677. face_coords:
  678.   ds.w    100*3
  679.   ds.w    21*3
  680.   ds.w    21*3
  681.   
  682. old_box1:        ; Coords of the box which contain the cube.
  683.   ds.w    4
  684. old_box2:        ; The same for vbl2.
  685.   ds.w    4
  686.  
  687. old_vbl:        ; All the parameters for screen,
  688.   ds.l    1    ; and interrupts...
  689. old_timerc:
  690.   ds.l    1
  691. old_conterm:
  692.   ds.w    1 
  693. old_rez:
  694.   ds.w    1
  695. old_screen:
  696.   ds.l    1
  697. wood:
  698.   ds.b    128*128