Customized Catalog Command for LKDos

See all articles from Update April 1989
Author(s): Larry Kenny
Publication: Update Magazine
Pub Details: Update April 1989
Date: April 1989
Pages: 32-33

This is an alternative Catalog command that can be added to your programs or to use when modifying an existing program for disk. It only prints the selected filenames in a single column without any other info such as disk name of disk parameters. It works very well with windows such as the ones in LKdos or in a program like Art Studio that uses pulldown menus.

This machine code routine is relocatable and is 120 bytes long. You can use an assembler to enter the assembly language source code on the next page or just enter the decimal values into memory at almost any address (40000 is ok) then save the code.

It will also fit into the printer buffer at address 23300. The syntax for the command is the same as the Cat command in the dos and it supports selected searches and wild card character ‘^’ the same as the dos on eprom. When using the new command, the USR call is to the address where you loaded the code.

EG: RAND USR 40000: CAT “”, (or CAT”.C”, etc)

Further Customizing – You can change the first command from LD A,2 to any channel number eg: LD A,3 will send it to printer or LD A,5 can be used for a window attached to chanel 5 Also you can modify the width of the cat listing by changing the return added on line 770 of the assembly listing to printing a few spaces instead which will let you print up to 3 file names per line. If you want to run entirely from machine code then remove the lines 210 to 260 and transfer your search string directly to prognm terminated by a ‘”‘.

The Basic program below is a demo to show the Cat command being used with Windows. If you are using a version 2 eprom be sure to load a narrow character set for the windows.

  5 REM -- WINDOW CATALOG DEMO --
10 RANDOMIZE USR 100: OPEN #4,"dd"
20 PRINT #4: CLOSE #2
25 CLS : PRINT INVERSE 1;"BASIC FILES","CODE FILES"
30 IF INKEY$="b" THEN GO TO 100
40 IF INKEY$="c" THEN GO TO 200
50 GO TO 30
100 PRINT #4: OPEN #2,"w0"
120 PRINT #4: INPUT #0,1,0,20,20
130 RANDOMIZE USR 40000: CAT ".B",
150 PAUSE 0: GO TO 20
200 PRINT #4: OPEN #2,"w0"
230 PRINT #4: INPUT #0,1,16,30,20
240 RANDOMIZE USR 40000: CAT ".C",
250 PAUSE 0: GO TO 20

Decimal Dump of Custom Catalog

62   2    205  48   18   243  205  98   0    175
50 29 32 205 126 0 205 123 0 231
205 156 0 235 121 254 0 32 3 33
34 32 54 34 205 141 0 33 136 32
35 126 254 250 202 186 0 254 255 32
245 35 126 254 254 40 239 34 176 92
6 9 17 34 32 26 254 34 40 31
254 94 40 8 190 40 8 35 16 241
24 214 19 24 236 26 254 94 40 7
254 34 40 7 190 32 199 19 35 24
240 42 176 92 6 9 126 35 229 197
215 193 225 16 247 62 13 215 24 176

Customized Catalog Command

00010 ORG  40000               - Can be anywhere
00020 wrkspc EQU 8220 - Work area in cartridge
00040 data EQU wrkspc +108 - Address of data block in Lkdos
00050 curtrk EQU wrkspc +1 - Holds the current block number
00060 prognm EQU wrkspc +6 - Buffer in Lkdos for String$
00070 LOADBF EQU 123 - Dos call to load disk to buffer
00080 TRACK EQU 126 - Move drive head to (curtrk)
00090 ENDLN EQU 141 - Move CHAD to end of Basic line
00100 GTFIL EQU 156 - Get file name or string from command
00110 JPOUT EQU 186 - Exit the cartridge
00120 ;-------------------------
00130 CAT LD A,2 - Open channel 2 (or any channel)
00140 CALL #1230
00150 DI
00160 CALL 98 - Turn on cartridge
00170 XOR A
00180 LD (curtrk),A
00190 CALL TRACK - Move head to Track 0 side 0
00200 CALL LOADBF - Load disk Catalog to buffer
00210 RST 32
00220 CALL GTFIL - Evaluate String$ in Cat command
00230 EX DE,HL - and place result at prognm
00240 LD A,C
00250 CP 0 - If length of string = 0 then
00260 JR NZ,QUOTE
00270 LD HL,prognm - put end quote right at start
00280 QUOTE LD (HL),34 - of the string buffer
00290 CALL ENDLN - move Basic pointer to next command
00300 LD HL,data - set HL to start of Catalog
00310 FNDNAM INC HL - Look for start of next name cell
00320 LD A,(HL)
00330 CP 250 - If 250 then end of Catalog
00340 JP Z,JPOUT - and exit cartridge
00350 CP 255 - 255 means the start of a name cell
00360 JR NZ,FNDNAM
00370 INC HL
00380 LD A,(HL)
00390 CP 254 - 254 means Cell not used or deleted
00400 JR Z,FNDNAM
00410 LD (23728),HL - Store the start adress of the Cell
00420 LD B,9 - Lenght of file name
00430 LD DE,prognm - Point to search string$
00440 First LD A,(DE) - Find first char of search string
00450 CP 34 - end of search string ?
00460 JR Z,Print - If so then print it .
00470 CP 94 - Is Wild card first character ?
00480 JR Z,Wild1
00490 CP (HL)
00500 JR Z,Match - Start of searh string found ?
00510 INC HL
00520 DJNZ First
00530 JR FNDNAM
00540 Wild1 INC DE - Move past the wild card character
00550 JR First
00560 Match LD A,(DE) - Check if entire string matches
00570 CP 94
00580 JR Z,Wildc - If Wild card then dont check it
00600 CP 34
00610 JR Z,Print
00620 CP (HL) - If string doesnt match then
00630 JR NZ,FNDNAM - go and find next name cell
00640 Wildc INC DE
00650 INC HL
00660 JR Match - Check next character
00670 Print LD HL,(23728) - Print the file name
00680 LD B,9 - print 9 characters
00690 Pnext LD A,(HL)
00700 INC HL
00710 PUSH HL
00720 PUSH BC
00730 RST 16 - send to current channel
00740 POP BC
00750 POP HL
00760 DJNZ Pnext
00770 LD A,13 - Print carridge return
00780 RST 16
00790 JR FNDNAM

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.