Skip to content

Commit

Permalink
Make script auto-rename ROM to shuffled.sfc
Browse files Browse the repository at this point in the history
Nice quality of life feature, also redoing documentation and bumping version to 0.4.
  • Loading branch information
krelbel committed Dec 10, 2020
1 parent 160f498 commit 77b08b0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 69 deletions.
94 changes: 61 additions & 33 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import glob
import sys

__version__ = '0.3-dev'
__version__ = '0.4-dev'

# Creates a shuffled MSU-1 pack for ALttP Randomizer from one or more source
# MSU-1 packs.
Expand All @@ -18,50 +18,58 @@
# 1) Copy this script to a new subdirectory in the directory containing all
# of your current MSU packs
#
# 2) Copy the ALttP Randomizer ROM (with background music enabled) to this
# directory. The script will rename it to "shuffled.sfc". The original name
# is printed to "output.log" (handy for retrieving spoilers). If you don't
# copy the ROM before running the script, you need to rename the ROM to
# "shuffled.sfc" yourself. The script will warn before overwriting
# "shuffled.sfc" if it already exists.
#
# 2) Run Main.py to execute the script to delete any old pack in this directory
# and generate a new one. Track names picked will be saved in "output.log"
# (cleared on reruns)
#
# - By default, the generated pack will pick each track from a matching
# track number in a random MSU pack in the parent directory of this
# script. For dungeon-specific or boss-specific tracks, if the random
# pack chosen isn't an extended MSU pack, the generic dungeon/boss music
# is chosen instead.
# 3) Load "shuffled.sfc" in an MSU-compatible emulator (works well with
# Snes9x 1.60)
#
# Note that if you ONLY have non-extended packs, this
# default behavior will create an extended pack, which (like all extended
# packs) prevents you from using music cues to distinguish pendant from
# crystal dungeons. If you want this, use --basicshuffle instead.
# Additional options/usage notes:
#
# - If run in the command line as "python Main.py --basicshuffle", each
# track is chosen from the same track from a random pack. If you have any
# extended packs, the dungeon/boss themes from non-extended packs will
# never be chosen.
# - By default, the generated pack will pick each track from a matching
# track number in a random MSU pack in the parent directory of this
# script. For dungeon-specific or boss-specific tracks, if the random
# pack chosen isn't an extended MSU pack, the generic dungeon/boss music
# is chosen instead.
#
# - If run in the command line as "python Main.py --fullshuffle", behavior
# for non-looping tracks (short fanfares, portals, etc.) remains as
# default, but looping tracks will be in shuffled order, so each track
# in the generated pack is chosen from a random track number in a random
# MSU pack. Pick this if you like shop music in Ganon's Tower.
# Note that if you ONLY have non-extended packs, this
# default behavior will create an extended pack, which (like all extended
# packs) prevents you from using music cues to distinguish pendant from
# crystal dungeons. If you want this, use --basicshuffle instead.
#
# - If run in the command line as
# "python Main.py --singleshuffle ../your-msu-pack-name-here", behavior is
# the same as with --fullshuffle, but a single MSU pack of your choice is
# chosen as the shuffled source for all tracks in the generated pack.
# - If run in the command line as "python Main.py --basicshuffle", each
# track is chosen from the same track from a random pack. If you have any
# extended packs, the dungeon/boss themes from non-extended packs will
# never be chosen.
#
# Debugging options (not necessary for normal use):
# - If run in the command line as "python Main.py --fullshuffle", behavior
# for non-looping tracks (short fanfares, portals, etc.) remains as
# default, but looping tracks will be in shuffled order, so each track
# in the generated pack is chosen from a random track number in a random
# MSU pack. Pick this if you like shop music in Ganon's Tower.
#
# - If run in the command line as
# "python Main.py --singleshuffle ../your-msu-pack-name-here", behavior is
# the same as with --fullshuffle, but a single MSU pack of your choice is
# chosen as the shuffled source for all tracks in the generated pack.
#
# - This script uses hardlinks instead of copies by default to reduce disk
# usage and increase speed; the --realcopy option can be used to create
# real copies instead of hardlinks.
# Debugging options (not necessary for normal use):
#
# - The --debug option can be used to make this script print the filesystem
# commands (deleting, creating, renaming files) it would have executed
# instead of executing them.
# - This script uses hardlinks instead of copies by default to reduce disk
# usage and increase speed; the --realcopy option can be used to create
# real copies instead of hardlinks.
#
# 3) Copy the ALttP Randomizer ROM (with background music enabled) to this
# directory and rename it to "shuffled.sfc". Load it in an MSU-compatible
# emulator (works well with Snes9x 1.60)
# - The --debug option can be used to make this script print the filesystem
# commands (deleting, creating, renaming files) it would have executed
# instead of executing them.

