import jaclib.memory.Stream;
import jaclib.memory.heap.NativeHeapBuffer;
import jaggl.OpenGL;

public class Class225_Sub52 extends Class225 {

   int[] anIntArray8966;
   NativeHeapBuffer aNativeHeapBuffer8967;
   int anInt8968;
   float aFloat8969;
   Class153 aClass153_8970;
   Class150 aClass150_8971;
   Class162_Sub2 aClass162_Sub2_8972;
   Class400_Sub3 aClass400_Sub3_8973;
   Class545_Sub1 aClass545_Sub1_8974;
   Stream aStream8975;


   void method14363(int var1, int var2, int var3) {
      this.anIntArray8966[var2 * this.aClass400_Sub3_8973.anInt4911 * 1724373523 + var1] |= 1 << var3;
   }

   void method14364(int var1) {
      this.aStream8975.method3017(var1 * 4 + 3);
      this.aStream8975.method3018(-1);
   }

   void method14365(int var1) {
      this.aNativeHeapBuffer8967 = this.aClass545_Sub1_8974.aNativeHeap9162.method825(var1 * 4, true);
      this.aStream8975 = new Stream(this.aNativeHeapBuffer8967);
   }

   void method14366(int var1, int var2, int var3) {
      this.anIntArray8966[var2 * this.aClass400_Sub3_8973.anInt4911 * 1724373523 + var1] |= 1 << var3;
   }

   void method14367(int var1, int var2, int var3, float var4) {
      int var6;
      int var7;
      if(this.anInt8968 != -1) {
         Class161 var5 = this.aClass545_Sub1_8974.anInterface24_7370.method113(this.anInt8968, -459189549);
         var6 = var5.aByte1990 & 255;
         int var9;
         if(var6 != 0 && var5.aByte1986 != 4) {
            if(var3 < 0) {
               var7 = 0;
            } else if(var3 > 127) {
               var7 = 16777215;
            } else {
               var7 = 131586 * var3;
            }

            if(var6 == 256) {
               var2 = var7;
            } else {
               var9 = 256 - var6;
               var2 = ((var7 & 16711935) * var6 + (var2 & 16711935) * var9 & -16711936) + ((var7 & '\uff00') * var6 + (var2 & '\uff00') * var9 & 16711680) >> 8;
            }
         }

         var7 = var5.aByte1991 & 255;
         if(var7 != 0) {
            var7 += 256;
            int var8 = ((var2 & 16711680) >> 16) * var7;
            if(var8 > '\uffff') {
               var8 = '\uffff';
            }

            var9 = ((var2 & '\uff00') >> 8) * var7;
            if(var9 > '\uffff') {
               var9 = '\uffff';
            }

            int var10 = (var2 & 255) * var7;
            if(var10 > '\uffff') {
               var10 = '\uffff';
            }

            var2 = (var8 << 8 & 16711680) + (var9 & '\uff00') + (var10 >> 8);
         }
      }

      if(var4 != 1.0F) {
         int var11 = var2 >> 16 & 255;
         var6 = var2 >> 8 & 255;
         var7 = var2 & 255;
         var11 = (int)((float)var11 * var4);
         if(var11 < 0) {
            var11 = 0;
         } else if(var11 > 255) {
            var11 = 255;
         }

         var6 = (int)((float)var6 * var4);
         if(var6 < 0) {
            var6 = 0;
         } else if(var6 > 255) {
            var6 = 255;
         }

         var7 = (int)((float)var7 * var4);
         if(var7 < 0) {
            var7 = 0;
         } else if(var7 > 255) {
            var7 = 255;
         }

         var2 = var11 << 16 | var6 << 8 | var7;
      }

      this.aStream8975.method3017(var1 * 4);
      this.aStream8975.method3018((byte)(var2 >> 16));
      this.aStream8975.method3018((byte)(var2 >> 8));
      this.aStream8975.method3018((byte)var2);
   }

