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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .PAG 'CLOSE'
  2. ;***************************************
  3. ;* CLOSE -- CLOSE LOGICAL FILE *
  4. ;* *
  5. ;* THE LOGICAL FILE NUMBER OF THE*
  6. ;* FILE TO BE CLOSED IS PASSED IN .A.*
  7. ;* KEYBOARD, SCREEN, AND FILES NOT *
  8. ;* OPEN PASS STRAIGHT THROUGH. TAPE *
  9. ;* FILES OPEN FOR WRITE ARE CLOSED BY*
  10. ;* DUMPING THE LAST BUFFER AND *
  11. ;* CONDITIONALLY WRITING AN END OF *
  12. ;* TAPE BLOCK.SERIAL FILES ARE CLOSED*
  13. ;* BY SENDING A CLOSE FILE COMMAND IF*
  14. ;* A SECONDARY ADDRESS WAS SPECIFIED *
  15. ;* IN ITS OPEN COMMAND. *
  16. ;***************************************
  17. ;
  18. NCLOSE JSR JLTLK ;LOOK FILE UP
  19. BEQ JX050 ;OPEN...
  20. CLC ;ELSE RETURN
  21. RTS
  22. ;
  23. JX050 JSR JZ100 ;EXTRACT TABLE DATA
  24. TXA ;SAVE TABLE INDEX
  25. PHA
  26. ;
  27. LDA FA ;CHECK DEVICE NUMBER
  28. BEQ JX150 ;IS KEYBOARD...DONE
  29. CMP #3
  30. BEQ JX150 ;IS SCREEN...DONE
  31. BCS JX120 ;IS SERIAL...PROCESS
  32. CMP #2 ;RS232?
  33. BNE JX115 ;NO...
  34. ;
  35. ; RS-232 CLOSE
  36. ;
  37. ; REMOVE FILE FROM TABLES
  38. PLA
  39. JSR JXRMV
  40. ;
  41. JSR CLN232 ;CLEAN UP RS232 FOR CLOSE
  42. ;
  43. ; DEALLOCATE BUFFERS
  44. ;
  45. JSR GETTOP ;GET MEMSIZ
  46. LDA RIBUF+1 ;CHECK INPUT ALLOCATION
  47. BEQ CLS010 ;NOT...ALLOCATED
  48. INY
  49. CLS010 LDA ROBUF+1 ;CHECK OUTPUT ALLOCATION
  50. BEQ CLS020
  51. INY
  52. CLS020 LDA #00 ;DEALLOCATE
  53. STA RIBUF+1
  54. STA ROBUF+1
  55. ; FLAG TOP OF MEMORY CHANGE
  56. JMP MEMTCF ;GO SET NEW TOP
  57. ;
  58. ;CLOSE CASSETTE FILE
  59. ;
  60. JX115 LDA SA ;WAS IT A TAPE READ?
  61. AND #$F
  62. BEQ JX150 ;YES
  63. ;
  64. JSR ZZZ ;NO. . .IT IS WRITE
  65. LDA #0 ;END OF FILE CHARACTER
  66. SEC ;NEED TO SET CARRY FOR CASOUT (ELSE RS232 OUTPUT!)
  67. JSR CASOUT ;PUT IN END OF FILE
  68. JSR WBLK
  69. BCC JX117 ;NO ERRORS...
  70. PLA ;CLEAN STACK FOR ERROR
  71. LDA #0 ;BREAK KEY ERROR
  72. RTS
  73. ;
  74. JX117 LDA SA
  75. CMP #$62 ;WRITE END OF TAPE BLOCK?
  76. BNE JX150 ;NO...
  77. ;
  78. LDA #EOT
  79. JSR TAPEH ;WRITE END OF TAPE BLOCK
  80. JMP JX150
  81. ;
  82. ;CLOSE AN SERIAL FILE
  83. ;
  84. JX120 JSR CLSEI
  85. ;
  86. ;ENTRY TO REMOVE A GIVE LOGICAL FILE
  87. ;FROM TABLE OF LOGICAL, PRIMARY,
  88. ;AND SECONDARY ADDRESSES
  89. ;
  90. JX150 PLA ;GET TABLE INDEX OFF STACK
  91. ;
  92. ; JXRMV - ENTRY TO USE AS AN RS-232 SUBROUTINE
  93. ;
  94. JXRMV TAX
  95. DEC LDTND
  96. CPX LDTND ;IS DELETED FILE AT END?
  97. BEQ JX170 ;YES...DONE
  98. ;
  99. ;DELETE ENTRY IN MIDDLE BY MOVING
  100. ;LAST ENTRY TO THAT POSITION.
  101. ;
  102. LDY LDTND
  103. LDA LAT,Y
  104. STA LAT,X
  105. LDA FAT,Y
  106. STA FAT,X
  107. LDA SAT,Y
  108. STA SAT,X
  109. ;
  110. JX170 CLC ;CLOSE EXIT
  111. JX175 RTS
  112. .SKI 5
  113. ;LOOKUP TABLIZED LOGICAL FILE DATA
  114. ;
  115. LOOKUP LDA #0
  116. STA STATUS
  117. TXA
  118. JLTLK LDX LDTND
  119. JX600 DEX
  120. BMI JZ101
  121. CMP LAT,X
  122. BNE JX600
  123. RTS
  124. .SKI 5
  125. ;ROUTINE TO FETCH TABLE ENTRIES
  126. ;
  127. JZ100 LDA LAT,X
  128. STA LA
  129. LDA FAT,X
  130. STA FA
  131. LDA SAT,X
  132. STA SA
  133. JZ101 RTS
  134. .END
  135. ; RSR 5/12/82 - MODIFY FOR CLN232