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.

seratn.src 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. .page 'ser.atn'
  2. ;
  3. ;
  4. ;
  5. atnirq lda pa1 ; clear irq (ca1)
  6. lda #1
  7. sta atnpnd
  8. rts
  9. ;
  10. atnsrv sei
  11. ;
  12. lda #0 ; clear pending flag
  13. sta atnpnd
  14. sta lsnact ; clear address flags
  15. sta tlkact
  16. ;
  17. ldx #topwrt ; reset stack
  18. txs
  19. ;
  20. lda #$80 ; set atn mode flag for acpt routine
  21. sta eoiflg ; reset eoi flag to non-eoi state
  22. sta atnmod
  23. ;
  24. jsr clkhi
  25. jsr datlow ; set data line low as response
  26. ;
  27. lda pb
  28. ; set atn ack to get hardware controll of data line
  29. ora #atna
  30. sta pb
  31. ;
  32. atns15 lda pb ; test atn still here
  33. bpl atns20 ; gone !
  34. and #clkin ; clock still low
  35. bne atns15
  36. ;
  37. ;
  38. atn30 jsr acptr ; get a command byte
  39. ;
  40. cmp #unlsn
  41. bne atn35
  42. ;
  43. lda #0 ; general unlisten command
  44. sta lsnact
  45. beq atn122 ; jmp
  46. ;
  47. atn35 cmp #untlk
  48. bne atn40
  49. ;
  50. lda #0
  51. sta tlkact ; untalk now
  52. beq atn122 ; jmp
  53. ;
  54. atn40 cmp tlkadr ; our talk address?
  55. bne atn45 ; nope
  56. ;
  57. lda #1 ; yes
  58. sta tlkact ; set active talker flag
  59. lda #0
  60. sta lsnact ; unlisten
  61. beq atn95 ; jump
  62. ;
  63. atn45 cmp lsnadr ; out listen address?
  64. bne atn50 ; nope
  65. ;
  66. lda #1 ; yes
  67. sta lsnact
  68. lda #0
  69. sta tlkact
  70. beq atn95 ; jump
  71. ;
  72. atn50 tax ; test if sa
  73. and #$60
  74. cmp #$60 ; sa = $60 + n
  75. bne atn120 ; did not get a valid command
  76. ;
  77. ;
  78. txa ; a sa for me
  79. sta orgsa
  80. and #$0f ; strip junk
  81. sta sa
  82. ;
  83. lda orgsa ; test if close
  84. and #$f0
  85. cmp #$e0
  86. bne atn122 ; no
  87. ;
  88. cli
  89. jsr close ; close the file
  90. sei
  91. ;
  92. ; warning:::close doesn't return in time for atn122:::
  93. ;
  94. atn95 bit pb ; test atn still here
  95. bmi atn30
  96. ;
  97. ;
  98. ; atn gone , do what we where told to do
  99. ;
  100. ;
  101. atns20 lda #0 ; clear atn mode
  102. sta atnmod
  103. ;
  104. lda pb ; atn gone , release atn ack
  105. and #$ff-atna
  106. sta pb
  107. ;
  108. lda lsnact ; listen ?
  109. beq atn100
  110. ;
  111. jsr listen
  112. jmp idle
  113. ;
  114. atn100 lda tlkact ; talk?
  115. beq atn110
  116. ;
  117. jsr dathi ; release data line
  118. jsr clklow ; pull clock low
  119. ;
  120. jsr talk
  121. atn110 jmp ilerr ; release all lines and go to idle
  122. ;
  123. ; fix so (device not present) errors reported
  124. ;
  125. atn120 lda #$10 ; kill all but atnak
  126. sta pb
  127. atn122 bit pb
  128. bpl atns20 ; exit out same way after atn done
  129. bmi atn122 ; jmp
  130. ;
  131. ;.end
  132. ; rsr 12/8/80 fix inverted logic
  133. ; rsr 12/16/80 fix bad logic
  134. ; rsr 12/31/80 fix eoiflg and logic