ys2-intro/loader/samples/minexample/conv_liltalk.py

29 lines
787 B
Python

f = open("liltalk_speak.txt","r").readlines()
f = [x[:-1] for x in f]
line_addrs = [11,16,16,29,33,27,32,29,11,32,24,13,14,17,27,4]
out = [0xFE, (40-line_addrs[0])//2]
cnt = 1
for line in f:
if line == '':
out.append(0xFE) # set line addr to beginning
out.append((40-line_addrs[cnt])//2)
cnt += 1
else:
num = 0
i = 0
while i < len(line) and line[i] in "0123456789":
num = num*10+int(line[i])
i += 1
str = line[i+1:]
str = str.upper()
str = str.replace("\\N","\n")
if num == 3: num += 1 # botches yay
out.append(num)
out.append(len(str))
for x in str: out.append(ord(x))
out.append(0xFF)
f = open("liltalk.bin","wb")
f.write(bytearray(out))
f.close()