;*************************** AMUS Program Label ******************************
; Filename: DEVCHR                                          Date: 6/30/92
; Category: UTIL         Hash Code: 410-321-577-677      Version: 1.0(100)
; Initials: GR/AM        Name: JAMES A. JARBOE IV
; Company: EDUCATIONAL VIDEO NETWORK, INC          Telephone #: 4092955767
; Related Files: NONE
; Min. Op. Sys.: 2.X                           Expertise Level: BEG
; Special: Must assemble on AMOS 2.x for 2.x calls.
; Description: Displays the device characteristics of a selected Device.
; Also displays number of blocks, total free blocks & total Contiguous blocks
; for file structured devices.
;*****************************************************************************
;*; Updated on 30-Jun-92 at 2:21 AM by James A. Jarboe I V; edit time: 1:37:14
;***************************************************************************
;*                                                                         *
;*                              DEVCHR.M68                                 *
;*                                                                         *
;*                     Written By: James A. Jarboe IV                      *
;*                            1401 19th Street                             *
;*                          Huntsville, TX 77340                           *
;*                              409-295-5767                               *
;*                                                                         *
;*                               29-Jun-92                                 *
;*                                 GR/AM                                   *
;***************************************************************************
;*                Copyright (c) 1992 - James A. Jarboe IV                  *
;*                   Unpublished - All rights reserved.                    *
;***************************************************************************
;
; Description:
;
;       Displays a devices label and characteristics.
;
; Edit History:
;
;[100] 29-Jun-92 Written by James A. Jarboe IV.
;

;;;;;   LINK    =       1               ; Set linker on.
       LINK    =       0               ; Set linker off.


       ASMMSG  "                                      "
       ASMMSG  "+------------------------------------+"
       ASMMSG  "|                                    |"
       ASMMSG  "|              DEVCHR                |"
       ASMMSG  "|                                    |"
       ASMMSG  "|  Displays  Device Characteristics  |"
       ASMMSG  "|                                    |"
       ASMMSG  "|      By: James A. Jarboe IV        |"
       ASMMSG  "|                                    |"
       ASMMSG  "+------------------------------------+"

; Alert if automatic linker active.
;
IF NE, LINK
       ASMMSG  "|    *     LINKER is Active.    *    |"
       ASMMSG  "+------------------------------------+"

       ; Let d/SOFT's MACRO automatically create sym table.
       ;
       LINKER  DEVCHR/S
       ;
ENDC
       ASMMSG  "                                      "


       PAGE
;***************************************************************************
;                                                                          *
;                           S Y M B O L I C S                              *
;                                                                          *
;***************************************************************************
;
       SEARCH  SYS                     ; Amos Standard symbolic.
       SEARCH  SYSSYM                  ; Amos Standard symbolic.

       PAGE
;***************************************************************************
;                                                                          *
;                      C U R R E N T   V E R S I O N                       *
;                                                                          *
;***************************************************************************
;
       VMAJOR  =       1.              ; First Version.
       VMINOR  =       0               ;
       VEDIT   =       100.            ; 29-Jun-92
       VWHO    =       0               ;

       PAGE
;***************************************************************************
;                                                                          *
;                      P R O G R A M   M A C R O S                         *
;                                                                          *
;***************************************************************************
;
; Define easy print at.
;
DEFINE  PRTTAB  ROW,COL
       MOVW    #<ROW_8.+COL>, D1
       TCRT
ENDM

; Dim display.
;
DEFINE  DIM
       PRTTAB  -1,11.
ENDM

; Bright display.
;
DEFINE  BRIGHT
       PRTTAB  -1,12.
ENDM

; Show text and value.
;     TEXT = Ascii text to display.
;      OFF = Offset value to display in decimal.
;      TYP = (optional)
;            not there - get as long word
;                there - get as word
;
DEFINE  SHWLN   TEXT, OFF, TYP
       TAB                             ; Bump
       TAB                             ; Bump
       DIM                             ; Dim
       TYPE    <TEXT>                  ; Output field display.
       BRIGHT                          ; Bright.
       IF      NB, TYP                 ; If not blank use WORD.
       CLR     D1                      ; Preclear.
               MOVW    OFF, D1         ; Get word value.
       IFF                             ; If BLANK use LWORD.
               MOV     OFF, D1         ; Get long word value.
       ENDC
       CALL    SHW.NUM                 ; Output decimal value.
ENDM

