You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
2.9KB

  1. .PAG 'IEEE'
  2. ;ATN IRQ PROCESS
  3. ; IRQ ON ATN, LISTEN TO PET
  4. ; CLEAR STACK
  5. .SKI 3
  6. IRQ
  7. LDX #$FF
  8. STX CMDNUM
  9. TXS
  10. LDA ATNPE ;CLEAR IRQ FLAG
  11. LDA #DAVO+EOIO
  12. ORA PAD2 ;FREE CONTROL LINES
  13. STA PAD2
  14. LDA #255
  15. STA IEEEDO ;FREE DATA LINES
  16. ATN10 LDA #DACO+RFDO+ATNA
  17. ORA PAD2
  18. STA PAD2
  19. ATN20 BIT PAD2
  20. BVC ATN30 ;DAV LO
  21. BMI ATN20 ;ATN LO ATNI HI
  22. BPL ATN50 ;ATN HI
  23. ATN30 LDA #255-RFDO ;NRFD LO
  24. AND PAD2
  25. STA PAD2
  26. AND #EOII
  27. STA EOIFLG ;SAVE EOI
  28. LDA IEEEDI
  29. EOR #$FF
  30. STA DATA ;SAVE COMMAND
  31. LDA #255-DACO ;NDAC HI
  32. AND PAD2
  33. STA PAD2
  34. DCDE LDY #0
  35. LDA DATA
  36. AND #%01100000
  37. CMP #$40 ;TALK?
  38. BEQ DCDE60
  39. CMP #$20 ;LISTEN?
  40. BEQ DCDE20
  41. CMP #$60 ;SECONDARY?
  42. BEQ DCDE70
  43. BNE DCDE80 ;OTHER
  44. DCDE20 LDA DATA
  45. CMP LSNADR
  46. BEQ DCDE40 ;MY LISTEN ADDRESS
  47. CMP #UNLSN
  48. BNE DCDE30
  49. STY LSNACT
  50. DCDE30 STY ADRSED ;NOT PRIMARY ADDRSED
  51. JMP DCDE80
  52. DCDE40 STA LSNACT
  53. STY TLKACT
  54. DCDE50 LDA #32
  55. STA SA ;DEFAULT SA
  56. STA ORGSA
  57. STA ADRSED ;PRIMARY ADDRESSED
  58. BNE DCDE80
  59. DCDE60 STY TLKACT
  60. LDA DATA
  61. CMP TLKADR
  62. BNE DCDE30
  63. STA TLKACT
  64. STY LSNACT
  65. BEQ DCDE50
  66. DCDE70 LDA ADRSED
  67. BEQ DCDE80 ;NOT ADDRESSED
  68. LDA DATA
  69. STA ORGSA
  70. PHA
  71. AND #$F
  72. STA SA
  73. PLA
  74. AND #$F0 ;CLOSE?
  75. CMP #$E0
  76. BNE DCDE80
  77. JSR CLOSE
  78. DCDE80
  79. ATN40 BIT PAD2
  80. BVC ATN40
  81. JMP ATN10
  82. ATN50 LDA LSNACT
  83. BEQ ATN60
  84. LDA #255-RFDO-ATNA
  85. AND PAD2
  86. STA PAD2
  87. CLI
  88. JSR LISTEN
  89. JMP IDLE
  90. ATN60 LDA #255-ATNA-DACO
  91. AND PAD2
  92. STA PAD2
  93. LDA TLKACT
  94. BEQ ATN70
  95. CLI
  96. JSR TALK
  97. ATN70 JMP IDLE
  98. .SKI 5
  99. LISTEN LDA #RFDO ;RFD: HI
  100. ORA PAD2
  101. STA PAD2
  102. LSN10 BIT PAD2 ;DAV: LO
  103. BVS LSN10
  104. JSR FNDWCH ; WAS LDX SA
  105. BCS LSN15
  106. .SKIP
  107. LDA CHNRDY,X
  108. ROR A ;OK, OPEN FOR LISTEN
  109. BCS LSN30
  110. LSN15 LDA ORGSA ; WAS TXA
  111. AND #$F0 ;SA=OPEN?
  112. CMP #$F0
  113. BEQ LSN30
  114. LSN20 LDA SA
  115. CMP #1
  116. BEQ LSN25
  117. LSN21 BIT PAD2
  118. BVC LSN21
  119. LDA #255-DACO
  120. AND PAD2
  121. STA PAD2
  122. RTS
  123. .SKIP
  124. LSN25 LDA #255-RFDO ; ACCEPT ALL DATA
  125. AND PAD2
  126. STA PAD2 ;RFD LOW
  127. LDA #255-DACO
  128. AND PAD2 ; DAC HI
  129. STA PAD2
  130. .SKIP
  131. LSN26 BIT PAD2 ; DAV HI
  132. BVC LSN26
  133. LDA #DACO
  134. ORA PAD2 ; DAC LOW
  135. STA PAD2
  136. LDA #RFDO ; RFD HI
  137. ORA PAD2
  138. STA PAD2
  139. LSN28 BIT PAD2 ; WAIT DAV LOW
  140. BVC LSN28
  141. JMP LSN25 ; DO UNTIL ATN PULLED
  142. LSN30 LDA #255-RFDO
  143. AND PAD2
  144. STA PAD2
  145. AND #EOII
  146. STA EOIFLG
  147. LDA IEEEDI
  148. EOR #$FF
  149. STA DATA
  150. SEI
  151. LDA #255-DACO
  152. AND PAD2
  153. STA PAD2
  154. LSN40 BIT PAD2
  155. BVC LSN40
  156. LDA #DACO
  157. ORA PAD2
  158. STA PAD2
  159. JSR PUT
  160. LSTRTN CLI
  161. JMP LISTEN
  162. .SKI 3
  163. TALK JSR FNDRCH
  164. BCS NOTLK ; TEST IF CHANNEL READY
  165. TALK1 LDX LINDX
  166. LDA CHNRDY,X
  167. BMI TLK10
  168. NOTLK RTS
  169. TLK10 BIT PBD2 ;RFD: HI
  170. BPL TLK10
  171. LDA CHNDAT,X
  172. EOR #$FF
  173. STA IEEEDO
  174. LDA CHNRDY,X
  175. ORA #255-EOIO-DAVO ;DAV: LO
  176. AND PAD2
  177. STA PAD2
  178. TLK20 BIT PBD2
  179. BPL TLK30
  180. BVC TLK20
  181. LDA #DAVO+EOIO
  182. ORA PAD2
  183. STA PAD2
  184. JMP IDLE
  185. TLK30 JSR GET
  186. TLK35 BIT PBD2
  187. BVC TLK35
  188. TLKRTN LDA #$FF
  189. STA IEEEDO
  190. LDA #DAVO+EOIO
  191. ORA PAD2
  192. STA PAD2
  193. TLK40 BIT PBD2
  194. BVS TLK40
  195. BVC TALK1
  196. .END