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.src 10KB

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. open
  9. lda sa
  10. sta tempsa
  11. jsr cmdset ; initiate cmd ptrs
  12. stx cmdnum
  13. ldx cmdbuf
  14. lda tempsa
  15. bne op021
  16. cpx #'* ; load last?
  17. bne op021
  18. lda prgtrk
  19. beq op0415 ; no last prog, init 0
  20. op02 ; load last program
  21. sta track
  22. lda prgdrv
  23. sta drvnum
  24. sta fildrv
  25. lda #prgtyp
  26. sta pattyp
  27. lda prgsec
  28. sta sector
  29. jsr setlds ; make sure led gets turned on!!
  30. jsr opnrch
  31. lda #prgtyp+prgtyp
  32. ora drvnum
  33. endrd ldx lindx
  34. sta filtyp,y
  35. jmp endcmd
  36. op021 cpx #'$
  37. bne op041
  38. lda tempsa ; load directory
  39. bne op04
  40. jmp loadir
  41. op04 jsr simprs ; open dir as seq file
  42. lda dirtrk
  43. sta track
  44. lda #0
  45. sta sector
  46. jsr opnrch
  47. lda drvnum
  48. ora #seqtyp+seqtyp
  49. jmp endrd
  50. op041 cpx #'# ; "#" is direct access
  51. bne op042
  52. jmp opnblk
  53. op0415 lda #prgtyp ; program type
  54. sta typflg
  55. lda #0
  56. sta drvnum
  57. sta lstdrv
  58. jsr initdr
  59. op042
  60. jsr prscln ; look for ":"
  61. bne op049
  62. ldx #0
  63. beq op20 ; bra
  64. op049
  65. txa
  66. beq op10
  67. op05 lda #badsyn ; something amiss
  68. jmp cmderr
  69. op10 dey ; back up to ":"
  70. beq op20 ; 1st char is ":"
  71. dey
  72. op20 sty filtbl ; save filename ptr
  73. lda #$8d ; look for cr-shifted
  74. jsr parse
  75. inx
  76. stx f2cnt
  77. jsr onedrv
  78. jsr optsch
  79. jsr ffst ; look for file entry
  80. ldx #0
  81. stx rec
  82. stx mode ; read mode
  83. stx type ; deleted
  84. inx
  85. cpx f1cnt
  86. bcs op40 ; no parameters
  87. ;
  88. jsr cktm ; check for type & mode
  89. inx
  90. cpx f1cnt
  91. bcs op40 ; only one parameter
  92. ;
  93. cpy #reltyp
  94. beq op60 ; set record size
  95. ;
  96. jsr cktm ; set type/mode
  97. op40
  98. ldx tempsa
  99. stx sa ; set sa back
  100. cpx #2
  101. bcs op45 ; not load or save
  102. ;
  103. stx mode ; mode=sa
  104. lda #$40
  105. sta wbam
  106. lda type
  107. bne op50 ; type from parm
  108. ;
  109. lda #prgtyp
  110. sta type ; use prg
  111. op45
  112. lda type
  113. bne op50 ; type from parm
  114. ;
  115. lda pattyp
  116. and #typmsk
  117. sta type ; type from file
  118. ;
  119. lda filtrk
  120. bne op50 ; yes, it exists
  121. ;
  122. lda #seqtyp
  123. sta type ; default is seq
  124. op50
  125. lda mode
  126. cmp #wtmode
  127. beq op75 ; go write
  128. ;
  129. jmp op90
  130. ;
  131. op60
  132. ldy filtbl,x ; get record size
  133. lda cmdbuf,y
  134. sta rec
  135. lda filtrk
  136. bne op40 ; it's here, read
  137. ;
  138. lda #wtmode ; use write to open
  139. sta mode
  140. bne op40 ; (bra)
  141. ;
  142. op75
  143. lda pattyp
  144. and #$80
  145. tax
  146. bne op81
  147. op77 lda #$20 ; open write
  148. bit pattyp
  149. beq op80
  150. jsr deldir ; created
  151. jmp opwrit
  152. op80 lda filtrk
  153. bne op81
  154. jmp opwrit ; not found, ok!
  155. op81 lda cmdbuf
  156. cmp #'@ ; check for replace
  157. beq op82
  158. txa
  159. bne op815
  160. lda #flexst
  161. jmp cmderr
  162. op815
  163. lda #badfn
  164. jmp cmderr
  165. ;********* check for bug here******
  166. op82
  167. lda pattyp ; replace
  168. and #typmsk
  169. cmp type
  170. bne op115
  171. cmp #reltyp
  172. beq op115
  173. ;
  174. jsr opnwch
  175. lda lindx
  176. sta wlindx
  177. lda #irsa ; internal chan
  178. sta sa
  179. jsr fndrch
  180. lda index
  181. jsr setpnt
  182. ldy #0
  183. lda (dirbuf),y
  184. ora #$20 ; set replace bit
  185. sta (dirbuf),y
  186. ;
  187. ldy #26
  188. lda track
  189. sta (dirbuf),y
  190. iny
  191. lda sector
  192. sta (dirbuf),y
  193. ldx wlindx
  194. lda entsec
  195. sta dsec,x
  196. lda entind
  197. sta dind,x
  198. jsr curblk
  199. jsr drtwrt
  200. jmp opfin
  201. ;**********************************
  202. ;
  203. op90 lda filtrk ; open read (& load)
  204. bne op100
  205. op95
  206. lda #flntfd ; track not recorded
  207. jmp cmderr ; not found
  208. op100
  209. lda mode
  210. cmp #mdmode
  211. beq op110
  212. lda #$20
  213. bit pattyp
  214. beq op110
  215. lda #filopn
  216. jmp cmderr
  217. op110 lda pattyp
  218. and #typmsk ; type is in index table
  219. cmp type
  220. beq op120
  221. op115 lda #mistyp ; type mismatch
  222. jmp cmderr
  223. op120 ; everything is ok!
  224. ldy #0
  225. sty f2ptr
  226. ldx mode
  227. cpx #apmode
  228. bne op125
  229. cmp #reltyp
  230. beq op115
  231. ;
  232. lda (dirbuf),y
  233. and #$4f
  234. sta (dirbuf),y
  235. lda sa
  236. pha
  237. lda #irsa
  238. sta sa
  239. jsr curblk
  240. jsr drtwrt
  241. pla
  242. sta sa
  243. op125
  244. jsr opread
  245. lda mode
  246. cmp #apmode
  247. bne opfin
  248. ;
  249. jsr append
  250. jmp endcmd
  251. ;
  252. ;**********************
  253. opread
  254. ldy #19
  255. lda (dirbuf),y
  256. sta trkss
  257. iny
  258. lda (dirbuf),y
  259. sta secss
  260. iny
  261. lda (dirbuf),y
  262. ldx rec
  263. sta rec
  264. txa
  265. beq op130
  266. cmp rec
  267. beq op130
  268. lda #norec
  269. jsr cmderr
  270. op130
  271. ldx f2ptr
  272. lda filtrk,x
  273. sta track
  274. lda filsec,x
  275. sta sector
  276. jsr opnrch
  277. ldy lindx ; open a read chnl
  278. ldx f2ptr
  279. lda entsec,x
  280. sta dsec,y
  281. lda entind,x
  282. sta dind,y
  283. rts
  284. ;
  285. opwrit
  286. lda fildrv
  287. and #1
  288. sta drvnum
  289. jsr opnwch
  290. jsr addfil ; add to directory
  291. opfin
  292. lda sa
  293. cmp #2
  294. bcs opf1
  295. ;
  296. jsr gethdr
  297. lda track
  298. sta prgtrk
  299. ;
  300. lda drvnum
  301. sta prgdrv
  302. ;
  303. lda sector
  304. sta prgsec
  305. opf1
  306. jmp endsav
  307. cktm
  308. ldy filtbl,x ; get ptr
  309. lda cmdbuf,y ; get char
  310. ldy #nmodes
  311. ckm1
  312. dey
  313. bmi ckm2 ; no valid mode
  314. ;
  315. cmp modlst,y
  316. bne ckm1
  317. sty mode ; mode found
  318. ckm2
  319. ldy #ntypes
  320. ckt1
  321. dey
  322. bmi ckt2 ; no valid type
  323. ;
  324. cmp tplst,y
  325. bne ckt1
  326. sty type ; type found
  327. ckt2
  328. rts
  329. ;
  330. append
  331. jsr gcbyte
  332. lda #lrf
  333. jsr tstflg
  334. beq append
  335. ;
  336. jsr rdlnk
  337. ldx sector
  338. inx
  339. txa
  340. bne ap30
  341. jsr wrt0 ; get another block
  342. lda #2
  343. ap30
  344. jsr setpnt
  345. ldx lindx
  346. lda #rdylst
  347. sta chnrdy,x
  348. lda #$80 ; chnl bit
  349. ora lindx
  350. ldx sa
  351. sta lintab,x
  352. rts
  353. ;
  354. ;
  355. ; load directory
  356. loadir
  357. lda #ldcmd
  358. sta cmdnum
  359. lda #0 ; load only drive zero
  360. ldx cmdsiz
  361. dex
  362. beq ld02
  363. ld01 dex ; load by name
  364. bne ld03
  365. lda cmdbuf+1
  366. jsr tst0v1
  367. bmi ld03
  368. ld02 ; load dir with a star
  369. sta fildrv
  370. inc f1cnt
  371. inc f2cnt
  372. inc filtbl
  373. lda #$80
  374. sta pattyp
  375. lda #'*
  376. sta cmdbuf ; cover both cases
  377. sta cmdbuf+1
  378. bne ld10 ; (branch)
  379. ld03
  380. jsr prscln
  381. bne ld05 ; found ":"
  382. ;search by name on both drives
  383. jsr cmdrst
  384. ldy #3
  385. ld05 dey
  386. dey
  387. sty filtbl
  388. jsr tc35 ; parse & set tables
  389. jsr fs1set
  390. jsr alldrs
  391. ld10 jsr optsch ; new directory
  392. jsr newdir
  393. jsr ffst
  394. ld20 jsr stdir ; start directory
  395. jsr getbyt ; set 1st byte
  396. ldx lindx
  397. sta chndat,x
  398. lda drvnum
  399. sta lstdrv
  400. ora #4
  401. sta filtyp,x
  402. lda #0
  403. sta buftab+cbptr
  404. rts
  405. ;.end