title Content of .IRL file name ('DIRIRL') maclib base80 ; This utility simply displays the content of an indexed REL-80 ; library file. ; Call it: ; ; DIRIRL {-opt} file{.ext} ; ; The file type defaults to .IRL. ; Option may be -L for short or -V for verbose listing. Option ; defaults to -L. ; ; Copyright (C) Werner Cirsovius ; Hohe Weide 44 ; D-20253 Hamburg ; Phone: +49/40/4223247 ext cmdarg,wcard,open,parse,dskget,dskred ext strcn0,crlf,conchd,combrk,@leng _eol equ 0feh CPM3 equ 30h _maxarg equ 2 dseg $ILL.CPU: db 'Requires Z80 CPU',eot $ILL.OS: db 'Requires CP/M 3.x or higher',eot $HELP: db 'This utility simply displays the content of ' db 'an indexed REL-80 library file.',cr,lf,lf db 'Call it:',cr,lf,lf db tab,'DIRIRL {-opt} file{.ext}',cr,lf,lf db 'The file type defaults to .IRL.',cr,lf db 'Option may be -L for short or -V for verbose ' db 'listing. Option defaults to -L.' db eot $ILL.OPT: db 'Invalid option, try -L or -V',eot $ILL.FILE: db 'Invalid file name',eot $ILL.WILD: db 'Wildcard not allowed in file name',eot $NO.FILE: db 'Cannot find library file',eot $IRL: db 'IRL' ParsPB: dw 0,FCB ARGV: ds 2*_maxarg Opt: db 'L' @E_R_B: db 0,0,0 e_r_b equ $-@E_R_B $NAME: ds 8+1 nam.len equ $-$NAME $E_R_B: db ' - Extent offset ' $E: db 'xx, Record offset ' $R: db 'xx, Byte offset ' $B: db 'xx',null cseg ; ; Tell position of item found ; Verbose: ld hl,$NAME call @leng ; Get length of name ld a,nam.len sub b ; .. get gap ld b,a ld e,' ' call conchd ; .. print blanks ld ix,@E_R_B ; Init field ld de,$E call StX ; .. store hex ld de,$R call StX ld de,$B call StX ld de,$E_R_B call strcn0 ; .. give position ret ; ; Store byte as ASCII ; ENTRY Reg IX points to byte ; Reg DE points to buffer ; StX: ld a,(ix) ; Get byte rrca ; .. upper bits rrca rrca rrca call StX4 ld a,(ix) inc ix StX4: and LoMask ; .. mask bits add a,90h daa adc a,40h daa ld (de),a inc de ret ; ; Tell all about the item ; TellItem: ld de,$NAME call strcn0 ; .. print name ld a,(Opt) cp 'V' ; Test verbose call z,Verbose ; .. do it call crlf call combrk ; .. test key ret nc jp OS ; ; Get position of item ; EXIT Carry set on error ; IRLpos: ld b,e_r_b ld hl,@E_R_B ..pos: call dskget ; .. get header ret c ld (hl),a inc hl djnz ..pos call dskget ; .. get next ret ; ; Process directory ; ProcIRL: ld de,FCB call dskred ; Skip record jr c,IRLerr IRL.loop: call IRLpos ; Get positions jr c,IRLerr ; .. error cp _eol ; Test end ret z ; .. yeap ld hl,$NAME ld b,nam.len-1 ..name: ld (hl),a ; .. save name inc hl call dskget ; Get more cp _eol ; Test end of name jr z,_eon djnz ..name ; .. take care of error IRLerr: ld de,$ILL.FILE jr Error ; .. error _eon: ld (hl),null ; .. close call TellItem ; .. give name of item jr IRL.loop ; ; Set default extension ; ENTRY Reg DE points to FCB ; DefExt: ld hl,.fdrv+.fname add hl,de ld a,(hl) ; Test extension cp ' ' ret nz ; .. yeap push de ex de,hl ld hl,$IRL ld bc,.fext ldir ; .. unpack pop de ret ; ; Parse file, verify end of input ; ENTRY Reg DE points to parse parameter block ; EXIT Carry set on parse error ; z.parse: call parse ; .. parse ret c ; .. error ld a,l or h ; Verify zero result sub 1 ccf ret ; ; Fetch option ; GetOpt: ld ix,(ARGV) ; Fetch first pointer ld hl,(ARGV+2) ld (ARGV),hl ; .. unpack file ld de,$ILL.OPT ld a,(ix+0) cp '-' ; Verify option jr nz,Error ld a,(ix+1) ld (Opt),a ; .. set option inc (ix+2) ; .. verify end dec (ix+2) jr nz,Error cp 'L' ret z cp 'V' ret z ; ; Simple error processing ; Error: ld c,.string call BDOS ; .. just print jp OS ; ; ############ ; ### MAIN ### ; ############ ; _main: sub a ; Test right machine ld de,$ILL.CPU jp pe,Error ; .. process error ld sp,(TPAtop) ld c,.vers call BDOS ; .. and OS ld de,$ILL.OS inc h dec h jr nz,Error ld a,l cp CPM3 jr c,Error ld b,_maxarg ld de,CCPlen ld hl,ARGV call cmdarg ; Get arguments ld de,$HELP jr c,Error ; .. invalid dec a call nz,GetOpt ; Fetch options ld hl,(ARGV) ; Get file pointer ld (ParsPB),hl ld de,ParsPB call z.parse ; parse file ld de,$ILL.FILE jr c,Error ; .. error ld de,FCB call DefExt ; Set default extension call wcard ; .. no wildcards here ex de,hl ld de,$ILL.WILD jr z,Error ex de,hl call open ; .. open file ld de,$NO.FILE jr c,Error call ProcIRL ; .. process directory jp OS end _main