import jaggl.OpenGL;

public class Class8_Sub3 extends Class8 {

   Class147_Sub4_Sub1 aClass147_Sub4_Sub1_9600;
   boolean aBool9601;
   Class149 aClass149_9602;
   Class545_Sub1 aClass545_Sub1_9603;


   void method629(char var1, int var2, int var3, int var4, boolean var5, Class496 var6, int var7, int var8) {
      Class496_Sub3 var9 = (Class496_Sub3)var6;
      Class147_Sub4_Sub1 var10 = var9.aClass147_Sub4_Sub1_9955;
      this.aClass545_Sub1_9603.method14588();
      this.aClass545_Sub1_9603.method14725(this.aClass147_Sub4_Sub1_9600);
      if(!this.aBool9601 && !var5) {
         this.aClass545_Sub1_9603.method14553(7681, 7681);
      } else {
         this.aClass545_Sub1_9603.method14553(7681, 8448);
         this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      }

      this.aClass545_Sub1_9603.method14641(1);
      this.aClass545_Sub1_9603.method14725(var10);
      this.aClass545_Sub1_9603.method14553(7681, 8448);
      this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      OpenGL.glTexGeni(8192, 9472, 9216);
      OpenGL.glTexGeni(8193, 9472, 9216);
      float var11 = var10.aFloat10363 / (float)var10.anInt10364;
      float var12 = var10.aFloat10366 / (float)var10.anInt10365;
      OpenGL.glTexGenfv(8192, 9474, new float[]{var11, 0.0F, 0.0F, (float)(-var7) * var11}, 0);
      OpenGL.glTexGenfv(8193, 9474, new float[]{0.0F, var12, 0.0F, (float)(-var8) * var12}, 0);
      OpenGL.glEnable(3168);
      OpenGL.glEnable(3169);
      OpenGL.glColor4ub((byte)(var4 >> 16), (byte)(var4 >> 8), (byte)var4, (byte)(var4 >> 24));
      OpenGL.glTranslatef((float)var2, (float)var3, 0.0F);
      this.aClass149_9602.method2737(var1);
      OpenGL.glLoadIdentity();
      OpenGL.glDisable(3168);
      OpenGL.glDisable(3169);
      this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      this.aClass545_Sub1_9603.method14553(8448, 8448);
      this.aClass545_Sub1_9603.method14725((Class147)null);
      this.aClass545_Sub1_9603.method14641(0);
      if(this.aBool9601 || var5) {
         this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      }

   }

   void method620(char var1, int var2, int var3, int var4, boolean var5, Class496 var6, int var7, int var8) {
      Class496_Sub3 var9 = (Class496_Sub3)var6;
      Class147_Sub4_Sub1 var10 = var9.aClass147_Sub4_Sub1_9955;
      this.aClass545_Sub1_9603.method14588();
      this.aClass545_Sub1_9603.method14725(this.aClass147_Sub4_Sub1_9600);
      if(!this.aBool9601 && !var5) {
         this.aClass545_Sub1_9603.method14553(7681, 7681);
      } else {
         this.aClass545_Sub1_9603.method14553(7681, 8448);
         this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      }

      this.aClass545_Sub1_9603.method14641(1);
      this.aClass545_Sub1_9603.method14725(var10);
      this.aClass545_Sub1_9603.method14553(7681, 8448);
      this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      OpenGL.glTexGeni(8192, 9472, 9216);
      OpenGL.glTexGeni(8193, 9472, 9216);
      float var11 = var10.aFloat10363 / (float)var10.anInt10364;
      float var12 = var10.aFloat10366 / (float)var10.anInt10365;
      OpenGL.glTexGenfv(8192, 9474, new float[]{var11, 0.0F, 0.0F, (float)(-var7) * var11}, 0);
      OpenGL.glTexGenfv(8193, 9474, new float[]{0.0F, var12, 0.0F, (float)(-var8) * var12}, 0);
      OpenGL.glEnable(3168);
      OpenGL.glEnable(3169);
      OpenGL.glColor4ub((byte)(var4 >> 16), (byte)(var4 >> 8), (byte)var4, (byte)(var4 >> 24));
      OpenGL.glTranslatef((float)var2, (float)var3, 0.0F);
      this.aClass149_9602.method2737(var1);
      OpenGL.glLoadIdentity();
      OpenGL.glDisable(3168);
      OpenGL.glDisable(3169);
      this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      this.aClass545_Sub1_9603.method14553(8448, 8448);
      this.aClass545_Sub1_9603.method14725((Class147)null);
      this.aClass545_Sub1_9603.method14641(0);
      if(this.aBool9601 || var5) {
         this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      }

   }

