-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheff-door.s
274 lines (261 loc) · 5.06 KB
/
eff-door.s
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
;; Open-the-door effect
;;
;; Displays an ascii animation of a door being opened, when
;; CONFIG OPEN=1 is set.
.macpack apple2
.include "taki-effect.inc"
.include "taki-public.inc"
.include "a2-monitor.inc"
kNumSprites = 7
kSpriteWidth = 4
kSpriteHeight = 4
kSpriteSize = kSpriteWidth * kSpriteHeight
tblSprites:
scrcode "DOOR"
scrcode " "
scrcode " "
scrcode " "
;
scrcode "DO "
scrcode " OR"
scrcode " "
scrcode " "
;
scrcode "D "
scrcode " OO "
scrcode " R"
scrcode " "
;
scrcode "D "
scrcode " O "
scrcode " O "
scrcode " R"
;
scrcode "D "
scrcode " O "
scrcode " O "
scrcode " R "
;
scrcode "D "
scrcode "O "
scrcode " O "
scrcode " R "
;
scrcode "D "
scrcode "O "
scrcode "O "
scrcode "R "
;
kOrientationSize = 1
tblOrientations:
; AS DEFINED:
.byte 0 ; start (as offset from start of sprite)
.word 1 ; step (can be negative)
.word 0 ; amount to adjust cursor between rows (can be negative)
declVar varOpen, 1
declVar varCH, 1
declVar varCV, 1
declVar varSprNum, 1
config: .byte 1
types: .byte TAKI_CFGTY_BYTE
words:
scrcode "OPEN"
.byte $00 ; terminator
TAKI_EFFECT TE_Door, "DOOR", 0, config
cmp #TAKI_DSP_INIT ; init?
bne CkColl
;; INIT
; Allocate the space we will need
effAllocate kVarSpaceNeeded
; save cursor X and Y
lda #0
effSetVar varOpen
lda Mon_CH
sta SavedCH
effSetNext ; varCH
lda Mon_CV
sta SavedCV
effSetNext ; varCV
lda Mon_BASL
sta SavedBAS
lda Mon_BASH
sta SavedBAS+1
lda #0
effSetNext ; varSprNum
jsr drawDoor
jmp Cleanup
UnsupportedMode:
rts
CkColl:
cmp #TAKI_DSP_COLLECT ; collect?
bne CkTick
; COLLECT
lda TAKI_ZP_ACC
jmp TakiIoFastOut ; XXX
CkTick:
cmp #TAKI_DSP_TICK ; tick?
bne UnsupportedMode
;; TICK
; Save away current CH, CV, and BAS
lda Mon_CH
sta SavedCH
lda Mon_CV
sta SavedCV
lda Mon_BASL
sta SavedBAS
lda Mon_BASH
sta SavedBAS+1
; Are we opening or closing a door?
effGetVar varOpen
bne @openDoor
@closeDoor:
; Decrement sprite #
effGetVar varSprNum
beq @drawDoor
sec
sbc #1
effSetCur
jmp @drawDoor
@openDoor:
; Increment sprite #
effGetVar varSprNum
cmp #(kNumSprites-1)
beq @drawDoor
clc
adc #1
effSetCur
@drawDoor:
jsr drawDoor
jmp Cleanup
Cleanup:
lda SavedCH
sta Mon_CH
lda SavedCV
sta Mon_CV
lda SavedBAS
sta Mon_BASL
lda SavedBAS+1
sta Mon_BASH
rts
SavedCH:
.byte 0
SavedCV:
.byte 0
SavedBAS:
.word 0
vSpriteCursor = TAKI_ZP_EFF_SPECIAL_0
vOrientation = TAKI_ZP_EFF_SPECIAL_2
vRowsLeft:
.byte 0
drawDoor:
; Init
lda #>tblSprites
sta vSpriteCursor+1
lda #<tblSprites
sta vSpriteCursor
lda #kSpriteHeight
sta vRowsLeft
;
; Adjust values per pakku's orientation
;
lda #<tblOrientations
sta vOrientation
lda #>tblOrientations
sta vOrientation+1
; adjust values
ldy #0
lda (vOrientation),y
sta @orStart+1
iny
lda (vOrientation),y
sta @orStepL+1
iny
lda (vOrientation),y
sta @orStepH+1
iny
lda (vOrientation),y
sta @orRowAdjL+1
iny
lda (vOrientation),y
sta @orRowAdjH+1
; Adjust for sprite #
effGetVar varSprNum
tax
beq @correctSpr
@nextSpr:
lda vSpriteCursor
clc
adc #kSpriteSize
sta vSpriteCursor
bcc :+
inc vSpriteCursor+1
:
dex
bne @nextSpr
@correctSpr:
; Now adjust for orientation start
lda vSpriteCursor
clc
@orStart:
adc #0 ; this op WILL BE MODIFIED for orientation
sta vSpriteCursor
bcc :+
inc vSpriteCursor+1
:
effGetVar varCV
pha
@rowLoop:
; Calculate memory location from y
sta Mon_CV
jsr Mon_VTAB
; Now add x
effGetVar varCH
clc
adc Mon_BASL
sta Mon_BASL
bcc :+
inc Mon_BASH
:
ldy #0
ldx #kSpriteWidth
@colLoop:
; copy "pixel" character
lda (vSpriteCursor),y
sta (Mon_BASL),y
; advance cursors
inc Mon_BASL
lda vSpriteCursor
clc
@orStepL:
adc #1 ; this op WILL BE MODIFIED for orientation
sta vSpriteCursor
lda vSpriteCursor+1
@orStepH:
adc #0 ; this op WILL BE MODIFIED for orientation
sta vSpriteCursor+1
;
dex
bne @colLoop ;END LOOP colLoop
; Are we done?
dec vRowsLeft
bne @notDone
; END LOOP rowLoop
pla
rts
@notDone:
; advance sprite cursor
lda vSpriteCursor
clc
@orRowAdjL:
adc #0 ; this op WILL BE MODIFIED for orientation
sta vSpriteCursor
lda vSpriteCursor+1
@orRowAdjH:
adc #0 ; this op WILL BE MODIFIED for orientation
sta vSpriteCursor+1
; advance CV
pla
clc
adc #1
pha
jmp @rowLoop