-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathed5.src
376 lines (301 loc) · 5.94 KB
/
ed5.src
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
.page
.subttl ed5 escape handler (05/06/85)
;///////////// E S C A P E F U N C T I O N S \\\\\\\\\\\\\\
; escape sequence handler. entry: character following <escape> in .a
escchr jmp (escvec) ;'escape' indirect
escape cmp #esc
bne 1$ ;...branch if not double <escape>
lsr datax ;...else cancel <escape> sequencer by fucking up lstchr
jmp toqm ;...and exit via 'toqm' to cancel all other modes too
1$ and #$7f
sec
sbc #'@' ;table begins at ascii '@' & ends at 'z'
cmp #27 ;'z'-'@'+1
bcs escrts ;invalid char...ignore it!
asl a ;character is index to dispatch table
tax
lda escvct+1,x ;get address of escape routine, push it, & rts to it
pha
lda escvct,x
pha
escrts rts
escvct .word eeos-1 ;@ erase to end of screen
.word auton-1 ;a auto insert
.word sethtb-1 ;b set bottom
.word autoff-1 ;c cancel auto insert
.word dline-1 ;d delete line
.word crsrnf-1 ;e select non-flashing cursor
.word crsrbl-1 ;f flashing cursor
.word bellon-1 ;g enable bell
.word bellof-1 ;h disable bell
.word iline-1 ;i insert line
.word fndsol-1 ;j move to start of line
.word fndeol-1 ;k move to end of line
.word scrsw0-1 ;l enable scrolling
.word scrsw1-1 ;m disable scrolling
.word dspnml-1 ;n un-reverse 8563 screen
.word toqm-1 ;o cancel insert, quote, reverse, ul & flash modes
.word etstol-1 ;p erase to start of line
.word etol-1 ;q erase to end of line
.word dsprvs-1 ;r reverse 8563 screen
.word crsral-1 ;s 8563 block cursor
.word sethtt-1 ;t set top of page
.word crsrul-1 ;u 8563 underscore cursor
.word suup-1 ;v scroll up
.word sddn-1 ;w scroll down
.word swap-1 ;x switch between 40/80 display modes
.word taball-1 ;y set default tab stops
.word tabclr-1 ;z clear all tab stops
.page
;*****************************
;
; window modes
;
;*****************************
sethtt
clc ;set top of window
.byte $24
sethtb
sec ;set bottom of window
ldx pntr
lda tblx
window bcc sttop ;//////entry from editor jump table here!
stbot
sta scbot
stx scrt
jmp rewrap
sreset ;reset screen to full window
lda lines ;max # of rows
ldx columns ;max # of columns
jsr stbot
lda #0
tax ;fall thru to set top
sttop
sta sctop ;set top of window
stx sclf
rewrap
lda #0 ;make all lines non-continued
ldx #4
1$
sta bitabl-1,x
dex
bne 1$
rts
.page
;*****************************
;
; insert line
;
;*****************************
iline
jsr scrdwn ;insert a blank line
jsr stu10 ;move to start of line
inx
jsr getbt1
php
jsr putbit ;set continuation same as in previous line
plp
bcs 1$ ;skip if was wrapped
sec
ror lsxp ;set flag - new line
1$
rts
;**************************
;
; delete line
;
;**************************
dline
jsr fistrt ;find start of line
lda sctop ;save current of window
pha
lda tblx ;make 1st display line top of window
sta sctop
lda scroll ;make sure logical scroll is off
pha
lda #$80
sta scroll
jsr scru15 ;scroll the top line away
pla
sta scroll
lda sctop ;make old 1st line of this 1 current
sta tblx
pla
sta sctop
sec
ror lsxp ;set flag - new line
jmp stu10 ;make this line the current one
.page
;******************************
;
; erase to end of line
;
;******************************
etol
jsr savpos
1$
jsr clrprt ;blank rest of line
inc tblx ;move to next line
jsr stupt
ldy sclf
jsr getbit ;check if next is wrapped line
bcs 1$ ;yes - blank next line
etout
jmp delout ;exit and restore original position
;*****************************
;
; erase to start of line
;
;*****************************
etstol
jsr savpos
1$
jsr blank ;do a blank
cpy sclf ;done a line?
bne 2$ ;no
jsr getbit ;at top of line
bcc etout ;yes - exit
2$ jsr bakchr ;back up
bcc 1$ ;always
;******************************
;
; erase to end of screen
;
;******************************
eeos
jsr savpos
1$
jsr clrprt ;blank rest of line
inc tblx ;move to next line
jsr stupt
ldy sclf
jsr getbit ;check if next is wrapped line
bcs 1$ ;yes - blank next line
lda tblx
cmp scbot ;check if at end of screen
bcc 1$
beq 1$
jmp delout ;exit and restore original position
.page
;*****************************
;
; scroll up
;
;*****************************
suup
jsr savpos
txa
pha
jsr scrup
pla
sta sedt2
jmp delout
;*****************************
;
; scroll down
;
;*****************************
sddn
jsr savpos
jsr getbit
bcs 1$
sec
ror lsxp ;set flag - left line
1$
lda sctop
sta tblx ;scroll from screen top
jsr scrdwn
jsr clrbit ;make first line non-continued
jmp delout
.page
;********************************
;
; scrolling enable/disable
;
;********************************
scrsw0
lda #0 ;enable scrolling
.byte $2c
scrsw1
lda #$80 ;disable scrolling
sta scroll
rts
;*******************************
;
; auto insert on/off
;
;*******************************
autoff
lda #0
.byte $2c
auton
lda #$ff
sta insflg
rts
.page
;*******************************
;
; cursor modes
;
;*******************************
crsral
bit mode
bpl crsr_c
lda curmod ;8563 solid cursor
and #$e0
jmp crsr_a ;bra
crsrul
bit mode
bpl crsr_c
lda curmod ;8563 underline cursor
and #$e0
ora #$07
bne crsr_a ;bra
crsrnf
bit mode ;select non-blinking cursor
bpl crsr_d
lda curmod ;8563 hardware cursor
and #$1f
crsr_a sta curmod
jmp crsrdo
crsr_d lda blnon ;vic cursor
ora #$40
bne crsr_b ;bra
crsrbl
bit mode ;select blinking cursor
bpl 1$
lda curmod ;8563 hardware cursor
and #$1f
ora #$60
bne crsr_a ;bra
1$ lda blnon ;vic cursor
and #$bf
crsr_b sta blnon
crsr_c rts
.page
;*******************************
;
; bell (ctrl-g) on/off
;
;*******************************
bellon
lda #0
.byte $2c
bellof
lda #$80
sta beeper
rts
dsprvs
ldx #24 ;reverse 8563 display
jsr vdcin
ora #$40
bne dspxxx
dspnml
ldx #24 ;normal 8563 display
jsr vdcin
and #$bf
dspxxx jmp vdcout
fndeol
jsr fndend ;move to last character in line
jmp movchr ;move past it & start a wrapped line if necessary
;.end