コード例 #1
0
 public Block(Tile[] tiles, Behavior behave)
 {
     tileArray = tiles;
     behaviors = behave;
 }
コード例 #2
0
        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);
            }
        }