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.

opnchnl.src 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. .page 'open channel'
  2. ; opchnl
  3. ;
  4. ; open a read chanl with 2 buffers
  5. ; will insert sa in lintab
  6. ; and inits all pointers.
  7. ; relative ss and ptrs are set.
  8. ;
  9. opnrch lda #1 ; get one data buffer
  10. jsr getrch
  11. jsr initp ; clear pointers
  12. lda type
  13. pha
  14. asl a
  15. ora drvnum
  16. sta filtyp,x ; set file type
  17. jsr strrd ; read 1st one or two blocks
  18. ldx lindx
  19. lda track
  20. bne or10
  21. ;
  22. lda sector
  23. sta lstchr,x ; set last char ptr
  24. or10
  25. pla
  26. cmp #reltyp
  27. bne or30 ; must be sequential stuff
  28. ;
  29. ldy sa
  30. lda lintab,y ; set channel as r/w
  31. ora #$40
  32. sta lintab,y
  33. ;
  34. ;
  35. lda rec
  36. sta rs,x ; set record size
  37. ;
  38. jsr getbuf ; get ss buffer
  39. bpl or20
  40. jmp gberr ; no buffer
  41. or20
  42. ldx lindx
  43. sta ss,x
  44. ldy trkss ; set ss track
  45. sty track
  46. ldy secss ; set ss sector
  47. sty sector
  48. jsr seth ; set ss header
  49. jsr rdss ; read it in
  50. jsr watjob
  51. orow
  52. ;
  53. ldx lindx
  54. lda #2
  55. sta nr,x ; set for nxtrec
  56. ;
  57. lda #0
  58. jsr setpnt ; set first data byte
  59. ;
  60. jsr rd40 ; set up 1st record
  61. jmp gethdr ; restore t&s
  62. ;
  63. or30
  64. jsr rdbyt ; sequential set up
  65. ldx lindx
  66. sta chndat,x
  67. lda #rdytlk
  68. sta chnrdy,x
  69. rts
  70. ;
  71. ; initialize variables for open chanl
  72. ; lstjob,sets active buffer#,lstchr,
  73. ; buffer pointers in buftab=2
  74. ;
  75. ;##### GCB 11/20/86 write to stack area bug ##############################
  76. initp ldx lindx
  77. lda buf0,x
  78. asl a
  79. bmi 1$ ;* GCB 11/20/86 *
  80. tay
  81. lda #2
  82. sta buftab,y
  83. 1$ lda buf1,x
  84. ora #$80
  85. sta buf1,x
  86. asl a
  87. bmi 2$ ;* GCB 11/20/86 *
  88. tay
  89. lda #2
  90. sta buftab,y
  91. 2$ lda #0
  92. sta nbkl,x
  93. jmp ptch26 ;* GCB 11/20/86 *
  94. nop ; (fill in the extra byte)
  95. ; sta nbkh,x
  96. ; lda #0
  97. ; sta lstchr,x
  98. ; rts
  99. rtch26
  100. ;##########################################################################
  101. ;
  102. ;
  103. ; open a write chanl with 2 buffers
  104. opnwch jsr intts ; get first track,sector
  105. lda #1
  106. jsr getwch ; get 1 buffers for writing
  107. jsr sethdr ; set up buffer headers
  108. jsr initp ; zropnt
  109. ldx lindx
  110. lda type
  111. pha
  112. asl a
  113. ora drvnum
  114. sta filtyp,x ; set filtyp=seq
  115. pla
  116. cmp #reltyp
  117. beq ow10
  118. lda #rdylst ; active listener
  119. sta chnrdy,x
  120. rts
  121. ;
  122. ow10
  123. ldy sa
  124. lda lintab,y
  125. and #$3f
  126. ora #$40
  127. sta lintab,y ; set channel as r/w
  128. ;
  129. lda rec
  130. sta rs,x ; set record size
  131. ;
  132. jsr getbuf ; get ss buffer
  133. bpl ow20
  134. jmp gberr ; no buffer
  135. ow20
  136. ldx lindx
  137. sta ss,x
  138. jsr clrbuf
  139. ;
  140. jsr nxtts
  141. lda track
  142. sta trkss ; save ss t&s
  143. lda sector
  144. sta secss
  145. ;
  146. ldx lindx
  147. lda ss,x
  148. jsr seth ; set ss header
  149. lda #0
  150. jsr setssp
  151. lda #0 ; set null link
  152. jsr putss
  153. lda #ssioff+1 ; set last char
  154. jsr putss
  155. lda #0 ; set this ss #
  156. jsr putss
  157. lda rec ; record size
  158. jsr putss
  159. lda track
  160. jsr putss
  161. lda sector
  162. jsr putss
  163. lda #ssioff
  164. jsr setssp
  165. jsr gethdr ; get first t&s
  166. lda track
  167. jsr putss
  168. lda sector
  169. jsr putss
  170. ;
  171. jsr wrtss ; write it out
  172. jsr watjob
  173. lda #2
  174. jsr setpnt
  175. ;
  176. ldx lindx ; set nr for null buffer
  177. sec
  178. lda #0
  179. sbc rs,x
  180. sta nr,x
  181. ;
  182. jsr nulbuf ; null records
  183. jsr nullnk
  184. jsr wrtout
  185. jsr watjob
  186. jsr mapout
  187. jmp orow
  188. ;
  189. ;*
  190. ;*
  191. ;***********************
  192. ;*
  193. ;* putss
  194. ;*
  195. ;* put byte into side sector
  196. ;*
  197. ;***********************
  198. ;*
  199. ;*
  200. putss pha
  201. ldx lindx
  202. lda ss,x
  203. jmp putb1
  204. ;
  205. ;.end