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.

tapefile 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. .PAG 'TAPE FILES'
  2. ;FAH -- FIND ANY HEADER
  3. ;
  4. ;READS TAPE DEVICE UNTIL ONE OF FOLLOWING
  5. ;BLOCK TYPES FOUND: BDFH--BASIC DATA
  6. ;FILE HEADER, BLF--BASIC LOAD FILE
  7. ;FOR SUCCESS CARRY IS CLEAR ON RETURN.
  8. ;FOR FAILURE CARRY IS SET ON RETURN.
  9. ;IN ADDITION ACCUMULATOR IS 0 IF STOP
  10. ;KEY WAS PRESSED.
  11. ;
  12. FAH LDA VERCK ;SAVE OLD VERIFY
  13. PHA
  14. JSR RBLK ;READ TAPE BLOCK
  15. PLA
  16. STA VERCK ;RESTORE VERIFY FLAG
  17. BCS FAH40 ;READ TERMINATED
  18. ;
  19. LDY #0
  20. LDA (TAPE1)Y ;GET HEADER TYPE
  21. ;
  22. CMP #EOT ;CHECK END OF TAPE?
  23. BEQ FAH40 ;YES...FAILURE
  24. ;
  25. CMP #BLF ;BASIC LOAD FILE?
  26. BEQ FAH50 ;YES...SUCCESS
  27. ;
  28. CMP #PLF ;FIXED LOAD FILE?
  29. BEQ FAH50 ;YES...SUCCESS
  30. ;
  31. CMP #BDFH ;BASIC DATA FILE?
  32. BNE FAH ;NO...KEEP TRYING
  33. ;
  34. FAH50 TAX ;RETURN FILE TYPE IN .X
  35. BIT MSGFLG ;PRINTING MESSAGES?
  36. BPL FAH45 ;NO...
  37. ;
  38. LDY #MS17-MS1 ;PRINT "FOUND"
  39. JSR MSG
  40. ;
  41. ;OUTPUT COMPLETE FILE NAME
  42. ;
  43. LDY #5
  44. FAH55 LDA (TAPE1)Y
  45. JSR BSOUT
  46. INY
  47. CPY #21
  48. BNE FAH55
  49. ;
  50. FAH56 LDA TIME+1 ;SET UP FOR TIME OUT...
  51. JSR FPATCH ;GOTO PATCH...
  52. NOP
  53. ;
  54. FAH45 CLC ;SUCCESS FLAG
  55. DEY ;MAKE NONZERO FOR OKAY RETURN
  56. ;
  57. FAH40 RTS
  58. .SKI 5
  59. ;TAPEH--WRITE TAPE HEADER
  60. ;ERROR IF TAPE BUFFER DE-ALLOCATED
  61. ;CARRY CLEAR IF O.K.
  62. ;
  63. TAPEH STA T1
  64. ;
  65. ;DETERMINE ADDRESS OF BUFFER
  66. ;
  67. JSR ZZZ
  68. BCC TH40 ;BUFFER WAS DE-ALLOCATED
  69. ;
  70. ;PRESERVE START AND END ADDRESSES
  71. ;FOR CASE OF HEADER FOR LOAD FILE
  72. ;
  73. LDA STAH
  74. PHA
  75. LDA STAL
  76. PHA
  77. LDA EAH
  78. PHA
  79. LDA EAL
  80. PHA
  81. ;
  82. ;PUT BLANKS IN TAPE BUFFER
  83. ;
  84. LDY #BUFSZ-1
  85. LDA #'
  86. BLNK2 STA (TAPE1)Y
  87. DEY
  88. BNE BLNK2
  89. ;
  90. ;PUT BLOCK TYPE IN HEADER
  91. ;
  92. LDA T1
  93. STA (TAPE1)Y
  94. ;
  95. ;PUT START LOAD ADDRESS IN HEADER
  96. ;
  97. INY
  98. LDA STAL
  99. STA (TAPE1)Y
  100. INY
  101. LDA STAH
  102. STA (TAPE1)Y
  103. ;
  104. ;PUT END LOAD ADDRESS IN HEADER
  105. ;
  106. INY
  107. LDA EAL
  108. STA (TAPE1)Y
  109. INY
  110. LDA EAH
  111. STA (TAPE1)Y
  112. ;
  113. ;PUT FILE NAME IN HEADER
  114. ;
  115. INY
  116. STY T2
  117. LDY #0
  118. STY T1
  119. TH20 LDY T1
  120. CPY FNLEN
  121. BEQ TH30
  122. LDA (FNADR)Y
  123. LDY T2
  124. STA (TAPE1)Y
  125. INC T1
  126. INC T2
  127. BNE TH20
  128. ;
  129. ;SET UP START AND END ADDRESS OF HEADER
  130. ;
  131. TH30 JSR LDAD1
  132. ;
  133. ;SET UP TIME FOR LEADER
  134. ;
  135. LDA #$69
  136. STA SHCNH
  137. ;
  138. JSR TWRT2 ;WRITE HEADER ON TAPE
  139. ;
  140. ;RESTORE START AND END ADDRESS OF
  141. ;LOAD FILE.
  142. ;
  143. TAY ;SAVE ERROR CODE IN .Y
  144. PLA
  145. STA EAL
  146. PLA
  147. STA EAH
  148. PLA
  149. STA STAL
  150. PLA
  151. STA STAH
  152. TYA ;RESTORE ERROR CODE FOR RETURN
  153. ;
  154. TH40 RTS
  155. .SKI 5
  156. ;FUNCTION TO RETURN TAPE BUFFER
  157. ;ADDRESS IN TAPE1
  158. ;
  159. ZZZ LDX TAPE1 ;ASSUME TAPE1
  160. LDY TAPE1+1
  161. CPY #>BUF ;CHECK FOR ALLOCATION...
  162. ;...[TAPE1+1]=0 OR 1 MEANS DEALLOCATED
  163. ;...C CLR => DEALLOCATED
  164. RTS
  165. .SKI 5
  166. LDAD1 JSR ZZZ ;GET PTR TO CASSETTE
  167. TXA
  168. STA STAL ;SAVE START LOW
  169. CLC
  170. ADC #BUFSZ ;COMPUTE POINTER TO END
  171. STA EAL ;SAVE END LOW
  172. TYA
  173. STA STAH ;SAVE START HIGH
  174. ADC #0 ;COMPUTE POINTER TO END
  175. STA EAH ;SAVE END HIGH
  176. RTS
  177. .SKI 5
  178. FAF JSR FAH ;FIND ANY HEADER
  179. BCS FAF40 ;FAILED
  180. ;
  181. ;SUCCESS...SEE IF RIGHT NAME
  182. ;
  183. LDY #5 ;OFFSET INTO TAPE HEADER
  184. STY T2
  185. LDY #0 ;OFFSET INTO FILE NAME
  186. STY T1
  187. FAF20 CPY FNLEN ;COMPARE THIS MANY
  188. BEQ FAF30 ;DONE
  189. ;
  190. LDA (FNADR)Y
  191. LDY T2
  192. CMP (TAPE1)Y
  193. BNE FAF ;MISMATCH--TRY NEXT HEADER
  194. INC T1
  195. INC T2
  196. LDY T1
  197. BNE FAF20 ;BRANCH ALWAYS
  198. ;
  199. FAF30 CLC ;SUCCESS FLAG
  200. FAF40 RTS
  201. .END
  202. ; RSR 4/10/82 ADD KEY DOWN TEST IN FAH...