home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 February / Gamestar_70_2005-02_dvd.iso / DVDStar / Editace / ogierinstall_103.exe / VP.xrg < prev    next >
Text File  |  2004-12-21  |  52KB  |  2,378 lines

  1.  
  2. /*»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*\
  3.     File:            General vertex program pipeline
  4.                     
  5.     Author:            Magnus H÷gdahl
  6.                     
  7.     Copyright:        Starbreeze Studios 2001
  8.                     
  9.     Comments:        This file implements a vertex processing pipeline that provide
  10.                     all functionality found in a standard fixed function pipeline that
  11.                     is required by GL/D3D rendering contexts.
  12.                     In addition to emulating the fixed pipeline, the vertex program 
  13.                     pipeline provide functionality such as matrix palette transformation 
  14.                     and new texture coordinate generation modes.
  15.  
  16.                     Vertex programs are assembled using defines to enable and disable
  17.                     program segments from this source file.
  18.  
  19.     History:        
  20.         010830:        Created File
  21.  
  22.         021121:        Nice history...
  23.  
  24. \*____________________________________________________________________________________________*/
  25.  
  26. /*************************************************************************************************\
  27. |»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  28. | Comments
  29. |__________________________________________________________________________________________________
  30. \*************************************************************************************************/
  31.  
  32. /*
  33.     Dynamic constants:
  34.  
  35.     $MP                Matrix palette
  36.     $LIGHT            Lights
  37.     $TEXPARAMx        Texture coordinate generation parameters, x = [0..CRC_MAXTEXTURE[
  38.     $TEXMATRIXx        Texture transform matrix, x = [0..CRC_MAXTEXTURE[
  39.     $CONSTANTCOLOR    Constant color
  40.     $POSTRANS        Position MAD parameters
  41.     $TEXTURETRANSx  Texture MAD parameters
  42.  
  43.  
  44.     Registers:
  45.  
  46.     R0                If matrixpalette: Vertex 4x3 transform. (Model-space to animated model-space)
  47.     R1                If matrixpalette: Vertex 4x3 transform. (Model-space to animated model-space)
  48.     R2                If matrixpalette: Vertex 4x3 transform. (Model-space to animated model-space)
  49.  
  50.     R8                Model-space vertex position. (After MP transform)
  51.     R9                Model-space normal. (if lighting is enabled)
  52.     R10                Diffuse color. (if lighting is enabled)
  53.     R11                Specular color. (if lighting is enabled) (NOT IMPLEMENTED)
  54.  
  55.  
  56.     Static constants:
  57.  
  58.     c[0..3]            Model*Projection    (Model-space to clip-space)
  59.     c[4..7]            Model                (Model-space to view-space)
  60.     c[$BASE+8].x            0.0f
  61.     c[$BASE+8].y            1.0f
  62.     c[$BASE+8].z            0.5f
  63.     c[$BASE+8].w            2*255.0001f        // Bone index multiplier.
  64.     c[$BASE+9].x            2.0f
  65.     c[$BASE+9].y            0 // Unused
  66.     c[$BASE+9].z            0 // Unused
  67.     c[$BASE+9].w            0 // Unused
  68.  
  69.  
  70.  
  71.     Quaternion -> Matrix:
  72.  
  73.         T xs,ys,zs,wx,wy,wz,xx,xy,xz,yy,yz,zz;
  74.         T s = 2.0;
  75.  
  76.         xs = k[0]*s;  ys = k[1]*s;  zs = k[2]*s;
  77.         wx = k[3]*xs; wy = k[3]*ys; wz = k[3]*zs;
  78.         xx = k[0]*xs; xy = k[0]*ys; xz = k[0]*zs;
  79.         yy = k[1]*ys; yz = k[1]*zs; zz = k[2]*zs;
  80.  
  81. R8    *    _Mat.k[0][0] = (1.0 - (yy+zz));
  82.         _Mat.k[0][1] = (xy-wz);
  83.     *    _Mat.k[0][2] = (xz+wy);
  84.  
  85. R9    *    _Mat.k[1][0] = (xy+wz);
  86.     *    _Mat.k[1][1] = (1.0 - (xx+zz));
  87.         _Mat.k[1][2] = (yz-wx);
  88.  
  89. R10        _Mat.k[2][0] = (xz-wy);
  90.         _Mat.k[2][1] = (yz+wx);
  91.     *    _Mat.k[2][2] = (1.0 - (xx+yy));
  92.  
  93.  
  94.         ADD R4, c[A0.x+$MP+0], c[A0.x+$MP+0];
  95.         MUL R5, R4.xyzz, c[A0.x+$MP+0].xxxx;    // xx = k[0]*xs; xy = k[0]*ys; xz = k[0]*zs;
  96.         MUL R6, R4.yzzz, c[A0.x+$MP+0].yyzz;    // yy = k[1]*ys; yz = k[1]*zs; zz = k[2]*zs;
  97.         MUL R4, R4.xyzz, c[A0.x+$MP+0].wwww;    // wx = k[3]*xs; wy = k[3]*ys; wz = k[3]*zs;
  98.         ADD R8.x, R6.xxxx, R6.zzzz;                // yy+zz
  99.         ADD R8.x, c[$BASE+8].y, -R8.x;                // 1 - yy+zz
  100.         ADD R9, R5.yzzz, R4.zyyy;                // R9.x = xy+wz, R9.y = xz+wy
  101.         ADD R10, c[$BASE+8].y, -R5.x;                    // R10 = 1 - xx
  102.         MOV R8.z, R9.y;                            // R8.z = R9.y = xz+wy
  103.         ADD R10, R10, -R6.zxxx;                    // R10.x = 1 - xx - zz, R10.yzw = 1 - xx - yy
  104.         ADD R8.y, R5.y, -R4.z;
  105.         ADD R9.z, R6.y, -R4.x;
  106.         MOV R9.y, R10.x;
  107.         ADD R10.x, R5.z, -R4.y;
  108.         ADD R10.y, R6.y, R4.x;
  109.  
  110.  
  111. */
  112.  
  113. /*************************************************************************************************\
  114. |»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  115. | Vertex program source
  116. |__________________________________________________________________________________________________
  117. \*************************************************************************************************/
  118.  
  119. *VertexProgram
  120. {
  121.     *vpheader
  122.     "@HEADER
  123.     "
  124.     *if_texcoordin0 "@TEXCOORDIN0"
  125.     *if_texcoordin1 "@TEXCOORDIN1"
  126.     *if_texcoordin2 "@TEXCOORDIN2"
  127.     *if_texcoordin3 "@TEXCOORDIN3"
  128.     *if_texcoordin4 "@TEXCOORDIN4"
  129.     *if_texcoordin5 "@TEXCOORDIN5"
  130.     *if_texcoordin6 "@TEXCOORDIN6"
  131.     *if_texcoordin7 "@TEXCOORDIN7"
  132.  
  133.     *if_texcoordout0 "@TEXCOORDOUT0"
  134.     *if_texcoordout1 "@TEXCOORDOUT1"
  135.     *if_texcoordout2 "@TEXCOORDOUT2"
  136.     *if_texcoordout3 "@TEXCOORDOUT3"
  137.     *if_texcoordout4 "@TEXCOORDOUT4"
  138.     *if_texcoordout5 "@TEXCOORDOUT5"
  139.     *if_texcoordout6 "@TEXCOORDOUT6"
  140.     *if_texcoordout7 "@TEXCOORDOUT7"
  141.  
  142.     // ----------------------------------------------------------------
  143.     //  Matrix palette transform
  144.     // ----------------------------------------------------------------
  145.  
  146.     *if_CubeVec
  147.     {
  148.         *if_PosTrans
  149.         "
  150.             MUL R8, @V_POS, c[$POSTRANS];
  151.             ADD R8, R8, c[$POSTRANS+1];
  152.         "
  153.         *ifnot_PosTrans
  154.         "
  155.             MOV R8, @V_POS;
  156.         "
  157.         
  158.         *Post
  159.         "
  160.             MUL R11, @V_MI, c[$BASE+9].xyyy;
  161.             @ARL A0.x, R11.x;
  162.             MUL R8.z, R8.z, c[A0.x+$MP+0].w;
  163.             ADD R8.xyz, R8, c[A0.x+$MP+0];
  164.             MUL R8.xyz, R8, c[$BASE+9].zzzz;
  165.         "
  166.  
  167.         *if_usenormal
  168.         {
  169.             *normal
  170.             "
  171.                 MOV R9, @V_NRML;
  172.             "
  173.  
  174.             *if_normalizenormal
  175.             "
  176.                 DP3 R3.w, R9, R9;
  177.                 RSQ R3.w, R3.w;
  178.                 MUL R9.xyz, R9, R3.w;
  179.             "
  180.         }
  181.     }
  182.     
  183.     *ifnot_CubeVec
  184.     {
  185.         *if_MWComp0
  186.         {
  187.             *if_PosTrans
  188.             "
  189.                 MUL R8, @V_POS, c[$POSTRANS];
  190.                 ADD R8, R8, c[$POSTRANS+1];
  191.             "
  192.             *ifnot_PosTrans
  193.             "
  194.                 MOV R8, @V_POS;
  195.             "
  196.  
  197.             *if_usenormal
  198.             {
  199.                 *normal
  200.                 "
  201.                     MOV R9, @V_NRML;
  202.                 "
  203.  
  204.                 *if_normalizenormal
  205.                 "
  206.                     DP3 R3.w, R9, R9;
  207.                     RSQ R3.w, R3.w;
  208.                     MUL R9.xyz, R9, R3.w;
  209.                 "
  210.             }
  211.         }
  212.  
  213.         *if_MWComp1
  214.         {
  215.             *Pre
  216.             "        
  217.                 MUL R3, @V_MI, c[$BASE+8].w;
  218.                 @ARL A0.x, R3.x;
  219.                 MUL R0, @V_MW.x, c[A0.x+$MP @MPSIGN 0];
  220.                 MUL R1, @V_MW.x, c[A0.x+$MP @MPSIGN 1];
  221.                 MUL R2, @V_MW.x, c[A0.x+$MP @MPSIGN 2];
  222.             "
  223.             *if_PosTrans
  224.             " 
  225.                 MUL R4, @V_POS, c[$POSTRANS];
  226.                 ADD R4, R4, c[$POSTRANS+1];
  227.             "
  228.             *ifnot_PosTrans
  229.             "
  230.                 MOV R4, @V_POS;
  231.             "
  232.             *Post
  233.             "        
  234.                 DP4 R8.x, R0, R4;
  235.                 DP4 R8.y, R1, R4;
  236.                 DP4 R8.z, R2, R4;
  237.                 MOV R8.w, c[$BASE+8].y;
  238.             "
  239.         }
  240.  
  241.         *if_MWComp2
  242.         {
  243.             *Pre
  244.             "        
  245.                 MUL R3, @V_MI, c[$BASE+8].w;
  246.                 @ARL A0.x, R3.x;
  247.                 MUL R0, @V_MW.x, c[A0.x+$MP @MPSIGN 0];
  248.                 MUL R1, @V_MW.x, c[A0.x+$MP @MPSIGN 1];
  249.                 MUL R2, @V_MW.x, c[A0.x+$MP @MPSIGN 2];
  250.                 @ARL A0.x, R3.y;
  251.                 MAD R0, @V_MW.y, c[A0.x+$MP @MPSIGN 0], R0;
  252.                 MAD R1, @V_MW.y, c[A0.x+$MP @MPSIGN 1], R1;
  253.                 MAD R2, @V_MW.y, c[A0.x+$MP @MPSIGN 2], R2;
  254.             "
  255.             *if_PosTrans
  256.             " 
  257.                 MUL R4, @V_POS, c[$POSTRANS];
  258.                 ADD R4, R4, c[$POSTRANS+1];
  259.             "
  260.             *ifnot_PosTrans
  261.             "
  262.                 MOV R4, @V_POS;
  263.             "
  264.             *Post
  265.             "        
  266.                 DP4 R8.x, R0, R4;
  267.                 DP4 R8.y, R1, R4;
  268.                 DP4 R8.z, R2, R4;
  269.                 MOV R8.w, c[$BASE+8].y;
  270.             "
  271.         }
  272.  
  273.         *if_MWComp3
  274.         {
  275.             *if_MPQuat
  276.             {
  277.                 *Pre
  278.                 "        
  279.                     MUL R3, @V_MI, c[$BASE+8].w;
  280.                     @ARL A0.x, R3.x;
  281.  
  282.                     ADD R4, c[A0.x+$MP+0], c[A0.x+$MP+0];
  283.                     MUL R5, R4.xyzz, c[A0.x+$MP+0].xxxx;
  284.                     MUL R6, R4.yzzz, c[A0.x+$MP+0].yyzz;
  285.                     MUL R4, R4.xyzz, c[A0.x+$MP+0].wwww;
  286.                     ADD R8.x, R6.xxxx, R6.zzzz;
  287.                     ADD R8.x, c[$BASE+8].y, -R8.x;
  288.                     ADD R9, R5.yzzz, R4.zyyy;
  289.                     ADD R10, c[$BASE+8].y, -R5.x;
  290.                     MOV R8.z, R9.y;
  291.                     ADD R10, R10, -R6.zxxx;
  292.                     ADD R8.y, R5.y, -R4.z;
  293.                     ADD R9.z, R6.y, -R4.x;
  294.                     MOV R9.y, R10.x;
  295.                     ADD R10.x, R5.z, -R4.y;
  296.                     ADD R10.y, R6.y, R4.x;
  297.                     MOV R8.w, c[A0.x+$MP+1].x;
  298.                     MOV R9.w, c[A0.x+$MP+1].y;
  299.                     MOV R10.w, c[A0.x+$MP+1].z;
  300.  
  301.                     MUL R0, @V_MW.x, R8;
  302.                     MUL R1, @V_MW.x, R9;
  303.                     MUL R2, @V_MW.x, R10;
  304.                     @ARL A0.x, R3.y;
  305.  
  306.                     ADD R4, c[A0.x+$MP+0], c[A0.x+$MP+0];
  307.                     MUL R5, R4.xyzz, c[A0.x+$MP+0].xxxx;
  308.                     MUL R6, R4.yzzz, c[A0.x+$MP+0].yyzz;
  309.                     MUL R4, R4.xyzz, c[A0.x+$MP+0].wwww;
  310.                     ADD R8.x, R6.xxxx, R6.zzzz;
  311.                     ADD R8.x, c[$BASE+8].y, -R8.x;
  312.                     ADD R9, R5.yzzz, R4.zyyy;
  313.                     ADD R10, c[$BASE+8].y, -R5.x;
  314.                     MOV R8.z, R9.y;
  315.                     ADD R10, R10, -R6.zxxx;
  316.                     ADD R8.y, R5.y, -R4.z;
  317.                     ADD R9.z, R6.y, -R4.x;
  318.                     MOV R9.y, R10.x;
  319.                     ADD R10.x, R5.z, -R4.y;
  320.                     ADD R10.y, R6.y, R4.x;
  321.                     MOV R8.w, c[A0.x+$MP+1].x;
  322.                     MOV R9.w, c[A0.x+$MP+1].y;
  323.                     MOV R10.w, c[A0.x+$MP+1].z;
  324.  
  325.                     MAD R0, @V_MW.y, R8, R0;
  326.                     MAD R1, @V_MW.y, R9, R1;
  327.                     MAD R2, @V_MW.y, R10, R2;
  328.                     @ARL A0.x, R3.z;
  329.  
  330.                     ADD R4, c[A0.x+$MP+0], c[A0.x+$MP+0];
  331.                     MUL R5, R4.xyzz, c[A0.x+$MP+0].xxxx;
  332.                     MUL R6, R4.yzzz, c[A0.x+$MP+0].yyzz;
  333.                     MUL R4, R4.xyzz, c[A0.x+$MP+0].wwww;
  334.                     ADD R8.x, R6.xxxx, R6.zzzz;
  335.                     ADD R8.x, c[$BASE+8].y, -R8.x;
  336.                     ADD R9, R5.yzzz, R4.zyyy;
  337.                     ADD R10, c[$BASE+8].y, -R5.x;
  338.                     MOV R8.z, R9.y;
  339.                     ADD R10, R10, -R6.zxxx;
  340.                     ADD R8.y, R5.y, -R4.z;
  341.                     ADD R9.z, R6.y, -R4.x;
  342.                     MOV R9.y, R10.x;
  343.                     ADD R10.x, R5.z, -R4.y;
  344.                     ADD R10.y, R6.y, R4.x;
  345.                     MOV R8.w, c[A0.x+$MP+1].x;
  346.                     MOV R9.w, c[A0.x+$MP+1].y;
  347.                     MOV R10.w, c[A0.x+$MP+1].z;
  348.  
  349.                     MAD R0, @V_MW.z, R8, R0;
  350.                     MAD R1, @V_MW.z, R9, R1;
  351.                     MAD R2, @V_MW.z, R10, R2;
  352.                 "
  353.                     
  354.                 *if_PosTrans
  355.                 " 
  356.                     MUL R4, @V_POS, c[$POSTRANS];
  357.                     ADD R4, R4, c[$POSTRANS+1];
  358.                 "
  359.                 *ifnot_PosTrans
  360.                 "
  361.                     MOV R4, @V_POS;
  362.                 "
  363.                 
  364.                 *Post
  365.                 "        
  366.                     DP4 R8.x, R0, R4;
  367.                     DP4 R8.y, R1, R4;
  368.                     DP4 R8.z, R2, R4;
  369.                     MOV R8.w, c[$BASE+8].y;
  370.                 "        
  371.             }
  372.             *ifnot_MPQuat
  373.             {
  374.                 *Pre
  375.                 "
  376.                     MUL R3, @V_MI, c[$BASE+8].w;
  377.                     @ARL A0.x, R3.x;
  378.                     MUL R0, @V_MW.x, c[A0.x+$MP @MPSIGN 0];
  379.                     MUL R1, @V_MW.x, c[A0.x+$MP @MPSIGN 1];
  380.                     MUL R2, @V_MW.x, c[A0.x+$MP @MPSIGN 2];
  381.                     @ARL A0.x, R3.y;
  382.                     MAD R0, @V_MW.y, c[A0.x+$MP @MPSIGN 0], R0;
  383.                     MAD R1, @V_MW.y, c[A0.x+$MP @MPSIGN 1], R1;
  384.                     MAD R2, @V_MW.y, c[A0.x+$MP @MPSIGN 2], R2;
  385.                     @ARL A0.x, R3.z;
  386.                     MAD R0, @V_MW.z, c[A0.x+$MP @MPSIGN 0], R0;
  387.                     MAD R1, @V_MW.z, c[A0.x+$MP @MPSIGN 1], R1;
  388.                     MAD R2, @V_MW.z, c[A0.x+$MP @MPSIGN 2], R2;
  389.                 "
  390.                 *if_PosTrans
  391.                 " 
  392.                     MUL R4, @V_POS, c[$POSTRANS];
  393.                     ADD R4, R4, c[$POSTRANS+1];
  394.                 "
  395.                 *ifnot_PosTrans
  396.                 "
  397.                     MOV R4, @V_POS;
  398.                 "
  399.                 *Post
  400.                 "
  401.                     DP4 R8.x, R0, R4;
  402.                     DP4 R8.y, R1, R4;
  403.                     DP4 R8.z, R2, R4;
  404.                     MOV R8.w, c[$BASE+8].y;
  405.                 "
  406.             }
  407.         }
  408.  
  409.         *if_MWComp4
  410.         {                
  411.             *Pre
  412.             "
  413.                 MUL R3, @V_MI, c[$BASE+8].w;
  414.                 @ARL A0.x, R3.x;
  415.                 MUL R0, @V_MW.x, c[A0.x+$MP @MPSIGN 0];
  416.                 MUL R1, @V_MW.x, c[A0.x+$MP @MPSIGN 1];
  417.                 MUL R2, @V_MW.x, c[A0.x+$MP @MPSIGN 2];
  418.                 @ARL A0.x, R3.y;
  419.                 MAD R0, @V_MW.y, c[A0.x+$MP @MPSIGN 0], R0;
  420.                 MAD R1, @V_MW.y, c[A0.x+$MP @MPSIGN 1], R1;
  421.                 MAD R2, @V_MW.y, c[A0.x+$MP @MPSIGN 2], R2;
  422.                 @ARL A0.x, R3.z;
  423.                 MAD R0, @V_MW.z, c[A0.x+$MP @MPSIGN 0], R0;
  424.                 MAD R1, @V_MW.z, c[A0.x+$MP @MPSIGN 1], R1;
  425.                 MAD R2, @V_MW.z, c[A0.x+$MP @MPSIGN 2], R2;
  426.                 @ARL A0.x, R3.w;
  427.                 MAD R0, @V_MW.w, c[A0.x+$MP @MPSIGN 0], R0;
  428.                 MAD R1, @V_MW.w, c[A0.x+$MP @MPSIGN 1], R1;
  429.                 MAD R2, @V_MW.w, c[A0.x+$MP @MPSIGN 2], R2;
  430.             "
  431.             *if_PosTrans
  432.             " 
  433.                 MUL R4, @V_POS, c[$POSTRANS];
  434.                 ADD R4, R4, c[$POSTRANS+1];
  435.             "
  436.             *ifnot_PosTrans
  437.             "
  438.                 MOV R4, @V_POS;
  439.             "
  440.             *Post
  441.             "
  442.                 DP4 R8.x, R0, R4;
  443.                 DP4 R8.y, R1, R4;
  444.                 DP4 R8.z, R2, R4;
  445.                 MOV R8.w, c[$BASE+8].y;
  446.             "
  447.         }
  448.         *ifnot_MWComp0
  449.         {
  450.             *if_usenormal
  451.             {
  452.                 *normal
  453.                 "
  454.                     DP3 R9.x, R0, @V_NRML;
  455.                     DP3 R9.y, R1, @V_NRML;
  456.                     DP3 R9.z, R2, @V_NRML;
  457.                 "
  458.  
  459.                 *if_normalizenormal
  460.                 "
  461.                     DP3 R3.w, R9, R9;
  462.                     RSQ R3.w, R3.w;
  463.                     MUL R9.xyz, R9, R3.w;
  464.                 "
  465.             }
  466.         }
  467.     }
  468.  
  469.  
  470.     // ----------------------------------------------------------------
  471.     //  Shadow volume
  472.     // ----------------------------------------------------------------
  473.     //    ADD R4, R8, -c[$TEXPARAM0+0];
  474.     *if_texgen0_shadowvolume
  475.     "
  476.         ADD R4.xyz, R8, -c[$TEXPARAM0];
  477.         DP3 R3.w, R4, R4;
  478.         RSQ R3.w, R3.w;
  479.         MUL R4.xyz, R4, R3.w;
  480.         DP3 R3.w, R4, R9;
  481.         SLT R3.w, R3.w, c[$BASE+8].x;
  482.         MUL R5, R3.wwww, R4;
  483.         MUL R5, c[$TEXPARAM0].wwww, R5;
  484.         ADD R8.xyz, R8, R5;
  485.     "
  486. //        MUL R3.w, R3.w, c[$BASE+8].w;
  487. //        MIN R3.w, R3.w, c[$BASE+8].y;
  488. //        MAX R3.w, R3.w, c[$BASE+8].x;
  489.  
  490.     // ----------------------------------------------------------------
  491.     //  Semi hardware shadow volume
  492.     // ----------------------------------------------------------------
  493.     *if_texgen0_shadowvolume2
  494.     {
  495.         *Pre
  496.         "
  497.             ADD R4.xyz, R8, -c[$TEXPARAM0];
  498.             DP3 R3.w, R4, R4;
  499.             RSQ R3.w, R3.w;
  500.             MUL R4.xyz, R4, R3.w;
  501.             MUL R4, c[$TEXPARAM0].wwww, R4;
  502.         "
  503.         *if_TextureTrans0
  504.         " 
  505.             MUL R5, $TEXINPUT0, c[$TEXTURETRANS0];
  506.             ADD R5, R5, c[$TEXTURETRANS0+1];
  507.             MUL R4, R5.xxxx, R4;
  508.         "
  509.         *ifnot_TextureTrans0
  510.         "
  511.             MUL R4, $TEXINPUT0.xxxx, R4;
  512.         "
  513.         *Post
  514.         "
  515.             ADD R8.xyz, R8, R4;
  516.         "
  517.     }
  518.  
  519.     // ----------------------------------------------------------------
  520.     //  Fog
  521.     // ----------------------------------------------------------------
  522.     *if_fogdepth
  523.     "
  524.         DP4 @O_FOG, c[$BASE+6], R8;
  525.     "
  526. /* Range fog speciale
  527.     "
  528.         DP4 R3.x, c[$BASE+4], R8;
  529.         DP4 R3.y, c[$BASE+5], R8;
  530.         DP4 R3.z, c[$BASE+6], R8;
  531.         DP3 R3.w, R3, R3;
  532.         RSQ R3.w, R3.w;
  533.         RCP R3.w, R3.w;
  534.         DP4 R3.x, c[$BASE+6], R8;
  535.         ADD R3.x, R3.x, R3.x;
  536.         MIN @O_FOG, R3.x, R3.w;
  537.     "
  538. */
  539.     // ----------------------------------------------------------------
  540.     //  Lighting
  541.     // ----------------------------------------------------------------
  542.  
  543.  
  544.     *if_lighting
  545.     {
  546.         *LightBegin
  547.         "
  548.             MOV R10.xyzw, c[$BASE+8].xxxy;
  549.         "
  550.  
  551.         // ----------------------------------------------------------------
  552.         // Point light 0 ($LIGHT+0 == LightPos (ViewSpace), $LIGHT+1 == Color)
  553.         *if_Light0_Point
  554.         "
  555.             ADD R4, c[$LIGHT+0], -R8;
  556.             DP3 R3.w, R4, R4;
  557.             RSQ R3.z, R3.w;
  558.             DST R3, R3.w, R3.z;
  559.             MUL R3.x, c[$LIGHT+0].wwww, -R3.yyyy;
  560.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  561.             MAX R3.x, R3.x, c[$BASE+8].x;
  562.             MUL R4.w, R3.w, R3.x;
  563.             MUL R4.xyz, R4, R4.w;
  564.             DP3 R3.x, R9, R4;
  565.             MAX R3.x, R3.x, c[$BASE+8].x;
  566.             MUL R10.xyz, R3.xxxx, c[$LIGHT+1];
  567.         "
  568.  
  569.         // ----------------------------------------------------------------
  570.         // Ambient light 0 ($LIGHT+0 == Unused, $LIGHT+1 == Color)
  571.  
  572.         *if_Light0_Ambient
  573.         "
  574.             MOV R10.xyz, c[$LIGHT+1];
  575.         "
  576.  
  577.         // ----------------------------------------------------------------
  578.         // Parallell light 0 ($LIGHT+0 == LightVector (ViewSpace), $LIGHT+1 == Color)
  579.  
  580.         *if_Light0_Parallell
  581.         "
  582.             DP3 R3.x, R9, c[$LIGHT+0];
  583.             MUL R10.xyz, R3.xxxx, c[$LIGHT+1];
  584.         "
  585.  
  586.  
  587.         // ----------------------------------------------------------------
  588.         // Point light 1-7 ($LIGHT+0 == LightPos (ViewSpace), $LIGHT+1 == Color)
  589.  
  590.         *if_Light1_Point
  591.         "
  592.             ADD R4, c[$LIGHT+2], -R8;
  593.             DP3 R3.w, R4, R4;
  594.             RSQ R3.z, R3.w;
  595.             DST R3, R3.w, R3.z;
  596.             MUL R3.x, c[$LIGHT+2].wwww, -R3.yyyy;
  597.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  598.             MAX R3.x, R3.x, c[$BASE+8].x;
  599.             MUL R4.w, R3.w, R3.x;
  600.             MUL R4.xyz, R4, R4.w;
  601.             DP3 R3.x, R9, R4;
  602.             MAX R3.x, R3.x, c[$BASE+8].x;
  603.             MAD R10.xyz, R3.xxxx, c[$LIGHT+3], R10;
  604.         "
  605.  
  606.         *if_Light2_Point
  607.         "
  608.             ADD R4, c[$LIGHT+4], -R8;
  609.             DP3 R3.w, R4, R4;
  610.             RSQ R3.z, R3.w;
  611.             DST R3, R3.w, R3.z;
  612.             MUL R3.x, c[$LIGHT+4].wwww, -R3.yyyy;
  613.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  614.             MAX R3.x, R3.x, c[$BASE+8].x;
  615.             MUL R4.w, R3.w, R3.x;
  616.             MUL R4.xyz, R4, R4.w;
  617.             DP3 R3.x, R9, R4;
  618.             MAX R3.x, R3.x, c[$BASE+8].x;
  619.             MAD R10.xyz, R3.xxxx, c[$LIGHT+5], R10;
  620.         "
  621.  
  622.         *if_Light3_Point
  623.         "
  624.             ADD R4, c[$LIGHT+6], -R8;
  625.             DP3 R3.w, R4, R4;
  626.             RSQ R3.z, R3.w;
  627.             DST R3, R3.w, R3.z;
  628.             MUL R3.x, c[$LIGHT+6].wwww, -R3.yyyy;
  629.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  630.             MAX R3.x, R3.x, c[$BASE+8].x;
  631.             MUL R4.w, R3.w, R3.x;
  632.             MUL R4.xyz, R4, R4.w;
  633.             DP3 R3.x, R9, R4;
  634.             MAX R3.x, R3.x, c[$BASE+8];
  635.             MAD R10.xyz, R3.xxxx, c[$LIGHT+7], R10;
  636.         "
  637.  
  638.         *if_Light4_Point
  639.         "
  640.             ADD R4, c[$LIGHT+8], -R8;
  641.             DP3 R3.w, R4, R4;
  642.             RSQ R3.z, R3.w;
  643.             DST R3, R3.w, R3.z;
  644.             MUL R3.x, c[$LIGHT+8].wwww, -R3.yyyy;
  645.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  646.             MAX R3.x, R3.x, c[$BASE+8].x;
  647.             MUL R4.w, R3.w, R3.x;
  648.             MUL R4.xyz, R4, R4.w;
  649.             DP3 R3.x, R9, R4;
  650.             MAX R3.x, R3.x, c[$BASE+8].x;
  651.             MAD R10.xyz, R3.xxxx, c[$LIGHT+9], R10;
  652.         "
  653.  
  654.         *if_Light5_Point
  655.         "
  656.             ADD R4, c[$LIGHT+10], -R8;
  657.             DP3 R3.w, R4, R4;
  658.             RSQ R3.z, R3.w;
  659.             DST R3, R3.w, R3.z;
  660.             MUL R3.x, c[$LIGHT+10].wwww, -R3.yyyy;
  661.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  662.             MAX R3.x, R3.x, c[$BASE+8].x;
  663.             MUL R4.w, R3.w, R3.x;
  664.             MUL R4.xyz, R4, R4.w;
  665.             DP3 R3.x, R9, R4;
  666.             MAX R3.x, R3.x, c[$BASE+8].x;
  667.             MAD R10.xyz, R3.xxxx, c[$LIGHT+11], R10;
  668.         "
  669.  
  670.         *if_Light6_Point
  671.         "
  672.             ADD R4, c[$LIGHT+12], -R8;
  673.             DP3 R3.w, R4, R4;
  674.             RSQ R3.z, R3.w;
  675.             DST R3, R3.w, R3.z;
  676.             MUL R3.x, c[$LIGHT+12].wwww, -R3.yyyy;
  677.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  678.             MAX R3.x, R3.x, c[$BASE+8].x;
  679.             MUL R4.w, R3.w, R3.x;
  680.             MUL R4.xyz, R4, R4.w;
  681.             DP3 R3.x, R9, R4;
  682.             MAX R3.x, R3.x, c[$BASE+8].x;
  683.             MAD R10.xyz, R3.xxxx, c[$LIGHT+13], R10;
  684.         "
  685.  
  686.         *if_Light7_Point
  687.         "
  688.             ADD R4, c[$LIGHT+14], -R8;
  689.             DP3 R3.w, R4, R4;
  690.             RSQ R3.z, R3.w;
  691.             DST R3, R3.w, R3.z;
  692.             MUL R3.x, c[$LIGHT+14].wwww, -R3.yyyy;
  693.             ADD R3.x, R3.x, c[$BASE+8].yyyy;
  694.             MAX R3.x, R3.x, c[$BASE+8].x;
  695.             MUL R4.w, R3.w, R3.x;
  696.             MUL R4.xyz, R4, R4.w;
  697.             DP3 R3.x, R9, R4;
  698.             MAX R3.x, R3.x, c[$BASE+8].x;
  699.             MAD R10.xyz, R3.xxxx, c[$LIGHT+15], R10;
  700.         "
  701.  
  702.         // ----------------------------------------------------------------
  703.         // Ambient light 1-7 ($LIGHT+0 == Unused, $LIGHT+1 == Color)
  704.  
  705.         *if_Light1_Ambient
  706.         "
  707.             ADD R10, R10, c[$LIGHT+3];
  708.         "
  709.  
  710.         *if_Light2_Ambient
  711.         "
  712.             ADD R10, R10, c[$LIGHT+5];
  713.         "
  714.  
  715.         *if_Light3_Ambient
  716.         "
  717.             ADD R10, R10, c[$LIGHT+7];
  718.         "
  719.  
  720.         *if_Light4_Ambient
  721.         "
  722.             ADD R10, R10, c[$LIGHT+9];
  723.         "
  724.  
  725.         *if_Light5_Ambient
  726.         "
  727.             ADD R10, R10, c[$LIGHT+11];
  728.         "
  729.  
  730.         *if_Light6_Ambient
  731.         "
  732.             ADD R10, R10, c[$LIGHT+13];
  733.         "
  734.  
  735.         *if_Light7_Ambient
  736.         "
  737.             ADD R10, R10, c[$LIGHT+15];
  738.         "
  739.  
  740.         // ----------------------------------------------------------------
  741.         // Parallell light 1-7 ($LIGHT+0 == LightVector (ViewSpace), $LIGHT+1 == Color)
  742.  
  743.         *if_Light1_Parallell
  744.         "
  745.             DP3 R3.x, R9, c[$LIGHT+2];
  746.             MAD R10.xyz, R3.xxxx, c[$LIGHT+3], R10;
  747.         "
  748.  
  749.         *if_Light2_Parallell
  750.         "
  751.             DP3 R3.x, R9, c[$LIGHT+4];
  752.             MAD R10.xyz, R3.xxxx, c[$LIGHT+5], R10;
  753.         "
  754.  
  755.         *if_Light3_Parallell
  756.         "
  757.             DP3 R3.x, R9, c[$LIGHT+6];
  758.             MAD R10.xyz, R3.xxxx, c[$LIGHT+7], R10;
  759.         "
  760.  
  761.         *if_Light4_Parallell
  762.         "
  763.             DP3 R3.x, R9, c[$LIGHT+8];
  764.             MAD R10.xyz, R3.xxxx, c[$LIGHT+9], R10;
  765.         "
  766.  
  767.         *if_Light5_Parallell
  768.         "
  769.             DP3 R3.x, R9, c[$LIGHT+10];
  770.             MAD R10.xyz, R3.xxxx, c[$LIGHT+11], R10;
  771.         "
  772.  
  773.         *if_Light6_Parallell
  774.         "
  775.             DP3 R3.x, R9, c[$LIGHT+12];
  776.             MAD R10.xyz, R3.xxxx, c[$LIGHT+13], R10;
  777.         "
  778.  
  779.         *if_Light7_Parallell
  780.         "
  781.             DP3 R3.x, R9, c[$LIGHT+14];
  782.             MAD R10.xyz, R3.xxxx, c[$LIGHT+15], R10;
  783.         "
  784.  
  785.         *clamplight
  786.         "
  787.             MAX R10, R10, c[$BASE+8].x;
  788.         "
  789.  
  790.         *if_colorvertex
  791.         "
  792.             MUL R10, R10, @V_COL0;
  793.         "
  794.  
  795.         *storecolor
  796.         "
  797.             MUL @O_COL0, R10, c[$CONSTANTCOLOR];
  798.         "
  799.  
  800.         // ----------------------------------------------------------------
  801.         *modelprojection
  802.         "
  803.             DP4    @O_HPOS.x, c[$BASE+0], R8;
  804.             DP4    @O_HPOS.y, c[$BASE+1], R8;
  805.             DP4    @O_HPOS.z, c[$BASE+2], R8;
  806.             DP4    @O_HPOS.w, c[$BASE+3], R8;
  807.         "
  808.     }
  809.  
  810.     *ifnot_lighting
  811.     {
  812.         *modelprojection
  813.         "
  814.             DP4    @O_HPOS.x, c[$BASE+0], R8;
  815.             DP4    @O_HPOS.y, c[$BASE+1], R8;
  816.             DP4    @O_HPOS.z, c[$BASE+2], R8;
  817.             DP4    @O_HPOS.w, c[$BASE+3], R8;
  818.             
  819.         "
  820.  
  821.         *if_colorvertex
  822.         "
  823.             MUL @O_COL0, @V_COL0, c[$CONSTANTCOLOR];
  824.         "
  825.  
  826.         *ifnot_colorvertex
  827.         "
  828.             MOV @O_COL0, c[$CONSTANTCOLOR];
  829.         "
  830.     }
  831.  
  832.     // ----------------------------------------------------------------
  833.     //  Prepare tangents
  834.     //
  835.     //  NOTE: Matrix palette transform final matrix is destroyed here!
  836.     // ----------------------------------------------------------------
  837.     *if_usetangents
  838.     {
  839.         *if_CubeVec
  840.         {
  841.             *if_TextureTrans2
  842.             " 
  843.                 MUL R0, $TEXINPUT2, c[$TEXTURETRANS2];
  844.                 ADD R0, R0, c[$TEXTURETRANS2+1];
  845.             "
  846.             *ifnot_TextureTrans2
  847.             "
  848.                 MOV R0, $TEXINPUT2;
  849.             "
  850.             *if_TextureTrans3
  851.             " 
  852.                 MUL R1, $TEXINPUT3, c[$TEXTURETRANS3];
  853.                 ADD R1, R1, c[$TEXTURETRANS3+1];
  854.             "
  855.             *ifnot_TextureTrans3
  856.             "
  857.                 MOV R1, $TEXINPUT3;
  858.             "
  859.         }
  860.         *ifnot_CubeVec
  861.         {
  862.             *if_MWComp0
  863.             {
  864.                 *if_TextureTrans2
  865.                 " 
  866.                     MUL R0, $TEXINPUT2, c[$TEXTURETRANS2];
  867.                     ADD R0, R0, c[$TEXTURETRANS2+1];
  868.                 "
  869.                 *ifnot_TextureTrans2
  870.                 "
  871.                     MOV R0, $TEXINPUT2;
  872.                 "
  873.                 *if_TextureTrans3
  874.                 " 
  875.                     MUL R1, $TEXINPUT3, c[$TEXTURETRANS3];
  876.                     ADD R1, R1, c[$TEXTURETRANS3+1];
  877.                 "
  878.                 *ifnot_TextureTrans3
  879.                 "
  880.                     MOV R1, $TEXINPUT3;
  881.                 "
  882.             }
  883.             *ifnot_MWComp0
  884.             {
  885.                 *if_TextureTrans2
  886.                 " 
  887.                     MUL R4, $TEXINPUT2, c[$TEXTURETRANS2];
  888.                     ADD R4, R4, c[$TEXTURETRANS2+1];
  889.                 "
  890.                 *ifnot_TextureTrans2
  891.                 "
  892.                     MOV R4, $TEXINPUT2;
  893.                 "
  894.                 *if_TextureTrans3
  895.                 " 
  896.                     MUL R5, $TEXINPUT3, c[$TEXTURETRANS3];
  897.                     ADD R5, R5, c[$TEXTURETRANS3+1];
  898.                 "
  899.                 *ifnot_TextureTrans3
  900.                 "
  901.                     MOV R5, $TEXINPUT3;
  902.                 "
  903.                 *Post
  904.                 " 
  905.                     DP3 R10.x, R0, R4;
  906.                     DP3 R10.y, R1, R4;
  907.                     DP3 R10.zw, R2, R4;
  908.                     DP3 R11.x, R0, R5;
  909.                     DP3 R11.y, R1, R5;
  910.                     DP3 R11.zw, R2, R5;
  911.                     MOV R0, R10;
  912.                     MOV R1, R11;
  913.                 "
  914.             }
  915.         }
  916.     }
  917.  
  918.     // ----------------------------------------------------------------
  919.     //  Texture coordinate generation and transform
  920.     // ----------------------------------------------------------------
  921.     *ifnot_texgen0_void
  922.     {
  923.         *if_texgen0_texcoord
  924.         {
  925.             *if_texmatrix0
  926.             {
  927.                 *if_TextureTrans0
  928.                 {
  929.                     *Post
  930.                     " 
  931.                         MUL R4, $TEXINPUT0, c[$TEXTURETRANS0];
  932.                         ADD R4, R4, c[$TEXTURETRANS0+1];
  933.                         DP4 @O_TEX0.x, R4, c[$TEXMATRIX0+0];
  934.                         DP4 @O_TEX0.y, R4, c[$TEXMATRIX0+1];
  935.                         DP4 @O_TEX0.z, R4, c[$TEXMATRIX0+2];
  936.                         DP4 @O_TEX0.w, R4, c[$TEXMATRIX0+3];
  937.                     "
  938.                 }
  939.                 *ifnot_TextureTrans0
  940.                 "
  941.                     DP4 @O_TEX0.x, $TEXINPUT0, c[$TEXMATRIX0+0];
  942.                     DP4 @O_TEX0.y, $TEXINPUT0, c[$TEXMATRIX0+1];
  943.                     DP4 @O_TEX0.z, $TEXINPUT0, c[$TEXMATRIX0+2];
  944.                     DP4 @O_TEX0.w, $TEXINPUT0, c[$TEXMATRIX0+3];
  945.                 "
  946.             }
  947.  
  948.             *ifnot_texmatrix0
  949.             {
  950.                 *if_TextureTrans0
  951.                 {
  952.                     *if_CubeTex
  953.                     {
  954.                         *Pre
  955.                         "
  956.                             MOV R4, c[$BASE+8].xxxy;
  957.                             MUL R4.xy, R11.y, c[A0.x+$MP+1];
  958.                             MAD R4.xy, R11.z, c[A0.x+$MP+1].zwww, R4;
  959.                         "
  960.                         *if_CubeTexScl2
  961.                         "                        
  962.                             MUL R3, $TEXINPUT0, c[$TEXTURETRANS0];
  963.                             ADD R3, R3, c[$TEXTURETRANS0+1];
  964.  
  965.                             ADD R5.x, R11.y, c[$BASE+8].y;
  966.                             MAD R4.xy, R3, R5.x, R4;
  967.                         "
  968.                         *ifnot_CubeTexScl2
  969.                         "
  970.                             MUL R3, $TEXINPUT0, c[$TEXTURETRANS0];
  971.                             ADD R3, R3, c[$TEXTURETRANS0+1];
  972.                             ADD R4.xy, R3, R4;
  973.                         "
  974.                         *if_CubeTexSclZ
  975.                         "
  976.                             MUL R3.x, R11.w, c[A0.x+$MP+0].w;
  977.                             MUL R3.y, R4.y, R3.x;
  978.                             SUB R3.z, c[$BASE+8].y, R11.w;
  979.                             MAD R4.y, R4.y, R3.z, R3.y;
  980.                         "
  981.                         
  982.                         *Post
  983.                         "
  984.                             MOV @O_TEX0, R4;
  985.                         "
  986.                     }
  987.  
  988.                     *ifnot_CubeTex
  989.                     "
  990.                         MUL R4, $TEXINPUT0, c[$TEXTURETRANS0];
  991.                         ADD @O_TEX0, R4, c[$TEXTURETRANS0+1];
  992.                     "
  993.                 }
  994.                 *ifnot_TextureTrans0
  995.                 {
  996.                 
  997.                     *if_CubeTex
  998.                     {
  999.                         *Pre
  1000.                         "
  1001.                             MOV R4, c[$BASE+8].xxxy;
  1002.                             MUL R4.xy, R11.y, c[A0.x+$MP+1];
  1003.                             MAD R4.xy, R11.z, c[A0.x+$MP+1].zwww, R4;
  1004.                         "
  1005.                         *if_CubeTexScl2
  1006.                         "                        
  1007.                             MUL R3.y, R11.y, c[$BASE+8].z;
  1008.                             SUB R3.x, c[$BASE+8].y, R3.y;
  1009.                             MAD R4.xy, $TEXINPUT0, R3.x, R4;
  1010.                         "
  1011.                         *ifnot_CubeTexScl2
  1012.                         "
  1013.                             ADD R4.xy, $TEXINPUT0, R4;
  1014.                         "
  1015.                         *if_CubeTexSclZ
  1016.                         "
  1017.                             MUL R3.x, R11.w, c[A0.x+$MP+0].w;
  1018.                             MUL R3.y, R4.y, R3.x;
  1019.                             SUB R3.z, c[$BASE+8].y, R11.w;
  1020.                             MAD R4.y, R4.y, R3.z, R3.y;
  1021.                         "
  1022.                         *Post
  1023.                         "
  1024.                             MOV @O_TEX0, R4;
  1025.                         "
  1026.                     }
  1027.                     *ifnot_CubeTex
  1028.                     "
  1029.                         MOV @O_TEX0, $TEXINPUT0;
  1030.                     "
  1031.                 }
  1032.             }
  1033.         }
  1034.  
  1035.         *ifnot_texgen0_texcoord
  1036.         {
  1037.             *if_texgen0_linear
  1038.             "
  1039.                 DP4 R3.x, R8, c[$TEXPARAM0+0];
  1040.                 DP4 R3.y, R8, c[$TEXPARAM0+1];
  1041.                 DP4 R3.z, R8, c[$TEXPARAM0+2];
  1042.                 DP4 R3.w, R8, c[$TEXPARAM0+3];
  1043.             "
  1044.  
  1045.             *if_texgen0_screen
  1046.             "
  1047.                 mul r4, c93, r12.w
  1048.                 mad r3, r12, c92, r4
  1049.             "
  1050.             
  1051.             *if_texgen0_linearnhf
  1052.             "
  1053.                 MOV R4, c[$TEXPARAM0+1];
  1054.                 MOV R4.w, c[$BASE+8].y;
  1055.                 ADD R5, R4, -R8;
  1056.                 DP3 R3.x, R8, c[$TEXPARAM0+0];
  1057.                 ADD R3.x, R3.x, c[$TEXPARAM0+0].w;
  1058.  
  1059.                 DP4 R3.y, R4, c[$TEXPARAM0+0];
  1060.                 ADD R3.w, R3.x, -R3.y;
  1061.                 RCP R3.w, R3.w;
  1062.                 MIN R3.y, R3.y, c[$BASE+8].x;
  1063.                 MUL R3.y, R3.y, R3.w;
  1064.                 MUL R5, R5, R3.y;
  1065.                 ADD R4, R4, R5;
  1066.                 ADD R5, R4, -R8;
  1067.  
  1068.                 DP3 R3.y, R4, c[$TEXPARAM0+0];
  1069.                 ADD R3.y, R3.y, c[$TEXPARAM0+0].w;
  1070.                 MIN R3.xy, R3, c[$BASE+8].yyyy;
  1071.                 MAX R3.xy, R3, c[$BASE+8].xxxx;
  1072.                 ADD R3.x, R3.x, R3.y;
  1073.                 DP3 R4.w, R5, R5;
  1074.                 RSQ R4.w, R4.w;
  1075.                 RCP R4.w, R4.w;
  1076.                 MUL R3.x, R3.x, R4.w;
  1077.                 MUL R3.x, R3.x, c[$TEXPARAM0+1].w;
  1078.                 MOV R3.yzw, c[$BASE+8].yyyy;
  1079.  
  1080.                 MOV @O_COL0, c[$TEXPARAM0+2];
  1081.             "
  1082.  
  1083.             *if_texgen0_boxnhf
  1084.             "
  1085.                 ADD R3, R8, -c[$TEXPARAM0+8];
  1086.                 MUL R3, R3, c[$TEXPARAM0+9];
  1087.                 MAX R3, R3, c[$BASE+8].xxxx;
  1088.                 MIN R3, R3, c[$BASE+8].yyyy;
  1089.  
  1090.                 MOV R10, c[$TEXPARAM0+1];
  1091.                 ADD R4, -c[$TEXPARAM0+0], R10;
  1092.                 MAD R5, R4, R3.xxxx, c[$TEXPARAM0+0];
  1093.                 MOV R10, c[$TEXPARAM0+3];
  1094.                 ADD R4, -c[$TEXPARAM0+2], R10;
  1095.                 MAD R6, R4, R3.xxxx, c[$TEXPARAM0+2];
  1096.                 ADD R4, -R5, R6;
  1097.                 MAD R7, R4, R3.yyyy, R5;
  1098.  
  1099.                 MOV R10, c[$TEXPARAM0+5];
  1100.                 ADD R4, -c[$TEXPARAM0+4], R10;
  1101.                 MAD R5, R4, R3.xxxx, c[$TEXPARAM0+4];
  1102.                 MOV R10, c[$TEXPARAM0+7];
  1103.                 ADD R4, -c[$TEXPARAM0+6], R10;
  1104.                 MAD R6, R4, R3.xxxx, c[$TEXPARAM0+6];
  1105.                 ADD R4, -R5, R6;
  1106.                 MAD R6, R4, R3.yyyy, R5;
  1107.  
  1108.                 ADD R4, -R7, R6;
  1109.                 MAD R7, R4, R3.zzzz, R7;
  1110.                 MOV R3, R7.w;
  1111.                 MOV R3.yzw, c[$BASE+8].yyyy;
  1112.                 MOV R7.w, c[$BASE+8].y;
  1113.                 MOV @O_COL0, R7;
  1114.             "
  1115.  
  1116.             *if_texgen0_normalmap
  1117.             "
  1118.                 MOV R3, R9;
  1119.             "
  1120.  
  1121.             *if_texgen0_tang_u
  1122.             "
  1123.                 MOV R3, R0;
  1124.             "
  1125.  
  1126.             *if_texgen0_tang_v
  1127.             "
  1128.                 MOV R3, R1;
  1129.             "
  1130.  
  1131.  
  1132.             *if_texgen0_reflection
  1133.             "
  1134.                 DP4 R3.x, R8, c[$BASE+4];
  1135.                 DP4 R3.y, R8, c[$BASE+5];
  1136.                 DP4 R3.z, R8, c[$BASE+6];
  1137.                 MOV R3.w, c[$BASE+8].x;
  1138.                 DP3 R4.x, R9, c[$BASE+4];
  1139.                 DP3 R4.y, R9, c[$BASE+5];
  1140.                 DP3 R4.z, R9, c[$BASE+6];
  1141.                 MOV R4.w, c[$BASE+8].x;
  1142.                 DP3 R3.w, -R3, R4;
  1143.                 ADD R3.w, R3.w, R3.w;
  1144.                 MUL R4, R4, R3.wwww;
  1145.                 ADD R3, R3, R4;
  1146.                 MOV R3.w, c[$BASE+8].x;
  1147.             "
  1148.  
  1149.             *if_texgen0_env
  1150.             {
  1151.                 *if_TextureTrans0
  1152.                 " 
  1153.                     MUL R3, $TEXINPUT0, c[$TEXTURETRANS0];
  1154.                     ADD R3, R3, c[$TEXTURETRANS0+1];
  1155.                 "
  1156.                 *ifnot_TextureTrans0
  1157.                 "
  1158.                     MOV R3, $TEXINPUT0;
  1159.                 "
  1160.                 *Post
  1161.                 "
  1162.                     DP3 R3.x, R9, c[$BASE+4];
  1163.                     DP3 R3.y, -R9, c[$BASE+5];
  1164.                     MUL R3, R3, c[$BASE+8].zzzz;
  1165.                     ADD R3, R3, c[$BASE+8].zzzz;
  1166.                 "
  1167.             }
  1168.  
  1169.             *if_texgen0_tslv
  1170.             "
  1171.                 ADD R4, c[$TEXPARAM0+0], -R8;
  1172.                 DP3 R3.x, R9, R4;
  1173.                 DP3 R3.y, R1, R4;
  1174.                 DP3 R3.z, R0, R4;
  1175.                 MUL R3.xyz, R3, c[$TEXPARAM0+0].wwww;
  1176.                 MOV R3.w, c[$BASE+8].x;
  1177.             "
  1178.  
  1179.             // Not tested, only on texcoord 0
  1180.             *if_texgen0_tsreflection
  1181.             "
  1182.                 DP4 R3.x, R8, c[$BASE+4];
  1183.                 DP4 R3.y, R8, c[$BASE+5];
  1184.                 DP4 R3.z, R8, c[$BASE+6];
  1185.                 MOV R3.w, c[$BASE+8].x;
  1186.                 DP3 R4.x, R9, c[$BASE+4];
  1187.                 DP3 R4.y, R9, c[$BASE+5];
  1188.                 DP3 R4.z, R9, c[$BASE+6];
  1189.                 MOV R4.w, c[$BASE+8].x;
  1190.                 DP3 R3.w, -R3, R4;
  1191.                 ADD R3.w, R3.w, R3.w;
  1192.                 MUL R4, R4, R3.wwww;
  1193.                 ADD R4, R3, R4;
  1194.                 DP3 R3.x, R0, R4;
  1195.                 DP3 R3.y, R1, R4;
  1196.                 DP3 R3.z, R9, R4;
  1197.                 MOV R3.w, c[$BASE+8].x;
  1198.             "
  1199.  
  1200.             *if_texgen0_mspos
  1201.             "
  1202.                 MOV @O_TEX0, R8;
  1203.             "
  1204.             
  1205.             *ifnot_texgen0_mspos
  1206.             {
  1207.                 *if_texmatrix0
  1208.                 "
  1209.                     DP4 @O_TEX0.x, R3, c[$TEXMATRIX0+0];
  1210.                     DP4 @O_TEX0.y, R3, c[$TEXMATRIX0+1];
  1211.                     DP4 @O_TEX0.z, R3, c[$TEXMATRIX0+2];
  1212.                     DP4 @O_TEX0.w, R3, c[$TEXMATRIX0+3];
  1213.                 "
  1214.                 
  1215.                 *ifnot_texmatrix0
  1216.                 "
  1217.                     MOV @O_TEX0, R3;
  1218.                 "
  1219.             }
  1220.         }
  1221.     }
  1222.  
  1223.     // ----------------------------------------------------------------
  1224.     *ifnot_texgen1_void
  1225.     {
  1226.         *if_texgen1_texcoord
  1227.         {
  1228.             *if_texmatrix1
  1229.             {
  1230.                 *if_TextureTrans1
  1231.                 " 
  1232.                     MUL R4, $TEXINPUT1, c[$TEXTURETRANS1];
  1233.                     ADD R4, R4, c[$TEXTURETRANS1+1];
  1234.                     DP4 @O_TEX1.x, R4, c[$TEXMATRIX1+0];
  1235.                     DP4 @O_TEX1.y, R4, c[$TEXMATRIX1+1];
  1236.                     DP4 @O_TEX1.z, R4, c[$TEXMATRIX1+2];
  1237.                     DP4 @O_TEX1.w, R4, c[$TEXMATRIX1+3];
  1238.                 "
  1239.                 *ifnot_TextureTrans1
  1240.                 "
  1241.                     DP4 @O_TEX1.x, $TEXINPUT1, c[$TEXMATRIX1+0];
  1242.                     DP4 @O_TEX1.y, $TEXINPUT1, c[$TEXMATRIX1+1];
  1243.                     DP4 @O_TEX1.z, $TEXINPUT1, c[$TEXMATRIX1+2];
  1244.                     DP4 @O_TEX1.w, $TEXINPUT1, c[$TEXMATRIX1+3];
  1245.                 "
  1246.             }
  1247.  
  1248.             *ifnot_texmatrix1
  1249.             {
  1250.                 *if_CubeTex
  1251.                 "
  1252.                     MOV @O_TEX1, R4;
  1253.                 "
  1254.                 
  1255.                 *ifnot_CubeTex
  1256.                 {
  1257.                     *if_TextureTrans1
  1258.                     " 
  1259.                         MUL R4, $TEXINPUT1, c[$TEXTURETRANS1];
  1260.                         ADD @O_TEX1, R4, c[$TEXTURETRANS1+1];
  1261.                     "
  1262.                     *ifnot_TextureTrans1
  1263.                     "
  1264.                         MOV @O_TEX1, $TEXINPUT1;
  1265.                     "
  1266.                 }
  1267.             }
  1268.         }
  1269.  
  1270.         *ifnot_texgen1_texcoord
  1271.         {
  1272.             *if_texgen1_linear
  1273.             "
  1274.                 DP4 R3.x, R8, c[$TEXPARAM1+0];
  1275.                 DP4 R3.y, R8, c[$TEXPARAM1+1];
  1276.                 DP4 R3.z, R8, c[$TEXPARAM1+2];
  1277.                 DP4 R3.w, R8, c[$TEXPARAM1+3];
  1278.             "
  1279.  
  1280.             *if_texgen1_screen
  1281.             "
  1282.                 mul r4, c93, r12.w
  1283.                 mad r3, r12, c92, r4
  1284.             "
  1285.  
  1286.             *if_texgen1_normalmap
  1287.             "
  1288.                 MOV R3, R9;
  1289.             "
  1290.  
  1291.             *if_texgen1_tang_u
  1292.             "
  1293.                 MOV R3, R0;
  1294.             "
  1295.  
  1296.             *if_texgen1_tang_v
  1297.             "
  1298.                 MOV R3, R1;
  1299.             "
  1300.  
  1301.             *if_texgen1_reflection
  1302.             "
  1303.                 DP4 R3.x, R8, c[$BASE+4];
  1304.                 DP4 R3.y, R8, c[$BASE+5];
  1305.                 DP4 R3.z, R8, c[$BASE+6];
  1306.                 DP3 R4.x, R9, c[$BASE+4];
  1307.                 DP3 R4.y, R9, c[$BASE+5];
  1308.                 DP3 R4.z, R9, c[$BASE+6];
  1309.                 DP3 R3.w, -R3, R4;
  1310.                 ADD R3.w, R3.w, R3.w;
  1311.                 MUL R4, R4, R3.wwww;
  1312.                 ADD R3, R3, R4;
  1313.                 MOV R3.w, c[$BASE+8].x;
  1314.             "
  1315.  
  1316.             *if_texgen1_env
  1317.             {
  1318.                 *if_TextureTrans1
  1319.                 " 
  1320.                     MUL R3, $TEXINPUT1, c[$TEXTURETRANS1];
  1321.                     ADD R3, R3, c[$TEXTURETRANS1+1];
  1322.                 "
  1323.                 *ifnot_TextureTrans1
  1324.                 "
  1325.                     MOV R3, $TEXINPUT1;
  1326.                 "
  1327.                 *Post
  1328.                 "
  1329.                     DP3 R3.x, R9, c[$BASE+4];
  1330.                     DP3 R3.y, -R9, c[$BASE+5];
  1331.                     MUL R3, R3, c[$BASE+8].zzzz;
  1332.                     ADD R3, R3, c[$BASE+8].zzzz;
  1333.                 "
  1334.             }
  1335.  
  1336.             *if_texgen1_tslv
  1337.             "
  1338.                 ADD R4, c[$TEXPARAM1+0], -R8;
  1339.                 DP3 R3.x, R9, R4;
  1340.                 DP3 R3.y, R1, R4;
  1341.                 DP3 R3.z, R0, R4;
  1342.                 MUL R3.xyz, R3, c[$TEXPARAM1+0].wwww;
  1343.                 MOV R3.w, c[$BASE+8].x;
  1344.             "
  1345. /*                DP3 R3.w, R3, R3;
  1346.                 RSQ R3.w, R3.w;
  1347.                 MUL R3.xyz, R3, R3.w;*/
  1348.  
  1349. /*            *if_texgen1_tsreflection
  1350.             "
  1351.                 ADD R4, c[$TEXPARAM1+0], -R8;
  1352.                 ADD R5, c[$TEXPARAM1+1], -R8;
  1353.                 DP3 R3.w, R4, R4;
  1354.                 RSQ R3.w, R3.w;
  1355.                 MUL R4.xyz, R4, R3.w;
  1356.                 DP3 R3.w, R5, R5;
  1357.                 RSQ R3.w, R3.w;
  1358.                 MUL R5.xyz, R5, R3.w;
  1359.                 ADD R4, R4, R5;
  1360.                 DP3 R3.x, R0, R4;
  1361.                 DP3 R3.y, R1, R4;
  1362.                 DP3 R3.z, R9, R4;
  1363.                 MOV R3.w, c[$BASE+8].x;
  1364.             "
  1365. */
  1366.             *if_texgen1_tsreflection
  1367.             "
  1368.                 ADD R4, c[$TEXPARAM1+0], -R8;
  1369.                 ADD R5, c[$TEXPARAM1+1], -R8;
  1370.                 ADD R4, R4, R5;
  1371.                 DP3 R3.w, R4, R4;
  1372.                 RSQ R3.w, R3.w;
  1373.                 MUL R4.xyz, R4, R3.w;
  1374.                 DP3 R3.x, R1, R4;
  1375.                 DP3 R3.y, R0, -R4;
  1376.                 DP3 R3.z, R9, R4;
  1377.                 MOV R4, c[$BASE+8].yxxx;
  1378.                 MUL R5, R3.zxyw, R4.yzxw;
  1379.                 MAD R5, R3.yzxw, R4.zxyw, -R5;
  1380.                 MUL R7, R3.zxyw, R5.yzxw;
  1381.                 MAD R4, R3.yzxw, R5.zxyw, -R7;
  1382.  
  1383.                 DP3 R3.w, R4, R4;
  1384.                 RSQ R3.w, R3.w;
  1385.                 MUL R4.xyz, R4, R3.w;
  1386.  
  1387.                 DP3 R3.w, R5, R5;
  1388.                 RSQ R3.w, R3.w;
  1389.                 MUL R5.xyz, R5, R3.w;
  1390.  
  1391.                 MOV @O_TEX2.x, R3.y;
  1392.                 MOV @O_TEX2.y, R4.y;
  1393.                 MOV @O_TEX2.z, R5.y;
  1394.                 MOV @O_TEX2.w, c[$BASE+8].x;
  1395.                 MOV @O_TEX3.x, R3.z;
  1396.                 MOV @O_TEX3.y, R4.z;
  1397.                 MOV @O_TEX3.z, R5.z;
  1398.                 MOV @O_TEX3.w, c[$BASE+8].x;
  1399.                 MOV R3.y, R4.x;
  1400.                 MOV R3.z, R5.x;
  1401.                 MOV R3.w, c[$BASE+8].x;
  1402.             "
  1403. /*                DP3 R3.x, R0, R4;
  1404.                 DP3 R3.y, R1, R4;
  1405.                 DP3 R3.z, R9, R4;
  1406.  
  1407.                 DP3 R3.w, R5, R5;
  1408.                 RSQ R3.w, R3.w;
  1409.                 MUL R5.xyz, R5, R3.w;
  1410.                 ADD R4, R4, R5;
  1411.                 
  1412.                 */
  1413.  
  1414. //                MOV R3, R0;
  1415. //                MOV @O_TEX2, R1;
  1416.  
  1417.             *if_texgen1_bumpcubeenv
  1418.             {
  1419.                 *doit
  1420.                 "
  1421.                     DP4    R3.x,c[$TEXPARAM1+0],R8;
  1422.                     DP4    R3.y,c[$TEXPARAM1+1],R8;
  1423.                     DP4    R3.z,c[$TEXPARAM1+2],R8;
  1424.                     ADD R3, -R3.xyzz, c[$TEXPARAM1+7].xyzz;
  1425.                     MOV R3.w, R3.x;
  1426.                     MOV R4.w, R3.y;
  1427.                     MOV R5.w, R3.z;
  1428.                 "
  1429.                 *if_texcoordout4
  1430.                 "
  1431.                     MUL @O_TEX4, R3,c[$BASE+9].wwww;
  1432.                 "
  1433.                 *doit2
  1434.                 "
  1435.                     DP3 R3.x,R9,c[$TEXPARAM1+0];
  1436.                     DP3 R3.y,R1,c[$TEXPARAM1+0];
  1437.                     DP3 R3.z,R0,c[$TEXPARAM1+0];
  1438.                     DP3 R4.x,R9,c[$TEXPARAM1+1];
  1439.                     DP3 R4.y,R1,c[$TEXPARAM1+1];
  1440.                     DP3 R4.z,R0,c[$TEXPARAM1+1];
  1441.                     DP3 R5.x,R9,c[$TEXPARAM1+2];
  1442.                     DP3 R5.y,R1,c[$TEXPARAM1+2];
  1443.                     DP3 R5.z,R0,c[$TEXPARAM1+2];
  1444.                     MUL R3.xyz, R3, c[$TEXPARAM1+3];
  1445.                     MUL R4.xyz, R4, c[$TEXPARAM1+3];
  1446.                     MUL R5.xyz, R5, c[$TEXPARAM1+3];
  1447.                     MOV @O_TEX2, R4;
  1448.                     MOV @O_TEX3, R5;
  1449.                 "
  1450.             }
  1451.  
  1452.             *if_texgen1_mspos
  1453.             "
  1454.                 MOV @O_TEX1, R8;
  1455.             "
  1456.             
  1457.             *ifnot_texgen1_mspos
  1458.             {
  1459.                 *if_texmatrix1
  1460.                 "
  1461.                     DP4 @O_TEX1.x, R3, c[$TEXMATRIX1+0];
  1462.                     DP4 @O_TEX1.y, R3, c[$TEXMATRIX1+1];
  1463.                     DP4 @O_TEX1.z, R3, c[$TEXMATRIX1+2];
  1464.                     DP4 @O_TEX1.w, R3, c[$TEXMATRIX1+3];
  1465.                 "
  1466.  
  1467.                 *ifnot_texmatrix1
  1468.                 "
  1469.                     MOV @O_TEX1, R3;
  1470.                 "
  1471.             }
  1472.         }
  1473.     }
  1474.  
  1475.     // ----------------------------------------------------------------
  1476.     *ifnot_texgen2_void
  1477.     {
  1478.         *if_texgen2_texcoord
  1479.         {
  1480.             *if_texmatrix2
  1481.             {
  1482.                 *if_TextureTrans2
  1483.                 " 
  1484.                     MUL R4, $TEXINPUT2, c[$TEXTURETRANS2];
  1485.                     ADD R4, R4, c[$TEXTURETRANS2+1];
  1486.                     DP4 @O_TEX2.x, R4, c[$TEXMATRIX2+0];
  1487.                     DP4 @O_TEX2.y, R4, c[$TEXMATRIX2+1];
  1488.                     DP4 @O_TEX2.z, R4, c[$TEXMATRIX2+2];
  1489.                     DP4 @O_TEX2.w, R4, c[$TEXMATRIX2+3];
  1490.                 "
  1491.                 *ifnot_TextureTrans2
  1492.                 "
  1493.                     DP4 @O_TEX2.x, $TEXINPUT2, c[$TEXMATRIX2+0];
  1494.                     DP4 @O_TEX2.y, $TEXINPUT2, c[$TEXMATRIX2+1];
  1495.                     DP4 @O_TEX2.z, $TEXINPUT2, c[$TEXMATRIX2+2];
  1496.                     DP4 @O_TEX2.w, $TEXINPUT2, c[$TEXMATRIX2+3];
  1497.                 "
  1498.             }
  1499.  
  1500.             *ifnot_texmatrix2
  1501.             {
  1502.                 *if_TextureTrans2
  1503.                 " 
  1504.                     MUL R4, $TEXINPUT2, c[$TEXTURETRANS2];
  1505.                     ADD @O_TEX2, R4, c[$TEXTURETRANS2+1];
  1506.                 "
  1507.                 *ifnot_TextureTrans2
  1508.                 "
  1509.                     MOV @O_TEX2, $TEXINPUT2;
  1510.                 "
  1511.             }
  1512.         }
  1513.  
  1514.         *ifnot_texgen2_texcoord
  1515.         {
  1516.             *if_texgen2_linear
  1517.             "
  1518.                 DP4 R3.x, R8, c[$TEXPARAM2+0];
  1519.                 DP4 R3.y, R8, c[$TEXPARAM2+1];
  1520.                 DP4 R3.z, R8, c[$TEXPARAM2+2];
  1521.                 DP4 R3.w, R8, c[$TEXPARAM2+3];
  1522.             "
  1523.  
  1524.             *if_texgen2_screen
  1525.             "
  1526.                 mul r4, c93, r12.w
  1527.                 mad r3, r12, c92, r4
  1528.             "
  1529.             
  1530.             *if_texgen2_normalmap
  1531.             "
  1532.                 MOV R3, R9;
  1533.             "
  1534.  
  1535.             *if_texgen2_tang_u
  1536.             "
  1537.                 MOV R3, R0;
  1538.             "
  1539.  
  1540.             *if_texgen2_tang_v
  1541.             "
  1542.                 MOV R3, R1;
  1543.             "
  1544.             *if_texgen2_reflection
  1545.             "
  1546.                 DP4 R3.x, R8, c[$BASE+4];
  1547.                 DP4 R3.y, R8, c[$BASE+5];
  1548.                 DP4 R3.z, R8, c[$BASE+6];
  1549.                 MOV R3.w, c[$BASE+8].x;
  1550.                 DP3 R4.x, R9, c[$BASE+4];
  1551.                 DP3 R4.y, R9, c[$BASE+5];
  1552.                 DP3 R4.z, R9, c[$BASE+6];
  1553.                 MOV R4.w, c[$BASE+8].x;
  1554.                 DP3 R3.w, -R3, R4;
  1555.                 ADD R3.w, R3.w, R3.w;
  1556.                 MUL R4, R4, R3.wwww;
  1557.                 ADD R3, R3, R4;
  1558.                 MOV R3.w, c[$BASE+8].x;
  1559.             "
  1560.  
  1561.             *if_texgen2_tsreflection
  1562.             "
  1563.                 ADD R4, c[$TEXPARAM2+0], -R8;
  1564.                 ADD R5, c[$TEXPARAM2+1], -R8;
  1565.                 DP3 R3.w, R4, R4;
  1566.                 RSQ R3.w, R3.w;
  1567.                 MUL R4.xyz, R4, R3.w;
  1568.                 DP3 R3.w, R5, R5;
  1569.                 RSQ R3.w, R3.w;
  1570.                 MUL R5.xyz, R5, R3.w;
  1571.                 ADD R4, R4, R5;
  1572.                 DP3 R3.x, R0, R4;
  1573.                 DP3 R3.y, R1, R4;
  1574.                 DP3 R3.z, R9, R4;
  1575.                 MOV R3.w, c[$BASE+8].x;
  1576.             "
  1577.  
  1578.  
  1579.             *if_texgen2_env
  1580.             {
  1581.                 *if_TextureTrans2
  1582.                 " 
  1583.                     MUL R3, $TEXINPUT2, c[$TEXTURETRANS2];
  1584.                     ADD R3, R3, c[$TEXTURETRANS2+1];
  1585.                 "
  1586.                 *ifnot_TextureTrans2
  1587.                 "
  1588.                     MOV R3, $TEXINPUT2;
  1589.                 "
  1590.                 *Post
  1591.                 "
  1592.                     DP3 R3.x, R9, c[$BASE+4];
  1593.                     DP3 R3.y, -R9, c[$BASE+5];
  1594.                     MUL R3, R3, c[$BASE+8].zzzz;
  1595.                     ADD R3, R3, c[$BASE+8].zzzz;
  1596.                 "
  1597.             }
  1598.  
  1599.             // This TSLV is flipped
  1600.             *if_texgen2_tslv
  1601.             "
  1602.                 ADD R4, c[$TEXPARAM2+0], -R8;
  1603.                 DP3 R3.x, R9, R4;
  1604.                 DP3 R3.y, R1, R4;
  1605.                 DP3 R3.z, R0, R4;
  1606.                 MUL R3, R3, c[$TEXPARAM2+0].wwww;
  1607.                 MOV R3.w, c[$BASE+8].x;
  1608.             "
  1609.  
  1610.             *if_texgen2_mspos
  1611.             "
  1612.                 MOV @O_TEX2, R8;
  1613.             "
  1614.             
  1615.             *ifnot_texgen2_mspos
  1616.             {
  1617.                 *if_texmatrix2
  1618.                 "
  1619.                     DP4 @O_TEX2.x, R3, c[$TEXMATRIX2+0];
  1620.                     DP4 @O_TEX2.y, R3, c[$TEXMATRIX2+1];
  1621.                     DP4 @O_TEX2.z, R3, c[$TEXMATRIX2+2];
  1622.                     DP4 @O_TEX2.w, R3, c[$TEXMATRIX2+3];
  1623.                 "
  1624.  
  1625.                 *ifnot_texmatrix2
  1626.                 "
  1627.                     MOV @O_TEX2, R3;
  1628.                 "
  1629.             }
  1630.         }
  1631.     }
  1632.  
  1633.     // ----------------------------------------------------------------
  1634.     *ifnot_texgen3_void
  1635.     {
  1636.         *if_texgen3_texcoord
  1637.         {
  1638.             *if_texmatrix3
  1639.             {
  1640.                 *if_TextureTrans3
  1641.                 " 
  1642.                     MUL R4, $TEXINPUT3, c[$TEXTURETRANS3];
  1643.                     ADD R4, R4, c[$TEXTURETRANS3+1];
  1644.                     DP4 @O_TEX3.x, R4, c[$TEXMATRIX3+0];
  1645.                     DP4 @O_TEX3.y, R4, c[$TEXMATRIX3+1];
  1646.                     DP4 @O_TEX3.z, R4, c[$TEXMATRIX3+2];
  1647.                     DP4 @O_TEX3.w, R4, c[$TEXMATRIX3+3];
  1648.                 "
  1649.                 *ifnot_TextureTrans3
  1650.                 "
  1651.                     DP4 @O_TEX3.x, $TEXINPUT3, c[$TEXMATRIX3+0];
  1652.                     DP4 @O_TEX3.y, $TEXINPUT3, c[$TEXMATRIX3+1];
  1653.                     DP4 @O_TEX3.z, $TEXINPUT3, c[$TEXMATRIX3+2];
  1654.                     DP4 @O_TEX3.w, $TEXINPUT3, c[$TEXMATRIX3+3];
  1655.                 "
  1656.             }
  1657.  
  1658.             *ifnot_texmatrix3
  1659.             {
  1660.                 *if_TextureTrans3
  1661.                 " 
  1662.                     MUL R4, $TEXINPUT3, c[$TEXTURETRANS3];
  1663.                     ADD @O_TEX3, R4, c[$TEXTURETRANS3+1];
  1664.                 "
  1665.                 *ifnot_TextureTrans3
  1666.                 "
  1667.                     MOV @O_TEX3, $TEXINPUT3;
  1668.                 "
  1669.             }
  1670.         }
  1671.  
  1672.         *ifnot_texgen3_texcoord
  1673.         {
  1674.             *if_texgen3_linear
  1675.             "
  1676.                 DP4 R3.x, R8, c[$TEXPARAM3+0];
  1677.                 DP4 R3.y, R8, c[$TEXPARAM3+1];
  1678.                 DP4 R3.z, R8, c[$TEXPARAM3+2];
  1679.                 DP4 R3.w, R8, c[$TEXPARAM3+3];
  1680.             "
  1681.  
  1682.             *if_texgen3_screen
  1683.             "
  1684.                 mul r4, c93, r12.w
  1685.                 mad r3, r12, c92, r4
  1686.             "
  1687.  
  1688.             *if_texgen3_normalmap
  1689.             "
  1690.                 MOV R3, R9;
  1691.             "
  1692.  
  1693.             *if_texgen3_tang_u
  1694.             "
  1695.                 MOV R3, R0;
  1696.             "
  1697.  
  1698.             *if_texgen3_tang_v
  1699.             "
  1700.                 MOV R3, R1;
  1701.             "
  1702.  
  1703.             *if_texgen3_reflection
  1704.             "
  1705.                 DP4 R3.x, R8, c[$BASE+4];
  1706.                 DP4 R3.y, R8, c[$BASE+5];
  1707.                 DP4 R3.z, R8, c[$BASE+6];
  1708.                 MOV R3.w, c[$BASE+8].x;
  1709.                 DP3 R4.x, R9, c[$BASE+4];
  1710.                 DP3 R4.y, R9, c[$BASE+5];
  1711.                 DP3 R4.z, R9, c[$BASE+6];
  1712.                 MOV R4.w, c[$BASE+8].x;
  1713.                 DP3 R3.w, -R3, R4;
  1714.                 ADD R3.w, R3.w, R3.w;
  1715.                 MUL R4, R4, R3.wwww;
  1716.                 ADD R3, R3, R4;
  1717.                 MOV R3.w, c[$BASE+8].x;
  1718.             "
  1719.  
  1720.             *if_texgen3_tsreflection
  1721.             "
  1722.                 ADD R4, c[$TEXPARAM3+0], -R8;
  1723.                 ADD R5, c[$TEXPARAM3+1], -R8;
  1724.                 ADD R4, R4, R5;
  1725.                 DP3 R3.w, R4, R4;
  1726.                 RSQ R3.w, R3.w;
  1727.                 MUL R4.xyz, R4, R3.w;
  1728.                 DP3 R3.x, R1, R4;
  1729.                 DP3 R3.y, R0, -R4;
  1730.                 DP3 R3.z, R9, R4;
  1731.                 MOV R4, c[$BASE+8].yxxx;
  1732.                 MUL R5, R3.zxyw, R4.yzxw;
  1733.                 MAD R5, R3.yzxw, R4.zxyw, -R5;
  1734.                 MUL R7, R3.zxyw, R5.yzxw;
  1735.                 MAD R4, R3.yzxw, R5.zxyw, -R7;
  1736.  
  1737.                 DP3 R3.w, R4, R4;
  1738.                 RSQ R3.w, R3.w;
  1739.                 MUL R4.xyz, R4, R3.w;
  1740.  
  1741.                 DP3 R3.w, R5, R5;
  1742.                 RSQ R3.w, R3.w;
  1743.                 MUL R5.xyz, R5, R3.w;
  1744.  
  1745.                 MOV @O_TEX4.x, R3.y;
  1746.                 MOV @O_TEX4.y, R4.y;
  1747.                 MOV @O_TEX4.z, R5.y;
  1748.                 MOV @O_TEX4.w, c[$BASE+8].x;
  1749.                 MOV @O_TEX5.x, R3.z;
  1750.                 MOV @O_TEX5.y, R4.z;
  1751.                 MOV @O_TEX5.z, R5.z;
  1752.                 MOV @O_TEX5.w, c[$BASE+8].x;
  1753.                 MOV R3.y, R4.x;
  1754.                 MOV R3.z, R5.x;
  1755.                 MOV R3.w, c[$BASE+8].x;
  1756.             "
  1757.  
  1758.             *if_texgen3_env
  1759.             {
  1760.                 *if_TextureTrans3
  1761.                 " 
  1762.                     MUL R3, $TEXINPUT3, c[$TEXTURETRANS3];
  1763.                     ADD R3, R3, c[$TEXTURETRANS3+1];
  1764.                 "
  1765.                 *ifnot_TextureTrans3
  1766.                 "
  1767.                     MOV R3, $TEXINPUT3;
  1768.                 "
  1769.                 *Post
  1770.                 "
  1771.                     MOV R3, $TEXINPUT3;
  1772.                     DP3 R3.x, R9, c[$BASE+4];
  1773.                     DP3 R3.y, -R9, c[$BASE+5];
  1774.                     MUL R3, R3, c[$BASE+8].zzzz;
  1775.                     ADD R3, R3, c[$BASE+8].zzzz;
  1776.                 "
  1777.             }
  1778.  
  1779.             *if_texgen3_tslv
  1780.             "
  1781.                 ADD R4, c[$TEXPARAM3+0], -R8;
  1782.                 DP3 R3.x, R9, R4;
  1783.                 DP3 R3.y, R1, R4;
  1784.                 DP3 R3.z, R0, R4;
  1785.                 MUL R3.xyz, R3, c[$TEXPARAM3+0].wwww;
  1786.                 MOV R3.w, c[$BASE+8].x;
  1787.             "
  1788.  
  1789.             *if_texgen3_mspos
  1790.             "
  1791.                 MOV @O_TEX3, R8;
  1792.             "
  1793.             
  1794.             *ifnot_texgen3_mspos
  1795.             {
  1796.                 *if_texmatrix3
  1797.                 "
  1798.                     DP4 @O_TEX3.x, R3, c[$TEXMATRIX3+0];
  1799.                     DP4 @O_TEX3.y, R3, c[$TEXMATRIX3+1];
  1800.                     DP4 @O_TEX3.z, R3, c[$TEXMATRIX3+2];
  1801.                     DP4 @O_TEX3.w, R3, c[$TEXMATRIX3+3];
  1802.                 "
  1803.  
  1804.                 *ifnot_texmatrix3
  1805.                 "
  1806.                     MOV @O_TEX3, R3;
  1807.                 "
  1808.             }
  1809.         }
  1810.     }
  1811.  
  1812.     // ----------------------------------------------------------------
  1813.     *ifnot_texgen4_void
  1814.     {
  1815.         *if_texgen4_texcoord
  1816.         {
  1817.             *if_texmatrix4
  1818.             {
  1819.                 *if_TextureTrans4
  1820.                 " 
  1821.                     MUL R4, $TEXINPUT4, c[$TEXTURETRANS4];
  1822.                     ADD R4, R4, c[$TEXTURETRANS4+1];
  1823.                     DP4 @O_TEX4.x, R4, c[$TEXMATRIX4+0];
  1824.                     DP4 @O_TEX4.y, R4, c[$TEXMATRIX4+1];
  1825.                     DP4 @O_TEX4.z, R4, c[$TEXMATRIX4+2];
  1826.                     DP4 @O_TEX4.w, R4, c[$TEXMATRIX4+3];
  1827.                 "
  1828.                 *ifnot_TextureTrans4
  1829.                 "
  1830.                     DP4 @O_TEX4.x, $TEXINPUT4, c[$TEXMATRIX4+0];
  1831.                     DP4 @O_TEX4.y, $TEXINPUT4, c[$TEXMATRIX4+1];
  1832.                     DP4 @O_TEX4.z, $TEXINPUT4, c[$TEXMATRIX4+2];
  1833.                     DP4 @O_TEX4.w, $TEXINPUT4, c[$TEXMATRIX4+3];
  1834.                 "
  1835.             }
  1836.  
  1837.             *ifnot_texmatrix4
  1838.             {
  1839.                 *if_TextureTrans4
  1840.                 " 
  1841.                     MUL R4, $TEXINPUT4, c[$TEXTURETRANS4];
  1842.                     ADD @O_TEX4, R4, c[$TEXTURETRANS4+1];
  1843.                 "
  1844.                 *ifnot_TextureTrans4
  1845.                 "
  1846.                     MOV @O_TEX4, $TEXINPUT4;
  1847.                 "
  1848.             }
  1849.         }
  1850.  
  1851.         *ifnot_texgen4_texcoord
  1852.         {
  1853.             *if_texgen4_linear
  1854.             "
  1855.                 DP4 R3.x, R8, c[$TEXPARAM4+0];
  1856.                 DP4 R3.y, R8, c[$TEXPARAM4+1];
  1857.                 DP4 R3.z, R8, c[$TEXPARAM4+2];
  1858.                 DP4 R3.w, R8, c[$TEXPARAM4+3];
  1859.             "
  1860.  
  1861.             *if_texgen4_screen
  1862.             "
  1863.                 mul r4, c93, r12.w
  1864.                 mad r3, r12, c92, r4
  1865.             "
  1866.  
  1867.             *if_texgen4_normalmap
  1868.             "
  1869.                 MOV R3, R9;
  1870.             "
  1871.  
  1872.             *if_texgen4_tang_u
  1873.             "
  1874.                 MOV R3, R0;
  1875.             "
  1876.  
  1877.             *if_texgen4_tang_v
  1878.             "
  1879.                 MOV R3, R1;
  1880.             "
  1881.  
  1882.             *if_texgen4_reflection
  1883.             "
  1884.                 DP4 R3.x, R8, c[$BASE+4];
  1885.                 DP4 R3.y, R8, c[$BASE+5];
  1886.                 DP4 R3.z, R8, c[$BASE+6];
  1887.                 MOV R3.w, c[$BASE+8].x;
  1888.                 DP3 R4.x, R9, c[$BASE+4];
  1889.                 DP3 R4.y, R9, c[$BASE+5];
  1890.                 DP3 R4.z, R9, c[$BASE+6];
  1891.                 MOV R4.w, c[$BASE+8].x;
  1892.                 DP3 R3.w, -R3, R4;
  1893.                 ADD R3.w, R3.w, R3.w;
  1894.                 MUL R4, R4, R3.wwww;
  1895.                 ADD R3, R3, R4;
  1896.                 MOV R3.w, c[$BASE+8].x;
  1897.             "
  1898.  
  1899.             *if_texgen4_env
  1900.             {
  1901.                 *if_TextureTrans4
  1902.                 " 
  1903.                     MUL R3, $TEXINPUT4, c[$TEXTURETRANS4];
  1904.                     ADD R3, R3, c[$TEXTURETRANS4+1];
  1905.                 "
  1906.                 *ifnot_TextureTrans4
  1907.                 "
  1908.                     MOV R3, $TEXINPUT4;
  1909.                 "
  1910.                 *Post
  1911.                 "
  1912.                     MOV R3, $TEXINPUT4;
  1913.                     DP3 R3.x, R9, c[$BASE+4];
  1914.                     DP3 R3.y, -R9, c[$BASE+5];
  1915.                     MUL R3, R3, c[$BASE+8].zzzz;
  1916.                     ADD R3, R3, c[$BASE+8].zzzz;
  1917.                 "
  1918.             }
  1919.  
  1920.             *if_texgen4_tslv
  1921.             "
  1922.                 ADD R4, c[$TEXPARAM4+0], -R8;
  1923.                 DP3 R3.x, R9, R4;
  1924.                 DP3 R3.y, R1, R4;
  1925.                 DP3 R3.z, R0, R4;
  1926.                 MUL R3.xyz, R3, c[$TEXPARAM4+0].wwww;
  1927.                 MOV R3.w, c[$BASE+8].x;
  1928.             "
  1929.  
  1930.             *if_texgen4_mspos
  1931.             "
  1932.                 MOV @O_TEX4, R8;
  1933.             "
  1934.             
  1935.             *ifnot_texgen4_mspos
  1936.             {
  1937.                 *if_texmatrix4
  1938.                 "
  1939.                     DP4 @O_TEX4.x, R3, c[$TEXMATRIX4+0];
  1940.                     DP4 @O_TEX4.y, R3, c[$TEXMATRIX4+1];
  1941.                     DP4 @O_TEX4.z, R3, c[$TEXMATRIX4+2];
  1942.                     DP4 @O_TEX4.w, R3, c[$TEXMATRIX4+3];
  1943.                 "
  1944.  
  1945.                 *ifnot_texmatrix4
  1946.                 "
  1947.                     MOV @O_TEX4, R3;
  1948.                 "
  1949.             }
  1950.         }
  1951.     }
  1952.  
  1953.     // ----------------------------------------------------------------
  1954.     *ifnot_texgen5_void
  1955.     {
  1956.         *if_texgen5_texcoord
  1957.         {
  1958.             *if_texmatrix5
  1959.             {
  1960.                 *if_TextureTrans5
  1961.                 " 
  1962.                     MUL R4, $TEXINPUT5, c[$TEXTURETRANS5];
  1963.                     ADD R4, R4, c[$TEXTURETRANS5+1];
  1964.                     DP4 @O_TEX5.x, R4, c[$TEXMATRIX5+0];
  1965.                     DP4 @O_TEX5.y, R4, c[$TEXMATRIX5+1];
  1966.                     DP4 @O_TEX5.z, R4, c[$TEXMATRIX5+2];
  1967.                     DP4 @O_TEX5.w, R4, c[$TEXMATRIX5+3];
  1968.                 "
  1969.                 *ifnot_TextureTrans5
  1970.                 "
  1971.                     DP4 @O_TEX5.x, $TEXINPUT5, c[$TEXMATRIX5+0];
  1972.                     DP4 @O_TEX5.y, $TEXINPUT5, c[$TEXMATRIX5+1];
  1973.                     DP4 @O_TEX5.z, $TEXINPUT5, c[$TEXMATRIX5+2];
  1974.                     DP4 @O_TEX5.w, $TEXINPUT5, c[$TEXMATRIX5+3];
  1975.                 "
  1976.             }
  1977.  
  1978.             *ifnot_texmatrix5
  1979.             {
  1980.                 *if_TextureTrans5
  1981.                 " 
  1982.                     MUL R4, $TEXINPUT5, c[$TEXTURETRANS5];
  1983.                     ADD @O_TEX5, R4, c[$TEXTURETRANS5+1];
  1984.                 "
  1985.                 *ifnot_TextureTrans5
  1986.                 "
  1987.                     MOV @O_TEX5, $TEXINPUT5;
  1988.                 "
  1989.             }
  1990.         }
  1991.  
  1992.         *ifnot_texgen5_texcoord
  1993.         {
  1994.             *if_texgen5_linear
  1995.             "
  1996.                 DP4 R3.x, R8, c[$TEXPARAM5+0];
  1997.                 DP4 R3.y, R8, c[$TEXPARAM5+1];
  1998.                 DP4 R3.z, R8, c[$TEXPARAM5+2];
  1999.                 DP4 R3.w, R8, c[$TEXPARAM5+3];
  2000.             "
  2001.  
  2002.             *if_texgen5_screen
  2003.             "
  2004.                 mul r4, c93, r12.w
  2005.                 mad r3, r12, c92, r4
  2006.             "
  2007.  
  2008.             *if_texgen5_normalmap
  2009.             "
  2010.                 MOV R3, R9;
  2011.             "
  2012.  
  2013.             *if_texgen5_reflection
  2014.             "
  2015.                 DP4 R3.x, R8, c[$BASE+4];
  2016.                 DP4 R3.y, R8, c[$BASE+5];
  2017.                 DP4 R3.z, R8, c[$BASE+6];
  2018.                 MOV R3.w, c[$BASE+8].x;
  2019.                 DP3 R4.x, R9, c[$BASE+4];
  2020.                 DP3 R4.y, R9, c[$BASE+5];
  2021.                 DP3 R4.z, R9, c[$BASE+6];
  2022.                 MOV R4.w, c[$BASE+8].x;
  2023.                 DP3 R3.w, -R3, R4;
  2024.                 ADD R3.w, R3.w, R3.w;
  2025.                 MUL R4, R4, R3.wwww;
  2026.                 ADD R3, R3, R4;
  2027.                 MOV R3.w, c[$BASE+8].x;
  2028.             "
  2029.  
  2030.             *if_texgen5_env
  2031.             {
  2032.                 *if_TextureTrans5
  2033.                 " 
  2034.                     MUL R3, $TEXINPUT5, c[$TEXTURETRANS5];
  2035.                     ADD R3, R3, c[$TEXTURETRANS5+1];
  2036.                 "
  2037.                 *ifnot_TextureTrans3
  2038.                 "
  2039.                     MOV R3, $TEXINPUT5;
  2040.                 "
  2041.                 *Post
  2042.                 "
  2043.                     MOV R3, $TEXINPUT5;
  2044.                     DP3 R3.x, R9, c[$BASE+4];
  2045.                     DP3 R3.y, -R9, c[$BASE+5];
  2046.                     MUL R3, R3, c[$BASE+8].zzzz;
  2047.                     ADD R3, R3, c[$BASE+8].zzzz;
  2048.                 "
  2049.             }
  2050.  
  2051.             *if_texgen5_tslv
  2052.             "
  2053.                 ADD R4, c[$TEXPARAM5+0], -R8;
  2054.                 DP3 R3.x, R9, R4;
  2055.                 DP3 R3.y, R1, R4;
  2056.                 DP3 R3.z, R0, R4;
  2057.                 MUL R3.xyz, R3, c[$TEXPARAM5+0].wwww;
  2058.                 MOV R3.w, c[$BASE+8].x;
  2059.             "
  2060.  
  2061.             *if_texgen5_mspos
  2062.             "
  2063.                 MOV @O_TEX5, R8;
  2064.             "
  2065.  
  2066.             *if_texgen5_bumpcubeenv
  2067.             {
  2068.                 *doit
  2069.                 "
  2070.                     DP3 R3.x,R9,c[$TEXPARAM1+0];
  2071.                     DP3 R3.y,R1,c[$TEXPARAM1+0];
  2072.                     DP3 R3.z,R0,c[$TEXPARAM1+0];
  2073.                     DP3 R4.x,R9,c[$TEXPARAM1+1];
  2074.                     DP3 R4.y,R1,c[$TEXPARAM1+1];
  2075.                     DP3 R4.z,R0,c[$TEXPARAM1+1];
  2076.                     DP3 R5.x,R9,c[$TEXPARAM1+2];
  2077.                     DP3 R5.y,R1,c[$TEXPARAM1+2];
  2078.                     DP3 R5.z,R0,c[$TEXPARAM1+2];
  2079.                     MOV @O_TEX6, R4;
  2080.                     MOV @O_TEX7, R5;
  2081.                 "
  2082.             }
  2083.             *ifnot_texgen5_mspos
  2084.             {
  2085.                 *if_texmatrix5
  2086.                 "
  2087.                     DP4 @O_TEX5.x, R3, c[$TEXMATRIX5+0];
  2088.                     DP4 @O_TEX5.y, R3, c[$TEXMATRIX5+1];
  2089.                     DP4 @O_TEX5.z, R3, c[$TEXMATRIX5+2];
  2090.                     DP4 @O_TEX5.w, R3, c[$TEXMATRIX5+3];
  2091.                 "
  2092.  
  2093.                 *ifnot_texmatrix5
  2094.                 "
  2095.                     MOV @O_TEX5, R3;
  2096.                 "
  2097.             }
  2098.         }
  2099.     }
  2100.  
  2101.     // ----------------------------------------------------------------
  2102.     *ifnot_texgen6_void
  2103.     {
  2104.         *if_texgen6_texcoord
  2105.         {
  2106.             *if_texmatrix6
  2107.             {
  2108.                 *if_TextureTrans6
  2109.                 " 
  2110.                     MUL R4, $TEXINPUT6, c[$TEXTURETRANS6];
  2111.                     ADD R4, R4, c[$TEXTURETRANS6+1];
  2112.                     DP4 @O_TEX6.x, R4, c[$TEXMATRIX6+0];
  2113.                     DP4 @O_TEX6.y, R4, c[$TEXMATRIX6+1];
  2114.                     DP4 @O_TEX6.z, R4, c[$TEXMATRIX6+2];
  2115.                     DP4 @O_TEX6.w, R4, c[$TEXMATRIX6+3];
  2116.                 "
  2117.                 *ifnot_TextureTrans6
  2118.                 "
  2119.                     DP4 @O_TEX6.x, $TEXINPUT6, c[$TEXMATRIX6+0];
  2120.                     DP4 @O_TEX6.y, $TEXINPUT6, c[$TEXMATRIX6+1];
  2121.                     DP4 @O_TEX6.z, $TEXINPUT6, c[$TEXMATRIX6+2];
  2122.                     DP4 @O_TEX6.w, $TEXINPUT6, c[$TEXMATRIX6+3];
  2123.                 "
  2124.             }
  2125.  
  2126.             *ifnot_texmatrix6
  2127.             {
  2128.                 *if_TextureTrans6
  2129.                 " 
  2130.                     MUL R4, $TEXINPUT6, c[$TEXTURETRANS6];
  2131.                     ADD @O_TEX6, R4, c[$TEXTURETRANS6+1];
  2132.                 "
  2133.                 *ifnot_TextureTrans6
  2134.                 "
  2135.                     MOV @O_TEX6, $TEXINPUT6;
  2136.                 "
  2137.             }
  2138.         }
  2139.  
  2140.         *ifnot_texgen6_texcoord
  2141.         {
  2142.             *if_texgen6_linear
  2143.             "
  2144.                 DP4 R3.x, R8, c[$TEXPARAM6+0];
  2145.                 DP4 R3.y, R8, c[$TEXPARAM6+1];
  2146.                 DP4 R3.z, R8, c[$TEXPARAM6+2];
  2147.                 DP4 R3.w, R8, c[$TEXPARAM6+3];
  2148.             "
  2149.  
  2150.             *if_texgen6_screen
  2151.             "
  2152.                 mul r4, c93, r12.w
  2153.                 mad r3, r12, c92, r4
  2154.             "
  2155.  
  2156.             *if_texgen6_normalmap
  2157.             "
  2158.                 MOV R3, R9;
  2159.             "
  2160.  
  2161.             *if_texgen6_reflection
  2162.             "
  2163.                 DP4 R3.x, R8, c[$BASE+4];
  2164.                 DP4 R3.y, R8, c[$BASE+5];
  2165.                 DP4 R3.z, R8, c[$BASE+6];
  2166.                 MOV R3.w, c[$BASE+8].x;
  2167.                 DP3 R4.x, R9, c[$BASE+4];
  2168.                 DP3 R4.y, R9, c[$BASE+5];
  2169.                 DP3 R4.z, R9, c[$BASE+6];
  2170.                 MOV R4.w, c[$BASE+8].x;
  2171.                 DP3 R3.w, -R3, R4;
  2172.                 ADD R3.w, R3.w, R3.w;
  2173.                 MUL R4, R4, R3.wwww;
  2174.                 ADD R3, R3, R4;
  2175.                 MOV R3.w, c[$BASE+8].x;
  2176.             "
  2177.  
  2178.             *if_texgen6_env
  2179.             {
  2180.                 *if_TextureTrans6
  2181.                 " 
  2182.                     MUL R3, $TEXINPUT6, c[$TEXTURETRANS6];
  2183.                     ADD R3, R3, c[$TEXTURETRANS6+1];
  2184.                 "
  2185.                 *ifnot_TextureTrans3
  2186.                 "
  2187.                     MOV R3, $TEXINPUT6;
  2188.                 "
  2189.                 *Post
  2190.                 "
  2191.                     MOV R3, $TEXINPUT6;
  2192.                     DP3 R3.x, R9, c[$BASE+4];
  2193.                     DP3 R3.y, -R9, c[$BASE+5];
  2194.                     MUL R3, R3, c[$BASE+8].zzzz;
  2195.                     ADD R3, R3, c[$BASE+8].zzzz;
  2196.                 "
  2197.             }
  2198.  
  2199.             *if_texgen6_tslv
  2200.             "
  2201.                 ADD R4, c[$TEXPARAM6+0], -R8;
  2202.                 DP3 R3.x, R9, R4;
  2203.                 DP3 R3.y, R1, R4;
  2204.                 DP3 R3.z, R0, R4;
  2205.                 MUL R3.xyz, R3, c[$TEXPARAM6+0].wwww;
  2206.                 MOV R3.w, c[$BASE+8].x;
  2207.             "
  2208.  
  2209.             *if_texgen6_mspos
  2210.             "
  2211.                 MOV @O_TEX6, R8;
  2212.             "
  2213.             
  2214.             *ifnot_texgen6_mspos
  2215.             {
  2216.                 *if_texmatrix6
  2217.                 "
  2218.                     DP4 @O_TEX6.x, R3, c[$TEXMATRIX6+0];
  2219.                     DP4 @O_TEX6.y, R3, c[$TEXMATRIX6+1];
  2220.                     DP4 @O_TEX6.z, R3, c[$TEXMATRIX6+2];
  2221.                     DP4 @O_TEX6.w, R3, c[$TEXMATRIX6+3];
  2222.                 "
  2223.  
  2224.                 *ifnot_texmatrix6
  2225.                 "
  2226.                     MOV @O_TEX6, R3;
  2227.                 "
  2228.             }
  2229.         }
  2230.     }
  2231.  
  2232.     // ----------------------------------------------------------------
  2233.     *ifnot_texgen7_void
  2234.     {
  2235.         *if_texgen7_texcoord
  2236.         {
  2237.             *if_texmatrix7
  2238.             {
  2239.                 *if_TextureTrans7
  2240.                 " 
  2241.                     MUL R4, $TEXINPUT7, c[$TEXTURETRANS7];
  2242.                     ADD R4, R4, c[$TEXTURETRANS7+1];
  2243.                     DP4 @O_TEX7.x, R4, c[$TEXMATRIX7+0];
  2244.                     DP4 @O_TEX7.y, R4, c[$TEXMATRIX7+1];
  2245.                     DP4 @O_TEX7.z, R4, c[$TEXMATRIX7+2];
  2246.                     DP4 @O_TEX7.w, R4, c[$TEXMATRIX7+3];
  2247.                 "
  2248.                 *ifnot_TextureTrans7
  2249.                 "
  2250.                     DP4 @O_TEX7.x, $TEXINPUT7, c[$TEXMATRIX7+0];
  2251.                     DP4 @O_TEX7.y, $TEXINPUT7, c[$TEXMATRIX7+1];
  2252.                     DP4 @O_TEX7.z, $TEXINPUT7, c[$TEXMATRIX7+2];
  2253.                     DP4 @O_TEX7.w, $TEXINPUT7, c[$TEXMATRIX7+3];
  2254.                 "
  2255.             }
  2256.  
  2257.             *ifnot_texmatrix7
  2258.             {
  2259.                 *if_TextureTrans7
  2260.                 " 
  2261.                     MUL R4, $TEXINPUT7, c[$TEXTURETRANS7];
  2262.                     ADD @O_TEX7, R4, c[$TEXTURETRANS7+1];
  2263.                 "
  2264.                 *ifnot_TextureTrans7
  2265.                 "
  2266.                     MOV @O_TEX7, $TEXINPUT7;
  2267.                 "
  2268.             }
  2269.         }
  2270.  
  2271.         *ifnot_texgen7_texcoord
  2272.         {
  2273.             *if_texgen7_linear
  2274.             "
  2275.                 DP4 R3.x, R8, c[$TEXPARAM7+0];
  2276.                 DP4 R3.y, R8, c[$TEXPARAM7+1];
  2277.                 DP4 R3.z, R8, c[$TEXPARAM7+2];
  2278.                 DP4 R3.w, R8, c[$TEXPARAM7+3];
  2279.             "
  2280.  
  2281.             *if_texgen7_screen
  2282.             "
  2283.                 mul r4, c93, r12.w
  2284.                 mad r3, r12, c92, r4
  2285.             "
  2286.  
  2287.             *if_texgen7_normalmap
  2288.             "
  2289.                 MOV R3, R9;
  2290.             "
  2291.  
  2292.             *if_texgen7_reflection
  2293.             "
  2294.                 DP4 R3.x, R8, c[$BASE+4];
  2295.                 DP4 R3.y, R8, c[$BASE+5];
  2296.                 DP4 R3.z, R8, c[$BASE+6];
  2297.                 MOV R3.w, c[$BASE+8].x;
  2298.                 DP3 R4.x, R9, c[$BASE+4];
  2299.                 DP3 R4.y, R9, c[$BASE+5];
  2300.                 DP3 R4.z, R9, c[$BASE+6];
  2301.                 MOV R4.w, c[$BASE+8].x;
  2302.                 DP3 R3.w, -R3, R4;
  2303.                 ADD R3.w, R3.w, R3.w;
  2304.                 MUL R4, R4, R3.wwww;
  2305.                 ADD R3, R3, R4;
  2306.                 MOV R3.w, c[$BASE+8].x;
  2307.             "
  2308.  
  2309.             *if_texgen7_env
  2310.             {
  2311.                 *if_TextureTrans7
  2312.                 " 
  2313.                     MUL R3, $TEXINPUT7, c[$TEXTURETRANS7];
  2314.                     ADD R3, R3, c[$TEXTURETRANS7+1];
  2315.                 "
  2316.                 *ifnot_TextureTrans3
  2317.                 "
  2318.                     MOV R3, $TEXINPUT7;
  2319.                 "
  2320.                 *Post
  2321.                 "
  2322.                     MOV R3, $TEXINPUT7;
  2323.                     DP3 R3.x, R9, c[$BASE+4];
  2324.                     DP3 R3.y, -R9, c[$BASE+5];
  2325.                     MUL R3, R3, c[$BASE+8].zzzz;
  2326.                     ADD R3, R3, c[$BASE+8].zzzz;
  2327.                 "
  2328.             }
  2329.  
  2330.             *if_texgen7_tslv
  2331.             "
  2332.                 ADD R4, c[$TEXPARAM7+0], -R8;
  2333.                 DP3 R3.x, R9, R4;
  2334.                 DP3 R3.y, R1, R4;
  2335.                 DP3 R3.z, R0, R4;
  2336.                 MUL R3.xyz, R3, c[$TEXPARAM7+0].wwww;
  2337.                 MOV R3.w, c[$BASE+8].x;
  2338.             "
  2339.  
  2340.             *if_texgen7_tsev
  2341.             "
  2342.                 ADD R4, -R8, c[$BASE+7];
  2343.                 DP3 R3.x, R0, R4;
  2344.                 DP3 R3.y, R1, R4;
  2345.                 DP3 R3.z, R9, R4;
  2346.                 MOV R3.w, c[$BASE+8].x;
  2347.             "
  2348.  
  2349.             *if_texgen7_mspos
  2350.             "
  2351.                 MOV @O_TEX7, R8;
  2352.             "
  2353.             
  2354.             *ifnot_texgen7_mspos
  2355.             {
  2356.                 *if_texmatrix7
  2357.                 "
  2358.                     DP4 @O_TEX7.x, R3, c[$TEXMATRIX7+0];
  2359.                     DP4 @O_TEX7.y, R3, c[$TEXMATRIX7+1];
  2360.                     DP4 @O_TEX7.z, R3, c[$TEXMATRIX7+2];
  2361.                     DP4 @O_TEX7.w, R3, c[$TEXMATRIX7+3];
  2362.                 "
  2363.  
  2364.                 *ifnot_texmatrix7
  2365.                 "
  2366.                     MOV @O_TEX7, R3;
  2367.                 "
  2368.             }
  2369.         }
  2370.     }
  2371.     *end
  2372.     "
  2373.     @END
  2374.     "
  2375. }
  2376.  
  2377.  
  2378.