public MultilayerArrangement[] getArrangements()
 {
     MultilayerArrangement[] output;
     this.SeekToOffset(0x01D0BC9C);
     ushort numlayers = this.ReadUInt16();
     ushort numarrs = this.ReadUInt16();
     output = new MultilayerArrangement[numarrs];
     Arrangement[] layers = new Arrangement[numlayers];
     for (int i = 0; i < numlayers; i++)
         layers[i] = GetMO3Layer(i);
     MultilayerArrangement temp;
     this.SeekToOffset(0x1D1EFC0);
     ushort layer1, layer2, alpha1, alpha2;
     for (int i = 0; i < numarrs; i++) {
         this.SeekToOffset(0x1D1EFC0 + i * 12);
         layer1 = this.ReadUInt16();
         layer2 = this.ReadUInt16();
         alpha1 = this.ReadUInt16();
         alpha2 = this.ReadUInt16();
         temp = new MultilayerArrangement(layers[layer1], layers[layer2]);
         temp.opacity[0] = alpha1 / 16.0;
         temp.opacity[1] = alpha2 / 16.0;
         output[i] = temp;
     }
     Console.WriteLine("Read {0} arrangements", output.Length);
     this.Close();
     this.Dispose();
     return output;
 }
        public MultilayerArrangement[] getArrangements()
        {
            MultilayerArrangement[] arrangements = new MultilayerArrangement[0x1E3 + 15 + ((this.GetGameDest() == America) ? 1 : 0)];
            int i;
            this.SeekToOffset(0x0ADCA1);
            byte[] tableData = this.ReadBytes(17 * 327);
            List<Arrangement> bglayers = new List<Arrangement>();
            for (i = 0; i < tableData.Length / 17; i++) {
                bglayers.Add(ReadCompressedArrangement(
                       this.ReadSNESPointer(0xAD93D + tableData[i * 17] * 4),
                       this.ReadSNESPointer(0xAD7A1 + tableData[i * 17] * 4),
                       this.ReadSNESPointer(0xADAD9 + tableData[i * 17 + 1] * 4),
                       tableData[i * 17 + 2],
                       "BattleBG " + i,
                       ARRANGEMENT + GRAPHICS));
            }
            this.SeekToOffset(0x0BD89A);
            for (i = 0; i < 0x1E3; i++)
                arrangements[i] = new MultilayerArrangement(bglayers[this.ReadInt16()], bglayers[this.ReadInt16()]);
            bglayers.Clear();
            i = 0x1E3;
            if (this.GetGameDest() == Japan) {
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21C692, 0x21C6DF, 0x21C800, 2, "Nintendo", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21C470, 0x21C4DC, 0x21C800, 2, "Itoi", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x18F8D6, 0x18FAD4, 0x18F8CE, 2, "Faulty cartridge", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x18F05E, 0x18F336, 0x18F8CE, 2, "Piracy is bad", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2148AB, 0x2148EF, 0x2149B8, 2, "Logo 1", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x214317, 0x214380, 0x214586, 2, "Logo 2", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2145CA, 0x21463E, 0x21480E, 2, "Logo 3", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2149FC, 0x214F4E, 0x219CB9, 8, "Gas Station", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2149FC, 0x214F4E, 0x219D5F, 8, "Gas Station Alt", ARRANGEMENT + GRAPHICS + PALETTE));
                //arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21B18C, 0x21A0A0, 0x219CB9, 8, "Title Screen", ARRANGEMENT + GRAPHICS + PALETTE));
                byte[] arrangementData;
                byte[] graphicsData, paletteData;
                byte[] decompBuffer;
                for (int j = 0; j < 6; j++) {
                    decompBuffer = this.ReadCompressedData(this.ReadSNESPointer(0x2030E5 + j * 4));
                    arrangementData = new byte[ARRANGEMENTSIZE];
                    paletteData = new byte[64];
                    graphicsData = new byte[decompBuffer.Length - ARRANGEMENTSIZE - 64];
                    Array.Copy(decompBuffer, paletteData, 64);
                    Array.Copy(decompBuffer, 64, arrangementData, 0, ARRANGEMENTSIZE);
                    Array.Copy(decompBuffer, ARRANGEMENTSIZE + 64, graphicsData, 0, graphicsData.Length);

                    arrangements[i + j] = new MultilayerArrangement(ReadMapArrangement(arrangementData, graphicsData, paletteData, 4, "Map " + j));
                }
            }
            else if (this.GetGameDest() == America) {

                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21AD01, 0x21AD4E, 0x21AE70, 2, "Nintendo", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21AADF, 0x21AB4B, 0x21AE70, 2, "Itoi", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x18F3C6, 0x18F5C4, 0x18F3BE, 2, "Faulty cartridge", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x18F05E, 0x18F20D, 0x18F3BE, 2, "Piracy is bad", ARRANGEMENT + GRAPHICS));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x215455, 0x21549E, 0x21558F, 2, "Logo 1", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x214EC1, 0x214F2A, 0x215130, 2, "Logo 2", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x215174, 0x2151E8, 0x2153B8, 2, "Logo 3", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2155D3, 0x215B33, 0x21A9B7, 8, "Gas Station", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x2155D3, 0x215B33, 0x21AA5D, 8, "Gas Station Alt", ARRANGEMENT + GRAPHICS + PALETTE));
                arrangements[i++] = new MultilayerArrangement(ReadCompressedArrangement(0x21AF7D, 0x21B211, 0x21CDE1, 8, "Title Screen", ARRANGEMENT + GRAPHICS + PALETTE));
                byte[] arrangementData;
                byte[] graphicsData, paletteData;
                byte[] decompBuffer;
                for (int j = 0; j < 6; j++) {
                    decompBuffer = this.ReadCompressedData(this.ReadSNESPointer(0x202190 + j * 4));
                    arrangementData = new byte[ARRANGEMENTSIZE];
                    paletteData = new byte[64];
                    graphicsData = new byte[decompBuffer.Length - ARRANGEMENTSIZE - 64];
                    Array.Copy(decompBuffer, paletteData, 64);
                    Array.Copy(decompBuffer, 64, arrangementData, 0, ARRANGEMENTSIZE);
                    Array.Copy(decompBuffer, ARRANGEMENTSIZE + 64, graphicsData, 0, graphicsData.Length);

                    arrangements[i + j] = new MultilayerArrangement(ReadMapArrangement(arrangementData, graphicsData, paletteData, 4, "Map " + j));
                }
                //int gfxOffset;
                //for (int i = 0; i < 31; i++)
                //{
                //    romfile.seekToOffset(0xCF04D+i*12);
                //    gfxOffset = romfile.ReadUInt16()+0xC0000;
                //    arrangements.Add(buildArrangement(romfile.ReadSNESPointer(0xCF593+i*4), gfxOffset, 0x0CF47F+i*8, 2, "PSI " + i));
                //}
            }
            this.Close();
            this.Dispose();
            return arrangements;
        }