From 8af56fb5863cb039930e788d09573dc910ad31db Mon Sep 17 00:00:00 2001 From: AmazingAmpharos Date: Tue, 27 Feb 2018 20:26:33 -0600 Subject: [PATCH] Heart color changing A new dropdown option is added to allow the player to choose heart color between four options: red, blue, green, and yellow. The adjuster supports this feature as well. --- Adjuster.py | 2 ++ AdjusterMain.py | 2 +- EntranceRandomizer.py | 2 ++ Gui.py | 21 +++++++++++++++++++-- Main.py | 2 +- Rom.py | 19 ++++++++++++++++--- 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Adjuster.py b/Adjuster.py index 83d3868b..9ca22dd6 100755 --- a/Adjuster.py +++ b/Adjuster.py @@ -29,6 +29,8 @@ def main(): Select the rate at which the heart beep sound is played at low health. (default: %(default)s) ''') + parser.add_argument('--heartcolor', default='red', const='red', nargs='?', choices=['red', 'blue', 'green', 'yellow'], + help='Select the color of Link\'s heart meter. (default: %(default)s)') parser.add_argument('--sprite', help='''\ Path to a sprite sheet to use for Link. Needs to be in binary format and have a length of 0x7000 (28672) bytes, diff --git a/AdjusterMain.py b/AdjusterMain.py index b6c128fa..346e9301 100644 --- a/AdjusterMain.py +++ b/AdjusterMain.py @@ -26,7 +26,7 @@ def adjust(args): else: raise RuntimeError('Provided Rom is not a valid Link to the Past Randomizer Rom. Please provide one for adjusting.') - apply_rom_settings(rom, args.heartbeep, args.quickswap, args.fastmenu, args.disablemusic, sprite) + apply_rom_settings(rom, args.heartbeep, args.heartcolor, args.quickswap, args.fastmenu, args.disablemusic, sprite) rom.write_to_file(output_path('%s.sfc' % outfilebase)) diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index eb4d3358..bc6d8451 100755 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -187,6 +187,8 @@ def start(): Select the rate at which the heart beep sound is played at low health. (default: %(default)s) ''') + parser.add_argument('--heartcolor', default='red', const='red', nargs='?', choices=['red', 'blue', 'green', 'yellow'], + help='Select the color of Link\'s heart meter. (default: %(default)s)') parser.add_argument('--sprite', help='''\ Path to a sprite sheet to use for Link. Needs to be in binary format and have a length of 0x7000 (28672) bytes, diff --git a/Gui.py b/Gui.py index fef864aa..85cc0c4c 100755 --- a/Gui.py +++ b/Gui.py @@ -207,6 +207,13 @@ def guiMain(args=None): heartbeepLabel = Label(heartbeepFrame, text='Heartbeep sound rate') heartbeepLabel.pack(side=LEFT) + heartcolorFrame = Frame(drowDownFrame) + heartcolorVar = StringVar() + heartcolorVar.set('red') + heartcolorOptionMenu = OptionMenu(heartcolorFrame, heartcolorVar, 'red', 'blue', 'green', 'yellow') + heartcolorOptionMenu.pack(side=RIGHT) + heartcolorLabel = Label(heartcolorFrame, text='Heart color') + heartcolorLabel.pack(side=LEFT) fastMenuFrame = Frame(drowDownFrame) fastMenuVar = StringVar() @@ -225,6 +232,7 @@ def guiMain(args=None): algorithmFrame.pack(expand=True, anchor=E) shuffleFrame.pack(expand=True, anchor=E) heartbeepFrame.pack(expand=True, anchor=E) + heartcolorFrame.pack(expand=True, anchor=E) fastMenuFrame.pack(expand=True, anchor=E) bottomFrame = Frame(randomizerWindow) @@ -249,6 +257,7 @@ def guiMain(args=None): guiargs.algorithm = algorithmVar.get() guiargs.shuffle = shuffleVar.get() guiargs.heartbeep = heartbeepVar.get() + guiargs.heartcolor = heartcolorVar.get() guiargs.fastmenu = fastMenuVar.get() guiargs.create_spoiler = bool(createSpoilerVar.get()) guiargs.suppress_rom = bool(suppressRomVar.get()) @@ -353,6 +362,12 @@ def guiMain(args=None): heartbeepLabel2 = Label(heartbeepFrame2, text='Heartbeep sound rate') heartbeepLabel2.pack(side=LEFT) + heartcolorFrame2 = Frame(drowDownFrame2) + heartcolorOptionMenu2 = OptionMenu(heartcolorFrame2, heartcolorVar, 'red', 'blue', 'green', 'yellow') + heartcolorOptionMenu2.pack(side=RIGHT) + heartcolorLabel2 = Label(heartcolorFrame2, text='Heart color') + heartcolorLabel2.pack(side=LEFT) + fastMenuFrame2 = Frame(drowDownFrame2) fastMenuOptionMenu2 = OptionMenu(fastMenuFrame2, fastMenuVar, 'normal', 'instant', 'double', 'triple', 'quadruple', 'half') fastMenuOptionMenu2.pack(side=RIGHT) @@ -360,6 +375,7 @@ def guiMain(args=None): fastMenuLabel2.pack(side=LEFT) heartbeepFrame2.pack(expand=True, anchor=E) + heartcolorFrame2.pack(expand=True, anchor=E) fastMenuFrame2.pack(expand=True, anchor=E) bottomFrame2 = Frame(topFrame2) @@ -367,6 +383,7 @@ def guiMain(args=None): def adjustRom(): guiargs = Namespace guiargs.heartbeep = heartbeepVar.get() + guiargs.heartcolor = heartcolorVar.get() guiargs.fastmenu = fastMenuVar.get() guiargs.quickswap = bool(quickSwapVar.get()) guiargs.disablemusic = bool(disableMusicVar.get()) @@ -385,7 +402,7 @@ def guiMain(args=None): drowDownFrame2.pack(side=LEFT, pady=(0, 40)) rightHalfFrame2.pack(side=RIGHT) - topFrame2.pack(side=TOP, pady=30) + topFrame2.pack(side=TOP, pady=70) bottomFrame2.pack(side=BOTTOM, pady=(180, 0)) # Custom Controls @@ -954,7 +971,7 @@ def guiMain(args=None): itemList3.pack(side=LEFT, padx=(0,0)) itemList4.pack(side=LEFT, padx=(0,0)) itemList5.pack(side=LEFT, padx=(0,0)) - topFrame3.pack(side=TOP) + topFrame3.pack(side=TOP, pady=(17,0)) if args is not None: # load values from commandline args diff --git a/Main.py b/Main.py index 086df203..24a17ad7 100644 --- a/Main.py +++ b/Main.py @@ -117,7 +117,7 @@ def main(args, seed=None): rom = JsonRom() else: rom = LocalRom(args.rom) - patch_rom(world, rom, bytearray(logic_hash), args.heartbeep, sprite) + patch_rom(world, rom, bytearray(logic_hash), args.heartbeep, args.heartcolor, sprite) if args.jsonout: print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()})) else: diff --git a/Rom.py b/Rom.py index 38cf6e30..653e2e82 100644 --- a/Rom.py +++ b/Rom.py @@ -261,7 +261,7 @@ def int32_as_bytes(value): value = value & 0xFFFFFFFF return [value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF, (value >> 24) & 0xFF] -def patch_rom(world, rom, hashtable, beep='normal', sprite=None): +def patch_rom(world, rom, hashtable, beep='normal', color='red', sprite=None): # patch items for location in world.get_locations(): itemid = location.item.code if location.item is not None else 0x5A @@ -782,11 +782,11 @@ def patch_rom(world, rom, hashtable, beep='normal', sprite=None): # store hash table for main menu hash rom.write_bytes(0x187F00, hashtable) - apply_rom_settings(rom, beep, world.quickswap, world.fastmenu, world.disable_music, sprite) + apply_rom_settings(rom, beep, color, world.quickswap, world.fastmenu, world.disable_music, sprite) return rom -def apply_rom_settings(rom, beep, quickswap, fastmenu, disable_music, sprite): +def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, sprite): # enable instant item menu if fastmenu == 'instant': @@ -911,6 +911,19 @@ def apply_rom_settings(rom, beep, quickswap, fastmenu, disable_music, sprite): # set heart beep rate rom.write_byte(0x180033, {'off': 0x00, 'half': 0x40, 'quarter': 0x80, 'normal': 0x20}[beep]) + # set heart color + rom.write_byte(0x6FA1E, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA20, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA22, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA24, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA26, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA28, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA2A, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA2C, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA2E, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x6FA30, {'red': 0x24, 'blue': 0x2C, 'green': 0x3C, 'yellow': 0x28}[color]) + rom.write_byte(0x65561, {'red': 0x05, 'blue': 0x0D, 'green': 0x19, 'yellow': 0x09}[color]) + # write link sprite if required if sprite is not None: write_sprite(rom, sprite)