-
Notifications
You must be signed in to change notification settings - Fork 85
/
channelio
210 lines (210 loc) · 4.64 KB
/
channelio
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
.PAG 'CHANNEL I/O'
;***************************************
;* GETIN -- GET CHARACTER FROM CHANNEL *
;* CHANNEL IS DETERMINED BY DFLTN.*
;* IF DEVICE IS 0, KEYBOARD QUEUE IS *
;* EXAMINED AND A CHARACTER REMOVED IF *
;* AVAILABLE. IF QUEUE IS EMPTY, Z *
;* FLAG IS RETURNED SET. DEVICES 1-31 *
;* ADVANCE TO BASIN. *
;***************************************
;
NGETIN LDA DFLTN ;CHECK DEVICE
BNE GN10 ;NOT KEYBOARD
;
LDA NDX ;QUEUE INDEX
BEQ BN31 ;NOBODY THERE...EXIT
;
SEI
JMP LP2 ;GO REMOVE A CHARACTER
;
GN10 CMP #2 ;IS IT RS-232
BNE BN10 ;NO...USE BASIN
;
GN232 STY XSAV ;SAVE .Y, USED IN RS232
JSR BSI232
LDY XSAV ;RESTORE .Y
CLC ;GOOD RETURN
RTS
.SKI 3
;***************************************
;* BASIN-- INPUT CHARACTER FROM CHANNEL*
;* INPUT DIFFERS FROM GET ON DEVICE*
;* #0 FUNCTION WHICH IS KEYBOARD. THE *
;* SCREEN EDITOR MAKES READY AN ENTIRE *
;* LINE WHICH IS PASSED CHAR BY CHAR *
;* UP TO THE CARRIAGE RETURN. OTHER *
;* DEVICES ARE: *
;* 0 -- KEYBOARD *
;* 1 -- CASSETTE #1 *
;* 2 -- RS232 *
;* 3 -- SCREEN *
;* 4-31 -- SERIAL BUS *
;***************************************
;
NBASIN LDA DFLTN ;CHECK DEVICE
BNE BN10 ;IS NOT KEYBOARD...
;
;INPUT FROM KEYBOARD
;
LDA PNTR ;SAVE CURRENT...
STA LSTP ;... CURSOR COLUMN
LDA TBLX ;SAVE CURRENT...
STA LSXP ;... LINE NUMBER
JMP LOOP5 ;BLINK CURSOR UNTIL RETURN
;
BN10 CMP #3 ;IS INPUT FROM SCREEN?
BNE BN20 ;NO...
;
STA CRSW ;FAKE A CARRIAGE RETURN
LDA LNMX ;SAY WE ENDED...
STA INDX ;...UP ON THIS LINE
JMP LOOP5 ;PICK UP CHARACTERS
;
BN20 BCS BN30 ;DEVICES >3
CMP #2 ;RS232?
BEQ BN50
;
;INPUT FROM CASSETTE BUFFERS
;
STX XSAV
JSR JTGET
BCS JTG37 ;STOP KEY/ERROR
PHA
JSR JTGET
BCS JTG36 ;STOP KEY/ERROR
BNE JTG35 ;NOT AN END OF FILE
LDA #64 ;TELL USER EOF
JSR UDST ;IN STATUS
JTG35 DEC BUFPT
LDX XSAV ;.X PRESERVED
PLA ;CHARACTER RETURNED
;C-CLEAR FROM JTGET
RTS ;ALL DONE
;
JTG36 TAX ;SAVE ERROR INFO
PLA ;TOSS DATA
TXA ;RESTORE ERROR
JTG37 LDX XSAV ;RETURN
RTS ;ERROR RETURN C-SET FROM JTGET
.SKI 3
;GET A CHARACTER FROM APPROPRIATE
;CASSETTE BUFFER
;
JTGET JSR JTP20 ;BUFFER POINTER WRAP?
BNE JTG10 ;NO...
JSR RBLK ;YES...READ NEXT BLOCK
BCS BN32 ;STOP KEY PRESSED
LDA #0
STA BUFPT ;POINT TO BEGIN.
BEQ JTGET ;BRANCH ALWAYS
;
JTG10 LDA (TAPE1)Y ;GET CHAR FROM BUF
CLC ;GOOD RETURN
RTS
.SKI 3
;INPUT FROM SERIAL BUS
;
BN30 LDA STATUS ;STATUS FROM LAST
BEQ BN35 ;WAS GOOD
LDA #$D ;BAD...ALL DONE
BN31 CLC ;VALID DATA
BN32 RTS
;
BN35 JMP ACPTR ;GOOD...HANDSHAKE
;
;INPUT FROM RS232
;
BN50 JSR GN232 ;GET INFO
BCS BN52 ;ERROR RETURN
CMP #00
BEQ BN50 ;WAIT FOR VALID DATA
CLC ;GOOD RETURN
BN52 RTS
.PAG 'CHANNEL OUTPUT'
;***************************************
;* BSOUT -- OUT CHARACTER TO CHANNEL *
;* DETERMINED BY VARIABLE DFLTO: *
;* 0 -- INVALID *
;* 1 -- CASSETTE #1 *
;* 2 -- RS232 *
;* 3 -- SCREEN *
;* 4-31 -- SERIAL BUS *
;***************************************
;
NBSOUT PHA ;PRESERVE .A
LDA DFLTO ;CHECK DEVICE
CMP #3 ;IS IT THE SCREEN?
BNE BO10 ;NO...
;
;PRINT TO CRT
;
PLA ;RESTORE DATA
JMP PRT ;PRINT ON CRT
;
BO10
BCC BO20 ;DEVICE 1 OR 2
;
;PRINT TO SERIAL BUS
;
PLA
JMP CIOUT
;
;PRINT TO CASSETTE DEVICES
;
BO20 CMP #2 ;RS232?
BEQ BO50
;
PLA
CASOUT STA T1
;
;PRESERVE REGISTERS
;
PHA
TXA
PHA
TYA
PHA
;
JSR JTP20 ;CHECK BUFFER POINTER
BNE JTP10 ;HAS NOT REACHED END
JSR WBLK ;WRITE FULL BUFFER
BCS RSTOR ;ABORT ON STOP KEY
;
;PUT BUFFER TYPE BYTE
;
LDA #BDF
LDY #0
STA (TAPE1)Y
;
;RESET BUFFER POINTER
;
INY ;MAKE .Y=1
STY BUFPT ;BUFPT=1
;
JTP10 LDA T1
STA (TAPE1)Y ;DATA TO BUFFER
;
;RESTORE .X AND .Y
;
CLC ;GOOD RETURN
RSTOR PLA
TAY
PLA
TAX
PLA ;RESTORE .A
BCC RSTOR1 ;NO ERROR
LDA #00 ;STOP ERROR IF C-SET
RSTOR1 RTS
;
;OUTPUT TO RS232
;
BO50 PLA ;GET DATA
STX XSAV ;PUT IN A TEMP
STY T1
JSR BSO232 ;COULD PUT CODE HERE
LDX XSAV ;GO RESTORE
LDY T1
CLC ;GOOD RETURN
RTS
.END