示例#1
0
文件: GFX.cs 项目: biosp4rk/mzmr
        public Gfx(Rom rom, int pointer, int width)
        {
            Width        = width;
            this.rom     = rom;
            this.pointer = pointer;

            // assume graphics compressed
            int offset = rom.ReadPtr(pointer);

            origLen = Compress.DecompLZ77(rom.Data, offset, out Data);
        }
示例#2
0
        public void DecompLZ77Test()
        {
            byte[] input = new byte[]
            {
                0x10, 0x0E, 0, 0,
                0x00, 1, 2, 3, 4, 5, 0, 1, 2,
                0xC0, 0x00, 0x02, 0x00, 0x08
            };
            byte[] actual;
            int    compLen = Compress.DecompLZ77(input, 0, out actual);

            Assert.AreEqual(0x12, compLen);

            byte[] expected = new byte[]
            {
                1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5
            };
            CollectionAssert.AreEqual(expected, actual);
        }
示例#3
0
        // constructor
        public Minimap(Rom rom, byte areaID)
        {
            this.rom = rom;
            AreaID   = areaID;

            try
            {
                // decompress map data
                pointer = Rom.MinimapDataOffset + AreaID * 4;
                int offset = rom.ReadPtr(pointer);
                origLen = Compress.DecompLZ77(rom.Data, offset, out byte[] decompData);
                // copy to ushort array
                data = new ushort[0x400];
                Buffer.BlockCopy(decompData, 0, data, 0, decompData.Length);
            }
            catch (IndexOutOfRangeException)
            {
                throw new Exception("Bad minimap data");
            }
        }
示例#4
0
        public Tilemap(Rom rom, int pointer, bool compressed = false)
        {
            this.rom        = rom;
            this.pointer    = pointer;
            this.compressed = compressed;

            if (compressed)
            {
                int offset = rom.ReadPtr(pointer);
                origLen = Compress.DecompLZ77(rom.Data, offset, out byte[] decompData);
                data    = Arrays.ByteToUshort(decompData);
            }
            else
            {
                int  offset = rom.ReadPtr(pointer);
                byte rows   = rom.Read8(offset + 1);
                origLen = rows * 0x40 + 1;

                byte[] bytes = new byte[origLen * 2];
                rom.RomToArray(bytes, offset, 0, bytes.Length);
                data = Arrays.ByteToUshort(bytes);
            }
        }