papermario/tools/splat/create_config.py
Ethan Roseman ab79244991
JP rom beginnings (#197)
* data, splat fixes

* fix .gitrepo?

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "fb8315b319"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "fb8315b319"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* audio updates (thanks Clover)

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "c56195a9c5"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "c56195a9c5"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* work on jp rom

* remove comment

* fix duplicate asm labels

* git subrepo pull (merge) tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "db51ae16c2"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "db51ae16c2"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* fix configure and delete grub

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "97e51bdf21"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "97e51bdf21"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* file split, moving things into os

* header
2021-03-04 18:00:56 +09:00

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
platform: n64
out_dir: .
target_path: baserom.z64
""".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
- name: boot
type: bin
start: 0x40
- name: main
type: code
start: 0x1000
vram: 0x{:X}
subsections:
- [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)