From f85dde63236b6deef6a779f58844359b21a0a2f3 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 18 Sep 2021 22:13:19 +0200 Subject: [PATCH] LttP: remove rom handling from Main.py --- Main.py | 1 - worlds/alttp/Rom.py | 21 +++++++++++++-------- worlds/alttp/__init__.py | 5 +++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Main.py b/Main.py index e9ca59b0..a93eea15 100644 --- a/Main.py +++ b/Main.py @@ -86,7 +86,6 @@ def main(args, seed=None): world.game = args.game.copy() world.set_options(args) world.player_name = args.name.copy() - world.alttp_rom = args.rom world.enemizer = args.enemizercli world.sprite = args.sprite.copy() world.glitch_triforce = args.glitch_triforce # This is enabled/disabled globally, no per player option. diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index a42712e4..120fa87a 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -747,7 +747,7 @@ bonk_addresses = [0x4CF6C, 0x4CFBA, 0x4CFE0, 0x4CFFB, 0x4D018, 0x4D01B, 0x4D028, def get_nonnative_item_sprite(item: str) -> int: - return 0x6B # set all non-native sprites to Power Star as per 13 to 2 vote at + return 0x6B # set all non-native sprites to Power Star as per 13 to 2 vote at # https://discord.com/channels/731205301247803413/827141303330406408/852102450822905886 @@ -785,7 +785,7 @@ def patch_rom(world, rom, player, enemized): itemid = 0x33 elif location.item.compass: itemid = 0x25 - if world.worlds[player].remote_items: # remote items does not currently work + if world.worlds[player].remote_items: # remote items does not currently work itemid = list(location_table.keys()).index(location.name) + 1 assert itemid < 0x100 rom.write_byte(location.player_address, 0xFF) @@ -1495,7 +1495,8 @@ def patch_rom(world, rom, player, enemized): rom.write_byte(0x18016A, 0x10 | ((0x01 if world.smallkey_shuffle[player] else 0x00) | (0x02 if world.compass_shuffle[player] else 0x00) | (0x04 if world.map_shuffle[player] else 0x00) - | (0x08 if world.bigkey_shuffle[player] else 0x00))) # free roaming item text boxes + | (0x08 if world.bigkey_shuffle[ + player] else 0x00))) # free roaming item text boxes rom.write_byte(0x18003B, 0x01 if world.map_shuffle[player] else 0x00) # maps showing crystals on overworld # compasses showing dungeon count @@ -1550,7 +1551,8 @@ def patch_rom(world, rom, player, enemized): rom.write_int16(0x18017C, get_reveal_bytes('Crystal 5') | get_reveal_bytes('Crystal 6') if world.map_shuffle[ player] else 0x0000) # Bomb Shop Reveal - rom.write_byte(0x180172, 0x01 if world.smallkey_shuffle[player] == smallkey_shuffle.option_universal else 0x00) # universal keys + rom.write_byte(0x180172, 0x01 if world.smallkey_shuffle[ + player] == smallkey_shuffle.option_universal else 0x00) # universal keys rom.write_byte(0x18637E, 0x01 if world.retro[player] else 0x00) # Skip quiver in item shops once bought rom.write_byte(0x180175, 0x01 if world.retro[player] else 0x00) # rupee bow rom.write_byte(0x180176, 0x0A if world.retro[player] else 0x00) # wood arrow cost @@ -2178,7 +2180,8 @@ def write_strings(rom, world, player): entrances_to_hint.update({'Inverted Pyramid Entrance': 'The extra castle passage'}) else: entrances_to_hint.update({'Pyramid Ledge': 'The pyramid ledge'}) - hint_count = 4 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed'] else 0 + hint_count = 4 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', + 'dungeonscrossed'] else 0 for entrance in all_entrances: if entrance.name in entrances_to_hint: if hint_count: @@ -2195,7 +2198,8 @@ def write_strings(rom, world, player): if world.shuffle[player] in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed']: locations_to_hint.extend(InconvenientVanillaLocations) local_random.shuffle(locations_to_hint) - hint_count = 3 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed'] else 5 + hint_count = 3 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', + 'dungeonscrossed'] else 5 for location in locations_to_hint[:hint_count]: if location == 'Swamp Left': if local_random.randint(0, 1): @@ -2254,7 +2258,8 @@ def write_strings(rom, world, player): if world.bigkey_shuffle[player]: items_to_hint.extend(BigKeys) local_random.shuffle(items_to_hint) - hint_count = 5 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed'] else 8 + hint_count = 5 if world.shuffle[player] not in ['vanilla', 'dungeonssimple', 'dungeonsfull', + 'dungeonscrossed'] else 8 while hint_count > 0 and items_to_hint: this_item = items_to_hint.pop(0) this_location = world.find_items(this_item, player) @@ -2953,4 +2958,4 @@ def get_base_rom_path(file_name: str = "") -> str: file_name = options["lttp_options"]["rom_file"] if not os.path.exists(file_name): file_name = Utils.local_path(file_name) - return file_name \ No newline at end of file + return file_name diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index 5257178a..1c5d7fd4 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -14,7 +14,8 @@ from .Rules import set_rules from .ItemPool import generate_itempool, difficulties from .Shops import create_shops, ShopSlotFill from .Dungeons import create_dungeons -from .Rom import LocalRom, patch_rom, patch_race_rom, patch_enemizer, apply_rom_settings, get_hash_string +from .Rom import LocalRom, patch_rom, patch_race_rom, patch_enemizer, apply_rom_settings, get_hash_string, \ + get_base_rom_path import Patch from .InvertedRegions import create_inverted_regions, mark_dark_world_regions @@ -261,7 +262,7 @@ class ALTTPWorld(World): or world.pot_shuffle[player] or world.bush_shuffle[player] or world.killable_thieves[player]) - rom = LocalRom(world.alttp_rom) + rom = LocalRom(get_base_rom_path()) patch_rom(world, rom, player, use_enemizer)