summaryrefslogtreecommitdiff
path: root/tools/makeshim.py
diff options
context:
space:
mode:
authormid-kid <esteve.varela@gmail.com>2020-09-09 23:57:39 +0200
committermid-kid <esteve.varela@gmail.com>2020-09-09 23:58:51 +0200
commitbf5d9d07f67b2f46450adae5646cb670d7b6e70a (patch)
tree767509bc46e73053b9b623b9ac41f6717ef78541 /tools/makeshim.py
parentb248d00f396d576074070e836c967ad814519bfb (diff)
Set up initial structure
Diffstat (limited to 'tools/makeshim.py')
-rwxr-xr-xtools/makeshim.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/makeshim.py b/tools/makeshim.py
new file mode 100755
index 0000000..2dbca01
--- /dev/null
+++ b/tools/makeshim.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+from sys import argv
+
+for line in open(argv[1]):
+ split = line.split(";")[0].split(" ")
+ if len(split) < 2:
+ continue
+ name = " ".join(split[1:]).strip()
+
+ split = split[0].split(":")
+ if len(split) != 2:
+ continue
+ bank = int(split[0], 16)
+ addr = int(split[1], 16)
+
+ section = None
+ bankdec = None
+ if bank == 0 and addr >= 0x0000 and addr < 0x4000:
+ section = "ROM0"
+ elif addr >= 0x4000 and addr < 0x8000:
+ section = "ROMX"
+ bankdec = bank
+ elif addr >= 0x8000 and addr < 0xA000:
+ section = "VRAM"
+ bankdec = bank
+ elif addr >= 0xA000 and addr < 0xC000:
+ section = "SRAM"
+ bankdec = bank
+ elif bank == 0 and addr >= 0xC000 and addr < 0xD000:
+ section = "WRAM0"
+ elif addr >= 0xD000 and addr < 0xE000:
+ section = "WRAMX"
+ bankdec = bank
+ elif bank == 0 and addr >= 0xFE00 and addr < 0xFEA0:
+ section = "OAM"
+ elif bank == 0 and addr >= 0xFF80 and addr < 0xFFFF:
+ section = "HRAM"
+ else:
+ continue
+
+ if bankdec is not None:
+ bankdec = ", BANK[$%x]" % bankdec
+ else:
+ bankdec = ""
+ print("SECTION \"Shim %s\",%s[$%x]%s" % (name, section, addr, bankdec))
+ print("%s::" % name)