# Tracklist from https://pastebin.com/zjqQZu5M
titles = [
Expand Down Expand Up @@ -202,6 +210,26 @@ def delete_old_msu(args):
if (args.debug):
logger.info("DEBUG MODE: Printing instead of executing.")

foundsrcrom = False
foundshuffled = False
for path in glob.glob('*.sfc'):
if (os.path.basename(str(path)) != "shuffled.sfc"):
srcrom = path
foundsrcrom = True
else:
foundshuffled = True

if foundsrcrom:
replace = "Y"
if foundshuffled:
replace = str(input("Replace shuffled.sfc with " + os.path.basename(srcrom) + "? [Y/n]") or "Y")
if (replace == "Y") or (replace == "y"):
if (args.debug):
logger.info("DEBUG: Would rename " + os.path.basename(srcrom) + " to shuffled.sfc.")
else:
logger.info("Renaming " + os.path.basename(srcrom) + " to shuffled.sfc.")
shutil.move(srcrom, "./shuffled.sfc")

for path in glob.glob('shuffled-*.pcm'):
if (args.debug):
logger.info("DEBUG: Would remove " + str(path))
Expand Down
80 changes: 44 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,56 @@ Usage:
1) Copy this script to a new subdirectory in the directory containing all
of your current MSU packs

2) Copy the ALttP Randomizer ROM (with background music enabled) to this
directory. The script will rename it to "shuffled.sfc". The original name
is printed to "output.log" (handy for retrieving spoilers). If you don't
copy the ROM before running the script, you need to rename the ROM to
"shuffled.sfc" yourself. The script will warn before overwriting
"shuffled.sfc" if it already exists.

2) Run Main.py to execute the script to delete any old pack in this directory
and generate a new one. Track names picked will be saved in "output.log"
(cleared on reruns)

- By default, the generated pack will pick each track from a matching
track number in a random MSU pack in the parent directory of this
script. For dungeon-specific or boss-specific tracks, if the random
pack chosen isn't an extended MSU pack, the generic dungeon/boss music
is chosen instead.

Note that if you ONLY have non-extended packs, this
default behavior will create an extended pack, which (like all extended
packs) prevents you from using music cues to distinguish pendant from
crystal dungeons. If you want this, use --basicshuffle instead.

- If run in the command line as "python Main.py --basicshuffle", each
track is chosen from the same track from a random pack. If you have any
extended packs, the dungeon/boss themes from non-extended packs will
never be chosen.

- If run in the command line as "python Main.py --fullshuffle", behavior
for non-looping tracks (short fanfares, portals, etc.) remains as
default, but looping tracks will be in shuffled order, so each track
in the generated pack is chosen from a random track number in a random
MSU pack. Pick this if you like shop music in Ganon's Tower.

- If run in the command line as
"python Main.py --singleshuffle ../your-msu-pack-name-here", behavior is
the same as with --fullshuffle, but a single MSU pack of your choice is
chosen as the shuffled source for all tracks in the generated pack.
3) Load "shuffled.sfc" in an MSU-compatible emulator (works well with
Snes9x 1.60)

Debugging options (not necessary for normal use):
Additional options/usage notes:

- By default, the generated pack will pick each track from a matching
track number in a random MSU pack in the parent directory of this
script. For dungeon-specific or boss-specific tracks, if the random
pack chosen isn't an extended MSU pack, the generic dungeon/boss music
is chosen instead.

Note that if you ONLY have non-extended packs, this
default behavior will create an extended pack, which (like all extended
packs) prevents you from using music cues to distinguish pendant from
crystal dungeons. If you want this, use --basicshuffle instead.

- This script uses hardlinks instead of copies by default to reduce disk
usage and increase speed; the --realcopy option can be used to create
real copies instead of hardlinks.
- If run in the command line as "python Main.py --basicshuffle", each
track is chosen from the same track from a random pack. If you have any
extended packs, the dungeon/boss themes from non-extended packs will
never be chosen.

- If run in the command line as "python Main.py --fullshuffle", behavior
for non-looping tracks (short fanfares, portals, etc.) remains as
default, but looping tracks will be in shuffled order, so each track
in the generated pack is chosen from a random track number in a random
MSU pack. Pick this if you like shop music in Ganon's Tower.

- If run in the command line as
"python Main.py --singleshuffle ../your-msu-pack-name-here", behavior is
the same as with --fullshuffle, but a single MSU pack of your choice is
chosen as the shuffled source for all tracks in the generated pack.

Debugging options (not necessary for normal use):

- The --debug option can be used to make this script print the filesystem
commands (deleting, creating, renaming files) it would have executed
instead of executing them.
- This script uses hardlinks instead of copies by default to reduce disk
usage and increase speed; the --realcopy option can be used to create
real copies instead of hardlinks.

3) Copy the ALttP Randomizer ROM (with background music enabled) to this
directory and rename it to "shuffled.sfc". Load it in an MSU-compatible
emulator (works well with Snes9x 1.60)
- The --debug option can be used to make this script print the filesystem
commands (deleting, creating, renaming files) it would have executed
instead of executing them.

0 comments on commit 77b08b0

Please sign in to comment.