2021-01-15 02:26:06 +01:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
2021-01-24 16:19:56 +01:00
|
|
|
from util.n64 import rominfo
|
|
|
|
from util.n64 import find_code_length
|
2021-01-15 02:26:06 +01:00
|
|
|
|
2021-01-24 16:19:56 +01:00
|
|
|
parser = argparse.ArgumentParser(description="Create a splat config from a rom (currently only n64 .z64 roms supported)")
|
2021-01-15 02:26:06 +01:00
|
|
|
parser.add_argument("rom", help="path to a .z64 rom")
|
|
|
|
|
|
|
|
|
|
|
|
def main(rom_path):
|
|
|
|
rom = rominfo.get_info(rom_path)
|
|
|
|
basename = rom.name.replace(" ", "").lower()
|
|
|
|
|
|
|
|
header = \
|
|
|
|
"""name: {0} ({1})
|
|
|
|
basename: {2}
|
|
|
|
options:
|
|
|
|
find_file_boundaries: True
|
2021-03-04 10:00:56 +01:00
|
|
|
compiler: IDO
|
|
|
|
platform: n64
|
2021-04-13 09:47:52 +02:00
|
|
|
base_dir: .
|
2021-03-04 10:00:56 +01:00
|
|
|
target_path: baserom.z64
|
2021-01-15 02:26:06 +01:00
|
|
|
""".format(rom.name.title(), rom.get_country_name(), basename)
|
|
|
|
|
|
|
|
with open(rom_path, "rb") as f:
|
|
|
|
fbytes = f.read()
|
2021-02-06 05:05:39 +01:00
|
|
|
|
2021-01-24 16:19:56 +01:00
|
|
|
first_section_end = find_code_length.run(fbytes, 0x1000, rom.entry_point)
|
2021-01-15 02:26:06 +01:00
|
|
|
|
|
|
|
segments = \
|
|
|
|
"""segments:
|
|
|
|
- name: header
|
|
|
|
type: header
|
|
|
|
start: 0x0
|
|
|
|
- name: boot
|
|
|
|
type: bin
|
|
|
|
start: 0x40
|
|
|
|
- name: main
|
|
|
|
type: code
|
|
|
|
start: 0x1000
|
|
|
|
vram: 0x{:X}
|
2021-04-13 09:47:52 +02:00
|
|
|
subsegments:
|
2021-01-15 02:26:06 +01:00
|
|
|
- [0x1000, asm]
|
|
|
|
- type: bin
|
|
|
|
start: 0x{:X}
|
|
|
|
- [0x{:X}]
|
2021-01-24 16:19:56 +01:00
|
|
|
""".format(rom.entry_point, first_section_end, rom.size)
|
2021-01-15 02:26:06 +01:00
|
|
|
|
|
|
|
outstr = header + segments
|
|
|
|
|
|
|
|
outname = rom.name.replace(" ", "").lower()
|
|
|
|
with open(outname + ".yaml", "w", newline="\n") as f:
|
|
|
|
f.write(outstr)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
args = parser.parse_args()
|
|
|
|
main(args.rom)
|