import jaggl.OpenGL;

public class Class141_Sub2 extends Class141 {

   static final char aChar9824 = '\u0000';
   static float[] aFloatArray9825 = new float[4];
   Class135 aClass135_9826;
   Class149 aClass149_9827;
   int anInt9828;
   float[] aFloatArray9829;
   static final String aString9830 = "!!ARBvp1.0\nOPTION  ARB_position_invariant;\nATTRIB  iPos         = vertex.position;\nATTRIB  iColour      = vertex.color;\nATTRIB  iTexCoord    = vertex.texcoord[0];\nOUTPUT  oColour      = result.color;\nOUTPUT  oTexCoord0   = result.texcoord[0];\nOUTPUT  oTexCoord1   = result.texcoord[1];\nOUTPUT  oFogCoord    = result.fogcoord;\nPARAM   time         = program.local[65];\nPARAM   turbulence   = program.local[64];\nPARAM   lightAmbient = program.local[66]; \nPARAM   pMatrix[4]   = { state.matrix.projection };\nPARAM   mvMatrix[4]  = { state.matrix.modelview };\nPARAM   ivMatrix[4]  = { state.matrix.texture[1] };\nPARAM   texMatrix[4]  = { state.matrix.texture[0] };\nPARAM   fNoise[64]   = { program.local[0..63] };\nTEMP    noise, viewPos, worldPos, texCoord;\nADDRESS noiseAddr;\nDP4   viewPos.x, mvMatrix[0], iPos;\nDP4   viewPos.y, mvMatrix[1], iPos;\nDP4   viewPos.z, mvMatrix[2], iPos;\nDP4   viewPos.w, mvMatrix[3], iPos;\nMOV   oFogCoord.x, viewPos.z;\nDP4   worldPos.x, ivMatrix[0], viewPos;\nDP4   worldPos.y, ivMatrix[1], viewPos;\nDP4   worldPos.z, ivMatrix[2], viewPos;\nDP4   worldPos.w, ivMatrix[3], viewPos;\nADD   noise.x, worldPos.x, worldPos.z;SUB   noise.y, worldPos.z, worldPos.x;MUL   noise, noise, 0.0001220703125;\nFRC   noise, noise;\nMUL   noise, noise, 64;\nARL   noiseAddr.x, noise.x;\nMOV   noise.x, fNoise[noiseAddr.x].x;\nARL   noiseAddr.x, noise.y;\nMOV   noise.y, fNoise[noiseAddr.x].y;\nMUL   noise, noise, turbulence.x;\nDP4   texCoord.x, texMatrix[0], iTexCoord;\nDP4   texCoord.y, texMatrix[1], iTexCoord;\nADD   oTexCoord0.xy, texCoord, noise;\nMOV   oTexCoord0.z, 0;\nMOV   oTexCoord0.w, 1;\nMUL   oTexCoord1.xy, texCoord, 0.125;\nMOV   oTexCoord1.zw, time.xxxw;\nMUL   oColour.xyz, iColour, lightAmbient;\nMOV   oColour.w, iColour.w;\nEND";
   Class132 aClass132_9831;
   static final char aChar9832 = '\u0001';
   float aFloat9833;


