summaryrefslogtreecommitdiff
path: root/tools/make_shim.py
diff options
context:
space:
mode:
authorSanqui <gsanky@gmail.com>2018-05-27 13:04:34 +0200
committerSanqui <gsanky@gmail.com>2018-05-27 13:04:54 +0200
commitc11cd644e88d0d8d7578b8f3c40fb6d7afb9eb81 (patch)
tree4c4bc8264b62ecd0ae5fdb605d9f35977456cc2e /tools/make_shim.py
parent2c77b5ad042d2c4b2a234ad2f1b05d85ae5805fb (diff)
Add shim
Diffstat (limited to 'tools/make_shim.py')
-rw-r--r--tools/make_shim.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/make_shim.py b/tools/make_shim.py
new file mode 100644
index 0000000..67b9f4e
--- /dev/null
+++ b/tools/make_shim.py
@@ -0,0 +1,39 @@
+from sys import argv, stderr
+
+for line in open(argv[1]):
+ line = line.split(";")[0]
+ line = line.strip()
+ if line and " " in line:
+ address, symbol = line.split()
+ bank, pointer = address.split(":")
+ bank = int(bank, 16)
+ pointer = int(pointer, 16)
+ section = None
+ if bank == 0 and pointer < 0x4000:
+ section = "ROM0"
+ bank = None
+ elif pointer < 0x8000:
+ section = "ROMX"
+ elif pointer < 0xa000:
+ section = "VRAM"
+ elif pointer < 0xc000:
+ section = "SRAM"
+ elif bank == 0 and pointer < 0xd000:
+ section = "WRAM0"
+ bank = None
+ elif pointer < 0xe000:
+ section = "WRAMX"
+ elif pointer > 0xff80 and pointer <= 0xffff:
+ section = "HRAM"
+ else:
+ stderr.write(f"Unknown section for {line}\n")
+
+ if section:
+ if bank:
+ print(f"SECTION \"Shim for {symbol}\", {section}[${pointer:x}], BANK[${bank:x}]")
+ else:
+ print(f"SECTION \"Shim for {symbol}\", {section}[${pointer:x}]")
+ print(f"{symbol}::\n\n")
+
+
+