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 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .PAGE 'CLOSE'
  2. ;
  3. ; CLOSE THE FILE ASSOCIATED WITH SA
  4. ;
  5. CLOSE
  6. LDA SA
  7. BNE CLS10 ; DIRECTORY CLOSE
  8. LDA #0
  9. STA DIRLST ; CLEAR DIR LIST
  10. JSR FRECHN
  11. CLS05
  12. JMP FREICH
  13. CLS10
  14. CMP #$F
  15. BEQ CLSALL ; CLOSE CMD CHANL
  16. JSR CLSCHN ; CLOSE CHANNEL
  17. LDA SA
  18. CMP #2
  19. BCC CLS05
  20. JMP ENDCMD
  21. ;
  22. ; CLOSE ALL SECONDARY CHANNELS
  23. ;
  24. CLSALL
  25. LDA #14
  26. STA SA
  27. CLS20
  28. JSR CLSCHN
  29. DEC SA
  30. BPL CLS20
  31. JMP ENDCMD
  32. ;
  33. ; CLOSE SECONDARY ADDRESS (SA)
  34. ;
  35. CLSCHN
  36. LDX SA
  37. LDA LINTAB,X
  38. CMP #$FF
  39. BNE CLSC28
  40. RTS
  41. CLSC28
  42. AND #$F
  43. STA LINDX
  44. JSR TYPFIL
  45. CMP #DIRTYP
  46. BEQ CLSC30 ; DIRECT CHANNEL
  47. CMP #RELTYP
  48. BEQ CLSREL
  49. JSR FNDWCH ; LOOK FOR WRITE CHANNEL
  50. BCS CLSC31
  51. JSR CLSWRT ; CLOSE SEQ WRITE
  52. JSR CLSDIR ; CLOSE DIRECTORY
  53. CLSC30
  54. JSR MAPOUT ; WRITE BAM OUT
  55. CLSC31
  56. JMP FRECHN
  57. CLSREL
  58. JSR SCRUB
  59. JSR DBLBUF
  60. JSR SSEND
  61. LDX SSNUM
  62. STX T4
  63. LDA SSIND
  64. SEC
  65. SBC #SSIOFF-2
  66. STA T3
  67. LDA GRPNUM
  68. STA R3
  69. JSR SSSCAL
  70. LDX #0
  71. LDA #2
  72. JSR ADDLIT
  73. LDX LINDX
  74. LDA RESULT
  75. STA NBKL,X
  76. LDA RESULT+1
  77. STA NBKH,X
  78. LDA #DYFILE
  79. JSR TSTFLG ; TEST IF FILE WRITTEN TO
  80. BEQ CLSR1
  81. JSR CLSDIR
  82. CLSR1
  83. JMP FRECHN
  84. ;
  85. ; CLOSE A WRITE CHANL
  86. ;
  87. CLSWRT
  88. LDX LINDX
  89. LDA NBKL,X
  90. ORA NBKH,X
  91. BNE CLSW10 ; AT LEAST 1 BLOCK WRITTEN
  92. JSR GETPNT
  93. CMP #2
  94. BNE CLSW10 ; AT LEAST 1 BYTE WRITTEN
  95. LDA #CR
  96. JSR PUTBYT
  97. CLSW10
  98. JSR GETPNT
  99. CMP #2
  100. BNE CLSW20 ; NOT MT BUFFER
  101. JSR DBLBUF ; SWITCH BUFS
  102. LDX LINDX
  103. LDA NBKL,X
  104. BNE CLSW15
  105. DEC NBKH,X
  106. CLSW15
  107. DEC NBKL,X
  108. JSR GETLNK
  109. JSR FRETS ; FREE EXTRA SECTOR
  110. LDA #0
  111. CLSW20
  112. SEC
  113. SBC #1 ; BACK UP 1
  114. PHA ; SAVE IT
  115. LDA #0
  116. JSR SETPNT
  117. JSR PUTBYT ; TRACK LINK = 0
  118. PLA ; LSTCHR COUNT
  119. JSR PUTBYT
  120. JSR WRTBUF ; WRITE OUT LAST BUFFER
  121. JSR WATJOB ; FINISH JOB UP
  122. JMP DBLBUF ; MAKE SURE BOTH BUFS OK
  123. ;
  124. ; DIRECTORY CLOSE ON OPEN WRITE FILE
  125. ;
  126. CLSDIR
  127. LDX LINDX ; SAVE LINDX
  128. STX WLINDX ; AND SA
  129. LDA SA
  130. PHA
  131. LDA DSEC,X ; GET DIRECTORY SECTOR
  132. STA SECTOR
  133. LDA DTRK,X
  134. STA TRACK
  135. LDA DIND,X ; GET SECTOR OFFSET
  136. STA INDEX
  137. LDA FILTYP,X ; DRIVE # IN FILTYP
  138. AND #1
  139. STA DRVNUM
  140. JSR GETACT ; ALLOCATE A BUFFER
  141. PHA
  142. STA JOBNUM
  143. JSR DRTRD ; READ DIRECTORY SECTOR
  144. LDY #0
  145. LDA BUFIND,X ; .X IS JOB#
  146. STA R0+1
  147. LDA INDEX
  148. STA R0
  149. LDA (R0),Y
  150. AND #$20
  151. BEQ CLSD5
  152. JSR TYPFIL
  153. CMP #RELTYP
  154. BEQ CLSD6
  155. LDA (R0),Y
  156. AND #$8F ; REPLACE FILE
  157. STA (R0),Y
  158. INY
  159. LDA (R0),Y
  160. STA TRACK
  161. STY TEMP+2
  162. LDY #27 ; EXTRACT REPLACEMENT LINK
  163. LDA (R0),Y ; TO LAST SECTOR
  164. PHA
  165. DEY
  166. LDA (R0),Y
  167. BNE CLSD4
  168. STA TRACK
  169. PLA
  170. STA SECTOR
  171. LDA #$67
  172. JSR CMDER2
  173. CLSD4
  174. PHA
  175. LDA #0
  176. STA (R0)Y
  177. INY
  178. STA (R0)Y
  179. PLA
  180. LDY TEMP+2
  181. STA (R0),Y
  182. INY
  183. LDA (R0),Y
  184. STA SECTOR
  185. PLA
  186. STA (R0),Y
  187. JSR DELFIL ; DELETE OLD FILE
  188. JMP CLSD6 ; SET CLOSE BIT
  189. CLSD5
  190. LDA (R0),Y
  191. AND #$F
  192. ORA #$80
  193. STA (R0),Y
  194. CLSD6 LDX WLINDX
  195. LDY #28 ; SET # OF BLOCKS
  196. LDA NBKL,X
  197. STA (R0),Y
  198. INY
  199. LDA NBKH,X
  200. STA (R0),Y
  201. PLA
  202. TAX
  203. LDA #WRITE ; WRITE DIRECTORY SECTOR
  204. ORA DRVNUM
  205. JSR DOIT
  206. PLA
  207. STA SA
  208. JMP FNDWCH ; RESTORE LINDX
  209. .END