From 11dcc719fb9664a31e7d944a666d446fc0a82b8d Mon Sep 17 00:00:00 2001 From: aerinon Date: Tue, 22 Jun 2021 16:05:41 -0600 Subject: [PATCH] Stop attempting to download link sprite Create link sprite from local rom if missing Fixing output_path bugs in the adjuster and sprite display --- AdjusterMain.py | 1 + RELEASENOTES.md | 3 ++ Rom.py | 63 ++++++++++++++++++++++++++++++++ source/classes/SpriteSelector.py | 5 ++- source/gui/adjust/overview.py | 1 + 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/AdjusterMain.py b/AdjusterMain.py index 73f5cea2..bc463444 100644 --- a/AdjusterMain.py +++ b/AdjusterMain.py @@ -27,6 +27,7 @@ def adjust(args): 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) + output_path.cached_path = args.outputpath rom.write_to_file(output_path('%s.sfc' % outfilebase)) logger.info('Done. Enjoy.') diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7ece7e7b..c0aa736f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -18,6 +18,9 @@ Thanks to qadan, cheuer, & compiling * Reduce flashing option added * Sprite author credit added * Ranged Crystal switch rules tweaked + * Baserom update: includes Credits Speedup, reduced flashing option, msu resume (but turned off by default) + * Create link sprite's zspr from local ROM and no longer attempts to download it from website + * Some minor bug fixes * 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 aa1e816b..5c2fae02 100644 --- a/Rom.py +++ b/Rom.py @@ -1638,6 +1638,14 @@ def hud_format_text(text): def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, sprite, ow_palettes, uw_palettes, reduce_flashing): + + if not os.path.exists("data/sprites/official/001.link.1.zspr"): + dump_zspr(rom.orig_buffer[0x80000:0x87000], rom.orig_buffer[0xdd308:0xdd380], + rom.orig_buffer[0xdedf5:0xdedf9], "data/sprites/official/001.link.1.zspr", "Nintendo", "Link") + + # todo: implement a flag for msu resume delay + rom.write_bytes(0x18021D, [0, 0]) # default to off for now + if sprite and not isinstance(sprite, Sprite): sprite = Sprite(sprite) if os.path.isfile(sprite) else get_sprite_from_name(sprite) @@ -1736,6 +1744,61 @@ def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, spr rom.write_crc() +# .zspr file dumping logic copied with permission from SpriteSomething: +# https://github.com/Artheau/SpriteSomething/blob/master/source/meta/classes/spritelib.py#L443 (thanks miketrethewey!) +def dump_zspr(basesprite, basepalette, baseglove, outfilename, author_name, sprite_name): + palettes = basepalette + # Add glove data + palettes.extend(baseglove) + HEADER_STRING = b"ZSPR" + VERSION = 0x01 + SPRITE_TYPE = 0x01 # this format has "1" for the player sprite + RESERVED_BYTES = b'\x00\x00\x00\x00\x00\x00' + QUAD_BYTE_NULL_CHAR = b'\x00\x00\x00\x00' + DOUBLE_BYTE_NULL_CHAR = b'\x00\x00' + SINGLE_BYTE_NULL_CHAR = b'\x00' + + write_buffer = bytearray() + + write_buffer.extend(HEADER_STRING) + write_buffer.extend(struct.pack('B', VERSION)) # as_u8 + checksum_start = len(write_buffer) + write_buffer.extend(QUAD_BYTE_NULL_CHAR) # checksum + sprite_sheet_pointer = len(write_buffer) + write_buffer.extend(QUAD_BYTE_NULL_CHAR) + write_buffer.extend(struct.pack('