--- /dev/null
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3) fieldsfirst nonlb space
+
+package mcsClient;
+
+import java.awt.image.MemoryImageSource;
+import java.io.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+// Referenced classes of package mcsClient:
+// HexConversion
+
+public final class Decompress {
+ class VideoCommands {
+
+ private static final byte BF = 96;
+ private static final byte NC = 0;
+ private static final byte CA = 64;
+ private static final byte CB = 32;
+ private static final byte MM = 96;
+ private static final byte WP = -128;
+ private static final byte EF = 112;
+ private static final byte CMD_MASK = -32;
+ private static final byte RC_MASK = 31;
+ private static final byte RC_SIZE = 5;
+
+ VideoCommands() {
+ }
+ }
+
+
+ public static boolean PRINT_DATA = false;
+ private byte imageData[];
+ boolean pixelsInParts;
+ private int oldY;
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public Decompress(byte abyte0[]) {
+ oldY = 0;
+ imageData = abyte0;
+ logger.setLevel(Level.WARNING);
+ String s = System.getProperty("mcs.debug");
+ if (s != null && s.equalsIgnoreCase("true"))
+ logger.setLevel(Level.ALL);
+ }
+
+ public void doDecompress(DataInputStream datainputstream, int i, int j, int k, MemoryImageSource memoryimagesource, int l, int i1) throws ArrayIndexOutOfBoundsException {
+ int j1 = j;
+ boolean flag = false;
+ int l1 = 0;
+ int i2 = 0;
+ int j2 = 0;
+ byte byte1 = 96;
+ byte byte2 = 96;
+ byte byte3 = 0;
+ boolean flag1 = false;
+ boolean flag2 = false;
+ boolean flag3 = false;
+ boolean flag4 = false;
+ int k2 = 0;
+ int i3 = ((j1 + k + l) - 1) / l;
+ if (j == 0) {
+ pixelsInParts = false;
+ oldY = 0;
+ }
+ int j3 = 0;
+ boolean flag5 = false;
+ do {
+ if (j1 >= j + k) {
+ if (j1 > j + k)
+ logger.info("ERROR0: imageDataIndex = " + j1 + ", videoRamOffset = " + j + ", videoRamCount = " + k);
+ if (pixelsInParts)
+ memoryimagesource.newPixels(0, oldY, l - 1, i3 - oldY, false);
+ break;
+ }
+ if (j3 >= i) {
+ if (j3 > i)
+ logger.warning("ERROR: bytesRead > datagramLength, bytesRead = " + j3 + ", datagramLength = " + i);
+ if (!flag3)
+ break;
+ j2 = i2;
+ j2 += 2;
+ byte2 = byte1;
+ flag1 = true;
+ flag3 = false;
+ flag5 = true;
+ }
+ if (!flag5) {
+ try {
+ l1 = datainputstream.readUnsignedByte();
+ if (PRINT_DATA) {
+ System.out.print(" " + HexConversion.toString(l1));
+ if (++k2 >= 32) {
+ k2 = 0;
+ System.out.println();
+ }
+ }
+ }
+ catch (IOException ioexception) {
+ logger.info("Decompress - error reading datagram byte " + ioexception);
+ return;
+ }
+ j3++;
+ byte byte0 = (byte)(l1 & 0xffffffe0);
+ if (flag3)
+ if (byte0 == byte1) {
+ byte3++;
+ i2 |= (l1 & 0x1f) << byte3 * 5;
+ if (i2 > l * i1)
+ logger.info("Bad repeat count " + i2);
+ if (j1 + i2 + 3 >= j + k) {
+ j2 = i2;
+ j2 += 2;
+ byte2 = byte1;
+ flag1 = true;
+ flag3 = false;
+ byte3 = 0;
+ }
+ } else {
+ j2 = i2;
+ j2 += 2;
+ byte2 = byte1;
+ flag1 = true;
+ flag3 = false;
+ byte3 = 0;
+ }
+ switch (byte0) {
+ case 0: // '\0'
+ case 32: // ' '
+ case 64: // '@'
+ if (byte0 != byte1) {
+ i2 = l1 & 0x1f;
+ flag3 = true;
+ byte3 = 0;
+ }
+ break;
+
+ case 96: // '`'
+ flag4 = true;
+ break;
+
+ default:
+ if ((l1 & 0x80) != 0) {
+ flag2 = true;
+ break;
+ }
+ logger.severe("Unknown video command received, got: " + byte0);
+ try {
+ datainputstream.close();
+ }
+ catch (IOException ioexception1) {
+ logger.info(ioexception1.toString());
+ }
+ return;
+ }
+ byte1 = byte0;
+ }
+ if (flag1) {
+ switch (byte2) {
+ default:
+ break;
+
+ case 0: // '\0'
+ if (j2 > 0x80000) {
+ int l2 = ((j1 + l) - 1) / l;
+ memoryimagesource.newPixels(0, oldY, l - 1, l2 - oldY, false);
+ oldY = ((j1 + j2) - (l - 1)) / l;
+ pixelsInParts = true;
+ }
+ j1 += j2;
+ break;
+
+ case 64: // '@'
+ if (j1 - j < l)
+ logger.warning("Error: copy above index = " + (j1 - j));
+ while (j2 > 0)
+ try {
+ imageData[j1] = imageData[j1 - l];
+ j1++;
+ j2--;
+ }
+ catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) {
+ logger.warning("imageDataIndex: " + j1);
+ throw arrayindexoutofboundsexception;
+ }
+ break;
+
+ case 32: // ' '
+ if (j1 - j < 1)
+ logger.warning("Error: copy left index = " + (j1 - j));
+ byte byte4 = imageData[j1 - 1];
+ while (j2 > 0)
+ try {
+ imageData[j1] = byte4;
+ j1++;
+ j2--;
+ }
+ catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception1) {
+ logger.info("imageDataIndex: " + j1);
+ throw arrayindexoutofboundsexception1;
+ }
+ break;
+ }
+ flag1 = false;
+ }
+ if (j1 >= j + k) {
+ if (pixelsInParts)
+ memoryimagesource.newPixels(0, oldY, l - 1, i3 - oldY, false);
+ break;
+ }
+ if (flag4) {
+ byte byte6 = 0;
+ int k1 = j1;
+ byte byte5 = imageData[j1 - 1];
+ int k3 = j1 - 2;
+ while (k3 >= j) {
+ if (imageData[k3] == byte5) {
+ k3--;
+ continue;
+ }
+ byte6 = imageData[k3];
+ break;
+ }
+ try {
+ imageData[j1++] = (l1 & 8) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 4) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 2) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 1) == 0 ? byte5 : byte6;
+ }
+ catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception2) {
+ logger.info("imageDataIndex: " + j1);
+ throw arrayindexoutofboundsexception2;
+ }
+ if ((l1 & 0x10) != 0)
+ do {
+ try {
+ l1 = datainputstream.readUnsignedByte();
+ if (PRINT_DATA) {
+ System.out.print(" " + HexConversion.toString(l1));
+ if (++k2 >= 32) {
+ k2 = 0;
+ System.out.println();
+ }
+ }
+ }
+ catch (IOException ioexception2) {
+ logger.info("Decompress - error reading monochrome byte");
+ return;
+ }
+ j3++;
+ try {
+ imageData[j1++] = (l1 & 0x40) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 0x20) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 0x10) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 8) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 4) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 2) == 0 ? byte5 : byte6;
+ imageData[j1++] = (l1 & 1) == 0 ? byte5 : byte6;
+ }
+ catch (ArrayIndexOutOfBoundsException arrayindexoutofboundsexception3) {
+ logger.info("imageDataIndex: " + j1);
+ throw arrayindexoutofboundsexception3;
+ }
+ } while ((l1 & 0x80) != 0);
+ flag4 = false;
+ }
+ if (j1 >= j + k) {
+ if (j1 > j + k)
+ logger.info("ERROR2: imageDataIndex = " + j1 + ", videoRamOffset = " + j + ", videoRamCount = " + k);
+ if (pixelsInParts)
+ memoryimagesource.newPixels(0, oldY, l - 1, i3 - oldY, false);
+ break;
+ }
+ if (flag2) {
+ imageData[j1++] = (byte)(l1 & 0x7f);
+ flag2 = false;
+ }
+ if (j1 < j + k)
+ continue;
+ if (j1 > j + k)
+ logger.info("ERROR3: imageDataIndex = " + j1 + ", videoRamOffset = " + j + ", videoRamCount = " + k);
+ if (pixelsInParts)
+ memoryimagesource.newPixels(0, oldY, l - 1, i3 - oldY, false);
+ break;
+ } while (true);
+ }
+
+}