TI89 Decoder

My attempt and decoding my TI-89 programs.

In [9]:
import binascii
In [52]:
PATH="../files/files/TI-89/fatigue.89p"
with open (PATH,"rb") as fid:
    r=fid.read()
In [53]:
header=r[0:8]
assert r[8]==0x01 # ?
folder_=r[0x3D:0x4B]
In [54]:
print(header)
b'**TI89**'
In [55]:
print(r[0x3C]) # This is different between programs.
98
In [59]:
lines=list()
line=bytearray()
for i in range(len(r)):
    if r[i] == 0x0D:
        lines.append(line)
        line=bytearray()
        continue
    line.append(r[i])
In [112]:
def decodify(line):
    line=line.replace(b"\x8f", b"$\\sigma$")
    line=line.replace(b"\x90", b"$\\tau$")
    line=line.replace(b"\x16", b"$\\rightarrow$")
    line=line.replace(b"\xb3", b"$^3$")
    line=line.replace(b"\xb2", b"$^2$")
    line=line.replace(b"\xa9", b"#")
    line=line.replace(b"\xad", b"${-}$")
    line=line.replace(b"\x9c", b"$\\leq$")
    line=line.replace(b"\x9e", b"$\\geq$")
    line=line.replace(b"\x95", b"$\\mathrm {E}$")
    line=line.replace(b"\xb1", b"$\\pm$")
    line=line.replace(b"\xa8", b"$\\sqrt$")
    return line
for line in lines[1:]:
    try:
        tmp=decodify(line).decode()
        #display(Latex(tmp))
    except:
        print(line)
bytearray(b'Input "\x88=",\x88')
bytearray(b'Disp "C[10]="&string(approx(fd*(xd/(x0+(\x88-x0)*(ln(1/rd))^(1/b)))^(1/a)))')
bytearray(b'Disp "C[10]="&string(approx(fd*(xd/(x0+(\x88-x0)*(1-rd)^(1/b)))^(1/a)))')
bytearray(b'Disp "\x8f=\xad32*M/(\x8c*d\xb3)"')
bytearray(b'Disp "\x90=16*T/(\x8c*d\xb3)"')
bytearray(b'Disp "\x8f\'[f]=\x8f0*\x86^m"')
bytearray(b'PopUp {"\xb0C","\xb0F"},a')
In [ ]: