home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol101 / tinit.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  11.9 KB  |  643 lines

  1. ;
  2. ;  PROGRAM:  TINIT
  3. ;  VERSION:  2.0
  4. ;  AUTHOR:  RICHARD CONN
  5. ;  DERIVATION:  TINIT.C, VERSION 1.1
  6. ;  PREVIOUS VERSIONS:  None
  7. ;
  8. vers    equ    20
  9.  
  10. ;
  11. ;    TINIT inits the TVI 950 terminal from a config file, optionally
  12. ; specified by the user.  The Config file is created by CONFIG.  TINIT
  13. ; will search along the command-search path for an indicated or default
  14. ; file, load it, and program the TVI 950 from it.
  15. ;
  16. ;    TINIT is invoked by the following forms:
  17. ;        TINIT        <-- Program using STD.CFG
  18. ;        TINIT file    <-- Program using file.CFG
  19. ;        TINIT file.typ    <-- Program using file.typ
  20. ;        TINIT //    <-- Print Help Message
  21. ;
  22.  
  23. ;
  24. ;  CP/M Constants
  25. ;
  26. cpm    equ    0    ; base of system
  27. fcb    equ    cpm+5ch
  28. tbuff    equ    cpm+80h
  29. cr    equ    0dh
  30. lf    equ    0ah
  31. esc    equ    1bh    ; ESCAPE code for CRT Programming
  32. delay    equ    200h    ; long delay for TVI 950 to accept command
  33. tablen    equ    80    ; length of tab buffer
  34. ullen    equ    81    ; length of user line buffer
  35. fkeylen    equ    464    ; length of function key buffer
  36.  
  37. ;
  38. ;  SYSLIB Routines
  39. ;
  40.     ext    zpfind,zgpins,cin,cout,crlf,print,pause,moveb
  41.     ext    getud,logud,putud
  42.     ext    codend,initfcb,fi0$open,f0$get,fi0$close
  43.  
  44. ;
  45. ;  TVI 950 Commands
  46. ;
  47. clear    equ    '+'    ; clear screen
  48.  
  49. fctkey    equ    '|'    ; begin function key defn
  50. fctend    equ    'Y'-'@'    ; end function key defn
  51.  
  52. loadusr    equ    'f'    ; load user line
  53. dispusr    equ    'g'    ; display user line
  54.  
  55. sscroll    equ    '8'    ; smooth scroll
  56. hscroll    equ    '9'    ; hard scroll
  57.  
  58. tabclr    equ    '3'    ; all tab clear
  59. tabset    equ    '1'    ; set tab at cursor
  60.  
  61. vidnorm    equ    'd'    ; normal video
  62. vidrev    equ    'b'    ; reverse video
  63.  
  64. clkon    equ    '>'    ; key click on
  65. clkoff    equ    '<'    ; key click off
  66.  
  67. curs    equ    '.'    ; define cursor type
  68.  
  69. ;
  70. ;  General Init Settings
  71. ;
  72. cls    equ    '+'    ; clear screen
  73. unlock    equ    '"'    ; unlock keyboard
  74. nograph    equ    '%'    ; no graphics
  75. noprot    equ    27h    ; protect mode off
  76. normi    equ    '('    ; normal intensity
  77. notabs    equ    '3'    ; clear all tabs
  78. noclick    equ    '<'    ; key click off
  79. nocopy    equ    'A'    ; copy print mode off
  80. cmode    equ    'C'    ; conversation mode on
  81. fdx    equ    'F'    ; full duplex
  82. nomonit    equ    'X'    ; clear monitor mode
  83. nobufpr    equ    'a'    ; buffer print off
  84. vid1    equ    'd'    ; white on black
  85. nopage    equ    'w'    ; auto page off
  86.  
  87. ;
  88. ;    This program is Copyright (c) 1982, 1983 by Richard Conn
  89. ;    All Rights Reserved
  90. ;
  91. ;    ZCPR2 and its utilities, including this one, are released
  92. ; to the public domain.  Anyone who wishes to USE them may do so with
  93. ; no strings attached.  The author assumes no responsibility or
  94. ; liability for the use of ZCPR2 and its utilities.
  95. ;
  96. ;    The author, Richard Conn, has sole rights to this program.
  97. ; ZCPR2 and its utilities may not be sold without the express,
  98. ; written permission of the author.
  99. ;
  100.  
  101. ;
  102. ;  Branch to Start of Program
  103. ;
  104.     jmp    start
  105.  
  106. ;
  107. ;******************************************************************
  108. ;
  109. ;  SINSFORM -- ZCPR2 Utility Standard General Purpose Initialization Format
  110. ;
  111. ;    This data block precisely defines the data format for
  112. ; initial features of a ZCPR2 system which are required for proper
  113. ; initialization of the ZCPR2-Specific Routines in SYSLIB.
  114. ;
  115.  
  116. ;
  117. ;  EXTERNAL PATH DATA
  118. ;
  119. EPAVAIL:
  120.     DB    0FFH    ; IS EXTERNAL PATH AVAILABLE? (0=NO, 0FFH=YES)
  121. EPADR:
  122.     DW    40H    ; ADDRESS OF EXTERNAL PATH IF AVAILABLE
  123.  
  124. ;
  125. ;  INTERNAL PATH DATA
  126. ;
  127. INTPATH:
  128.     DB    0,0    ; DISK, USER FOR FIRST PATH ELEMENT
  129.             ; DISK = 1 FOR A, '$' FOR CURRENT
  130.             ; USER = NUMBER, '$' FOR CURRENT
  131.     DB    0,0
  132.     DB    0,0
  133.     DB    0,0
  134.     DB    0,0
  135.     DB    0,0
  136.     DB    0,0
  137.     DB    0,0    ; DISK, USER FOR 8TH PATH ELEMENT
  138.     DB    0    ; END OF PATH
  139.  
  140. ;
  141. ;  MULTIPLE COMMAND LINE BUFFER DATA
  142. ;
  143. MCAVAIL:
  144.     DB    0FFH    ; IS MULTIPLE COMMAND LINE BUFFER AVAILABLE?
  145. MCADR:
  146.     DW    0FF00H    ; ADDRESS OF MULTIPLE COMMAND LINE BUFFER IF AVAILABLE
  147.  
  148. ;
  149. ;  DISK/USER LIMITS
  150. ;
  151. MDISK:
  152.     DB    4    ; MAXIMUM NUMBER OF DISKS
  153. MUSER:
  154.     DB    31    ; MAXIMUM USER NUMBER
  155.  
  156. ;
  157. ;  FLAGS TO PERMIT LOG IN FOR DIFFERENT USER AREA OR DISK
  158. ;
  159. DOK:
  160.     DB    0FFH    ; ALLOW DISK CHANGE? (0=NO, 0FFH=YES)
  161. UOK:
  162.     DB    0FFH    ; ALLOW USER CHANGE? (0=NO, 0FFH=YES)
  163.  
  164. ;
  165. ;  PRIVILEGED USER DATA
  166. ;
  167. PUSER:
  168.     DB    10    ; BEGINNING OF PRIVILEGED USER AREAS
  169. PPASS:
  170.     DB    'chdir',0    ; PASSWORD FOR MOVING INTO PRIV USER AREAS
  171.     DS    41-($-PPASS)    ; 40 CHARS MAX IN BUFFER + 1 for ending NULL
  172.  
  173. ;
  174. ;  CURRENT USER/DISK INDICATOR
  175. ;
  176. CINDIC:
  177.     DB    '$'    ; USUAL VALUE (FOR PATH EXPRESSIONS)
  178.  
  179. ;
  180. ;  DMA ADDRESS FOR DISK TRANSFERS
  181. ;
  182. DMADR:
  183.     DW    80H    ; TBUFF AREA
  184.  
  185. ;
  186. ;  NAMED DIRECTORY INFORMATION
  187. ;
  188. NDRADR:
  189.     DW    00000H    ; ADDRESS OF MEMORY-RESIDENT NAMED DIRECTORY
  190. NDNAMES:
  191.     DB    64    ; MAX NUMBER OF DIRECTORY NAMES
  192. DNFILE:
  193.     DB    'NAMES   '    ; NAME OF DISK NAME FILE
  194.     DB    'DIR'        ; TYPE OF DISK NAME FILE
  195.  
  196. ;
  197. ;  REQUIREMENTS FLAGS
  198. ;
  199. EPREQD:
  200.     DB    0FFH    ; EXTERNAL PATH?
  201. MCREQD:
  202.     DB    000H    ; MULTIPLE COMMAND LINE?
  203. MXREQD:
  204.     DB    000H    ; MAX USER/DISK?
  205. UDREQD:
  206.     DB    000H    ; ALLOW USER/DISK CHANGE?
  207. PUREQD:
  208.     DB    000H    ; PRIVILEGED USER?
  209. CDREQD:
  210.     DB    0FFH    ; CURRENT INDIC AND DMA?
  211. NDREQD:
  212.     DB    000H    ; NAMED DIRECTORIES?
  213. Z2CLASS:
  214.     DB    7    ; CLASS 7
  215.     DB    'ZCPR2'
  216.     DS    10    ; RESERVED
  217.  
  218. ;
  219. ;  END OF SINSFORM -- STANDARD DEFAULT PARAMETER DATA
  220. ;
  221. ;******************************************************************
  222. ;
  223.  
  224. ;
  225. ;  Default Name of CFG File
  226. ;
  227. speed:
  228.     db    4        ; 4 MHz
  229. cfgfile:
  230.     db    'STD     '    ; may be changed by GENINS
  231.     db    'CFG'
  232.  
  233. ;
  234. ;  Start of Program
  235. ;
  236. start:
  237.     call    zgpins    ; init ZCPR2 buffers
  238.  
  239.     call    print
  240.     db    'TINIT  Version '
  241.     db    (vers/10)+'0','.',(vers mod 10)+'0',0
  242.  
  243. ;
  244. ;  Allocate Buffer Space
  245. ;
  246.     call    codend        ; get start of buffer
  247.     shld    ulbuffer    ; start of underline buffer
  248.     lxi    d,ullen        ; buffer is ullen bytes
  249.     dad    d
  250.     shld    tabbuffer    ; start of tab buffer
  251.     lxi    d,tablen    ; buffer is tablen bytes
  252.     dad    d
  253.     shld    fkeybuffer    ; start of function key buffer
  254.  
  255. ;
  256. ;  Copy Default File Name into FCB
  257. ;
  258.     lxi    h,cfgfile    ; pt to default name
  259.     lxi    d,cfgfcb+1    ; pt to FCB
  260.     mvi    b,11        ; 11 bytes
  261.     call    moveb
  262.  
  263. ;
  264. ;  Check for file name
  265. ;
  266.     lda    fcb+1    ; check for file name
  267.     cpi    ' '    ; <SP> if none
  268.     jz    program    ; program from default FCB
  269.     cpi    '/'    ; help?
  270.     jnz    start1
  271.  
  272. ;
  273. ;  Print Help Message
  274. ;
  275.     call    print
  276.     db    cr,lf,'    TINIT is used to program a TVI 950 CRT from a'
  277.     db    cr,lf,'Configuration File (CFG File) created by the CONFIG'
  278.     db    cr,lf,'Program.  TINIT is invoked in the following ways --'
  279.     db    cr,lf
  280.     db    cr,lf,'        TINIT        <-- Program from Default'
  281.     db    cr,lf,'        TINIT file    <-- Pgm from file.CFG'
  282.     db    cr,lf,'        TINIT file.typ    <-- Pgm from file.typ'
  283.     db    cr,lf,'        TINIT //    <-- Print Help'
  284.     db    cr,lf,0
  285.     ret
  286.  
  287. ;
  288. ;  Process File Name
  289. ;
  290. start1:
  291.     lxi    h,fcb+1        ; copy file name part
  292.     lxi    d,cfgfcb+1    ; copy into CFGFCB
  293.     mvi    b,8        ; 8 bytes
  294.     call    moveb
  295.     lxi    h,fcb+9        ; pt to file type
  296.     lxi    d,cfgfcb+8    ; prepare to copy file type
  297.     mvi    b,3        ; 3 bytes
  298.     mov    a,m        ; any specified?
  299.     cpi    ' '        ; default type if space
  300.     cnz    moveb
  301.  
  302. ;
  303. ;  Load Config File and Program TVI 950
  304. ;
  305. program:
  306.     lxi    d,cfgfcb    ; pt to fcb
  307.     call    initfcb        ; init it
  308.     mvi    b,0ffh        ; search current dir first
  309.     call    zpfind        ; look for file
  310.     jnz    prog1
  311.     call    print
  312.     db    cr,lf,'Configuration File ',0
  313.     xchg            ; HL pts to config file
  314.     inx    h        ; pt to file name
  315.     call    prfn        ; print name
  316.     call    print
  317.     db    ' Not Found',0
  318.     jmp    cpm
  319.  
  320. ;
  321. ;  Load File Buffer into Files
  322. ;
  323. prog1:
  324.     call    print
  325.     db    cr,lf,'Programming TVI 950 from File ',0
  326.     mov    h,d        ; ptr to fcb in HL also
  327.     mov    l,e
  328.     inx    h
  329.     call    prfn        ; print file name
  330.     call    crlf        ; new line
  331.     call    putud
  332.     call    logud        ; log into directory
  333.     call    fi0$open    ; open file for input
  334.     call    getch        ; read char
  335.     sta    cursor        ; set cursor type
  336.     call    getch
  337.     sta    ffkeys        ; set function key flag
  338.     call    getch
  339.     sta    click        ; set key click
  340.     call    getch
  341.     sta    scroll        ; set scrolling
  342.     call    getch
  343.     sta    ftabs        ; set tab program flag
  344.     call    getch
  345.     sta    fuline        ; set user line program flag
  346.     call    getch
  347.     sta    video        ; set video type
  348.     call    getch        ; flush <CR> <LF>
  349.     call    getch
  350.     lhld    ulbuffer    ; load user line if specified
  351.     lxi    d,ullen        ; size of buffer
  352.     lda    fuline
  353.     ora    a        ; 0=no
  354.     cnz    readbuffer    ; read buffer if yes
  355.     lhld    tabbuffer    ; load tab line if specified
  356.     lxi    d,tablen    ; size of buffer
  357.     lda    ftabs
  358.     ora    a
  359.     cnz    readbuffer
  360.     lhld    fkeybuffer    ; program function keys if specified
  361.     lxi    d,fkeylen    ; size of buffer
  362.     lda    ffkeys
  363.     ora    a
  364.     cnz    readbuffer
  365.     call    fi0$close    ; close file
  366.     call    getud        ; restore original user/disk
  367.  
  368. ;
  369. ;  Send Out All Terminial Initializations
  370. ;
  371.     mvi    a,unlock    ; unlock keyboard
  372.     call    cmnd
  373.     mvi    a,nograph    ; no graphics
  374.     call    cmnd
  375.     mvi    a,noprot    ; protect off
  376.     call    cmnd
  377.     mvi    a,normi        ; normal intensity
  378.     call    cmnd
  379.     mvi    a,notabs    ; no tabs
  380.     call    cmnd
  381.     mvi    a,noclick    ; no key click
  382.     call    cmnd
  383.     mvi    a,nocopy    ; no copy print mode
  384.     call    cmnd
  385.     mvi    a,cmode        ; conversation mode on
  386.     call    cmnd
  387.     mvi    a,fdx        ; full duplex
  388.     call    cmnd
  389.     mvi    a,nomonit    ; no monitor mode
  390.     call    cmnd
  391.     mvi    a,nobufpr    ; no buffer print
  392.     call    cmnd
  393.     mvi    a,vid1        ; white on black
  394.     call    cmnd
  395.     mvi    a,nopage    ; auto page off
  396.     call    cmnd
  397.     lxi    h,videom    ; normal video
  398.     call    cmnds
  399.     lxi    h,insert    ; set insert char to space
  400.     call    cmnds
  401. ;
  402. ;  Program Cursor Type
  403. ;
  404.     mvi    a,curs
  405.     call    cmnd
  406.     lda    cursor        ; cursor type
  407.     call    cout
  408. ;
  409. ;  Program Function Keys
  410. ;
  411.     lda    ffkeys        ; any function keys?
  412.     ora    a        ; 0=no
  413.     jz    setclick
  414.     mvi    b,22        ; 22 keys to program
  415.     lhld    fkeybuffer    ; pt to buffer
  416.     mvi    a,'1'        ; set for first function key
  417.     sta    fkey
  418. nxtkey:
  419.     mov    a,m        ; get first char
  420.     ora    a        ; no string?
  421.     jz    nkey1
  422.     push    h        ; save ptr to first char
  423.     mvi    a,fctkey    ; function key follows
  424.     call    cmnd
  425.     lda    fkey        ; print function key
  426.     call    cout
  427.     call    pstr        ; print string pted to by HL
  428.     mvi    a,fctend    ; end function
  429.     call    cout
  430.     pop    h        ; get ptr to first char
  431. nkey1:
  432.     lxi    d,20        ; pt to next function key
  433.     dad    d
  434.     lda    fkey        ; increment function key
  435.     inr    a
  436.     sta    fkey
  437.     dcr    b        ; count down
  438.     jnz    nxtkey
  439.     call    sleep
  440.  
  441. ;
  442. ;  Set Key Click
  443. ;
  444. setclick:
  445.     lda    click        ; from file
  446.     call    cmnd
  447.  
  448. ;
  449. ;  Set Scrolling
  450. ;
  451.     lda    scroll        ; from file
  452.     call    cmnd
  453.  
  454. ;
  455. ;  Set Tabs
  456. ;
  457.     lda    ftabs        ; set tabs?
  458.     ora    a        ; 0=no
  459.     jz    setul
  460.     mvi    a,tabclr    ; clear all tab stops
  461.     call    cmnd
  462.     call    crlf        ; new line
  463.     lhld    tabbuffer    ; pt to buffer
  464.     mvi    b,tablen    ; tablen chars in buffer
  465. settabs:
  466.     mov    a,m        ; get buffer char
  467.     inx    h        ; pt to next
  468.     cpi    '.'        ; dot means set tab here
  469.     jnz    stabs1
  470.     mvi    a,tabset    ; set tab
  471.     call    cmnd
  472. stabs1:
  473.     mvi    a,' '        ; space over
  474.     call    cout
  475.     dcr    b        ; count down
  476.     jnz    settabs
  477.     call    crlf        ; new line
  478.  
  479. ;
  480. ;  Set User Line
  481. ;
  482. setul:
  483.     lda    fuline        ; get flag
  484.     ora    a        ; 0=no
  485.     jz    setvideo
  486.     mvi    a,loadusr    ; load user line
  487.     call    cmnd
  488.     lhld    ulbuffer    ; print buffer contents
  489.     call    pstr
  490.     mvi    a,cr        ; send just <CR>
  491.     call    cout
  492.     mvi    a,dispusr    ; display user line
  493.     call    cmnd
  494.     call    sleep
  495. ;
  496. ;  Set Video
  497. ;
  498. setvideo:
  499.     lda    video        ; get command
  500.     call    cmnd
  501.  
  502. ;
  503. ;  Done -- Clear Screen and Return to OS
  504. ;
  505.     mvi    a,cls        ; clear screen
  506.     call    cmnd
  507.     ret
  508.  
  509. ;
  510. ;  Write Single-Char Command in A
  511. ;
  512. cmnd:
  513.     push    psw        ; save command
  514.     mvi    a,esc
  515.     call    cout        ; send ESC
  516.     pop    psw
  517.     call    cout        ; send char
  518.     push    h        ; save regs
  519.     push    psw
  520.     lxi    h,delay        ; long delay
  521. cmndl:
  522.     xthl            ; long command with no effect
  523.     xthl            ; ... if doubled
  524.     dcx    h        ; count down
  525.     mov    a,h
  526.     ora    l
  527.     jnz    cmndl
  528.     pop    psw        ; restore regs
  529.     pop    h
  530.     ret
  531.  
  532. ;
  533. ;  Write String Command pted to by HL
  534. ;
  535. cmnds:
  536.     mvi    a,esc        ; send ESC
  537.     call    cout        ; and fall thru to pstr
  538. ;
  539. ;  Write String Pted to by HL
  540. ;
  541. pstr:
  542.     push    h        ; save HL
  543. pstr1:
  544.     mov    a,m        ; get char
  545.     ora    a        ; done?
  546.     jz    pstr2
  547.     inx    h        ; pt to next
  548.     call    cout        ; send char
  549.     jmp    pstr1
  550. pstr2:
  551.     pop    h        ; get HL
  552.     ret
  553. ;
  554. ;  Print File Name pted to by HL
  555. ;
  556. prfn:
  557.     push    b        ; save BC
  558.     mvi    b,8
  559.     call    prfn1        ; print name part
  560.     mvi    a,'.'
  561.     call    cout
  562.     mvi    b,3        ; print type
  563.     call    prfn1
  564.     pop    b        ; restore BC
  565.     ret
  566. prfn1:
  567.     mov    a,m        ; get char
  568.     call    cout        ; print char
  569.     inx    h        ; pt to next
  570.     dcr    b        ; count down
  571.     jnz    prfn1
  572.     ret
  573.  
  574. ;
  575. ;  Sleep 0.1 secs
  576. ;
  577. sleep:
  578.     push    h        ; save regs
  579.     push    b
  580.     push    psw
  581.     lda    speed        ; get processor speed
  582.     mov    b,a        ; ... in B
  583.     lxi    h,1        ; 0.1 secs
  584.     call    pause
  585.     pop    psw        ; restore regs
  586.     pop    b
  587.     pop    h
  588.     ret
  589.  
  590. ;
  591. ;  Get Char from File with Possible Abort
  592. ;
  593. getch:
  594.     call    f0$get        ; get char
  595.     rz            ; char OK
  596.     call    print
  597.     db    cr,lf,'File Read Error -- Aborting',0
  598.     jmp    cpm
  599.  
  600. ;
  601. ;  Read into buffer pted to by HL for DE bytes
  602. ;
  603. readbuffer:
  604.     call    getch        ; get byte from file
  605.     mov    m,a        ; put byte
  606.     inx    h        ; pt to next
  607.     dcx    d        ; count down
  608.     mov    a,d        ; done?
  609.     ora    e
  610.     jnz    readbuffer
  611.     call    getch        ; flush <CR> <LF>
  612.     jmp    getch
  613.  
  614. ;
  615. ;  Some Command Strings
  616. ;
  617. videom:
  618.     db    'G0',0
  619. insert:
  620.     db    'e ',0
  621.  
  622. ;
  623. ;  Buffers
  624. ;
  625. cursor:    ds    1
  626. fuline:    ds    1
  627. video:    ds    1
  628. ftabs:    ds    1
  629. fkey:    ds    1
  630. click:    ds    1
  631. scroll:    ds    1
  632. ffkeys:    ds    1
  633. ulbuffer:
  634.     ds    2    ; ptr
  635. tabbuffer:
  636.     ds    2    ; ptr
  637. fkeybuffer:
  638.     ds    2    ; ptr
  639. cfgfcb:
  640.     ds    36    ; FCB for config file
  641.  
  642.     end
  643.