-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot
More file actions
468 lines (441 loc) · 5.45 KB
/
plot
File metadata and controls
468 lines (441 loc) · 5.45 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
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
*fx11
AUTO
REMMODE 4:linelen=&140
MODE0:linelen=&280
HIMEM=&4800
C.129:C.0
CLS
V.28,0,31,79,20
DIM code% 2048
chars=&4800
OSCLI"L.CHARS "+STR$~chars
nchars=chars?0
widthlo=chars+2
widthhi=chars+2+nchars
h%=chars?1
DIM blank h%
FOR I%=0 TOh%-1:blank?I%=0:NEXT
tmp1=&70
tmp2=&71
tmp=&72
revmask=&73
ptr1=&74
ptr2=&76
ptr3=&86
tmp3=&88
lmask=&78
rmask=&79
fontwidth=&7A
xoffset=&7B
fontptr=&7C
height=&80
drawnlines=&81
screenptr=&84
fontptr2=&8A
FOR I%=0 TO2 STEP 2
P%=code%
[OPT I%
.lmasks
\ 7F BF DF EF F7 FB FD FE
\ 3F 9F CF E7 F3 F9 FC FE
\ 1F 8F C7 E3 F1 F8 FC FE
\ 0F 87 C3 E1 F0 F8 FC FE
\ 07 83 C1 E0 F0 F8 FC FE
\ 03 81 C0 E0 F0 F8 FC FE
\ 01 80 C0 E0 F0 F8 FC FE
\ 00 80 C0 E0 F0 F8 FC FE
equd &E0C08000: equd &FEFCF8F0 \ width >=8
equd &EFDFBF7F: equd &FEFDFBF7 \ width 1
equd &E7CF9F3F: equd &FEFCF9F3 \ width 2
equd &E3C78F1F: equd &FEFCF8F1 \ width 3
equd &E1C3870F: equd &FEFCF8F0 \ width 4
equd &E0C18307: equd &FEFCF8F0 \ width 5
equd &E0C08103: equd &FEFCF8F0 \ width 6
equd &E0C08001: equd &FEFCF8F0 \ width 7
\ equd &E0C08000: equd &FEFCF8F0 \ width 8
\ width >8 are all the same as 8
\if width+offset<=8 rmask=FF
.rmasks
equb &7F
equb &3F
equb &1F
equb &0F
equb &07
equb &03
equb &01
equb &00 \ width 9
\7654321076543210
\ vvvvvvvv
\tmp1 is left byte mask
\tmp2 is right byte mask
\tmp is right byte data to plot
.branches1 \ PC+2+off
equb b1_0-b1_ \ unused
equb b1_1-b1_
equb b1_2-b1_
equb b1_3-b1_
equb b1_4-b1_
equb b1_5-b1_
equb b1_6-b1_
equb b1_7-b1_
.branches2byte
\ equb 23
\ equb 20
\ equb 17
\ equb 14
\ equb 11
\ equb 8
\ equb 5
\ equb 2
equb twoblank-branch2_
equb b2_1-branch2_
equb b2_2-branch2_
equb b2_3-branch2_
equb b2_4-branch2_
equb b2_5-branch2_
equb b2_6-branch2_
equb b2_7-branch2_
.thischar
EQUB 32
.speedtest
LDA thischar
JSR plot
INC thischar
BPL speedtest
LDA #32
STA thischar
RTS
.wrchv
STA thischar
TXA
PHA
TYA
PHA
LDA thischar
SEC
SBC#32
JSR plot
PLA
TAY
PLA
TAX
RTS
.plot
tax
lda widthlo,X
sta fontptr
lda widthhi,X
and #&0F
clc
adc #chars DIV256
sta fontptr+1
lda widthhi,X
lsr a
lsr a
lsr a
lsr a
\clc \ already clear
adc #1
sta fontwidth
lda #h%
sta height
\copy screenptr to ptr1
lda screenptr
sta ptr1
lda screenptr+1
sta ptr1+1
.doplot
lda ptr1
and #7
eor #7
clc
adc #1
\ A is how many lines we can draw
cmp height
bcc drawsome \ >= height?
beq drawsome
.drawall
lda height
.drawsome
tay
sty drawnlines
dey
\sta tmp
\lda height
\sec
\sbc tmp
\sta height
tya
eor #&FF
clc
adc height
sta height
\lda drawnlines
\ora #&30
\jsr &FFEE
.draw
\ put ptr1+8 in ptr2
clc
lda ptr1
adc #8
sta ptr2
lda ptr1+1
adc #0
sta ptr2+1
\get lmask
lda fontwidth
bit #&F8
beq widthle8 \ <= 8
\set fontptr2 to second byte by adding height
lda #h%
clc
adc fontptr
sta fontptr2
lda fontptr+1
adc #0
sta fontptr2+1
ldx xoffset
bpl getlmask \ always
.widthle8
asl a
asl a
asl a
ora xoffset
tax
lda #blank MOD256
sta fontptr2
lda #blank DIV256
sta fontptr2+1
.getlmask
lda lmasks,X \ 8 bytes each, 1-indexed
sta lmask
\get rmask if needed
clc
lda fontwidth
adc xoffset
cmp #9
bcc onebyte \ width+offset<=8 -> one byte
tax
cpx #17
bcc twobytes
.threebytes
lda rmasks-17,X
sta rmask
\brk
jmp threebytesreal
.twobytes
lda rmasks-9,X
sta rmask
ldx xoffset
lda branches2byte,X
sta branch2+1
.loop1
lda (fontptr2),Y
sta tmp
lda (ptr1),Y
and lmask
sta tmp1
lda (ptr2),Y
and rmask
sta tmp2
lda (fontptr),Y
\eor revmask
.branch2
bne branch2
.branch2_
beq twoblank
.b2_7
\asl a
\sta tmp
\lda #0
\adc #0
\bcc twoblank \ always
lsr a
ror tmp
.b2_6
lsr a
ror tmp
.b2_5
lsr a
ror tmp
.b2_4
lsr a
ror tmp
.b2_3
lsr a
ror tmp
.b2_2
lsr a
ror tmp
.b2_1
lsr a
ror tmp
.twoblank
ora tmp1
sta (ptr1),Y
lda tmp2
ora tmp
sta (ptr2),Y
dey
bpl loop1
jmp done
.noshift
bit lmask
bmi noshiftnomask
.loopnoshift
lda (ptr1),Y
and lmask
ora (fontptr),Y
sta (ptr1),Y
dey
bpl loopnoshift
jmp done
.noshiftnomask
.loopnsnm
lda (fontptr),Y
sta (ptr1),Y
dey
bpl loopnsnm
jmp done
.onebyte
ldx xoffset
\ check for no shifting required
beq noshift
lda branches1,X
sta loop11branch+1
clc
.loop1byte
lda (ptr1),Y
and lmask
sta tmp1
lda (fontptr),Y
\eor revmask
.loop11branch
bcc loop11branch
.b1_
.b1_7
lsr a
.b1_6
lsr a
.b1_5
lsr a
.b1_4
lsr a
.b1_3
lsr a
.b1_2
lsr a
.b1_1
lsr a
.b1_0
ora tmp1
sta (ptr1),Y
dey
bpl loop1byte
\jmp done
.done
lda height
beq reallydone
.add2802
clc
lda ptr1
adc #linelen MOD256
and #&F8
sta ptr1
lda ptr1+1
adc #linelen DIV256
sta ptr1+1
\no need for clc
lda fontptr
adc drawnlines
sta fontptr
lda fontptr+1
adc #0
sta fontptr+1
jmp doplot
.reallydone
clc
lda fontwidth
adc xoffset
sta tmp
and #7
sta xoffset
lda tmp
and #&F8
beq noscreeninc
sta tmp
\no need for clc
lda screenptr
adc tmp
sta screenptr
bcc noscreeninc
inc screenptr+1
.noscreeninc
rts
.threebytesreal
lda ptr1
clc
adc #16
sta ptr3
lda ptr1+1
adc #0
sta ptr3+1
.loop3
lda (fontptr2),Y
sta tmp
lda #0
sta tmp3
lda (ptr1),Y
and lmask
sta tmp1
lda (ptr3),Y
and rmask
sta tmp2
lda (fontptr),Y
ldx xoffset
beq nothreeloop
.threeloop
lsr a
ror tmp
ror tmp3
dex
bne threeloop
.nothreeloop
ora tmp1
sta (ptr1),Y
lda tmp
sta (ptr2),Y
lda tmp3
ora tmp2
sta (ptr3),Y
dey
bpl loop3
jmp done
]
NEXT
DIM string 100
REM$string="Hello, world!"
$string="Pack my box with five dozen liquor jugsssssASD"
?xoffset=0
REPEAT
REMFOR n%=0 TO LEN$string-1
REMch%=string?n%-32
!screenptr=&5800+RND(&2800)
FOR A%=0 TO95
CALLplot
NEXT
IFGET
UNTIL 0
END
!fontptr=fontdata
?fontwidth=7
?xoffset=0
!ptr1=&4000
FOR C=0 TO 77
CALLplot
V.30
P."lmask=",~?lmask," rmask=",~?rmask
IFGET
?xoffset=?xoffset+?fontwidth
IF ?xoffset>=8:?xoffset=?xoffset-8:!ptr1=!ptr1+8
NEXT