-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathbwinit
333 lines (333 loc) · 6.35 KB
/
bwinit
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
.PAG 'BWINIT 05/01/83'
;****************************************
;
; 80 COLUMN CBM II SCREEN EDITOR
;
; WITH UNLIMITED SCREEN LINE WRAP
;
;****************************************
.SKIP 3
SCNRAM = $D000 ;START OF SCREEN MEMORY
SIDREG = $DA00 ;SID REGISTERS
LLEN = 80 ;SCREEN LENGTH
NROWS = 25 ;SCRREN LENGTH
SCXMAX = LLEN-1 ;MAX COLUMN NUMBER
SCYMAX = NROWS-1 ;MAX LINE NUMBER
KEYMAX = 9 ;KEYBOARD BUFFER SIZE - 1
DBLZER = 89 ;KEY CODE FOR DOUBLE ZERO
PGMKYS = 20 ;NUMBER OF PROGAM KEYS
ALOCAT = $FF81
IERROR = $0280 ;BASIC ERROR INDIRECT
CURSOR = $60 ;INIT TO FULL FLASHING CURSOR
ROMIMG = $00 ;INIT TO NORMAL IMAGE & CHAR ROM
.SKI 3
*=$E004
;************ JUMP TABLE ****************
;
JCINT JMP CINT
JLP2 JMP LP2
JLOOP5 JMP LOOP5
JPRT JMP PRT
JSCROR JMP SCRORG
JKEY JMP KEY
JMVCUR JMP MOVCUR ;JMP PREND CODE REMOVED...MOV CURSOR
JPLOT JMP PLOT
JIOBAS JMP IOBASE
JESCRT JMP ESCAPE
PGMKEY JMP KEYFUN
;
PLOT
BCS RDPLT
STX TBLX
STX LSXP
STY PNTR
STY LSTP
; JSR SRESET ;ALWAYS RESET THE WINDOW
JSR STUPT ;CHANGE POINTER TO THIS NEW LINE
JSR MOVCUR ;MOVE THE CURSOR THERE
RDPLT
LDX TBLX
LDY PNTR
RTS
;
IOBASE
LDX #<CIA
LDY #>CIA
RTS
;
SCRORG
LDX #LLEN
LDY #NROWS
RTS
;
.PAG
CINT
LDA #0
LDX #ZPEND-KEYPNT-1 ;ERASE ALL BUT FKEY ALLOCATION
CLOOP1 STA KEYPNT,X ;CLEAR PAGE 0 VARIABLES
DEX
BPL CLOOP1
LDX #ABSEND-RVS-1
CLOOP2 STA RVS,X ;CLEAR ABSOLUTE VARIABLES BUT FKEY ALLOCATIONS
DEX
BPL CLOOP2
LDA #$C
STA DELAY ;INIT REPEAT CTR
LDA #CURSOR
STA CONFIG ;SET FULL FLASHING CURSOR
LDA #<DOKEYF
STA FUNVEC ;SET UP INDIRECVCT FOR FUNCTION KEYS
LDA #>DOKEYF
STA FUNVEC+1
LDA PKYBUF ;CHECK IF BUFFERS ARE ALLOCATED
ORA PKYBUF+1
BNE NOROOM ;YES...JUST RESET THE SCREEN
LDA HIADR ;GET END OF KEY AREA
STA PKYEND
LDA HIADR+1
STA PKYEND+1
LDA #$40
LDX #0
LDY #2
JSR ALOCAT ;GET 512 BYTES
BCS NOROOM
STA KEYSEG
INX
STX PKYBUF
BNE ROOM10
INY
ROOM10
STY PKYBUF+1 ;SAVE START ADDRESS
KYSET
LDY #KEYEND-KEYDEF
JSR PAGST2
KYSET1
LDA KEYDEF-1,Y
DEY
STA (PKYBUF),Y
BNE KYSET1
JSR PAGRES
LDY #KEYDEF-KEYLEN
KYSET2
LDA KEYLEN-1,Y
STA KEYSIZ-1,Y
DEY
BNE KYSET2
NOROOM
JSR SRESET ;SET FULL SCREEN WINDOW
JSR TXCRT ;SET TEXT MODE/CHAR ROM
JSR CRTINT ;INITIALIZE CRT
;
CLSR
JSR NXTD ;START AT TOP OF WINDOW
CLS10
JSR SCRSET
JSR CLRLN ;CLEAR THE LINE
CPX SCBOT ;DONE ?
INX
BCC CLS10 ;NO
;
NXTD
LDX SCTOP ;MOVE TO TOP
STX TBLX
STX LSXP ;FOR INPUT AFTER HOME OR CLEAR
STU10 LDY SCLF ;LEFT OF THE SCREEN WINDOW
STY PNTR
STY LSTP
STUPT
LDX TBLX ;RESET PTR TO LINE BEGIN
;
SCRSET
LDA LDTB2,X
STA PNT
LDA LDTB1,X
STA PNT+1
RTS
;
; MOVCUR - MOVE THE CURSOR ROUTINE
; WATCH OUT .Y IS NOW ZAPPED
;
MOVCUR
LDY #15
CLC
LDA PNT
ADC PNTR
STY VDC+ADREG
STA VDC+DAREG ;SET LOW BYTE OF CURSOR ADDRESS
DEY
STY VDC+ADREG
LDA VDC+DAREG ;GET OLD HIGH BYTE OF CURSOR ADDRESS
AND #$F8 ;MASK OUT 3 LOW ORDER BITS
STA SEDT1 ;SAVE IT
LDA PNT+1
ADC #0
AND #07 ;GET NEW LOW ORDER BITS
ORA SEDT1 ;ADD IN MASKED BITS
STA VDC+DAREG ;SET HIGH BYTE OF CURSOR ADDRESS
RTS
.SKI 2
; *** INPUT ROUTINES ***
;
LP2 LDX KYNDX ;ARE THERE ANY PGM KEYS
BEQ LP3 ;BRANCH IF NOT
LDY KEYIDX ;GET INDEX TO CURRENT CHAR
JSR PAGST2 ;MAKE SURE RAM 0
LDA (KEYPNT)Y ;GET CURRENT BYT
JSR PAGRES ;RESTORE RAM PAGE
DEC KYNDX ;1 BYTE DOWN
INC KEYIDX ;BUMP INDEX TO NEXT CHAR
CLI
RTS
LP3 LDY KEYD ;GET KEY FROM IRQ BUFFER
LDX #0
LP1 LDA KEYD+1,X
STA KEYD,X
INX
CPX NDX
BNE LP1
DEC NDX
TYA
CLI
RTS
;
LOOP4 JSR PRT ;PRINT THE CHARACTER
LOOP3
LDY #10
LDA CONFIG
STY VDC+ADREG
STA VDC+DAREG ;SET CURSOR TYPE
LOOP3A
LDA NDX
ORA KYNDX
BEQ LOOP3A ;LOOP - WAIT FOR KEY INPUT
SEI
; LDY #10 FROM LOOP3
LDA #$20
STY VDC+ADREG
STA VDC+DAREG ;TURN OFF CURSOR
LP21
JSR LP2 ;GET KEY INPUT
CMP #$D
BNE LOOP4
STA CRSW ;FLAG - WE PASS CHARS NOW
JSR FNDEND ;CHECK NXT LINE FOR CONT
STX LINTMP ;SAVE LAST LINE NUMBER OF SENTENCE
JSR FISTRT ;FIND BEGINING OF LINE
LDA #0
STA QTSW ;CLEAR QUOTE MODE
LDY SCLF ;RETRIEVE FROM LINE START IF LEFT IT
LDA LSXP ;INPUT STARTED ROW
BMI LP80 ;FLAG WE LEFT START LINE
CMP TBLX
BCC LP80
LDY LSTP ;INPUT STARTED COLUMN
CMP LINTMP ;ON START LINE
BNE LP70
CPY INDX ;PAST START COLUMN
BEQ LP75 ;OK IF THE SAME
LP70 BCS CLP2 ;YES - NULL INPUT
LP75
STA TBLX ;START FROM HERE ON INPUT
LP80 STY PNTR
JMP LOP5
;
LOOP5 TYA
PHA
TXA
PHA
LDA CRSW ;PASSING CHARS TO INPUT
BEQ LOOP3 ;NO - BUFFER ON SCREEN
BPL LOP5 ;NOT DONE - GET NEXT CHAR
CLP2
LDA #0 ;INPUT DONE CLEAR FLAG
STA CRSW
LDA #$D ;PASS A RETURN
BNE CLP7
LOP5
JSR STUPT ;SET PNT AND USER
JSR GET1CH ;GET A SCREEN CHAR
STA DATA
AND #$3F
ASL DATA
BIT DATA
BPL LOP54
ORA #$80
LOP54 BCC LOP52
LDX QTSW
BNE LOP53
LOP52 BVS LOP53
ORA #$40
LOP53 JSR QTSWC
LDY TBLX ;ON INPUT END LINE ?
CPY LINTMP
BCC CLP00 ;NO
LDY PNTR ;ON INPUT END COLUMN ?
CPY INDX
BCC CLP00 ;NO
ROR CRSW ;C=1 MINUS FLAGS LAST CHAR SENT
BMI CLP1 ;ALWAYS
;
CLP00
JSR NXTCHR ;AT NEXT CHAR
CLP1
CMP #$DE ;A PI ?
BNE CLP7 ;NO
LDA #$FF ;TRANSLATE
CLP7
STA DATA
PLA
TAX
PLA
TAY
LDA DATA
RTS
.SKIP 3
; *** TEST FOR QUOTE MODE ***
QTSWC CMP #$22
BNE QTSWL
LDA INSRT ;IF WE ARE IN INSERT MODE...
BNE QTSWI ;DON'T MESS WITH QUOTE MODE...
LDA QTSW
EOR #$1
STA QTSW
QTSWI LDA #$22
QTSWL RTS
.SKIP 3
; *** OUTPUT CHARS ***
NXT3
BIT RVS
BPL NVS
NC3 ORA #$80
NVS LDX INSRT
BEQ NVSA
DEC INSRT
NVSA BIT INSFLG ;ARE WE IN AUTO INSERT MODE?
BPL NVS1 ;BRANCH IF NOT
PHA ;SAVE THE CHAR
JSR INSERT ;MAKE ROOM FOR THIS CHAR
LDX #0
STX INSRT ;MAKE SURE WE TURN OFF INSERT MODE.
PLA ;RESTORE CHAR
NVS1
JSR DSPP ;DISPLAY THE CHARACTER
CPY #69
BNE NVS2 ;DO NOT RING BELL
JSR BELL ;RING END OF LINE BELL
NVS2
JSR MOVCHR ;MOVE TO NEXT CHAR POS
;
; ********* EXIT FROM PRT *********
;
LOOP2 LDA DATA ;COPY LAST CHAR
STA LSTCHR
JSR MOVCUR ;MOVE THE CURSOR
PLA
TAY
LDA INSRT
BEQ LOP2
LSR QTSW
LOP2 PLA
TAX
PLA
RTS
.END