-
Notifications
You must be signed in to change notification settings - Fork 9
/
d77inspect.py
49 lines (42 loc) · 1.66 KB
/
d77inspect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# d77 inspectate utility
import argparse
from d77lib import *
def main(args):
with open(args.input, 'rb') as f:
img = f.read()
d77 = decode_d77(img)
# Display results
print('Header:', d77['header'])
t = eval(args.track)
if type(t) is tuple:
start = t[0]
end = t[1]
else:
start = t
end = t
all_sectors = d77['sectors']
for trkid in range(start, end+1):
key = trkid
sectors = all_sectors[key]
print(trkid)
print('# C H R N S1 S2 AM SIZE ICRC POS')
for i, sect in enumerate(sectors):
c,h,r,n = sect['CHRN'].split(':')
status = sect['status']
size = sect['size']
am = 'DDAM' if sect['am']==0x10 else 'DAM '
pos = sect['pos']
ext_sta = sect['ext_sta']
id_crc = sect['id_crc_val'] # id crc value
print('{:03} {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} - {:4} {:4} {:04x} {:04x}'.format(i,
int(c),int(h),int(r),int(n),
ext_sta, status, am, size, id_crc, pos))
#print('density', sect['density'])
#print('num_sec', sect['num_sec'])
if __name__ == '__main__':
print('** D77 disk image inspection tool')
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', type=str, required=True, help='input bitstream file path')
parser.add_argument('-t', '--track', required=True, help='track number. single number or a tuple (start,end) (track # should be 0-83 for 2D, 0-163 for 2DD)')
args = parser.parse_args()
main(args)