forked from mist64/msbasic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.s
410 lines (396 loc) · 7.41 KB
/
print.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
.segment "CODE"
.ifdef AIM65
PRINT:
lda PRIFLG
sta ZBE
jsr L297E
LB8B1:
lda ZBE
sta PRIFLG
rts
.endif
PRSTRING:
jsr STRPRT
L297E:
jsr CHRGOT
; ----------------------------------------------------------------------------
; "PRINT" STATEMENT
; ----------------------------------------------------------------------------
.ifndef AIM65
PRINT:
.endif
beq CRDO
PRINT2:
beq L29DD
.ifdef AIM65
jsr LB89D
beq L29DD
.endif
cmp #TOKEN_TAB
beq L29F5
cmp #TOKEN_SPC
.ifdef CONFIG_2
clc ; also AppleSoft II
.endif
beq L29F5
cmp #','
; Pre-KIM had no CLC. KIM added the CLC
; here. Post-KIM moved the CLC up...
; (makes no sense on KIM, liveness = 0)
.if .def(CONFIG_11A) && (!.def(CONFIG_2))
clc
.endif
beq L29DE
cmp #$3B
beq L2A0D
jsr FRMEVL
bit VALTYP
bmi PRSTRING
jsr FOUT
jsr STRLIT
.ifndef CONFIG_NO_CR
ldy #$00
lda (FAC_LAST-1),y
clc
adc POSX
.ifdef KBD
cmp #$28
.else
cmp Z17
.endif
bcc L29B1
jsr CRDO
L29B1:
.endif
jsr STRPRT
.ifdef KBD
jmp L297E
.else
jsr OUTSP
bne L297E ; branch always
.endif
.ifdef KBD
; PATCHES
LE86C:
pla
jmp CONTROL_C_TYPED
LE870:
jsr GETBYT
txa
LE874:
beq LE878
bpl LE8F2
LE878:
jmp IQERR
; PATCHES
.endif
.ifndef KBD
L29B9:
.if .def(CBM2) || .def(KIMROM)
lda #$00
sta INPUTBUFFER,x
ldx #<(INPUTBUFFER-1)
ldy #>(INPUTBUFFER-1)
.else
.ifndef APPLE
ldy #$00
sty INPUTBUFFER,x
ldx #LINNUM+1
.endif
.if .def(MICROTAN) || .def(SYM1)
bne CRDO2
.endif
.endif
.ifdef CONFIG_FILE
lda CURDVC
bne L29DD
.endif
.endif
CRDO:
.if .def(CONFIG_PRINTNULLS) && .def(CONFIG_FILE)
lda CURDVC
bne LC9D8
sta POSX
LC9D8:
.endif
lda #CRLF_1
.ifndef CONFIG_CBM_ALL
sta POSX
.endif
jsr OUTDO
CRDO2:
lda #CRLF_2
jsr OUTDO
PRINTNULLS:
.if .def(KBD) || .def(AIM65)
lda #$00
sta POSX
eor #$FF
.else
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
.ifdef CONFIG_FILE
; Although there is no statement for it,
; CBM1 had NULL support and ignores
; it when not targeting the screen,
; CBM2 dropped it completely.
lda CURDVC
bne L29DD
.endif
txa
pha
ldx Z15
beq L29D9
.ifdef SYM1
lda #$FF
.else
lda #$00
.endif
L29D3:
jsr OUTDO
dex
bne L29D3
L29D9:
stx POSX
pla
tax
.else
.ifndef CONFIG_2
lda #$00
sta POSX
.endif
eor #$FF
.endif
.endif
L29DD:
rts
L29DE:
lda POSX
.ifndef CONFIG_NO_CR
.ifdef KBD
cmp #$1A
.else
cmp Z18
.endif
bcc L29EA
jsr CRDO
jmp L2A0D
L29EA:
.endif
sec
L29EB:
.if .def(CONFIG_CBM_ALL) || .def(AIM65)
sbc #$0A
.else
.ifdef KBD
sbc #$0D
.else
sbc #$0E
.endif
.endif
bcs L29EB
eor #$FF
adc #$01
bne L2A08
L29F5:
.ifdef CONFIG_11A
php
.else
pha
.endif
jsr GTBYTC
cmp #')'
.ifdef CONFIG_11A
.ifdef CONFIG_2
bne SYNERR4
.else
jne SYNERR
.endif
plp
bcc L2A09
.else
.ifdef CONFIG_11
jne SYNERR
.else
bne SYNERR4
.endif
pla
cmp #TOKEN_TAB
.ifdef CONFIG_11
bne L2A09
.else
bne L2A0A
.endif
.endif
txa
sbc POSX
bcc L2A0D
.ifndef CONFIG_11
beq L2A0D
.endif
L2A08:
tax
.ifdef CONFIG_11
L2A09:
inx
.endif
L2A0A:
.ifndef CONFIG_11
jsr OUTSP
.endif
dex
.ifndef CONFIG_11
bne L2A0A
.else
bne L2A13
.endif
L2A0D:
jsr CHRGET
jmp PRINT2
.ifdef CONFIG_11
L2A13:
jsr OUTSP
bne L2A0A
.endif
; ----------------------------------------------------------------------------
; PRINT STRING AT (Y,A)
; ----------------------------------------------------------------------------
STROUT:
jsr STRLIT
; ----------------------------------------------------------------------------
; PRINT STRING AT (FACMO,FACLO)
; ----------------------------------------------------------------------------
STRPRT:
jsr FREFAC
tax
ldy #$00
inx
L2A22:
dex
beq L29DD
lda (INDEX),y
jsr OUTDO
iny
cmp #$0D
bne L2A22
jsr PRINTNULLS
jmp L2A22
; ----------------------------------------------------------------------------
OUTSP:
.ifdef CONFIG_FILE
.ifndef CBM1
; on non-screen devices, print SPACE
; instead of CRSR RIGHT
lda CURDVC
beq LCA40
lda #$20
.byte $2C
LCA40:
.endif
lda #$1D ; CRSR RIGHT
.else
lda #$20
.endif
.byte $2C
OUTQUES:
lda #$3F
; ----------------------------------------------------------------------------
; PRINT CHAR FROM (A)
; ----------------------------------------------------------------------------
OUTDO:
.ifndef KBD
bit Z14
bmi L2A56
.endif
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
; Commodore forgot to remove this in CBM1
pha
.endif
.ifdef CBM1
cmp #$1D ; CRSR RIGHT
beq LCA6A
cmp #$9D ; CRSR LEFT
beq LCA5A
cmp #$14 ; DEL
bne LCA64
LCA5A:
lda POSX
beq L2A4E
lda CURDVC
bne L2A4E
dec POSX
LCA64:
and #$7F
.endif
.ifndef CBM2
cmp #$20
bcc L2A4E
.endif
LCA6A:
.ifdef CONFIG_CBM1_PATCHES
lda CURDVC
jsr PATCH6
nop
.endif
.ifdef CONFIG_PRINT_CR
lda POSX
cmp Z17
bne L2A4C
.ifdef AIM65
lda #$00
sta POSX
.elseif .def(APPLE)
nop ; PATCH!
nop ; don't print CR
nop
.else
jsr CRDO
.endif
L2A4C:
.endif
.ifndef CONFIG_CBM_ALL
inc POSX
.endif
L2A4E:
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
; Commodore forgot to remove this in CBM1
pla
.endif
.ifdef CONFIG_MONCOUT_DESTROYS_Y
sty DIMFLG
.endif
.ifdef CONFIG_IO_MSB
ora #$80
.endif
jsr MONCOUT
.ifdef CONFIG_IO_MSB
and #$7F
.endif
.ifdef CONFIG_MONCOUT_DESTROYS_Y
ldy DIMFLG
.endif
.ifdef OSI
nop
nop
nop
nop
.endif
L2A56:
and #$FF
LE8F2:
rts
; ----------------------------------------------------------------------------
; ???
; ----------------------------------------------------------------------------
.ifdef KBD
LE8F3:
pha
lda $047F
clc
beq LE900
lda #$00
sta $047F
sec
LE900:
pla
rts
.endif