forked from Pigu-A/nobankskank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_mecha_grill.asm
executable file
·321 lines (308 loc) · 4.85 KB
/
7_mecha_grill.asm
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
; Part 7: GR.9/10 interlaced art ✗
.include "gvars.asm"
SDMCTL = $22f
SDLSTL = $230
COLOR = $2c0
HEIGHT = 100
* = partEntry_7
start
mva #0, SDMCTL
mwa #vbi, rNMI
mva #$40, rNMIEN
mva #$70, dlist0 ; 8 blank lines
sta dlist0+1
sta dlist1
sta dlist1+1
mva #$30, dlist0+2 ; 4 blank lines
sta dlist1+2
mwa #gfxl-2, zTMP0
mwa #gfxc-2, zTMP2
ldx #0
ldy #HEIGHT
- lda #$5f ; lms + hscrol
sta dlist0d, x
_dst00C = *-2
sta dlist0d+3, x
_dst01C = *-2
sta dlist1d, x
_dst10C = *-2
sta dlist1d+3, x
_dst11C = *-2
lda zTMP0
sta dlist0d+1, x
_dst00L = *-2
sta dlist1d+4, x
_dst11L = *-2
lda zTMP1
sta dlist0d+2, x
_dst00H = *-2
sta dlist1d+5, x
_dst11H = *-2
lda zTMP2
sta dlist0d+4, x
_dst01L = *-2
sta dlist1d+1, x
_dst10L = *-2
lda zTMP3
sta dlist0d+5, x
_dst01H = *-2
sta dlist1d+2, x
_dst10H = *-2
addw #40, zTMP0
addw #40, zTMP2
txa
add #6
tax
bcc +
inc _dst00C+1
inc _dst00L+1
inc _dst00H+1
inc _dst01C+1
inc _dst01L+1
inc _dst01H+1
inc _dst10C+1
inc _dst10L+1
inc _dst10H+1
inc _dst11C+1
inc _dst11L+1
inc _dst11H+1
+ dey
bne -
mva #$41, dlist0d+HEIGHT*6 ; jvb
sta dlist1d+HEIGHT*6
mwa #dlist0, dlist0d+HEIGHT*6+1
mwa #dlist1, dlist1d+HEIGHT*6+1
mwa #dlist0, SDLSTL
mva #$22, SDMCTL ; enable dlist dma, normal pf
loop
lda #0
framecnt = *-1
eor #1
sta framecnt
sta zTMP0
sta rWSYNC
sta rPRIOR
bne +
lda >#dlist0
gne ++
+ lda >#dlist1
+ sta SDLSTL+1
lda COLOR
sta rCOLBK
jsr scene0 ; update scene-specific variables
scefunc = *-2
mva #(HEIGHT*2), zTMP1
lda #(63-HEIGHT/2) ; wait until display begin
- cmp rVCOUNT
bne -
sta rWSYNC
clc
- lda rRANDOM
and #0
rand = *-1
adc #8
offs = *-1
tay
lda zTMP0
eor #1
sta zTMP0
beq +
lda #$40
ldx #0
geq ++
+ lda #$80
ldx #0
color8 = *-1
+ sta rWSYNC
stx rCOLBK
sta rPRIOR
sty rHSCROL
dec zTMP1
bne -
jmp loop
scene0
lda framecnt
bne _done
ldx #8
- lda gfxcpals,x
and #$f
add _fade
cmp #$f
bcc +
lda #$f
+ sta zTMP1
lda gfxcpals,x
and #$f0
ora zTMP1
cpx #8
beq +
sta COLOR,x
gne ++
+ sta color8
+ dex
bpl -
dec _fade
bpl _done
mwa #scene1, scefunc
_done
rts
_fade .byte 15
scene1 ; TODO tile copying system when I actually have an animation finished
lda zCurMsxOrd
cmp #$24
bne _done
lda zCurMsxRow
cmp #$30
bne _done
mwa #scene2, scefunc
jmp scene2
_done
rts
scene2
; scroll the whole gfx to the right
lda #0
_state = *-1
eor #6
sta _state
sta zTMP2
ldx _lasti
lda _lut,x
sta zTMP3
bne _move
rts ; no need to move the gfx data yet
_move
; since both gfxl and gfxc are aligned to the same lower byte,
; we can just do only one math on the lower byte of both gfxs
; same goes with dlist0 and dlist1
lda _lastp
ldx zTMP2
beq _s0
sub zTMP3
sta _lastp
sta _dstl
sta _dstc
lda _lastp+1
bcs _st
dec _lastp+1
gcc _st
_s0
add #40
sta _dstl
sta _dstc
lda _lastp+1
adc #0
_st
sta _dstl+1
add >#(gfxc-gfxl)
sta _dstc+1
mva >#(dlist0d+1), _dst00S+1
sta _dst00L+1
sta _dst00H+1
sta _dst01L+1
sta _dst01H+1
mva >#(dlist1d+1), _dst10L+1
sta _dst10H+1
sta _dst11L+1
sta _dst11H+1
ldy #HEIGHT/2
_moveloop
ldx zTMP3
lda #0
- sta $ffff,x
_dstl = *-2
sta $ffff,x
_dstc = *-2
dex
bne -
ldx zTMP2
lda dlist0d+1,x
_dst00S = *-2
sub zTMP3
sta dlist0d+1,x
_dst00L = *-2
sta dlist0d+4,x
_dst01L = *-2
sta dlist1d+1,x
_dst10L = *-2
sta dlist1d+4,x
_dst11L = *-2
bcs +
dec dlist0d+2,x
_dst00H = *-2
dec dlist0d+5,x
_dst01H = *-2
dec dlist1d+2,x
_dst10H = *-2
dec dlist1d+5,x
_dst11H = *-2
+ txa
add #12
sta zTMP2
bcc +
inc _dst00S+1
inc _dst00L+1
inc _dst00H+1
inc _dst01L+1
inc _dst01H+1
inc _dst10L+1
inc _dst10H+1
inc _dst11L+1
inc _dst11H+1
+ addw #80, _dstl
addw #80, _dstc
dey
bne _moveloop
lda _state
bne _done
inc _lasti
lda _lasti
cmp #size(_lut)
bne _done
pla ; pop return address so the stack points
pla ; to the loader's return address instead
mva #0, rCOLPF2
sta COLOR+6
_done
rts
_lasti .byte 0
_lastp .word gfxl+39
_lut .block
_x := 1
_t1 := 0
.rept 16
_t2 := int(32*(_x/16.0)**2+_x/2.0+.5)
.byte _t2-_t1
_t1 := _t2
_x := _x + 1
.next
.bend
vbi
sta nmiA
stx nmiX
sty nmiY
mwa SDLSTL, rDLISTL
mva SDMCTL, rDMACTL
ldx #7
- mva COLOR,x, rCOLPM0,x
dex
bpl -
jsr updateMusic
lda nmiA
ldx nmiX
ldy nmiY
rti
.align $1000
.fill 42, 0 ; buffer for when scrolling right
gfxl .binary "gfx/mechag_l.4bpp"
.align $1000
.fill 42, 0
gfxc .binary "gfx/mechag_c.4bpp"
.fill 2
gfxcpals .byte $00,$07,$0f,$15,$1c,$35,$85,$ec,$9c
.align $400
dlist0 .fill 3
dlist0d .fill HEIGHT*6+3
.align $400
dlist1 .fill 3
dlist1d .fill HEIGHT*6+3
.warn format("Part 7's memory usage: %#04x - %#04x", start, *)