; Table entries.
;     VAL = value to check.
;     ROW = Row to position cursor
;     COL = Column to position cursor
;   TEXT1 = Field text display.
;   TEXT2 = Flag on text.
;   TEXT3 = Flag off text.
;
DEFINE  TBLENT  VAL, ROW, COL, TEXT1, TEXT2, TEXT3
       LWORD   VAL                     ; Flag value.
       LWORD   1$$-.                   ; Offset to next entry.
       WORD    ROW
       WORD    COL
       LWORD   2$$-.                   ; Offset to match flag.
       LWORD   3$$-.                   ; Offset to not match flag.
       LWORD   4$$-.
2$$:    ASCII   /TEXT1/                 ; Text Field display.
       BYTE    0
       EVEN
3$$:    ASCII   /TEXT2/                 ; ON text.
       BYTE    0
       EVEN
4$$:    ASCII   /TEXT3/                 ; OFF text.
       BYTE    0
       EVEN
1$$:                                    ; End of table entry.

ENDM

; Check Device characteristic flag.
;
;       FLG = flag value to check.
;
DEFINE  IS.IT   FLG
       MOV     DC.FLG(A0), D7          ; Get device char flags.
       AND     #FLG, D7                ; See if it is set.
ENDM

       PAGE
;***************************************************************************
;                                                                          *
;              B U F F E R   S I Z E S   A N D   E Q U A T E S             *
;                                                                          *
;***************************************************************************
;
       S..IOB  =       512.            ; Size of Buffer.

       DS.ROW  =       16.             ; Starting characteristic display row.
       DS.CL1  =       5.              ; Characteristic display column 1
       DS.CL2  =       40.             ; Characteristic display column 2

       $SPACE  =       32.             ; Value of Space character.

       PAGE
;***************************************************************************
;                                                                          *
;                  P R O G R A M   I M P U R E   A R E A                   *
;                                                                          *
;***************************************************************************
;

OFINI
OFDEF   DE.DDB, D.DDB                   ; Device DDB.
OFDEF   DE.CHR, DC.SIZ                  ; Device characteristics.
OFDEF   DE.DFR, DF.SIZ                  ; Device Free data.
OFDEF   DE.MIS, S..IOB                  ; Miscellaneous buffer.
OFSIZ   DE.SIZ                          ; Size of impure area.

       PAGE
;***************************************************************************
;                                                                          *
;                 S T A R T   O F   P R O G R A M   C O D E                *
;                                                                          *
;***************************************************************************
;
;+************************+
;         DEVCHR          *
;+************************+
;
; Description:
;
;       Displays device characteristics.
;

DEVCH:  PHDR    -1,0,PH$REE!PH$REU
       GETIMP  DE.SIZ, A5              ; Get impure area.

       MOV     SYSTEM, D7              ; Get system flags.
       AND     #SY$EXD, D7             ; Is this 2.X?
       BNE     10$                     ; Yes..onward.
       CRLF                            ; Bump line and report error.
       TYPECR  <                   Only works on AMOS version 2.x or greater>
       EXIT

10$:    BYP                             ; Bypass junk.
       TRM                             ; End of line?
       JEQ     HELPEM                  ; Yes..help them.

       INIT    DE.DDB(A5)              ; Init DDb.
       FSPEC   DE.DDB(A5)              ; Get device spec.

       TSTW    DE.DDB+D.DEV(A5)        ; Did we get a device spec?
       JEQ     HELPEM                  ; No..tellem how.
       TSTW    DE.DDB+D.DRV(A5)        ; Did we get a drive?
       JMI     HELPEM                  ; No..tellem how.
       CALL    DO.HEADER               ; Display header.

       DEVCHR  DE.DDB(A5), DE.CHR(A5)  ; Get device characteristics.
       LEA     A0, DE.CHR(A5)          ; Index device char table.
       PRTTAB  3.,1                    ;
       CRLF

       SHWLN   <         Physical Device: >, DC.PHY(A0), WRD
       SHWLN   <            Logical Unit: >, DC.LOG(A0), WRD
       SHWLN   <     Standard block size: >, DC.BUF(A0)

       IS.IT   DC$FSD                  ; Is device file structured?
       JEQ     20$                     ; No..bypass bitmap stuff.
       SHWLN   <             Bitmap Size: >, DC.BMS(A0)
       SHWLN   <  Total Number of Blocks: >, DC.BLK(A0)

       DSKFRE  DE.DDB(A5), DE.DFR(A5)  ; Yes..get free block data.
       SHWLN   <       Total Free Blocks: >, DE.DFR+DF.FRE(A5)
       SHWLN   <  Contiguous Free Blocks: >, DE.DFR+DF.HOL(A5)

