aboutsummaryrefslogtreecommitdiff
path: root/tools/chksize
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-11-05 11:22:55 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-11-05 11:31:28 +0000
commit2fbdf974338bde8576efdae40a819a76b2391033 (patch)
tree64d41a37470143f142344f9a439d96de3e7918c2 /tools/chksize
downloadkitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz
kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip
Initial import of the open source release
Diffstat (limited to 'tools/chksize')
-rwxr-xr-xtools/chksize40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/chksize b/tools/chksize
new file mode 100755
index 0000000..147f4af
--- /dev/null
+++ b/tools/chksize
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import sys
+
+# video memory - stack
+TOP_MEM = 0xc000 - 256
+
+
+def main():
+ if len(sys.argv) != 3:
+ sys.exit("usage: %s load_addr filename.map" % sys.argv[0])
+
+ load_addr = int(sys.argv[1])
+
+ with open(sys.argv[2], "r") as fd:
+ lines = fd.readlines()
+ # warnings
+ for line in lines:
+ if "l__INITIALIZED" in line:
+ init_size = int(line.split()[0], base=16)
+ if init_size != 0:
+ print("*WARNING* Initialized data found")
+ # search for HEAP
+ for line in lines:
+ if "s__HEAP" in line:
+ heap_addr = int(line.split()[0], base=16)
+ print("""\
+***
+ Max: {} bytes
+ Current: {} bytes ({} bytes left)
+***
+""".format(TOP_MEM - load_addr, heap_addr - load_addr,
+ TOP_MEM - heap_addr - load_addr))
+ sys.exit(0)
+
+ sys.exit("HEAP size not found")
+
+
+if __name__ == "__main__":
+ main()