   void method14368(int var1) {
      this.aStream8975.method3021();
      Interface10 var2 = this.aClass545_Sub1_8974.method14583(4, this.aNativeHeapBuffer8967, var1 * 4, false);
      if(var2 instanceof Class145_Sub1) {
         this.aNativeHeapBuffer8967.method1290();
      }

      this.aClass150_8971 = new Class150(var2, 5121, 4, 0);
      this.aNativeHeapBuffer8967 = null;
      this.aStream8975 = null;
   }

   void method14369(int var1) {
      this.aStream8975.method3017(var1 * 4 + 3);
      this.aStream8975.method3018(-1);
   }

   void method14370(int var1) {
      this.aNativeHeapBuffer8967 = this.aClass545_Sub1_8974.aNativeHeap9162.method825(var1 * 4, true);
      this.aStream8975 = new Stream(this.aNativeHeapBuffer8967);
   }

   void method14371(int var1) {
      this.aNativeHeapBuffer8967 = this.aClass545_Sub1_8974.aNativeHeap9162.method825(var1 * 4, true);
      this.aStream8975 = new Stream(this.aNativeHeapBuffer8967);
   }

   Class225_Sub52(Class400_Sub3 var1, int var2, int var3, Class153 var4) {
      this.aClass400_Sub3_8973 = var1;
      this.aClass545_Sub1_8974 = this.aClass400_Sub3_8973.aClass545_Sub1_9558;
      this.anInt8968 = var2;
      this.aFloat8969 = (float)var3;
      this.aClass153_8970 = var4;
      this.anIntArray8966 = new int[this.aClass400_Sub3_8973.anInt4911 * 1724373523 * this.aClass400_Sub3_8973.anInt4908 * 1696648095];
      this.aClass162_Sub2_8972 = new Class162_Sub2(this.aClass545_Sub1_8974, 5123, (byte[])null, 1);
   }

   void method14372(int var1) {
      this.aStream8975.method3017(var1 * 4 + 3);
      this.aStream8975.method3018(-1);
   }

   void method14373(int[] var1, int var2) {
      int var3 = 0;
      Class225_Sub23_Sub2 var4 = this.aClass545_Sub1_8974.aClass225_Sub23_Sub2_9294;
      var4.position = 0;
      int var5;
      int var6;
      short[] var7;
      int var8;
      int var9;
      int var10;
      if(this.aClass545_Sub1_8974.aBool9257) {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.writeShort(var7[var10++] & '\uffff', 872928464);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', -1334558492);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', -209185702);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      } else {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      }

