예제 #1
0
        public SpriteGroup(RomData romData, SpriteRequirementCollection spriteRequirementsCollection, int groupId)
        {
            this.romData = romData;
            this.spriteRequirementsCollection = spriteRequirementsCollection;

            this.GroupId = groupId;

            this.SubGroup0 = romData[SpriteGroupBaseAddress + (groupId * 4) + 0];
            this.SubGroup1 = romData[SpriteGroupBaseAddress + (groupId * 4) + 1];
            this.SubGroup2 = romData[SpriteGroupBaseAddress + (groupId * 4) + 2];
            this.SubGroup3 = romData[SpriteGroupBaseAddress + (groupId * 4) + 3];

            this.PreserveSubGroup0 = false;
            this.PreserveSubGroup1 = false;
            this.PreserveSubGroup2 = false;
            this.PreserveSubGroup3 = false;

            this.ForceRoomsToGroup = new List <int>();

            // F**k it. Hard code shops
            //if(this.DungeonGroupId == 5)
            //{
            //    this.PreserveSubGroup3 = true;
            //}
        }
예제 #2
0
 private void RemoveBlindSpawnCode(RomData romData)
 {
     for (int i = 0; i < 15; i++) //REMOVE BLIND SPAWN CODE
     {
         romData[0xEA081 + i] = AssemblyConstants.NoOp;
     }
 }
예제 #3
0
 public DungeonObjectDataPointer(RomData romData, int roomId, int pointerAddress, byte[] address)
 {
     this.pointerAddress = pointerAddress;
     this.RoomId         = roomId;
     this.snesAddress    = Utilities.SnesByteArrayTo24bitSnesAddress(address);
     this.Data           = new DungeonObjectDataTable(romData, this.ROMAddress);
 }
예제 #4
0
        public DungeonObjectDataTable(RomData romData, int startAddress)
        {
            this.romData      = romData;
            this.startAddress = startAddress;

            LoadData();
        }
