LttP: remove rom handling from Main.py

This commit is contained in:
Fabian Dill 2021-09-18 22:13:19 +02:00
parent 6441f92c9f
commit f85dde6323
3 changed files with 16 additions and 11 deletions

View File

@ -86,7 +86,6 @@ def main(args, seed=None):
world.game = args.game.copy() world.game = args.game.copy()
world.set_options(args) world.set_options(args)
world.player_name = args.name.copy() world.player_name = args.name.copy()
world.alttp_rom = args.rom
world.enemizer = args.enemizercli world.enemizer = args.enemizercli
world.sprite = args.sprite.copy() world.sprite = args.sprite.copy()
world.glitch_triforce = args.glitch_triforce # This is enabled/disabled globally, no per player option. world.glitch_triforce = args.glitch_triforce # This is enabled/disabled globally, no per player option.

View File

@ -747,7 +747,7 @@ bonk_addresses = [0x4CF6C, 0x4CFBA, 0x4CFE0, 0x4CFFB, 0x4D018, 0x4D01B, 0x4D028,
def get_nonnative_item_sprite(item: str) -> int: 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 # https://discord.com/channels/731205301247803413/827141303330406408/852102450822905886
@ -785,7 +785,7 @@ def patch_rom(world, rom, player, enemized):
itemid = 0x33 itemid = 0x33
elif location.item.compass: elif location.item.compass:
itemid = 0x25 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 itemid = list(location_table.keys()).index(location.name) + 1
assert itemid < 0x100 assert itemid < 0x100
rom.write_byte(location.player_address, 0xFF) 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) rom.write_byte(0x18016A, 0x10 | ((0x01 if world.smallkey_shuffle[player] else 0x00)
| (0x02 if world.compass_shuffle[player] else 0x00) | (0x02 if world.compass_shuffle[player] else 0x00)
| (0x04 if world.map_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 rom.write_byte(0x18003B, 0x01 if world.map_shuffle[player] else 0x00) # maps showing crystals on overworld
# compasses showing dungeon count # 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[ rom.write_int16(0x18017C, get_reveal_bytes('Crystal 5') | get_reveal_bytes('Crystal 6') if world.map_shuffle[
player] else 0x0000) # Bomb Shop Reveal 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(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(0x180175, 0x01 if world.retro[player] else 0x00) # rupee bow
rom.write_byte(0x180176, 0x0A if world.retro[player] else 0x00) # wood arrow cost 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'}) entrances_to_hint.update({'Inverted Pyramid Entrance': 'The extra castle passage'})
else: else:
entrances_to_hint.update({'Pyramid Ledge': 'The pyramid ledge'}) 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: for entrance in all_entrances:
if entrance.name in entrances_to_hint: if entrance.name in entrances_to_hint:
if hint_count: if hint_count:
@ -2195,7 +2198,8 @@ def write_strings(rom, world, player):
if world.shuffle[player] in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed']: if world.shuffle[player] in ['vanilla', 'dungeonssimple', 'dungeonsfull', 'dungeonscrossed']:
locations_to_hint.extend(InconvenientVanillaLocations) locations_to_hint.extend(InconvenientVanillaLocations)
local_random.shuffle(locations_to_hint) 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]: for location in locations_to_hint[:hint_count]:
if location == 'Swamp Left': if location == 'Swamp Left':
if local_random.randint(0, 1): if local_random.randint(0, 1):
@ -2254,7 +2258,8 @@ def write_strings(rom, world, player):
if world.bigkey_shuffle[player]: if world.bigkey_shuffle[player]:
items_to_hint.extend(BigKeys) items_to_hint.extend(BigKeys)
local_random.shuffle(items_to_hint) 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: while hint_count > 0 and items_to_hint:
this_item = items_to_hint.pop(0) this_item = items_to_hint.pop(0)
this_location = world.find_items(this_item, player) 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"] file_name = options["lttp_options"]["rom_file"]
if not os.path.exists(file_name): if not os.path.exists(file_name):
file_name = Utils.local_path(file_name) file_name = Utils.local_path(file_name)
return file_name return file_name

View File

@ -14,7 +14,8 @@ from .Rules import set_rules
from .ItemPool import generate_itempool, difficulties from .ItemPool import generate_itempool, difficulties
from .Shops import create_shops, ShopSlotFill from .Shops import create_shops, ShopSlotFill
from .Dungeons import create_dungeons 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 import Patch
from .InvertedRegions import create_inverted_regions, mark_dark_world_regions 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.pot_shuffle[player] or world.bush_shuffle[player]
or world.killable_thieves[player]) or world.killable_thieves[player])
rom = LocalRom(world.alttp_rom) rom = LocalRom(get_base_rom_path())
patch_rom(world, rom, player, use_enemizer) patch_rom(world, rom, player, use_enemizer)