home *** CD-ROM | disk | FTP | other *** search
- page ,132
- title direx ( directory manipulator - ibm ) as of 12/05/87 - 11:30 am
- ;*
- ;* dont forget to
- ;* exe2bin ( cetc direx )
- ;*
- ;
- target equ 0d8h
- source equ 0b0h
- bya equ 06eh ; brown, yelo attr
- gya equ 02eh ; green, " "
- blya equ 01eh ; blue, " "
- mbtr equ 61*1024 ; max bytes to read
- ;
- ;*------------------------
- code segment
- ;*------------------------
- ;
- assume cs:code,ds:code,es:code
- ;
- org 256
- ;
- start: jmp direx
- ;
- ;*
- ;* messages
- ;*
- prompt db '[ c=copy, d=delete, n=new dir, p=protect, '
- db 'q=quit, u=unprotect, <space>=mark ]$'
- cpy_msg db 'pathname to copy marked files to: $'
- nd_msg db 'new pathname: $'
- full_msg db '* TARGET DISK FULL: *$'
- del_msg db 'delete marked file (y/n)? $'
- ;*
- ;* flags
- ;*
- cpyflg db 0 ; set when doing copies
- d1_flag db 0 ; in DISPLAY, not DSPLAY2
- dspflg db 0 ; set when initial display done
- fullflg db 0 ; disk full flag
- nofilf db 0 ; no filename given
- ;*
- sfhndl dw 0 ; source file handle
- tfhndl dw 0 ; target file handle
- spe dw 0b0h ; sors path end - put filenames here
- tpe dw 0dbh ; tgt path end - put filenames here
- tstpe dw 0 ; test path end
- bytsred dw 0 ; bytes read for copy
- bytsreq dw 0 ; bytes requested to be read
- ;*
- bess db 27,'[','1',';','43',';','33','m'
- bese db 0
- ;*
- marked db 0 ; file marked ?
- attrib db 7 ; screen attr
- wildcard db '*.*',0 ;
- cursor_x db 0 ; cursor column position ( dl )
- cursor_y db 0 ; cursor row position ( dh )
- tempx db 0 ; tem storage for x pos
- tempy db 0 ; tem storage for y pos
- filename db 10 dup (0) ; store given filename here
- ;*
- ;* start of direx
- ;*
- direx proc near
- call brown ; set initial color
- call display ; display dir
- mov si,spe ; light up first filename
- call gfn
- topper: mov attrib,bya ; set brown, yelo
- call color
- top: mov ah,0 ; read a char w/o echo
- int 16h
- ;*
- ;* check for space ( mark )
- ;*
- space: cmp al,20h ; space ? ( mark )
- jne right
- mov ah,8 ; read a char fct
- mov bx,0 ;
- add cursor_x,12 ; position to col after name
- call setcrsr
- int 10h ; read it
- cmp al,0ffh ; marked already ?
- je rtu ; if so, unmark
- ;*
- ;* request to mark
- ;*
- sub cursor_x,12 ; -12 col to name begin
- call setcrsr
- mov attrib,blya ; set marked color
- call color
- add cursor_x,12 ; +12 col to name end
- call setcrsr
- ;
- mov al,0ffh ; mark !
- jmp cwac ; goto common write a char
- ;*
- ;* request to unmark
- ;*
- rtu: mov al,0 ; unmark !
- ;*
- ;* common write a char
- ;*
- cwac:
- mov ah,10 ; write a char fct
- mov cx,1 ; 1 char
- int 10h
- sub cursor_x,12 ; -12 col to name begin
- call setcrsr
- jmp top
- ;*
- ;* check for cursor right
- ;*
- right: cmp ah,4dh ; cursor right ?
- jne left ; if not, try left
- mov attrib,bya ; unlite name
- call color
- call incrsr ; next name
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for cursor left
- ;*
- left: cmp ah,4bh ; cursor left ?
- jne up ; if not, try up
- mov dl,cursor_x ; save col
- mov dh,cursor_y ; save row
- mov attrib,bya ; unlite name
- call color
- sub dl,13 ; -13 col
- jnc ok ; if no carry, ok
- mov dl,5*13 ; if so, make col = 65
- sub dh,1 ; -1 row
- jnc ok ; if no carry, ok
- mov dl,cursor_x ; if so, do not
- mov dh,cursor_y ; change marked file
- ok: mov cursor_x,dl ; load new col
- mov cursor_y,dh ; and row
- call setcrsr
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for cursor up
- ;*
- up: cmp ah,48h ; cursor up ?
- jne down ; if not, try down
- mov dl,cursor_x ; save col
- mov dh,cursor_y ; and row
- mov attrib,bya ; unlite name
- call color
- sub dh,1 ; -1 row
- jnc nottop ; if no carry, ok
- add dh,1 ; +1 row
- nottop: mov cursor_x,dl ; set new col
- mov cursor_y,dh ; and row
- call setcrsr
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for cursor down
- ;*
- down: cmp ah,50h ; cursor down ?
- jne letters ; if not, try letters
- mov attrib,bya ; unlite name
- call color
- inc cursor_y ; inc row
- call setcrsr
- mov si,spe ; set index at end
- call gfn ; get file name
- cmp byte ptr ds:[si],' ' ; is there a name here
- ja go ; if so, carry on
- nogo: dec cursor_y ; else, decr row
- call setcrsr
- go: mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for letters ( q, d, p, u, c, n )
- ;*
- letters: cmp al,'a' ; test for lower case a
- jnl gol ; if EQ/GT, carry on
- add al,32 ; else, convert to lower case
- ;*
- ;* check for quit
- ;*
- gol: cmp al,'q' ; quit ?
- jne del ; if not, try delete
- ;*
- ;* clear all 25 rows
- ;*
- mov cx,25
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- wipe2: push cx
- call setcrsr
- mov cx,80
- mov ah,9
- mov bl,bya
- mov bh,0
- mov al,0
- int 10h
- pop cx
- inc cursor_x ; incr col
- loop wipe2
- ;
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- jmp out
- ;*
- ;* check for delete
- ;*
- del: cmp al,'d' ; delete ?
- je okd ; if so, do delete process
- jmp pro ; else, test protect
- ;
- okd: mov attrib,bya ; unlite name
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- ; clear bottom row
- mov ah,9
- mov cx,80
- mov al,' '
- mov bl,bya
- mov bh,0
- int 10h
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- ; send msg
- mov ah,9
- mov dx, offset del_msg
- int 21h
- ; request reply
- mov ah,1
- int 21h
- ; test reply
- cmp al,'a' ; test for lower case a
- jnl checky ; if EQ/GT, carry on
- add al,32 ; else, convert to lower case
- ;
- checky: cmp al,'y' ; yes ?
- je godel ; if so, go delete
- call dsplay2
- mov attrib,gya ; lite it
- call color
- jmp top
- ;
- godel: mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- ;
- loopd: call gmf ; get marked file
- mov dx,source ; point to source string
- mov ah,41h ; delete
- int 21h
- call incrsr ; move to next file
- cmp dx,0ffh ; is there one ?
- je find
- cmp cx,0ffh ; ?
- jne loopd
- find: call dsplay2
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for protect
- ;*
- pro: cmp al,'p' ; protect ?
- jne unpro ; if not, test unprotect
- mov attrib,bya ; unlite name
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- ;
- ; protect loop
- ;
- loopp: call gmf
- mov dx,source
- mov ah,43h
- mov al,01
- mov cx,1
- int 21h
- call incrsr
- cmp dx,0ffh
- je finp
- cmp cx,0ffh
- jne loopp
- finp: call dsplay2
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for unprotect
- ;*
- unpro: cmp al,'u' ; unprotect ?
- jne copy ; if not, test copy
- mov attrib,bya ; unlite name
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- ;
- ; unprotect loop
- ;
- loopu: call gmf
- mov dx,source
- mov ah,43h
- mov al,01
- mov cx,0
- int 21h
- call incrsr
- cmp dx,0ffh
- je finu
- cmp cx,0ffh
- jne loopu
- finu: call dsplay2
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for copy
- ;*
- copy: cmp al,'c' ; copy ?
- je goc ; if so, do copy process
- jmp new_dir ; else, test new directory
- ;
- goc: mov fullflg,0
- mov attrib,bya ; unlite name
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- ; clear bottom line
- mov ah,9
- mov cx,80
- mov al,' '
- mov bl,bya
- mov bh,0
- int 10h
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- ; send msg
- mov ah,9
- mov dx, offset cpy_msg
- int 21h
- ; buffered keyboard input
- mov ah,10
- mov bx,target-2
- mov dx,target-2
- mov byte ptr [bx],32 ; max 32 byte input
- int 21h
- ;
- mov si,target
- trans: cmp byte ptr [si],13 ; C R ?
- je slash2
- inc si ; next byte
- jmp trans ; keep lookin'
- ;
- slash2: cmp byte ptr [si-1],'\' ; CR - 1 slash ?
- je filer2 ; if so, carry on
- mov byte ptr [si],'\' ; else, move \ on top of CR
- inc si ; past it
- ;
- filer2: mov tpe,si
- mov attrib,bya ; unlite it
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- loopc: mov cpyflg,1
- call gmf
- mov cpyflg,0
- cmp cx,0ffh
- jne open
- jmp finc
- open: mov dx,source
- mov ax,3d00h
- int 21h
- jc botc
- mov sfhndl,ax
- mov dx,target
- mov ah,3ch
- mov cx,0
- int 21h
- jc botc
- mov tfhndl,ax
- stuff: mov dx,offset data
- mov cx,mbtr
- mov ah,3fh
- mov bx,sfhndl
- int 21h
- mov bytsred,ax
- mov cx,ax
- mov bytsreq,cx
- mov ah,40h
- mov bx,tfhndl
- mov dx,offset data
- int 21h
- cmp ax,bytsreq
- jne full
- cmp bytsred,mbtr
- je stuff
- jmp botc
- full:
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- mov ah,9
- mov dx, offset full_msg
- int 21h
- mov fullflg,1
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- botc:
- mov ah,3eh
- mov bx,sfhndl
- int 21h
- mov ah,3eh
- mov bx,tfhndl
- int 21h
- cmp fullflg,1
- jne notfull
- mov dx,target
- mov ah,41h
- int 21h
- jmp topper
- notfull: call incrsr
- cmp dx,0ffh
- je finc
- jmp loopc
- finc: call dsplay2
- mov attrib,gya ; lite it
- call color
- jmp top
- ;*
- ;* check for new directory
- ;*
- new_dir: cmp al,'n' ; new directory ?
- je gon ; if so, do new directory process
- jmp top ; else, invalid code, get another
- ;
- gon: mov attrib,bya ; unlite name
- call color
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- ; clear msg line
- mov ah,9
- mov cx,80
- mov al,' '
- mov bl,bya
- mov bh,0
- int 10h
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- mov ah,9
- mov dx, offset nd_msg
- int 21h
- ; buffered keyboard input
- mov ah,10
- mov bx,80h
- mov dx,80h
- mov byte ptr [bx],32
- int 21h
- jmp direx
- out:
- call brown
- int 20h
- direx endp
- ;*
- ;* get marked file
- ;*
- gmf proc near
- ; cx=ff= no more to be found
- begi: mov ah,8
- add cursor_x,12 ; +12 col to name end
- call setcrsr
- mov bx,0
- int 10h
- sub cursor_x,12 ; -12 col to name begin
- call setcrsr
- cmp al,0ffh ; marked file ?
- je fini
- call incrsr
- cmp dx,0ffh
- jne begi
- mov cx,0ffh
- jmp outer
- fini: mov cx,0
- mov si,spe
- call gfn
- cmp cpyflg,1
- jne outer
- mov si,tpe
- call gfn
- outer: ret
- gmf endp
- ;*
- ;* get file name
- ;*
- gfn proc near
- ; call with ds:si as address to put filename in
- push cx
- push si
- push word ptr cursor_x ; save col position
- mov ah,8
- mov bx,0
- mov cx,12
- loopb: mov ah,8
- int 10h
- inc cursor_x ; incr col
- call setcrsr
- mov ds:[si],al
- inc si
- loop loopb
- mov byte ptr ds:[si],0
- pop word ptr cursor_x ; restore col position
- pop si
- call setcrsr
- pop cx
- ret
- gfn endp
- ;*
- ;* lites / unlites file names
- ;* if file is marked, will not unlite
- ;*
- color proc near
- push cx
- push word ptr cursor_x ; save col position
- mov cx,12
- cmp attrib,bya ; are we unliting ?
- je ulc ; if so, carry on
- cmp attrib,gya ; are we liting ?
- jne sabl ; if not, set all bytes
- ;*
- ;* unlite character
- ;*
- ulc:
- mov ah,8 ; read a char
- add cursor_x,12 ; +12 col to end of name
- call setcrsr
- mov bx,0
- int 10h
- sub cursor_x,12 ; -12 col to name begin
- call setcrsr
- cmp al,0ffh ; was char marked ?
- je fine ; if so, leave
- ;*
- ;* set all bytes loop
- ;*
- sabl:
- mov bx,0 ; read a char
- mov ah,8
- int 10h
- push cx
- mov cx,1 ; 1 char
- mov bl,attrib ; attrib
- mov ah,9 ; write
- int 10h
- pop cx
- inc cursor_x ; +1 col to next letter
- call setcrsr
- loop sabl
- ;
- fine: pop word ptr cursor_x ; restore col position
- call setcrsr
- pop cx
- ret
- color endp
- ;
- display proc near
- mov di,source
- mov d1_flag,1
- mov si,82h
- mov spe,source
- mov bx,80h
- cmp byte ptr [bx],0
- je dsplay2
- trans2: cmp byte ptr [si],13
- je put0
- movsb
- cmp byte ptr [si-1],'\'
- je stor
- cmp byte ptr [si-1],':'
- jne trans2
- stor: mov spe,di
- ;
- push si
- push di
- lea di,filename
- mov cx,10
- mov al,0
- rep stosb
- lea di,filename
- mov cx,9
- oneby: cmp byte ptr [si],13
- jne move
- mov byte ptr [di],0
- jmp short fin0
- move: movsb
- loop oneby
- fin0: pop di
- pop si
- jmp trans2
- put0: mov byte ptr [di],0
- mov tstpe,di
- mov nofilf,0
- jmp chkfil
- ;
- dsplay2: mov d1_flag,0
- cmp filename,0
- jne chkfil
- mov nofilf,1
- chkfil: mov cx,25
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- wipe: push cx
- call setcrsr
- mov cx,80
- mov ah,9
- mov bl,bya
- mov bh,0
- mov al,0
- int 10h
- pop cx
- inc cursor_y ; incr row
- loop wipe
- mov cursor_x,0 ; col = 0
- mov cursor_y,24 ; row = 24
- call setcrsr
- mov ah,9
- mov dx,offset prompt
- int 21h
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- mov di,tstpe
- cmp nofilf,1
- je tslash
- cmp byte ptr [di-1],'\'
- je nofile
- cmp d1_flag,1
- je puta
- cmp filename,0
- je puta
- mov cx,10
- mov si,offset filename
- mov di,spe
- rep movsb
- puta: mov ah,4eh
- mov dx,source
- int 21h
- jnc match1
- nofile: mov filename,0
- tslash: cmp tstpe,0
- jne slash
- mov spe,source
- mov di,spe
- jmp putw
- slash: mov di,tstpe
- mov spe,di
- cmp byte ptr [di-1],'\'
- je putw
- mov byte ptr [di],'\'
- inc di
- inc spe
- putw: mov cx,4
- mov si,offset wildcard
- rep movsb
- src: mov ah,4eh
- mov dx,source
- int 21h
- jc ender
- match1: mov dx,0
- mov ah,2
- int 10h
- call print
- mov cx,120
- looper: mov ah,4fh
- int 21h
- jc ender
- mov dspflg,0ffh ; set DISPLAY flag
- call incrsr
- mov dspflg,0
- call print
- mov dx,offset source
- loop looper
- ender:
- mov cursor_x,0 ; col = 0
- mov cursor_y,0 ; row = 0
- call setcrsr
- ret
- display endp
- ;*
- ;* move hilite to next name on screen
- ;*
- incrsr proc near
- push cx
- mov dl,cursor_x ; save col
- mov dh,cursor_y ; and row
- mov tempx,dl ; in temp
- mov tempy,dh ; storage
- add dl,13 ; next name
- cmp dl,75 ; end of screen
- jl fin ; if LT, carry on
- mov dl,0 ; if EQ/GT, set col = 0
- inc dh ; and incr row
- fin: mov cursor_x,dl ; restore col
- mov cursor_y,dh ; and row
- mov dx,0 ; set return 0
- call setcrsr
- cmp dspflg,0 ; is DISPLAY clear ?
- jne set ; no, dont check for file name
- mov si,spe
- call gfn
- cmp byte ptr ds:[si],' ' ; file name ?
- ja set ; if yes, carry on
- sub cursor_x,13 ; -13 col to last name
- cmp cursor_x,0 ; col 0 ?
- jg leav ; if GT, exit
- mov dl,tempx ; restore temp
- mov cursor_x,dl ; col
- mov dh,tempy ; and
- mov cursor_y,dh ; row
- leav: call setcrsr
- mov dx,0ffh
- set: pop cx
- ret
- incrsr endp
- ;
- setcrsr proc near
- push ax
- mov dl,cursor_x ; set row
- mov dh,cursor_y ; set column
- mov ah,2 ; position cursor
- int 10h
- pop ax
- ret
- setcrsr endp
- ;
- print proc near
- push cx
- mov dx,80h+30 ; point to name
- mov bx,dx
- mov cx,13
- loopa: cmp byte ptr [bx],0 ; zero ?
- je found ; if so, end of file name found
- inc bx
- loop loopa
- found: mov byte ptr ds:[bx+1],'$' ; substitute $ for zero
- mov ah,9 ; print to $
- int 21h
- pop cx
- ret
- print endp
- ;
- include brown.prc
- ;
- data:
- ;
- code ends
- ;
- end start
-