Repository navigation
Expand file tree
/
Copy patheffects.asm
More file actions
256 lines (195 loc) · 3.31 KB
/
Copy patheffects.asm
File metadata and controls
256 lines (195 loc) · 3.31 KB
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
.include "header.inc"
.include "snesregs.inc"
.include "misc_macros.inc"
.include "zeropage.inc"
.16BIT
.bank 0
.ramsection "effects_variables" SLOT RAM_SLOT
; Pointer to the effect routine that must be called from vblank (see effects_dovblank)
effects_cur_routine: dw
; Effect state and varibles (shared between different effects)
effects_state: dw
effects_tmp: dw
; Options for mosaic effects: BG mask (for the 4 lower bits of MOSAIC/$2106)
effects_mosaic_bgmask: dw
.ends
.section "Effects" FREE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Run the active non-blocking effect.
;
; To be called from vblank.
;
effects_dovblank:
jmp (effects_cur_routine)
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Initialize the non blocking effect helper
;
effects_init:
pushall
A16
lda #_effects_nop
sta effects_cur_routine
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Start a "mosaic pulse" effect.
;
; Not bad to signal errors. Similar to a visual bell.
;
effect_mosaic_pulse:
pushall
A16
lda #_effects_mosaic_do
sta effects_cur_routine
stz effects_state
stz effects_tmp
lda #5
sta effects_mosaic_bgmask
popall
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Internal no-operation routine used as a placeholder when there
; is no active effect.
;
_effects_nop:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Internal function for the mosaic pulse effect.
;
_effects_mosaic_do:
pushall
A8
lda effects_state
bne @shrinking
@growing:
lda effects_tmp
inc A
cmp #7
beq @done_growing
sta effects_tmp
asl
asl
asl
asl
ora effects_mosaic_bgmask
sta MOSAIC
bra @done
@done_growing:
inc effects_state
bra @done
@shrinking:
lda effects_tmp
dec A
bmi @done_shrinking
sta effects_tmp
asl
asl
asl
asl
ora effects_mosaic_bgmask
sta MOSAIC
bra @done
@done_shrinking:
A16
lda #_effects_nop ; Replace this routine by the nop
sta effects_cur_routine ; routine, stop being called.
@done:
popall
rts
pha
phx
phy
php
A8
XY8
; ramp up
lda #07
@lp1:
wai
sta MOSAIC
clc
adc #$20
bcc @lp1
; ramp down
lda #$e7
@lp2:
wai
sta MOSAIC
sec
sbc #$20
bit #$f0
bne @lp2
stz MOSAIC
plp
ply
plx
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Performa fade-in using INIDISP bits 3-0 (master brightness)
;
; BLOCKING
;
effect_fadein:
pha
phx
php
A8
XY8
ldx #0 ; black screen, not blanked
stx INIDISP
; Bits 3-0 : Master brightness. 0 = black, 15 = max
@loop:
; Halt until next vblank
wai
; Increment brightness every 4 frames
lda framecount
and #0 ; will be 0 every 2 cycles
bne @loop
inx
stx INIDISP
cpx #15
beq @done
bra @loop
@done:
plp
plx
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Performa fade-out using INIDISP bits 3-0 (master brightness)
;
; BLOCKING
;
effect_fadeout:
pha
phx
php
A8
XY8
ldx #15 ; black screen, not blanked
; Bits 3-0 : Master brightness. 0 = black, 15 = max
@loop:
; Halt until next vblank
wai
; Decrement brightness every 4 frames
lda framecount
and #0 ; will be 0 every 2 cycles
bne @loop
dex
stx INIDISP
cpx #0
beq @done
bra @loop
@done:
plp
plx
pla
rts
.ends