20$:
       IS.IT   DC$ATT                  ; Does it have alternate track?
       BEQ     30$                     ; No..never mind.
       SHWLN   <Alternate track bytes: >, DC.ATT(A0)
30$:
       IS.IT   DC$SHR                  ; Is it a sharable device?
       BNE     40$                     ; Yes..never mind.
       IS.IT   DC$ASN                  ; Is it assigned to a job?
       BEQ     40$                     ; No..never mind.
       TYPE    <      Assigned to JOB: >
       MOV     DC.JOB(A0), A6          ; Get JCB.
       LEA     A1, JOBNAM(A6)          ; Index JOBNAM.
       LEA     A2, DE.MIS(A5)          ; Index miscellaneous buffer.
       UNPACK                          ; Make ascii.
       UNPACK
       CLRB    @A2                     ; Clear end of buffer.
       TTYL    DE.MIS(A5)              ; Output ASCII.
       CRLF
40$:
       MOV     #DS.ROW, D1             ; Set display row.
       SUB     #3, D1                  ; Bump back some rows.
       CALL    DRW.LINE                ; Draw a line.
       CALL    SHW.FLAGS               ; Display flag off/on values.
       PRTTAB  24.,1                   ; Position cursor.
       EXIT                            ; Exit program.


       PAGE
;+************************+
;        SHW.NUM          *
;+************************+
;
; Description:
;
;       Displays decimal value of D1
;
; Incoming:
;               D1 =: value to display.
;
SHW.NUM:
       DCVT    0, OT$TRM               ; Output value to terminal.
       CRLF                            ; Bump line.
       RTN                             ; Return to caller.

       PAGE
;+************************+
;        SHW.FLAGS        *
;+************************+
;
; Description:
;
;       Display text and true or false textual value of flag.
;
; Incoming:
;               A0 -> Indexes Device characteristics table.
;
SHW.FLAGS:
       SAVE    D0-D3, A0-A1            ; Save what we use.
       LEA     A1, DEV.FLG             ; Index table.
10$:
       MOV     (A1)+, D0               ; Get flag value.
       BMI     99$                     ; Return when finished with table.
       PUSH    A1                      ; Save index value.
       MOV     (A1)+, D2               ; Get next entry offset.
       PUSH    A1                      ; Save offset.
       DIM                             ; Dim
       MOVW    (A1)+, D1               ; Get row value.
       ROLW    D1, #8.                 ; Set high order byte of low word.
       MOVW    (A1)+, D3               ; Get column value.
       MOVB    D3, D1                  ; Set low order byte of low word.
       TCRT                            ; Position cursor.
       ADD     @A1, A1                 ; Get offset of display text.
       TTYL    @A1                     ; Output to terminal.
       BRIGHT                          ; Bright.
       POP     A1                      ; Restore offset.
       ADD     #8., A1                 ; Bump to on offset.
       MOV     DC.FLG(A0), D6          ; Get device flag.
       AND     D0, D6                  ; Is it valid?
       BNE     20$                     ; Yes..use text.
       ADD     #4, A1                  ; Bump to off offset value.
20$:    ADD     @A1, A1                 ; Set text offset.
       TTYL    @A1                     ; Output text.
       CRLF                            ; Bump line.
       POP     A1                      ; Restore table index.
       ADD     D2, A1                  ; Get next table entry offset.
       BR      10$                     ; Try again.
99$:
       REST    D0-D3, A0-A1            ; Restore what we used.
       RTN                             ; Return to caller

