forked from dh219/Hi-Lo-Byte-Split
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hi_low_byte_split.py
67 lines (48 loc) · 1.8 KB
/
hi_low_byte_split.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/local/bin/python3
# Extremely basic high/low byte splitter for ROMS -- Public Domain
fin = open( "tos.img", "rb" )
fhi = open( "2way_high.img", "wb" )
flo = open( "2way_low.img", "wb" )
byte = 1 # just want the next test to pass
while byte: # stop at EOF
byte = fin.read(1) # read one byte
fhi.write(byte) # write it to the high file
byte = fin.read(1) # read one more byte
flo.write(byte) # write it the low file, then repeat
fin.close()
fhi.close()
flo.close()
fhi = open( "2way_high.img", "rb" )
flo = open( "2way_low.img", "rb" )
fhi0 = open( "6way_high_0.img", "wb" )
fhi1 = open( "6way_high_1.img", "wb" )
fhi2 = open( "6way_high_2.img", "wb" )
flo0 = open( "6way_low_0.img", "wb" )
flo1 = open( "6way_low_1.img", "wb" )
flo2 = open( "6way_low_2.img", "wb" )
# let's then further split those into 6 for the pre-STE range
byte = 1 # just want the next test to pass
while byte: # stop at EOF
byte = fhi.read(1) # read one byte from high
fhi0.write(byte) # write it to the high 0 file
byte = fhi.read(1) # read one byte from high
fhi1.write(byte) # write it to the high 1 file
byte = fhi.read(1) # read one byte form high
fhi2.write(byte) # write it to the high 2 file
# same now for low
byte = 1 # just want the next test to pass
while byte: # stop at EOF
byte = flo.read(1) # read one byte from low
flo0.write(byte) # write it to the low 0 file
byte = flo.read(1) # read one byte from low
flo1.write(byte) # write it to the low 1 file
byte = flo.read(1) # read one byte form low
flo2.write(byte) # write it to the low 2 file
fhi.close()
flo.close()
fhi0.close()
fhi1.close()
fhi2.close()
flo0.close()
flo1.close()
flo2.close()