/
to8xx
executable file
·55 lines (37 loc) · 1.22 KB
/
to8xx
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
#!/data/data/com.termux/files/usr/bin/python
import sys
global chksum
chksum = 0
def chkwrite(outfile, bytearray):
global chksum
outfile.write(bytearray)
for byte in bytearray:
chksum += int(byte)
def main(argv):
if len(argv) !=2:
print("Wrong Syntax!\nUsage: %s filename\n" %argv[0])
sys.exit(10)
infile = open(argv[1] + '.bin', 'rb')
outfile = open(argv[1] + '.83p', 'wb')
data = infile.read()
tmp=len(data)+2+2+13
outfile.write(b'**TI83**')
outfile.write(b'\x1a\x0a\x00')
outfile.write(b'File generated by to8xx in python'.ljust(42, b' '))
outfile.write(tmp.to_bytes(2, 'little'))
chkwrite(outfile, b'\x0b\x00')
tmp = len(data) + 2;
chkwrite(outfile, tmp.to_bytes(2, 'little'))
chkwrite(outfile, b'\x06')
chkwrite(outfile, argv[1].upper().encode().ljust(8, b'\x00'))
tmp = len(data) + 2
chkwrite(outfile, tmp.to_bytes(2, 'little'))
chkwrite(outfile, len(data).to_bytes(2, 'little'))
chkwrite(outfile, data)
print("wrote almost all..%d\n" %chksum)
chkwrite(outfile, (chksum&65535).to_bytes(2, 'little'))
infile.close()
outfile.close()
print("wrote all!!\n")
if __name__ == '__main__':
main(sys.argv)