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);
        }
Exemple #2
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));
            }
        }