return decomp(cdata, buffer, maxlen, rom);
int start = cdata; int bpos = 0, bpos2 = 0; byte tmp; while (rom.read(cdata) != 0xFF) { int cmdtype = rom.read(cdata) >> 5; int len = (rom.read(cdata) & 0x1F) + 1; if (cmdtype == 7) { cmdtype = (rom.read(cdata) & 0x1C) >> 2; len = ((rom.read(cdata) & 3) << 8) + rom.read(cdata + 1) + 1; cdata++; } if (bpos + len > maxlen) return new int[] { -1 }; cdata++; if (cmdtype >= 4) { bpos2 = (rom.read(cdata) << 8) + rom.read(cdata + 1); if (bpos2 >= maxlen) return new int[] { -2 }; cdata += 2; }  switch (cmdtype) { case 0 : System.arraycopy(rom.readByte(cdata, len), 0, buffer, bpos, len); bpos += len; cdata += len;     break; case 1 : Arrays.fill(buffer, bpos, bpos + len, rom.readByte(cdata)); bpos += len;     cdata++; break; case 2 : if (bpos + 2 * len > maxlen) return new int[] { -3 }; while (len-- != 0) { buffer[bpos++] = rom.readByte(cdata); buffer[bpos++] = rom.readByte(cdata + 1); } cdata += 2; break; case 3 : tmp = rom.readByte(cdata++); while (len-- != 0) buffer[bpos++] = tmp++; break; case 4 : if (bpos2 + len > maxlen) return new int[] { -4 }; System.arraycopy(buffer, bpos2, buffer, bpos, len); bpos += len;     break; case 5 : if (bpos2 + len > maxlen) return new int[] { -5 }; while (len-- != 0) { tmp = buffer[bpos2++];  tmp = (byte) (((tmp >> 1) & 0x55) | ((tmp << 1) & 0xAA)); tmp = (byte) (((tmp >> 2) & 0x33) | ((tmp << 2) & 0xCC)); tmp = (byte) (((tmp >> 4) & 0x0F) | ((tmp << 4) & 0xF0)); buffer[bpos++] = tmp; } break; case 6 : if (bpos2 - len + 1 < 0) return new int[] { -6 }; while (len-- != 0) buffer[bpos++] = buffer[bpos2--]; break; case 7 : return new int[] { -7 }; } } return new int[] { bpos, cdata - start + 1 };
    public int[] decomp(int cdata, byte[] buffer, int maxlen)    {        return decomp(cdata, buffer, maxlen, rom);    }