-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy patheditor.2
406 lines (406 loc) · 7.91 KB
/
editor.2
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
.PAG 'EDITOR.2'
;SCREEN SCROLL ROUTINE
;
SCROL LDA SAL
PHA
LDA SAH
PHA
LDA EAL
PHA
LDA EAH
PHA
;
; S C R O L L U P
;
SCRO0 LDX #$FF
DEC TBLX
DEC LSXP
DEC LINTMP
SCR10 INX ;GOTO NEXT LINE
JSR SETPNT ;POINT TO 'TO' LINE
CPX #NLINES-1 ;DONE?
BCS SCR41 ;BRANCH IF SO
;
LDA LDTB2+1,X ;SETUP FROM PNTR
STA SAL
LDA LDTB1+1,X
JSR SCRLIN ;SCROLL THIS LINE UP1
BMI SCR10
;
SCR41
JSR CLRLN
;
LDX #0 ;SCROLL HI BYTE POINTERS
SCRL5 LDA LDTB1,X
AND #$7F
LDY LDTB1+1,X
BPL SCRL3
ORA #$80
SCRL3 STA LDTB1,X
INX
CPX #NLINES-1
BNE SCRL5
;
LDA LDTB1+NLINES-1
ORA #$80
STA LDTB1+NLINES-1
LDA LDTB1 ;DOUBLE LINE?
BPL SCRO0 ;YES...SCROLL AGAIN
;
INC TBLX
INC LINTMP
LDA #$7F ;CHECK FOR CONTROL KEY
STA COLM ;DROP LINE 2 ON PORT B
LDA ROWS
CMP #$FB ;SLOW SCROLL KEY?(CONTROL)
PHP ;SAVE STATUS. RESTORE PORT B
LDA #$7F ;FOR STOP KEY CHECK
STA COLM
PLP
BNE MLP42
;
LDY #0
MLP4 NOP ;DELAY
DEX
BNE MLP4
DEY
BNE MLP4
STY NDX ;CLEAR KEY QUEUE BUFFER
;
MLP42 LDX TBLX
;
PULIND PLA ;RESTORE OLD INDIRECTS
STA EAH
PLA
STA EAL
PLA
STA SAH
PLA
STA SAL
RTS
.PAGE
NEWLIN
LDX TBLX
BMT1 INX
; CPX #NLINES ;EXCEDED THE NUMBER OF LINES ???
; BEQ BMT2 ;VIC-40 CODE
LDA LDTB1,X ;FIND LAST DISPLAY LINE OF THIS LINE
BPL BMT1 ;TABLE END MARK=>$FF WILL ABORT...ALSO
BMT2 STX LINTMP ;FOUND IT
;GENERATE A NEW LINE
CPX #NLINES-1 ;IS ONE LINE FROM BOTTOM?
BEQ NEWLX ;YES...JUST CLEAR LAST
BCC NEWLX ;<NLINES...INSERT LINE
JSR SCROL ;SCROLL EVERYTHING
LDX LINTMP
DEX
DEC TBLX
JMP WLOG30
NEWLX LDA SAL
PHA
LDA SAH
PHA
LDA EAL
PHA
LDA EAH
PHA
LDX #NLINES
SCD10 DEX
JSR SETPNT ;SET UP TO ADDR
CPX LINTMP
BCC SCR40
BEQ SCR40 ;BRANCH IF FINISHED
LDA LDTB2-1,X ;SET FROM ADDR
STA SAL
LDA LDTB1-1,X
JSR SCRLIN ;SCROLL THIS LINE DOWN
BMI SCD10
SCR40
JSR CLRLN
LDX #NLINES-2
SCRD21
CPX LINTMP ;DONE?
BCC SCRD22 ;BRANCH IF SO
LDA LDTB1+1,X
AND #$7F
LDY LDTB1,X ;WAS IT CONTINUED
BPL SCRD19 ;BRANCH IF SO
ORA #$80
SCRD19 STA LDTB1+1,X
DEX
BNE SCRD21
SCRD22
LDX LINTMP
JSR WLOG30
;
JMP PULIND ;GO PUL OLD INDIRECTS AND RETURN
;
; SCROLL LINE FROM SAL TO PNT
; AND COLORS FROM EAL TO USER
;
SCRLIN
AND #$03 ;CLEAR ANY GARBAGE STUFF
ORA HIBASE ;PUT IN HIORDER BITS
STA SAL+1
JSR TOFROM ;COLOR TO & FROM ADDRS
LDY #LLEN-1
SCD20
LDA (SAL)Y
STA (PNT)Y
LDA (EAL)Y
STA (USER)Y
DEY
BPL SCD20
RTS
;
; DO COLOR TO AND FROM ADDRESSES
; FROM CHARACTER TO AND FROM ADRS
;
TOFROM
JSR SCOLOR
LDA SAL ;CHARACTER FROM
STA EAL ;MAKE COLOR FROM
LDA SAL+1
AND #$03
ORA #>VICCOL
STA EAL+1
RTS
;
; SET UP PNT AND Y
; FROM .X
;
SETPNT LDA LDTB2,X
STA PNT
LDA LDTB1,X
AND #$03
ORA HIBASE
STA PNT+1
RTS
;
; CLEAR THE LINE POINTED TO BY .X
;
CLRLN LDY #LLEN-1
JSR SETPNT
JSR SCOLOR
CLR10 LDA #$20
STA (PNT)Y
JSR CPATCH ;DO THE COLOR (IN BACKGROUND)
NOP ;FILL
DEY
BPL CLR10
RTS
.SKI 5
;
;PUT A CHAR ON THE SCREEN
;
DSPP TAY ;SAVE CHAR
LDA #2
STA BLNCT ;BLINK CURSOR
JSR SCOLOR ;SET COLOR PTR
TYA ;RESTORE COLOR
DSPP2 LDY PNTR ;GET COLUMN
STA (PNT)Y ;CHAR TO SCREEN
TXA
STA (USER)Y ;COLOR TO SCREEN
RTS
.SKI 5
SCOLOR LDA PNT ;GENERATE COLOR PTR
STA USER
LDA PNT+1
AND #$03
ORA #>VICCOL ;VIC COLOR RAM
STA USER+1
RTS
.PAG
KEY JSR $FFEA ;UPDATE JIFFY CLOCK
LDA BLNSW ;BLINKING CRSR ?
BNE KEY4 ;NO
DEC BLNCT ;TIME TO BLINK ?
BNE KEY4 ;NO
LDA #20 ;RESET BLINK COUNTER
REPDO STA BLNCT
LDY PNTR ;CURSOR POSITION
LSR BLNON ;CARRY SET IF ORIGINAL CHAR
LDX GDCOL ;GET CHAR ORIGINAL COLOR
LDA (PNT)Y ;GET CHARACTER
BCS KEY5 ;BRANCH IF NOT NEEDED
;
INC BLNON ;SET TO 1
STA GDBLN ;SAVE ORIGINAL CHAR
JSR SCOLOR
LDA (USER)Y ;GET ORIGINAL COLOR
STA GDCOL ;SAVE IT
LDX COLOR ;BLINK IN THIS COLOR
LDA GDBLN ;WITH ORIGINAL CHARACTER
;
KEY5 EOR #$80 ;BLINK IT
JSR DSPP2 ;DISPLAY IT
;
KEY4 LDA R6510 ;GET CASSETTE SWITCHES
AND #$10 ;IS SWITCH DOWN ?
BEQ KEY3 ;BRANCH IF SO
;
LDY #0
STY CAS1 ;CASSETTE OFF SWITCH
;
LDA R6510
ORA #$20
BNE KL24 ;BRANCH IF MOTOR IS OFF
;
KEY3 LDA CAS1
BNE KL2
;
LDA R6510
AND #%011111 ;TURN MOTOR ON
;
KL24
STA R6510
;
KL2 JSR SCNKEY ;SCAN KEYBOARD
;
KPREND LDA D1ICR ;CLEAR INTERUPT FLAGS
PLA ;RESTORE REGISTERS
TAY
PLA
TAX
PLA
RTI ;EXIT FROM IRQ ROUTINES
.SKI 3
; ****** GENERAL KEYBOARD SCAN ******
;
SCNKEY LDA #$00
STA SHFLAG
LDY #64 ;LAST KEY INDEX
STY SFDX ;NULL KEY FOUND
STA COLM ;RAISE ALL LINES
LDX ROWS ;CHECK FOR A KEY DOWN
CPX #$FF ;NO KEYS DOWN?
BEQ SCNOUT ;BRANCH IF NONE
TAY ;.A=0 LDY #0
LDA #<MODE1
STA KEYTAB
LDA #>MODE1
STA KEYTAB+1
LDA #$FE ;START WITH 1ST COLUMN
STA COLM
SCN20 LDX #8 ;8 ROW KEYBOARD
PHA ;SAVE COLUMN OUTPUT INFO
SCN22 LDA ROWS
CMP ROWS ;DEBOUNCE KEYBOARD
BNE SCN22
SCN30 LSR A ;LOOK FOR KEY DOWN
BCS CKIT ;NONE
PHA
LDA (KEYTAB),Y ;GET CHAR CODE
CMP #$05
BCS SPCK2 ;IF NOT SPECIAL KEY GO ON
CMP #$03 ;COULD IT BE A STOP KEY?
BEQ SPCK2 ;BRANCH IF SO
ORA SHFLAG
STA SHFLAG ;PUT SHIFT BIT IN FLAG BYTE
BPL CKUT
SPCK2
STY SFDX ;SAVE KEY NUMBER
CKUT PLA
CKIT INY
CPY #65
BCS CKIT1 ;BRANCH IF FINISHED
DEX
BNE SCN30
SEC
PLA ;RELOAD COLUMN INFO
ROL A
STA COLM ;NEXT COLUMN ON KEYBOARD
BNE SCN20 ;ALWAYS BRANCH
CKIT1 PLA ;DUMP COLUMN OUTPUT...ALL DONE
JMP (KEYLOG) ;EVALUATE SHIFT FUNCTIONS
REKEY LDY SFDX ;GET KEY INDEX
LDA (KEYTAB)Y ;GET CHAR CODE
TAX ;SAVE THE CHAR
CPY LSTX ;SAME AS PREV CHAR INDEX?
BEQ RPT10 ;YES
LDY #$10 ;NO - RESET DELAY BEFORE REPEAT
STY DELAY
BNE CKIT2 ;ALWAYS
RPT10 AND #$7F ;UNSHIFT IT
BIT RPTFLG ;CHECK FOR REPEAT DISABLE
BMI RPT20 ;YES
BVS SCNRTS
CMP #$7F ;NO KEYS ?
SCNOUT BEQ CKIT2 ;YES - GET OUT
CMP #$14 ;AN INST/DEL KEY ?
BEQ RPT20 ;YES - REPEAT IT
CMP #$20 ;A SPACE KEY ?
BEQ RPT20 ;YES
CMP #$1D ;A CRSR LEFT/RIGHT ?
BEQ RPT20 ;YES
CMP #$11 ;A CRSR UP/DWN ?
BNE SCNRTS ;NO - EXIT
RPT20 LDY DELAY ;TIME TO REPEAT ?
BEQ RPT40 ;YES
DEC DELAY
BNE SCNRTS
RPT40 DEC KOUNT ;TIME FOR NEXT REPEAT ?
BNE SCNRTS ;NO
LDY #4 ;YES - RESET CTR
STY KOUNT
LDY NDX ;NO REPEAT IF QUEUE FULL
DEY
BPL SCNRTS
CKIT2
LDY SFDX ;GET INDEX OF KEY
STY LSTX ;SAVE THIS INDEX TO KEY FOUND
LDY SHFLAG ;UPDATE SHIFT STATUS
STY LSTSHF
CKIT3 CPX #$FF ;A NULL KEY OR NO KEY ?
BEQ SCNRTS ;BRANCH IF SO
TXA ;NEED X AS INDEX SO...
LDX NDX ;GET # OF CHARS IN KEY QUEUE
CPX XMAX ;IRQ BUFFER FULL ?
BCS SCNRTS ;YES - NO MORE INSERT
PUTQUE
STA KEYD,X ;PUT RAW DATA HERE
INX
STX NDX ;UPDATE KEY QUEUE COUNT
SCNRTS LDA #$7F ;SETUP PB7 FOR STOP KEY SENSE
STA COLM
RTS
.PAG
;
; SHIFT LOGIC
;
SHFLOG
LDA SHFLAG
CMP #$03 ;COMMODORE SHIFT COMBINATION?
BNE KEYLG2 ;BRANCH IF NOT
CMP LSTSHF ;DID I DO THIS ALREADY
BEQ SCNRTS ;BRANCH IF SO
LDA MODE
BMI SHFOUT ;DONT SHIFT IF ITS MINUS
.SKI
SWITCH LDA VICREG+24 ;**********************************:
EOR #$02 ;TURN ON OTHER CASE
STA VICREG+24 ;POINT THE VIC THERE
JMP SHFOUT
.SKI
;
KEYLG2
ASL A
CMP #$08 ;WAS IT A CONTROL KEY
BCC NCTRL ;BRANCH IF NOT
LDA #6 ;ELSE USE TABLE #4
;
NCTRL
NOTKAT
TAX
LDA KEYCOD,X
STA KEYTAB
LDA KEYCOD+1,X
STA KEYTAB+1
SHFOUT
JMP REKEY
.END
; RSR 12/08/81 MODIFY FOR VIC-40
; RSR 2/18/82 MODIFY FOR 6526 INPUT PAD SENSE
; RSR 3/11/82 FIX KEYBOARD DEBOUNCE, REPAIR FILE
; RSR 3/11/82 MODIFY FOR COMMODORE 64