summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crodump.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/crodump.py b/crodump.py
index f50f45b..46fd969 100644
--- a/crodump.py
+++ b/crodump.py
@@ -83,12 +83,12 @@ class Datafile:
83 return kodecode(idx, encdat) 83 return kodecode(idx, encdat)
84 84
85 85
86 def dump(self, args, nodecode=False): 86 def dump(self, args):
87 print("tadhdr: %08x %08x" % tuple(self.tadhdr)) 87 print("tadhdr: %08x %08x" % tuple(self.tadhdr))
88 ranges = [] # keep track of used bytes in the .dat file. 88 ranges = [] # keep track of used bytes in the .dat file.
89 for i, (ofs, ln, chk) in enumerate(self.tadidx): 89 for i, (ofs, ln, chk) in enumerate(self.tadidx):
90 if ln==0xFFFFFFFF: 90 if ln==0xFFFFFFFF:
91 print("%5d: %08x %08x %08x" % (i, ofs, ln, chk)) 91 print("%5d: %08x %08x %08x" % (i+1, ofs, ln, chk))
92 continue 92 continue
93 flags = ln>>24 93 flags = ln>>24
94 94
@@ -102,7 +102,7 @@ class Datafile:
102 if not dat: 102 if not dat:
103 # empty record 103 # empty record
104 encdat = dat 104 encdat = dat
105 elif not nodecode and not flags: 105 elif self.need_decode and not flags:
106 extofs, extlen = struct.unpack("<LL", dat[:8]) 106 extofs, extlen = struct.unpack("<LL", dat[:8])
107 infostr = "%08x;%08x" % (extofs, extlen) 107 infostr = "%08x;%08x" % (extofs, extlen)
108 encdat = dat[8:] 108 encdat = dat[8:]
@@ -119,13 +119,13 @@ class Datafile:
119 encdat = dat 119 encdat = dat
120 decflag = '*' 120 decflag = '*'
121 121
122 if nodecode: 122 if self.need_decode:
123 decdat = kodecode(i+1, encdat)
124 else:
123 decdat = encdat 125 decdat = encdat
124 decflag = ' ' 126 decflag = ' '
125 else:
126 decdat = kodecode(i+1, encdat)
127 127
128 print("%5d: %08x-%08x: (%02x:%08x) %s %s%s %s" % (i, ofs, ofs+ln, flags, chk, infostr, decflag, toout(args, decdat), tohex(tail))) 128 print("%5d: %08x-%08x: (%02x:%08x) %s %s%s %s" % (i+1, ofs, ofs+ln, flags, chk, infostr, decflag, toout(args, decdat), tohex(tail)))
129 129
130 if args.verbose: 130 if args.verbose:
131 # output parts not referenced in the .tad file. 131 # output parts not referenced in the .tad file.
@@ -195,7 +195,11 @@ def decode_kod(args, data):
195 """ 195 """
196 if args.nokod: 196 if args.nokod:
197 # plain hexdump, no KOD decode 197 # plain hexdump, no KOD decode
198 hexdump(args.offset, data) 198 if args.ascdump:
199 print(asasc(data))
200 else:
201 hexdump(args.offset, data)
202
199 elif args.shift: 203 elif args.shift:
200 # explicitly specified shift. 204 # explicitly specified shift.
201 args.shift = int(args.shift, 0) 205 args.shift = int(args.shift, 0)