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 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. .PAGE 'LOOKUP-OPTSCH'
  2. ;OPTSCH OPTIMAL SEARCH FOR LOOKUP
  3. ; AND FNDFIL
  4. .SKIP
  5. OPTSCH LDA #0 ;DETERMINE OPTIMAL SEARCH
  6. STA TEMP ;INIT DRIVE MASK
  7. STA DRVFLG
  8. PHA
  9. LDX F2CNT
  10. OS10 PLA
  11. ORA TEMP
  12. PHA
  13. LDA #1
  14. STA TEMP
  15. DEX
  16. BMI OS30
  17. LDA FILDRV,X
  18. BPL OS15
  19. ASL TEMP
  20. ASL TEMP
  21. .SKIP
  22. OS15 LSR A
  23. BCC OS10
  24. ASL TEMP
  25. BNE OS10 ;(BRANCH)
  26. .SKIP
  27. OS30 PLA
  28. TAX
  29. LDA SCHTBL-1,X
  30. PHA
  31. AND #3
  32. STA DRVCNT
  33. PLA
  34. ASL A
  35. BPL OS40
  36. LDA FILDRV
  37. OS35 AND #1
  38. STA DRVNUM
  39. ;
  40. LDA DRVCNT
  41. BEQ OS60 ;ONLY ONE DRIVE ADDRESSED
  42. ;
  43. JSR AUTOI ;CHECK DRIVE FOR AUTOINIT
  44. BEQ OS50 ;DRIVE IS ACTIVE
  45. ;
  46. JSR TOGDRV
  47. LDA #0 ;SET 1 DRIVE ADDRESSED
  48. STA DRVCNT
  49. JSR AUTOI ;CHECK DRIVE FOR AUTOINIT
  50. BEQ OS70 ;DRIVE IS ACTIVE
  51. OS45
  52. LDA #NODRIV
  53. JSR CMDERR
  54. OS50
  55. JSR TOGDRV
  56. JSR AUTOI ;CHECK DRIVE FOR AUTOINIT
  57. PHP
  58. JSR TOGDRV
  59. PLP
  60. BEQ OS70 ;DRIVE IS ACTIVE
  61. ;
  62. LDA #0 ;SET 1 DRIVE ADDRESSED
  63. STA DRVCNT
  64. BEQ OS70 ;BRA
  65. OS60
  66. JSR AUTOI ;CHECK DRIVE FOR AUTOINIT
  67. BNE OS45 ;DRIVE IS NOT ACTIVE
  68. OS70
  69. JMP SETLDS
  70. .SKIP
  71. OS40 ROL A
  72. JMP OS35
  73. .SKIP
  74. SCHTBL .BYT 0,$80,$41
  75. .BYT 1,1,1,1
  76. .BYT $81,$81,$81,$81
  77. .BYT $42,$42,$42,$42
  78. .PAGE 'LOOKUP/FNDFIL'
  79. ; LOOK UP ALL FILES IN STREAM
  80. ; AND FILL TABLES W/ INFO
  81. .SKIP
  82. LOOKUP JSR OPTSCH
  83. LK05 LDA #0
  84. STA DELIND
  85. JSR SRCHST ;START SEARCH
  86. BNE LK25
  87. LK10 DEC DRVCNT
  88. BPL LK15
  89. RTS ;NO MORE DRIVE SEARCHES
  90. LK15 LDA #1 ;TOGGLE DRIVE #
  91. STA DRVFLG
  92. JSR TOGDRV
  93. JSR SETLDS ; TURN ON LED
  94. JMP LK05
  95. LK20 JSR SEARCH ;FIND VALID FN
  96. BEQ LK30 ;END OF SEARCH
  97. LK25 JSR COMPAR ;COMPARE DIR W/ TABLE
  98. LDA FOUND ;FOUND FLAG
  99. BEQ LK26 ;ALL FN'S NOT FOUND, YET
  100. RTS
  101. .SKIP
  102. LK26 LDA ENTFND
  103. BMI LK20
  104. BPL LK25
  105. .SKIP
  106. LK30 LDA FOUND
  107. BEQ LK10
  108. RTS
  109. .SKIP 2
  110. ; FIND NEXT FILE NAME MATCHING
  111. ; ANY FILE IN STREAM & RETURN
  112. ; WITH ENTRY FOUND STUFFED INTO
  113. ; TABLES
  114. FFRE JSR SRRE ;FIND FILE RE-ENTRY
  115. BEQ FF10
  116. BNE FF25
  117. .SKIP
  118. FF15 LDA #1
  119. STA DRVFLG
  120. JSR TOGDRV
  121. JSR SETLDS
  122. .SKIP
  123. FFST LDA #0 ;FIND FILE START ENTRY
  124. STA DELIND
  125. JSR SRCHST
  126. BNE FF25
  127. STA FOUND
  128. FF10 LDA FOUND
  129. BNE FF40
  130. DEC DRVCNT
  131. BPL FF15
  132. RTS
  133. .SKIP
  134. FNDFIL JSR SEARCH ;FIND FILE CONTINUOUS...
  135. BEQ FF10 ;... RE-ENTRY, NO CHANNEL ACTIVITY
  136. FF25 JSR COMPAR ;COMPARE FILE NAMES
  137. LDX ENTFND
  138. BPL FF30
  139. LDA FOUND
  140. BEQ FNDFIL
  141. BNE FF40
  142. .SKIP
  143. FF30 LDA TYPFLG
  144. BEQ FF40 ;NO TYPE RESTRICTION
  145. LDA PATTYP,X
  146. AND #TYPMSK
  147. CMP TYPFLG
  148. BNE FNDFIL
  149. FF40 RTS
  150. .PAGE 'LOOKUP-COMPAR'
  151. ;COMPARE ALL FILENAMES IN STREAM TABLE
  152. ; WITH EACH VALID ENTRY IN THE
  153. ; DIRECTORY. MATCHES ARE TABULATED
  154. .SKIP
  155. COMPAR LDX #$FF
  156. STX ENTFND
  157. INX
  158. STX PATFLG
  159. JSR CMPCHK
  160. BEQ CP10
  161. CP02 RTS ;ALL ARE FOUND
  162. .SKIP
  163. CP05 JSR CC10
  164. BNE CP02
  165. CP10 LDA DRVNUM
  166. EOR FILDRV,X
  167. LSR A
  168. BCC CP20 ;RIGHT DRIVE
  169. AND #$40
  170. BEQ CP05 ;NO DEFAULT
  171. LDA #2
  172. CMP DRVCNT
  173. BEQ CP05 ;DON'T USE DEFAULT
  174. .SKIP
  175. CP20 LDA FILTBL,X ;GOOD DRIVE MATCH
  176. TAX
  177. JSR FNDLMT
  178. LDY #3
  179. JMP CP33
  180. CP30
  181. LDA CMDBUF,X
  182. CMP (DIRBUF)Y
  183. BEQ CP32 ;CHARS ARE =
  184. ;
  185. CMP #'?
  186. BNE CP05 ;NO SINGLE PATTERN
  187. LDA (DIRBUF)Y
  188. CMP #$A0
  189. BEQ CP05 ;END OF FILENAME
  190. CP32
  191. INX
  192. INY
  193. CP33
  194. CPX LIMIT
  195. BCS CP34 ;END OF PATTERN
  196. ;
  197. LDA CMDBUF,X
  198. CMP #'*
  199. BEQ CP40 ;STAR MATCHES ALL
  200. BNE CP30 ;KEEP CHECKING
  201. CP34
  202. CPY #19
  203. BCS CP40 ;END OF FILENAME
  204. ;
  205. LDA (DIRBUF)Y
  206. CMP #$A0
  207. BNE CP05
  208. .SKIP
  209. CP40 LDX F2PTR ;FILENAMES MATCH
  210. STX ENTFND
  211. LDA PATTYP,X ;STORE INFO IN TABLES
  212. AND #$80
  213. STA PATFLG
  214. LDA INDEX
  215. STA ENTIND,X
  216. LDA SECTOR
  217. STA ENTSEC,X
  218. LDY #0
  219. LDA (DIRBUF),Y
  220. INY
  221. PHA
  222. AND #$40
  223. STA TEMP
  224. PLA
  225. AND #$FF-$20
  226. BMI CP42
  227. ;
  228. ORA #$20
  229. CP42
  230. AND #$27
  231. ORA TEMP
  232. STA TEMP
  233. LDA #$80
  234. AND PATTYP,X
  235. ORA TEMP
  236. STA PATTYP,X
  237. LDA FILDRV,X
  238. AND #$80
  239. ORA DRVNUM
  240. STA FILDRV,X
  241. ;
  242. LDA (DIRBUF),Y
  243. STA FILTRK,X
  244. INY
  245. LDA (DIRBUF),Y
  246. STA FILSEC,X
  247. LDA REC
  248. BNE CP50
  249. LDY #21
  250. LDA (DIRBUF)Y
  251. STA REC
  252. CP50
  253. ;JMP CMPCHK
  254. ;RTS
  255. .SKIP
  256. ;CHECK TABLE FOR UNFOUND FILES
  257. .SKIP
  258. CMPCHK LDA #$FF
  259. STA FOUND
  260. LDA F2CNT
  261. STA F2PTR
  262. .SKIP
  263. CC10 DEC F2PTR
  264. BPL CC15
  265. RTS ;TABLE EXHAUSTED
  266. .SKIP
  267. CC15 LDX F2PTR
  268. LDA PATTYP,X
  269. BMI CC20
  270. LDA FILTRK,X
  271. BNE CC10
  272. CC20 LDA #0
  273. STA FOUND
  274. RTS
  275. .PAGE 'LOOKUP-SEARCH'
  276. ;SEARCH DIRECTORY
  277. ; RETURNS WITH VALID ENTRY W/ DELIND=0
  278. ; OR RETURNS W/ 1ST DELETED ENTRY
  279. ; W/ DELIND=1
  280. ;
  281. ; SRCHST WILL INITIATE A SEARCH
  282. ; SEARCH WILL CONTINUE A SEARCH
  283. .SKIP
  284. SRCHST
  285. LDY #0 ;INIT DELETED SECTOR
  286. STY DELSEC
  287. DEY
  288. STY ENTFND
  289. .SKIP
  290. LDA DIRTRK ;START SEARCH AT BEGINNING
  291. STA TRACK
  292. LDA #1
  293. STA SECTOR
  294. STA LSTBUF
  295. JSR OPNIRD ;OPEN INTERNAL READ CHNL
  296. .SKIP
  297. SR10 LDA LSTBUF ;LAST BUFFER IF 0
  298. BNE SR15
  299. RTS ;(Z=1)
  300. .SKIP
  301. SR15 LDA #7
  302. STA FILCNT
  303. LDA #0 ;READ TRACK #
  304. JSR DRDBYT
  305. STA LSTBUF ;UPDATE END FLAG
  306. .SKIP
  307. SR20 JSR GETPNT
  308. DEC FILCNT
  309. LDY #0
  310. LDA (DIRBUF),Y ;READ FILE TYPE
  311. BNE SR30
  312. .SKIP
  313. LDA DELSEC ;DELETED ENTRY FOUND
  314. BNE SEARCH ;DELETED ENTRY ALREADY FOUND
  315. JSR CURBLK ;GET CURRENT SECTOR
  316. LDA SECTOR
  317. STA DELSEC
  318. .SKIP
  319. LDA DIRBUF ;GET CURRENT INDEX
  320. LDX DELIND ;BIT1: WANT DELETED ENTRY
  321. STA DELIND
  322. BEQ SEARCH ;NEED VALID ENTRY
  323. RTS ;(Z=0)
  324. .SKIP
  325. SR30 LDX #1
  326. CPX DELIND ;?LOOKING FOR DELETED?
  327. BNE SR50 ; NO!
  328. BEQ SEARCH
  329. .SKIP
  330. SRRE LDA DIRTRK
  331. STA TRACK
  332. LDA DIRSEC
  333. STA SECTOR
  334. JSR OPNIRD
  335. LDA INDEX
  336. JSR SETPNT
  337. .SKIP
  338. SEARCH LDA #$FF
  339. STA ENTFND
  340. LDA FILCNT ;ADJUST FILE COUNT
  341. BMI SR40
  342. LDA #32 ;INCR BY 32
  343. JSR INCPTR
  344. JMP SR20
  345. .SKIP
  346. SR40 JSR NXTBUF ;NEW BUFFER
  347. JMP SR10 ;(BRANCH)
  348. .SKIP
  349. SR50 LDA DIRBUF ;FOUND VALID ENTRY
  350. STA INDEX ;SAVE INDEX
  351. JSR CURBLK ;GET SECTOR
  352. LDA SECTOR
  353. STA DIRSEC
  354. .SKIP
  355. RTS ;(Z=0)
  356. AUTOI
  357. ; CHECK DRIVE FOR ACTIVE DISKETTE
  358. ; INIT IF NEEDED
  359. ; RETURN NODRV STATUS
  360. ;
  361. LDA AUTOFG
  362. BNE AUTO2 ;AUTO-INIT IS DISABLED
  363. ;
  364. LDX DRVNUM
  365. LSR WPSW,X ;TEST & CLEAR WPSW
  366. BCC AUTO2 ;NO CHANGE IN DISKETTE
  367. ;
  368. LDA #$FF
  369. STA JOBRTN ;SET ERROR RETURN CODE
  370. JSR ITRIAL ;INIT-SEEK TEST
  371. LDY #$FF ; .Y= TRUE
  372. CMP #2
  373. BEQ AUTO1 ;NO SYNC= NO DISKETTE
  374. ;
  375. CMP #3
  376. BEQ AUTO1 ;NO HEADER= NO DIRECTORY
  377. ;
  378. CMP #$F
  379. BEQ AUTO1 ;NO DRIVE!!!!
  380. ;
  381. LDY #0 ;SET .Y FALSE
  382. AUTO1
  383. LDX DRVNUM
  384. TYA
  385. STA NODRV,X ;SET CONDN OF NO-DRIVE
  386. BNE AUTO2 ;NO NEED TO INIT CRUD!
  387. ;
  388. JSR INITDR ;INIT THAT DRIVE
  389. AUTO2
  390. LDX DRVNUM
  391. LDA NODRV,X ;RETURN NO-DRIVE CONDN
  392. RTS
  393. .SKIP
  394. .END