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.

load 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. .PAG 'LOAD FUNCTION'
  2. ;**********************************
  3. ;* LOAD RAM FUNCTION *
  4. ;* *
  5. ;* LOADS FROM CASSETTE 1 OR 2, OR *
  6. ;* SERIAL BUS DEVICES >=4 TO 31 *
  7. ;* AS DETERMINED BY CONTENTS OF *
  8. ;* VARIABLE FA. VERIFY FLAG IN .A *
  9. ;* *
  10. ;* ALT LOAD IF SA=0, NORMAL SA=1 *
  11. ;* .X , .Y LOAD ADDRESS IF SA=0 *
  12. ;* .A=0 PERFORMS LOAD,<> IS VERIFY*
  13. ;* *
  14. ;* HIGH LOAD RETURN IN X,Y. *
  15. ;* *
  16. ;**********************************
  17. .SKI 3
  18. LOADSP STX MEMUSS ;.X HAS LOW ALT START
  19. STY MEMUSS+1
  20. LOAD JMP (ILOAD) ;MONITOR LOAD ENTRY
  21. ;
  22. NLOAD STA VERCK ;STORE VERIFY FLAG
  23. LDA #0
  24. STA STATUS
  25. ;
  26. LDA FA ;CHECK DEVICE NUMBER
  27. BNE LD20
  28. ;
  29. LD10 JMP ERROR9 ;BAD DEVICE #-KEYBOARD
  30. ;
  31. LD20 CMP #3
  32. BEQ LD10 ;DISALLOW SCREEN LOAD
  33. BCC LD100 ;HANDLE TAPES DIFFERENT
  34. ;
  35. ;LOAD FROM CBM IEEE DEVICE
  36. ;
  37. LDY FNLEN ;MUST HAVE FILE NAME
  38. BNE LD25 ;YES...OK
  39. ;
  40. JMP ERROR8 ;MISSING FILE NAME
  41. ;
  42. LD25 LDX SA ;SAVE SA IN .X
  43. JSR LUKING ;TELL USER LOOKING
  44. LDA #$60 ;SPECIAL LOAD COMMAND
  45. STA SA
  46. JSR OPENI ;OPEN THE FILE
  47. ;
  48. LDA FA
  49. JSR TALK ;ESTABLISH THE CHANNEL
  50. LDA SA
  51. JSR TKSA ;TELL IT TO LOAD
  52. ;
  53. JSR ACPTR ;GET FIRST BYTE
  54. STA EAL
  55. ;
  56. LDA STATUS ;TEST STATUS FOR ERROR
  57. LSR A
  58. LSR A
  59. BCS LD90 ;FILE NOT FOUND...
  60. JSR ACPTR
  61. STA EAH
  62. ;
  63. TXA ;FIND OUT OLD SA
  64. BNE LD30 ;SA<>0 USE DISK ADDRESS
  65. LDA MEMUSS ;ELSE LOAD WHERE USER WANTS
  66. STA EAL
  67. LDA MEMUSS+1
  68. STA EAH
  69. LD30 JSR LODING ;TELL USER LOADING
  70. ;
  71. LD40 LDA #$FD ;MASK OFF TIMEOUT
  72. AND STATUS
  73. STA STATUS
  74. ;
  75. JSR STOP ;STOP KEY?
  76. BNE LD45 ;NO...
  77. ;
  78. JMP BREAK ;STOP KEY PRESSED
  79. ;
  80. LD45 JSR ACPTR ;GET BYTE OFF IEEE
  81. TAX
  82. LDA STATUS ;WAS THERE A TIMEOUT?
  83. LSR A
  84. LSR A
  85. BCS LD40 ;YES...TRY AGAIN
  86. TXA
  87. LDY VERCK ;PERFORMING VERIFY?
  88. BEQ LD50 ;NO...LOAD
  89. LDY #0
  90. CMP (EAL)Y ;VERIFY IT
  91. BEQ LD60 ;O.K....
  92. LDA #SPERR ;NO GOOD...VERIFY ERROR
  93. JSR UDST ;UPDATE STATUS
  94. .BYT $2C ;SKIP NEXT STORE
  95. ;
  96. LD50 STA (EAL)Y
  97. LD60 INC EAL ;INCREMENT STORE ADDR
  98. BNE LD64
  99. INC EAH
  100. LD64 BIT STATUS ;EOI?
  101. BVC LD40 ;NO...CONTINUE LOAD
  102. ;
  103. JSR UNTLK ;CLOSE CHANNEL
  104. JSR CLSEI ;CLOSE THE FILE
  105. BCC LD180 ;BRANCH ALWAYS
  106. ;
  107. LD90 JMP ERROR4 ;FILE NOT FOUND
  108. ;
  109. ;LOAD FROM TAPE
  110. ;
  111. LD100 LSR A
  112. BCS LD102 ;IF C-SET THEN IT'S CASSETTE
  113. ;
  114. JMP ERROR9 ;BAD DEVICE #
  115. ;
  116. LD102 JSR ZZZ ;SET POINTERS AT TAPE
  117. BCS LD104
  118. JMP ERROR9 ;DEALLOCATED...
  119. LD104 JSR CSTE1 ;TELL USER ABOUT BUTTONS
  120. BCS LD190 ;STOP KEY PRESSED?
  121. JSR LUKING ;TELL USER SEARCHING
  122. ;
  123. LD112 LDA FNLEN ;IS THERE A NAME?
  124. BEQ LD150 ;NONE...LOAD ANYTHING
  125. JSR FAF ;FIND A FILE ON TAPE
  126. BCC LD170 ;GOT IT!
  127. BEQ LD190 ;STOP KEY PRESSED
  128. BCS LD90 ;NOPE...END OF TAPE
  129. ;
  130. LD150 JSR FAH ;FIND ANY HEADER
  131. BEQ LD190 ;STOP KEY PRESSED
  132. BCS LD90 ;NO HEADER
  133. ;
  134. LD170 LDA STATUS
  135. AND #SPERR ;MUST GOT HEADER RIGHT
  136. SEC
  137. BNE LD190 ;IS BAD
  138. ;
  139. CPX #BLF ;IS IT A MOVABLE PROGRAM...
  140. BEQ LD178 ;YES
  141. ;
  142. CPX #PLF ;IS IT A PROGRAM
  143. BNE LD112 ;NO...ITS SOMETHING ELSE
  144. ;
  145. LD177 LDY #1 ;FIXED LOAD...
  146. LDA (TAPE1)Y ;...THE ADDRESS IN THE...
  147. STA MEMUSS ;...BUFFER IS THE START ADDRESS
  148. INY
  149. LDA (TAPE1)Y
  150. STA MEMUSS+1
  151. BCS LD179 ;JMP ..CARRY SET BY CPX'S
  152. ;
  153. LD178 LDA SA ;CHECK FOR MONITOR LOAD...
  154. BNE LD177 ;...YES WE WANT FIXED TYPE
  155. ;
  156. LD179 LDY #3 ;TAPEA - TAPESTA
  157. ;CARRY SET BY CPX'S
  158. LDA (TAPE1)Y
  159. LDY #1
  160. SBC (TAPE1)Y
  161. TAX ;LOW TO .X
  162. LDY #4
  163. LDA (TAPE1)Y
  164. LDY #2
  165. SBC (TAPE1)Y
  166. TAY ;HIGH TO .Y
  167. ;
  168. CLC ;EA = STA+(TAPEA-TAPESTA)
  169. TXA
  170. ADC MEMUSS ;
  171. STA EAL
  172. TYA
  173. ADC MEMUSS+1
  174. STA EAH
  175. LDA MEMUSS ;SET UP STARTING ADDRESS
  176. STA STAL
  177. LDA MEMUSS+1
  178. STA STAH
  179. JSR LODING ;TELL USER LOADING
  180. JSR TRD ;DO TAPE BLOCK LOAD
  181. .BYT $24 ;CARRY FROM TRD
  182. ;
  183. LD180 CLC ;GOOD EXIT
  184. ;
  185. ; SET UP END LOAD ADDRESS
  186. ;
  187. LDX EAL
  188. LDY EAH
  189. ;
  190. LD190 RTS
  191. .SKI 5
  192. ;SUBROUTINE TO PRINT TO CONSOLE:
  193. ;
  194. ;SEARCHING [FOR NAME]
  195. ;
  196. LUKING LDA MSGFLG ;SUPPOSED TO PRINT?
  197. BPL LD115 ;...NO
  198. LDY #MS5-MS1 ;"SEARCHING"
  199. JSR MSG
  200. LDA FNLEN
  201. BEQ LD115
  202. LDY #MS6-MS1 ;"FOR"
  203. JSR MSG
  204. .SKI 3
  205. ;SUBROUTINE TO OUTPUT FILE NAME
  206. ;
  207. OUTFN LDY FNLEN ;IS THERE A NAME?
  208. BEQ LD115 ;NO...DONE
  209. LDY #0
  210. LD110 LDA (FNADR)Y
  211. JSR BSOUT
  212. INY
  213. CPY FNLEN
  214. BNE LD110
  215. ;
  216. LD115 RTS
  217. .SKI 3
  218. ;SUBROUTINE TO PRINT:
  219. ;
  220. ;LOADING/VERIFING
  221. ;
  222. LODING LDY #MS10-MS1 ;ASSUME 'LOADING'
  223. LDA VERCK ;CHECK FLAG
  224. BEQ LD410 ;ARE DOING LOAD
  225. LDY #MS21-MS1 ;ARE 'VERIFYING'
  226. LD410 JMP SPMSG
  227. .END