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

  1. ; *************************************************************************
  2. ; *****                      *****
  3. ; *****    Routine which draws a 3-planes shaded polygon.          *****
  4. ; *****                By Alain BROBECKER.              *****
  5. ; *****       Coded between 22nd and 23rd of june 1994.          *****
  6. ; *****      Rewritten & Optimised on 25th of june 1994.          *****
  7. ; *****                      *****
  8. ; *************************************************************************
  9. ; Parameters:    a0.l = ramvideo adress.
  10. ;    a1.l = adress of brows coords and intensities.
  11. ;    d0.w = nb of brows.
  12. ;
  13. ; The brows coords and intensities are organised like this:
  14. ; 1 word: x.
  15. ; 1 word: y.
  16. ; 1 word: intensity. (Integer part of it in the 4 most significant bits.)
  17. ; The brows must be placed anticlockwise. Also, the min intensity must be
  18. ; 2 and the max one must be 14 as there sometimes is an imprecision of
  19. ; one color during the interpolation.
  20. ; *************************************************************************
  21.  
  22.   movem.l    d0-a6,-(sp)
  23.  
  24. ; *************************************************************************
  25. ; * First copy the brows once just after their first appearance in a1.l, so
  26. ; * the "tracking" of the min & max lines will be easier. At the same time
  27. ; * search ymin & ymax of the poly.
  28. .copy_and_search:
  29.   move.l    a1,a2
  30.   move.l    a2,a3
  31.   move.w    d0,d1    ; 6 words per brow.
  32.   add.w    d1,d1
  33.   add.w    d0,d1
  34.   add.w    d1,d1
  35.   add.w    d1,a3    ; a3 points just after the brows.
  36.   move.w    #800,d6    ; d6=ymin.
  37.   move.w    #-600,d7    ; d7=ymax.
  38.   subq.w    #$1,d0    ; Beware the dbra.
  39.   
  40. .copy_one_brow:
  41.   move.l    (a2)+,d1    ; Load x and y in d1.
  42.   move.l    d1,(a3)+    ; Copy them.
  43.   cmp.w    d1,d6    ; This y lower than ymin?
  44.   blt.s    .not_ymin
  45.   move.w    d1,d6    ; Yes, then it's the new ymin.
  46. .not_ymin:
  47.   cmp.w    d1,d7    ; This y bigger than ymax?
  48.   bgt.s    .not_ymax
  49.   move.w    d1,d7    ; Yes, then it' s the new ymax.
  50. .not_ymax:
  51.   move.w    (a2)+,(a3)+    ; Copy intensity.
  52.   dbra    d0,.copy_one_brow ; Next brow.
  53.   
  54. ; *************************************************************************
  55. ; * When ymin and ymax are found, we can see if the poly is in the screen,
  56. ; * if it' s partly hidden (y_clipping only) or if it' s invisible.
  57.  
  58. .poly_visibility:
  59.   cmp.w    d6,d7    ; ymin=ymax?
  60.   beq.s    .poly_invisible
  61.   tst.w    d7    ; ymax=<0?
  62.   ble.s    .poly_invisible
  63.   cmp.w    #198,d6    ; ymin>=199?
  64.   ble.s    .poly_clipping
  65. .poly_invisible:    ; Poly out of the screen, so...
  66.   movem.l    (sp)+,d0-a6
  67.   rts
  68.   
  69. .poly_clipping:        ; The poly is (partly?) visible.
  70.   moveq.l    #$0,d0    ; d0=nb h_lines to pass at the beginning.
  71.   move.w    d7,d1
  72.   sub.w    d6,d1    ; d1=ymax-ymin=nb h_lines to draw-1.
  73.   tst.w    d6    ; ymin<0?
  74.   bge.s    .no_clip_up
  75. .clip_up:        ; Yes, so cut the first -ymin h_lines.
  76.   move.w    d6,d0    ; Pass -ymin h_lines at the beginning.
  77.   neg.w    d0
  78.   move.w    d7,d1    ; Nb lines to draw=ymax-0.
  79.   bra.s    .no_clip_down    ; I assume the poly is not that big.
  80. .no_clip_up:
  81.   cmp.w    #199,d7    ; ymax>199.
  82.   ble.s    .no_clip_down
  83. .clip_down:
  84.   move.w    #199,d1    ; Yes, so reduce the nb of h_lines.
  85.   sub.w    d6,d1
  86. .no_clip_down:
  87.   move.w    d0,.nb_lines_2_pass
  88.   addq.w    #$1,d1
  89.   move.w    d1,.nb_lines_2_draw
  90.   
  91. ; *************************************************************************
  92. ; * Not very hard or important, but we must do it, so....
  93.  
  94.   move.l    #.y_table,a2    ; The faster way to multiply by 160???
  95.   move.w    d6,d5
  96.   add.w    d0,d5    ; d5=first seen y.
  97.   add.w    d5,d5    ; One word per y.
  98.   add.w    (a2,d5.w),a0    ; a0 points on first line.
  99.  
  100. ; *************************************************************************
  101. ; * Now, the first important part. We "track" the max_lines, which are on
  102. ; * the right of the poly and calculate xmax and intensity_max for each
  103. ; * y between ymin-ymax by using linear interpolations.
  104.  
  105. .xmax_tracking:        ; First, search the upper right brow.
  106.   subq.w    #$6,a3    ; Next point in clockwise cycle.
  107.   cmp.w    $2(a3),d6    ; y=ymin?
  108.   bne.s    .xmax_tracking
  109. .xmax_ymin_found:    ; If the next brow=ymin, then it' s more
  110.   cmp.w    -$4(a3),d6    ; on the right...
  111.   bne.s    .xmax_ymin_ok
  112.   subq.w    #$6,a3    ; It is the upper right brow.
  113. .xmax_ymin_ok:        ; a3 points on the good brow.
  114.  
  115.   move.l    #.xmax_buffer,a2 ; Store int_maxs and xmaxs here.
  116.   move.l    #.inverses,a4    ; Inverse table.
  117.   move.l    #.xmax_ad,a5    ; The adresses for the jump.
  118. .xmax_one_line:        ; Interpolate on one line.
  119.   move.w    (a3),d0    ; d0=x1.
  120.   move.w    $2(a3),d1    ; d1=y1.
  121.   cmp.w    d1,d7    ; y1=ymax?
  122.   beq    .xmax_end    ; Yes, then it' s finished.
  123.   move.w    $4(a3),d2    ; d2=intensity1.
  124.   subq.l    #$6,a3    ; Next brow.
  125.   move.w    (a3),d3    ; d3=x2.
  126.   move.w    $2(a3),d4    ; d4=y2.
  127.   move.w    $4(a3),d5    ; d5=intensity2.
  128.   sub.w    d1,d4    ; d4=y2-y1, always <>0.
  129.   add.w    d4,d4    ; One word per inverse.
  130.   move.w    (a4,d4.w),d1    ; d1=16384/(y2-y1).
  131.   add.w    d4,d4    ; Two words per jump adress.
  132.   move.l    (a5,d4.w),a6    ; a6=adress where to jump.
  133.   sub.w    d2,d5    ; d5=int2-int1.
  134.   muls.w    d1,d5
  135.   lsl.l    #$2,d5    ; d5=65536*(int2-int1)/dy.
  136.   sub.w    d0,d3    ; d3=x2-x1.
  137.   muls.w    d1,d3
  138.   lsl.l    #$2,d3    ; d3=65536*(dx/dy).
  139.   swap.w    d3
  140.   move.w    d3,d5    ; up(d5)=dint/dy ; low(d5)=int(dx/dy).
  141.   swap.w    d3    ; low(d3)=reg(dx/dy).
  142.   swap.w    d2
  143.   move.w    d0,d2    ; up(d2)=intensity ; low(d2)=x.
  144.   moveq.l    #$0,d0    ; d0=error.
  145.   jmp    (a6)
  146.  
  147.  rept    300
  148.   move.l    d2,(a2)+    ; Save intensity and x.
  149.   add.w    d3,d0    ; error=error+reg(dx/dy).
  150.   addx.l    d5,d2    ; int=int+inc ; x=x+int(dy/dx)+eXtend.
  151.  endr
  152. .xmax_line_end:
  153.   subq.w    #$4,a2    ; Erase last point.
  154.   bra    .xmax_one_line
  155. .xmax_end:
  156.  
  157. ; *************************************************************************
  158. ; * Do the same with the min_lines, which are on the right of the poly
  159. ; * and calculate xmin and intensity_min for each y between ymin-ymax by
  160. ; * using linear interpolations.
  161.  
  162.   subq.w    #$6,a1
  163. .xmin_tracking:        ; First, search the upper left brow.
  164.   addq.w    #$6,a1    ; Next point in anticlockwise cycle.
  165.   cmp.w    $2(a1),d6    ; y=ymin?
  166.   bne.s    .xmin_tracking
  167. .xmin_ymin_found:    ; If the next brow=ymin, then it' s more
  168.   cmp.w    $a(a1),d6    ; on the left...
  169.   bne.s    .xmin_ymin_ok
  170.   addq.w    #$6,a3    ; It is the upper left brow.
  171. .xmin_ymin_ok:        ; a1 points on the good brow.
  172.  
  173.   move.l    #.xmin_buffer,a2 ; Store int_mins and xmins here.
  174.   move.l    #.inverses,a4    ; Inverse table.
  175.   move.l    #.xmin_ad,a5    ; The adresses for the jump.
  176. .xmin_one_line:        ; Interpolate on one line.
  177.   move.w    (a1)+,d0    ; d0=x1.
  178.   move.w    (a1)+,d1    ; d1=y1.
  179.   cmp.w    d1,d7    ; y1=ymax?
  180.   beq    .xmin_end    ; Yes, then it' s finished.
  181.   move.w    (a1)+,d2    ; d2=intensity1.
  182.   move.w    (a1),d3    ; d3=x2.
  183.   move.w    $2(a1),d4    ; d4=y2.
  184.   move.w    $4(a1),d5    ; d5=intensity2.
  185.   sub.w    d1,d4    ; d4=y2-y1, always <>0.
  186.   add.w    d4,d4    ; One word per inverse.
  187.   move.w    (a4,d4.w),d1    ; d1=16384/(y2-y1).
  188.   add.w    d4,d4    ; Two words per jump adress.
  189.   move.l    (a5,d4.w),a6    ; a6=adress where to jump.
  190.   sub.w    d2,d5    ; d5=int2-int1.
  191.   muls.w    d1,d5
  192.   lsl.l    #$2,d5    ; d5=65536*(int2-int1)/dy.
  193.   sub.w    d0,d3    ; d3=x2-x1.
  194.   muls.w    d1,d3
  195.   lsl.l    #$2,d3    ; d3=65536*(dx/dy).
  196.   swap.w    d3
  197.   move.w    d3,d5    ; up(d5)=dint/dy ; low(d5)=int(dx/dy).
  198.   swap.w    d3    ; low(d3)=reg(dx/dy).
  199.   swap.w    d2
  200.   move.w    d0,d2    ; up(d2)=intensity ; low(d2)=x.
  201.   moveq.l    #$0,d0    ; d0=error.
  202.   jmp    (a6)
  203.  
  204.  rept    300
  205.   move.l    d2,(a2)+    ; Save intensity and x.
  206.   add.w    d3,d0    ; error=error+reg(dx/dy).
  207.   addx.l    d5,d2    ; int=int+inc ; x=x+int(dy/dx)+eXtend.
  208.  endr
  209. .xmin_line_end:
  210.   subq.w    #$4,a2    ; Erase last point.
  211.   bra    .xmin_one_line
  212. .xmin_end:
  213.  
  214. ; *************************************************************************
  215. ; * Ok, now we have all we want, it' s now time to draw the poly on the
  216. ; * screen. I proceed by drawing each h_line one after another, and as
  217. ; * intensity_min and intensity_max are different, I have to do an
  218. ; * interpolation between them.
  219.  
  220. .draw_shaded:
  221.   move.l    #.xmin_buffer,a1
  222.   move.w    .nb_lines_2_pass,d0
  223.   add.w    d0,d0    ; 4 bytes per int+x.
  224.   add.w    d0,d0
  225.   add.w    d0,a1    ; Pass the invisible lines.
  226.   move.l    #.points_ad,-(sp) ; Store the table x->adress.
  227.   move.l    #.endrouts_ad,-(sp) ; Table xmax mod(16)->endrout adress.
  228.   move.w    .nb_lines_2_draw,d0 ; The counter.
  229.   subq.w    #$1,d0    ; Beware dbra..
  230.   move.w    d0,-(sp)    ; Store the counter.
  231.   move.l    #.inverses,a2
  232. .draw_one_hline:
  233.   move.w    d0,(sp)    ; Store the counter.
  234.   move.w    (a1)+,d5    ; d5=int_min.
  235.   move.w    1198(a1),d6    ; d6=int_max.
  236.   move.w    (a1)+,d0    ; d0=xmin.
  237.   move.w    1198(a1),d1    ; d1=xmax.
  238.   move.w    d1,d2
  239.   sub.w    d0,d2    ; d2=xmax-xmin=dx.
  240.   ble.s    .next_line    ; Don' t draw if xmin>=xmax.
  241.   add.w    d2,d2
  242.   move.w    (a2,d2.w),d2    ; d2=16384/dx.
  243.   sub.w    d5,d6    ; d6=int_max-int_min=dint.
  244.   add.w    d5,d5    ; The intensity in the 4 Msbits...
  245.   muls.w    d2,d6
  246.   lsl.l    #$3,d6    ; d6=2*65536*(dint/dx). No more sign bit.
  247.   swap.w    d6    ; In the lowerword please.
  248.   move.w    d6,d7
  249.   add.w    #$800,d6    ; d6=inc1=0.5+(dint/dx).
  250.   sub.w    #$800,d7    ; d7=inc2=-0.5+(dint/dx).
  251.   move.l    $2(sp),a4    ; a4=endrouts_ad table.
  252.   move.w    d1,d2
  253.   moveq.l    #$f,d3
  254.   and.w    d3,d2    ; d2=xmax mod(16).
  255.   add.w    d2,d2    ; One long per adress.
  256.   add.w    d2,d2
  257.   move.l    (a4,d2.w),a4    ; a4 points on the endrout to use.
  258.   move.l    $6(sp),a5    ; points_ad table.
  259.   and.w    d0,d3    ; d3=xmin mod(16).
  260.   sub.w    d3,d0    ; d0=xmin-xmin mod(16).
  261.   add.w    d3,d3
  262.   add.w    d3,d3
  263.   move.l    (a5,d3.w),a3    ; a3 points on first point.
  264.   sub.w    d0,d1    ; d1=xmax-(xmin-xmin mod(16)).
  265.   add.w    d1,d1
  266.   add.w    d1,d1
  267.   move.l    (a5,d1.w),a5    ; a5 points on last point-1.
  268.   move.w    #$4ed4,(a5)    ; Put the "jump (a4)".
  269.   lsr.w    #$1,d0    ; d0=offset to xmin.
  270.   move.l    a0,a6
  271.   add.w    d0,a6    ; a6 points on first word.
  272.   add.w    #$a0,a0    ; Next line.
  273.   moveq.l    #$0,d1    ; Clear bitplanes.
  274.   moveq.l    #$0,d2
  275.   moveq.l    #$0,d3
  276.   moveq.l    #$0,d4
  277.   jmp    (a3)    ; Go on first point.
  278.   
  279. .next_line:
  280.   move.w    (sp),d0    ; Load the counter.
  281.   dbra    d0,.draw_one_hline
  282.   add.w    #$a,sp    ; Fuck the stored tiddies.
  283. .the_end:
  284.   movem.l    (sp)+,d0-a6
  285.   rts
  286.  
  287. ; *************************************************************************
  288. ; * We have to use different endroutines in order to gain speed, cos the
  289. ; * ending bitplanes must be rotated and they must be "or.w".
  290.  
  291. shademac1:    MACRO
  292. ;  add.w    d5,d5
  293. ;  addx.w    d4,d4
  294.   add.w    d5,d5
  295.   addx.w    d3,d3
  296.   add.w    d5,d5
  297.   addx.w    d2,d2
  298.   add.w    d5,d5
  299.   addx.w    d1,d1
  300.       ENDM
  301.  
  302. shademac2:    MACRO
  303.   and.w    d0,d1
  304.   and.w    d0,d2
  305.   and.w    d0,d3
  306. ;  and.w    d0,d4
  307.     ENDM
  308.  
  309. shademac3:    MACRO
  310.   or.w    d1,(a6)+
  311.   or.w    d2,(a6)+
  312.   or.w    d3,(a6)+
  313. ;  or.w    d4,(a6)+
  314.       ENDM
  315.  
  316. shademac4:    MACRO
  317.   move.w    #$3005,(a5)    ; Restore initial code.
  318.   move.w    (sp),d0    ; Load counter.
  319.   dbra    d0,.draw_one_hline
  320.   add.w    #$a,sp    ; Fuck the stored tiddies.
  321.   movem.l    (sp)+,d0-a6    ; The end.
  322.   rts
  323.     ENDM
  324.  
  325.  
  326. .endrout_0:
  327.   shademac1        ; Convert last point.
  328.   ror.w    #$1,d1    ; Rotate the bitplanes.
  329.   ror.w    #$1,d2
  330.   ror.w    #$1,d3
  331. ;  ror.w    #$1,d4
  332.   move.w    #$8000,d0    ; For destroying unusefull bits.
  333.   shademac2        ; Fuck them.
  334.   shademac3        ; Print last word.
  335.   shademac4
  336.  
  337. .endrout_1:
  338.   shademac1        ; Convert last point.
  339.   ror.w    #$2,d1    ; Rotate the bitplanes.
  340.   ror.w    #$2,d2
  341.   ror.w    #$2,d3
  342. ;  ror.w    #$2,d4
  343.   move.w    #$c000,d0    ; For destroying unusefull bits.
  344.   shademac2        ; Fuck them.
  345.   shademac3        ; Print last word.
  346.   shademac4
  347.  
  348. .endrout_2:
  349.   shademac1        ; Convert last point.
  350.   ror.w    #$3,d1    ; Rotate the bitplanes.
  351.   ror.w    #$3,d2
  352.   ror.w    #$3,d3
  353. ;  ror.w    #$3,d4
  354.   move.w    #$e000,d0    ; For destroying unusefull bits.
  355.   shademac2        ; Fuck them.
  356.   shademac3        ; Print last word.
  357.   shademac4
  358.  
  359. .endrout_3:
  360.   shademac1        ; Convert last point.
  361.   ror.w    #$4,d1    ; Rotate the bitplanes.
  362.   ror.w    #$4,d2
  363.   ror.w    #$4,d3
  364. ;  ror.w    #$4,d4
  365.   move.w    #$f000,d0    ; For destroying unusefull bits.
  366.   shademac2        ; Fuck them.
  367.   shademac3        ; Print last word.
  368.   shademac4
  369.  
  370. .endrout_4:
  371.   shademac1        ; Convert last point.
  372.   ror.w    #$5,d1    ; Rotate the bitplanes.
  373.   ror.w    #$5,d2
  374.   ror.w    #$5,d3
  375. ;  ror.w    #$5,d4
  376.   move.w    #$f800,d0    ; For destroying unusefull bits.
  377.   shademac2        ; Fuck them.
  378.   shademac3        ; Print last word.
  379.   shademac4
  380.  
  381. .endrout_5:
  382.   shademac1        ; Convert last point.
  383.   ror.w    #$6,d1    ; Rotate the bitplanes.
  384.   ror.w    #$6,d2
  385.   ror.w    #$6,d3
  386. ;  ror.w    #$6,d4
  387.   move.w    #$fc00,d0    ; For destroying unusefull bits.
  388.   shademac2        ; Fuck them.
  389.   shademac3        ; Print last word.
  390.   shademac4
  391.  
  392. .endrout_6:
  393.   shademac1        ; Convert last point.
  394.   ror.w    #$7,d1    ; Rotate the bitplanes.
  395.   ror.w    #$7,d2
  396.   ror.w    #$7,d3
  397. ;  ror.w    #$7,d4
  398.   move.w    #$fe00,d0    ; For destroying unusefull bits.
  399.   shademac2        ; Fuck them.
  400.   shademac3        ; Print last word.
  401.   shademac4
  402.  
  403. .endrout_7:
  404.   shademac1        ; Convert last point.
  405.   lsl.w    #$8,d1    ; Rotate the bitplanes.
  406.   lsl.w    #$8,d2
  407.   lsl.w    #$8,d3
  408. ;  lsl.w    #$8,d4
  409.   shademac3        ; Print last word.
  410.   shademac4
  411.  
  412. .endrout_8:
  413.   shademac1        ; Convert last point.
  414.   lsl.w    #$7,d1    ; Rotate the bitplanes.
  415.   lsl.w    #$7,d2
  416.   lsl.w    #$7,d3
  417. ;  lsl.w    #$7,d4
  418.   shademac3        ; Print last word.
  419.   shademac4
  420.  
  421. .endrout_9:
  422.   shademac1        ; Convert last point.
  423.   lsl.w    #$6,d1    ; Rotate the bitplanes.
  424.   lsl.w    #$6,d2
  425.   lsl.w    #$6,d3
  426. ;  lsl.w    #$6,d4
  427.   shademac3        ; Print last word.
  428.   shademac4
  429.  
  430. .endrout_a:
  431.   shademac1        ; Convert last point.
  432.   lsl.w    #$5,d1    ; Rotate the bitplanes.
  433.   lsl.w    #$5,d2
  434.   lsl.w    #$5,d3
  435. ;  lsl.w    #$5,d4
  436.   shademac3        ; Print last word.
  437.   shademac4
  438.  
  439. .endrout_b:
  440.   shademac1        ; Convert last point.
  441.   lsl.w    #$4,d1    ; Rotate the bitplanes.
  442.   lsl.w    #$4,d2
  443.   lsl.w    #$4,d3
  444. ;  lsl.w    #$4,d4
  445.   shademac3        ; Print last word.
  446.   shademac4
  447.  
  448. .endrout_c:
  449.   shademac1        ; Convert last point.
  450.   lsl.w    #$3,d1    ; Rotate the bitplanes.
  451.   lsl.w    #$3,d2
  452.   lsl.w    #$3,d3
  453. ;  lsl.w    #$3,d4
  454.   shademac3        ; Print last word.
  455.   shademac4
  456.  
  457. .endrout_d:
  458.   shademac1        ; Convert last point.
  459.   lsl.w    #$2,d1    ; Rotate the bitplanes.
  460.   lsl.w    #$2,d2
  461.   lsl.w    #$2,d3
  462. ;  lsl.w    #$2,d4
  463.   shademac3        ; Print last word.
  464.   shademac4
  465.  
  466. .endrout_e:
  467.   shademac1        ; Convert last point.
  468.   add.w    d1,d1    ; Rotate the bitplanes.
  469.   add.w    d2,d2
  470.   add.w    d3,d3
  471. ;  add.w    d4,d4
  472.   shademac3        ; Print last word.
  473.   shademac4
  474.  
  475. .endrout_f:
  476.   shademac1        ; Convert last point.
  477.   shademac3
  478.   shademac4
  479.  
  480. ; *************************************************************************
  481. ; * The core of the shading poly routine... Very repetitive, cos I don' t
  482. ; * like the dbra and I LOOOOooove Speed....
  483.  
  484. shademac5:    MACRO
  485.  rept    8
  486.   move.w    d5,d0    ; Convert first point.
  487. ;  add.w    d0,d0
  488. ;  addx.w    d4,d4
  489.   add.w    d0,d0
  490.   addx.w    d3,d3
  491.   add.w    d0,d0
  492.   addx.w    d2,d2
  493.   add.w    d0,d0
  494.   addx.w    d1,d1
  495.   add.w    d6,d5    ; intensity=intensity+increment1.
  496.   move.w    d5,d0    ; Convert second point.
  497. ;  add.w    d0,d0
  498. ;  addx.w    d4,d4
  499.   add.w    d0,d0
  500.   addx.w    d3,d3
  501.   add.w    d0,d0
  502.   addx.w    d2,d2
  503.   add.w    d0,d0
  504.   addx.w    d1,d1
  505.   add.w    d7,d5    ; intensity=intensity+increment2.
  506.  endr
  507.     ENDM
  508.  
  509. .core:
  510.   shademac5        ; 16 pixies.
  511.   or.w    d1,(a6)+    ; Print first bitlanes.
  512.   or.w    d2,(a6)+
  513.   or.w    d3,(a6)+
  514.   addq.w    #$2,a6
  515. ;  or.w    d4,(a6)+
  516.  
  517. .core_2:
  518.   shademac5        ; Do 16 pixies.
  519.   movem.w    d1-d3,(a6)    ; Store planes.
  520.   addq.w    #$8,a6
  521.   shademac5
  522.   movem.w    d1-d3,(a6)
  523.   addq.w    #$8,a6
  524.   shademac5
  525.   movem.w    d1-d3,(a6)
  526.   addq.w    #$8,a6
  527.   shademac5
  528.   movem.w    d1-d3,(a6)
  529.   addq.w    #$8,a6
  530.   shademac5
  531.   movem.w    d1-d3,(a6)
  532.   addq.w    #$8,a6
  533.   shademac5
  534.   movem.w    d1-d3,(a6)
  535.   addq.w    #$8,a6
  536.   shademac5
  537.   movem.w    d1-d3,(a6)
  538.   addq.w    #$8,a6
  539.   shademac5
  540.   movem.w    d1-d3,(a6)
  541.   addq.w    #$8,a6
  542.   shademac5
  543.   movem.w    d1-d3,(a6)
  544.   addq.w    #$8,a6
  545.   shademac5
  546.   movem.w    d1-d3,(a6)
  547.   addq.w    #$8,a6
  548.   shademac5
  549.   movem.w    d1-d3,(a6)
  550.   addq.w    #$8,a6
  551.   shademac5
  552.   movem.w    d1-d3,(a6)
  553.   addq.w    #$8,a6
  554.   shademac5
  555.   movem.w    d1-d3,(a6)
  556.   addq.w    #$8,a6
  557.   shademac5
  558.   movem.w    d1-d3,(a6)
  559.   addq.w    #$8,a6
  560.   shademac5
  561.   movem.w    d1-d3,(a6)
  562.   addq.w    #$8,a6
  563.  
  564.  
  565. ; *************************************************************************
  566.   Section DATA
  567.   
  568. .y_table:        ; Table for y->y*160 conversions.
  569. N set 0
  570.  rept    200
  571.   dc.w    N  
  572. N set N+160
  573.  endr
  574.  
  575. .inverses:        ; Table n->16384/n.
  576.   incbin    'a:\shading\inverses.xxx'
  577.  
  578. .xmax_ad:        ; Table of adresses for the jump.
  579. N set 6
  580.  rept    300
  581.   dc.l    .xmax_line_end-N
  582. N set N+6
  583.  endr
  584.  
  585. .xmin_ad:        ; The same for the xmin tracking.
  586. N set 6
  587.  rept    300
  588.   dc.l    .xmin_line_end-N
  589. N set N+6
  590.  endr
  591.  
  592. .points_ad:        ; Convert x->adress in the "core".
  593. N set 0        ; For the first 16 pixies.
  594.  rept    16
  595.   dc.l    .core+N
  596. N set N+16
  597.  endr
  598. N set 0        ; For the next ones.
  599.  rept    15    ; 240 points.
  600.   dc.l    .core_2+000+N,.core_2+016+N
  601.   dc.l    .core_2+032+N,.core_2+048+N
  602.   dc.l    .core_2+064+N,.core_2+080+N
  603.   dc.l    .core_2+096+N,.core_2+112+N
  604.   dc.l    .core_2+128+N,.core_2+144+N
  605.   dc.l    .core_2+160+N,.core_2+176+N
  606.   dc.l    .core_2+192+N,.core_2+208+N
  607.   dc.l    .core_2+224+N,.core_2+240+N
  608. N set N+256+6
  609.  endr
  610.  
  611. .endrouts_ad:        ; Table for the endrouts adresses. 
  612.   dc.l    .endrout_0,.endrout_1,.endrout_2,.endrout_3
  613.   dc.l    .endrout_4,.endrout_5,.endrout_6,.endrout_7
  614.   dc.l    .endrout_8,.endrout_9,.endrout_a,.endrout_b
  615.   dc.l    .endrout_c,.endrout_d,.endrout_e,.endrout_f
  616.    
  617.  
  618. ; *************************************************************************
  619.   Section BSS
  620.   
  621. .nb_lines_2_pass:    ; This two vars are used for the clipping.
  622.   ds.w    1
  623. .nb_lines_2_draw:
  624.   ds.w    1
  625. .xmin_buffer:
  626.   ds.l    300
  627. .xmax_buffer:
  628.   ds.l    300
  629.