forked from KevinCathcart/ALttPEntranceRandomizer
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.5.2 release
- Loading branch information
Showing
99 changed files
with
2,190 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import os | ||
import logging | ||
import textwrap | ||
import sys | ||
|
||
from AdjusterMain import adjust | ||
|
||
class ArgumentDefaultsHelpFormatter(argparse.RawTextHelpFormatter): | ||
|
||
def _get_help_string(self, action): | ||
return textwrap.dedent(action.help) | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter) | ||
|
||
parser.add_argument('--rom', default='ER_base.sfc', help='Path to an ALttP JAP(1.0) rom to use as a base.') | ||
parser.add_argument('--loglevel', default='info', const='info', nargs='?', choices=['error', 'info', 'warning', 'debug'], help='Select level of logging for output.') | ||
parser.add_argument('--fastmenu', default='normal', const='normal', nargs='?', choices=['normal', 'instant', 'double', 'triple', 'quadruple', 'half'], | ||
help='''\ | ||
Select the rate at which the menu opens and closes. | ||
(default: %(default)s) | ||
''') | ||
parser.add_argument('--quickswap', help='Enable quick item swapping with L and R.', action='store_true') | ||
parser.add_argument('--disablemusic', help='Disables game music.', 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. (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, | ||
or 0x7078 (28792) bytes including palette data. | ||
Alternatively, can be a ALttP Rom patched with a Link | ||
sprite that will be extracted. | ||
''') | ||
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) | ||
sys.exit(1) | ||
if args.sprite is not None and not os.path.isfile(args.sprite): | ||
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite) | ||
sys.exit(1) | ||
|
||
# set up logger | ||
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel] | ||
logging.basicConfig(format='%(message)s', level=loglevel) | ||
|
||
adjust(args=args) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import time | ||
import logging | ||
|
||
from Utils import output_path | ||
from Rom import LocalRom, Sprite, apply_rom_settings | ||
|
||
|
||
def adjust(args): | ||
start = time.clock() | ||
logger = logging.getLogger('') | ||
logger.info('Patching ROM.') | ||
|
||
if args.sprite is not None: | ||
if isinstance(args.sprite, Sprite): | ||
sprite = args.sprite | ||
else: | ||
sprite = Sprite(args.sprite) | ||
else: | ||
sprite = None | ||
|
||
outfilebase = os.path.basename(args.rom)[:-4] + '_adjusted' | ||
|
||
if os.stat(args.rom).st_size == 2097152 and os.path.splitext(args.rom)[-1].lower() == '.sfc': | ||
rom = LocalRom(args.rom, False) | ||
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) | ||
|
||
rom.write_to_file(output_path('%s.sfc' % outfilebase)) | ||
|
||
logger.info('Done. Enjoy.') | ||
logger.debug('Total Time: %s', time.clock() - start) | ||
|
||
return args |
Oops, something went wrong.