예제 #1
0
        public Map(int Offset, GBAROM ROM, int CurrentBank, int CurrentMap)
        {
            offset = Offset;
            originROM = ROM;
            currentBank = (byte)CurrentBank;
            currentMap = (byte)CurrentMap;
            rawHeaderOrig = originROM.GetData(offset, 0x1C);
            rawHeader = (byte[])rawHeaderOrig.Clone();

            LoadMapHeaderFromRaw();

            if (Program.mapLayouts.ContainsKey(mapLayoutIndex))
                layout = Program.mapLayouts[mapLayoutIndex];
            else
            {
                Program.mapLayoutNotFoundCount++;
                if (mapLayoutIndex > Program.maxLayout)
                {
                    Program.maxLayout = mapLayoutIndex;
                }
            }
        }
예제 #2
0
        public MapLayout(int index, int offset, GBAROM ROM)
        {
            layoutIndex = (byte)index;
            originROM = ROM;
            if (Program.currentGame.RomType == "FRLG")
                rawHeaderOrig = originROM.GetData(offset, 0x1C);
            else
                rawHeaderOrig = originROM.GetData(offset, 0x18);
            rawHeader = (byte[])rawHeaderOrig.Clone();
            LoadLayoutHeaderFromRaw();

            if (borderBlocksPointer > 0 && borderBlocksPointer < Program.ROM.Length)
            {
                rawBorderOrig = originROM.GetData(borderBlocksPointer, borderWidth * borderHeight * 4);
                rawBorder = (byte[])rawBorderOrig.Clone();
                LoadBorderFromRaw();
            }

            if (mapDataPointer > 0 && mapDataPointer < Program.ROM.Length)
            {
                rawLayoutOrig = originROM.GetData(mapDataPointer, layoutWidth * layoutHeight * 4);
                rawLayout = (byte[])rawLayoutOrig.Clone();
                LoadLayoutFromRaw();
            }
        }
        public MapTileset(int Offset, GBAROM ROM)
        {
            offset = Offset;
            originROM = ROM;
            byte[] temp = originROM.GetData(offset, 0x4);
            isCompressed = temp[0];
            isSecondary = temp[1];
            buffer1 = temp[2];
            buffer2 = temp[3];
            imagePointer = originROM.ReadPointer(offset + 0x4);
            imagePalsPointer = originROM.ReadPointer(offset + 0x8);
            blocksPointer = originROM.ReadPointer(offset + 0xC);

            if (Program.currentGame.RomType == "FRLG")
            {
                animationPointer = originROM.ReadPointer(offset + 0x10);
                behaviorPointer = originROM.ReadPointer(offset + 0x14);
            }
            else if (Program.currentGame.RomType == "E")
            {
                behaviorPointer = originROM.ReadPointer(offset + 0x10);
                animationPointer = originROM.ReadPointer(offset + 0x14);
            }

            blockSet = new Blockset(blocksPointer, behaviorPointer, (isSecondary & 1) == 1, originROM);
        }
 public void ReadData(GBAROM rom, int offset, int length)
 {
     hasBeenEdited = false;
     data.Clear();
     try
     {
         data.AddRange(rom.GetData(offset, length));
     }
     catch (ArgumentException)
     {
         throw;
     }
 }
        public Blockset(int blocksPointer, int behaviorsPointer,  bool isSecondary, GBAROM ROM)
        {
            originROM = ROM;

            if(!isSecondary)
                blocks = new Block[Program.currentGame.MainTSBlocks];
            else
                blocks = new Block[0x400 - Program.currentGame.MainTSBlocks];  //this needs fixing

            for (int i = 0; i < blocks.Length; i++)
            {
                byte[] rawBehaviorData = null;
                int isTriple = 0;
                if (Program.currentGame.RomType == "FRLG")
                    rawBehaviorData = originROM.GetData(behaviorsPointer + (i * 4), 4);
                else if (Program.currentGame.RomType == "E")
                    rawBehaviorData = originROM.GetData(behaviorsPointer + (i * 2), 2);

                Behavior behavior = new Behavior(rawBehaviorData);
                if (behavior.GetBackground() == 3)
                    isTriple = 1;
                else if (behavior.GetBackground() == 4)
                    isTriple = 2;

                byte[] rawTileData = originROM.GetData(blocksPointer + (i * 16) + ((isTriple == 2) ? 8 : 0), ((isTriple == 0) ? 16 : 24));

                short[] tileData = new short[(int)Math.Ceiling((double)(rawTileData.Length / 2))];
                Buffer.BlockCopy(rawTileData, 0, tileData, 0, rawTileData.Length);

                Tile[] tiles = new Tile[(isTriple == 0) ? 8 : 12];
                for (int j = 0; j < tiles.Length; j++)
                    tiles[j] = new Tile(tileData[j] & 0x3FF, (tileData[j] & 0xF000) >> 12, (tileData[j] & 0x400) == 0x400, (tileData[j] & 0x800) == 0x800);

                blocks[i] = new Block(tiles,behavior);
            }
        }