From 23ffc61667a27542f8cacfe4ec6abecfd31280c0 Mon Sep 17 00:00:00 2001 From: aerinon Date: Mon, 7 Jun 2021 11:13:28 -0600 Subject: [PATCH] Sprite author credit Reduce flashing option --- Adjuster.py | 1 + AdjusterMain.py | 3 +- CLI.py | 4 ++- Main.py | 6 ++-- RELEASENOTES.md | 3 ++ Rom.py | 31 +++++++++++++++++-- resources/app/cli/args.json | 4 +++ resources/app/cli/lang/en.json | 3 +- .../app/gui/adjust/overview/widgets.json | 3 +- resources/app/gui/lang/en.json | 2 ++ .../gui/randomize/gameoptions/widgets.json | 3 +- source/classes/constants.py | 3 +- source/gui/adjust/overview.py | 3 +- 13 files changed, 57 insertions(+), 12 deletions(-) diff --git a/Adjuster.py b/Adjuster.py index 570bcef9..c6f42e6e 100755 --- a/Adjuster.py +++ b/Adjuster.py @@ -35,6 +35,7 @@ def main(): help='Select the color of Link\'s heart meter. (default: %(default)s)') parser.add_argument('--ow_palettes', default='default', choices=['default', 'random', 'blackout']) parser.add_argument('--uw_palettes', default='default', choices=['default', 'random', 'blackout']) + parser.add_argument('--reduce_flashing', help='Reduce some in-game flashing.', action='store_true') 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 b1d5cadf..73f5cea2 100644 --- a/AdjusterMain.py +++ b/AdjusterMain.py @@ -24,7 +24,8 @@ def adjust(args): if not hasattr(args,"sprite"): args.sprite = None - apply_rom_settings(rom, args.heartbeep, args.heartcolor, args.quickswap, args.fastmenu, args.disablemusic, args.sprite, args.ow_palettes, args.uw_palettes) + apply_rom_settings(rom, args.heartbeep, args.heartcolor, args.quickswap, args.fastmenu, args.disablemusic, + args.sprite, args.ow_palettes, args.uw_palettes, args.reduce_flashing) rom.write_to_file(output_path('%s.sfc' % outfilebase)) diff --git a/CLI.py b/CLI.py index 18692950..222f8a90 100644 --- a/CLI.py +++ b/CLI.py @@ -101,7 +101,8 @@ def parse_cli(argv, no_defaults=False): 'retro', 'accessibility', 'hints', 'beemizer', 'experimental', 'dungeon_counters', 'shufflebosses', 'shuffleenemies', 'enemy_health', 'enemy_damage', 'shufflepots', 'ow_palettes', 'uw_palettes', 'sprite', 'disablemusic', 'quickswap', 'fastmenu', 'heartcolor', 'heartbeep', - 'remote_items', 'shopsanity', 'keydropshuffle', 'mixed_travel', 'standardize_palettes', 'code']: + 'remote_items', 'shopsanity', 'keydropshuffle', 'mixed_travel', 'standardize_palettes', 'code', + 'reduce_flashing']: value = getattr(defaults, name) if getattr(playerargs, name) is None else getattr(playerargs, name) if player == 1: setattr(ret, name, {1: value}) @@ -187,6 +188,7 @@ def parse_settings(): "fastmenu": "normal", "ow_palettes": "default", "uw_palettes": "default", + "reduce_flashing": False, # Spoiler defaults to TRUE # Playthrough defaults to TRUE diff --git a/Main.py b/Main.py index bc621f7c..fb44aa7c 100644 --- a/Main.py +++ b/Main.py @@ -27,7 +27,7 @@ from Fill import sell_potions, sell_keys, balance_multiworld_progression, balanc from ItemList import generate_itempool, difficulties, fill_prizes, customize_shops from Utils import output_path, parse_player_names -__version__ = '0.4.0.6-u' +__version__ = '0.4.0.7-u' class EnemizerError(RuntimeError): @@ -280,7 +280,9 @@ def main(args, seed=None, fish=None): rom_names.append((player, team, list(rom.name))) world.spoiler.hashes[(player, team)] = get_hash_string(rom.hash) - apply_rom_settings(rom, args.heartbeep[player], args.heartcolor[player], args.quickswap[player], args.fastmenu[player], args.disablemusic[player], args.sprite[player], args.ow_palettes[player], args.uw_palettes[player]) + apply_rom_settings(rom, args.heartbeep[player], args.heartcolor[player], args.quickswap[player], + args.fastmenu[player], args.disablemusic[player], args.sprite[player], + args.ow_palettes[player], args.uw_palettes[player], args.reduce_flashing[player]) if args.jsonout: jsonout[f'patch_t{team}_p{player}'] = rom.patches diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8097eff2..9c3b9502 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -14,6 +14,9 @@ Thanks to qadan, cheuer, & compiling # Bug Fixes and Notes. +* 0.4.0.7 + * Reduce flashing option added + * Sprite author credit added * 0.4.0.6 * Hints now default to off * The maiden gives you a hint to the attic if you bring her to the unlit boss room diff --git a/Rom.py b/Rom.py index 9b06ec57..e9ca420d 100644 --- a/Rom.py +++ b/Rom.py @@ -495,8 +495,6 @@ class Sprite(object): sprite_name = read_utf16le(stream) author_name = read_utf16le(stream) - # Ignoring the Author Rom name for the time being. - real_csum = sum(filedata) % 0x10000 if real_csum != csum or real_csum ^ 0xFFFF != icsum: logger.warning('ZSPR file has incorrect checksum. It may be corrupted.') @@ -1638,7 +1636,8 @@ def hud_format_text(text): return output[:32] -def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, sprite, ow_palettes, uw_palettes): +def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, sprite, + ow_palettes, uw_palettes, reduce_flashing): if sprite and not isinstance(sprite, Sprite): sprite = Sprite(sprite) if os.path.isfile(sprite) else get_sprite_from_name(sprite) @@ -1695,6 +1694,32 @@ def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, spr if sprite is not None: write_sprite(rom, sprite) + # sprite author credits + padded_author = sprite.author_name if sprite is not None else "Nintendo" + padded_author = padded_author[:28] if len(padded_author) > 28 else padded_author + padded_author = padded_author.center(28).upper() + + def convert_char_to_credits(char): + char_map = { + " ": (0x9F, 0x9F), "0": (0x53, 0x79), "1": (0x54, 0x7A), "2": (0x55, 0x7B), "3": (0x56, 0x7C), + "4": (0x57, 0x7D), "5": (0x58, 0x7E), "6": (0x59, 0x7F), "7": (0x5A, 0x80), "8": (0x5B, 0x81), + "9": (0x5C, 0x82), "A": (0x5D, 0x83), "B": (0x5E, 0x84), "C": (0x5F, 0x85), "D": (0x60, 0x86), + "E": (0x61, 0x87), "F": (0x62, 0x88), "G": (0x63, 0x89), "H": (0x64, 0x8A), "I": (0x65, 0x8B), + "J": (0x66, 0x8C), "K": (0x67, 0x8D), "L": (0x68, 0x8E), "M": (0x69, 0x8F), "N": (0x6A, 0x90), + "O": (0x6B, 0x91), "P": (0x6C, 0x92), "Q": (0x6D, 0x93), "R": (0x6E, 0x94), "S": (0x6F, 0x95), + "T": (0x70, 0x96), "U": (0x71, 0x97), "V": (0x72, 0x98), "W": (0x73, 0x99), "X": (0x74, 0x9A), + "Y": (0x75, 0x9B), "Z": (0x76, 0x9C), "'": (0x77, 0x9d), ".": (0xA0, 0xC0), "/": (0xA2, 0xC2), + ":": (0xA3, 0xC3), "_": (0xA6, 0xC6)} + return char_map[char] if char in char_map else (0x9F, 0x9F) + + character_bytes = map(convert_char_to_credits, padded_author) + for i, pair in enumerate(character_bytes): + rom.write_byte(0x118002 + i, pair[0]) + rom.write_byte(0x118020 + i, pair[1]) + + if reduce_flashing: + rom.write_byte(0x18017f, 1) + default_ow_palettes(rom) if ow_palettes == 'random': randomize_ow_palettes(rom) diff --git a/resources/app/cli/args.json b/resources/app/cli/args.json index a41adb17..0dc97277 100644 --- a/resources/app/cli/args.json +++ b/resources/app/cli/args.json @@ -195,6 +195,10 @@ "action": "store_true", "type": "bool" }, + "reduce_flashing": { + "action": "store_true", + "type": "bool" + }, "mapshuffle": { "action": "store_true", "type": "bool" diff --git a/resources/app/cli/lang/en.json b/resources/app/cli/lang/en.json index 183b3c2e..145667ef 100644 --- a/resources/app/cli/lang/en.json +++ b/resources/app/cli/lang/en.json @@ -278,7 +278,7 @@ "Include the Ganon's Tower and Pyramid Hole in the", "entrance shuffle pool. (default: %(default)s)" ], - "shufflelink": [ + "shufflelinks": [ "Include Link's House in the entrance shuffle pool. (default: %(default)s)" ], "heartbeep": [ @@ -293,6 +293,7 @@ "Alternatively, can be a ALttP Rom patched with a Link", "sprite that will be extracted." ], + "reduce_flashing": [ "Reduce some in-game flashing (default: %(default)s)" ], "create_rom": [ "Create an output rom file. (default: %(default)s)" ], "gui": [ "Launch the GUI. (default: %(default)s)" ], "jsonout": [ diff --git a/resources/app/gui/adjust/overview/widgets.json b/resources/app/gui/adjust/overview/widgets.json index f56bfd08..b61fff0e 100644 --- a/resources/app/gui/adjust/overview/widgets.json +++ b/resources/app/gui/adjust/overview/widgets.json @@ -1,7 +1,8 @@ { "checkboxes": { "nobgm": { "type": "checkbox" }, - "quickswap": { "type": "checkbox" } + "quickswap": { "type": "checkbox" }, + "reduce_flashing": {"type": "checkbox"} }, "leftAdjustFrame": { "heartcolor": { diff --git a/resources/app/gui/lang/en.json b/resources/app/gui/lang/en.json index aa6cd6dc..8ae98e81 100644 --- a/resources/app/gui/lang/en.json +++ b/resources/app/gui/lang/en.json @@ -2,6 +2,7 @@ "gui": { "adjust.nobgm": "Disable Music & MSU-1", "adjust.quickswap": "L/R Quickswapping", + "adjust.reduce_flashing": "Reduce Flashing", "adjust.heartcolor": "Heart Color", "adjust.heartcolor.red": "Red", @@ -131,6 +132,7 @@ "randomizer.gameoptions.nobgm": "Disable Music & MSU-1", "randomizer.gameoptions.quickswap": "L/R Quickswapping", + "randomizer.gameoptions.reduce_flashing": "Reduce Flashing", "randomizer.gameoptions.heartcolor": "Heart Color", "randomizer.gameoptions.heartcolor.red": "Red", diff --git a/resources/app/gui/randomize/gameoptions/widgets.json b/resources/app/gui/randomize/gameoptions/widgets.json index 7f612cb4..63556e0f 100644 --- a/resources/app/gui/randomize/gameoptions/widgets.json +++ b/resources/app/gui/randomize/gameoptions/widgets.json @@ -1,7 +1,8 @@ { "checkboxes": { "nobgm": { "type": "checkbox" }, - "quickswap": { "type": "checkbox" } + "quickswap": { "type": "checkbox" }, + "reduce_flashing": {"type": "checkbox"} }, "leftRomOptionsFrame": { "heartcolor": { diff --git a/source/classes/constants.py b/source/classes/constants.py index c0e95861..3e59af3c 100644 --- a/source/classes/constants.py +++ b/source/classes/constants.py @@ -105,7 +105,8 @@ SETTINGSTOPROCESS = { "heartbeep": "heartbeep", "menuspeed": "fastmenu", "owpalettes": "ow_palettes", - "uwpalettes": "uw_palettes" + "uwpalettes": "uw_palettes", + "reduce_flashing": "reduce_flashing" }, "generation": { "createspoiler": "create_spoiler", diff --git a/source/gui/adjust/overview.py b/source/gui/adjust/overview.py index b741f63e..c44e169f 100644 --- a/source/gui/adjust/overview.py +++ b/source/gui/adjust/overview.py @@ -101,7 +101,8 @@ def adjust_page(top, parent, settings): "owpalettes": "ow_palettes", "uwpalettes": "uw_palettes", "quickswap": "quickswap", - "nobgm": "disablemusic" + "nobgm": "disablemusic", + "reduce_flashing": "reduce_flashing", } guiargs = Namespace() for option in options: