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.

rs232inout 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. .PAG 'RS232 INOUT'
  2. ; OUTPUT A FILE OVER USR PORT
  3. ; USING RS232
  4. ;
  5. CKO232 STA DFLTO ;SET DEFAULT OUT
  6. LDA M51CDR ;CHECK FOR 3/X LINE
  7. LSR A
  8. BCC CKO100 ;3LINE...NO TURN AROUND
  9. ;
  10. ;*TURN AROUND LOGIC
  11. ;
  12. ; CHECK FOR DSR AND RTS
  13. ;
  14. LDA #$02 ;BIT RTS IS ON
  15. BIT D2PRB
  16. BPL CKDSRX ;NO DSR...ERROR
  17. BNE CKO100 ;RTS...OUTPUTING OR FULL DUPLEX
  18. ;
  19. ; CHECK FOR ACTIVE INPUT
  20. ; RTS WILL BE LOW IF CURRENTLY INPUTING
  21. ;
  22. CKO020 LDA ENABL
  23. AND #$02 ;LOOK AT IER FOR T2
  24. BNE CKO020 ;HANG UNTILL INPUT DONE
  25. ;
  26. ; WAIT FOR CTS TO BE OFF AS SPEC REQS
  27. ;
  28. CKO030 BIT D2PRB
  29. BVS CKO030
  30. ;
  31. ; TURN ON RTS
  32. ;
  33. LDA D2PRB
  34. ORA #$02
  35. STA D2PRB
  36. ;
  37. ; WAIT FOR CTS TO GO ON
  38. ;
  39. CKO040 BIT D2PRB
  40. BVS CKO100 ;DONE...
  41. BMI CKO040 ;WE STILL HAVE DSR
  42. ;
  43. CKDSRX LDA #$40 ;A DATA SET READY ERROR
  44. STA RSSTAT ;MAJOR ERROR....WILL REQUIRE REOPEN
  45. ;
  46. CKO100 CLC ;NO ERROR
  47. RTS
  48. ;
  49. .PAGE 'RS232 INOUT'
  50. ; BSO232 - OUTPUT A CHAR RS232
  51. ; DATA PASSED IN T1 FROM BSOUT
  52. ;
  53. ; HANG LOOP FOR BUFFER FULL
  54. ;
  55. BSOBAD JSR BSO100 ;KEEP TRYING TO START SYSTEM...
  56. ;
  57. ; BUFFER HANDLER
  58. ;
  59. BSO232 LDY RODBE
  60. INY
  61. CPY RODBS ;CHECK FOR BUFFER FULL
  62. BEQ BSOBAD ;HANG IF SO...TRYING TO RESTART
  63. STY RODBE ;INDICATE NEW START
  64. DEY
  65. LDA T1 ;GET DATA...
  66. STA (ROBUF)Y ;STORE DATA
  67. ;
  68. ; SET UP IF NECESSARY TO OUTPUT
  69. ;
  70. BSO100 LDA ENABL ;CHECK FOR A T1 NMI ENABLE
  71. LSR A ;BIT 0
  72. BCS BSO120 ;RUNNING....SO EXIT
  73. ;
  74. ; SET UP T1 NMI'S
  75. ;
  76. BSO110 LDA #$10 ;TURN OFF TIMER TO PREVENT FALSE START...
  77. STA D2CRA
  78. LDA BAUDOF ;SET UP TIMER1
  79. STA D2T1L
  80. LDA BAUDOF+1
  81. STA D2T1H
  82. LDA #$81
  83. JSR OENABL
  84. JSR RSTBGN ;SET UP TO SEND (WILL STOP ON CTS OR DSR ERROR)
  85. LDA #$11 ;TURN ON TIMER
  86. STA D2CRA
  87. BSO120 RTS
  88. .PAGE 'RS232 INOUT'
  89. ; INPUT A FILE OVER USER PORT
  90. ; USING RS232
  91. ;
  92. CKI232 STA DFLTN ;SET DEFAULT INPUT
  93. ;
  94. LDA M51CDR ;CHECK FOR 3/X LINE
  95. LSR A
  96. BCC CKI100 ;3 LINE...NO HANDSHAKE
  97. ;
  98. AND #$08 ;FULL/HALF CHECK (BYTE SHIFTED ABOVE)
  99. BEQ CKI100 ;FULL...NO HANDSHAKE
  100. ;
  101. ;*TURN AROUND LOGIC
  102. ;
  103. ; CHECK IF DSR AND NOT RTS
  104. ;
  105. LDA #$02 ;BIT RTS IS ON
  106. BIT D2PRB
  107. BPL CKDSRX ;NO DSR...ERROR
  108. BEQ CKI110 ;RTS LOW...IN CORRECT MODE
  109. ;
  110. ; WAIT FOR ACTIVE OUTPUT TO BE DONE
  111. ;
  112. CKI010 LDA ENABL
  113. LSR A ;CHECK T1 (BIT 0)
  114. BCS CKI010
  115. ;
  116. ; TURN OFF RTS
  117. ;
  118. LDA D2PRB
  119. AND #$FF-02
  120. STA D2PRB
  121. ;
  122. ; WAIT FOR DCD TO GO HIGH (IN SPEC)
  123. ;
  124. CKI020 LDA D2PRB
  125. AND #$04
  126. BEQ CKI020
  127. ;
  128. ; ENABLE FLAG FOR RS232 INPUT
  129. ;
  130. CKI080 LDA #$90
  131. CLC ;NO ERROR
  132. JMP OENABL ;FLAG IN ENABL**********
  133. ;
  134. ; IF NOT 3 LINE HALF THEN...
  135. ; SEE IF WE NEED TO TURN ON FLAG
  136. ;
  137. CKI100 LDA ENABL ;CHECK FOR FLAG OR T2 ACTIVE
  138. AND #$12
  139. BEQ CKI080 ;NO NEED TO TURN ON
  140. CKI110 CLC ;NO ERROR
  141. RTS
  142. .PAGE 'RS232 INOUT'
  143. ; BSI232 - INPUT A CHAR RS232
  144. ;
  145. ; BUFFER HANDLER
  146. ;
  147. BSI232 LDA RSSTAT ;GET STATUS UP TO CHANGE...
  148. LDY RIDBS ;GET LAST BYTE ADDRESS
  149. CPY RIDBE ;SEE IF BUFFER EMPTY
  150. BEQ BSI010 ;RETURN A NULL IF NO CHAR
  151. ;
  152. AND #$FF-$08 ;CLEAR BUFFER EMPTY STATUS
  153. STA RSSTAT
  154. LDA (RIBUF)Y ;GET LAST CHAR
  155. INC RIDBS ;INC TO NEXT POS
  156. ;
  157. ; RECEIVER ALWAYS RUNS
  158. ;
  159. RTS
  160. ;
  161. BSI010 ORA #$08 ;SET BUFFER EMPTY STATUS
  162. STA RSSTAT
  163. LDA #$0 ;RETURN A NULL
  164. RTS
  165. .SKI 4
  166. ; RSP232 - PROTECT SERIAL/CASS FROM RS232 NMI'S
  167. ;
  168. RSP232 PHA ;SAVE .A
  169. LDA ENABL ;DOES RS232 HAVE ANY ENABLES?
  170. BEQ RSPOK ;NO...
  171. RSPOFF LDA ENABL ;WAIT UNTILL DONE
  172. AND #%00000011 ; WITH T1 & T2
  173. BNE RSPOFF
  174. LDA #%00010000 ; DISABLE FLAG (NEED TO RENABLE IN USER CODE)
  175. STA D2ICR ;TURN OF ENABL************
  176. LDA #0
  177. STA ENABL ;CLEAR ALL ENABLS
  178. RSPOK PLA ;ALL DONE
  179. RTS
  180. .END
  181. ; RSR 8/24/80 ORIGINAL CODE OUT
  182. ; RSR 8/25/80 ORIGINAL CODE IN
  183. ; RSR 9/22/80 REMOVE PARALLEL REFS & FIX XLINE LOGIC
  184. ; RSR 12/11/81 MODIFY FOR VIC-40 I/O
  185. ; RSR 2/15/82 FIX SOME ENABL PROBLEMS
  186. ; RSR 3/31/82 FIX FLASE STARTS ON TRANSMITT
  187. ; RSR 5/12/82 REDUCE CODE AND FIX X-LINE CTS HOLD-OFF