예제 #5
0
 public Room(int roomId, RomData romData, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
 {
     this.RoomId  = roomId;
     this.romData = romData;
     this.spriteGroupCollection       = spriteGroupCollection;
     this.spriteRequirementCollection = spriteRequirementCollection;
 }
예제 #6
0
 public RoomCollection(RomData romData, Random rand, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
 {
     this.romData = romData;
     this.rand    = rand;
     this.spriteGroupCollection       = spriteGroupCollection;
     this.spriteRequirementCollection = spriteRequirementCollection;
 }
예제 #7
0
 public void PatchRom(RomData rom)
 {
     foreach (var patch in Patches)
     {
         rom.PatchData(patch);
     }
 }
예제 #8
0
 public OverworldSprite(RomData romData, int SpriteAddress)
 {
     this.romData       = romData;
     this.SpriteAddress = SpriteAddress;
     this.SpriteY       = romData[SpriteAddress];
     this.SpriteX       = romData[SpriteAddress + 1];
     this.SpriteId      = romData[SpriteAddress + 2];
 }
예제 #9
0
        public void RandomizeRom(RomData romData, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
        {
            FillDungeonPool();
            FillBossPool();

            GenerateRandomizedBosses();
            SetBossSpriteGroups(spriteGroupCollection, spriteRequirementCollection);
            WriteRom(romData);
        }
예제 #10
0
        public void PatchRom(RomData rom)
        {
            var patches = JsonConvert.DeserializeObject <List <PatchObject> >(File.ReadAllText(this.patchFilename));

            foreach (var patch in patches)
            {
                rom.PatchData(patch);
            }
        }
예제 #11
0
        public OverworldEnemyRandomizer(RomData romData, Random rand, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
        {
            this.romData = romData;
            this.rand    = rand;
            this.spriteGroupCollection       = spriteGroupCollection;
            this.spriteRequirementCollection = spriteRequirementCollection;

            areas = new OverworldAreaCollection(romData, rand, spriteGroupCollection, spriteRequirementCollection);
        }
예제 #12
0
 public DungeonObjectDataPointerCollection(RomData romData)
 {
     this.romData = romData;
     for (int i = 0; i < TotalRooms; i++)
     {
         var pointerAddress = AddressConstants.ObjectDataPointerTableAddress + (i * 3);
         RoomDungeonObjectDataPointers.Add(i, new DungeonObjectDataPointer(romData, i, pointerAddress, romData.GetDataChunk(pointerAddress, 3)));
     }
 }
예제 #13
0
        public void ResetRom(RomData romData)
        {
            FillDungeonPool();
            FillBossPool();

            ResetBosses();

            WriteRom(romData);
        }
예제 #14
0
        public DungeonEnemyRandomizer(RomData romData, Random rand, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
        {
            this.romData = romData;
            this.rand    = rand;
            this.spriteGroupCollection       = spriteGroupCollection;
            this.spriteRequirementCollection = spriteRequirementCollection;

            this.roomCollection = new RoomCollection(romData, rand, spriteGroupCollection, spriteRequirementCollection);
        }
        public OverworldAreaCollection(RomData romData, Random rand, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
        {
            this.romData = romData;
            this.rand    = rand;
            this.spriteGroupCollection       = spriteGroupCollection;
            this.spriteRequirementCollection = spriteRequirementCollection;

            LoadAreas();
        }
예제 #16
0
        public SpriteGroupCollection(RomData romData, Random rand, SpriteRequirementCollection spriteRequirementsCollection)
        {
            this.romData = romData;
            this.rand    = rand;
            this.spriteRequirementsCollection = spriteRequirementsCollection;

            dungeonReqs = new RoomGroupRequirementCollection();

            SpriteGroups = new List <SpriteGroup>();
        }
예제 #17
0
 public void WriteShellsToRom(RomData romData)
 {
     foreach (var shell in Shells.Where(x => x.ShellData != null))
     {
         for (int i = 0; i < shell.ShellData.Length; i++)
         {
             romData[shell.RomPointer + i] = shell.ShellData[i];
         }
     }
 }
예제 #18
0
        private void WriteRom(RomData romData)
        {
            foreach (var dungeon in DungeonPool)
            {
                romData[dungeon.DungeonRoomSpritePointerAddress]     = dungeon.SelectedBoss.BossPointer[0];
                romData[dungeon.DungeonRoomSpritePointerAddress + 1] = dungeon.SelectedBoss.BossPointer[1];

                romData[AddressConstants.dungeonHeaderBaseAddress + ((dungeon.BossRoomId * 14) + 3)] = dungeon.SelectedBoss.BossGraphics;
            }
        }
예제 #19
0
        public RomNormalEntrance(RomData romData, int entranceIndex)
            : base(romData)
        {
            this.EntranceIndex   = entranceIndex;
            this.EntranceAddress = 0xDBB73 + entranceIndex;
            this.EntranceNumber  = romData[EntranceAddress];

            this.EntranceAreaId = (romData[0xDB96F + (entranceIndex * 2) + 1] << 8) + romData[0xDB96F + (entranceIndex * 2)];

            this.ConnectToRoomId = (romData[0x14577 + (this.EntranceNumber * 2) + 1] << 8) + romData[0x14577 + (this.EntranceNumber * 2)];
        }
예제 #20
0
        public RomExit(RomData romData, int index)
        {
            this.romData   = romData;
            this.ExitIndex = index;

            this.RoomAddress = 0x15AEE + (index * 2);
            this.AreaAddress = 0x15B8C + index;

            this.RoomId = (romData[RoomAddress + 1] << 8) + romData[RoomAddress];
            this.AreaId = romData[AreaAddress];
        }
예제 #21
0
        public RomDropEntrance(RomData romData, int entranceIndex)
            : base(romData)
        {
            this.EntranceIndex   = entranceIndex;
            this.EntranceAddress = 0xDB84C + entranceIndex;
            this.EntranceNumber  = romData[EntranceAddress];

            this.EntranceAreaId = (romData[0xDB826 + (entranceIndex * 2) + 1] << 8) + romData[0xDB826 + (entranceIndex * 2)];

            // hope this is the same...
            this.ConnectToRoomId = (romData[0x14577 + (this.EntranceNumber * 2) + 1] << 8) + romData[0x14577 + (this.EntranceNumber * 2)];
        }
예제 #22
0
        public void WriteRom(RomData romData, int newAddress)
        {
            romData[newAddress++] = HeaderByte0;
            romData[newAddress++] = HeaderByte1;

            newAddress = WriteLayer(Layer1Objects, Layer1DoorObjects, newAddress, false);
            newAddress = WriteLayer(Layer2Objects, Layer2DoorObjects, newAddress, false);
            newAddress = WriteLayer(Layer3Objects, Layer3DoorObjects, newAddress, true);

            romData[newAddress++] = 0xFF;
            romData[newAddress++] = 0xFF;
        }
예제 #23
0
        public void UpdateRom(RomData romData)
        {
            romData[0x4BA21] = Speed;

            romData[0x04BA1D] = (byte)this.Items.Count;

            for (int i = 0; i < this.Items.Count; i++)
            {
                // x
                romData[0x4BA2A + i] = (byte)((this.Items[i].x + 3) * 16);

                // y
                romData[0x4BA2A + 0x16 + i] = (byte)((this.Items[i].y + 4) * 16);
            }
        }
예제 #24
0
        byte[] trapDoors = { 0x16, 0x18, 0x36, 0x38, 0x44 }; //, 0x48, 0x4A };

        public int WriteRom(RomData romData, int newAddess)
        {
            //this.pointerAddress = newAddess;
            ROMAddress = newAddess;
            var snesPointer = Utilities.PCAddressToSnesByteArray(newAddess);

            // update the pointer
            romData[this.pointerAddress]     = snesPointer[2];
            romData[this.pointerAddress + 1] = snesPointer[1];
            romData[this.pointerAddress + 2] = snesPointer[0];

            Data.WriteRom(romData, newAddess);

            // update the address
            return(newAddess + Data.Length); // return the new address
        }
예제 #25
0
        public static void MoveRoomHeaders(RomData romData)
        {
            // TODO: clean this up
            int pointerTableBase = AddressConstants.dungeonHeaderPointerTableBaseAddress;                     // 0x271E2
            int headerBase       = AddressConstants.dungeonHeaderBaseAddress;                                 // AsarSymbols.Instance.Symbols["room_header_table"]

            byte newRoomBank = romData[AsarSymbols.Instance.Symbols["moved_room_header_bank_value_address"]]; // AddressConstants.MovedRoomBank;

            romData[AddressConstants.RoomHeaderBankLocation] = newRoomBank;                                   // change room header bank (at 0xB5E7) to bank to 0x40

            // copy header table
            for (int i = 0; i < 320; i++)
            {
                //get pointer of that room
                // pointers are 16bit with hard coded bank
                byte[] roomPointer = new byte[4];
                roomPointer[0] = romData[(pointerTableBase + (i * 2) + 0)];
                roomPointer[1] = romData[(pointerTableBase + (i * 2) + 1)];
                roomPointer[2] = 04; // bank
                int snesAddress = BitConverter.ToInt32(roomPointer, 0);
                int pcAddress   = Utilities.SnesToPCAddress(snesAddress);

                // copy the room headers to the new room_header_table
                for (int j = 0; j < 14; j++)
                {
                    romData[headerBase + (i * 14) + j] = romData[pcAddress + j];
                }
            }

            // repoint the pointer table to the new header table
            for (int i = 0; i < 320; i++)
            {
                int  snesAddress = Utilities.PCToSnesAddress(headerBase + (i * 14));
                byte low         = (byte)(snesAddress & 0xFF);
                byte high        = (byte)((snesAddress >> 8) & 0xFF);
                byte bank        = (byte)((snesAddress >> 16) & 0xFF);

                //rewrite all room header address
                romData[pointerTableBase + (i * 2)]     = low;
                romData[pointerTableBase + (i * 2) + 1] = high;
                // bank is set above. once for all rooms, so need to make sure we are in the same bank at the end
                if (bank != newRoomBank)
                {
                    throw new Exception("We changed banks in the middle of moving the room headers! This should have been caught by dev team, unless you were playing with files you shouldn't touch.");
                }
            }
        }
예제 #26
0
        public OverworldArea(RomData romData, int AreaId, Random rand, SpriteGroupCollection spriteGroupCollection, SpriteRequirementCollection spriteRequirementCollection)
        {
            this.romData = romData;
            this.AreaId  = AreaId;
            this.spriteGroupCollection       = spriteGroupCollection;
            this.spriteRequirementCollection = spriteRequirementCollection;
            this.rand = rand;

            int spriteTableBaseSnesAddress = (09 << 16) // bank 9
                                             + (romData[AddressConstants.OverworldSpritePointerTableBaseAddress + (AreaId * 2) + 1] << 8)
                                             + (romData[AddressConstants.OverworldSpritePointerTableBaseAddress + (AreaId * 2)]);

            SpriteTableBaseAddress = Utilities.SnesToPCAddress(spriteTableBaseSnesAddress);

            LoadGraphicsBlock();
            LoadSprites();
        }
예제 #27
0
        public SpriteGroup(RomData romData, SpriteRequirementCollection spriteRequirementsCollection, int groupId)
        {
            this.romData = romData;
            this.spriteRequirementsCollection = spriteRequirementsCollection;

            this.GroupId = groupId;

            this.SubGroup0 = romData[SpriteGroupBaseAddress + (groupId * 4) + 0];
            this.SubGroup1 = romData[SpriteGroupBaseAddress + (groupId * 4) + 1];
            this.SubGroup2 = romData[SpriteGroupBaseAddress + (groupId * 4) + 2];
            this.SubGroup3 = romData[SpriteGroupBaseAddress + (groupId * 4) + 3];

            this.PreserveSubGroup0 = false;
            this.PreserveSubGroup1 = false;
            this.PreserveSubGroup2 = false;
            this.PreserveSubGroup3 = false;

            this.ForceRoomsToGroup = new List <int>();
        }
예제 #28
0
        public GraphData(RomData romData, OptionFlags optionFlags, RomEntranceCollection romEntrances, RomExitCollection romExits, RomChestCollection romChests)
        {
            this.romData      = romData;
            this.romEntrances = romEntrances;
            this.romExits     = romExits;
            this.romChests    = romChests;

            RawEntranceCollection     rawEntranceCollection     = new RawEntranceCollection();
            RawExitCollection         rawExitCollection         = new RawExitCollection();
            RawItemLocationCollection rawItemLocationCollection = new RawItemLocationCollection();
            RawItemEdgeCollection     rawItemEdgeCollection     = new RawItemEdgeCollection();
            RawRoomEdgeCollection     rawRoomEdgeCollection     = new RawRoomEdgeCollection();

            romChests.LoadChests(rawItemLocationCollection);

            UpdateFromRom(rawEntranceCollection, rawExitCollection, rawItemLocationCollection, rawItemEdgeCollection);
            UpdateFromOptions(optionFlags, rawRoomEdgeCollection);
            FillNodesAndEdges(rawEntranceCollection, rawExitCollection, rawItemLocationCollection, rawItemEdgeCollection, rawRoomEdgeCollection);

            _rawItemLocationCollection = rawItemLocationCollection;
        }
예제 #29
0
        public RomChest(RomData romData, int address)
        {
            this.romData = romData;

            Address = address;
            ItemId  = romData[Address];

            if (CrystalAddresses.Contains(Address))
            {
                // crystal/pendant boss drop
                var crystalName = GetCrystalString(Address);
                ItemId = Data.GameItems.Items.Values.Where(x => x.LogicalId == crystalName).Select(x => x.Id).FirstOrDefault();
            }

            if (Address == MiseryMireMedallionAddress || Address == TurtleRockMedallionAddress)
            {
                var medallionName = RomItemConstants.GetEntranceMedallion(ItemId);
                ItemId = Data.GameItems.Items.Values.Where(x => x.LogicalId == medallionName).Select(x => x.Id).FirstOrDefault();
            }

            byte low  = romData[Address - 2];
            byte high = romData[Address - 1];

            if (Address >= 0xE96E && Address <= 0xEB65)
            {
                if (high == 0x80)
                {
                    RoomId = low;
                }
                else
                {
                    RoomId = (high << 8) + low;
                }
            }
            else
            {
                RoomId = GetRoomIdFromAddress(Address);
            }
        }
예제 #30
0
        public DungeonSprite(RomData romData, int address)
        {
            this.romData = romData;
            this.Address = address;

            byte0    = romData[address];
            byte1    = romData[address + 1];
            spriteId = romData[address + 2];

            // overlords should be 00111 (keys are 11000)
            IsOverlord = (byte1 & SpriteConstants.OverlordMask) == SpriteConstants.OverlordMask &&
                         (byte0 & SpriteConstants.SpriteSubtypeByte0Mask) != SpriteConstants.SpriteSubtypeByte0Mask;
            if (!IsOverlord && spriteId != SpriteConstants.KeySprite && spriteId != SpriteConstants.WallmasterSprite) // wall masters spawn out if you remove params
            {
                // fix our guards
                RemoveParams();
            }

            if (romData[address + 3] != 0xFF && (romData[address + 5] == SpriteConstants.KeySprite || romData[address + 5] == SpriteConstants.BigKeySprite))
            {
                HasAKey = true;
            }
        }