Esempio n. 1
0
 protected virtual void OnAreaNumberChanged(EventArgs e)
 {
     UpdateArea();
     UpdateMap16();
     TilemapLoader.LoadTilemap(AreaIndex);
     GfxData.LoadTileSet(TilemapLoader.TileSetIndex);
     AreaNumberChanged?.Invoke(this, e);
 }
Esempio n. 2
0
        public RomData(RomIO rom)
        {
            Rom = rom ?? throw new ArgumentOutOfRangeException(nameof(rom));
            if (Rom.HeaderlessSize < 0x200000)
            {
                throw new ArgumentException(
                          "ROM data size is insufficient.");
            }

            AreaLoader  = new AreaLoader(this);
            PaletteData = new PaletteData(this);
            GfxData     = new GfxData(this);
            AreaBg2Map  = new AreaBg2Map(this);
            Map16Data   = new Obj16Tile[0x200];
            var offsets = new byte[] { 0x00, 0x40, 0x80, 0xC0 };
            var sizes   = new byte[] { 0x2B, 0x38, 0x0E, 0x3E };

            for (var i = 0; i < 4; i++)
            {
                var low     = Rom.ReadByte(Map16DataLowByteAddress + i);
                var high    = Rom.ReadByte(Map16DataHighByteAddress + i);
                var address = 0x030000 | (high << 8) | low;

                var tiles = Rom.ReadBytes(address, sizes[i] << 3, true);
                unsafe
                {
                    fixed(byte *src = tiles)
                    fixed(Obj16Tile * dest = Map16Data)
                    {
                        Buffer.MemoryCopy(
                            src,
                            dest + offsets[i],
                            0x800,
                            tiles.Length);
                    }
                }
            }

            TilemapLoader = new TilemapLoader(this);

            AreaObjectRenderer = new AreaObjectRenderer(AreaObjectLoader);
            AreaSpriteRenderer = new AreaSpriteRenderer(AreaSpriteLoader);

            AreaNumber = AreaLoader.GetAreaNumber(0, 0);
        }