Add support for custom Link sprites.

This commit is contained in:
LLCoolDave 2017-05-26 18:39:32 +02:00
parent 5207ccd8fd
commit c58e63b695
2 changed files with 16 additions and 2 deletions

12
Main.py
View File

@ -70,8 +70,13 @@ def main(args, seed=None):
logger.info('Patching ROM.')
if args.sprite is not None:
sprite = bytearray(open(args.sprite, 'rb').read())
else:
sprite = None
rom = bytearray(open(args.rom, 'rb').read())
patched_rom = patch_rom(world, rom, logic_hash, args.quickswap, args.heartbeep)
patched_rom = patch_rom(world, rom, logic_hash, args.quickswap, args.heartbeep, sprite)
outfilebase = 'ER_%s_%s_%s_%s' % (world.mode, world.goal, world.shuffle, world.seed)
@ -394,11 +399,16 @@ if __name__ == '__main__':
parser.add_argument('--nodungeonitems', help='Remove Maps and Compasses from Itempool, replacing them by empty slots.', action='store_true')
parser.add_argument('--heartbeep', default='normal', const='normal', nargs='?', choices=['normal', 'half', 'quarter', 'off'],
help='Select the rate at which the heart beep sound is played at low health.')
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.')
args = parser.parse_args()
# ToDo: Validate files further than mere existance
if not os.path.isfile(args.rom):
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
exit(1)
if args.sprite is not None and not os.path.isfile(args.rom):
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
exit(1)
# set up logger
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]

6
Rom.py
View File

@ -6,7 +6,7 @@ from Text import KingsReturn_texts, Sanctuary_texts, Kakariko_texts, Blacksmiths
import random
def patch_rom(world, rom, hashtable, quickswap=False, beep='normal'):
def patch_rom(world, rom, hashtable, quickswap=False, beep='normal', sprite=None):
# patch items
for location in world.get_locations():
if location.name == 'Ganon':
@ -233,6 +233,10 @@ def patch_rom(world, rom, hashtable, quickswap=False, beep='normal'):
# store hash table for main menu hash
write_bytes(rom, 0x181000, hashtable)
# write link sprite if required
if sprite is not None:
write_bytes(rom, 0x80000, sprite)
return rom