home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / A-R / DEV11A.LBR / DEV11A.ZZ0 / DEV11A.Z80
Text File  |  2000-06-30  |  12KB  |  540 lines

  1. ;
  2. ; Program:  DEV3
  3. ; Author:   Richard Conn
  4. ; Version:  1.0
  5. ; Date:     04 Apr 84
  6. ; Based on: DEVICE2 of ZCPR2
  7. ;
  8. VERS    EQU    11
  9. Z3ENV    DEFL    0FE00H
  10. ;
  11. ; Version 1.1A strips high bits from EFCB characters in
  12. ; help screens.     Bruce Morgen    December 30, 1987
  13. ;
  14. ; Version 1.1 modifications by Bruce Morgen, December 21, 1987:  Made
  15. ; DEV respond to the WHEEL and QUIET bytes to make it a viable tool on
  16. ; an IOP-based RAS.  DEV now requires wheel powers to work at all.  With
  17. ; the quiet byte set, all display options are disabled while device as-
  18. ; signment proceeds as per 1.0, but with no CON: output.  In combination
  19. ; with WHEEL 3.1 or later and T3RAS.IOP, this allows BYE.COM to be a
  20. ; VALIAS/SALIAS-style recursive alias.    TERM3 supplies the other required
  21. ; tools, T3HANGUP and T3ANSWER.  Implemented smarter help message using
  22. ; External FCB and QUIET byte, added Type 3 environment code.
  23. ;_______________________________________________________________
  24. ;
  25. ;    DEV is a program which enables the user to manipulate the
  26. ; extended ZCPR3 redirectable device drivers.  It allows the user to
  27. ; perform the following functions:
  28. ;
  29. ;        o Display the Names of the Current Devices
  30. ;        o Set One or More of the Current Devices
  31. ;        o Ask for Help
  32. ;
  33. ;    The format of the DEV command is:
  34. ;
  35. ;        DEV or DEV //            <-- Ask for Help
  36. ;        DEV command,command,command ... <-- Issue Commands
  37. ;
  38. ; where "command" may take the following forms:
  39. ;
  40. ;        DISPLAY ALL    <-- Display Names of All Devices
  41. ;        DISPLAY CON    <-- Display Names of Consoles
  42. ;        DISPLAY LST    <-- Display Names of Printers
  43. ;        DISPLAY RDR    <-- Display Names of Readers
  44. ;        DISPLAY PUN    <-- Display Names of Punches
  45. ;
  46. ;        CON:=name    <-- Select Console
  47. ;        LST:=name    <-- Select Printer
  48. ;        RDR:=name    <-- Select Reader
  49. ;        PUN:=name    <-- Select Punch
  50. ;
  51. ;
  52. ;  Constants
  53. ;
  54. TBUFF    EQU    80H
  55. CR    EQU    0DH
  56. LF    EQU    0AH
  57. ;
  58. ;  SYSLIB Routines
  59. ;
  60.     EXT    Z3INIT,GETIOP
  61.     EXT    CIN,COUT,PSTR,PRINT,CLINE,CRLF
  62.     EXT    GETEFCB,GETWHL,GETQUIET,QPRINT
  63. ;
  64. ; External ZCPR3 Environment Descriptor
  65. ;
  66. ; TYPE 3 HEADER
  67. ;
  68. ; Code modified as suggested by Charles Irvine to function correctly with
  69. ; interrupts enabled.  Program will abort with an error message when not
  70. ; loaded to the correct address (attempt to run it under CP/M or Z30).
  71. ;
  72.      IF    Z3ENV NE 0
  73. ENTRY:    JR    STARTH        ; Must use relative jump
  74.     NOP            ; Filler
  75.     DB    'Z3ENV',3    ; Type-3 environment
  76.  
  77. Z3EADR:    DW    Z3ENV        ; Filled in by Z33
  78.     DW    ENTRY        ; Intended load address
  79.  
  80. STARTH:    LD    HL,0        ; Point to warmboot entry
  81.     LD    A,(HL)        ; Save the byte there
  82.     DI            ; Protect against interrupts
  83.     LD    (HL),0C9H    ; Replace warmboot with a return opcode
  84.     RST    0        ; Call address 0, pushing RETADDR
  85.                 ; Onto stack
  86. RETADDR:LD    (HL),A        ; Restore byte at 0
  87.     DEC    SP        ; Get stack pointer to point
  88.     DEC    SP        ; To the value of RETADDR
  89.     POP    HL        ; Get it into HL and restore stack
  90.     EI            ; We can allow interrupts again
  91.     LD    DE,RETADDR    ; This is where we should be
  92.     XOR    A        ; Clear carry flag
  93.     PUSH    HL        ; Save address again
  94.     SBC    HL,DE        ; Subtract -- we should have 0 now
  95.     POP    HL        ; Restore value of RETADDR
  96.     JR    Z,START        ; If addresses matched, begin real code
  97.  
  98.     LD    DE,NOTZ33MSG-RETADDR ; Offset to message
  99.     ADD    HL,DE
  100.     EX    DE,HL        ; Switch pointer to message into DE
  101.     LD    C,9
  102.     JP    0005H        ; Return via BDOS print string function
  103.  
  104. NOTZ33MSG:
  105.     DB    'Not Z33+$'    ; Abort message if not Z33-compatible
  106.  
  107. START:    LD    HL,(Z3EADR)    ; Point to ZCPR3 environment
  108.      ENDIF            ; Z3ENV NE 0
  109. ;
  110. ; Internal ZCPR3 Environment Descriptor
  111. ;
  112.      IF    NOT (Z3DNV NE 0)
  113.  
  114.     MACLIB    Z3BASE.LIB
  115.     MACLIB    SYSENV.LIB
  116.  
  117. Z3EADR:    JP    START
  118.     SYSENV
  119.  
  120. START:    LD    HL,Z3EADR    ; Point to ZCPR3 environment
  121.      ENDIF            ; NOT (Z3DNV NE 0)
  122. ;
  123. ; Start of Program -- Initialize ZCPR3 Environment
  124. ;
  125.     CALL    Z3INIT        ; Initialize the ZCPR3 Environment
  126.     CALL    GETWHL
  127.     JR    NZ,WHLOK
  128.     CALL    QPRINT
  129.     DB    'Wheel privileges required.',0
  130.     RET
  131. ;
  132. ; Start of Program
  133. ;
  134. WHLOK:    CALL    GETIOP        ; Check for initialization
  135.     LD    A,H
  136.     OR    L        ; Must NOT be zero
  137.     JR    NZ,START0
  138.     CALL    BANNER
  139.     CALL    PRINT
  140.     DB    CR,LF,'DEV NOT Initialized with I/O Base',0
  141.  
  142. ABORT:    CALL    PRINT
  143.     DB    ' -- Aborting',0
  144.     RET
  145.  
  146. START0:    CALL    STATUS        ; Check for drivers
  147.     JR    NZ,START1
  148.     CALL    BANNER
  149.     CALL    PRINT
  150.     DB    CR,LF,'Redirection Not Supported',0
  151.     JR    ABORT
  152.  
  153. START1:    LD    HL,TBUFF    ; Point to input buffer
  154.     CALL    CLINE        ; Extract and save command line
  155.     CALL    SBLANK        ; Skip to non-blank
  156.     OR    A        ; EOL?
  157.     JR    Z,HELP        ; Select help
  158.     CP    '/'        ; Help?
  159.     JP    NZ,DOCMD    ; Run command subroutine
  160. ;
  161. ; Print Help Message
  162. ;
  163. HELP:    CALL    BANNER
  164.     CALL    PRINT
  165.     DB    CR,LF,'DEV - Quick Redirectable I/O Device Selector'
  166.     DB    CR,LF,'Syntax:'
  167.     DB    CR,LF,'   ',0
  168.     CALL    COMNAM
  169.     CALL    PRINT
  170.     DB    ' or ',0
  171.     CALL    COMNAM
  172.     CALL    PRINT
  173.     DB    ' //             '
  174.     DB    '<-- Ask for Help'
  175.     DB    CR,LF,'   ',0
  176.     CALL    COMNAM
  177.     CALL    PRINT
  178.     DB    ' Command,Command, ...  '
  179.     DB    '<-- Issue Commands'
  180.     DB    CR,LF,'where "command" may take the following forms:'
  181.     DB    0
  182.     CALL    QPRINT        ; No display options if QUIET
  183.     DB    CR,LF,'  DISPLAY=ALL '
  184.     DB    '<-- Display All Devices'
  185.     DB    CR,LF,'  DISPLAY=CON '
  186.     DB    '<-- Display Consoles'
  187.     DB    CR,LF,'  DISPLAY=LST '
  188.     DB    '<-- Display Printers'
  189.     DB    CR,LF,'  DISPLAY=RDR '
  190.     DB    '<-- Display Readers'
  191.     DB    CR,LF,'  DISPLAY=PUN '
  192.     DB    '<-- Display Punches'
  193.     DB    CR,LF,0
  194.     CALL    PRINT
  195.     DB    CR,LF,'  CON:=name  <-- Select Console'
  196.     DB    CR,LF,'  LST:=name  <-- Select Printer'
  197.     DB    CR,LF,'  RDR:=name  <-- Select Reader'
  198.     DB    CR,LF,'  PUN:=name  <-- Select Punch'
  199.     DB    0
  200.     RET
  201. ;
  202. ; Print Banner
  203. ;
  204. BANNER:    CALL    PRINT
  205.     DB    'DEV, Version '
  206.     DB    [VERS/10]+'0','.',[VERS    MOD 10]+'0',0
  207.     RET
  208. ;
  209. ; Skip to Non-Blank Routine
  210. ;
  211. SBLANK:    LD    A,(HL)        ; Get char
  212.     INC    HL        ; Pt to next
  213.     CP    ' '        ; Blank?
  214.     JR    Z,SBLANK    ; Continue if so
  215.     DEC    HL        ; Pt to non-blank
  216.     RET
  217. ;
  218. ; Skip until a delimiter encountered
  219. ;
  220. SDELM:    LD    A,(HL)        ; Get char
  221.     INC    HL        ; Pt to next
  222.     CP    ' '+1        ; <SP> or less?
  223.     RET    C
  224.     CP    '='
  225.     RET    Z
  226.     CP    ','
  227.     RET    Z
  228.     JR    SDELM
  229. ;
  230. ; DOCMD -- This subroutine processes the command line pointed to by HL.
  231. ;   It is the Main Line if a DEVICE command line is given, it is just
  232. ;   a subroutine if the user is in interactive mode.
  233. ;
  234. DOCMD:    CALL    DOCMD1        ; Do first command
  235.     CALL    SDELM        ; Skip to delim
  236.     CP    ','        ; Another command?
  237.     JR    Z,DOCMD
  238.     RET
  239.  
  240. DOCMD1:    LD    A,(HL)        ; Get command letter
  241.     CP    'D'        ; Display?
  242.     JR    NZ,NOTDIS
  243.     CALL    GETQUIET
  244.     JP    Z,DODISP
  245.     RET
  246.  
  247. NOTDIS:    CP    'C'        ; Console assignment?
  248.     JR    Z,DOCON
  249.     CP    'L'        ; LST:?
  250.     JR    Z,DOLST
  251.     CP    'P'        ; PUN:?
  252.     JR    Z,DOPUN
  253.     CP    'R'        ; RDR:?
  254.     JR    Z,DORDR
  255.  
  256. CERR:    CALL    PRINT
  257.     DB    CR,LF,'Error at -- ',0
  258.     CALL    PSTR        ; Print rest
  259.     RET
  260. ;
  261. ; Do LST: Assignment
  262. ;
  263. DOLST:    CALL    QPRINT
  264.     DB    ' LST:',0
  265.     LD    A,3        ; Select LST:
  266.     JR    ASSIGN
  267. ;
  268. ;  Do PUN: Assignment
  269. ;
  270. DOPUN:    CALL    QPRINT
  271.     DB    ' PUN:',0
  272.     LD    A,2        ; Select PUN:
  273.     JR    ASSIGN
  274. ;
  275. ;  Do RDR: Assignment
  276. ;
  277. DORDR:    CALL    QPRINT
  278.     DB    ' RDR:',0
  279.     LD    A,1        ; Select RDR:
  280.     JR    ASSIGN
  281. ;
  282. ;  Do CON: Assignment
  283. ;
  284. DOCON:
  285.     CALL    QPRINT
  286.     DB    ' CON:',0
  287.     LD    A,0        ; Select console
  288. ;
  289. ;  Do Assignment in General
  290. ;
  291. ASSIGN:    LD    B,A        ; Save A in B
  292.     PUSH    BC        ; Save BC
  293.     CALL    SDELM        ; Skip to delimiter
  294.     POP    BC        ; Get BC
  295.     CP    ' '
  296.     JR    Z,ASGN0
  297.     CP    '='
  298.     JR    NZ,CERR
  299.  
  300. ASGN0:    LD    A,B        ; Get A back
  301.     LD    (LOGICAL),A    ; Save logical device number
  302.     LD    (NAME),HL    ; Save pointer to mnemonic
  303.     LD    B,A        ; Number in B
  304.     INC    B        ; Add 1 for offset
  305.     CALL    STATUS        ; Get device status
  306.     DEC    HL        ; Pt to previous
  307.     DEC    HL
  308.  
  309. ASGN1:    INC    HL        ; Pt to next
  310.     INC    HL
  311.     DJNZ    ASGN1        ; Count down
  312.     LD    C,(HL)        ; Get number of devices in C
  313.     LD    A,C        ; Check for value of zero
  314.     OR    A
  315.     JR    NZ,ASGN2
  316.     LD    HL,(NAME)    ; Pt to error name
  317.     JR    CERR
  318.  
  319. ASGN2:    LD    A,(LOGICAL)    ; Get logical device number
  320.     LD    B,A        ; In B
  321.     PUSH    BC        ; Save device count
  322.     DEC    C        ; Pt to previous
  323.     CALL    NAMER        ; Get name
  324.     EX    DE,HL        ; Name pted to by DE
  325.     LD    HL,(NAME)    ; User's name pted to by HL
  326.  
  327. ASGN3:    LD    A,(DE)        ; Get name of device
  328.     CP    ' '+1        ; Done?
  329.     JR    C,ASGN3A
  330.     CP    (HL)        ; Compare to user
  331.     JR    NZ,ASGN4
  332.     INC    HL        ; Pt to next
  333.     INC    DE
  334.     JR    ASGN3
  335.  
  336. ASGN3A:    LD    A,(HL)        ; Get user
  337.     CP    ' '+1        ; Done?
  338.     JR    C,ASGN3B
  339.     CP    ','        ; Done?
  340.     JR    NZ,ASGN4
  341.  
  342. ASGN3B:    POP    BC        ; Match -- C-1 is selected device
  343.     DEC    C        ; Decrement
  344.     CALL    SELECT        ; Select device
  345.     CALL    GETQUIET
  346.     LD    A,(LOGICAL)    ; Get logical device in A
  347.     CALL    Z,CURRENT    ; Print name of device selected
  348.     LD    HL,(NAME)    ; Pt to name for scan continuation
  349.     RET
  350.  
  351. ASGN4:    POP    BC        ; Count down
  352.     DEC    C        ; Count down
  353.     JR    NZ,ASGN2    ; Continue
  354.     LD    HL,(NAME)    ; Pt to invalid name
  355.     CALL    PRINT
  356.     DB    CR,LF,' Invalid Name at -- ',0
  357.     CALL    PSTR
  358.     LD    HL,(NAME)    ; Pt to name for scan continuation
  359.     RET
  360. ;
  361. ; Display Devices and Assignments
  362. ;
  363. DODISP:    CALL    SDELM        ; Skip to delimiter
  364.     OR    A        ; None=all
  365.     JR    Z,DISPALL
  366.     LD    A,(HL)        ; Get char after delimiter
  367.     CP    'A'        ; All?
  368.     JR    Z,DISPALL
  369.     CP    'C'        ; CON:
  370.     JR    Z,DISPCON
  371.     CP    'L'        ; LST:
  372.     JR    Z,DISPLST
  373.     CP    'P'        ; PUN:
  374.     JR    Z,DISPPUN
  375.     CP    'R'        ; RDR:
  376.     JR    Z,DISPRDR
  377.     JP    CERR
  378.  
  379. DISPALL:CALL    DISPCON        ; Successive displays
  380.     CALL    DISPRDR
  381.     CALL    PRINT
  382.     DB    CR,LF,'Strike Any Key -- ',0
  383.     CALL    CIN
  384.     CALL    DISPPUN
  385.     JR    DISPLST
  386.  
  387. DISPCON:CALL    PRINT
  388.     DB    CR,LF,'CON:',0
  389.     LD    A,0        ; Select CON:
  390.     CALL    DISP
  391.     JR    CURR
  392.  
  393. DISPLST:CALL    PRINT
  394.     DB    CR,LF,'LST:',0
  395.     LD    A,3        ; Select LST:
  396.     CALL    DISP
  397.     JR    CURR
  398.  
  399. DISPRDR:CALL    PRINT
  400.     DB    CR,LF,'RDR:',0
  401.     LD    A,1        ; Select RDR:
  402.     CALL    DISP
  403.     JR    CURR
  404.  
  405. DISPPUN:CALL    PRINT
  406.     DB    CR,LF,'PUN:',0
  407.     LD    A,2        ; Select PUN:
  408.     CALL    DISP
  409. ;
  410. ; Print Name of Current Device
  411. ;
  412. CURR:    CALL    CRLF        ; New line
  413.  
  414. CURRENT:PUSH    HL        ; Save ptr
  415.     LD    B,A        ; Save number in B
  416.     PUSH    BC        ; Save B
  417.     CALL    PRINT
  418.     DB    ' Assignment is ',0
  419.     PUSH    BC        ; Save B
  420.     CALL    STATUS        ; Get status
  421.     POP    BC        ; Get B
  422.     INC    B        ; Add 1 for offset
  423.     DEC    HL        ; Back up
  424.  
  425. CURR1:    INC    HL        ; Point to next
  426.     INC    HL
  427.     DJNZ    CURR1        ; Count down
  428.     POP    BC        ; Get logical number in B
  429.     LD    C,(HL)        ; Get physical number in C
  430.     CALL    PNAME0        ; Print first part of name only
  431.     POP    HL        ; Get ptr
  432.     RET
  433. ;
  434. ; Print Names of All Physical Devices for a Logical Device
  435. ;
  436. DISP:    PUSH    HL        ; Save character ponter
  437.     PUSH    AF        ; Save device number
  438.     CALL    PRINT
  439.     DB    ' Devices --',0
  440.     LD    B,A        ; Logical device in B
  441.     PUSH    BC        ; Save for later
  442.     PUSH    BC        ; Save it
  443.     CALL    STATUS        ; Get status report
  444.     POP    BC        ; Get logical device number
  445.     INC    B        ; Add 1 for offset
  446.     DEC    HL        ; Back up
  447.     DEC    HL
  448.  
  449. DISP1:    INC    HL        ; Point to next
  450.     INC    HL
  451.     DJNZ    DISP1        ; Count down
  452.     POP    BC        ; Get B back
  453.     LD    C,(HL)        ; Get count of devices
  454.     LD    A,C        ; Check for none
  455.     OR    A
  456.     JR    Z,DISP3
  457.  
  458. DISP2:    PUSH    BC        ; Save values
  459.     DEC    C        ; Point to next name
  460.     CALL    PRINT
  461.     DB    CR,LF,'    ',0
  462.     CALL    PNAMER        ; Print name (B=logical, C=physical)
  463.     POP    BC        ; Get count
  464.     DEC    C        ; Count down
  465.     JR    NZ,DISP2
  466.  
  467. DISP3:    POP    AF
  468.     POP    HL
  469.     RET
  470. ;
  471. ; Routine to Print Name of Selected Device
  472. ;    B=logical number, C=physical number
  473. ;
  474. PNAMER:    PUSH    BC        ; Save BC
  475.     CALL    PNAME0        ; Print first part of name
  476.     CALL    PRINT        ; Print separator
  477.     DB    ' - ',0
  478.     CALL    PSTR        ; Print rest as string
  479.     POP    BC        ; Restore BC
  480.     RET
  481. ;
  482. ; Print first part of selected device name
  483. ;
  484. PNAME0:    CALL    NAMER        ; Get ptr to string
  485.     LD    B,8        ; At most 8 chars
  486. PNAME1:    LD    A,(HL)        ; Get char
  487.  
  488.     INC    HL        ; Pt to next char
  489.     CP    ' '        ; End of name?
  490.     JR    Z,PNAME2
  491.     CALL    COUT        ; Print char
  492.     DJNZ    PNAME1        ; Count down
  493.     RET
  494.  
  495. PNAME2:    LD    A,' '        ; Print spaces
  496.     CALL    COUT
  497.     DJNZ    PNAME2        ; Count down
  498.     RET
  499. ;
  500. ; Basic Interface Routines
  501. ;
  502. STATUS:    LD    DE,0        ; Offset 0
  503.  
  504. RUNIT:    CALL    GETIOP        ; Device driver base
  505.     ADD    HL,DE
  506.     JP    (HL)
  507.  
  508. SELECT:    LD    DE,3        ; Offset 3
  509.     JR    RUNIT
  510.  
  511. NAMER:    LD    DE,6        ; Offset 6
  512.     JR    RUNIT
  513. ;
  514. ; Print actual COMfile name if possible, otherwise print "DEV"
  515. ;
  516. COMNAM:    CALL    GETEFCB
  517.     JR    Z,NOEFCB
  518.     LD    B,8
  519.  
  520. COMNLP:    INC    HL
  521.     LD    A,(HL)
  522.     AND    7FH
  523.     CP    ' '
  524.     CALL    NZ,COUT
  525.     DJNZ    COMNLP
  526.     RET
  527.  
  528. NOEFCB:    CALL    PRINT
  529.     DB    'DEV',0
  530.     RET
  531. ;
  532. ;  Buffers
  533. ;
  534.     DSEG
  535.  
  536. LOGICAL:DS    1        ; Logical Device Number
  537. NAME:    DS    2        ; Pointer to User-Supplied Name
  538.  
  539.     END
  540.