Skip to content

Instantly share code, notes, and snippets.

@Sammi-Husky
Last active May 15, 2020 01:35
Show Gist options
  • Save Sammi-Husky/60bdbfe3226987d1cb0826c55b31e97e to your computer and use it in GitHub Desktop.
Save Sammi-Husky/60bdbfe3226987d1cb0826c55b31e97e to your computer and use it in GitHub Desktop.
Converts brawl .map files to dolphin readable form.
import sys
import io
import argparse
from pathlib import Path
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)
if __name__ == '__main__':
parser = MyParser(usage='\n %(prog)s [options] <input file> [optional: <output file>]')
parser.add_argument('file', help=".map file to convert", metavar='<input file>')
parser.add_argument('-a', '--address', help="Load address of the .text section for this module in dolphin", metavar='address', dest='address', nargs='?', default=None)
parser.add_argument(help="The output .map file. Defaults to <inputfile>.dolphin.map", nargs='?', dest='output', metavar='<output file>', default=None)
args = parser.parse_args()
outpath = args.output if args.output is not None else f'{Path(args.file).stem}.dolphin.map'
outFile = open(outpath, 'w+')
with open(args.file, 'r') as f:
outFile.write('.text\n')
lines = f.readlines()
for line in lines:
if args.address is not None:
addr = int(line[0:8], 16)
addr += int(args.address, 16)
line = f'{addr:08X} {line[8:].strip()}\n'
print(line.strip())
outFile.write(line)
outFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment