home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quakeworld_src / client / d_scanppc.s < prev    next >
Encoding:
Text File  |  2000-06-17  |  48.6 KB  |  1,536 lines

  1. # Copyright (C) 1996-1997 Id Software, Inc. 
  2. # This program is free software; you can redistribute it and/or 
  3. # modify it under the terms of the GNU General Public License 
  4. # as published by the Free Software Foundation; either version 2 
  5. # of the License, or (at your option) any later version. 
  6. # This program is distributed in the hope that it will be useful, 
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   
  9. # See the GNU General Public License for more details. 
  10. # You should have received a copy of the GNU General Public License 
  11. # along with this program; if not, write to the Free Software 
  12. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
  13.  
  14. ##
  15. ## Quake for AMIGA
  16. ##
  17. ## d_scanPPC.s
  18. ##
  19. ## Define WOS for PowerOpen ABI, otherwise SVR4-ABI is used.
  20. ##
  21.  
  22. .set NOLR,1
  23. .include        "macrosPPC.i"
  24.  
  25. .macro    rsreset
  26. .set    rscnt,0
  27. .endm
  28.  
  29. .macro    rs
  30. .set    \1,rscnt
  31. .set    rscnt,rscnt+\2
  32. .endm
  33.  
  34. #
  35. # external references
  36. #
  37.     xrefv    cacheblock
  38.     xrefv    d_sdivzorigin
  39.     xrefv    d_sdivzstepu
  40.     xrefv    d_sdivzstepv
  41.     xrefv    d_tdivzorigin
  42.     xrefv    d_tdivzstepu
  43.     xrefv    d_tdivzstepv
  44.     xrefv    d_ziorigin
  45.     xrefv    d_zistepu
  46.     xrefv    d_zistepv
  47.     xrefv    sadjust
  48.     xrefv    tadjust
  49.     xrefv    sdivz
  50.     xrefv    tdivz
  51.     xrefv    bbextents
  52.     xrefv    bbextentt
  53.     xrefv    d_viewbuffer
  54.     xrefv    screenwidth
  55.     xrefv    cachewidth
  56.     xrefv    d_zwidth
  57.     xrefv    d_pzbuffer
  58.     xrefv    sintable
  59.  
  60.     xrefa    d_subdiv16
  61.     xrefa    cl
  62.     xrefa    intsintable
  63.     xrefa    sintable
  64.     xrefa    vid
  65.     xrefa    scr_vrect
  66.     xrefa    r_refdef
  67.  
  68.     xrefv    INT2DBL_0
  69.     xrefv    c0
  70.     xrefv    c2
  71.     xrefv    c65536
  72.     xrefa    _ReciprocTable
  73.  
  74.  
  75. #
  76. # defines
  77. #
  78.  
  79. .set    QDIV,1
  80. .set    NICE_DIV,1
  81.  
  82. .set    PSPAN_NEXT,12
  83. .set    CL_TIME,438452
  84. .set    VID_BUFFER,0
  85. .set    VID_ROWBYTES,16
  86.  
  87. .set    SCR_VRECT_X,0
  88. .set    SCR_VRECT_Y,4
  89. .set    SCR_VRECT_WIDTH,8
  90. .set    SCR_VRECT_HEIGHT,12
  91.  
  92. .set    REFDEF_VRECT_X,0
  93. .set    REFDEF_VRECT_Y,4
  94. .set    REFDEF_VRECT_WIDTH,8
  95. .set    REFDEF_VRECT_HEIGHT,12
  96. .set    CVAR_VALUE,16
  97.  
  98. # MUST match the #define in d_iface.h!
  99. .set    CYCLE,128
  100. .set    AMP2,3
  101. .set    SPEED,20
  102.  
  103.  
  104.  
  105.  
  106.  
  107. ###########################################################################
  108. #
  109. #       void D_WarpScreen (void)
  110. #
  111. #       water effect algorithm
  112. #
  113. ###########################################################################
  114.  
  115.     funcdef    D_WarpScreen
  116.  
  117.     rsreset
  118.     rs    int2dbl_tmp1,8
  119.     rs    dbl2int_tmp1,8
  120.     rs    rowptr,1024*4
  121.     rs    column,1280*4
  122.  
  123.     init    0,rscnt+512,8,0
  124.     stmw    r24,gb(r1)
  125.     la    r4,local+rowptr(r1)        #r4 -> rowptr[1024]
  126.     la    r5,local+column(r1)        #r5 -> column[1280]
  127.     lf    f1,INT2DBL_0            #f1 = 0x4330000080000000
  128.     stfd    f1,local+int2dbl_tmp1(r1)    #int2dbl_tmp1 = 0x43300000...
  129.  
  130.     lxa    r6,vid                #r6 -> vid
  131.     lxa    r7,r_refdef            #r7 -> r_refdef
  132.     lxa    r8,scr_vrect            #r8 -> scr_vrect
  133.     lwz    r9,SCR_VRECT_WIDTH(r8)        #r9 = scr_vrect.width
  134.     lwz    r10,SCR_VRECT_HEIGHT(r8)    #r10 = scr_vrect.height
  135.     lwz    r11,REFDEF_VRECT_X(r7)        #r11 = r_refdef.vrect.x
  136.     lwz    r12,REFDEF_VRECT_Y(r7)        #r12 = r_refdef.vrect.y
  137.     lwz    r0,REFDEF_VRECT_WIDTH(r7)
  138.     int2dbl    f2,r0,r0,local+int2dbl_tmp1,f1    #f2 = (float)r_refdef.vrect.width
  139.     lwz    r0,REFDEF_VRECT_HEIGHT(r7)
  140.     int2dbl f3,r0,r0,local+int2dbl_tmp1,f1    #f3 = (float)r_refdef.vrect.height
  141.     lw      r31,screenwidth            #r31 = screenwidth
  142.     ls      f4,cAMP2times2            #f4 = AMP2*2
  143.  
  144. #        w = r_refdef.vrect.width;
  145. #        h = r_refdef.vrect.height;
  146. #
  147. #        wratio = w / (float)scr_vrect.width;
  148. #        hratio = h / (float)scr_vrect.height;
  149.  
  150.     fadds    f5,f2,f4                #f5 = w + AMP2*2
  151.     fadds    f6,f3,f4                #f6 = h + AMP2*2
  152.     int2dbl f0,r9,r0,local+int2dbl_tmp1,f1
  153.     fmuls    f5,f5,f0        #* (float)scr_vrect.width
  154.     int2dbl    f0,r10,r0,local+int2dbl_tmp1,f1
  155.     fmuls    f6,f6,f0        #* (float)scr_vrect.height
  156.     fmuls    f2,f2,f2        #w*w
  157.     fmuls    f3,f3,f3        #h*h
  158.     fdivs    f2,f2,f5        #f2 = wratio*w/(w+AMP2*2)
  159.     fdivs    f3,f3,f6        #f3 = hratio*h/(h+AMP2*2)
  160.     mullw    r12,r12,r31        #r12 = r_refdef.vrect.y*screenwidth
  161.     lw    r29,d_viewbuffer
  162.     add    r12,r12,r29        #r12 = d_viewbuffer + r12
  163.     lwz    r29,VID_ROWBYTES(r6)    #r29 = vid.rowbytes
  164.     addi    r27,r9,AMP2*2
  165.     addi    r28,r10,AMP2*2
  166.  
  167. #        for (v=0 ; v<scr_vrect.height+AMP2*2 ; v++)
  168. #        {
  169. #                rowptr[v] = d_viewbuffer + (r_refdef.vrect.y * screenwidth) +
  170. #                                 (screenwidth * (int)((float)v * hratio * h / (h + AMP2 * 2)));
  171. #        }
  172.  
  173.     li    r26,0            #v = 0
  174.     subi    r25,r4,4        #r25 -> rowptr[0] - 4
  175. .wsloop:
  176.     int2dbl    f7,r26,r0,local+int2dbl_tmp1,f1 #f7 = (float)v
  177.     fmuls    f7,f7,f3                #(float)v*hratio*h/(h+AMP2*2)
  178.     fctiwz    f0,f7
  179.     stfd    f0,local+dbl2int_tmp1(r1)
  180.     lwz    r24,local+dbl2int_tmp1+4(r1) #r24 = (int)f7
  181.     mullw    r24,r24,r31
  182.     add    r24,r24,r12
  183.     addi    r26,r26,1               #v++
  184.     stwu    r24,4(r25)              #rowptr[v] = r24
  185.     cmpw    r26,r28
  186.     blt    .wsloop
  187.  
  188. #        for (u=0 # u<scr_vrect.width+AMP2*2 ; u++)
  189. #        {
  190. #                column[u] = r_refdef.vrect.x +
  191. #                                (int)((float)u * wratio * w / (w + AMP2 * 2));
  192. #        }
  193.     li    r26,0                   #u = 0
  194.     subi    r25,r5,4                #r25 -> column[0]
  195. .wsloop2:
  196.     int2dbl    f7,r26,r0,local+int2dbl_tmp1,f1 #f7 = (float)u
  197.     fmuls    f7,f7,f2        #(float)u*wratio*w/(w+AMP2*2)
  198.     fctiwz    f0,f7
  199.     stfd    f0,local+dbl2int_tmp1(r1)
  200.     lwz    r24,local+dbl2int_tmp1+4(r1) #r24 = (int)f7
  201.     add    r24,r24,r11
  202.     addi    r26,r26,1        #u++
  203.     stwu    r24,4(r25)        #column[u] = r24
  204.     cmpw    r26,r27
  205.     blt    .wsloop2
  206.  
  207. #        turb = intsintable + ((int)(cl.time*SPEED)&(CYCLE-1));
  208. #        dest = vid.buffer + scr_vrect.y * vid.rowbytes + scr_vrect.x;
  209. #        for (v=0 ; v<scr_vrect.height ; v++, dest += vid.rowbytes)
  210. #        {
  211. #                col = &column[turb[v]];
  212. #                row = &rowptr[v];
  213. #                for (u=0 ; u<scr_vrect.width ; u+=4)
  214. #                {
  215. #                        dest[u+0] = row[turb[u+0]][col[u+0]];
  216. #                        dest[u+1] = row[turb[u+1]][col[u+1]];
  217. #                        dest[u+2] = row[turb[u+2]][col[u+2]];
  218. #                        dest[u+3] = row[turb[u+3]][col[u+3]];
  219. #                }
  220. #        }
  221.  
  222.     srawi    r9,r9,2
  223.     lxa    r28,cl
  224.     addis    r28,r28,CL_TIME@ha
  225.     lfd    f7,CL_TIME@l(r28)
  226.     ls    f0,cSPEED
  227.     fmuls    f7,f7,f0
  228.     fctiwz    f0,f7
  229.     stfd    f0,local+dbl2int_tmp1(r1)
  230.     lwz    r27,local+dbl2int_tmp1+4(r1)
  231.     andi.    r27,r27,CYCLE-1
  232.     slwi    r27,r27,2
  233.     lxa    r26,intsintable
  234.     add    r27,r27,r26        #r27 = turb = sintable + ...
  235.  
  236.     lwz    r28,SCR_VRECT_Y(r8)
  237.     mullw    r28,r28,r29
  238.     lwz    r26,SCR_VRECT_X(r8)
  239.     add    r26,r26,r28
  240.     lwz    r28,VID_BUFFER(r6)
  241.     add    r26,r26,r28        #r26 = dest = vid.buffer + ...
  242.  
  243.     li    r6,0
  244. .wsloop3:
  245.     slwi    r0,r6,2
  246.     mtctr    r9
  247.     subi    r7,r27,4        #r7 -> turb[u] - 4
  248.     lwzx    r8,r27,r0        #r8 = turb[v]
  249.     subi    r11,r26,1        #r11 -> dest[u] - 1
  250.     slwi    r8,r8,2
  251.     add    r12,r5,r8        #r12 = col = &column[turb[v]]
  252.     subi    r12,r12,4
  253.     add    r31,r4,r0        #r31 = row = &rowptr[v]
  254. .wsloop4:
  255.     lwzu    r0,4(r7)        #r0 = turb[u+0]
  256.     slwi    r0,r0,2
  257.     lwzx    r30,r31,r0        #r30 = row[turb[u+0]]
  258.     lwzu    r0,4(r12)        #r0 = col[u+0]
  259.     lbzx    r0,r30,r0        #r0 = row[turb[u+0][col[u+0]]
  260.     stbu    r0,1(r11)        #dest[u+0] = r0
  261.     lwzu    r0,4(r7)        #r0 = turb[u+0]
  262.     slwi    r0,r0,2
  263.     lwzx    r30,r31,r0        #r30 = row[turb[u+0]]
  264.     lwzu    r0,4(r12)        #r0 = col[u+0]
  265.     lbzx    r0,r30,r0        #r0 = row[turb[u+0][col[u+0]]
  266.     stbu    r0,1(r11)        #dest[u+0] = r0
  267.     lwzu    r0,4(r7)        #r0 = turb[u+0]
  268.     slwi    r0,r0,2
  269.     lwzx    r30,r31,r0        #r30 = row[turb[u+0]]
  270.     lwzu    r0,4(r12)        #r0 = col[u+0]
  271.     lbzx    r0,r30,r0        #r0 = row[turb[u+0][col[u+0]]
  272.     stbu    r0,1(r11)        #dest[u+0] = r0
  273.     lwzu    r0,4(r7)        #r0 = turb[u+0]
  274.     slwi    r0,r0,2
  275.     lwzx    r30,r31,r0        #r30 = row[turb[u+0]]
  276.     lwzu    r0,4(r12)        #r0 = col[u+0]
  277.     lbzx    r0,r30,r0        #r0 = row[turb[u+0][col[u+0]]
  278.     stbu    r0,1(r11)        #dest[u+0] = r0
  279.     bdnz    .wsloop4
  280.     add    r26,r26,r29        #dest += vid.rowbytes
  281.     addi    r6,r6,1
  282.     cmpw    r6,r10
  283.     blt    .wsloop3
  284.  
  285.     lmw    r24,gb(r1)
  286.     exit
  287.  
  288.     funcend    D_WarpScreen
  289.  
  290.  
  291.  
  292.  
  293. ###########################################################################
  294. #
  295. #       void Turbulent8 (espan_t *pspan)
  296. #
  297. #       standard scan drawing function for animated textures
  298. #       Note: The function D_DrawTurbulent8Span was inlined into this
  299. #       function, because it's never used anywhere else.
  300. #
  301. ###########################################################################
  302.  
  303.     funcdef    Turbulent8
  304.  
  305.     init    0,16,7,16        # 16 local bytes for int2dbl/dbl2int
  306.     stmw    r25,gb(r1)
  307.     stfd    f14,fb+0*8(r1)
  308.     stfd    f15,fb+1*8(r1)
  309.     stfd    f16,fb+2*8(r1)
  310.     stfd    f17,fb+3*8(r1)
  311.     stfd    f18,fb+4*8(r1)
  312.     stfd    f19,fb+5*8(r1)
  313.     stfd    f20,fb+6*8(r1)
  314.     stfd    f21,fb+7*8(r1)
  315.     stfd    f22,fb+8*8(r1)
  316.     stfd    f23,fb+9*8(r1)
  317.     stfd    f24,fb+10*8(r1)
  318.     stfd    f25,fb+11*8(r1)
  319.     stfd    f26,fb+12*8(r1)
  320.     stfd    f27,fb+13*8(r1)
  321.     stfd    f28,fb+14*8(r1)
  322.     stfd    f29,fb+15*8(r1)
  323.  
  324.     lxa    r26,_ReciprocTable
  325.     lw      r27,cacheblock          #r27 = r_turb_pbase
  326.     lxa     r5,cl
  327.     addis    r5,r5,CL_TIME@ha
  328.     lfd     f1,CL_TIME@l(r5)
  329.     ls      f2,cSPEED
  330.     fmuls   f1,f1,f2
  331.     fctiwz  f0,f1
  332.     stfd    f0,local+8(r1)
  333.     lwz     r4,local+12(r1)
  334.     andi.   r4,r4,CYCLE-1
  335.     slwi    r4,r4,2
  336.     lxa     r5,sintable
  337.     add     r4,r4,r5                #r4 = r_turb_turb = sintable + ...
  338.     ls      f1,d_sdivzstepu         #f1 = d_sdivzstepu
  339.     ls      f2,d_sdivzstepv         #f2 = d_sdivzstepv
  340.     ls      f3,d_sdivzorigin        #f3 = d_sdivzorigin
  341.     ls      f4,d_tdivzstepu         #f4 = d_tdivzstepu
  342.     ls      f5,d_tdivzstepv         #f5 = d_tdivzstepv
  343.     ls      f6,d_tdivzorigin        #f6 = d_tdivzorigin
  344.     ls      f7,d_zistepu            #f7 = d_zistepu
  345.     ls      f8,d_zistepv            #f8 = d_zistepv
  346.     ls      f9,d_ziorigin           #f9 = d_ziorigin
  347.     lf      f10,INT2DBL_0           #for int2dbl_setup
  348.     stfd    f10,local(r1)
  349.     lw      r6,sadjust
  350.     int2dbl f11,r6,r0,local,f10    #f11 = sadjust
  351.     lw      r6,tadjust
  352.     int2dbl f12,r6,r0,local,f10    #f12 = tadjust
  353.     lw      r6,bbextents
  354.     int2dbl f13,r6,r0,local,f10    #f13 = bbextents
  355.     lw      r6,bbextentt
  356.     int2dbl f14,r6,r0,local,f10    #f14 = bbextentt
  357.     lw      r6,d_viewbuffer         #r6 = d_viewbuffer
  358.     lw      r7,screenwidth          #r7 = screenwidth
  359.     ls      f15,c65536              #f15 = 65536
  360.     ls      f16,c16                    #f16 = 16
  361.     ls      f25,c0                  #f25 = 0
  362.     ls      f28,c2                  #f28 = 2
  363.     fmuls   f17,f1,f16              #f17 = sdivz16stepu
  364.     fmuls   f18,f4,f16              #f18 = tdivz16stepu
  365.     fmuls   f19,f7,f16              #f19 = zi16stepu
  366.     subi    r3,r3,4                 #prepare for postincrement
  367.  
  368. ######  First loop. In every iteration one complete span is drawn
  369.  
  370. #        pbase = (unsigned char *)cacheblock;
  371. #
  372. #        sdivz16stepu = d_sdivzstepu * 16;
  373. #        tdivz16stepu = d_tdivzstepu * 16;
  374. #        zi16stepu = d_zistepu * 16;
  375. #
  376. #        do
  377. #        {
  378. #                r_turb_pdest = (unsigned char *)((byte *)d_viewbuffer +
  379. #                                (screenwidth * pspan->v) + pspan->u);
  380. #
  381. #                count = pspan->count;
  382. #
  383. #        // calculate the initial s/z, t/z, 1/z, s, and t and clamp
  384. #                du = (float)pspan->u;
  385. #                dv = (float)pspan->v;
  386. #
  387. #                sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
  388. #                tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
  389. #                zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
  390. #                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  391. #
  392.  
  393. .t8loop:
  394.     lwzu    r8,4(r3)
  395.     int2dbl f20,r8,r0,local,f10    #f20 = du
  396.     lwzu    r9,4(r3)
  397.     int2dbl f21,r9,r0,local,f10    #f21 = dv
  398.     fmadds  f24,f21,f8,f9
  399.     fmadds  f22,f21,f2,f3
  400.     fmadds  f23,f21,f5,f6
  401.     fmadds  f26,f20,f7,f24          #f26 = zi
  402.     fmadds  f22,f20,f1,f22          #f22 = sdivz
  403.     fmadds  f23,f20,f4,f23          #f23 = tdivz
  404.     fmuls   f0,f26,f26
  405.     frsqrte f0,f0
  406.     mullw   r10,r9,r7               #r10 = pspan->v * screenwidth
  407.     fnmsubs f29,f0,f26,f28
  408.     add     r10,r10,r8              #r10 = r10 + pspan->u
  409.     fmuls   f0,f0,f29
  410.     add     r11,r6,r10              #r11 = pdest
  411.     fnmsubs f29,f0,f26,f28
  412.     subi    r11,r11,1               #prepare for postincrement
  413.     fmuls   f0,f0,f29
  414.     lwzu    r12,4(r3)               #r12 = count
  415.     fmuls   f24,f0,f15
  416.     fmadds  f20,f22,f24,f11         #f20 = s
  417.     fsubs   f0,f20,f13
  418.     fsel    f20,f0,f13,f20          #if (s>bb...) s = bbextents
  419.     fsel    f20,f20,f20,f25         #if (s<0) s = 0
  420.     fctiwz  f0,f20
  421.     stfd    f0,local+8(r1)
  422.     lwz     r8,local+12(r1)         #r8 = (int)s
  423.     fmadds  f21,f23,f24,f12         #f21 = t
  424.     fsubs   f0,f21,f14
  425.     fsel    f21,f0,f14,f21          #if (t>bb...) t = bbextentt
  426.     fsel    f21,f21,f21,f25         #if (t<0) t = 0
  427.     fctiwz  f0,f21
  428.     stfd    f0,local+8(r1)
  429.     lwz     r9,local+12(r1)         #r9 = (int)t
  430.  
  431.  
  432. ######  Second loop. In every iteration one part of the whole span is drawn
  433.  
  434. #                do
  435. #                {
  436. #                // calculate s and t at the far end of the span
  437. #                        if (count >= 16)
  438. #                                r_turb_spancount = 16;
  439. #                        else
  440. #                                r_turb_spancount = count;
  441. #
  442. #                        count -= r_turb_spancount;
  443. #
  444. #                        if (count)
  445. #                        {
  446.  
  447. .t8loop2:
  448.     cmpwi   r12,16
  449.     bgt     .t8cont
  450.     mtctr   r12
  451.     subi    r10,r12,1
  452.     int2dbl f21,r10,r0,local,f10    #spancountminus1 = (float)...
  453.     li      r12,0                   #r12 = count -= spancount
  454.     fmadds  f26,f21,f7,f26          #zi += d_zistepu * ...
  455.     b       .t8finalpart
  456. .t8cont:
  457.     fadds   f26,f26,f19             #zi += zi16stepu
  458.     li      r10,16                  #r10 = spancount = 16
  459.     fmuls   f0,f26,f26
  460.     subf    r12,r10,r12             #r12 = count -= spancount
  461.     frsqrte f0,f0
  462.     mtctr   r10
  463.  
  464. ######  Evaluation of the values for the inner loop. This version is used for
  465. ######  span size = 16
  466.  
  467. #                        // calculate s/z, t/z, zi->fixed s and t at far end of span,
  468. #                        // calculate s and t steps across span by shifting
  469. #                                sdivz += sdivz16stepu;
  470. #                                tdivz += tdivz16stepu;
  471. #                                zi += zi16stepu;
  472. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  473. #                                snext = (int)(sdivz * z) + sadjust;
  474. #                                if (snext > bbextents)
  475. #                                        snext = bbextents;
  476. #                                else if (snext < 16)
  477. #                                        snext = 16;      // prevent round-off error on <0 steps from
  478. #                                                                //  from causing overstepping & running off the
  479. #                                                                //  edge of the texture
  480. #                                tnext = (int)(tdivz * z) + tadjust;
  481. #                                if (tnext > bbextentt)
  482. #                                        tnext = bbextentt;
  483. #                                else if (tnext < 16)
  484. #                                        tnext = 16;      // guard against round-off error on <0 steps
  485. #                                r_turb_sstep = (snext - r_turb_s) >> 4;
  486. #                                r_turb_tstep = (tnext - r_turb_t) >> 4;
  487. #                        }
  488.  
  489.     fnmsubs f20,f0,f26,f28
  490.     fadds   f22,f22,f17             #sdivz += sdivz16stepu
  491.     fmuls   f0,f0,f20
  492.     fadds   f23,f23,f18             #tdivz += tdivz16stepu
  493.     fnmsubs f20,f0,f26,f28
  494.     fmuls   f0,f0,f20
  495.     fmuls   f24,f0,f15
  496.     fmadds  f20,f22,f24,f11         #f20 = snext
  497.     fsubs   f0,f20,f13
  498.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  499.     fsubs   f0,f20,f16
  500.     fsel    f20,f0,f20,f16          #if (snext<16) snext = 16
  501.     fctiwz  f0,f20
  502.     stfd    f0,local+8(r1)
  503.     lwz     r31,local+12(r1)        #r31 = (int)snext
  504.     fmadds  f21,f23,f24,f12         #f21 = tnext
  505.     fsubs   f0,f21,f14
  506.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  507.     subf    r29,r8,r31
  508.     fsubs   f0,f21,f16
  509.     srawi   r29,r29,4               #r29 = sstep = (snext - s) >> 4
  510.     fsel    f21,f0,f21,f16          #if (tnext<16) tnext = 16
  511.     fctiwz  f0,f21
  512.     stfd    f0,local+8(r1)
  513.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  514.     subf    r28,r9,r30
  515.     srawi   r28,r28,4               #r28 = tstep = (tnext - t) >> 4
  516.     b       .t8mainloop
  517.  
  518. ######  Evaluation of the values for the inner loop. This version is used for
  519. ######  span size < 16
  520.  
  521. ######  The original algorithm has two ugly divisions at the end of this part.
  522. ######  These are removed by the following optimization:
  523. ######  First, the divisors 1,2 and 4 are handled specially to gain speed. The
  524. ######  other divisors are handled using a reciprocal table.
  525.  
  526. #                        // calculate s/z, t/z, zi->fixed s and t at last pixel in span (so
  527. #                        // can't step off polygon), clamp, calculate s and t steps across
  528. #                        // span by division, biasing steps low so we don't run off the
  529. #                        // texture
  530. #                                spancountminus1 = (float)(r_turb_spancount - 1);
  531. #                                sdivz += d_sdivzstepu * spancountminus1;
  532. #                                tdivz += d_tdivzstepu * spancountminus1;
  533. #                                zi += d_zistepu * spancountminus1;
  534. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  535. #                                snext = (int)(sdivz * z) + sadjust;
  536. #                                if (snext > bbextents)
  537. #                                        snext = bbextents;
  538. #                                else if (snext < 16)
  539. #                                        snext = 16;      // prevent round-off error on <0 steps from
  540. #                                                                //  from causing overstepping & running off the
  541. #                                                                //  edge of the texture
  542. #
  543. #                                tnext = (int)(tdivz * z) + tadjust;
  544. #                                if (tnext > bbextentt)
  545. #                                        tnext = bbextentt;
  546. #                                else if (tnext < 16)
  547. #                                        tnext = 16;      // guard against round-off error on <0 steps
  548. #
  549. #                                if (r_turb_spancount > 1)
  550. #                                {
  551. #                                        r_turb_sstep = (snext - r_turb_s) / (spancount - 1);
  552. #                                        r_turb_tstep = (tnext - r_turb_t) / (spancount - 1);
  553. #                                }
  554. #                        }
  555.  
  556. .t8finalpart:
  557.     fmuls   f0,f26,f26
  558.     fmadds  f22,f21,f1,f22          #sdivz += d_sdivzstepu * ...
  559.     frsqrte f0,f0
  560.     fmadds  f23,f21,f4,f23          #tdivs += d_tdivzstepu * ...
  561.     fnmsubs f20,f0,f26,f28
  562.     cmplwi  r10,5
  563.     fmuls   f0,f0,f20
  564.     fnmsubs f20,f0,f26,f28
  565.     fmuls   f0,f0,f20
  566.     fmuls   f24,f0,f15
  567.     fmadds  f20,f22,f24,f11         #f27 = snext
  568.     fsubs   f0,f20,f13
  569.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  570.     fsubs   f0,f20,f16
  571.     fsel    f20,f0,f20,f16          #if (snext<16) snext = 16
  572.     fctiwz  f0,f20
  573.     stfd    f0,local+8(r1)
  574.     lwz     r31,local+12(r1)        #r31 = (int)snext
  575.     fmadds  f21,f23,f24,f12         #f21 = tnext
  576.     fsubs   f0,f21,f14
  577.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  578.     subf    r29,r8,r31
  579.     fsubs   f0,f21,f16
  580.     fsel    f21,f0,f21,f16          #if (tnext<16) tnext = 16
  581.     fctiwz  f0,f21
  582.     stfd    f0,local+8(r1)
  583.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  584.     subf    r28,r9,r30
  585.     blt     .t8special
  586. .t8qdiv:
  587.     slwi    r0,r10,2
  588.     lwzx    r0,r26,r0
  589.     mulhw   r29,r29,r0
  590.     mulhw   r28,r28,r0
  591.     b       .t8mainloop
  592. .t8special:
  593.     cmplwi  r10,1
  594.     ble     .t8mainloop
  595.     cmplwi  r10,3
  596.     beq     .t8qdiv
  597.     blt     .t8spec_2
  598.     srawi   r29,r29,2
  599.     srawi   r28,r28,2
  600.     b       .t8mainloop
  601. .t8spec_2:
  602.     srawi   r29,r29,1
  603.     srawi   r28,r28,1
  604.  
  605. ######  D_DrawTurbulent8Span (inlined)
  606. ######  Main drawing loop.
  607.  
  608. #        do
  609. #        {
  610. #                sturb = ((r_turb_s + r_turb_turb[(r_turb_t>>16)&(CYCLE-1)])>>16)&63;
  611. #                tturb = ((r_turb_t + r_turb_turb[(r_turb_s>>16)&(CYCLE-1)])>>16)&63;
  612. #                *r_turb_pdest++ = *(r_turb_pbase + (tturb<<6) + sturb);
  613. #                r_turb_s += r_turb_sstep;
  614. #                r_turb_t += r_turb_tstep;
  615. #        } while (--r_turb_spancount > 0);
  616.  
  617.  
  618. .t8mainloop:
  619.     andis.  r8,r8,CYCLE-1
  620.     andis.  r9,r9,CYCLE-1
  621. .t8draw:
  622.     rlwinm  r0,r9,18,23,29        #implicit: CYCLE = 128
  623.     rlwinm  r25,r8,18,23,29        #implicit: CYCLE = 128
  624.     lwzx    r10,r4,r0
  625.     add     r10,r10,r8
  626.     lwzx    r25,r4,r25
  627.     add     r8,r8,r29
  628.     add     r25,r25,r9
  629.     extrwi  r10,r10,6,10
  630.     rlwinm  r25,r25,22,20,25
  631.     add     r10,r10,r25
  632.     add     r9,r9,r28
  633.     lbzx    r0,r27,r10
  634.     stbu    r0,1(r11)
  635.     bdnz    .t8draw
  636.  
  637.     mr      r8,r31
  638.     mr      r9,r30
  639.     mr.    r12,r12
  640.     bgt     .t8loop2
  641.     lwz     r3,4(r3)                #while (...)
  642.     mr.    r3,r3
  643.     subi    r3,r3,4
  644.     bne     .t8loop
  645.  
  646.     lmw    r25,gb(r1)
  647.     lfd    f14,fb+0*8(r1)
  648.     lfd    f15,fb+1*8(r1)
  649.     lfd    f16,fb+2*8(r1)
  650.     lfd    f17,fb+3*8(r1)
  651.     lfd    f18,fb+4*8(r1)
  652.     lfd    f19,fb+5*8(r1)
  653.     lfd    f20,fb+6*8(r1)
  654.     lfd    f21,fb+7*8(r1)
  655.     lfd    f22,fb+8*8(r1)
  656.     lfd    f23,fb+9*8(r1)
  657.     lfd    f24,fb+10*8(r1)
  658.     lfd    f25,fb+11*8(r1)
  659.     lfd    f26,fb+12*8(r1)
  660.     lfd    f27,fb+13*8(r1)
  661.     lfd    f28,fb+14*8(r1)
  662.     lfd    f29,fb+15*8(r1)
  663.     exit
  664.  
  665.     funcend    Turbulent8
  666.  
  667.  
  668.  
  669.  
  670. ###########################################################################
  671. #
  672. #       void D_DrawSpans8 (espan_t *pspan)
  673. #
  674. #       standard scan drawing function (8 pixel subdivision)
  675. #
  676. ###########################################################################
  677.  
  678.     funcdef    D_DrawSpans8
  679.  
  680.     lxa     r4,d_subdiv16        # subdiv16? then call DrawSpans16!
  681.     lfs     f0,CVAR_VALUE(r4)
  682.     ls      f1,c0
  683.     fcmpo   0,f0,f1
  684. .ifdef    WOS
  685.     bne     _D_DrawSpans16
  686. .else
  687.     bne    D_DrawSpans16
  688. .endif
  689.  
  690.     init    0,16,6,16        # 16 local bytes for int2dbl/dbl2int
  691.     stmw    r26,gb(r1)
  692.     stfd    f14,fb+0*8(r1)
  693.     stfd    f15,fb+1*8(r1)
  694.     stfd    f16,fb+2*8(r1)
  695.     stfd    f17,fb+3*8(r1)
  696.     stfd    f18,fb+4*8(r1)
  697.     stfd    f19,fb+5*8(r1)
  698.     stfd    f20,fb+6*8(r1)
  699.     stfd    f21,fb+7*8(r1)
  700.     stfd    f22,fb+8*8(r1)
  701.     stfd    f23,fb+9*8(r1)
  702.     stfd    f24,fb+10*8(r1)
  703.     stfd    f25,fb+11*8(r1)
  704.     stfd    f26,fb+12*8(r1)
  705.     stfd    f27,fb+13*8(r1)
  706.     stfd    f28,fb+14*8(r1)
  707.     stfd    f29,fb+15*8(r1)
  708.  
  709.     lxa     r26,_ReciprocTable
  710.     lw      r27,cacheblock          #r27 = pbase
  711.     lw      r4,cachewidth           #r4 = cachewidth
  712.     ls      f1,d_sdivzstepu         #f1 = d_sdivzstepu
  713.     ls      f2,d_sdivzstepv         #f2 = d_sdivzstepv
  714.     ls      f3,d_sdivzorigin        #f3 = d_sdivzorigin
  715.     ls      f4,d_tdivzstepu         #f4 = d_tdivzstepu
  716.     ls      f5,d_tdivzstepv         #f5 = d_tdivzstepv
  717.     ls      f6,d_tdivzorigin        #f6 = d_tdivzorigin
  718.     ls      f7,d_zistepu            #f7 = d_zistepu
  719.     ls      f8,d_zistepv            #f8 = d_zistepv
  720.     ls      f9,d_ziorigin           #f9 = d_ziorigin
  721.     lf      f10,INT2DBL_0           #for int2dbl_setup
  722.     stfd    f10,local(r1)
  723.     lw      r6,sadjust
  724.     int2dbl f11,r6,r0,local,f10    #f11 = sadjust
  725.     lw      r6,tadjust
  726.     int2dbl f12,r6,r0,local,f10    #f12 = tadjust
  727.     lw      r6,bbextents
  728.     int2dbl f13,r6,r0,local,f10    #f13 = bbextents
  729.     lw      r6,bbextentt
  730.     int2dbl f14,r6,r0,local,f10    #f14 = bbextentt
  731.     lw      r6,d_viewbuffer         #r6 = d_viewbuffer
  732.     lw      r7,screenwidth          #r7 = screenwidth
  733.     ls      f15,c65536              #f15 = 65536
  734.     ls      f16,c8            #f16 = 8
  735.     ls      f25,c0                  #f25 = 0
  736.     ls      f28,c2                  #f28 = 2
  737.     fmuls   f17,f1,f16              #f17 = sdivz8stepu
  738.     fmuls   f18,f4,f16              #f18 = tdivz8stepu
  739.     fmuls   f19,f7,f16              #f19 = zi8stepu
  740.     subi    r3,r3,4                 #prepare for postincrement
  741.  
  742. ######  First loop. In every iteration one complete span is drawn
  743.  
  744. #        pbase = (unsigned char *)cacheblock;
  745. #
  746. #        sdivz8stepu = d_sdivzstepu * 8;
  747. #        tdivz8stepu = d_tdivzstepu * 8;
  748. #        zi8stepu = d_zistepu * 8;
  749. #
  750. #        do
  751. #        {
  752. #                pdest = (unsigned char *)((byte *)d_viewbuffer +
  753. #                                (screenwidth * pspan->v) + pspan->u);
  754. #
  755. #                count = pspan->count;
  756. #
  757. #        // calculate the initial s/z, t/z, 1/z, s, and t and clamp
  758. #                du = (float)pspan->u;
  759. #                dv = (float)pspan->v;
  760. #
  761. #                sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
  762. #                tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
  763. #                zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
  764. #                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  765. #
  766.  
  767. .d8loop:
  768.     lwzu    r8,4(r3)
  769.     int2dbl f20,r8,r0,local,f10    #f20 = du
  770.     lwzu    r9,4(r3)
  771.     int2dbl f21,r9,r0,local,f10    #f21 = dv
  772.     fmadds  f24,f21,f8,f9
  773.     fmadds  f22,f21,f2,f3
  774.     fmadds  f23,f21,f5,f6
  775.     fmadds  f26,f20,f7,f24          #f26 = zi
  776.     fmadds  f22,f20,f1,f22          #f22 = sdivz
  777.     fmadds  f23,f20,f4,f23          #f23 = tdivz
  778.     fmuls   f0,f26,f26
  779.     frsqrte f0,f0
  780.     mullw   r10,r9,r7               #r10 = pspan->v * screenwidth
  781.     fnmsubs f29,f0,f26,f28
  782.     add     r10,r10,r8              #r10 = r10 + pspan->u
  783.     fmuls   f0,f0,f29
  784.     add     r11,r6,r10              #r11 = pdest
  785.     fnmsubs f29,f0,f26,f28
  786.     subi    r11,r11,1               #prepare for postincrement
  787.     fmuls   f0,f0,f29
  788.     lwzu    r12,4(r3)               #r12 = count
  789.     fmuls   f24,f0,f15
  790.     fmadds  f20,f22,f24,f11         #f20 = s
  791.     fsubs   f0,f20,f13
  792.     fsel    f20,f0,f13,f20          #if (s>bb...) s = bbextents
  793.     fsel    f20,f20,f20,f25         #if (s<0) s = 0
  794.     fctiwz  f0,f20
  795.     stfd    f0,local+8(r1)
  796.     lwz     r8,local+12(r1)         #r8 = (int)s
  797.     fmadds  f21,f23,f24,f12         #f21 = t
  798.     fsubs   f0,f21,f14
  799.     fsel    f21,f0,f14,f21          #if (t>bb...) t = bbextentt
  800.     fsel    f21,f21,f21,f25         #if (t<0) t = 0
  801.     fctiwz  f0,f21
  802.     stfd    f0,local+8(r1)
  803.     lwz     r9,local+12(r1)         #r9 = (int)t
  804.     li      r0,1
  805.     dcbtst  r11,r0
  806.  
  807.  
  808. ######  Second loop. In every iteration one part of the whole span is drawn
  809.  
  810. #                do
  811. #                {
  812. #                // calculate s and t at the far end of the span
  813. #                        if (count >= 8)
  814. #                                spancount = 8;
  815. #                        else
  816. #                                spancount = count;
  817. #
  818. #                        count -= spancount;
  819. #
  820. #                        if (count)
  821. #                        {
  822.  
  823. .d8loop2:
  824.     cmpwi   r12,8
  825.     bgt     .d8cont
  826.     mtctr   r12
  827.     subi    r10,r12,1
  828.     int2dbl f21,r10,r0,local,f10    #spancountminus1 = (float)...
  829.     li      r12,0                   #r12 = count -= spancount
  830.     fmadds  f26,f21,f7,f26          #zi += d_zistepu # ...
  831.     b       .d8finalpart
  832. .d8cont:
  833.     fadds   f26,f26,f19             #zi += zi8stepu
  834.     li      r10,8                   #r10 = spancount = 8
  835.     fmuls   f0,f26,f26
  836.     subf    r12,r10,r12             #r12 = count -= spancount
  837.     frsqrte f0,f0
  838.     mtctr   r10
  839.  
  840. ######  Evaluation of the values for the inner loop. This version is used for
  841. ######  span size = 8
  842.  
  843. #                        // calculate s/z, t/z, zi->fixed s and t at far end of span,
  844. #                        // calculate s and t steps across span by shifting
  845. #                                sdivz += sdivz8stepu;
  846. #                                tdivz += tdivz8stepu;
  847. #                                zi += zi8stepu;
  848. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  849. #                                snext = (int)(sdivz * z) + sadjust;
  850. #                                if (snext > bbextents)
  851. #                                        snext = bbextents;
  852. #                                else if (snext < 8)
  853. #                                        snext = 8;      // prevent round-off error on <0 steps from
  854. #                                                                //  from causing overstepping & running off the
  855. #                                                                //  edge of the texture
  856. #                                tnext = (int)(tdivz * z) + tadjust;
  857. #                                if (tnext > bbextentt)
  858. #                                        tnext = bbextentt;
  859. #                                else if (tnext < 8)
  860. #                                        tnext = 8;      // guard against round-off error on <0 steps
  861. #                                sstep = (snext - s) >> 3;
  862. #                                tstep = (tnext - t) >> 3;
  863. #                        }
  864.  
  865.     fnmsubs f20,f0,f26,f28
  866.     fadds   f22,f22,f17             #sdivz += sdivz8stepu
  867.     fmuls   f0,f0,f20
  868.     fadds   f23,f23,f18             #tdivz += tdivz8stepu
  869.     fnmsubs f20,f0,f26,f28
  870.     fmuls   f0,f0,f20
  871.     fmuls   f24,f0,f15
  872.     fmadds  f20,f22,f24,f11         #f20 = snext
  873.     fsubs   f0,f20,f13
  874.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  875.     fsubs   f0,f20,f16
  876.     fsel    f20,f0,f20,f16          #if (snext<8) snext = 8
  877.     fctiwz  f0,f20
  878.     stfd    f0,local+8(r1)
  879.     lwz     r31,local+12(r1)        #r31 = (int)snext
  880.     fmadds  f21,f23,f24,f12         #f21 = tnext
  881.     fsubs   f0,f21,f14
  882.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  883.     subf    r29,r8,r31
  884.     fsubs   f0,f21,f16
  885.     srawi   r29,r29,3               #r29 = sstep = (snext - s) >> 3
  886.     fsel    f21,f0,f21,f16          #if (tnext<8) tnext = 8
  887.     fctiwz  f0,f21
  888.     stfd    f0,local+8(r1)
  889.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  890.     subf    r28,r9,r30
  891.     srawi   r28,r28,3               #r28 = tstep = (tnext - t) >> 3
  892.     b       .d8mainloop
  893.  
  894. ######  Evaluation of the values for the inner loop. This version is used for
  895. ######  span size < 8
  896.  
  897. ######  The original algorithm has two ugly divisions at the end of this part.
  898. ######  These are removed by the following optimization:
  899. ######  First, the divisors 1,2 and 4 are handled specially to gain speed. The
  900. ######  other divisors are handled using a reciprocal table.
  901.  
  902. #                        // calculate s/z, t/z, zi->fixed s and t at last pixel in span (so
  903. #                        // can't step off polygon), clamp, calculate s and t steps across
  904. #                        // span by division, biasing steps low so we don't run off the
  905. #                        // texture
  906. #                                spancountminus1 = (float)(spancount - 1);
  907. #                                sdivz += d_sdivzstepu * spancountminus1;
  908. #                                tdivz += d_tdivzstepu * spancountminus1;
  909. #                                zi += d_zistepu * spancountminus1;
  910. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  911. #                                snext = (int)(sdivz * z) + sadjust;
  912. #                                if (snext > bbextents)
  913. #                                        snext = bbextents;
  914. #                                else if (snext < 8)
  915. #                                        snext = 8;      // prevent round-off error on <0 steps from
  916. #                                                                //  from causing overstepping & running off the
  917. #                                                                //  edge of the texture
  918. #
  919. #                                tnext = (int)(tdivz * z) + tadjust;
  920. #                                if (tnext > bbextentt)
  921. #                                        tnext = bbextentt;
  922. #                                else if (tnext < 8)
  923. #                                        tnext = 8;      // guard against round-off error on <0 steps
  924. #
  925. #                                if (spancount > 1)
  926. #                                {
  927. #                                        sstep = (snext - s) / (spancount - 1);
  928. #                                        tstep = (tnext - t) / (spancount - 1);
  929. #                                }
  930. #                        }
  931.  
  932. .d8finalpart:
  933.     fmuls   f0,f26,f26
  934.     fmadds  f22,f21,f1,f22          #sdivz += d_sdivzstepu * ...
  935.     frsqrte f0,f0
  936.     fmadds  f23,f21,f4,f23          #tdivs += d_tdivzstepu * ...
  937.     fnmsubs f20,f0,f26,f28
  938.     cmplwi  r10,5
  939.     fmuls   f0,f0,f20
  940.     fnmsubs f20,f0,f26,f28
  941.     fmuls   f0,f0,f20
  942.     fmuls   f24,f0,f15
  943.     fmadds  f20,f22,f24,f11         #f27 = snext
  944.     fsubs   f0,f20,f13
  945.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  946.     fsubs   f0,f20,f16
  947.     fsel    f20,f0,f20,f16          #if (snext<8) snext = 8
  948.     fctiwz  f0,f20
  949.     stfd    f0,local+8(r1)
  950.     lwz     r31,local+12(r1)        #r31 = (int)snext
  951.     fmadds  f21,f23,f24,f12         #f21 = tnext
  952.     fsubs   f0,f21,f14
  953.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  954.     subf    r29,r8,r31
  955.     fsubs   f0,f21,f16
  956.     fsel    f21,f0,f21,f16          #if (tnext<8) tnext = 8
  957.     fctiwz  f0,f21
  958.     stfd    f0,local+8(r1)
  959.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  960.     subf    r28,r9,r30
  961.     blt     .d8special
  962. .d8qdiv:
  963.     slwi    r0,r10,2
  964.     lwzx    r0,r26,r0
  965.     mulhw   r29,r29,r0
  966.     mulhw   r28,r28,r0
  967.     b       .d8mainloop
  968. .d8special:
  969.     cmplwi  r10,1
  970.     ble     .d8mainloop
  971.     cmplwi  r10,3
  972.     beq     .d8qdiv
  973.     blt     .d8spec_2
  974.     srawi   r29,r29,2
  975.     srawi   r28,r28,2
  976.     b       .d8mainloop
  977. .d8spec_2:
  978.     srawi   r29,r29,1
  979.     srawi   r28,r28,1
  980.  
  981. ######  Main drawing loop. Here lies the speed.
  982.  
  983. #                        do
  984. #                        {
  985. #                                *pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
  986. #                                s += sstep;
  987. #                                t += tstep;
  988. #                        } while (--spancount > 0);
  989.  
  990. .d8mainloop:
  991.     srawi   r0,r9,16
  992.     srawi   r10,r8,16
  993.     mullw   r0,r0,r4
  994.     add     r9,r9,r28
  995.     add     r0,r0,r10
  996.     add     r8,r8,r29
  997.     lbzx    r0,r27,r0
  998.     stbu    r0,1(r11)
  999.     bdnz    .d8mainloop
  1000.     mr      r8,r31
  1001.     mr      r9,r30
  1002.     mr.    r12,r12
  1003.     bgt     .d8loop2
  1004.     lwz     r3,4(r3)                #while (...)
  1005.     mr.    r3,r3
  1006.     subi    r3,r3,4
  1007.     bne     .d8loop
  1008.  
  1009.     lmw    r26,gb(r1)
  1010.     lfd    f14,fb+0*8(r1)
  1011.     lfd    f15,fb+1*8(r1)
  1012.     lfd    f16,fb+2*8(r1)
  1013.     lfd    f17,fb+3*8(r1)
  1014.     lfd    f18,fb+4*8(r1)
  1015.     lfd    f19,fb+5*8(r1)
  1016.     lfd    f20,fb+6*8(r1)
  1017.     lfd    f21,fb+7*8(r1)
  1018.     lfd    f22,fb+8*8(r1)
  1019.     lfd    f23,fb+9*8(r1)
  1020.     lfd    f24,fb+10*8(r1)
  1021.     lfd    f25,fb+11*8(r1)
  1022.     lfd    f26,fb+12*8(r1)
  1023.     lfd    f27,fb+13*8(r1)
  1024.     lfd    f28,fb+14*8(r1)
  1025.     lfd    f29,fb+15*8(r1)
  1026.     exit
  1027.  
  1028.     funcend    D_DrawSpans8
  1029.  
  1030.  
  1031.  
  1032.  
  1033. ###########################################################################
  1034. #
  1035. #       void D_DrawSpans16 (espan_t *pspan)
  1036. #
  1037. #       standard scan drawing function (16 pixel subdivision)
  1038. #
  1039. ###########################################################################
  1040.  
  1041.     funcdef    D_DrawSpans16
  1042.  
  1043.     init    0,16,6,16        # 16 local bytes for int2dbl/dbl2int
  1044.     stmw    r26,gb(r1)
  1045.     stfd    f14,fb+0*8(r1)
  1046.     stfd    f15,fb+1*8(r1)
  1047.     stfd    f16,fb+2*8(r1)
  1048.     stfd    f17,fb+3*8(r1)
  1049.     stfd    f18,fb+4*8(r1)
  1050.     stfd    f19,fb+5*8(r1)
  1051.     stfd    f20,fb+6*8(r1)
  1052.     stfd    f21,fb+7*8(r1)
  1053.     stfd    f22,fb+8*8(r1)
  1054.     stfd    f23,fb+9*8(r1)
  1055.     stfd    f24,fb+10*8(r1)
  1056.     stfd    f25,fb+11*8(r1)
  1057.     stfd    f26,fb+12*8(r1)
  1058.     stfd    f27,fb+13*8(r1)
  1059.     stfd    f28,fb+14*8(r1)
  1060.     stfd    f29,fb+15*8(r1)
  1061.  
  1062.     lxa     r26,_ReciprocTable
  1063.     lw      r27,cacheblock          #r27 = pbase
  1064.     lw      r4,cachewidth           #r4 = cachewidth
  1065.     ls      f1,d_sdivzstepu         #f1 = d_sdivzstepu
  1066.     ls      f2,d_sdivzstepv         #f2 = d_sdivzstepv
  1067.     ls      f3,d_sdivzorigin        #f3 = d_sdivzorigin
  1068.     ls      f4,d_tdivzstepu         #f4 = d_tdivzstepu
  1069.     ls      f5,d_tdivzstepv         #f5 = d_tdivzstepv
  1070.     ls      f6,d_tdivzorigin        #f6 = d_tdivzorigin
  1071.     ls      f7,d_zistepu            #f7 = d_zistepu
  1072.     ls      f8,d_zistepv            #f8 = d_zistepv
  1073.     ls      f9,d_ziorigin           #f9 = d_ziorigin
  1074.     lf      f10,INT2DBL_0           #for int2dbl_setup
  1075.     stfd    f10,local(r1)
  1076.     lw      r6,sadjust
  1077.     int2dbl f11,r6,r0,local,f10    #f11 = sadjust
  1078.     lw      r6,tadjust
  1079.     int2dbl f12,r6,r0,local,f10    #f12 = tadjust
  1080.     lw      r6,bbextents
  1081.     int2dbl f13,r6,r0,local,f10    #f13 = bbextents
  1082.     lw      r6,bbextentt
  1083.     int2dbl f14,r6,r0,local,f10    #f14 = bbextentt
  1084.     lw      r6,d_viewbuffer         #r6 = d_viewbuffer
  1085.     lw      r7,screenwidth          #r7 = screenwidth
  1086.     ls      f15,c65536              #f15 = 65536
  1087.     ls      f16,c16                 #f16 = 16
  1088.     ls      f25,c0                  #f25 = 0
  1089.     ls      f28,c2                  #f28 = 2
  1090.     fmuls   f17,f1,f16              #f17 = sdivz16stepu
  1091.     fmuls   f18,f4,f16              #f18 = tdivz16stepu
  1092.     fmuls   f19,f7,f16              #f19 = zi16stepu
  1093.     subi    r3,r3,4                 #prepare for postincrement
  1094.  
  1095. ######  First loop. In every iteration one complete span is drawn
  1096.  
  1097. #        pbase = (unsigned char *)cacheblock;
  1098. #
  1099. #        sdivz16stepu = d_sdivzstepu * 16;
  1100. #        tdivz16stepu = d_tdivzstepu * 16;
  1101. #        zi16stepu = d_zistepu * 16;
  1102. #
  1103. #        do
  1104. #        {
  1105. #                pdest = (unsigned char *)((byte *)d_viewbuffer +
  1106. #                                (screenwidth * pspan->v) + pspan->u);
  1107. #
  1108. #                count = pspan->count;
  1109. #
  1110. #        // calculate the initial s/z, t/z, 1/z, s, and t and clamp
  1111. #                du = (float)pspan->u;
  1112. #                dv = (float)pspan->v;
  1113. #
  1114. #                sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
  1115. #                tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
  1116. #                zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
  1117. #                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  1118. #
  1119.  
  1120. .d16loop:
  1121.     lwzu    r8,4(r3)
  1122.     int2dbl f20,r8,r0,local,f10    #f20 = du
  1123.     lwzu    r9,4(r3)
  1124.     int2dbl f21,r9,r0,local,f10    #f21 = dv
  1125.     fmadds  f24,f21,f8,f9
  1126.     fmadds  f22,f21,f2,f3
  1127.     fmadds  f23,f21,f5,f6
  1128.     fmadds  f26,f20,f7,f24          #f26 = zi
  1129.     fmadds  f22,f20,f1,f22          #f22 = sdivz
  1130.     fmadds  f23,f20,f4,f23          #f23 = tdivz
  1131.     fmuls   f0,f26,f26
  1132.     frsqrte f0,f0
  1133.     mullw   r10,r9,r7               #r10 = pspan->v * screenwidth
  1134.     fnmsubs f29,f0,f26,f28
  1135.     add     r10,r10,r8              #r10 = r10 + pspan->u
  1136.     fmuls   f0,f0,f29
  1137.     add     r11,r6,r10              #r11 = pdest
  1138.     fnmsubs f29,f0,f26,f28
  1139.     subi    r11,r11,1               #prepare for postincrement
  1140.     fmuls   f0,f0,f29
  1141.     lwzu    r12,4(r3)               #r12 = count
  1142.     fmuls   f24,f0,f15
  1143.     fmadds  f20,f22,f24,f11         #f20 = s
  1144.     fsubs   f0,f20,f13
  1145.     fsel    f20,f0,f13,f20          #if (s>bb...) s = bbextents
  1146.     fsel    f20,f20,f20,f25         #if (s<0) s = 0
  1147.     fctiwz  f0,f20
  1148.     stfd    f0,local+8(r1)
  1149.     lwz     r8,local+12(r1)         #r8 = (int)s
  1150.     fmadds  f21,f23,f24,f12         #f21 = t
  1151.     fsubs   f0,f21,f14
  1152.     fsel    f21,f0,f14,f21          #if (t>bb...) t = bbextentt
  1153.     fsel    f21,f21,f21,f25         #if (t<0) t = 0
  1154.     fctiwz  f0,f21
  1155.     stfd    f0,local+8(r1)
  1156.     lwz     r9,local+12(r1)         #r9 = (int)t
  1157.     li      r0,1
  1158.     dcbtst  r11,r0
  1159.  
  1160. ######  Second loop. In every iteration one part of the whole span is drawn
  1161.  
  1162. #                do
  1163. #                {
  1164. #                // calculate s and t at the far end of the span
  1165. #                        if (count >= 16)
  1166. #                                spancount = 16;
  1167. #                        else
  1168. #                                spancount = count;
  1169. #
  1170. #                        count -= spancount;
  1171. #
  1172. #                        if (count)
  1173. #                        {
  1174.  
  1175. .d16loop2:
  1176.     cmpwi   r12,16
  1177.     bgt     .d16cont
  1178.     mtctr   r12
  1179.     subi    r10,r12,1
  1180.     int2dbl f21,r10,r0,local,f10    #spancountminus1 = (float)...
  1181.     li      r12,0                   #r12 = count -= spancount
  1182.     fmadds  f26,f21,f7,f26          #zi += d_zistepu * ...
  1183.     b       .d16finalpart
  1184. .d16cont:
  1185.     fadds   f26,f26,f19             #zi += zi16stepu
  1186.     li      r10,16                  #r10 = spancount = 16
  1187.     fmuls   f0,f26,f26
  1188.     subf    r12,r10,r12             #r12 = count -= spancount
  1189.     frsqrte f0,f0
  1190.     mtctr   r10
  1191.  
  1192. #######  Evaluation of the values for the inner loop. This version is used for
  1193. #######  span size = 16
  1194.  
  1195. #                        // calculate s/z, t/z, zi->fixed s and t at far end of span,
  1196. #                        // calculate s and t steps across span by shifting
  1197. #                                sdivz += sdivz16stepu;
  1198. #                                tdivz += tdivz16stepu;
  1199. #                                zi += zi16stepu;
  1200. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  1201. #                                snext = (int)(sdivz * z) + sadjust;
  1202. #                                if (snext > bbextents)
  1203. #                                        snext = bbextents;
  1204. #                                else if (snext < 16)
  1205. #                                        snext = 16;      // prevent round-off error on <0 steps from
  1206. #                                                                //  from causing overstepping & running off the
  1207. #                                                                //  edge of the texture
  1208. #                                tnext = (int)(tdivz * z) + tadjust;
  1209. #                                if (tnext > bbextentt)
  1210. #                                        tnext = bbextentt;
  1211. #                                else if (tnext < 16)
  1212. #                                        tnext = 16;      // guard against round-off error on <0 steps
  1213. #                                sstep = (snext - s) >> 4;
  1214. #                                tstep = (tnext - t) >> 4;
  1215. #                        }
  1216.  
  1217.     fnmsubs f20,f0,f26,f28
  1218.     fadds   f22,f22,f17             #sdivz += sdivz16stepu
  1219.     fmuls   f0,f0,f20
  1220.     fadds   f23,f23,f18             #tdivz += tdivz16stepu
  1221.     fnmsubs f20,f0,f26,f28
  1222.     fmuls   f0,f0,f20
  1223.     fmuls   f24,f0,f15
  1224.     fmadds  f20,f22,f24,f11         #f20 = snext
  1225.     fsubs   f0,f20,f13
  1226.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  1227.     fsubs   f0,f20,f16
  1228.     fsel    f20,f0,f20,f16          #if (snext<16) snext = 16
  1229.     fctiwz  f0,f20
  1230.     stfd    f0,local+8(r1)
  1231.     lwz     r31,local+12(r1)        #r31 = (int)snext
  1232.     fmadds  f21,f23,f24,f12         #f21 = tnext
  1233.     fsubs   f0,f21,f14
  1234.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  1235.     subf    r29,r8,r31
  1236.     fsubs   f0,f21,f16
  1237.     srawi   r29,r29,4               #r29 = sstep = (snext - s) >> 4
  1238.     fsel    f21,f0,f21,f16          #if (tnext<16) tnext = 16
  1239.     fctiwz  f0,f21
  1240.     stfd    f0,local+8(r1)
  1241.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  1242.     subf    r28,r9,r30
  1243.     srawi   r28,r28,4               #r28 = tstep = (tnext - t) >> 4
  1244.     b       .d16mainloop
  1245.  
  1246. ######  Evaluation of the values for the inner loop. This version is used for
  1247. ######  span size < 16
  1248.  
  1249. ######  The original algorithm has two ugly divisions at the end of this part.
  1250. ######  These are removed by the following optimization:
  1251. ######  First, the divisors 1,2 and 4 are handled specially to gain speed. The
  1252. ######  other divisors are handled using a reciprocal table.
  1253.  
  1254. #                        // calculate s/z, t/z, zi->fixed s and t at last pixel in span (so
  1255. #                        // can't step off polygon), clamp, calculate s and t steps across
  1256. #                        // span by division, biasing steps low so we don't run off the
  1257. #                        // texture
  1258. #                                spancountminus1 = (float)(spancount - 1);
  1259. #                                sdivz += d_sdivzstepu * spancountminus1;
  1260. #                                tdivz += d_tdivzstepu * spancountminus1;
  1261. #                                zi += d_zistepu * spancountminus1;
  1262. #                                z = (float)0x10000 / zi;        // prescale to 16.16 fixed-point
  1263. #                                snext = (int)(sdivz * z) + sadjust;
  1264. #                                if (snext > bbextents)
  1265. #                                        snext = bbextents;
  1266. #                                else if (snext < 16)
  1267. #                                        snext = 16;      // prevent round-off error on <0 steps from
  1268. #                                                                //  from causing overstepping & running off the
  1269. #                                                                //  edge of the texture
  1270. #
  1271. #                                tnext = (int)(tdivz * z) + tadjust;
  1272. #                                if (tnext > bbextentt)
  1273. #                                        tnext = bbextentt;
  1274. #                                else if (tnext < 16)
  1275. #                                        tnext = 16;      // guard against round-off error on <0 steps
  1276. #
  1277. #                                if (spancount > 1)
  1278. #                                {
  1279. #                                        sstep = (snext - s) / (spancount - 1);
  1280. #                                        tstep = (tnext - t) / (spancount - 1);
  1281. #                                }
  1282. #                        }
  1283.  
  1284. .d16finalpart:
  1285.     fmuls   f0,f26,f26
  1286.     fmadds  f22,f21,f1,f22          #sdivz += d_sdivzstepu * ...
  1287.     frsqrte f0,f0
  1288.     fmadds  f23,f21,f4,f23          #tdivs += d_tdivzstepu * ...
  1289.     fnmsubs f20,f0,f26,f28
  1290.     cmplwi  r10,5
  1291.     fmuls   f0,f0,f20
  1292.     fnmsubs f20,f0,f26,f28
  1293.     fmuls   f0,f0,f20
  1294.     fmuls   f24,f0,f15
  1295.     fmadds  f20,f22,f24,f11         #f27 = snext
  1296.     fsubs   f0,f20,f13
  1297.     fsel    f20,f0,f13,f20          #if (snext>bb...) snext = bbextents
  1298.     fsubs   f0,f20,f16
  1299.     fsel    f20,f0,f20,f16          #if (snext<16) snext = 16
  1300.     fctiwz  f0,f20
  1301.     stfd    f0,local+8(r1)
  1302.     lwz     r31,local+12(r1)        #r31 = (int)snext
  1303.     fmadds  f21,f23,f24,f12         #f21 = tnext
  1304.     fsubs   f0,f21,f14
  1305.     fsel    f21,f0,f14,f21          #if (tnext>bb...) tnext = bbextentt
  1306.     subf    r29,r8,r31
  1307.     fsubs   f0,f21,f16
  1308.     fsel    f21,f0,f21,f16          #if (tnext<16) tnext = 16
  1309.     fctiwz  f0,f21
  1310.     stfd    f0,local+8(r1)
  1311.     lwz     r30,local+12(r1)        #r30 = (int)tnext
  1312.     subf    r28,r9,r30
  1313.     blt     .d16special
  1314. .d16qdiv:
  1315.     slwi    r0,r10,2
  1316.     lwzx    r0,r26,r0
  1317.     mulhw   r29,r29,r0
  1318.     mulhw   r28,r28,r0
  1319.     b       .d16mainloop
  1320. .d16special:
  1321.     cmplwi  r10,1
  1322.     ble     .d16mainloop
  1323.     cmplwi  r10,3
  1324.     beq     .d16qdiv
  1325.     blt     .d16spec_2
  1326.     srawi   r29,r29,2
  1327.     srawi   r28,r28,2
  1328.     b       .d16mainloop
  1329. .d16spec_2:
  1330.     srawi   r29,r29,1
  1331.     srawi   r28,r28,1
  1332.  
  1333. ######  Main drawing loop. Here lies the speed.
  1334.  
  1335. #                        do
  1336. #                        {
  1337. #                                *pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
  1338. #                                s += sstep;
  1339. #                                t += tstep;
  1340. #                        } while (--spancount > 0);
  1341.  
  1342. .d16mainloop:
  1343.     srawi   r0,r9,16
  1344.     srawi   r10,r8,16
  1345.     mullw   r0,r0,r4
  1346.     add     r9,r9,r28
  1347.     add     r0,r0,r10
  1348.     add     r8,r8,r29
  1349.     lbzx    r0,r27,r0
  1350.     stbu    r0,1(r11)
  1351.     bdnz    .d16mainloop
  1352.     mr      r8,r31
  1353.     mr      r9,r30
  1354.     mr.    r12,r12
  1355.     bgt     .d16loop2
  1356.     lwz     r3,4(r3)                #while (...)
  1357.     mr.    r3,r3
  1358.     subi    r3,r3,4
  1359.     bne     .d16loop
  1360.  
  1361.     lmw    r26,gb(r1)
  1362.     lfd    f14,fb+0*8(r1)
  1363.     lfd    f15,fb+1*8(r1)
  1364.     lfd    f16,fb+2*8(r1)
  1365.     lfd    f17,fb+3*8(r1)
  1366.     lfd    f18,fb+4*8(r1)
  1367.     lfd    f19,fb+5*8(r1)
  1368.     lfd    f20,fb+6*8(r1)
  1369.     lfd    f21,fb+7*8(r1)
  1370.     lfd    f22,fb+8*8(r1)
  1371.     lfd    f23,fb+9*8(r1)
  1372.     lfd    f24,fb+10*8(r1)
  1373.     lfd    f25,fb+11*8(r1)
  1374.     lfd    f26,fb+12*8(r1)
  1375.     lfd    f27,fb+13*8(r1)
  1376.     lfd    f28,fb+14*8(r1)
  1377.     lfd    f29,fb+15*8(r1)
  1378.     exit
  1379.  
  1380.     funcend    D_DrawSpans16
  1381.  
  1382.  
  1383.  
  1384.  
  1385. ###########################################################################
  1386. #
  1387. #       void D_DrawZSpans (espan_t *pspan)
  1388. #                          r3
  1389. #
  1390. #       standard z-scan drawing function
  1391. #
  1392. ###########################################################################
  1393.  
  1394.     funcdef    D_DrawZSpans
  1395.  
  1396.     init    0,16,0,0        # 16 local bytes for int2dbl/dbl2int
  1397.     lf      f1,INT2DBL_0            #for int2dbl_setup
  1398.     stfd    f1,local(r1)
  1399.  
  1400.     ls      f2,cHUGE                #f2 = 0x8000*0x10000
  1401.     ls      f3,d_zistepu            #f3 = d_zistepu
  1402.     ls      f4,d_zistepv            #f4 = d_zistepv
  1403.     ls      f5,d_ziorigin           #f5 = d_ziorigin
  1404.     lw      r5,d_pzbuffer           #r5 = d_pzbuffer
  1405.     lw      r6,d_zwidth             #r6 = d_zwidth
  1406.  
  1407. #        izistep = (int)(d_zistepu * 0x8000 * 0x10000);
  1408.  
  1409.     fmuls   f6,f3,f2
  1410.     fctiwz  f0,f6
  1411.     stfd    f0,local+8(r1)
  1412.     lwz     r7,local+12(r1)         #r7 = izistep
  1413.     subi    r3,r3,4                 #prepare for postincrement
  1414.  
  1415. #                pdest = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
  1416. #
  1417. #                count = pspan->count;
  1418. #
  1419. #        // calculate the initial 1/z
  1420. #                du = (float)pspan->u;
  1421. #                dv = (float)pspan->v;
  1422. #
  1423. #                zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
  1424. #        // we count on FP exceptions being turned off to avoid range problems
  1425. #                izi = (int)(zi * 0x8000 * 0x10000);
  1426.  
  1427.  
  1428. .zloop:
  1429.     lwzu    r8,4(r3)                #r8 = pspan->u
  1430.     lwzu    r9,4(r3)                #r9 = pspan->v
  1431.     lwzu    r10,4(r3)               #r10 = pspan->count
  1432.     mullw   r11,r9,r6
  1433.     add     r11,r11,r8
  1434.     add     r11,r11,r11
  1435.     add     r12,r5,r11              #r12 = pdest = d_pzbuffer + ...
  1436.     int2dbl f7,r8,r0,local,f1    #f7 = du
  1437.     int2dbl f8,r9,r0,local,f1    #f8 = dv
  1438.     fmadds  f10,f8,f4,f5
  1439.     subi    r12,r12,4
  1440.     fmadds  f10,f7,f3,f10           #zi = d_ziorigin + ...
  1441.     fmuls   f7,f10,f2
  1442.     fctiwz  f0,f7
  1443.     stfd    f0,local+8(r1)
  1444.     lwz     r8,local+12(r1)         #r8 = izi = (int)(zi * ...)
  1445.  
  1446. #                if ((long)pdest & 0x02)
  1447. #                {
  1448. #                        *pdest++ = (short)(izi >> 16);
  1449. #                        izi += izistep;
  1450. #                        count--;
  1451. #                }
  1452.  
  1453.     andi.   r0,r12,2                #if (long)pdest & 0x02
  1454.     beq     .zcont
  1455.     srawi   r0,r8,16
  1456.     sth     r0,4(r12)               #*pdest++ (short)(izi >> 16)
  1457.     addi    r12,r12,2
  1458.     add     r8,r8,r7                #izi += izistep
  1459.     subi    r10,r10,1               #count--
  1460. .zcont:
  1461.  
  1462.  
  1463. #                if ((doublecount = count >> 1) > 0)
  1464. #                {
  1465. #                        do
  1466. #                        {
  1467. #                                ltemp = izi >> 16;
  1468. #                                izi += izistep;
  1469. #                                ltemp |= izi & 0xFFFF0000;
  1470. #                                izi += izistep;
  1471. #                                *(int *)pdest = ltemp;
  1472. #                                pdest += 2;
  1473. #                        } while (--doublecount > 0);
  1474. #                }
  1475.  
  1476.     srawi.  r0,r10,1                #if ((doublecount = count >> 1))
  1477.     ble     .zcont2
  1478.     mtctr   r0
  1479. .zloop2:
  1480.     srawi   r0,r8,16                #ltemp = izi >> 16
  1481.     add     r8,r8,r7                #izi += izistep
  1482.     inslwi  r0,r8,16,0              #ltemp |= izi & 0xFFFF0000
  1483.     add     r8,r8,r7                #izi += izistep
  1484.     stwu    r0,4(r12)               #*(int *)pdest = ltemp
  1485.     bdnz    .zloop2
  1486. .zcont2:
  1487.  
  1488. #                if (count & 1)
  1489. #                        *pdest = (short)(izi >> 16);
  1490.  
  1491.     andi.   r0,r10,1                #if (count & 1)
  1492.     beq     .zcont3
  1493.     srawi   r0,r8,16                #*pdest = (short)(izi >> 16)
  1494.     sth     r0,4(r12)
  1495. .zcont3:
  1496.  
  1497. #        } while ((pspan = pspan->pnext) != NULL);
  1498.  
  1499.     lwz     r3,4(r3)                #while (...)
  1500.     mr.    r3,r3
  1501.     subi    r3,r3,4
  1502.     bne     .zloop
  1503.  
  1504.     exit
  1505.  
  1506.     funcend    D_DrawZSpans
  1507.  
  1508.  
  1509.  
  1510.  
  1511. .ifdef    WOS
  1512.     .tocd
  1513. .else
  1514.     .data
  1515. .endif
  1516.  
  1517. lab c8
  1518.     .float    8.0
  1519. lab c16
  1520.     .float    16.0
  1521. lab cHUGE
  1522.     .float    2147483648.0
  1523. lab cSPEED
  1524.     .float    20
  1525. lab cAMP2times2
  1526.     .float    6.0    # 2 * AMP2
  1527. .ifne AMP2-3
  1528. .fail "AMP2 must be 3!"
  1529. .endif
  1530.