      if(var3 > 0) {
         this.aClass162_Sub2_8972.method74(5123, var4.buffer, var4.position * -543666943);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14590(this.anInt8968, (this.aClass400_Sub3_8973.anInt9563 & 7) != 0, (this.aClass400_Sub3_8973.anInt9563 & 8) != 0);
         if(this.aClass545_Sub1_8974.aBool9242) {
            this.aClass545_Sub1_8974.method11496(Integer.MAX_VALUE, this.aClass153_8970);
         }

         OpenGL.glMatrixMode(5890);
         OpenGL.glPushMatrix();
         OpenGL.glScalef(1.0F / this.aFloat8969, 1.0F / this.aFloat8969, 1.0F);
         OpenGL.glMatrixMode(5888);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14610(this.aClass162_Sub2_8972, 4, 0, var3);
         OpenGL.glMatrixMode(5890);
         OpenGL.glPopMatrix();
         OpenGL.glMatrixMode(5888);
      }

   }

   void method14374(int var1, int var2, int var3, float var4) {
      int var6;
      int var7;
      if(this.anInt8968 != -1) {
         Class161 var5 = this.aClass545_Sub1_8974.anInterface24_7370.method113(this.anInt8968, 1088976492);
         var6 = var5.aByte1990 & 255;
         int var9;
         if(var6 != 0 && var5.aByte1986 != 4) {
            if(var3 < 0) {
               var7 = 0;
            } else if(var3 > 127) {
               var7 = 16777215;
            } else {
               var7 = 131586 * var3;
            }

            if(var6 == 256) {
               var2 = var7;
            } else {
               var9 = 256 - var6;
               var2 = ((var7 & 16711935) * var6 + (var2 & 16711935) * var9 & -16711936) + ((var7 & '\uff00') * var6 + (var2 & '\uff00') * var9 & 16711680) >> 8;
            }
         }

         var7 = var5.aByte1991 & 255;
         if(var7 != 0) {
            var7 += 256;
            int var8 = ((var2 & 16711680) >> 16) * var7;
            if(var8 > '\uffff') {
               var8 = '\uffff';
            }

            var9 = ((var2 & '\uff00') >> 8) * var7;
            if(var9 > '\uffff') {
               var9 = '\uffff';
            }

            int var10 = (var2 & 255) * var7;
            if(var10 > '\uffff') {
               var10 = '\uffff';
            }

            var2 = (var8 << 8 & 16711680) + (var9 & '\uff00') + (var10 >> 8);
         }
      }

      if(var4 != 1.0F) {
         int var11 = var2 >> 16 & 255;
         var6 = var2 >> 8 & 255;
         var7 = var2 & 255;
         var11 = (int)((float)var11 * var4);
         if(var11 < 0) {
            var11 = 0;
         } else if(var11 > 255) {
            var11 = 255;
         }

         var6 = (int)((float)var6 * var4);
         if(var6 < 0) {
            var6 = 0;
         } else if(var6 > 255) {
            var6 = 255;
         }

         var7 = (int)((float)var7 * var4);
         if(var7 < 0) {
            var7 = 0;
         } else if(var7 > 255) {
            var7 = 255;
         }

         var2 = var11 << 16 | var6 << 8 | var7;
      }

      this.aStream8975.method3017(var1 * 4);
      this.aStream8975.method3018((byte)(var2 >> 16));
      this.aStream8975.method3018((byte)(var2 >> 8));
      this.aStream8975.method3018((byte)var2);
   }

   void method14375(int var1, int var2, int var3) {
      this.anIntArray8966[var2 * this.aClass400_Sub3_8973.anInt4911 * 1724373523 + var1] |= 1 << var3;
   }

   void method14376(int var1) {
      this.aStream8975.method3017(var1 * 4 + 3);
      this.aStream8975.method3018(-1);
   }

   void method14377(int var1, int var2, int var3, float var4) {
      int var6;
      int var7;
      if(this.anInt8968 != -1) {
         Class161 var5 = this.aClass545_Sub1_8974.anInterface24_7370.method113(this.anInt8968, -1932600789);
         var6 = var5.aByte1990 & 255;
         int var9;
         if(var6 != 0 && var5.aByte1986 != 4) {
            if(var3 < 0) {
               var7 = 0;
            } else if(var3 > 127) {
               var7 = 16777215;
            } else {
               var7 = 131586 * var3;
            }

            if(var6 == 256) {
               var2 = var7;
            } else {
               var9 = 256 - var6;
               var2 = ((var7 & 16711935) * var6 + (var2 & 16711935) * var9 & -16711936) + ((var7 & '\uff00') * var6 + (var2 & '\uff00') * var9 & 16711680) >> 8;
            }
         }

         var7 = var5.aByte1991 & 255;
         if(var7 != 0) {
            var7 += 256;
            int var8 = ((var2 & 16711680) >> 16) * var7;
            if(var8 > '\uffff') {
               var8 = '\uffff';
            }

            var9 = ((var2 & '\uff00') >> 8) * var7;
            if(var9 > '\uffff') {
               var9 = '\uffff';
            }

            int var10 = (var2 & 255) * var7;
            if(var10 > '\uffff') {
               var10 = '\uffff';
            }

            var2 = (var8 << 8 & 16711680) + (var9 & '\uff00') + (var10 >> 8);
         }
      }

      if(var4 != 1.0F) {
         int var11 = var2 >> 16 & 255;
         var6 = var2 >> 8 & 255;
         var7 = var2 & 255;
         var11 = (int)((float)var11 * var4);
         if(var11 < 0) {
            var11 = 0;
         } else if(var11 > 255) {
            var11 = 255;
         }

         var6 = (int)((float)var6 * var4);
         if(var6 < 0) {
            var6 = 0;
         } else if(var6 > 255) {
            var6 = 255;
         }

         var7 = (int)((float)var7 * var4);
         if(var7 < 0) {
            var7 = 0;
         } else if(var7 > 255) {
            var7 = 255;
         }

         var2 = var11 << 16 | var6 << 8 | var7;
      }

      this.aStream8975.method3017(var1 * 4);
      this.aStream8975.method3018((byte)(var2 >> 16));
      this.aStream8975.method3018((byte)(var2 >> 8));
      this.aStream8975.method3018((byte)var2);
   }

   void method14378(int var1, int var2, int var3) {
      this.anIntArray8966[var2 * this.aClass400_Sub3_8973.anInt4911 * 1724373523 + var1] |= 1 << var3;
   }

   void method14379(int var1, int var2, int var3, float var4) {
      int var6;
      int var7;
      if(this.anInt8968 != -1) {
         Class161 var5 = this.aClass545_Sub1_8974.anInterface24_7370.method113(this.anInt8968, -187482919);
         var6 = var5.aByte1990 & 255;
         int var9;
         if(var6 != 0 && var5.aByte1986 != 4) {
            if(var3 < 0) {
               var7 = 0;
            } else if(var3 > 127) {
               var7 = 16777215;
            } else {
               var7 = 131586 * var3;
            }

            if(var6 == 256) {
               var2 = var7;
            } else {
               var9 = 256 - var6;
               var2 = ((var7 & 16711935) * var6 + (var2 & 16711935) * var9 & -16711936) + ((var7 & '\uff00') * var6 + (var2 & '\uff00') * var9 & 16711680) >> 8;
            }
         }

         var7 = var5.aByte1991 & 255;
         if(var7 != 0) {
            var7 += 256;
            int var8 = ((var2 & 16711680) >> 16) * var7;
            if(var8 > '\uffff') {
               var8 = '\uffff';
            }

            var9 = ((var2 & '\uff00') >> 8) * var7;
            if(var9 > '\uffff') {
               var9 = '\uffff';
            }

            int var10 = (var2 & 255) * var7;
            if(var10 > '\uffff') {
               var10 = '\uffff';
            }

            var2 = (var8 << 8 & 16711680) + (var9 & '\uff00') + (var10 >> 8);
         }
      }

      if(var4 != 1.0F) {
         int var11 = var2 >> 16 & 255;
         var6 = var2 >> 8 & 255;
         var7 = var2 & 255;
         var11 = (int)((float)var11 * var4);
         if(var11 < 0) {
            var11 = 0;
         } else if(var11 > 255) {
            var11 = 255;
         }

         var6 = (int)((float)var6 * var4);
         if(var6 < 0) {
            var6 = 0;
         } else if(var6 > 255) {
            var6 = 255;
         }

         var7 = (int)((float)var7 * var4);
         if(var7 < 0) {
            var7 = 0;
         } else if(var7 > 255) {
            var7 = 255;
         }

         var2 = var11 << 16 | var6 << 8 | var7;
      }

      this.aStream8975.method3017(var1 * 4);
      this.aStream8975.method3018((byte)(var2 >> 16));
      this.aStream8975.method3018((byte)(var2 >> 8));
      this.aStream8975.method3018((byte)var2);
   }

   void method14380(int var1) {
      this.aStream8975.method3021();
      Interface10 var2 = this.aClass545_Sub1_8974.method14583(4, this.aNativeHeapBuffer8967, var1 * 4, false);
      if(var2 instanceof Class145_Sub1) {
         this.aNativeHeapBuffer8967.method1290();
      }

      this.aClass150_8971 = new Class150(var2, 5121, 4, 0);
      this.aNativeHeapBuffer8967 = null;
      this.aStream8975 = null;
   }

   void method14381(int var1) {
      this.aStream8975.method3021();
      Interface10 var2 = this.aClass545_Sub1_8974.method14583(4, this.aNativeHeapBuffer8967, var1 * 4, false);
      if(var2 instanceof Class145_Sub1) {
         this.aNativeHeapBuffer8967.method1290();
      }

      this.aClass150_8971 = new Class150(var2, 5121, 4, 0);
      this.aNativeHeapBuffer8967 = null;
      this.aStream8975 = null;
   }

   void method14382(int[] var1, int var2) {
      int var3 = 0;
      Class225_Sub23_Sub2 var4 = this.aClass545_Sub1_8974.aClass225_Sub23_Sub2_9294;
      var4.position = 0;
      int var5;
      int var6;
      short[] var7;
      int var8;
      int var9;
      int var10;
      if(this.aClass545_Sub1_8974.aBool9257) {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.writeShort(var7[var10++] & '\uffff', 249743327);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', 797525846);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', 1685258465);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      } else {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      }

      if(var3 > 0) {
         this.aClass162_Sub2_8972.method74(5123, var4.buffer, var4.position * -543666943);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14590(this.anInt8968, (this.aClass400_Sub3_8973.anInt9563 & 7) != 0, (this.aClass400_Sub3_8973.anInt9563 & 8) != 0);
         if(this.aClass545_Sub1_8974.aBool9242) {
            this.aClass545_Sub1_8974.method11496(Integer.MAX_VALUE, this.aClass153_8970);
         }

         OpenGL.glMatrixMode(5890);
         OpenGL.glPushMatrix();
         OpenGL.glScalef(1.0F / this.aFloat8969, 1.0F / this.aFloat8969, 1.0F);
         OpenGL.glMatrixMode(5888);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14610(this.aClass162_Sub2_8972, 4, 0, var3);
         OpenGL.glMatrixMode(5890);
         OpenGL.glPopMatrix();
         OpenGL.glMatrixMode(5888);
      }

   }

   void method14383(int[] var1, int var2) {
      int var3 = 0;
      Class225_Sub23_Sub2 var4 = this.aClass545_Sub1_8974.aClass225_Sub23_Sub2_9294;
      var4.position = 0;
      int var5;
      int var6;
      short[] var7;
      int var8;
      int var9;
      int var10;
      if(this.aClass545_Sub1_8974.aBool9257) {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.writeShort(var7[var10++] & '\uffff', -202693149);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', 560895915);
                     ++var3;
                     var4.writeShort(var7[var10++] & '\uffff', -1562336667);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      } else {
         for(var5 = 0; var5 < var2; ++var5) {
            var6 = var1[var5];
            var7 = this.aClass400_Sub3_8973.aShortArrayArray9566[var6];
            var8 = this.anIntArray8966[var6];
            if(var8 != 0 && var7 != null) {
               var9 = 0;
               var10 = 0;

               while(var10 < var7.length) {
                  if((var8 & 1 << var9++) != 0) {
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                     var4.method13704(var7[var10++] & '\uffff', 1094649230);
                     ++var3;
                  } else {
                     var10 += 3;
                  }
               }
            }
         }
      }

      if(var3 > 0) {
         this.aClass162_Sub2_8972.method74(5123, var4.buffer, var4.position * -543666943);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14590(this.anInt8968, (this.aClass400_Sub3_8973.anInt9563 & 7) != 0, (this.aClass400_Sub3_8973.anInt9563 & 8) != 0);
         if(this.aClass545_Sub1_8974.aBool9242) {
            this.aClass545_Sub1_8974.method11496(Integer.MAX_VALUE, this.aClass153_8970);
         }

         OpenGL.glMatrixMode(5890);
         OpenGL.glPushMatrix();
         OpenGL.glScalef(1.0F / this.aFloat8969, 1.0F / this.aFloat8969, 1.0F);
         OpenGL.glMatrixMode(5888);
         this.aClass545_Sub1_8974.method14625(this.aClass400_Sub3_8973.aClass150_9579, this.aClass400_Sub3_8973.aClass150_9584, this.aClass150_8971, this.aClass400_Sub3_8973.aClass150_9569);
         this.aClass545_Sub1_8974.method14610(this.aClass162_Sub2_8972, 4, 0, var3);
         OpenGL.glMatrixMode(5890);
         OpenGL.glPopMatrix();
         OpenGL.glMatrixMode(5888);
      }

   }
}
