mirror of
https://github.com/zeldaret/mm.git
synced 2026-09-12 20:26:02 -04:00
Cleanup: Pass all paths to tools rather than tools constructing them (#1669)
* Pass all paths to tools rather than tools constructing them * review * fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import struct
|
||||
|
||||
@@ -250,9 +251,9 @@ class MessageNES:
|
||||
prevNewline = False
|
||||
prevCmd = True
|
||||
|
||||
def parseTable(start):
|
||||
def parseTable(baseromSegmentsDir: Path, start):
|
||||
table = {}
|
||||
with open("extracted/n64-us/baserom/code","rb") as f:
|
||||
with open(baseromSegmentsDir / "code","rb") as f:
|
||||
f.seek(start)
|
||||
buf = f.read(8)
|
||||
textId, typePos, segment = struct.unpack(">HBxI", buf)
|
||||
@@ -266,12 +267,10 @@ def parseTable(start):
|
||||
NES_MESSAGE_TABLE_ADDR = 0x1210D8 # Location of NES message table in extracted/n64-us/baserom/code
|
||||
NES_SEGMENT_ADDR = 0x08000000
|
||||
|
||||
def main(outfile):
|
||||
msgTable = parseTable(NES_MESSAGE_TABLE_ADDR)
|
||||
def main(baseromSegmentsDir: Path, outfile):
|
||||
msgTable = parseTable(baseromSegmentsDir, NES_MESSAGE_TABLE_ADDR)
|
||||
|
||||
buf = []
|
||||
with open("extracted/n64-us/baserom/message_data_static", "rb") as f:
|
||||
buf = f.read()
|
||||
buf = (baseromSegmentsDir / "message_data_static").read_bytes()
|
||||
|
||||
bufLen = len(buf)
|
||||
i = 0
|
||||
@@ -310,7 +309,14 @@ def main(outfile):
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Extract message_data_static text")
|
||||
parser.add_argument(
|
||||
"--baserom-segments",
|
||||
dest="baserom_segments_dir",
|
||||
type=Path,
|
||||
required=True,
|
||||
help="Directory of uncompressed ROM segments",
|
||||
)
|
||||
parser.add_argument('-o', '--outfile', help='output file to write to. None for stdout')
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args.outfile)
|
||||
main(args.baserom_segments_dir, args.outfile)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import struct
|
||||
|
||||
@@ -170,9 +171,9 @@ class MessageCredits:
|
||||
prevNewline = False
|
||||
prevCmd = True
|
||||
|
||||
def parseTable(start):
|
||||
def parseTable(baseromSegmentsDir: Path, start):
|
||||
table = {}
|
||||
with open("extracted/n64-us/baserom/code","rb") as f:
|
||||
with open(baseromSegmentsDir / "code","rb") as f:
|
||||
f.seek(start)
|
||||
buf = f.read(8)
|
||||
textId, typePos, segment = struct.unpack(">HBxI", buf)
|
||||
@@ -186,12 +187,10 @@ def parseTable(start):
|
||||
STAFF_MESSAGE_TABLE_ADDR = 0x12A048 # Location of Staff message table in extracted/n64-us/baserom/code
|
||||
STAFF_SEGMENT_ADDR = 0x07000000
|
||||
|
||||
def main(outfile):
|
||||
msgTable = parseTable(STAFF_MESSAGE_TABLE_ADDR)
|
||||
def main(baseromSegmentsDir: Path, outfile):
|
||||
msgTable = parseTable(baseromSegmentsDir, STAFF_MESSAGE_TABLE_ADDR)
|
||||
|
||||
buf = []
|
||||
with open("extracted/n64-us/baserom/staff_message_data_static", "rb") as f:
|
||||
buf = f.read()
|
||||
buf = (baseromSegmentsDir / "staff_message_data_static").read_bytes()
|
||||
|
||||
bufLen = len(buf)
|
||||
i = 0
|
||||
@@ -225,7 +224,14 @@ def main(outfile):
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Extract staff_message_data_static text")
|
||||
parser.add_argument(
|
||||
"--baserom-segments",
|
||||
dest="baserom_segments_dir",
|
||||
type=Path,
|
||||
required=True,
|
||||
help="Directory of uncompressed ROM segments",
|
||||
)
|
||||
parser.add_argument('-o', '--outfile', help='output file to write to. None for stdout')
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args.outfile)
|
||||
main(args.baserom_segments_dir, args.outfile)
|
||||
|
||||
Reference in New Issue
Block a user