mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 20:12:30 +01:00
5c5c0cc410
subrepo: subdir: "tools/splat" merged: "9304f9415" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "733546fea" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596"
60 lines
1.3 KiB
Python
Executable File
60 lines
1.3 KiB
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
import argparse
|
|
from util.n64 import rominfo
|
|
from util.n64 import find_code_length
|
|
from segtypes.n64.code import N64SegCode
|
|
|
|
parser = argparse.ArgumentParser(description="Create a splat config from a rom (currently only n64 .z64 roms supported)")
|
|
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
|
|
compiler: "IDO"
|
|
""".format(rom.name.title(), rom.get_country_name(), basename)
|
|
|
|
with open(rom_path, "rb") as f:
|
|
fbytes = f.read()
|
|
|
|
first_section_end = find_code_length.run(fbytes, 0x1000, rom.entry_point)
|
|
|
|
segments = \
|
|
"""segments:
|
|
- name: header
|
|
type: header
|
|
start: 0x0
|
|
vram: 0
|
|
files:
|
|
- [0x0, header, header]
|
|
- name: boot
|
|
type: bin
|
|
start: 0x40
|
|
- name: main
|
|
type: code
|
|
start: 0x1000
|
|
vram: 0x{:X}
|
|
files:
|
|
- [0x1000, asm]
|
|
- type: bin
|
|
start: 0x{:X}
|
|
- [0x{:X}]
|
|
""".format(rom.entry_point, first_section_end, rom.size)
|
|
|
|
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)
|