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.

225 lines
3.0KB

  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