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.

lookup.src 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. .page 'lookup-optsch'
  2. ;optsch optimal search for lookup
  3. ; and fndfil
  4. optsch lda #0 ; determine optimal search
  5. sta temp ; init drive mask
  6. sta drvflg
  7. pha
  8. ldx f2cnt
  9. os10 pla
  10. ora temp
  11. pha
  12. lda #1
  13. sta temp
  14. dex
  15. bmi os30
  16. lda fildrv,x
  17. bpl os15
  18. asl temp
  19. asl temp
  20. os15 lsr a
  21. bcc os10
  22. asl temp
  23. bne os10 ; (branch)
  24. os30 pla
  25. tax
  26. lda schtbl-1,x
  27. pha
  28. and #3
  29. sta drvcnt
  30. pla
  31. asl a
  32. bpl os40
  33. lda fildrv
  34. os35 and #1
  35. sta drvnum
  36. ;
  37. lda drvcnt
  38. beq os60 ; only one drive addressed
  39. ;
  40. jsr autoi ; check drive for autoinit
  41. beq os50 ; drive is active
  42. ;
  43. jsr togdrv
  44. lda #0 ; set 1 drive addressed
  45. sta drvcnt
  46. jsr autoi ; check drive for autoinit
  47. beq os70 ; drive is active
  48. os45
  49. lda #nodriv
  50. jsr cmderr
  51. os50
  52. jsr togdrv
  53. jsr autoi ; check drive for autoinit
  54. php
  55. jsr togdrv
  56. plp
  57. beq os70 ; drive is active
  58. ;
  59. lda #0 ; set 1 drive addressed
  60. sta drvcnt
  61. beq os70 ; bra
  62. os60
  63. jsr autoi ; check drive for autoinit
  64. bne os45 ; drive is not active
  65. os70
  66. jmp setlds
  67. os40 rol a
  68. jmp os35
  69. schtbl .byte 0,$80,$41
  70. .byte 1,1,1,1
  71. .byte $81,$81,$81,$81
  72. .byte $42,$42,$42,$42
  73. .page 'lookup/fndfil'
  74. ; look up all files in stream
  75. ; and fill tables w/ info
  76. lookup jsr optsch
  77. lk05 lda #0
  78. sta delind
  79. jsr srchst ; start search
  80. bne lk25
  81. lk10 dec drvcnt
  82. bpl lk15
  83. rts ; no more drive searches
  84. lk15 lda #1 ; toggle drive #
  85. sta drvflg
  86. jsr togdrv
  87. jsr setlds ; turn on led
  88. jmp lk05
  89. lk20 jsr search ; find valid fn
  90. beq lk30 ; end of search
  91. lk25 jsr compar ; compare dir w/ table
  92. lda found ; found flag
  93. beq lk26 ; all fn's not found, yet
  94. rts
  95. lk26 lda entfnd
  96. bmi lk20
  97. bpl lk25
  98. lk30 lda found
  99. beq lk10
  100. rts
  101. ; find next file name matching
  102. ; any file in stream & return
  103. ; with entry found stuffed into
  104. ; tables
  105. ffre jsr srre ; find file re-entry
  106. beq ff10
  107. bne ff25
  108. ff15 lda #1
  109. sta drvflg
  110. jsr togdrv
  111. jsr setlds
  112. ffst lda #0 ; find file start entry
  113. sta delind
  114. jsr srchst
  115. bne ff25
  116. sta found
  117. ff10 lda found
  118. bne ff40
  119. dec drvcnt
  120. bpl ff15
  121. rts
  122. fndfil jsr search ; find file continuous...
  123. beq ff10 ; ... re-entry, no channel activity
  124. ff25 jsr compar ; compare file names
  125. ldx entfnd
  126. bpl ff30
  127. lda found
  128. beq fndfil
  129. bne ff40
  130. ff30 lda typflg
  131. beq ff40 ; no type restriction
  132. lda pattyp,x
  133. and #typmsk
  134. cmp typflg
  135. bne fndfil
  136. ff40 rts
  137. .page 'lookup-compar'
  138. ;compare all filenames in stream table
  139. ; with each valid entry in the
  140. ; directory. matches are tabulated
  141. compar ldx #$ff
  142. stx entfnd
  143. inx
  144. stx patflg
  145. jsr cmpchk
  146. beq cp10
  147. cp02 rts ; all are found
  148. cp05 jsr cc10
  149. bne cp02
  150. cp10 lda drvnum
  151. eor fildrv,x
  152. lsr a
  153. bcc cp20 ; right drive
  154. and #$40
  155. beq cp05 ; no default
  156. lda #2
  157. cmp drvcnt
  158. beq cp05 ; don't use default
  159. cp20 lda filtbl,x ; good drive match
  160. tax
  161. jsr fndlmt
  162. ldy #3
  163. jmp cp33
  164. cp30
  165. lda cmdbuf,x
  166. cmp (dirbuf),y
  167. beq cp32 ; chars are =
  168. ;
  169. cmp #'?
  170. bne cp05 ; no single pattern
  171. lda (dirbuf),y
  172. cmp #$a0
  173. beq cp05 ; end of filename
  174. cp32
  175. inx
  176. iny
  177. cp33
  178. cpx limit
  179. bcs cp34 ; end of pattern
  180. ;
  181. lda cmdbuf,x
  182. cmp #'*
  183. beq cp40 ; star matches all
  184. bne cp30 ; keep checking
  185. cp34
  186. cpy #19
  187. bcs cp40 ; end of filename
  188. ;
  189. lda (dirbuf),y
  190. cmp #$a0
  191. bne cp05
  192. cp40 ldx f2ptr ; filenames match
  193. stx entfnd
  194. lda pattyp,x ; store info in tables
  195. and #$80
  196. sta patflg
  197. lda index
  198. sta entind,x
  199. lda sector
  200. sta entsec,x
  201. ldy #0
  202. lda (dirbuf),y
  203. iny
  204. pha
  205. and #$40
  206. sta temp
  207. pla
  208. and #$ff-$20
  209. bmi cp42
  210. ;
  211. ora #$20
  212. cp42
  213. and #$27
  214. ora temp
  215. sta temp
  216. lda #$80
  217. and pattyp,x
  218. ora temp
  219. sta pattyp,x
  220. lda fildrv,x
  221. and #$80
  222. ora drvnum
  223. sta fildrv,x
  224. ;
  225. lda (dirbuf),y
  226. sta filtrk,x
  227. iny
  228. lda (dirbuf),y
  229. sta filsec,x
  230. lda rec
  231. bne cp50
  232. ldy #21
  233. lda (dirbuf),y
  234. sta rec
  235. cp50
  236. ;jmp cmpchk
  237. ;rts
  238. ;check table for unfound files
  239. cmpchk lda #$ff
  240. sta found
  241. lda f2cnt
  242. sta f2ptr
  243. cc10 dec f2ptr
  244. bpl cc15
  245. rts ; table exhausted
  246. cc15 ldx f2ptr
  247. lda pattyp,x
  248. bmi cc20
  249. lda filtrk,x
  250. bne cc10
  251. cc20 lda #0
  252. sta found
  253. rts
  254. .page 'lookup-search'
  255. ;search directory
  256. ; returns with valid entry w/ delind=0
  257. ; or returns w/ 1st deleted entry
  258. ; w/ delind=1
  259. ;
  260. ; srchst will initiate a search
  261. ; search will continue a search
  262. srchst
  263. ldy #0 ; init deleted sector
  264. sty delsec
  265. dey
  266. sty entfnd
  267. lda dirtrk ; start search at beginning
  268. sta track
  269. lda #1
  270. sta sector
  271. sta lstbuf
  272. jsr opnird ; open internal read chnl
  273. sr10 lda lstbuf ; last buffer if 0
  274. bne sr15
  275. rts ; (z=1)
  276. sr15 lda #7
  277. sta filcnt
  278. lda #0 ; read track #
  279. jsr drdbyt
  280. sta lstbuf ; update end flag
  281. sr20 jsr getpnt
  282. dec filcnt
  283. ldy #0
  284. lda (dirbuf),y ; read file type
  285. bne sr30
  286. lda delsec ; deleted entry found
  287. bne search ; deleted entry already found
  288. jsr curblk ; get current sector
  289. lda sector
  290. sta delsec
  291. lda dirbuf ; get current index
  292. ldx delind ; bit1: want deleted entry
  293. sta delind
  294. beq search ; need valid entry
  295. rts ; (z=0)
  296. sr30 ldx #1
  297. cpx delind ; ?looking for deleted?
  298. bne sr50 ; no!
  299. beq search
  300. srre lda dirtrk
  301. sta track
  302. lda dirsec
  303. sta sector
  304. jsr opnird
  305. lda index
  306. jsr setpnt
  307. search lda #$ff
  308. sta entfnd
  309. lda filcnt ; adjust file count
  310. bmi sr40
  311. lda #32 ; incr by 32
  312. jsr incptr
  313. jmp sr20
  314. sr40 jsr nxtbuf ; new buffer
  315. jmp sr10 ; (branch)
  316. sr50 lda dirbuf ; found valid entry
  317. sta index ; save index
  318. jsr curblk ; get sector
  319. lda sector
  320. sta dirsec
  321. rts ; (z=0)
  322. autoi
  323. ; check drive for active diskette
  324. ; init if needed
  325. ; return nodrv status
  326. ;
  327. lda autofg
  328. bne auto2 ; auto-init is disabled
  329. ;
  330. ldx drvnum
  331. lsr wpsw,x ; test & clear wpsw
  332. bcc auto2 ; no change in diskette
  333. ;
  334. lda #$ff
  335. sta jobrtn ; set error return code
  336. jsr itrial ; init-seek test
  337. ldy #$ff ; .y= true
  338. cmp #2
  339. beq auto1 ; no sync= no diskette
  340. ;
  341. cmp #3
  342. beq auto1 ; no header= no directory
  343. ;
  344. cmp #$f
  345. beq auto1 ; no drive!!!!
  346. ;
  347. ldy #0 ; set .y false
  348. auto1
  349. ldx drvnum
  350. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  351. jmp ptch20 ; *rom ds 09/03/85* *GCB 11/20/86 SAVE @ fix*
  352. ; tya
  353. ; sta nodrv,x ; set condn of no-drive
  354. rtch20
  355. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  356. bne auto2 ; no need to init crud!
  357. ;
  358. jsr initdr ; init that drive
  359. auto2
  360. ldx drvnum
  361. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  362. jmp ptch17 ; *rom ds 09/03/85* *GCB 11/20/86 SAVE @ fix*
  363. ; lda nodrv,x ; return no-drive condn
  364. ; rts
  365. ;<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  366. ; .end