Esempio n. 1
0
        public SanityCheckerV2(List <Map> _maps, OverworldMap _overworldMap, NPCdata _npcdata, FF1Rom _rom, ItemShopSlot _declaredShopSlot, ShipLocations _shiplocations)
        {
            rom          = _rom;
            overworldMap = _overworldMap;
            maps         = _maps;
            npcdata      = _npcdata;

            locations = new OwLocationData(rom);
            locations.LoadData();

            Shiplocations = _shiplocations;

            allTreasures     = ItemLocations.AllTreasures.Select(r => r as TreasureChest).Where(r => r != null).ToDictionary(r => (byte)(r.Address - 0x3100));
            allQuestNpcs     = ItemLocations.AllNPCItemLocations.Select(r => r as MapObject).Where(r => r != null).ToDictionary(r => r.ObjectId);
            declaredShopSlot = _declaredShopSlot;

            UpdateNpcRequirements();

            Main = new SCMain(_maps, _overworldMap, _npcdata, locations, _rom);
        }
        public SCCoords SetShipLocation(int dungeonIndex)
        {
            locations.LoadData();

            var shiplocation = data.FirstOrDefault(s => s.TeleporterIndex == dungeonIndex);

            if (shiplocation == null)
            {
                shiplocation = data.FirstOrDefault(s => s.TeleporterIndex == 255);
            }

            if (shiplocation != null)
            {
                locations.ShipLocation = new SCCoords(shiplocation.X, shiplocation.Y);
            }

            locations.StoreData();

            return(locations.ShipLocation);
        }
Esempio n. 3
0
        public void ExecuteStep1()
        {
            if (Data.DecompressedMapRows != null)
            {
                overworldMap.SwapMap(Data.DecompressedMapRows);
            }
            else
            {
                overworldMap.SwapMap(name + ".ffm");
            }

            //load default locations first, doh
            locations.LoadData();

            if (data.StartingLocation.HasValue)
            {
                locations.StartingLocation = data.StartingLocation.Value;
            }
            if (data.AirShipLocation.HasValue)
            {
                locations.AirShipLocation = data.AirShipLocation.Value;
            }
            if (data.BridgeLocation.HasValue)
            {
                locations.BridgeLocation = data.BridgeLocation.Value;
            }
            if (data.CanalLocation.HasValue)
            {
                locations.CanalLocation = data.CanalLocation.Value;
            }

            locations.StoreData();

            foreach (var tf in data.TeleporterFixups)
            {
                exit[tf.Index.Value] = tf.To;
            }

            exit.StoreData();

            ShipLocations.SetShipLocation(255);

            if (data.HorizontalBridge)
            {
                // Rotate bridge sprite
                // tiles $14 - $17
                // CHR for map tiles is bank $02 at $9C00

                // 0 1  \ \
                // 2 3  / /

                var tile0 = new byte[8 * 8] {
                    0, 0, 0, 0, 1, 1, 1, 1,
                    0, 0, 1, 1, 2, 2, 2, 2,
                    1, 1, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 1, 1, 1, 1, 1,
                    2, 1, 1, 2, 2, 2, 2, 2,
                    1, 2, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 2, 2, 2, 2, 2,
                };

                var tile1 = new byte[8 * 8] {
                    2, 2, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 2, 1, 1, 1, 1,
                    2, 2, 1, 1, 2, 2, 2, 2,
                    1, 1, 2, 2, 2, 2, 2, 2,
                    2, 2, 2, 1, 1, 1, 1, 1,
                    1, 1, 1, 0, 0, 0, 0, 0
                };

                var tile2 = new byte[8 * 8];
                var tile3 = new byte[8 * 8];

                for (int j = 0; j < 8; j++)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        // mirror tiles
                        tile2[j * 8 + i] = tile0[j * 8 + (7 - i)];
                        tile3[j * 8 + i] = tile1[j * 8 + (7 - i)];
                    }
                }

                rom.PutInBank(0x2, 0x9C00 + 0x04 * 16, rom.EncodeForPPU(tile0));
                rom.PutInBank(0x2, 0x9C00 + 0x05 * 16, rom.EncodeForPPU(tile2));
                rom.PutInBank(0x2, 0x9C00 + 0x06 * 16, rom.EncodeForPPU(tile1));
                rom.PutInBank(0x2, 0x9C00 + 0x07 * 16, rom.EncodeForPPU(tile3));
            }
        }