   void w(char var1, int var2, int var3, int var4, boolean var5) {
      this.aClass545_Sub1_9603.method14588();
      this.aClass545_Sub1_9603.method14725(this.aClass147_Sub4_Sub1_9600);
      if(!this.aBool9601 && !var5) {
         this.aClass545_Sub1_9603.method14553(7681, 7681);
      } else {
         this.aClass545_Sub1_9603.method14553(7681, 8448);
         this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      }

      OpenGL.glColor4ub((byte)(var4 >> 16), (byte)(var4 >> 8), (byte)var4, (byte)(var4 >> 24));
      OpenGL.glTranslatef((float)var2, (float)var3, 0.0F);
      this.aClass149_9602.method2737(var1);
      OpenGL.glLoadIdentity();
      if(this.aBool9601 || var5) {
         this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      }

   }

   Class8_Sub3(Class545_Sub1 var1, Class405 var2, Class86_Sub1[] var3, boolean var4) {
      super(var1, var2);
      this.aClass545_Sub1_9603 = var1;
      int var5 = 0;

      int var6;
      for(var6 = 0; var6 < 256; ++var6) {
         Class86_Sub1 var7 = var3[var6];
         if(var7.anInt9470 > var5) {
            var5 = var7.anInt9470;
         }

         if(var7.anInt9468 > var5) {
            var5 = var7.anInt9468;
         }
      }

      var6 = var5 * 16;
      int var8;
      Class86_Sub1 var9;
      int var11;
      int var12;
      int var13;
      int var14;
      int var15;
      int var17;
      int var18;
      if(var4) {
         byte[] var22 = new byte[var6 * var6];

         for(var8 = 0; var8 < 256; ++var8) {
            var9 = var3[var8];
            int var10 = var9.anInt9470;
            var11 = var9.anInt9468;
            var12 = var8 % 16 * var5;
            var13 = var8 / 16 * var5;
            var14 = var13 * var6 + var12;
            var15 = 0;
            byte[] var16;
            if(var9.aByteArray9473 == null) {
               var16 = var9.aByteArray9472;

               for(var17 = 0; var17 < var10; ++var17) {
                  for(var18 = 0; var18 < var11; ++var18) {
                     var22[var14++] = (byte)(var16[var15++] == 0?0:-1);
                  }

                  var14 += var6 - var11;
               }
            } else {
               var16 = var9.aByteArray9473;

               for(var17 = 0; var17 < var10; ++var17) {
                  for(var18 = 0; var18 < var11; ++var18) {
                     var22[var14++] = var16[var15++];
                  }

                  var14 += var6 - var11;
               }
            }
         }

         this.aClass147_Sub4_Sub1_9600 = Class147_Sub4_Sub1.method15946(var1, Class98.aClass98_987, Class91.aClass91_897, var6, var6, false, var22, Class98.aClass98_987);
         this.aBool9601 = true;
      } else {
         int[] var24 = new int[var6 * var6];

         for(var8 = 0; var8 < 256; ++var8) {
            var9 = var3[var8];
            int[] var28 = var9.anIntArray9466;
            byte[] var27 = var9.aByteArray9473;
            byte[] var30 = var9.aByteArray9472;
            var13 = var9.anInt9470;
            var14 = var9.anInt9468;
            var15 = var8 % 16 * var5;
            int var31 = var8 / 16 * var5;
            var17 = var31 * var6 + var15;
            var18 = 0;
            int var19;
            int var20;
            if(var27 != null) {
               for(var19 = 0; var19 < var13; ++var19) {
                  for(var20 = 0; var20 < var14; ++var20) {
                     var24[var17++] = var27[var18] << 24 | var28[var30[var18] & 255];
                     ++var18;
                  }

                  var17 += var6 - var14;
               }
            } else {
               for(var19 = 0; var19 < var13; ++var19) {
                  for(var20 = 0; var20 < var14; ++var20) {
                     byte var21;
                     if((var21 = var30[var18++]) != 0) {
                        var24[var17++] = -16777216 | var28[var21 & 255];
                     } else {
                        ++var17;
                     }
                  }

                  var17 += var6 - var14;
               }
            }
         }

         this.aClass147_Sub4_Sub1_9600 = Class147_Sub4_Sub1.method15945(var1, var6, var6, false, var24, 0, 0);
         this.aBool9601 = false;
      }

      this.aClass147_Sub4_Sub1_9600.method2694(false);
      this.aClass149_9602 = new Class149(var1, 256);
      float var23 = this.aClass147_Sub4_Sub1_9600.aFloat10363 / (float)this.aClass147_Sub4_Sub1_9600.anInt10364;
      float var25 = this.aClass147_Sub4_Sub1_9600.aFloat10366 / (float)this.aClass147_Sub4_Sub1_9600.anInt10365;

      for(int var26 = 0; var26 < 256; ++var26) {
         Class86_Sub1 var29 = var3[var26];
         var11 = var29.anInt9470;
         var12 = var29.anInt9468;
         var13 = var29.anInt9469;
         var14 = var29.anInt9467;
         float var32 = (float)(var26 % 16 * var5);
         float var33 = (float)(var26 / 16 * var5);
         float var36 = var32 * var23;
         float var35 = var33 * var25;
         float var34 = (var32 + (float)var12) * var23;
         float var37 = (var33 + (float)var11) * var25;
         this.aClass149_9602.method2735(var26);
         OpenGL.glBegin(7);
         OpenGL.glTexCoord2f(var36, this.aClass147_Sub4_Sub1_9600.aFloat10366 - var35);
         OpenGL.glVertex2i(var14, var13);
         OpenGL.glTexCoord2f(var36, this.aClass147_Sub4_Sub1_9600.aFloat10366 - var37);
         OpenGL.glVertex2i(var14, var13 + var11);
         OpenGL.glTexCoord2f(var34, this.aClass147_Sub4_Sub1_9600.aFloat10366 - var37);
         OpenGL.glVertex2i(var14 + var12, var13 + var11);
         OpenGL.glTexCoord2f(var34, this.aClass147_Sub4_Sub1_9600.aFloat10366 - var35);
         OpenGL.glVertex2i(var14 + var12, var13);
         OpenGL.glEnd();
         this.aClass149_9602.method2736();
      }

   }

