-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscroll.acme
309 lines (265 loc) · 5.22 KB
/
scroll.acme
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
SCROLL_COLS = SCR_COLS
SCROLL_ROWS = SCR_ROWS-2
INC_HARD_Y !zone {
inc HARD_Y
lda #SCR_ROWS+1
cmp HARD_Y
bne .return
lda #0
sta HARD_Y
lda HARD_X
sec
sbc #16
sta HARD_X
clc
adc #SCR_COLS
cmp #SCR_COLS
bcs .return ; jmp if A < 40
sta HARD_X
inc HARD_Y
.return
rts
}
DEC_HARD_Y !zone {
dec HARD_Y
bpl .return
lda #SCR_ROWS
sta HARD_Y
lda HARD_X
clc
adc #16
sta HARD_X
sec
sbc #SCR_COLS
bmi .return
sta HARD_X
dec HARD_Y
.return
rts
}
!macro wrap_inc .mem, .inc, .and, .l {
lda .mem
clc
adc #.inc
and #.and-1 ; assumes 2^x = .and
sta .mem
bne .l
}
!macro wrap_dec .mem, .dec, .and, .l {
lda .mem
sec
sbc #.dec
and #.and-1 ; assumes 2^x = .and
sta .mem
bcs .l
}
!macro wrap_add .lo, .hi, .add, .and {
clc
lda .lo
adc #(.add % 256)
sta .lo
!if .add < 256 {
bcc +
}
lda .hi
adc #(.add / 256)
and #.and-1 ; assumes 2^x = .and
sta .hi
+
}
!macro wrap_sub .lo, .hi, .sub, .and {
sec
lda .lo
sbc #(.sub % 256)
sta .lo
!if .sub < 256 {
bcs +
}
lda .hi
sbc #(.sub / 256)
and #.and-1 ; assumes 2^x = .and
sta .hi
+
}
SCROLL_U !zone {
; lda VIC_SPR_0_Y
; cmp #73
; beq+
; !for .i, 0, 7 {
; ;dec VIC_SPR_0_Y + .i*2
; }
;+
+wrap_dec SOFT_Y, SCROLL_SPEED, 8, .check_copy_tiles
jsr DEC_HARD_Y
rts
.check_copy_tiles
; lda SOFT_Y
!if SCROLL_SPEED = 2 { cmp #2 } else { cmp #3 }
beq .prepare_copy_tiles
rts
.prepare_copy_tiles
lda #COPY_COL_FRAMES
sta C_COPY
lda TILE_ROW
sec
sbc #1
bcs +
adc #TILE_ROWS
dec C_MAP_POS_HI
dec R_MAP_POS_HI
+
sta TILE_ROW
+wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, SCROLL_COLS, 4
+wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS, 4
+wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8*SCROLL_COLS, 8*4
+wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8*SCROLL_COLS, 8*4
lda SCROLL_U_D
beq +
sec
lda C_MAP_POS_HI
sbc #(SCROLL_ROWS-1)/TILE_ROWS
sta C_MAP_POS_HI
+wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, (SCROLL_ROWS-1)*SCROLL_COLS, 4
+wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8*(SCROLL_ROWS-1)*SCROLL_COLS, 8*4
lda #0
sta SCROLL_U_D
+
rts
}
SCROLL_D !zone {
; !for .i, 0, 7 {
; ;inc VIC_SPR_0_Y + .i*2
; }
+wrap_inc SOFT_Y, SCROLL_SPEED, 8, .check_copy_tiles
jsr INC_HARD_Y
rts
.check_copy_tiles
; lda SOFT_Y
cmp #4
beq .prepare_copy_tiles
rts
.prepare_copy_tiles
lda #COPY_COL_FRAMES
sta C_COPY
lda TILE_ROW
clc
adc #1
cmp #TILE_ROWS
bcc +
sbc #TILE_ROWS
inc C_MAP_POS_HI
inc R_MAP_POS_HI
+
sta TILE_ROW
+wrap_add C_SCR_POS_LO, C_SCR_POS_HI, SCROLL_COLS, 4
+wrap_add R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS, 4
+wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8*SCROLL_COLS, 8*4
+wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8*SCROLL_COLS, 8*4
lda SCROLL_U_D
bne +
clc
lda C_MAP_POS_HI
adc #(SCROLL_ROWS-1)/TILE_ROWS
sta C_MAP_POS_HI
+wrap_add C_SCR_POS_LO, C_SCR_POS_HI, (SCROLL_ROWS-1)*SCROLL_COLS, 4
+wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8*(SCROLL_ROWS-1)*SCROLL_COLS, 8*4
lda #1
sta SCROLL_U_D
+
rts
}
SCROLL_L !zone {
; !for .i, 0, 7 {
; ;dec VIC_SPR_0_X + .i*2
; }
+wrap_inc SOFT_X, SCROLL_SPEED, 8, .check_copy_tiles
inc HARD_X
lda #SCR_COLS
cmp HARD_X
bne +
lda #0
sta HARD_X
jsr DEC_HARD_Y
+
rts
.check_copy_tiles
; lda SOFT_X
cmp #4
beq .prepare_copy_tiles
rts
.prepare_copy_tiles
lda #COPY_ROW_FRAMES
sta R_COPY
lda TILE_COL
sec
sbc #1
bcs +
adc #TILE_COLS
dec C_MAP_POS_LO
dec R_MAP_POS_LO
+
sta TILE_COL
+wrap_sub C_SCR_POS_LO, C_SCR_POS_HI, 1, 4
+wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, 1, 4
+wrap_sub C_PIX_POS_LO, C_PIX_POS_HI, 8, 8*4
+wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8, 8*4
lda SCROLL_L_R
beq +
sec
lda R_MAP_POS_LO
sbc #(SCROLL_COLS-1)/TILE_COLS
sta R_MAP_POS_LO
+wrap_sub R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS-1, 4
+wrap_sub R_PIX_POS_LO, R_PIX_POS_HI, 8*(SCROLL_COLS-1), 8*4
lda #0
sta SCROLL_L_R
+
rts
}
SCROLL_R !zone {
; !for .i, 0, 7 {
; ;inc VIC_SPR_0_X + .i*2
; }
+wrap_dec SOFT_X, SCROLL_SPEED, 8, .check_copy_tiles
dec HARD_X
bpl +
lda #SCR_COLS-1
sta HARD_X
jsr INC_HARD_Y
+
rts
.check_copy_tiles
; lda SOFT_X
!if SCROLL_SPEED = 2 { cmp #2 } else { cmp #3 }
beq .prepare_copy_tiles
rts
.prepare_copy_tiles
lda #COPY_ROW_FRAMES
sta R_COPY
lda TILE_COL
clc
adc #1
cmp #TILE_COLS
bcc +
sbc #TILE_COLS
inc C_MAP_POS_LO
inc R_MAP_POS_LO
+
sta TILE_COL
+wrap_add C_SCR_POS_LO, C_SCR_POS_HI, 1, 4
+wrap_add R_SCR_POS_LO, R_SCR_POS_HI, 1, 4
+wrap_add C_PIX_POS_LO, C_PIX_POS_HI, 8, 8*4
+wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8, 8*4
lda SCROLL_L_R
bne +
clc
lda R_MAP_POS_LO
adc #(SCROLL_COLS-1)/TILE_COLS
sta R_MAP_POS_LO
+wrap_add R_SCR_POS_LO, R_SCR_POS_HI, SCROLL_COLS-1, 4
+wrap_add R_PIX_POS_LO, R_PIX_POS_HI, 8*(SCROLL_COLS-1), 8*4
lda #1
sta SCROLL_L_R
+
rts
}