-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgraphics.s
387 lines (329 loc) · 5.73 KB
/
graphics.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
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
;
; graphics.s
;
; Created by Quinn Dunki on 9/10/16
; Copyright (c) 2015 One Girl, One Laptop Productions. All rights reserved.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; EnableHires
;
EnableHires:
sta TEXT
sta HIRES1
sta HIRES2
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; EnableText
;
EnableText:
sta TEXT2
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SaveBackground
; PARAM0: X pos
; PARAM1: Y pos
; PARAM2: Storage area (LSB)
; PARAM3: Storage area (MSB)
;
; Assumes 6-byte-wide, 8px-high sprites
;
SaveBackground:
SAVE_AXY
ldy #0
lda #0
pha
saveBackground_loop:
clc
pla
pha
adc PARAM1 ; Calculate Y line
tax
lda HGRROWS_H1,x ; Compute hires row
sta saveBackground_smc0+2
sta saveBackground_smc1+2
sta saveBackground_smc2+2
sta saveBackground_smc3+2
sta saveBackground_smc4+2
sta saveBackground_smc5+2
lda HGRROWS_L,x
sta saveBackground_smc0+1
sta saveBackground_smc1+1
sta saveBackground_smc2+1
sta saveBackground_smc3+1
sta saveBackground_smc4+1
sta saveBackground_smc5+1
ldx PARAM0 ; Compute hires column
lda DIV7_2,x
tax
saveBackground_smc0:
lda $2000,x
sta (PARAM2),y
iny
inx
saveBackground_smc1:
lda $2000,x
sta (PARAM2),y
iny
inx
saveBackground_smc2:
lda $2000,x
sta (PARAM2),y
iny
inx
saveBackground_smc3:
lda $2000,x
sta (PARAM2),y
iny
inx
saveBackground_smc4:
lda $2000,x
sta (PARAM2),y
iny
inx
saveBackground_smc5:
lda $2000,x
sta (PARAM2),y
iny
pla
inc
pha
cpy #48
bne saveBackground_loop
pla
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RestoreBackground
; PARAM0: X pos
; PARAM1: Y pos
; PARAM2: Storage area (LSB)
; PARAM3: Storage area (MSB)
;
; Assumes 4-byte-wide, 8px-high sprites
;
RestoreBackground:
SAVE_AXY
ldy #0
lda #0
pha
restoreBackground_loop:
clc
pla
pha
adc PARAM1 ; Calculate Y line
tax
lda HGRROWS_H1,x ; Compute hires row
sta restoreBackground_smc0+2
sta restoreBackground_smc1+2
sta restoreBackground_smc2+2
sta restoreBackground_smc3+2
sta restoreBackground_smc4+2
sta restoreBackground_smc5+2
lda HGRROWS_L,x
sta restoreBackground_smc0+1
sta restoreBackground_smc1+1
sta restoreBackground_smc2+1
sta restoreBackground_smc3+1
sta restoreBackground_smc4+1
sta restoreBackground_smc5+1
ldx PARAM0 ; Compute hires column
lda DIV7_2,x
tax
lda (PARAM2),y
restoreBackground_smc0:
sta $2000,x
iny
inx
lda (PARAM2),y
restoreBackground_smc1:
sta $2000,x
iny
inx
lda (PARAM2),y
restoreBackground_smc2:
sta $2000,x
iny
inx
lda (PARAM2),y
restoreBackground_smc3:
sta $2000,x
iny
inx
lda (PARAM2),y
restoreBackground_smc4:
sta $2000,x
iny
inx
lda (PARAM2),y
restoreBackground_smc5:
sta $2000,x
iny
pla
inc
pha
cpy #48
bne restoreBackground_loop
pla
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BlackRect
; PARAM0: X pos
; PARAM1: Y pos
;
; Assumes 6-byte-wide, 8px-high sprites
; 1099 cycles per call
;
BlackRect:
SAVE_AX ; 6
lda #0 ; 2
pha ; 3 9 setup
blackRect_loop:
clc ; 2
pla ; 4
pha ; 3
adc PARAM1 ; 3 ; Calculate Y line
tax ; 2
lda HGRROWS_H1,x ; 4 ; Compute hires row
sta blackRect_smc0+2 ; 4
sta blackRect_smc1+2 ; 4
sta blackRect_smc2+2 ; 4
sta blackRect_smc3+2 ; 4
sta blackRect_smc4+2 ; 4
sta blackRect_smc5+2 ; 4
lda HGRROWS_L,x ; 4
sta blackRect_smc0+1 ; 4
sta blackRect_smc1+1 ; 4
sta blackRect_smc2+1 ; 4
sta blackRect_smc3+1 ; 4
sta blackRect_smc4+1 ; 4
sta blackRect_smc5+1 ; 4
ldx PARAM0 ; 3 ; Compute hires column
lda DIV7_2,x ; 4
tax ; 2
; 79
blackRect_smc0:
stz $2000,x ; 5
inx ; 2
blackRect_smc1:
stz $2000,x ; 5
inx ; 2
blackRect_smc2:
stz $2000,x ; 5
inx ; 2
blackRect_smc3:
stz $2000,x ; 5
inx ; 2
blackRect_smc4:
stz $2000,x ; 5
inx ; 2
blackRect_smc5:
stz $2000,x ; 5
pla ; 4
inc ;2
pha ; 3
cmp #8 ; 2
bne blackRect_loop ; 2 134 per row
pla ; 4
RESTORE_AX ; 8
rts ; 6 18 cleanup
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LinearFill
; A: Byte value to fill
; Trashes all registers
;
LinearFill:
ldx #0
linearFill_outer:
pha
lda HGRROWS_H1,x
sta linearFill_inner+2
lda HGRROWS_L,x
sta linearFill_inner+1
pla
ldy #39
linearFill_inner:
sta $2000,y
dey
bpl linearFill_inner
inx
cpx #192
bne linearFill_outer
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; VenetianFill
; A: Byte value to fill
; Trashes all registers
;
VenetianFill:
ldx #$3f
venetianFill_outer:
stx venetianFill_inner+2
ldy #$00
venetianFill_inner:
sta $2000,y ; Upper byte of address is self-modified
iny
bne venetianFill_inner
dex
cpx #$1f
bne venetianFill_outer
rts
INBUF = $0200
DOSCMD = $be03
KBD = $c000
KBDSTRB = $c010
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CommandLine
;
; PARAM0: Command line string (LSB)
; PARAM1: Command line string (MSB)
;
CommandLine:
SAVE_AXY
ldx #0
ldy #0
CommandLine_loop:
lda (PARAM0),y
beq CommandLine_done
sta $0200,x ; Keyboard input buffer
inx
iny
bra CommandLine_loop
CommandLine_done:
lda #$8d ; Terminate with return and null
sta $0200,x
inx
lda #0
sta $0200,x
jsr $be03 ; ProDOS 8 entry point
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; BloadHires
;
; PARAM0: Filename (LSB)
; PARAM1: Filename (MSB)
;
; Max filename length: 16 chars!
;
BloadHires:
SAVE_AXY
ldx #0
ldy #0
BloadHires_loop:
lda (PARAM0),y ; Copy filename into BLOAD buffer
beq BloadHires_done
sta BloadHires_buffer+6,x
inx
iny
bra BloadHires_loop
BloadHires_done:
lda #<BloadHires_buffer
sta PARAM0
lda #>BloadHires_buffer
sta PARAM1
jsr CommandLine
RESTORE_AXY
rts
BloadHires_buffer:
.byte "BLOAD ",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0