Title Verifile: Verify all files (9_Feb_84) ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; Howard Fullmer .z80 aseg org 100h system equ 5 file_line equ 5 set_dma equ 26 open_file equ 15 close_file equ 16 search_first equ 17 search_next equ 18 read_random equ 33 set_user equ 32 display equ 9 con_stat equ 11 con_input equ 1 set_error_mode equ 45 ret_cur_dsk equ 25 sel_dsk equ 14 rand equ 33 main: ld a,0 ;set verifile flag ld (40h),a ld c,set_error_mode ld e,0FFh call system ld a,0ffh ;get current user call user ld (cuser),a ;save current user ld c,ret_cur_dsk ;get current disk call system ld (cdisk),a ;save current disk ld c,set_dma ;set dma address ld de,data_buf ;data buffer call system ld hl,80h ;pointer to tail ld a,(hl) ;see if command tail or a jr z,search_loop ;jump if no tail ld b,a ;tail length space_loop: inc hl ld a,(hl) ;get char from tail cp 20h ;compare to space jr nz,found_drive djnz space_loop ;loop to get rid of spaces ld a,41h ;drive A is default found_drive: ld c,sel_dsk ;select new disk sub 41h ld e,a call system or a ;check for error jp nz,error search_loop: ld c,con_stat ;get console status call system cp 1 ;see if char. ld c,con_input ;get input code call z,system ;only call if char. ready cp 3 ;see if ^C jp z,finished ;exit if ^C ld bc,(search_count) ;get count for next dir entry push bc ;save count ld c,search_first ;search for first dir entry ld de,search_fcb call system jr first_jmp search_again: push bc ;save count ld c,search_next ;search for next dir entry ld de,search_fcb call system first_jmp: pop bc ;restore count cp 0ffh ;see if done jr nz,dir_ok ;jump if done ld a,h ;see if error or end or a jp z,finished ;jump if end jp error ;else error dir_ok: ld e,a ;save dir entry offset dec bc ;decrement count ld a,c ;check if 0 or b ld a,e ;restore dir entry offset jr nz,search_again ;jump if count not 0 ld bc,(search_count) ;get count for next dir entry inc bc ;increment count for next entry ld (search_count),bc rlca ;multiply A * 32 rlca rlca rlca rlca ld e,a ;put A * 32 in de ld d,0 ld hl,data_buf ;pointer to data buffer add hl,de ;pointer to dir entry ld a,(hl) ;get first byte of dir entry cp 0e5h ;see if dir entry is active jr z,search_loop ;go to next entry if not active and 0fh ;mask off user # call user ;set user # inc hl ;pointer to file name ld de,fcb+1 ;pointer to data fcb ld bc,11 ;file name length ldir ;move file name into fcb ld a,(hl) ;check extent of dir entry cp 2 jr nc,search_loop ;go to next entry if not 1st extent ld a,'$' ;set extent to $ to print file name ld (de),a push hl push de ld c,display ;display file name ld de,fcb+1 call system ld a,(line_flag) dec a ld (line_flag),a ld de,sep_name jr nz,same_line ld de,new_line ;display cr & lf ld a,file_line ld (line_flag),a same_line: ld c,display call system pop de pop hl ld a,0 ;set extent to 0 ld (de),a ld l,e ;hl = de ld h,d inc de ;set up to clear rest of fcb ld bc,23 ldir ;clear rest of fcb ld c,open_file ;open file ld de,fcb call system or a ;check for error jp nz,error read_loop: ld c,read_random ;read record ld de,fcb call system or a ;see if read ok jr nz,close ;jump if read not ok ld hl,(fcb+rand) ;lower 16 bits of record number ld de,8 ;physical sector length add hl,de ;set record to next sector ld (fcb+rand),hl jr nc,read_loop ;jump if no carry ld a,(fcb+rand+2) ;high 8 bits of record number inc a ;add carry to high byte ld (fcb+rand+2),a jr read_loop ;read next record close: cp 3 ;see if extent error jr nz,not_extent ;jump if not extent error ld h,a ;put error code in h jp error not_extent: cp 0ffh ;see if phys. error jp z,error ;jump if error ld c,close_file ;close file ld de,fcb call system or a ;check for error jp nz,error ;jump if error jp search_loop ;go to next file user: push hl ld c,set_user ;set user ld e,a call system pop hl ret finished: ld a,(cuser) ;set user back to current user call user ld a,(cdisk) ;get current disk ld e,a ld c,sel_dsk call system ;set current disk jp 0 ;warm boot error: ld a,h ;get extended error code or a ;see if not found error ld de,not_fnd ;not found mesg. jr z,disp_error ;display error cp 3 ;check for extent error jr z,disp_error ;display error cp 1 ;check for file error jr z,file_error cp 4 ;check for bad drive ld de,bad_drive jr z,disp_error ;display error ld de,unknown ;unknown error disp_error: ld c,display call system ld de,cant_cont ld c,display call system exit: ld a,1 ;set verifile flag ld (40h),a jp finished file_error: ;bad file found ld a,'$' ld (fcb+13),a ld de,file1 ld c,display call system ld de,fcb+1 ld c,display call system ld de,new_line ld c,display call system jr exit search_count: dw 1 cuser: db 0 cdisk: db 0 line_flag: db file_line new_line: db 0dh,0ah,'$' sep_name: db ' | $' not_fnd: db 0dh,0ah,'Directory is bad.$' bad_drive: db 0dh,0ah,'Invalid drive specified.$' cant_cont: db 0dh,0ah,'Unable to continue Verifile.',0dh,0ah,'$' file1: db 0dh,0ah,'Bad file found: $' unknown: db 0dh,0ah,'Unknown error encountered.$' search_fcb: db '?' ds 35,0 fcb: ds 36,0 data_buf equ $ end