   void method2639(int var1, int var2) {
      if(this.aClass149_9827 != null) {
         this.aClass545_Sub1_1628.method14641(1);
         int var3;
         if((var1 & 128) == 0) {
            if((var2 & 1) == 1) {
               if(!this.aClass135_9826.aBool1583) {
                  var3 = this.aClass545_Sub1_1628.anInt9158 % 4000 * 16 / 4000;
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[var3]);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, this.aFloat9833, 0.0F, 0.0F, 1.0F);
               }
            } else {
               if(this.aClass135_9826.aBool1583) {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[0]);
               }

               OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
            }
         } else {
            this.aClass545_Sub1_1628.method14725((Class147)null);
         }

         this.aClass545_Sub1_1628.method14641(0);
         if((var1 & 64) == 0) {
            aFloatArray9825[0] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9130;
            aFloatArray9825[1] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9123;
            aFloatArray9825[2] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9225;
            OpenGL.glProgramLocalParameter4fvARB('\u8620', 66, aFloatArray9825, 0);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 66, 1.0F, 1.0F, 1.0F, 1.0F);
         }

         var3 = var1 & 3;
         if(var3 == 2) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.05F, 1.0F, 1.0F, 1.0F);
         } else if(var3 == 3) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.1F, 1.0F, 1.0F, 1.0F);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.025F, 1.0F, 1.0F, 1.0F);
         }

      }
   }

   boolean method2633() {
      return true;
   }

   void method15398() {
      this.aClass149_9827 = new Class149(this.aClass545_Sub1_1628, 2);
      this.aClass149_9827.method2735(0);
      this.aClass545_Sub1_1628.method14641(1);
      this.aClass545_Sub1_1628.method14603(-16777216);
      this.aClass545_Sub1_1628.method14553(260, 7681);
      this.aClass545_Sub1_1628.method14630(0, '\u8576', 770);
      this.aClass545_Sub1_1628.method14641(0);
      OpenGL.glBindProgramARB('\u8620', this.aClass132_9831.anInt1567);
      OpenGL.glEnable('\u8620');
      this.aClass149_9827.method2736();
      this.aClass149_9827.method2735(1);
      this.aClass545_Sub1_1628.method14641(1);
      OpenGL.glMatrixMode(5890);
      OpenGL.glLoadIdentity();
      OpenGL.glMatrixMode(5888);
      this.aClass545_Sub1_1628.method14591(0);
      this.aClass545_Sub1_1628.method14630(0, 5890, 770);
      this.aClass545_Sub1_1628.method14641(0);
      OpenGL.glBindProgramARB('\u8620', 0);
      OpenGL.glDisable('\u8620');
      OpenGL.glDisable('\u8804');
      this.aClass149_9827.method2736();
   }

   void method2624(boolean var1) {}

   boolean method2626() {
      return true;
   }

   void method2635(Class147 var1, int var2) {
      this.aClass545_Sub1_1628.method14725(var1);
      this.aClass545_Sub1_1628.method14591(var2);
   }

   void method2627(int var1, int var2) {
      if(this.aClass149_9827 != null) {
         this.aClass545_Sub1_1628.method14641(1);
         int var3;
         if((var1 & 128) == 0) {
            if((var2 & 1) == 1) {
               if(!this.aClass135_9826.aBool1583) {
                  var3 = this.aClass545_Sub1_1628.anInt9158 % 4000 * 16 / 4000;
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[var3]);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, this.aFloat9833, 0.0F, 0.0F, 1.0F);
               }
            } else {
               if(this.aClass135_9826.aBool1583) {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[0]);
               }

               OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
            }
         } else {
            this.aClass545_Sub1_1628.method14725((Class147)null);
         }

         this.aClass545_Sub1_1628.method14641(0);
         if((var1 & 64) == 0) {
            aFloatArray9825[0] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9130;
            aFloatArray9825[1] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9123;
            aFloatArray9825[2] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9225;
            OpenGL.glProgramLocalParameter4fvARB('\u8620', 66, aFloatArray9825, 0);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 66, 1.0F, 1.0F, 1.0F, 1.0F);
         }

         var3 = var1 & 3;
         if(var3 == 2) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.05F, 1.0F, 1.0F, 1.0F);
         } else if(var3 == 3) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.1F, 1.0F, 1.0F, 1.0F);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.025F, 1.0F, 1.0F, 1.0F);
         }

      }
   }

   Class141_Sub2(Class545_Sub1 var1, Class135 var2) {
      super(var1);
      this.aClass135_9826 = var2;
      if(this.aClass545_Sub1_1628.aBool9279 && this.aClass545_Sub1_1628.anInt9194 >= 2) {
         this.aClass132_9831 = Class132.method2496(this.aClass545_Sub1_1628, '\u8620', "!!ARBvp1.0\nOPTION  ARB_position_invariant;\nATTRIB  iPos         = vertex.position;\nATTRIB  iColour      = vertex.color;\nATTRIB  iTexCoord    = vertex.texcoord[0];\nOUTPUT  oColour      = result.color;\nOUTPUT  oTexCoord0   = result.texcoord[0];\nOUTPUT  oTexCoord1   = result.texcoord[1];\nOUTPUT  oFogCoord    = result.fogcoord;\nPARAM   time         = program.local[65];\nPARAM   turbulence   = program.local[64];\nPARAM   lightAmbient = program.local[66]; \nPARAM   pMatrix[4]   = { state.matrix.projection };\nPARAM   mvMatrix[4]  = { state.matrix.modelview };\nPARAM   ivMatrix[4]  = { state.matrix.texture[1] };\nPARAM   texMatrix[4]  = { state.matrix.texture[0] };\nPARAM   fNoise[64]   = { program.local[0..63] };\nTEMP    noise, viewPos, worldPos, texCoord;\nADDRESS noiseAddr;\nDP4   viewPos.x, mvMatrix[0], iPos;\nDP4   viewPos.y, mvMatrix[1], iPos;\nDP4   viewPos.z, mvMatrix[2], iPos;\nDP4   viewPos.w, mvMatrix[3], iPos;\nMOV   oFogCoord.x, viewPos.z;\nDP4   worldPos.x, ivMatrix[0], viewPos;\nDP4   worldPos.y, ivMatrix[1], viewPos;\nDP4   worldPos.z, ivMatrix[2], viewPos;\nDP4   worldPos.w, ivMatrix[3], viewPos;\nADD   noise.x, worldPos.x, worldPos.z;SUB   noise.y, worldPos.z, worldPos.x;MUL   noise, noise, 0.0001220703125;\nFRC   noise, noise;\nMUL   noise, noise, 64;\nARL   noiseAddr.x, noise.x;\nMOV   noise.x, fNoise[noiseAddr.x].x;\nARL   noiseAddr.x, noise.y;\nMOV   noise.y, fNoise[noiseAddr.x].y;\nMUL   noise, noise, turbulence.x;\nDP4   texCoord.x, texMatrix[0], iTexCoord;\nDP4   texCoord.y, texMatrix[1], iTexCoord;\nADD   oTexCoord0.xy, texCoord, noise;\nMOV   oTexCoord0.z, 0;\nMOV   oTexCoord0.w, 1;\nMUL   oTexCoord1.xy, texCoord, 0.125;\nMOV   oTexCoord1.zw, time.xxxw;\nMUL   oColour.xyz, iColour, lightAmbient;\nMOV   oColour.w, iColour.w;\nEND");
         if(this.aClass132_9831 == null) {
            return;
         }

         int[][] var3 = Class118_Sub9.method13193(64, 256, 0, 4, 4, 3, 0.4F, false, (byte)-93);
         int[][] var4 = Class118_Sub9.method13193(64, 256, 8, 4, 4, 3, 0.4F, false, (byte)-25);
         int var5 = 0;
         this.aFloatArray9829 = new float['\u8000'];

         for(int var6 = 0; var6 < 256; ++var6) {
            int[] var7 = var3[var6];
            int[] var8 = var4[var6];

            for(int var9 = 0; var9 < 64; ++var9) {
               this.aFloatArray9829[var5++] = (float)var7[var9] / 4096.0F;
               this.aFloatArray9829[var5++] = (float)var8[var9] / 4096.0F;
            }
         }

         this.method15398();
      }

   }

   boolean method2629() {
      return true;
   }

   void method2628(Class147 var1, int var2) {
      this.aClass545_Sub1_1628.method14725(var1);
      this.aClass545_Sub1_1628.method14591(var2);
   }

   void method2631(boolean var1) {
      if(this.aClass149_9827 != null) {
         this.aClass149_9827.method2737('\u0000');
         this.aClass545_Sub1_1628.method14641(1);
         OpenGL.glMatrixMode(5890);
         OpenGL.glLoadMatrixf(this.aClass545_Sub1_1628.aClass317_9286.aFloatArray4000, 0);
         OpenGL.glMatrixMode(5888);
         this.aClass545_Sub1_1628.method14641(0);
         if(this.anInt9828 != this.aClass545_Sub1_1628.anInt9158) {
            int var2 = this.aClass545_Sub1_1628.anInt9158 % 5000 * 128 / 5000;

            for(int var3 = 0; var3 < 64; ++var3) {
               OpenGL.glProgramLocalParameter4fvARB('\u8620', var3, this.aFloatArray9829, var2);
               var2 += 2;
            }

            if(this.aClass135_9826.aBool1583) {
               this.aFloat9833 = (float)(this.aClass545_Sub1_1628.anInt9158 % 4000) / 4000.0F;
            } else {
               OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
            }

            this.anInt9828 = this.aClass545_Sub1_1628.anInt9158;
         }

      }
   }

   void method2632() {
      if(this.aClass149_9827 != null) {
         this.aClass149_9827.method2737('\u0001');
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
      }
   }

   void method2636(boolean var1) {}

   void method2634(int var1, int var2) {
      if(this.aClass149_9827 != null) {
         this.aClass545_Sub1_1628.method14641(1);
         int var3;
         if((var1 & 128) == 0) {
            if((var2 & 1) == 1) {
               if(!this.aClass135_9826.aBool1583) {
                  var3 = this.aClass545_Sub1_1628.anInt9158 % 4000 * 16 / 4000;
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[var3]);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
                  OpenGL.glProgramLocalParameter4fARB('\u8620', 65, this.aFloat9833, 0.0F, 0.0F, 1.0F);
               }
            } else {
               if(this.aClass135_9826.aBool1583) {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub2_1579);
               } else {
                  this.aClass545_Sub1_1628.method14725(this.aClass135_9826.aClass147_Sub4Array1584[0]);
               }

               OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
            }
         } else {
            this.aClass545_Sub1_1628.method14725((Class147)null);
         }

         this.aClass545_Sub1_1628.method14641(0);
         if((var1 & 64) == 0) {
            aFloatArray9825[0] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9130;
            aFloatArray9825[1] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9123;
            aFloatArray9825[2] = this.aClass545_Sub1_1628.aFloat9168 * this.aClass545_Sub1_1628.aFloat9225;
            OpenGL.glProgramLocalParameter4fvARB('\u8620', 66, aFloatArray9825, 0);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 66, 1.0F, 1.0F, 1.0F, 1.0F);
         }

         var3 = var1 & 3;
         if(var3 == 2) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.05F, 1.0F, 1.0F, 1.0F);
         } else if(var3 == 3) {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.1F, 1.0F, 1.0F, 1.0F);
         } else {
            OpenGL.glProgramLocalParameter4fARB('\u8620', 64, 0.025F, 1.0F, 1.0F, 1.0F);
         }

      }
   }

   void method2630() {
      if(this.aClass149_9827 != null) {
         this.aClass149_9827.method2737('\u0001');
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
      }
   }

   void method2625(boolean var1) {
      if(this.aClass149_9827 != null) {
         this.aClass149_9827.method2737('\u0000');
         this.aClass545_Sub1_1628.method14641(1);
         OpenGL.glMatrixMode(5890);
         OpenGL.glLoadMatrixf(this.aClass545_Sub1_1628.aClass317_9286.aFloatArray4000, 0);
         OpenGL.glMatrixMode(5888);
         this.aClass545_Sub1_1628.method14641(0);
         if(this.anInt9828 != this.aClass545_Sub1_1628.anInt9158) {
            int var2 = this.aClass545_Sub1_1628.anInt9158 % 5000 * 128 / 5000;

            for(int var3 = 0; var3 < 64; ++var3) {
               OpenGL.glProgramLocalParameter4fvARB('\u8620', var3, this.aFloatArray9829, var2);
               var2 += 2;
            }

            if(this.aClass135_9826.aBool1583) {
               this.aFloat9833 = (float)(this.aClass545_Sub1_1628.anInt9158 % 4000) / 4000.0F;
            } else {
               OpenGL.glProgramLocalParameter4fARB('\u8620', 65, 0.0F, 0.0F, 0.0F, 1.0F);
            }

            this.anInt9828 = this.aClass545_Sub1_1628.anInt9158;
         }

      }
   }

   void method2637(boolean var1) {}

   void method2638(boolean var1) {}

   void method2623() {
      if(this.aClass149_9827 != null) {
         this.aClass149_9827.method2737('\u0001');
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
      }
   }
}
