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.

rs232nmi 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. .PAGE 'NMI HANDLER'
  2. NMI SEI ;NO IRQ'S ALLOWED...
  3. JMP (NMINV) ;...COULD MESS UP CASSETTES
  4. NNMI PHA
  5. TXA
  6. PHA
  7. TYA
  8. PHA
  9. NNMI10 LDA #$7F ;DISABLE ALL NMI'S
  10. STA D2ICR
  11. LDY D2ICR ;CHECK IF REAL NMI...
  12. BMI NNMI20 ;NO...RS232/OTHER
  13. ;
  14. NNMI18 JSR A0INT ;CHECK IF $A0 IN...NO .Y
  15. BNE NNMI19 ;...NO
  16. JMP ($8002) ;...YES
  17. ;
  18. ; CHECK FOR STOP KEY DOWN
  19. ;
  20. NNMI19
  21. JSR UD60 ;NO .Y
  22. JSR STOP ;NO .Y
  23. BNE NNMI20 ;NO STOP KEY...TEST FOR RS232
  24. ;
  25. ; TIMB - WHERE SYSTEM GOES ON A BRK INSTRUCTION
  26. ;
  27. TIMB JSR RESTOR ;RESTORE SYSTEM INDIRECTS
  28. JSR IOINIT ;RESTORE I/O FOR BASIC
  29. JSR CINT ;RESTORE SCREEN FOR BASIC
  30. JMP ($A002) ;...NO, SO BASIC WARM START
  31. .SKI 2
  32. ; DISABLE NMI'S UNTILL READY
  33. ; SAVE ON STACK
  34. ;
  35. NNMI20 TYA ;.Y SAVED THROUGH RESTORE
  36. AND ENABL ;SHOW ONLY ENABLES
  37. TAX ;SAVE IN .X FOR LATTER
  38. ;
  39. ; T1 NMI CHECK - TRANSMITT A BIT
  40. ;
  41. AND #$01 ;CHECK FOR T1
  42. BEQ NNMI30 ;NO...
  43. ;
  44. LDA D2PRA
  45. AND #$FF-$04 ;FIX FOR CURRENT I/O
  46. ORA NXTBIT ;LOAD DATA AND...
  47. STA D2PRA ;...SEND IT
  48. ;
  49. LDA ENABL ;RESTORE NMI'S
  50. STA D2ICR ;READY FOR NEXT...
  51. ;
  52. ; BECAUSE OF 6526 ICR STRUCTURE...
  53. ; HANDLE ANOTHER NMI AS A SUBROUTINE
  54. ;
  55. TXA ;TEST FOR ANOTHER NMI
  56. AND #$12 ;TEST FOR T2 OR FLAG
  57. BEQ NNMI25
  58. AND #$02 ;CHECK FOR T2
  59. BEQ NNMI22 ;MUST BE A FLAG
  60. ;
  61. JSR T2NMI ;HANDLE A NORMAL BIT IN...
  62. JMP NNMI25 ;...THEN CONTINUE OUTPUT
  63. ;
  64. NNMI22 JSR FLNMI ;HANDLE A START BIT...
  65. ;
  66. NNMI25 JSR RSTRAB ;GO CALC INFO (CODE COULD BE IN LINE)
  67. JMP NMIRTI
  68. ;
  69. .SKI 2
  70. ; T2 NMI CHECK - RECIEVE A BIT
  71. ;
  72. NNMI30 TXA
  73. AND #$02 ;MASK TO T2
  74. BEQ NNMI40 ;NO...
  75. ;
  76. JSR T2NMI ;HANDLE INTERRUPT
  77. JMP NMIRTI
  78. .SKI 2
  79. ; FLAG NMI HANDLER - RECIEVE A START BIT
  80. ;
  81. NNMI40 TXA ;CHECK FOR EDGE
  82. AND #$10 ;ON FLAG...
  83. BEQ NMIRTI ;NO...
  84. ;
  85. JSR FLNMI ;START BIT ROUTINE
  86. .SKI 2
  87. NMIRTI LDA ENABL ;RESTORE NMI'S
  88. STA D2ICR
  89. PREND PLA ;BECAUSE OF MISSING SCREEN EDITOR
  90. TAY
  91. PLA
  92. TAX
  93. PLA
  94. RTI
  95. .SKI 4
  96. ; BAUDO TABLE CONTAINS VALUES
  97. ; FOR 14.31818E6/14/BAUD RATE/2 (NTSC)
  98. ;
  99. BAUDO .WOR 10277-CBIT ; 50 BAUD
  100. .WOR 6818-CBIT ; 75 BAUD
  101. .WOR 4649-CBIT ; 110 BAUD
  102. .WOR 3800-CBIT ; 134.6 BAUD
  103. .WOR 3409-CBIT ; 150 BAUD
  104. .WOR 1705-CBIT ; 300 BAUD
  105. .WOR 852-CBIT ; 600 BAUD
  106. .WOR 426-CBIT ; 1200 BAUD
  107. .WOR 284-CBIT ; 1800 BAUD
  108. .WOR 213-CBIT ; 2400 BAUD
  109. ;
  110. ; CBIT - AN ADJUSTMENT TO MAKE NEXT T2 HIT NEAR CENTER
  111. ; OF THE NEXT BIT.
  112. ; APROX THE TIME TO SERVICE A CB1 NMI
  113. CBIT =100 ;CYCLES
  114. .PAG 'NMI - SUBROUTINES'
  115. ; T2NMI - SUBROUTINE TO HANDLE AN RS232
  116. ; BIT INPUT.
  117. ;
  118. T2NMI LDA D2PRB ;GET DATA IN
  119. AND #01 ;MASK OFF...
  120. STA INBIT ;...SAVE FOR LATTER
  121. ;
  122. ; UPDATE T2 FOR MID BIT CHECK
  123. ; (WORST CASE <213 CYCLES TO HERE)
  124. ; (CALC 125 CYCLES+43-66 DEAD)
  125. ;
  126. LDA D2T2L ;CALC NEW TIME & CLR NMI
  127. SBC #22+6
  128. ADC BAUDOF
  129. STA D2T2L
  130. LDA D2T2H
  131. ADC BAUDOF+1
  132. STA D2T2H
  133. ;
  134. LDA #$11 ;ENABLE TIMER
  135. STA D2CRB
  136. ;
  137. LDA ENABL ;RESTORE NMI'S EARLY...
  138. STA D2ICR
  139. ;
  140. LDA #$FF ;ENABLE COUNT FROM $FFFF
  141. STA D2T2L
  142. STA D2T2H
  143. ;
  144. JMP RSRCVR ;GO SHIFT IN...
  145. .SKI 3
  146. ; FLNMI - SUBROUTINE TO HANDLE THE
  147. ; START BIT TIMING..
  148. ;
  149. ; CHECK FOR NOISE ?
  150. ;
  151. FLNMI
  152. ;
  153. ; GET HALF BIT RATE VALUE
  154. ;
  155. LDA M51AJB
  156. STA D2T2L
  157. LDA M51AJB+1
  158. STA D2T2H
  159. ;
  160. LDA #$11 ;ENABLE TIMER
  161. STA D2CRB
  162. ;
  163. LDA #$12 ;DISABLE FLAG, ENABLE T2
  164. EOR ENABL
  165. STA ENABL
  166. ;ORA #$82
  167. ;STA D2ICR
  168. ;
  169. LDA #$FF ;PRESET FOR COUNT DOWN
  170. STA D2T2L
  171. STA D2T2H
  172. ;
  173. LDX BITNUM ;GET #OF BITS IN
  174. STX BITCI ;PUT IN RCVRCNT
  175. RTS
  176. ;
  177. ; POPEN - PATCHES OPEN RS232 FOR UNIVERSAL KERNAL
  178. ;
  179. POPEN TAX ;WE'RE CALCULATING BAUD RATE
  180. LDA M51AJB+1 ; M51AJB=FREQ/BAUD/2-100
  181. ROL A
  182. TAY
  183. TXA
  184. ADC #CBIT+CBIT
  185. STA BAUDOF
  186. TYA
  187. ADC #0
  188. STA BAUDOF+1
  189. RTS
  190. NOP
  191. NOP
  192. .END
  193. ; RSR 8/02/80 - ROUTINE FOR PANIC
  194. ; RSR 8/08/80 - PANIC & STOP KEY
  195. ; RSR 8/12/80 - CHANGE FOR A0INT A SUBROUTINE
  196. ; RSR 8/19/80 - ADD RS-232 CHECKS
  197. ; RSR 8/21/80 - MODIFY RS-232
  198. ; RSR 8/29/80 - CHANGE PANIC ORDER FOR JACK
  199. ; RSR 8/30/80 - ADD T2
  200. ; RSR 9/22/80 - ADD 1800 BAUD OPPS!
  201. ; RSR 12/08/81 - MODIFY FOR VIC-40 SYSTEM
  202. ; RSR 12/11/81 - CONTINUE MODIFICATIONS (VIC-40)
  203. ; RSR 12/14/81 - MODIFY FOR 6526 TIMER ADJUST
  204. ; RSR 2/09/82 - FIX ENABLE FOR FLAG NMI
  205. ; RSR 2/16/82 - REWRITE FOR 6526 PROBLEMS
  206. ; RSR 3/11/82 - CHANGE NMI RENABLE, FIX RESTORE
  207. ; RSR 3/29/82 - ENABLES ARE ALWAYS OR'ED WITH $80