-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathrs232inout
187 lines (187 loc) · 3.92 KB
/
rs232inout
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
.PAG 'RS232 INOUT'
; OUTPUT A FILE OVER USR PORT
; USING RS232
;
CKO232 STA DFLTO ;SET DEFAULT OUT
LDA M51CDR ;CHECK FOR 3/X LINE
LSR A
BCC CKO100 ;3LINE...NO TURN AROUND
;
;*TURN AROUND LOGIC
;
; CHECK FOR DSR AND RTS
;
LDA #$02 ;BIT RTS IS ON
BIT D2PRB
BPL CKDSRX ;NO DSR...ERROR
BNE CKO100 ;RTS...OUTPUTING OR FULL DUPLEX
;
; CHECK FOR ACTIVE INPUT
; RTS WILL BE LOW IF CURRENTLY INPUTING
;
CKO020 LDA ENABL
AND #$02 ;LOOK AT IER FOR T2
BNE CKO020 ;HANG UNTILL INPUT DONE
;
; WAIT FOR CTS TO BE OFF AS SPEC REQS
;
CKO030 BIT D2PRB
BVS CKO030
;
; TURN ON RTS
;
LDA D2PRB
ORA #$02
STA D2PRB
;
; WAIT FOR CTS TO GO ON
;
CKO040 BIT D2PRB
BVS CKO100 ;DONE...
BMI CKO040 ;WE STILL HAVE DSR
;
CKDSRX LDA #$40 ;A DATA SET READY ERROR
STA RSSTAT ;MAJOR ERROR....WILL REQUIRE REOPEN
;
CKO100 CLC ;NO ERROR
RTS
;
.PAGE 'RS232 INOUT'
; BSO232 - OUTPUT A CHAR RS232
; DATA PASSED IN T1 FROM BSOUT
;
; HANG LOOP FOR BUFFER FULL
;
BSOBAD JSR BSO100 ;KEEP TRYING TO START SYSTEM...
;
; BUFFER HANDLER
;
BSO232 LDY RODBE
INY
CPY RODBS ;CHECK FOR BUFFER FULL
BEQ BSOBAD ;HANG IF SO...TRYING TO RESTART
STY RODBE ;INDICATE NEW START
DEY
LDA T1 ;GET DATA...
STA (ROBUF)Y ;STORE DATA
;
; SET UP IF NECESSARY TO OUTPUT
;
BSO100 LDA ENABL ;CHECK FOR A T1 NMI ENABLE
LSR A ;BIT 0
BCS BSO120 ;RUNNING....SO EXIT
;
; SET UP T1 NMI'S
;
BSO110 LDA #$10 ;TURN OFF TIMER TO PREVENT FALSE START...
STA D2CRA
LDA BAUDOF ;SET UP TIMER1
STA D2T1L
LDA BAUDOF+1
STA D2T1H
LDA #$81
JSR OENABL
JSR RSTBGN ;SET UP TO SEND (WILL STOP ON CTS OR DSR ERROR)
LDA #$11 ;TURN ON TIMER
STA D2CRA
BSO120 RTS
.PAGE 'RS232 INOUT'
; INPUT A FILE OVER USER PORT
; USING RS232
;
CKI232 STA DFLTN ;SET DEFAULT INPUT
;
LDA M51CDR ;CHECK FOR 3/X LINE
LSR A
BCC CKI100 ;3 LINE...NO HANDSHAKE
;
AND #$08 ;FULL/HALF CHECK (BYTE SHIFTED ABOVE)
BEQ CKI100 ;FULL...NO HANDSHAKE
;
;*TURN AROUND LOGIC
;
; CHECK IF DSR AND NOT RTS
;
LDA #$02 ;BIT RTS IS ON
BIT D2PRB
BPL CKDSRX ;NO DSR...ERROR
BEQ CKI110 ;RTS LOW...IN CORRECT MODE
;
; WAIT FOR ACTIVE OUTPUT TO BE DONE
;
CKI010 LDA ENABL
LSR A ;CHECK T1 (BIT 0)
BCS CKI010
;
; TURN OFF RTS
;
LDA D2PRB
AND #$FF-02
STA D2PRB
;
; WAIT FOR DCD TO GO HIGH (IN SPEC)
;
CKI020 LDA D2PRB
AND #$04
BEQ CKI020
;
; ENABLE FLAG FOR RS232 INPUT
;
CKI080 LDA #$90
CLC ;NO ERROR
JMP OENABL ;FLAG IN ENABL**********
;
; IF NOT 3 LINE HALF THEN...
; SEE IF WE NEED TO TURN ON FLAG
;
CKI100 LDA ENABL ;CHECK FOR FLAG OR T2 ACTIVE
AND #$12
BEQ CKI080 ;NO NEED TO TURN ON
CKI110 CLC ;NO ERROR
RTS
.PAGE 'RS232 INOUT'
; BSI232 - INPUT A CHAR RS232
;
; BUFFER HANDLER
;
BSI232 LDA RSSTAT ;GET STATUS UP TO CHANGE...
LDY RIDBS ;GET LAST BYTE ADDRESS
CPY RIDBE ;SEE IF BUFFER EMPTY
BEQ BSI010 ;RETURN A NULL IF NO CHAR
;
AND #$FF-$08 ;CLEAR BUFFER EMPTY STATUS
STA RSSTAT
LDA (RIBUF)Y ;GET LAST CHAR
INC RIDBS ;INC TO NEXT POS
;
; RECEIVER ALWAYS RUNS
;
RTS
;
BSI010 ORA #$08 ;SET BUFFER EMPTY STATUS
STA RSSTAT
LDA #$0 ;RETURN A NULL
RTS
.SKI 4
; RSP232 - PROTECT SERIAL/CASS FROM RS232 NMI'S
;
RSP232 PHA ;SAVE .A
LDA ENABL ;DOES RS232 HAVE ANY ENABLES?
BEQ RSPOK ;NO...
RSPOFF LDA ENABL ;WAIT UNTILL DONE
AND #%00000011 ; WITH T1 & T2
BNE RSPOFF
LDA #%00010000 ; DISABLE FLAG (NEED TO RENABLE IN USER CODE)
STA D2ICR ;TURN OF ENABL************
LDA #0
STA ENABL ;CLEAR ALL ENABLS
RSPOK PLA ;ALL DONE
RTS
.END
; RSR 8/24/80 ORIGINAL CODE OUT
; RSR 8/25/80 ORIGINAL CODE IN
; RSR 9/22/80 REMOVE PARALLEL REFS & FIX XLINE LOGIC
; RSR 12/11/81 MODIFY FOR VIC-40 I/O
; RSR 2/15/82 FIX SOME ENABL PROBLEMS
; RSR 3/31/82 FIX FLASE STARTS ON TRANSMITT
; RSR 5/12/82 REDUCE CODE AND FIX X-LINE CTS HOLD-OFF