Skip to content

Commit

Permalink
Merge commit 'af77fcb211e9bd2b1c74d931387d40a7e5ee0267'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeturic committed Feb 12, 2020
2 parents b3ae82e + af77fcb commit d8030b6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tools/freesia/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

import argparse, sys, os.path
import argparse, sys
from pathlib import Path

argparser = argparse.ArgumentParser(description="Locates free space inside a GBA ROM.")
argparser.add_argument("--rom", dest="ROM", required=True)
Expand All @@ -24,6 +21,7 @@ def find_needed_bytes(rom, needed_bytes, start_at):
return 0

needed_words = round_up_to_4(needed_bytes) >> 2
start_at = round_up_to_4(start_at)

with open(rom, "rb") as rom:
rom.seek(start_at)
Expand All @@ -42,7 +40,7 @@ def find_needed_bytes(rom, needed_bytes, start_at):
else:
record += 1
elif len(val) < 4:
print("{}: error: end of file reached before a suitable location was found".format(os.path.basename(sys.argv[0])), file=sys.stderr)
print(f"{Path(sys.argv[0]).name}: error: end of file reached before a suitable location was found", file=sys.stderr)
sys.exit(1)
else:
record, start = 0, None
Expand All @@ -56,4 +54,4 @@ def find_needed_bytes(rom, needed_bytes, start_at):

addr = find_needed_bytes(rom=args.ROM, needed_bytes=args.NEEDED_BYTES, start_at=args.START_AT) | 0x08000000

print("0x{0:08X}".format(addr))
print(f"0x{addr :08X}")

0 comments on commit d8030b6

Please sign in to comment.