From c11cd644e88d0d8d7578b8f3c40fb6d7afb9eb81 Mon Sep 17 00:00:00 2001 From: Sanqui Date: Sun, 27 May 2018 13:04:34 +0200 Subject: Add shim --- tools/make_shim.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tools/make_shim.py (limited to 'tools') 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") + + + -- cgit v1.2.3