From 7af2425c9f7e5da6ce1140b7dbc37c393d877a82 Mon Sep 17 00:00:00 2001 From: LLCoolDave Date: Thu, 25 May 2017 12:50:42 +0200 Subject: [PATCH] Add option to enable item quickswap with L/R --- Main.py | 9 +++++---- Rom.py | 28 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Main.py b/Main.py index 86994893..3b41305d 100644 --- a/Main.py +++ b/Main.py @@ -14,7 +14,7 @@ import os __version__ = '0.1-dev' -def main(seed=None, shuffle='default', logic='noglitches', mode='standard', difficulty='normal', goal='ganon', algo='regular', spoiler=True, base_rom='Open_Base_Rom.sfc'): +def main(seed=None, shuffle='default', logic='noglitches', mode='standard', difficulty='normal', goal='ganon', algo='regular', spoiler=True, base_rom='Base_Rom.sfc', quickswap=False): start = time.clock() # initialize the world @@ -62,7 +62,7 @@ def main(seed=None, shuffle='default', logic='noglitches', mode='standard', diff logger.info('Patching ROM.') rom = bytearray(open(base_rom, 'rb').read()) - patched_rom = patch_rom(world, rom) + patched_rom = patch_rom(world, rom, quickswap) outfilebase = 'ER_%s_%s_%s_%s' % (world.mode, world.goal, world.shuffle, world.seed) @@ -406,6 +406,7 @@ if __name__ == '__main__': parser.add_argument('--loglevel', default='info', const='info', nargs='?', choices=['error', 'info', 'warning', 'debug'], help='Select level of logging for output.') parser.add_argument('--seed', help='Define seed number to generate.', type=int) parser.add_argument('--count', help='Use to batch generate multiple seeds with same settings. If --seed is provided, it will be used for the first seed, then used to derive the next seed (i.e. generating 10 seeds with --seed given will produce the same 10 (different) roms each time).', type=int) + parser.add_argument('--quickswap', help='Enable quick item swapping with L and R.', action='store_true') args = parser.parse_args() if not os.path.isfile(args.rom): @@ -419,7 +420,7 @@ if __name__ == '__main__': if args.count is not None: seed = args.seed for i in range(args.count): - main(seed=seed, logic=args.logic, mode=args.mode, goal=args.goal, difficulty=args.difficulty, algo=args.algorithm, shuffle=args.shuffle, base_rom=args.rom, spoiler=args.create_spoiler) + main(seed=seed, logic=args.logic, mode=args.mode, goal=args.goal, difficulty=args.difficulty, algo=args.algorithm, shuffle=args.shuffle, base_rom=args.rom, spoiler=args.create_spoiler, quickswap=args.quickswap) seed = random.randint(0, 999999999) else: - main(seed=args.seed, logic=args.logic, mode=args.mode, goal=args.goal, difficulty=args.difficulty, algo=args.algorithm, shuffle=args.shuffle, base_rom=args.rom, spoiler=args.create_spoiler) + main(seed=args.seed, logic=args.logic, mode=args.mode, goal=args.goal, difficulty=args.difficulty, algo=args.algorithm, shuffle=args.shuffle, base_rom=args.rom, spoiler=args.create_spoiler, quickswap=args.quickswap) diff --git a/Rom.py b/Rom.py index eeff2030..afbb1323 100644 --- a/Rom.py +++ b/Rom.py @@ -4,7 +4,7 @@ from Text import string_to_alttp_text, text_addresses, altar_text import random -def patch_rom(world, rom): +def patch_rom(world, rom, quickswap=False): # patch items for location in world.get_locations(): if location.name == 'Ganon': @@ -196,6 +196,27 @@ def patch_rom(world, rom): else: write_byte(rom, 0x4E3BB, 0xEB) + # disable open door sprites when exiting caves + if world.shuffle not in ['default', 'dungeonssimple', 'dungeonsfull']: + for i in range(0x85): + write_byte(rom, 0x15274 + i, 0x00) + + # enable quick item swapping with L and R (ported by Amazing Ampharos) + if quickswap: + write_bytes(rom, 0x107fb, [0x22, 0x50, 0xFF, 0x1F]) + write_bytes(rom, 0x12451, [0x22, 0x50, 0xFF, 0x1F]) + write_bytes(rom, 0xfff50, [0x20, 0x58, 0xFF, 0xA5, 0xF6, 0x29, 0x40, 0x6B, 0xA5, 0xF6, 0x89, 0x10, 0xF0, 0x03, 0x4C, 0x69, + 0xFF, 0x89, 0x20, 0xF0, 0x03, 0x4C, 0xAA, 0xFF, 0x60, 0xAD, 0x02, 0x02, 0xF0, 0x3B, 0xDA, 0xAA, + 0xE0, 0x0F, 0xF0, 0x14, 0xE0, 0x10, 0xF0, 0x14, 0xE0, 0x14, 0xD0, 0x02, 0xA2, 0x00, 0xE8, 0xBF, + 0x3F, 0xF3, 0x7E, 0xF0, 0xEB, 0x4C, 0xEB, 0xFF, 0xA2, 0x01, 0x80, 0x0A, 0xAF, 0x4F, 0xF3, 0x7E, + 0xAA, 0xE0, 0x04, 0xF0, 0x10, 0xE8, 0xBF, 0x5B, 0xF3, 0x7E, 0xF0, 0xF5, 0x8A, 0x8F, 0x4F, 0xF3, + 0x7E, 0xA2, 0x10, 0x80, 0xE0, 0xA2, 0x11, 0x80, 0xD6, 0x60, 0xAD, 0x02, 0x02, 0xF0, 0x3B, 0xDA, + 0xAA, 0xE0, 0x11, 0xF0, 0x14, 0xE0, 0x10, 0xF0, 0x14, 0xE0, 0x01, 0xD0, 0x02, 0xA2, 0x15, 0xCA, + 0xBF, 0x3F, 0xF3, 0x7E, 0xF0, 0xEB, 0x4C, 0xEB, 0xFF, 0xA2, 0x04, 0x80, 0x0A, 0xAF, 0x4F, 0xF3, + 0x7E, 0xAA, 0xE0, 0x01, 0xF0, 0x10, 0xCA, 0xBF, 0x5B, 0xF3, 0x7E, 0xF0, 0xF5, 0x8A, 0x8F, 0x4F, + 0xF3, 0x7E, 0xA2, 0x10, 0x80, 0xE0, 0xA2, 0x0F, 0x80, 0xD6, 0x60, 0xA9, 0x20, 0x8D, 0x2F, 0x01, + 0x8E, 0x02, 0x02, 0x22, 0x7F, 0xDB, 0x0D, 0xFA, 0x60, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]) + # write strings write_string_to_rom(rom, 'Ganon2', 'Did you find the silver arrows in Hyrule?') write_string_to_rom(rom, 'Uncle', 'Good Luck!\nYou will need it.') @@ -209,11 +230,6 @@ def patch_rom(world, rom): write_string_to_rom(rom, 'Ganon1', '\n\n\n\n\n\n\n\n\nWhy are you reading an empty textbox?') write_string_to_rom(rom, 'TavernMan', 'Did you know that talking to random NPCs wastes time in a race? I hope this information may be of use to you in the future.') - # disable open door sprites when exiting caves - if world.shuffle not in ['default', 'dungeonssimple', 'dungeonsfull']: - for i in range(0x85): - write_byte(rom, 0x15274 + i, 0x00) - altaritem = world.get_location('Altar').item.name if world.get_location('Altar').item is not None else 'Nothing' write_string_to_rom(rom, 'Altar', altar_text.get(altaritem, 'Unknown Item.'))