mirror of
https://github.com/clang-retro/mac-sdk.git
synced 2026-11-28 13:19:22 -08:00
Every 68k trap and selector comes from the ROM's InterfaceLib glue. trapinfo.py now records the constants the glue loads into registers, so calls like HoldMemory and AOn get their selector words. New tools: add-types.py (compact type definitions) and drop-defs.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRRDDKyi26yxudMyvEb
33 lines
1012 B
Python
33 lines
1012 B
Python
#!/usr/bin/env python3
|
|
"""Give functions in a defs file explicit 68k code words.
|
|
|
|
python3 tools/set-inline.py defs/Foo.yaml Name=0x2F3C,0x0004,0xFFFF ...
|
|
|
|
For calls whose 68k form is known but that the ROM glue does not show
|
|
(component calls, for example).
|
|
"""
|
|
import sys
|
|
|
|
import yaml
|
|
|
|
path = sys.argv[1]
|
|
want = {}
|
|
for a in sys.argv[2:]:
|
|
n, w = a.split("=")
|
|
want[n] = [int(x, 0) for x in w.split(",")]
|
|
text = open(path, encoding="utf-8").read()
|
|
items = yaml.safe_load(text)
|
|
out = []
|
|
for chunk in text.split("\n# ####\n"):
|
|
data = yaml.safe_load(chunk) or []
|
|
if len(data) == 1 and "function" in data[0] and \
|
|
"only-for" not in data[0] and \
|
|
data[0]["function"]["name"] in want:
|
|
f = data[0]["function"]
|
|
f["m68k-inline"] = want.pop(f["name"])
|
|
chunk = "\n" + yaml.safe_dump(data, sort_keys=False, width=100)
|
|
out.append(chunk)
|
|
if want:
|
|
sys.exit(f"not found: {', '.join(want)}")
|
|
open(path, "w", encoding="utf-8").write("\n# ####\n".join(out))
|