aboutsummaryrefslogtreecommitdiff
path: root/tools/chksize
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2021-05-03 08:21:10 +0100
committerJuan J. Martinez <jjm@usebox.net>2021-05-03 10:00:00 +0100
commitc3b0fa04a663fe233765b83d3be41a42aa08c25d (patch)
tree0befda349001ef6ce306b39378f9c70ad917363e /tools/chksize
downloadreturn-of-traxtor-cpc-c3b0fa04a663fe233765b83d3be41a42aa08c25d.tar.gz
return-of-traxtor-cpc-c3b0fa04a663fe233765b83d3be41a42aa08c25d.zip
Initial import for public releaseHEADmain
Diffstat (limited to 'tools/chksize')
-rwxr-xr-xtools/chksize42
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/chksize b/tools/chksize
new file mode 100755
index 0000000..6f2c9b8
--- /dev/null
+++ b/tools/chksize
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import sys
+
+# video memory + back buffer (stack in 0x200)
+TOP_MEM = 0xc000
+
+
+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)
+ max_mem = TOP_MEM - load_addr
+ cur_mem = heap_addr - load_addr
+ left_mem = max_mem - cur_mem
+ print("""\
+***
+ Max: {} bytes
+ Current: {} bytes ({} bytes left)
+***
+""".format(max_mem, cur_mem, left_mem))
+ sys.exit(0)
+
+ sys.exit("HEAP size not found")
+
+
+if __name__ == "__main__":
+ main()