-
Notifications
You must be signed in to change notification settings - Fork 0
/
spritemacro.py
55 lines (43 loc) · 1.19 KB
/
spritemacro.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
import sys
import glob
'''
Wasn't satisfied with vasms macro capabilities for what I needed to do. This just generates code for the data structures
that the Blitter chip expects for each frame for each tile in the overall sit-sprite animation. It then creates an array of pointers
to each frame:
anim:
|_frame1
|_f1_1
|_f1_2
... etc
|_frame2
... etc
'''
inglob = sys.argv[1]
count = 0
macrolab = "sit_{}:"
macro = ' frame_gen {} "{}"'
fulltext = " dc.w $6d40+8*{} \n\
dc.w $c300 \n\
incbin \"{}\" \n\
dc.w $0000,0000 \n\
\n\
CNOP 0,2\n"
framelists = []
spriteindex = 6
frames = -1
for path in glob.iglob(inglob):
if (spriteindex > 5):
print("\n")
framelists.append([])
frames += 1
spriteindex = 0
print(macrolab.format(path[-8:-4]))
print(fulltext.format(path[-5], path))
framelists[frames].append(macrolab.format(path[-8:-4]).replace(":", ""))
spriteindex += 1
for i, frame in enumerate(framelists):
print("sit_frame{}:".format(i))
for item in frame:
print(" dc.l {}".format(item))
print(" dc.l $fffffffe")
print(" CNOP 0,4\n")