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.

channelio 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. .PAG 'CHANNEL I/O'
  2. ;***************************************
  3. ;* GETIN -- GET CHARACTER FROM CHANNEL *
  4. ;* CHANNEL IS DETERMINED BY DFLTN.*
  5. ;* IF DEVICE IS 0, KEYBOARD QUEUE IS *
  6. ;* EXAMINED AND A CHARACTER REMOVED IF *
  7. ;* AVAILABLE. IF QUEUE IS EMPTY, Z *
  8. ;* FLAG IS RETURNED SET. DEVICES 1-31 *
  9. ;* ADVANCE TO BASIN. *
  10. ;***************************************
  11. ;
  12. NGETIN LDA DFLTN ;CHECK DEVICE
  13. BNE GN10 ;NOT KEYBOARD
  14. ;
  15. LDA NDX ;QUEUE INDEX
  16. BEQ GN20 ;NOBODY THERE...EXIT
  17. ;
  18. SEI
  19. JMP LP2 ;GO REMOVE A CHARACTER
  20. ;
  21. GN10 CMP #2 ;IS IT RS-232
  22. BNE BN10 ;NO...USE BASIN
  23. ;
  24. GN232 STY XSAV ;SAVE .Y, USED IN RS232
  25. JSR BSI232
  26. LDY XSAV ;RESTORE .Y
  27. GN20 CLC ;GOOD RETURN
  28. RTS
  29. .SKI 3
  30. ;***************************************
  31. ;* BASIN-- INPUT CHARACTER FROM CHANNEL*
  32. ;* INPUT DIFFERS FROM GET ON DEVICE*
  33. ;* #0 FUNCTION WHICH IS KEYBOARD. THE *
  34. ;* SCREEN EDITOR MAKES READY AN ENTIRE *
  35. ;* LINE WHICH IS PASSED CHAR BY CHAR *
  36. ;* UP TO THE CARRIAGE RETURN. OTHER *
  37. ;* DEVICES ARE: *
  38. ;* 0 -- KEYBOARD *
  39. ;* 1 -- CASSETTE #1 *
  40. ;* 2 -- RS232 *
  41. ;* 3 -- SCREEN *
  42. ;* 4-31 -- SERIAL BUS *
  43. ;***************************************
  44. ;
  45. NBASIN LDA DFLTN ;CHECK DEVICE
  46. BNE BN10 ;IS NOT KEYBOARD...
  47. ;
  48. ;INPUT FROM KEYBOARD
  49. ;
  50. LDA PNTR ;SAVE CURRENT...
  51. STA LSTP ;... CURSOR COLUMN
  52. LDA TBLX ;SAVE CURRENT...
  53. STA LSXP ;... LINE NUMBER
  54. JMP LOOP5 ;BLINK CURSOR UNTIL RETURN
  55. ;
  56. BN10 CMP #3 ;IS INPUT FROM SCREEN?
  57. BNE BN20 ;NO...
  58. ;
  59. STA CRSW ;FAKE A CARRIAGE RETURN
  60. LDA LNMX ;SAY WE ENDED...
  61. STA INDX ;...UP ON THIS LINE
  62. JMP LOOP5 ;PICK UP CHARACTERS
  63. ;
  64. BN20 BCS BN30 ;DEVICES >3
  65. CMP #2 ;RS232?
  66. BEQ BN50
  67. ;
  68. ;INPUT FROM CASSETTE BUFFERS
  69. ;
  70. STX XSAV
  71. JSR JTGET
  72. BCS JTG37 ;STOP KEY/ERROR
  73. PHA
  74. JSR JTGET
  75. BCS JTG36 ;STOP KEY/ERROR
  76. BNE JTG35 ;NOT AN END OF FILE
  77. LDA #64 ;TELL USER EOF
  78. JSR UDST ;IN STATUS
  79. JTG35 DEC BUFPT
  80. LDX XSAV ;.X PRESERVED
  81. PLA ;CHARACTER RETURNED
  82. ;C-CLEAR FROM JTGET
  83. RTS ;ALL DONE
  84. ;
  85. JTG36 TAX ;SAVE ERROR INFO
  86. PLA ;TOSS DATA
  87. TXA ;RESTORE ERROR
  88. JTG37 LDX XSAV ;RETURN
  89. RTS ;ERROR RETURN C-SET FROM JTGET
  90. .SKI 3
  91. ;GET A CHARACTER FROM APPROPRIATE
  92. ;CASSETTE BUFFER
  93. ;
  94. JTGET JSR JTP20 ;BUFFER POINTER WRAP?
  95. BNE JTG10 ;NO...
  96. JSR RBLK ;YES...READ NEXT BLOCK
  97. BCS BN33 ;STOP KEY PRESSED
  98. LDA #0
  99. STA BUFPT ;POINT TO BEGIN.
  100. BEQ JTGET ;BRANCH ALWAYS
  101. ;
  102. JTG10 LDA (TAPE1)Y ;GET CHAR FROM BUF
  103. CLC ;GOOD RETURN
  104. RTS
  105. .SKI 3
  106. ;INPUT FROM SERIAL BUS
  107. ;
  108. BN30 LDA STATUS ;STATUS FROM LAST
  109. BEQ BN35 ;WAS GOOD
  110. BN31 LDA #$D ;BAD...ALL DONE
  111. BN32 CLC ;VALID DATA
  112. BN33 RTS
  113. ;
  114. BN35 JMP ACPTR ;GOOD...HANDSHAKE
  115. ;
  116. ;INPUT FROM RS232
  117. ;
  118. BN50 JSR GN232 ;GET INFO
  119. BCS BN33 ;ERROR RETURN
  120. CMP #00
  121. BNE BN32 ;GOOD DATA...EXIT
  122. LDA RSSTAT ;CHECK FOR DSR OR DCD ERROR
  123. AND #$60
  124. BNE BN31 ;AN ERROR...EXIT WITH C/R
  125. BEQ BN50 ;NO ERROR...STAY IN LOOP
  126. .PAG 'CHANNEL OUTPUT'
  127. ;***************************************
  128. ;* BSOUT -- OUT CHARACTER TO CHANNEL *
  129. ;* DETERMINED BY VARIABLE DFLTO: *
  130. ;* 0 -- INVALID *
  131. ;* 1 -- CASSETTE #1 *
  132. ;* 2 -- RS232 *
  133. ;* 3 -- SCREEN *
  134. ;* 4-31 -- SERIAL BUS *
  135. ;***************************************
  136. ;
  137. NBSOUT PHA ;PRESERVE .A
  138. LDA DFLTO ;CHECK DEVICE
  139. CMP #3 ;IS IT THE SCREEN?
  140. BNE BO10 ;NO...
  141. ;
  142. ;PRINT TO CRT
  143. ;
  144. PLA ;RESTORE DATA
  145. JMP PRT ;PRINT ON CRT
  146. ;
  147. BO10
  148. BCC BO20 ;DEVICE 1 OR 2
  149. ;
  150. ;PRINT TO SERIAL BUS
  151. ;
  152. PLA
  153. JMP CIOUT
  154. ;
  155. ;PRINT TO CASSETTE DEVICES
  156. ;
  157. BO20 LSR A ;RS232?
  158. PLA ;GET DATA OFF STACK...
  159. ;
  160. CASOUT STA T1 ;PASS DATA IN T1
  161. ; CASOUT MUST BE ENTERED WITH CARRY SET!!!
  162. ;PRESERVE REGISTERS
  163. ;
  164. TXA
  165. PHA
  166. TYA
  167. PHA
  168. BCC BO50 ;C-CLR MEANS DFLTO=2 (RS232)
  169. ;
  170. JSR JTP20 ;CHECK BUFFER POINTER
  171. BNE JTP10 ;HAS NOT REACHED END
  172. JSR WBLK ;WRITE FULL BUFFER
  173. BCS RSTOR ;ABORT ON STOP KEY
  174. ;
  175. ;PUT BUFFER TYPE BYTE
  176. ;
  177. LDA #BDF
  178. LDY #0
  179. STA (TAPE1)Y
  180. ;
  181. ;RESET BUFFER POINTER
  182. ;
  183. INY ;MAKE .Y=1
  184. STY BUFPT ;BUFPT=1
  185. ;
  186. JTP10 LDA T1
  187. STA (TAPE1)Y ;DATA TO BUFFER
  188. ;
  189. ;RESTORE .X AND .Y
  190. ;
  191. RSTOA CLC ;GOOD RETURN
  192. RSTOR PLA
  193. TAY
  194. PLA
  195. TAX
  196. LDA T1 ;GET .A FOR RETURN
  197. BCC RSTOR1 ;NO ERROR
  198. LDA #00 ;STOP ERROR IF C-SET
  199. RSTOR1 RTS
  200. ;
  201. ;OUTPUT TO RS232
  202. ;
  203. BO50 JSR BSO232 ;PASS DATA THROUGH VARIABLE T1
  204. JMP RSTOA ;GO RESTORE ALL..ALWAYS GOOD
  205. .END
  206. ; RSR 5/12/82 FIX BSOUT FOR NO REG AFFECT BUT ERRORS