-
Notifications
You must be signed in to change notification settings - Fork 85
/
ieee
196 lines (196 loc) · 2.92 KB
/
ieee
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
.PAG 'IEEE'
;ATN IRQ PROCESS
; IRQ ON ATN, LISTEN TO PET
; CLEAR STACK
.SKI 3
IRQ
LDX #$FF
STX CMDNUM
TXS
LDA ATNPE ;CLEAR IRQ FLAG
LDA #DAVO+EOIO
ORA PAD2 ;FREE CONTROL LINES
STA PAD2
LDA #255
STA IEEEDO ;FREE DATA LINES
ATN10 LDA #DACO+RFDO+ATNA
ORA PAD2
STA PAD2
ATN20 BIT PAD2
BVC ATN30 ;DAV LO
BMI ATN20 ;ATN LO ATNI HI
BPL ATN50 ;ATN HI
ATN30 LDA #255-RFDO ;NRFD LO
AND PAD2
STA PAD2
AND #EOII
STA EOIFLG ;SAVE EOI
LDA IEEEDI
EOR #$FF
STA DATA ;SAVE COMMAND
LDA #255-DACO ;NDAC HI
AND PAD2
STA PAD2
DCDE LDY #0
LDA DATA
AND #%01100000
CMP #$40 ;TALK?
BEQ DCDE60
CMP #$20 ;LISTEN?
BEQ DCDE20
CMP #$60 ;SECONDARY?
BEQ DCDE70
BNE DCDE80 ;OTHER
DCDE20 LDA DATA
CMP LSNADR
BEQ DCDE40 ;MY LISTEN ADDRESS
CMP #UNLSN
BNE DCDE30
STY LSNACT
DCDE30 STY ADRSED ;NOT PRIMARY ADDRSED
JMP DCDE80
DCDE40 STA LSNACT
STY TLKACT
DCDE50 LDA #32
STA SA ;DEFAULT SA
STA ORGSA
STA ADRSED ;PRIMARY ADDRESSED
BNE DCDE80
DCDE60 STY TLKACT
LDA DATA
CMP TLKADR
BNE DCDE30
STA TLKACT
STY LSNACT
BEQ DCDE50
DCDE70 LDA ADRSED
BEQ DCDE80 ;NOT ADDRESSED
LDA DATA
STA ORGSA
PHA
AND #$F
STA SA
PLA
AND #$F0 ;CLOSE?
CMP #$E0
BNE DCDE80
JSR CLOSE
DCDE80
ATN40 BIT PAD2
BVC ATN40
JMP ATN10
ATN50 LDA LSNACT
BEQ ATN60
LDA #255-RFDO-ATNA
AND PAD2
STA PAD2
CLI
JSR LISTEN
JMP IDLE
ATN60 LDA #255-ATNA-DACO
AND PAD2
STA PAD2
LDA TLKACT
BEQ ATN70
CLI
JSR TALK
ATN70 JMP IDLE
.SKI 5
LISTEN LDA #RFDO ;RFD: HI
ORA PAD2
STA PAD2
LSN10 BIT PAD2 ;DAV: LO
BVS LSN10
JSR FNDWCH ; WAS LDX SA
BCS LSN15
.SKIP
LDA CHNRDY,X
ROR A ;OK, OPEN FOR LISTEN
BCS LSN30
LSN15 LDA ORGSA ; WAS TXA
AND #$F0 ;SA=OPEN?
CMP #$F0
BEQ LSN30
LSN20 LDA SA
CMP #1
BEQ LSN25
LSN21 BIT PAD2
BVC LSN21
LDA #255-DACO
AND PAD2
STA PAD2
RTS
.SKIP
LSN25 LDA #255-RFDO ; ACCEPT ALL DATA
AND PAD2
STA PAD2 ;RFD LOW
LDA #255-DACO
AND PAD2 ; DAC HI
STA PAD2
.SKIP
LSN26 BIT PAD2 ; DAV HI
BVC LSN26
LDA #DACO
ORA PAD2 ; DAC LOW
STA PAD2
LDA #RFDO ; RFD HI
ORA PAD2
STA PAD2
LSN28 BIT PAD2 ; WAIT DAV LOW
BVC LSN28
JMP LSN25 ; DO UNTIL ATN PULLED
LSN30 LDA #255-RFDO
AND PAD2
STA PAD2
AND #EOII
STA EOIFLG
LDA IEEEDI
EOR #$FF
STA DATA
SEI
LDA #255-DACO
AND PAD2
STA PAD2
LSN40 BIT PAD2
BVC LSN40
LDA #DACO
ORA PAD2
STA PAD2
JSR PUT
LSTRTN CLI
JMP LISTEN
.SKI 3
TALK JSR FNDRCH
BCS NOTLK ; TEST IF CHANNEL READY
TALK1 LDX LINDX
LDA CHNRDY,X
BMI TLK10
NOTLK RTS
TLK10 BIT PBD2 ;RFD: HI
BPL TLK10
LDA CHNDAT,X
EOR #$FF
STA IEEEDO
LDA CHNRDY,X
ORA #255-EOIO-DAVO ;DAV: LO
AND PAD2
STA PAD2
TLK20 BIT PBD2
BPL TLK30
BVC TLK20
LDA #DAVO+EOIO
ORA PAD2
STA PAD2
JMP IDLE
TLK30 JSR GET
TLK35 BIT PBD2
BVC TLK35
TLKRTN LDA #$FF
STA IEEEDO
LDA #DAVO+EOIO
ORA PAD2
STA PAD2
TLK40 BIT PBD2
BVS TLK40
BVC TALK1
.END