   void k(char var1, int var2, int var3, int var4, boolean var5) {
      this.aClass545_Sub1_9603.method14588();
      this.aClass545_Sub1_9603.method14725(this.aClass147_Sub4_Sub1_9600);
      if(!this.aBool9601 && !var5) {
         this.aClass545_Sub1_9603.method14553(7681, 7681);
      } else {
         this.aClass545_Sub1_9603.method14553(7681, 8448);
         this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      }

      OpenGL.glColor4ub((byte)(var4 >> 16), (byte)(var4 >> 8), (byte)var4, (byte)(var4 >> 24));
      OpenGL.glTranslatef((float)var2, (float)var3, 0.0F);
      this.aClass149_9602.method2737(var1);
      OpenGL.glLoadIdentity();
      if(this.aBool9601 || var5) {
         this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      }

   }

   void UA(char var1, int var2, int var3, int var4, boolean var5) {
      this.aClass545_Sub1_9603.method14588();
      this.aClass545_Sub1_9603.method14725(this.aClass147_Sub4_Sub1_9600);
      if(!this.aBool9601 && !var5) {
         this.aClass545_Sub1_9603.method14553(7681, 7681);
      } else {
         this.aClass545_Sub1_9603.method14553(7681, 8448);
         this.aClass545_Sub1_9603.method14679(0, '\u8578', 768);
      }

      OpenGL.glColor4ub((byte)(var4 >> 16), (byte)(var4 >> 8), (byte)var4, (byte)(var4 >> 24));
      OpenGL.glTranslatef((float)var2, (float)var3, 0.0F);
      this.aClass149_9602.method2737(var1);
      OpenGL.glLoadIdentity();
      if(this.aBool9601 || var5) {
         this.aClass545_Sub1_9603.method14679(0, 5890, 768);
      }

   }
}
