summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crodump.py48
1 files changed, 47 insertions, 1 deletions
diff --git a/crodump.py b/crodump.py
index 148b3cf..09823b8 100644
--- a/crodump.py
+++ b/crodump.py
@@ -55,6 +55,10 @@ class Datafile:
55 raise Exception("not a Crofile") 55 raise Exception("not a Crofile")
56 self.use64bit = self.version == b'01.03' 56 self.use64bit = self.version == b'01.03'
57 57
58 if self.version == b'01.11':
59 # only found in app: v5/CroSys.dat
60 raise Exception("v01.11 format is not yet supported")
61
58 # blocksize 62 # blocksize
59 # 0040 -> Bank 63 # 0040 -> Bank
60 # 0400 -> Index or Sys 64 # 0400 -> Index or Sys
@@ -264,7 +268,32 @@ def destruct_base_definition(args, data):
264 remaining = rd.readbytes() 268 remaining = rd.readbytes()
265 269
266 print("rem: %s" % tohex(remaining)) 270 print("rem: %s" % tohex(remaining))
267 271
272def destruct_sys3_def(rd):
273 pass
274def destruct_sys4_def(rd):
275 n = rd.readdword()
276 for _ in range(n):
277 marker = rd.readdword()
278 description = rd.readlongstring()
279 path = rd.readlongstring()
280 marker2 = rd.readdword()
281
282 print("%08x;%08x: %-50s : %s" % (marker, marker2, path, description))
283
284def destruct_sys_definition(args, data):
285 """
286 decode the 'sys' / dbindex definition
287 """
288 rd = ByteReader(data)
289
290 systype = rd.readbyte()
291 if systype == 3:
292 return destruct_sys3_def(rd)
293 elif systype == 4:
294 return destruct_sys4_def(rd)
295 else:
296 raise Exception("unsupported sys record")
268 297
269 298
270class Database: 299class Database:
@@ -439,6 +468,13 @@ def stru_dump(args):
439 db = Database(args.dbdir) 468 db = Database(args.dbdir)
440 db.strudump(args) 469 db.strudump(args)
441 470
471def sys_dump(args):
472 """ hexdump all CroSys records """
473
474 db = Database(args.dbdir)
475 if db.sys:
476 db.sys.dump(args)
477
442def bank_dump(args): 478def bank_dump(args):
443 """ hexdump all records """ 479 """ hexdump all records """
444 if args.maxrecs: 480 if args.maxrecs:
@@ -463,6 +499,8 @@ def destruct(args):
463 destruct_bank_definition(args, data) 499 destruct_bank_definition(args, data)
464 elif args.type==2: 500 elif args.type==2:
465 destruct_base_definition(args, data) 501 destruct_base_definition(args, data)
502 elif args.type==3:
503 destruct_sys_definition(args, data)
466 504
467def main(): 505def main():
468 import argparse 506 import argparse
@@ -492,6 +530,14 @@ def main():
492 p.add_argument('dbdir', type=str) 530 p.add_argument('dbdir', type=str)
493 p.set_defaults(handler=cro_dump) 531 p.set_defaults(handler=cro_dump)
494 532
533 p = subparsers.add_parser('sysdump', help='SYSdumper')
534 p.add_argument('--verbose', '-v', action='store_true')
535 p.add_argument('--ascdump', '-a', action='store_true')
536 p.add_argument('--nodecompress', action='store_false', dest='decompress', default='true')
537 p.add_argument('dbdir', type=str)
538 p.set_defaults(handler=sys_dump)
539
540
495 p = subparsers.add_parser('bankdump', help='BANKdumper') 541 p = subparsers.add_parser('bankdump', help='BANKdumper')
496 p.add_argument('--verbose', '-v', action='store_true') 542 p.add_argument('--verbose', '-v', action='store_true')
497 p.add_argument('--ascdump', '-a', action='store_true') 543 p.add_argument('--ascdump', '-a', action='store_true')