;+************************+
;        DO.HEADER        *
;+************************+
;
; Description:
;
;       Display program header.
;
DO.HEADER:
       SAVE    D0-D1, A0-A2            ; Save what we use.
       PRTTAB  -1,0                    ; Clear screen.
       PRTTAB  1,80.                   ; Position cursor.
       PRTTAB  -1,33.                  ; Reverse off.
       PRTTAB  1,1                     ; Position cursor.
       PRTTAB  -1,32.                  ; Reverse on
       DIM                             ; Dim
       TYPE    <                                                                              >
       PRTTAB  1,23.                   ; Position cursor.
       BRIGHT                          ; Bright.
       TYPE    < Device Characteristics of >
       LEA     A2, DE.MIS(A5)          ; Index buffer.
       LEA     A1,DE.DDB+D.DEV(A5)     ; Index device.
       UNPACK                          ; Make ascii.
       CLR     D1                      ; Preclear.
       MOVW    DE.DDB+D.DRV(A5), D1    ; Get drive number.
       DCVT    0,OT$MEM                ; Output to buffer.
       MOVB    #':, (A2)+              ; Get seperator.
       MOVB    #$SPACE, (A2)+          ; Output space.
       CLRB    @A2                     ; Mark end of buffer.
       TTYL    DE.MIS(A5)              ; Output buffer.
       DIM                             ; Dim
       PRTTAB  1, 80.                  ; Position cursor.
       PRTTAB  -1,33.                  ; Reverse off.
       PRTTAB  -1,12.                  ; Bright.
       CRLF                            ; Bump line.
       REST    D0-D1, A0-A2            ; Restore what we use.
       RTN                             ; Return to caller.

;+************************+
;        DRW.LINE         *
;+************************+
;
; Description:
;
;       Draws a line from column 1 to column 80.
;
; Incoming:
;               D1 = Row.
;
DRW.LINE:
       ROLW    D1, #8.                 ; Set row.
       MOVB    #80., D1                ; Set last column.
       TCRT                            ; Position cursor.
       PUSH    D1                      ; Save it.
       PRTTAB  -1,31.                  ; Under off.
       POP     D1                      ; Restore it.
       MOVB    #1, D1                  ; Set column 1.
       TCRT                            ; Set cursor.
       PRTTAB  -1,30.                  ; Under on.
       TYPE    <                                                                            >
       PRTTAB  -1,31.                  ; Under off.
       RTN                             ; Return to caller.

;+************************+
;        HELPEM           *
;+************************+
;
; Description:
;
;       Displays a couple of lines of help for the novice.
;       Exits program.
;
HELPEM:
       CRLF                            ; Bump
       DIM                             ; Dim.
       TYPE    <%Usage: >
       BRIGHT                          ; Bright.
       LEA     A1, DEVCH-6.            ; Index program name.
       LEA     A2, DE.MIS(A5)          ; Index buffer.
       UNPACK                          ; Make ASCII
       UNPACK
10$:    CMPB    -(A2), #$SPACE          ; Space?
       BEQ     10$                     ; Erase it.
       INC     A2                      ; Bump past character.
       CLRB    @A2                     ; Mark end of buffer.
       TTYL    DE.MIS(A5)              ; Output Program name.
       TYPE    < device>
       CRLF
       CRLF
       TYPECR  <        Displays the characteristics of a Device>
       CRLF
       TYPE    <        Example:      >
       TTYL    DE.MIS(A5)              ; Output program name.
       TYPECR  < DSK0:>
       CRLF
       EXIT                            ; Exit program



       PAGE
;***************************************************************************
;                                                                          *
;                         DEVICE FLAG TABLE VALUES                         *
;                                                                          *
;***************************************************************************
;
;
       EVEN                            ; Even up assembly.

DEV.FLG:
       TBLENT  DC$FSD, DS.ROW,   DS.CL1, <     File structured: >, <Yes>, <No>
       TBLENT  DC$ATT, DS.ROW+1, DS.CL1, <Uses Alternate table: >, <Yes>, <No>
       TBLENT  DC$LOG, DS.ROW+2, DS.CL1, <        Logical unit: >, <Yes>, <No>
       TBLENT  DC$SHR, DS.ROW+3, DS.CL1, <     Sharable device: >, <Yes>, <No>
       TBLENT  DC$PAG, DS.ROW+4, DS.CL1, <        Paged Bitmap: >, <Yes>, <No>
       TBLENT  DC$ASN, DS.ROW,   DS.CL2, <   Assigned to a JOB: >, <Yes>, <No>
       TBLENT  DC$MNT, DS.ROW+1, DS.CL2, <   Currently Mounted: >, <Yes>, <No>
       TBLENT  DC$NAC, DS.ROW+2, DS.CL2, <      Network access: >, <No>, <Yes>
       TBLENT  DC$14D, DS.ROW+3, DS.CL2, <    Directory Format: >, <Extended>, <Traditional>
       LWORD   -1

       EVEN                            ; Even out assembly.

       END                             ; End of program.