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 / ZCPR2 / DEVICE.MAC < prev    next >
Text File  |  2000-06-30  |  13KB  |  624 lines

  1. ;
  2. ;  PROGRAM:  DEVICE2
  3. ;  AUTHOR:  RICHARD CONN
  4. ;  VERSION:  1.3
  5. ;  DATE:  6 Jan 83
  6. ;  PREVIOUS VERSION:  1.0 (29 Dec 82), 1.1 (2 Jan 83), 1.2 (5 Jan 83)
  7. ;
  8. VERS    EQU    13
  9.  
  10. ;
  11. ;    This program is Copyright (c) 1982, 1983 by Richard Conn
  12. ;    All Rights Reserved
  13. ;
  14. ;    ZCPR2 and its utilities, including this one, are released
  15. ; to the public domain.  Anyone who wishes to USE them may do so with
  16. ; no strings attached.  The author assumes no responsibility or
  17. ; liability for the use of ZCPR2 and its utilities.
  18. ;
  19. ;    The author, Richard Conn, has sole rights to this program.
  20. ; ZCPR2 and its utilities may not be sold without the express,
  21. ; written permission of the author.
  22. ;
  23.  
  24.  
  25. ;
  26. ;    DEVICE is a program which enables the user to manipulate the
  27. ; extended ZCPR2 redirectable device drivers.  It allows the user to
  28. ; perform the following functions:
  29. ;
  30. ;        o Display the Names of the Current Devices
  31. ;        o Set One or More of the Current Devices
  32. ;        o Ask for Help
  33. ;
  34. ;    The format of the DEVICE command is:
  35. ;
  36. ;        DEVICE or DEVICE //        <-- Ask for Help
  37. ;        DEVICE command,command,command ...    <-- Issue Commands
  38. ;
  39. ; where "command" may take the following forms:
  40. ;
  41. ;        DISPLAY ALL    <-- Display Names of All Devices
  42. ;        DISPLAY CON    <-- Display Names of Consoles
  43. ;        DISPLAY LST    <-- Display Names of Printers
  44. ;        DISPLAY RDR    <-- Display Names of Readers
  45. ;        DISPLAY PUN    <-- Display Names of Punches
  46. ;
  47. ;        CON:=name    <-- Select Console
  48. ;        LST:=name    <-- Select Printer
  49. ;        RDR:=name    <-- Select Reader
  50. ;        PUN:=name    <-- Select Punch
  51. ;
  52.  
  53. ;
  54. ;  Constants
  55. ;
  56. tbuff    equ    80h
  57. cr    equ    0dh
  58. lf    equ    0ah
  59.  
  60. ;
  61. ;  SYSLIB Routines
  62. ;
  63.     ext    cin,cout,pstr,print,cline,bbline
  64.  
  65. ;
  66. ;  Branch to Start of Program
  67. ;
  68.     jmp    start
  69.  
  70. ;
  71. ;******************************************************************
  72. ;
  73. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  74. ;
  75. ;    This data block precisely defines the data format for
  76. ; initial features of a ZCPR2 system which are required for proper
  77. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  78. ;
  79.  
  80. ;
  81. ;  EXTERNAL PATH DATA
  82. ;
  83. EPAVAIL:
  84.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  85. EPADR:
  86.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  87.  
  88. ;
  89. ;  INTERNAL PATH DATA
  90. ;
  91. INTPATH:
  92.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  93.             ; DISK = 1 FOR A, '$' FOR CURRENT
  94.             ; USER = NUMBER, '$' FOR CURRENT
  95.     DB    0,0
  96.     DB    0,0
  97.     DB    0,0
  98.     DB    0,0
  99.     DB    0,0
  100.     DB    0,0
  101.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  102.     DB    0    ; END OF PATH
  103.  
  104. ;
  105. ;  MULTIPLE COMMAND LINE BUFFER DATA
  106. ;
  107. MCAVAIL:
  108.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  109. MCADR:
  110.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  111.  
  112. ;
  113. ;  DISK/USER LIMITS
  114. ;
  115. MDISK:
  116.     DB    4    ; MAXIMUM NUMBER OF DISKS
  117. MUSER:
  118.     DB    31    ; MAXIMUM USER NUMBER
  119.  
  120. ;
  121. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  122. ;
  123. DOK:
  124.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  125. UOK:
  126.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  127.  
  128. ;
  129. ;  PRIVILEGED USER DATA
  130. ;
  131. PUSER:
  132.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  133. PPASS:
  134.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  135.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  136.  
  137. ;
  138. ;  CURRENT USER/DISK INDICATOR
  139. ;
  140. CINDIC:
  141.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  142.  
  143. ;
  144. ;  DMA ADDRESS FOR DISK TRANSFERS
  145. ;
  146. DMADR:
  147.     DW    80H    ; TBUFF AREA
  148.  
  149. ;
  150. ;  NAMED DIRECTORY INFORMATION
  151. ;
  152. NDRADR:
  153.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  154. NDNAMES:
  155.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  156. DNFILE:
  157.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  158.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  159.  
  160. ;
  161. ;  REQUIREMENTS FLAGS
  162. ;
  163. EPREQD:
  164.     DB    000H    ; EXTERNAL PATH?
  165. MCREQD:
  166.     DB    000H    ; MULTIPLE COMMAND LINE?
  167. MXREQD:
  168.     DB    000H    ; MAX USER/DISK?
  169. UDREQD:
  170.     DB    000H    ; ALLOW USER/DISK CHANGE?
  171. PUREQD:
  172.     DB    000H    ; PRIVILEGED USER?
  173. CDREQD:
  174.     DB    000H    ; CURRENT INDIC AND DMA?
  175. NDREQD:
  176.     DB    000H    ; NAMED DIRECTORIES?
  177. Z2CLASS:
  178.     DB    1    ; CLASS 1
  179.     DB    'ZCPR2'
  180.     DS    10    ; RESERVED
  181.  
  182. ;
  183. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  184. ;
  185. ;******************************************************************
  186. ;
  187.  
  188. ;
  189. ;  Other Parameter Data
  190. ;
  191. drvadr:
  192.     dw    0    ; Address of I/O Drivers
  193.  
  194. ;
  195. ;  Start of Program
  196. ;
  197. start:
  198.     call    print
  199.     db    'DEVICE2, Version '
  200.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  201.  
  202.     lhld    drvadr    ;check for initialization
  203.     mov    a,h
  204.     ora    l    ;must NOT be zero
  205.     jnz    start0
  206.     call    print
  207.     db    cr,lf,'DEVICE NOT Initialized with I/O Base -- Aborting',0
  208.     ret
  209.  
  210. start0:
  211.     call    status    ;check for drivers
  212.     jnz    start1
  213.     call    print
  214.     db    cr,lf,'Redirection Not Supported -- Aborting',0
  215.     ret
  216.  
  217. start1:
  218.     lxi    h,tbuff    ;pt to input buffer
  219.     call    cline    ;extract and save command line
  220.     call    sblank    ;skip to non-blank
  221.     ora    a    ;EOL?
  222.     jz    command    ;command mode
  223.     cpi    '/'    ;help?
  224.     jnz    docmd    ;run command subroutine
  225.  
  226. ;
  227. ;  Print Help Message
  228. ;
  229. help:
  230.     call    print
  231.     db    cr,lf,'    DEVICE is a program which enables the user to'
  232.     db    cr,lf,'manipulate the extended ZCPR2 redirectable device'
  233.     db    cr,lf,'drivers.  It allows the user to perform the following'
  234.     db    cr,lf,'functions:'
  235.     db    cr,lf,'        Display the Names of the Current Devices'
  236.     db    cr,lf,'        Set One or More of the Current Devices'
  237.     db    cr,lf,'    The format of the DEVICE command is:'
  238.     db    cr,lf,'        DEVICE                '
  239.     db    '<-- Enter Interactive Mode'
  240.     db    cr,lf,'        DEVICE //            '
  241.     db    '<-- Ask for Help'
  242.     db    cr,lf,'        DEVICE '
  243. help1:
  244.     db    'Command,Command, ...     '
  245.     db    '<-- Issue Commands'
  246.     db    cr,lf,'where "command" may take the following forms:'
  247.     db    cr,lf,'        DISPLAY=ALL    '
  248.     db    '<-- Display Names of All Devices'
  249.     db    cr,lf,'        DISPLAY=CON    '
  250.     db    '<-- Display Names of Consoles'
  251.     db    cr,lf,'        DISPLAY=LST    '
  252.     db    '<-- Display Names of Printers'
  253.     db    cr,lf,'        DISPLAY=RDR    '
  254.     db    '<-- Display Names of Readers'
  255.     db    cr,lf,'        DISPLAY=PUN    '
  256.     db    '<-- Display Names of Punches'
  257.     db    cr,lf
  258.     db    cr,lf,'        CON:=name    <-- Select Console'
  259.     db    cr,lf,'        LST:=name    <-- Select Printer'
  260.     db    cr,lf,'        RDR:=name    <-- Select Reader'
  261.     db    cr,lf,'        PUN:=name    <-- Select Punch'
  262.     db    cr,lf,0
  263.     ret
  264. ;
  265. ;  Skip to Non-Blank Routine
  266. ;
  267. sblank:
  268.     mov    a,m    ;get char
  269.     inx    h    ;pt to next
  270.     cpi    ' '    ;blank?
  271.     jz    sblank    ;continue if so
  272.     dcx    h    ;pt to non-blank
  273.     ret
  274.  
  275. ;
  276. ;  Skip until a delimiter encountered
  277. ;
  278. sdelm:
  279.     mov    a,m    ;get char
  280.     inx    h    ;pt to next
  281.     cpi    ' '+1    ;<SP> or less?
  282.     rc
  283.     cpi    '='
  284.     rz
  285.     cpi    ','
  286.     rz
  287.     cpi    ';'
  288.     rz
  289.     jmp    sdelm
  290.  
  291. ;
  292. ;  COMMAND -- This is an interactive mainline which allows user input,
  293. ;    runs command lines via DOCMD, and permits Help and Comments
  294. ;
  295. command:
  296.     call    print
  297.     db    cr,lf,'DEVICE2 Interactive Command System'
  298.     db    cr,lf,'Type ? and Strike RETURN for Help'
  299.     db    0
  300. cloop:
  301.     call    print
  302.     db    cr,lf,'DEVICE2 Command? ',0
  303.     mvi    a,0ffh    ;capitalize
  304.     call    bbline
  305.     call    sblank    ;skip to non-blank
  306.     mov    a,m    ;empty line?
  307.     ora    a    ;0=yes
  308.     jz    cloop
  309.     cpi    '?'    ;help?
  310.     jz    chelp
  311.     cpi    ';'    ;comment?
  312.     jz    cloop
  313.     cpi    'X'    ;done?
  314.     rz
  315.     call    docmd    ;run command line
  316.     jmp    cloop
  317. chelp:
  318.     call    print
  319.     db    cr,lf,'DEVICE2 Commands are of the form:',cr,lf,0
  320.     lxi    h,help1
  321.     call    pstr
  322.     call    print
  323.     db    cr,lf,'A command line beginning with a semicolon (;) is a'
  324.     db    ' comment.'
  325.     db    cr,lf,'The X Command Exits DEVICE2.'
  326.     db    cr,lf,0
  327.     jmp    cloop
  328.  
  329. ;
  330. ;  DOCMD -- This subroutine processes the command line pted to by HL.
  331. ;    It is the Main Line if a DEVICE command line is given, it is just
  332. ;    a subroutine if the user is in interactive mode.
  333. ;
  334. docmd:
  335.     call    docmd1    ;do first command
  336.     call    sdelm    ;skip to delim
  337.     cpi    ','    ;another command?
  338.     jz    docmd
  339.     cpi    ';'    ;another also?
  340.     jz    docmd
  341.     ret
  342. docmd1:
  343.     mov    a,m    ;get command letter
  344.     cpi    'C'    ;console assignment?
  345.     jz    docon
  346.     cpi    'D'    ;display?
  347.     jz    dodisp
  348.     cpi    'L'    ;LST:?
  349.     jz    dolst
  350.     cpi    'P'    ;PUN:?
  351.     jz    dopun
  352.     cpi    'R'    ;RDR:?
  353.     jz    dordr
  354. cerr:
  355.     call    print
  356.     db    cr,lf,'Command Error at -- ',0
  357.     call    pstr    ;print rest
  358.     ret
  359.  
  360. ;
  361. ;  Do LST: Assignment
  362. ;
  363. dolst:
  364.     mvi    a,3    ;select LST:
  365.     jmp    assign
  366.  
  367. ;
  368. ;  Do PUN: Assignment
  369. ;
  370. dopun:
  371.     mvi    a,2    ;select PUN:
  372.     jmp    assign
  373.  
  374. ;
  375. ;  Do RDR: Assignment
  376. ;
  377. dordr:
  378.     mvi    a,1    ;select RDR:
  379.     jmp    assign
  380.  
  381. ;
  382. ;  Do CON: Assignment
  383. ;
  384. docon:
  385.     mvi    a,0    ;select console
  386. ;
  387. ;  Do Assignment in General
  388. ;
  389. assign:
  390.     mov    b,a    ;save A in B
  391.     push    b    ;save BC
  392.     call    sdelm    ;skip to delimiter
  393.     pop    b    ;get BC
  394.     cpi    ' '
  395.     jz    asgn0
  396.     cpi    '='
  397.     jnz    cerr
  398. asgn0:
  399.     mov    a,b    ;get A back
  400.     sta    logical    ;save logical device number
  401.     shld    name    ;save ptr to mnemonic
  402.     mov    b,a    ;number in B
  403.     inr    b    ;add 1 for offset
  404.     call    status    ;get device status
  405.     dcx    h    ;pt to previous
  406.     dcx    h
  407. asgn1:
  408.     inx    h    ;pt to next
  409.     inx    h
  410.     dcr    b    ;count down
  411.     jnz    asgn1
  412.     mov    c,m    ;get number of devices in C
  413.     mov    a,c    ;check for value of zero
  414.     ora    a
  415.     jnz    asgn2
  416.     lhld    name    ;pt to error name
  417.     jmp    cerr
  418. asgn2:
  419.     lda    logical    ;get logical device number
  420.     mov    b,a    ;... in B
  421.     push    b    ;save device count
  422.     dcr    c    ;pt to previous
  423.     call    namer    ;get name
  424.     xchg        ;name pted to by DE
  425.     lhld    name    ;user's name pted to by HL
  426. asgn3:
  427.     ldax    d    ;get name of device
  428.     cpi    ' '+1    ;done?
  429.     jc    asgn3a
  430.     cmp    m    ;compare to user
  431.     jnz    asgn4
  432.     inx    h    ;pt to next
  433.     inx    d
  434.     jmp    asgn3
  435. asgn3a:
  436.     mov    a,m    ;get user
  437.     cpi    ' '+1    ;done?
  438.     jc    asgn3b
  439.     cpi    ','    ;done?
  440.     jnz    asgn4
  441. asgn3b:
  442.     pop    b    ;match -- C-1 is selected device
  443.     dcr    c    ;decrement
  444.     call    select    ;select device
  445.     lhld    name    ;pt to name for scan continuation
  446.     ret
  447. asgn4:
  448.     pop    b    ;count down
  449.     dcr    c    ;count down
  450.     jnz    asgn2    ;continue
  451.     lhld    name    ;pt to invalid name
  452.     call    print
  453.     db    cr,lf,'Invalid Name Assignment at -- ',0
  454.     call    pstr
  455.     lhld    name    ;pt to name for scan continuation
  456.     ret
  457.  
  458. ;
  459. ;  Display Devices and Assignments
  460. ;
  461. dodisp:
  462.     call    sdelm    ;skip to delimiter
  463.     ora    a    ;none=all
  464.     jz    dispall
  465.     mov    a,m    ;get char after delimiter
  466.     cpi    'A'    ;all?
  467.     jz    dispall
  468.     cpi    'C'    ;CON:
  469.     jz    dispcon
  470.     cpi    'L'    ;LST:
  471.     jz    displst
  472.     cpi    'P'    ;PUN:
  473.     jz    disppun
  474.     cpi    'R'    ;RDR:
  475.     jz    disprdr
  476.     jmp    cerr
  477. dispall:
  478.     call    dispcon    ;successive displays
  479.     call    disprdr
  480.     call    print
  481.     db    cr,lf,'Strike Any Key to Continue -- ',0
  482.     call    cin
  483.     call    disppun
  484.     jmp    displst
  485. dispcon:
  486.     call    print
  487.     db    cr,lf,cr,lf,'CON: Devices --',0
  488.     mvi    a,0    ;select CON:
  489.     call    disp
  490.     jmp    current
  491. displst:
  492.     call    print
  493.     db    cr,lf,cr,lf,'LST: Devices --',0
  494.     mvi    a,3    ;select LST:
  495.     call    disp
  496.     jmp    current
  497. disprdr:
  498.     call    print
  499.     db    cr,lf,cr,lf,'RDR: Devices --',0
  500.     mvi    a,1    ;select RDR:
  501.     call    disp
  502.     jmp    current
  503. disppun:
  504.     call    print
  505.     db    cr,lf,cr,lf,'PUN: Devices --',0
  506.     mvi    a,2    ;select PUN:
  507.     call    disp
  508. ;
  509. ;  Print Name of Current Device
  510. ;
  511. current:
  512.     push    h    ;save ptr
  513.     mov    b,a    ;save number in B
  514.     push    b    ;save B
  515.     call    print
  516.     db    cr,lf,'  Current Assignment: ',0
  517.     push    b    ;save B
  518.     call    status    ;get status
  519.     pop    b    ;get B
  520.     inr    b    ;add 1 for offset
  521.     dcx    h    ;back up
  522. curr:
  523.     inx    h    ;pt to next
  524.     inx    h
  525.     dcr    b    ;count down
  526.     jnz    curr
  527.     pop    b    ;get logical number in B
  528.     mov    c,m    ;get physical number in C
  529.     call    pname0    ;print first part of name only
  530.     pop    h    ;get ptr
  531.     ret
  532. ;
  533. ;  Print Names of All Physical Devices for a Logical Device
  534. ;
  535. disp:
  536.     push    h    ;save char ptr
  537.     push    psw    ;save device number
  538.     mov    b,a    ;logical device in B
  539.     push    b    ;save for later
  540.     push    b    ;save it
  541.     call    status    ;get status report
  542.     pop    b    ;get logical device number
  543.     inr    b    ;add 1 for offset
  544.     dcx    h    ;back up
  545.     dcx    h
  546. disp1:
  547.     inx    h    ;pt to next
  548.     inx    h
  549.     dcr    b    ;count down
  550.     jnz    disp1
  551.     pop    b    ;get B back
  552.     mov    c,m    ;get count of devices
  553. disp2:
  554.     push    b    ;save values
  555.     dcr    c    ;pt to next name
  556.     call    print
  557.     db    cr,lf,'    ',0
  558.     call    pnamer    ;print name (B=logical, C=physical)
  559.     pop    b    ;get count
  560.     dcr    c    ;count down
  561.     jnz    disp2
  562.     pop    psw
  563.     pop    h
  564.     ret
  565. ;
  566. ;  Routine to Print Name of Selected Device
  567. ;    B=logical number, C=physical number
  568. ;
  569. pnamer:
  570.     push    b    ;save BC
  571.     call    pname0    ;print first part of name
  572.     call    print    ;print separator
  573.     db    ' - ',0
  574.     call    pstr    ;print rest as string
  575.     pop    b    ;restore BC
  576.     ret
  577. ;
  578. ;  Print first part of selected device name
  579. ;
  580. pname0:
  581.     call    namer    ;get ptr to string
  582.     mvi    b,8    ;at most 8 chars
  583. pname1:
  584.     mov    a,m    ;get char
  585.     inx    h    ;pt to next char
  586.     cpi    ' '    ;end of name?
  587.     jz    pname2
  588.     call    cout    ;print char
  589.     dcr    b    ;count down
  590.     jnz    pname1
  591.     ret
  592. pname2:
  593.     mvi    a,' '    ;print spaces
  594.     call    cout
  595.     dcr    b    ;count down
  596.     jnz    pname2
  597.     ret
  598.  
  599. ;
  600. ;  Basic Interface Routines
  601. ;
  602. status:
  603.     lxi    d,0    ;Offset 0
  604. runit:
  605.     lhld    drvadr    ;device driver base
  606.     dad    d
  607.     pchl
  608. select:
  609.     lxi    d,3    ;Offset 3
  610.     jmp    runit
  611. namer:
  612.     lxi    d,6    ;Offset 6
  613.     jmp    runit
  614.  
  615. ;
  616. ;  Buffers
  617. ;
  618. logical:
  619.     ds    1    ;Logical Device Number
  620. name:
  621.     ds    2    ;Pointer to User-Supplied Name
  622.  
  623.     end
  624.