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.

close.src 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. .page 'close'
  2. ; close the file associated with sa
  3. ;
  4. close
  5. lda #0
  6. sta wbam
  7. lda sa
  8. bne cls10 ; directory close
  9. lda #0
  10. sta dirlst ; clear dir list
  11. jsr frechn
  12. cls05
  13. jmp freich
  14. cls10
  15. cmp #$f
  16. beq clsall ; close cmd chanl
  17. jsr clschn ; close channel
  18. lda sa
  19. cmp #2
  20. bcc cls05
  21. ;
  22. lda erword
  23. bne cls15 ; last command had an error
  24. jmp endcmd
  25. cls15
  26. jmp scren1
  27. ;
  28. clsall
  29. lda #14
  30. sta sa
  31. cls20
  32. jsr clschn
  33. dec sa
  34. bpl cls20
  35. lda erword
  36. bne cls25 ; last command had an error
  37. jmp endcmd
  38. cls25
  39. jmp scren1
  40. ;
  41. clschn
  42. ldx sa
  43. lda lintab,x
  44. cmp #$ff
  45. bne clsc28
  46. rts
  47. clsc28
  48. and #$f
  49. sta lindx
  50. ;
  51. jsr typfil
  52. cmp #dirtyp
  53. beq clsc30 ; direct channel
  54. cmp #reltyp
  55. beq clsrel
  56. ;
  57. jsr fndwch ; look for write channel
  58. bcs clsc31
  59. ;
  60. jsr clswrt ; close seq write
  61. jsr clsdir ; close directory
  62. clsc30
  63. jsr mapout ; write bam
  64. clsc31
  65. jmp frechn
  66. ;
  67. clsrel
  68. jsr scrub
  69. jsr dblbuf
  70. jsr ssend
  71. ldx ssnum
  72. stx t4
  73. inc t4
  74. lda #0
  75. sta t1
  76. sta t2
  77. lda ssind
  78. sec
  79. sbc #ssioff-2
  80. sta t3
  81. jsr sscalc
  82. ldx lindx
  83. lda t1
  84. sta nbkl,x
  85. lda t2
  86. sta nbkh,x
  87. lda #dyfile
  88. jsr tstflg
  89. beq clsr1
  90. jsr clsdir
  91. clsr1 jmp frechn
  92. ;
  93. ; close a write chanl
  94. ;
  95. clswrt ; close seq write file
  96. ldx lindx
  97. lda nbkl,x
  98. ora nbkh,x
  99. bne clsw10 ; at least 1 block written
  100. ;
  101. jsr getpnt
  102. cmp #2
  103. bne clsw10 ; at least 1 byte written
  104. ;
  105. lda #cr
  106. jsr putbyt
  107. clsw10
  108. jsr getpnt
  109. cmp #2
  110. bne clsw20 ; not mt buffer
  111. ;
  112. jsr dblbuf ; switch bufs
  113. ;
  114. ldx lindx
  115. lda nbkl,x
  116. bne clsw15
  117. dec nbkh,x
  118. clsw15
  119. dec nbkl,x
  120. ;
  121. lda #0
  122. clsw20
  123. sec
  124. sbc #1 ; back up 1
  125. pha ; save it
  126. lda #0
  127. jsr setpnt
  128. jsr putbyt ; tlink=0
  129. pla ; lstchr count
  130. jsr putbyt
  131. ;
  132. jsr wrtbuf ; write out last buffer
  133. jsr watjob ; finish job up
  134. jmp dblbuf ; make sure both bufs ok
  135. ;rts
  136. ;
  137. ; directory close on open write file
  138. ;
  139. clsdir ldx lindx ; save lindx
  140. stx wlindx ; &sa
  141. lda sa
  142. pha
  143. lda dsec,x ; get directory sector
  144. sta sector
  145. lda dind,x ; get sector offset
  146. sta index
  147. lda filtyp,x ; drv # in filtyp
  148. and #1
  149. sta drvnum
  150. lda dirtrk
  151. sta track
  152. jsr getact ; allocate a buffer
  153. pha
  154. sta jobnum
  155. jsr drtrd ; read directory sector
  156. ldy #0
  157. lda bufind,x ; .x is job#
  158. sta r0+1
  159. lda index
  160. sta r0
  161. lda (r0),y
  162. and #$20
  163. beq clsd5
  164. jsr typfil
  165. cmp #reltyp
  166. beq clsd6
  167. ;
  168. lda (r0),y
  169. and #$8f ; replace file
  170. sta (r0),y
  171. iny
  172. lda (r0),y
  173. sta track
  174. sty temp+2
  175. ldy #27 ; extract replacement link
  176. lda (r0),y ; to last sector
  177. pha
  178. dey
  179. lda (r0),y
  180. bne clsd4
  181. sta track
  182. pla
  183. sta sector
  184. lda #$67
  185. jsr cmder2
  186. clsd4
  187. pha
  188. lda #0
  189. sta (r0),y
  190. iny
  191. sta (r0),y
  192. pla
  193. ldy temp+2
  194. sta (r0),y
  195. iny
  196. lda (r0),y
  197. sta sector
  198. pla
  199. sta (r0),y
  200. jsr delfil ; delete old file
  201. jmp clsd6 ; set close bit
  202. clsd5
  203. lda (r0),y
  204. and #$f
  205. ora #$80
  206. sta (r0),y
  207. clsd6 ldx wlindx
  208. ldy #28 ; set # of blocks
  209. lda nbkl,x
  210. sta (r0),y
  211. iny
  212. lda nbkh,x
  213. sta (r0),y
  214. pla
  215. tax
  216. lda #write ; write directory sector
  217. ora drvnum
  218. jsr doit
  219. pla
  220. sta sa
  221. jmp fndwch ; restore lindx
  222. ;
  223. ;
  224. ; .end