init files
This commit is contained in:
commit
8197a022bd
1409 changed files with 139317 additions and 0 deletions
77
loader/samples/minexample/anim2cus.py
Normal file
77
loader/samples/minexample/anim2cus.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import sys
|
||||
f = list(open(sys.argv[1], "rb").read())[2:]
|
||||
|
||||
out = f[:(0x4711-0x2000)]
|
||||
|
||||
a = open(sys.argv[2],"r").read().split("\n")
|
||||
a = [x for x in a if x != ""]
|
||||
a = [x.split(",")[1] for x in a[:-1]]
|
||||
|
||||
frame = []
|
||||
frame_dict = {}
|
||||
|
||||
cnt = 0
|
||||
def append_frame(frame):
|
||||
global cnt
|
||||
if cnt < len(a):
|
||||
filename_csv = a[cnt]
|
||||
if filename_csv not in frame_dict:
|
||||
frame_dict[filename_csv] = []
|
||||
for d in frame:
|
||||
if d not in frame_dict[filename_csv]:
|
||||
frame_dict[filename_csv].append(d)
|
||||
else:
|
||||
print(cnt, len(a))
|
||||
cnt += 1
|
||||
|
||||
ptr = 0x4711-0x2000
|
||||
while ptr < len(f):
|
||||
num_chars = f[ptr]
|
||||
#print(ptr,len(f),num_chars)
|
||||
ptr += 1
|
||||
if num_chars == 0:
|
||||
delay = f[ptr]
|
||||
ptr += 1
|
||||
append_frame(frame)
|
||||
frame = []
|
||||
continue
|
||||
elif num_chars == 0xFF:
|
||||
append_frame(frame)
|
||||
break
|
||||
bitmap = (f[ptr]|(f[ptr+1]<<8))+0x2000
|
||||
ptr += 2
|
||||
screen = (f[ptr]|(f[ptr+1]<<8))+0x400
|
||||
cram = (f[ptr]|(f[ptr+1]<<8))+0xd800
|
||||
ptr += 2
|
||||
for i in range(num_chars):
|
||||
frame.append([bitmap,f[ptr:ptr+8]])
|
||||
ptr += 8
|
||||
frame.append([screen,f[ptr]])
|
||||
frame.append([cram,f[ptr+1]])
|
||||
ptr += 2
|
||||
bitmap += 8
|
||||
screen += 1
|
||||
cram += 1
|
||||
|
||||
out_pat_addr = len(out)
|
||||
out.extend([0]*(len(a)*3))
|
||||
|
||||
frame_dict_offs = []
|
||||
for i in frame_dict:
|
||||
frame_dict_offs.append(len(out))
|
||||
sort_dict = sorted([x for x in frame_dict[i]], key=lambda x : x[0])
|
||||
print(sort_dict)
|
||||
for j in sort_dict:
|
||||
out.append(j[0]&0xff)
|
||||
out.append(j[0]>>8&0xff)
|
||||
if type(j[1]) == list:
|
||||
out.extend(j[1])
|
||||
else:
|
||||
out.append(j[1])
|
||||
|
||||
#print(out)
|
||||
|
||||
print(hex(0x2000+len(out)))
|
||||
f = open(sys.argv[3],"wb")
|
||||
f.write(bytearray(out))
|
||||
f.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue