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.

open 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. .PAGE 'OPEN'
  2. ;OPEN CHANNEL FROM IEEE
  3. ; PARSES THE INPUT STRING THAT IS
  4. ; SENT AS AN OPEN DATA CHANNEL,
  5. ; LOAD, OR SAVE. CHANNELS ARE ALLOCATED
  6. ; AND THE DIRECTORY IS SEARCHED FOR
  7. ; THE FILENAME CONTAINED IN THE STRING.
  8. .SKIP
  9. OPEN
  10. LDA SA
  11. STA TEMPSA
  12. JSR CMDSET ;INITIATE CMD PTRS
  13. STX CMDNUM
  14. LDX CMDBUF
  15. LDA TEMPSA
  16. BNE OP021
  17. CPX #'* ;LOAD LAST?
  18. BNE OP021
  19. LDA PRGTRK
  20. BEQ OP0415 ;NO LAST PROG, INIT 0
  21. .SKIP
  22. OP02 ;LOAD LAST PROGRAM
  23. STA TRACK
  24. LDA PRGDRV
  25. STA DRVNUM
  26. STA FILDRV
  27. LDA #PRGTYP
  28. STA PATTYP
  29. LDA PRGSEC
  30. STA SECTOR
  31. JSR SETLDS ; MAKE SURE LED GETS TURNED ON!!
  32. JSR OPNRCH
  33. LDA #PRGTYP+PRGTYP
  34. ORA DRVNUM
  35. ENDRD LDX LINDX
  36. STA FILTYP,Y
  37. JMP ENDCMD
  38. .SKIP
  39. OP021 CPX #'$
  40. BNE OP041
  41. LDA TEMPSA ;LOAD DIRECTORY
  42. BNE OP04
  43. JMP LOADIR
  44. .SKIP
  45. OP04 JSR SIMPRS ;OPEN DIR AS SEQ FILE
  46. LDA DIRTRK
  47. STA TRACK
  48. LDA #0
  49. STA SECTOR
  50. JSR OPNRCH
  51. LDA DRVNUM
  52. ORA #SEQTYP+SEQTYP
  53. JMP ENDRD
  54. .SKIP
  55. OP041 CPX #'# ;"#" IS DIRECT ACCESS
  56. BNE OP042
  57. JMP OPNBLK
  58. .SKIP
  59. OP0415 LDA #PRGTYP ;PROGRAM TYPE
  60. STA TYPFLG
  61. LDA #0
  62. STA DRVNUM
  63. STA LSTDRV
  64. JSR INITDR
  65. .SKIP
  66. OP042
  67. JSR PRSCLN ;LOOK FOR ":"
  68. BNE OP049
  69. LDX #0
  70. BEQ OP20 ;BRA
  71. OP049
  72. TXA
  73. BEQ OP10
  74. OP05 LDA #BADSYN ;SOMETHING AMISS
  75. JMP CMDERR
  76. OP10 DEY ;BACK UP TO ":"
  77. BEQ OP20 ;1ST CHAR IS ":"
  78. DEY
  79. OP20 STY FILTBL ;SAVE FILENAME PTR
  80. LDA #$8D ;LOOK FOR CR-SHIFTED
  81. JSR PARSE
  82. .SKIP
  83. INX
  84. STX F2CNT
  85. JSR ONEDRV
  86. JSR OPTSCH
  87. JSR FFST ;LOOK FOR FILE ENTRY
  88. LDX #0
  89. STX REC
  90. STX MODE ;READ MODE
  91. STX TYPE ;DELETED
  92. INX
  93. CPX F1CNT
  94. BCS OP40 ;NO PARAMETERS
  95. ;
  96. JSR CKTM ;CHECK FOR TYPE & MODE
  97. INX
  98. CPX F1CNT
  99. BCS OP40 ;ONLY ONE PARAMETER
  100. ;
  101. CPY #RELTYP
  102. BEQ OP60 ;SET RECORD SIZE
  103. ;
  104. JSR CKTM ;SET TYPE/MODE
  105. OP40
  106. LDX TEMPSA
  107. STX SA ;SET SA BACK
  108. CPX #2
  109. BCS OP45 ;NOT LOAD OR SAVE
  110. ;
  111. STX MODE ;MODE=SA
  112. LDA #$40
  113. STA WBAM
  114. LDA TYPE
  115. BNE OP50 ;TYPE FROM PARM
  116. ;
  117. LDA #PRGTYP
  118. STA TYPE ;USE PRG
  119. OP45
  120. LDA TYPE
  121. BNE OP50 ;TYPE FROM PARM
  122. ;
  123. LDA PATTYP
  124. AND #TYPMSK
  125. STA TYPE ;TYPE FROM FILE
  126. ;
  127. LDA FILTRK
  128. BNE OP50 ;YES, IT EXISTS
  129. ;
  130. LDA #SEQTYP
  131. STA TYPE ;DEFAULT IS SEQ
  132. OP50
  133. LDA MODE
  134. CMP #WTMODE
  135. BEQ OP75 ;GO WRITE
  136. ;
  137. JMP OP90
  138. ;
  139. OP60
  140. LDY FILTBL,X ;GET RECORD SIZE
  141. LDA CMDBUF,Y
  142. STA REC
  143. LDA FILTRK
  144. BNE OP40 ;IT'S HERE, READ
  145. ;
  146. LDA #WTMODE ;USE WRITE TO OPEN
  147. STA MODE
  148. BNE OP40 ;(BRA)
  149. ;
  150. OP75
  151. LDA PATTYP
  152. AND #$80
  153. TAX
  154. BNE OP81
  155. OP77 LDA #$20 ;OPEN WRITE
  156. BIT PATTYP
  157. BEQ OP80
  158. JSR DELDIR ;CREATED
  159. JMP OPWRIT
  160. .SKIP
  161. OP80 LDA FILTRK
  162. BNE OP81
  163. JMP OPWRIT ;NOT FOUND, OK!
  164. OP81 LDA CMDBUF
  165. CMP #'@ ;CHECK FOR REPLACE
  166. BEQ OP82
  167. TXA
  168. BNE OP815
  169. LDA #FLEXST
  170. JMP CMDERR
  171. OP815
  172. LDA #BADFN
  173. JMP CMDERR
  174. .SKIP
  175. ;********* CHECK FOR BUG HERE******
  176. OP82
  177. LDA PATTYP ;REPLACE
  178. AND #TYPMSK
  179. CMP TYPE
  180. BNE OP115
  181. CMP #RELTYP
  182. BEQ OP115
  183. ;
  184. .SKIP
  185. JSR OPNWCH
  186. LDA LINDX
  187. STA WLINDX
  188. LDA #IRSA ;INTERNAL CHAN
  189. STA SA
  190. JSR FNDRCH
  191. LDA INDEX
  192. JSR SETPNT
  193. LDY #0
  194. LDA (DIRBUF),Y
  195. ORA #$20 ;SET REPLACE BIT
  196. STA (DIRBUF),Y
  197. ;
  198. LDY #26
  199. LDA TRACK
  200. STA (DIRBUF),Y
  201. INY
  202. LDA SECTOR
  203. STA (DIRBUF),Y
  204. .SKIP
  205. LDX WLINDX
  206. LDA ENTSEC
  207. STA DSEC,X
  208. LDA ENTIND
  209. STA DIND,X
  210. JSR CURBLK
  211. JSR DRTWRT
  212. JMP OPFIN
  213. ;**********************************
  214. ;
  215. .SKIP
  216. OP90 LDA FILTRK ;OPEN READ (& LOAD)
  217. BNE OP100
  218. OP95
  219. LDA #FLNTFD ;TRACK NOT RECORDED
  220. JMP CMDERR ;NOT FOUND
  221. OP100
  222. LDA MODE
  223. CMP #MDMODE
  224. BEQ OP110
  225. LDA #$20
  226. BIT PATTYP
  227. BEQ OP110
  228. LDA #FILOPN
  229. JMP CMDERR
  230. OP110 LDA PATTYP
  231. AND #TYPMSK ;TYPE IS IN INDEX TABLE
  232. CMP TYPE
  233. BEQ OP120
  234. OP115 LDA #MISTYP ;TYPE MISMATCH
  235. JMP CMDERR
  236. OP120 ;EVERYTHING IS OK!
  237. LDY #0
  238. STY F2PTR
  239. LDX MODE
  240. CPX #APMODE
  241. BNE OP125
  242. CMP #RELTYP
  243. BEQ OP115
  244. ;
  245. LDA (DIRBUF),Y
  246. AND #$4F
  247. STA (DIRBUF),Y
  248. LDA SA
  249. PHA
  250. LDA #IRSA
  251. STA SA
  252. JSR CURBLK
  253. JSR DRTWRT
  254. PLA
  255. STA SA
  256. OP125
  257. JSR OPREAD
  258. LDA MODE
  259. CMP #APMODE
  260. BNE OPFIN
  261. ;
  262. JSR APPEND
  263. JMP ENDCMD
  264. ;
  265. ;**********************
  266. OPREAD
  267. LDY #19
  268. LDA (DIRBUF)Y
  269. STA TRKSS
  270. INY
  271. LDA (DIRBUF)Y
  272. STA SECSS
  273. INY
  274. LDA (DIRBUF)Y
  275. LDX REC
  276. STA REC
  277. TXA
  278. BEQ OP130
  279. CMP REC
  280. BEQ OP130
  281. LDA #NOREC
  282. JSR CMDERR
  283. OP130
  284. LDX F2PTR
  285. LDA FILTRK,X
  286. STA TRACK
  287. LDA FILSEC,X
  288. STA SECTOR
  289. JSR OPNRCH
  290. LDY LINDX ;OPEN A READ CHNL
  291. LDX F2PTR
  292. LDA ENTSEC,X
  293. STA DSEC,Y
  294. LDA ENTIND,X
  295. STA DIND,Y
  296. RTS
  297. ;
  298. .SKIP
  299. OPWRIT
  300. LDA FILDRV
  301. AND #1
  302. STA DRVNUM
  303. JSR OPNWCH
  304. JSR ADDFIL ;ADD TO DIRECTORY
  305. OPFIN
  306. LDA SA
  307. CMP #2
  308. BCS OPF1
  309. ;
  310. JSR GETHDR
  311. LDA TRACK
  312. STA PRGTRK
  313. ;
  314. LDA DRVNUM
  315. STA PRGDRV
  316. ;
  317. LDA SECTOR
  318. STA PRGSEC
  319. OPF1
  320. JMP ENDSAV
  321. .SKIP
  322. CKTM
  323. LDY FILTBL,X ;GET PTR
  324. LDA CMDBUF,Y ;GET CHAR
  325. LDY #NMODES
  326. CKM1
  327. DEY
  328. BMI CKM2 ;NO VALID MODE
  329. ;
  330. CMP MODLST,Y
  331. BNE CKM1
  332. STY MODE ;MODE FOUND
  333. CKM2
  334. LDY #NTYPES
  335. CKT1
  336. DEY
  337. BMI CKT2 ;NO VALID TYPE
  338. ;
  339. CMP TPLST,Y
  340. BNE CKT1
  341. STY TYPE ;TYPE FOUND
  342. CKT2
  343. RTS
  344. ;
  345. APPEND
  346. JSR GCBYTE
  347. LDA #LRF
  348. JSR TSTFLG
  349. BEQ APPEND
  350. ;
  351. JSR RDLNK
  352. LDX SECTOR
  353. INX
  354. TXA
  355. BNE AP30
  356. JSR WRT0 ;GET ANOTHER BLOCK
  357. LDA #2
  358. AP30
  359. JSR SETPNT
  360. LDX LINDX
  361. LDA #RDYLST
  362. STA CHNRDY,X
  363. LDA #$80 ;CHNL BIT
  364. ORA LINDX
  365. LDX SA
  366. STA LINTAB,X
  367. RTS
  368. ;
  369. ;
  370. ; LOAD DIRECTORY
  371. LOADIR
  372. LDA #LDCMD
  373. STA CMDNUM
  374. LDA #0 ;LOAD ONLY DRIVE ZERO
  375. LDX CMDSIZ
  376. DEX
  377. BEQ LD02
  378. .SKIP
  379. LD01 DEX ;LOAD BY NAME
  380. BNE LD03
  381. LDA CMDBUF+1
  382. JSR TST0V1
  383. BMI LD03
  384. .SKIP
  385. LD02 ;LOAD DIR WITH A STAR
  386. STA FILDRV
  387. INC F1CNT
  388. INC F2CNT
  389. INC FILTBL
  390. LDA #$80
  391. STA PATTYP
  392. LDA #'*
  393. STA CMDBUF ;COVER BOTH CASES
  394. STA CMDBUF+1
  395. BNE LD10 ;(BRANCH)
  396. .SKIP
  397. LD03
  398. JSR PRSCLN
  399. BNE LD05 ;FOUND ":"
  400. ;SEARCH BY NAME ON BOTH DRIVES
  401. JSR CMDRST
  402. LDY #3
  403. LD05 DEY
  404. DEY
  405. STY FILTBL
  406. .SKIP
  407. JSR TC35 ;PARSE & SET TABLES
  408. JSR FS1SET
  409. JSR ALLDRS
  410. .SKIP
  411. LD10 JSR OPTSCH ;NEW DIRECTORY
  412. JSR NEWDIR
  413. JSR FFST
  414. LD20 JSR STDIR ;START DIRECTORY
  415. JSR GETBYT ;SET 1ST BYTE
  416. LDX LINDX
  417. STA CHNDAT,X
  418. LDA DRVNUM
  419. STA LSTDRV
  420. ORA #4
  421. STA FILTYP,X
  422. LDA #0
  423. STA BUFTAB+CBPTR
  424. RTS
  425. .SKIP
  426. .END