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.
This commit is contained in:
AmazingAmpharos 2018-02-27 20:26:33 -06:00 committed by GitHub
parent c26f325b0a
commit 8af56fb586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 7 deletions

View File

@ -29,6 +29,8 @@ def main():
Select the rate at which the heart beep sound is played at Select the rate at which the heart beep sound is played at
low health. (default: %(default)s) 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='''\ parser.add_argument('--sprite', help='''\
Path to a sprite sheet to use for Link. Needs to be in Path to a sprite sheet to use for Link. Needs to be in
binary format and have a length of 0x7000 (28672) bytes, binary format and have a length of 0x7000 (28672) bytes,

View File

@ -26,7 +26,7 @@ def adjust(args):
else: else:
raise RuntimeError('Provided Rom is not a valid Link to the Past Randomizer Rom. Please provide one for adjusting.') 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)) rom.write_to_file(output_path('%s.sfc' % outfilebase))

View File

@ -187,6 +187,8 @@ def start():
Select the rate at which the heart beep sound is played at Select the rate at which the heart beep sound is played at
low health. (default: %(default)s) 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='''\ parser.add_argument('--sprite', help='''\
Path to a sprite sheet to use for Link. Needs to be in Path to a sprite sheet to use for Link. Needs to be in
binary format and have a length of 0x7000 (28672) bytes, binary format and have a length of 0x7000 (28672) bytes,

21
Gui.py
View File

@ -207,6 +207,13 @@ def guiMain(args=None):
heartbeepLabel = Label(heartbeepFrame, text='Heartbeep sound rate') heartbeepLabel = Label(heartbeepFrame, text='Heartbeep sound rate')
heartbeepLabel.pack(side=LEFT) 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) fastMenuFrame = Frame(drowDownFrame)
fastMenuVar = StringVar() fastMenuVar = StringVar()
@ -225,6 +232,7 @@ def guiMain(args=None):
algorithmFrame.pack(expand=True, anchor=E) algorithmFrame.pack(expand=True, anchor=E)
shuffleFrame.pack(expand=True, anchor=E) shuffleFrame.pack(expand=True, anchor=E)
heartbeepFrame.pack(expand=True, anchor=E) heartbeepFrame.pack(expand=True, anchor=E)
heartcolorFrame.pack(expand=True, anchor=E)
fastMenuFrame.pack(expand=True, anchor=E) fastMenuFrame.pack(expand=True, anchor=E)
bottomFrame = Frame(randomizerWindow) bottomFrame = Frame(randomizerWindow)
@ -249,6 +257,7 @@ def guiMain(args=None):
guiargs.algorithm = algorithmVar.get() guiargs.algorithm = algorithmVar.get()
guiargs.shuffle = shuffleVar.get() guiargs.shuffle = shuffleVar.get()
guiargs.heartbeep = heartbeepVar.get() guiargs.heartbeep = heartbeepVar.get()
guiargs.heartcolor = heartcolorVar.get()
guiargs.fastmenu = fastMenuVar.get() guiargs.fastmenu = fastMenuVar.get()
guiargs.create_spoiler = bool(createSpoilerVar.get()) guiargs.create_spoiler = bool(createSpoilerVar.get())
guiargs.suppress_rom = bool(suppressRomVar.get()) guiargs.suppress_rom = bool(suppressRomVar.get())
@ -353,6 +362,12 @@ def guiMain(args=None):
heartbeepLabel2 = Label(heartbeepFrame2, text='Heartbeep sound rate') heartbeepLabel2 = Label(heartbeepFrame2, text='Heartbeep sound rate')
heartbeepLabel2.pack(side=LEFT) 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) fastMenuFrame2 = Frame(drowDownFrame2)
fastMenuOptionMenu2 = OptionMenu(fastMenuFrame2, fastMenuVar, 'normal', 'instant', 'double', 'triple', 'quadruple', 'half') fastMenuOptionMenu2 = OptionMenu(fastMenuFrame2, fastMenuVar, 'normal', 'instant', 'double', 'triple', 'quadruple', 'half')
fastMenuOptionMenu2.pack(side=RIGHT) fastMenuOptionMenu2.pack(side=RIGHT)
@ -360,6 +375,7 @@ def guiMain(args=None):
fastMenuLabel2.pack(side=LEFT) fastMenuLabel2.pack(side=LEFT)
heartbeepFrame2.pack(expand=True, anchor=E) heartbeepFrame2.pack(expand=True, anchor=E)
heartcolorFrame2.pack(expand=True, anchor=E)
fastMenuFrame2.pack(expand=True, anchor=E) fastMenuFrame2.pack(expand=True, anchor=E)
bottomFrame2 = Frame(topFrame2) bottomFrame2 = Frame(topFrame2)
@ -367,6 +383,7 @@ def guiMain(args=None):
def adjustRom(): def adjustRom():
guiargs = Namespace guiargs = Namespace
guiargs.heartbeep = heartbeepVar.get() guiargs.heartbeep = heartbeepVar.get()
guiargs.heartcolor = heartcolorVar.get()
guiargs.fastmenu = fastMenuVar.get() guiargs.fastmenu = fastMenuVar.get()
guiargs.quickswap = bool(quickSwapVar.get()) guiargs.quickswap = bool(quickSwapVar.get())
guiargs.disablemusic = bool(disableMusicVar.get()) guiargs.disablemusic = bool(disableMusicVar.get())
@ -385,7 +402,7 @@ def guiMain(args=None):
drowDownFrame2.pack(side=LEFT, pady=(0, 40)) drowDownFrame2.pack(side=LEFT, pady=(0, 40))
rightHalfFrame2.pack(side=RIGHT) rightHalfFrame2.pack(side=RIGHT)
topFrame2.pack(side=TOP, pady=30) topFrame2.pack(side=TOP, pady=70)
bottomFrame2.pack(side=BOTTOM, pady=(180, 0)) bottomFrame2.pack(side=BOTTOM, pady=(180, 0))
# Custom Controls # Custom Controls
@ -954,7 +971,7 @@ def guiMain(args=None):
itemList3.pack(side=LEFT, padx=(0,0)) itemList3.pack(side=LEFT, padx=(0,0))
itemList4.pack(side=LEFT, padx=(0,0)) itemList4.pack(side=LEFT, padx=(0,0))
itemList5.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: if args is not None:
# load values from commandline args # load values from commandline args

View File

@ -117,7 +117,7 @@ def main(args, seed=None):
rom = JsonRom() rom = JsonRom()
else: else:
rom = LocalRom(args.rom) 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: if args.jsonout:
print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()})) print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()}))
else: else:

19
Rom.py
View File

@ -261,7 +261,7 @@ def int32_as_bytes(value):
value = value & 0xFFFFFFFF value = value & 0xFFFFFFFF
return [value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF, (value >> 24) & 0xFF] 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 # patch items
for location in world.get_locations(): for location in world.get_locations():
itemid = location.item.code if location.item is not None else 0x5A 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 # store hash table for main menu hash
rom.write_bytes(0x187F00, hashtable) 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 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 # enable instant item menu
if fastmenu == 'instant': if fastmenu == 'instant':
@ -911,6 +911,19 @@ def apply_rom_settings(rom, beep, quickswap, fastmenu, disable_music, sprite):
# set heart beep rate # set heart beep rate
rom.write_byte(0x180033, {'off': 0x00, 'half': 0x40, 'quarter': 0x80, 'normal': 0x20}[beep]) 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 # write link sprite if required
if sprite is not None: if sprite is not None:
write_sprite(rom, sprite) write_sprite(rom, sprite)