-
Notifications
You must be signed in to change notification settings - Fork 10
/
unit_test.s
368 lines (302 loc) · 4.54 KB
/
unit_test.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
;
; unit_test.s
; WeeGui
;
; Unit tests of various systems
;
; Created by Quinn Dunki on 8/15/14.
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tortureTestPrint
; Prints strings in a range of positions and scrolling offsets
;
; Stack:
; Curr Scroll X
; Curr Scroll Y
; Delta X
; Delta Y
tortureTestPrint:
ldx #WGClearScreen
jsr WeeGUI
lda #0 ; Initialize
ldx #WGScrollX
jsr WeeGUI
ldx #WGScrollY
jsr WeeGUI
tortureTestPrint_init:
WGCALL16 WGCreateView,testPrintView
lda #0
ldx #WGSelectView
jsr WeeGUI
ldx #WGPaintView
jsr WeeGUI
lda #0
pha
pha
lda #-1
pha
pha
tsx
inx
tortureTestPrint_loop:
phx
lda #0 ; Initialize
sta PARAM0
sta PARAM1
ldx #WGSetCursor
jsr WeeGUI
plx
inx ; Grab current delta X
lda $0100,x
inx
inx
clc
adc $0100,x ; Add Scroll X
sta $0100,x
beq tortureTestPrint_flipDeltaX ; Check for bounce
cmp #-5
beq tortureTestPrint_flipDeltaX
bra tortureTestPrint_continueX
tortureTestPrint_flipDeltaX:
dex
dex
lda $0100,x
eor #$ff
inc
sta $0100,x
inx
inx
tortureTestPrint_continueX:
phx
lda $0100,x
ldx #WGScrollX ; Apply current X scroll
jsr WeeGUI
plx
dex
dex
dex
lda $0100,x ; Grab current delta Y
inx
inx
clc
adc $0100,x ; Add Scroll Y
sta $0100,x
beq tortureTestPrint_flipDeltaY ; Check for bounce
cmp #-5
beq tortureTestPrint_flipDeltaY
bra tortureTestPrint_continueY
tortureTestPrint_flipDeltaY:
dex
dex
lda $0100,x
eor #$ff
inc
sta $0100,x
inx
inx
tortureTestPrint_continueY:
phx
lda $0100,x
ldx #WGScrollY
jsr WeeGUI
plx
dex
dex
tortureTestPrint_print:
; VBL_SYNC
phx
ldx #WGEraseViewContents
jsr WeeGUI
WGCALL16 WGPrint,unitTestStr
ldx #WGPrint ; Do it again
jsr WeeGUI
; jmp tortureTestPrint_lock
jsr delay
plx
jmp tortureTestPrint_loop
tortureTestPrint_reset:
pla
pla
jmp tortureTestPrint_init
tortureTestPrint_lock:
jmp tortureTestPrint_lock
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tortureTestRects
; Strokes and paints rectangles of many different geometries
;
; Stack:
; Curr X
; Curr Y
; Curr Width
; Curr Height
tortureTestRects:
ldx #WGClearScreen
jsr WeeGUI
tortureTestRectsEven:
lda #38 ; Initialize
pha
lda #11
pha
lda #2
pha
lda #2
pha
tortureTestRectsEvenLoop:
@0: lda $C019 ; Sync to VBL
bmi @0
ldx #WGClearScreen
jsr WeeGUI
tsx
inx
lda $0100,x ; Load Height, then modify
sta PARAM3
inc
inc
sta $0100,x
cmp #25
bcs tortureTestRectsEvenDone
inx ; Load Width, then modify
lda $0100,x
sta PARAM2
inc
inc
inc
inc
inc
inc
sta $0100,x
inx ; Load Y, then modify
lda $0100,x
sta PARAM1
dec
sta $0100,x
inx ; Load X, then modify
lda $0100,x
sta PARAM0
dec
dec
dec
sta $0100,x
ldy #'Q'+$80
ldx #WGFillRect
jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort
jsr delayShort
jsr delayShort
jmp tortureTestRectsEvenLoop
tortureTestRectsEvenDone:
pla
pla
pla
pla
tortureTestRectsOdd:
lda #37 ; Initialize
pha
lda #11
pha
lda #2
pha
lda #2
pha
tortureTestRectsOddLoop:
ldx #WGClearScreen
jsr WeeGUI
tsx
inx
lda $0100,x ; Load Height, then modify
sta PARAM3
inc
inc
sta $0100,x
cmp #25
bcs tortureTestRectsOddDone
inx ; Load Width, then modify
lda $0100,x
sta PARAM2
inc
inc
inc
inc
inc
inc
sta $0100,x
inx ; Load Y, then modify
lda $0100,x
sta PARAM1
dec
sta $0100,x
inx ; Load X, then modify
lda $0100,x
sta PARAM0
dec
dec
dec
sta $0100,x
ldy #'Q'+$80
ldx #WGFillRect
jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort
jsr delayShort
jsr delayShort
jmp tortureTestRectsOddLoop
tortureTestRectsOddDone:
pla
pla
pla
pla
jmp tortureTestRectsEven
delayShort: ; ~1/30 sec
pha
phx
phy
ldy #$06 ; Loop a bit
delayShortOuter:
ldx #$ff
delayShortInner:
nop
nop
nop
nop
nop
nop
nop
dex
bne delayShortInner
dey
bne delayShortOuter
ply
plx
pla
rts
delay: ; ~1 sec
pha
phx
phy
ldy #$ce ; Loop a bunch
delayOuter:
ldx #$ff
delayInner:
nop
nop
nop
nop
nop
nop
nop
dex
bne delayInner
dey
bne delayOuter
ply
plx
pla
rts
testPrintView:
.byte 0,0,15,6,30,10,40,126
unitTestStr:
.byte "This is a test of the emergency broadcast system. If this had been a real emergency, you would be dead now. Amusingly, it can be noted that if this had been a real emergency, and you were now a steaming pile of ash, there would of course be nobody.",0; to read this message. That begs any number",0; of extistential questions about this very text.",0