;***************************************************************************;
; ;
; FILMAP ;
; Directory Command ;
; ;
;***************************************************************************;
;Copyright (C) 1986 by UltraSoft. All Rights Reserved.
;
;Written by: David Pallmann
;
;What it does:
;
; FILMAP is (yet another) directory command. You can use ^R and ^T to
; scan back and forth through the directory. This utility was written
; for the AMUS M68-SIG as an example of how to use our wildcard scanner,
; WLDSCN.
;
;How to assemble FILMAP:
;
; 1. Make sure you have (1) FILMAP.M68 (2) WLDSCN.M68 (3) WLDSYM.M68
; 2. Assemble WLDSCN.M68 to create WLDSCN.OBJ (uses WLDSYM.M68)
; 3. Assemble FILMAP with the command .M68 FILMAP
; 4. Link FILMAP with the command .LNKLIT FILMAP,WLDSCN
;
;How to use it:
;
; It's just like DIR - enter a filespec, or even a blank line. Examples:
; .FILMAP .FILMAP ALL:*.BAS[] .FILMAP *.CMD
;
;Edit History:
;1.0 17-Jul-86 created. /DFP
;1.0A 19-Jul-86 force octal mode. /DFP
;1.1 02-Aug-86 remove dependence on UltraSoft universals. /DFP
VMAJOR=1
VMINOR=1
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
;dedicated registers
MEM=A5 ; impure index
WILD=A4 ; wildscan DDB index
BASE=A3 ; base of file specs in memory
INDEX=A1 ; current filespec pointer
COUNT=D5 ; number of files in memory
CURR=D4 ; current file number
;impure area used by FILMAP
.OFINI
.OFDEF BUFFER,30.
.OFDEF LSTDEV,2 ; last device displayed
.OFDEF LSTDRV,2 ; last drive displayed
.OFDEF LSTPPN,2 ; last PPN displayed
.OFSIZ MEMSIZ
;the following structure is used to remember the directory information in
;memory
;macro definitions
;
; CURSOR {row},{col} is the same as PRINT TAB(row,col); in BASIC
; TCALL {code} is the same as PRINT TAB(-1,code) in BASIC
; CLS clears the screen (-1,0);
; CLREOL clears to end of line (-1,9);
; LOW sets low intensity (-1,11);
; HIGH sets high intensity (-1,12);
; GRAFIX turns on graphics mode (-1,23);
; TEXT turn off graphics mode (-1,24);
; REVERS turns on reverse video (-1,32);
; NORMAL turns off reverse video (-1,33);
; HLINE outputs a horizontal graphics line (-1,46);
;These macros are used to call WLDSCN, the wildcard directory scanner
;These are defined in WLDSCN.UNV as well
DEFINE WINIT
IF NDF,W.INIT,EXTERN W.INIT
CALL W.INIT
ENDM
DEFINE WSPEC EXT
IF NDF,W.SPEC,EXTERN W.SPEC
CALL W.SPEC
IF B,EXT,ASCII /???/
IF NB,EXT,ASCII /'EXT/
BYTE 0
ENDM
DEFINE WSCAN
IF NDF,W.SCAN,EXTERN W.SCAN
CALL W.SCAN
ENDM
;start of code
START: PHDR -1,PV$RPD!PV$RSM,PH$REE!PH$REU ; program header
INIT: GETIMP MEMSIZ,MEM ; allocate local memory
WINIT ; initialize WLDSCN (sets up A4)
USRFRE BASE ; point to free memory to file table
MOV BASE,INDEX ; set index to table base
CLR COUNT ; clear file count
SETOCT: JOBIDX A6 ; index user's JCB [1.0A]
ANDW #^C<J.HEX>,JOBTYP(A6) ; force OCTAL radix [1.0A]
CMDLIN: BYP ; bypass leading cmd line spaces
WSPEC ; process wildcard file specification
JNE EXIT ; branch on invalid spec
USREND A2 ; index end of free memory
SUB #10,A2 ; subtract 8 bytes for good measure
LOAD: CTRLC EXIT ; branch on ^C
WSCAN ; get next file that matches spec
JNE CKZERO ; no more - branch
MOVW D.DEV(WILD),F.DEV(INDEX); copy spec
MOVW D.DRV(WILD),F.DRV(INDEX); from wildscan
MOVW D.PPN(WILD),F.PPN(INDEX); DDB @A4 to
MOV D.FIL(WILD),F.FIL(INDEX); our internal
MOVW D.EXT(WILD),F.EXT(INDEX); table
INC COUNT ; add one to file count
JOBIDX A0 ; index user's JCB again
TSTW F.DEV(INDEX) ; defaulted device code?
BNE 10$ ; no
MOVW JOBDEV(A0),F.DEV(INDEX) ; yes - use log device code
10$: TSTW F.DRV(INDEX) ; defaulted drive number?
BPL 20$ ; no
MOVW JOBDRV(A0),F.DRV(INDEX) ; yes - use log device code
20$: TSTW F.PPN(INDEX) ; defaulted PPN?
BNE 30$ ; no
MOVW JOBUSR(A0),F.PPN(INDEX) ; yes - use log account number
30$: ADD #F.SIZ,INDEX ; point index to next table entry
CMP INDEX,A2 ; are we out of memory?
JLT LOAD ; no
TYPECR %Couldn't fit entire directory in memory ; yes - say so
CKZERO: TST COUNT ; any files selected?
BNE SETTRM ; yeah
TYPECR %No such files ; nope
EXIT ; exit
SETTRM: JOBIDX A6 ; index JCB
MOV JOBTRM(A6),A6 ; get TCB address
ORW #T$IMI!T$ECS,T.STS(A6) ; force image mode, disable echo
;home display to beginning of directory(ies) in memory
HOME: MOV BASE,INDEX ; set index to table base
CLR CURR ; clear current file index
;display current page
DISPLY: CLRW LSTDEV(MEM) ; forget about
CLRW LSTDRV(MEM) ; previously displayed
CLRW LSTPPN(MEM) ; data
CLS ; clear screen
HIGH ; high intensity
MOV INDEX,A0 ; copy table index
MOV CURR,D0 ; copy file index
MOV #1,D2 ; set row
10$: MOV #1,D3 ; set column
20$: JOBIDX A6 ; index JCB
MOV JOBTRM(A6),A6 ; get TCB address
TST T.ICC(A6) ; any characters entered?
JNE GETCHR ; yes - abort screen display
CMP D2,#24. ; at row 24?
BGE 30$ ; yes - done w/display
CTRLC EXIT ; branch on ^C
CURSOR D2,D3 ; address cursor
CALL DISFIL ; display file
CMP D2,#23. ; at end of screen?
JGT 30$ ; yes
INC D0 ; inc temp file count
CMP D0,COUNT ; past end of table?
BGE 30$ ; yes
ADD #F.SIZ,A0 ; advance to next entry
ADD #13.,D3 ; advance column
CMP D3,#68. ; past end of line?
BLT 20$ ; no
INC D2 ; advance row
BR 10$ ; branch
30$: TST CURR ; are we at start of table?
BNE SELECT ; yes - branch
CMP D0,COUNT ; are we at end of table?
JGE FINISH ; yes - branch
SELECT: CURSOR #24.,#1
HIGH
TYPE B
LOW
TYPE <ack, >
HIGH
TYPE F
LOW
TYPE <orward, >
HIGH
TYPE Q
LOW
TYPE <uit: >
JMPTBL: WORD BACK-JMPTBL
WORD END-JMPTBL
WORD FORWRD-JMPTBL
WORD TOHOME-JMPTBL
WORD FINISH-JMPTBL
WORD BACK-JMPTBL
WORD END-JMPTBL
WORD FORWRD-JMPTBL
WORD TOHOME-JMPTBL
WORD FINISH-JMPTBL