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 / JSAGE / ZSUS / PROGPACK / TCSRC14.LBR / TCSRC14.ZZ0 / TCSRC14.Z8°
Text File  |  2000-06-30  |  23KB  |  1,038 lines

  1. ; ZCPR3 Z3TCAP (MYTERM.Z3T) file to source code (MYTERM.Z80) generator
  2. ; Program Name:  TCSRC.Z80
  3. ; Author:  Terry Hazen
  4. ; Version:  1.3
  5. ; Date:  24 August 90
  6.  
  7. ; Takes specified Z3TCAP (MYTERM.Z3T) file and creates commented
  8. ; source code (MYTERM.Z80) file for editing or customizing.
  9.  
  10. VERS    EQU    14        ; 24 August 90  jth
  11.  
  12. ; Revised to change the command interface and the name of the default
  13. ; environmental TCAP file from Z3ENV.Z80 to Z3TCAP.Z80 to be
  14. ; compatible with ENVSRC.COM.  Documentation now correctly describes
  15. ; the RC function.
  16.  
  17. ; vers    equ    13        ; 07 May 90  jth
  18. ; Revised to add ability to create blank source code file when infile
  19. ; is specified as BLANK.
  20.  
  21. ; vers    equ    12        ; 05 Feb 90  jth
  22. ; Revised to reflect changes in control string locations in VLIB4D,
  23. ; including replacing the last byte of the name string (now reduced to
  24. ; 13 bytes) by GOFF, the offset from the start of the Z3TCAP to the
  25. ; start of the graphics area at GOELD.    Also added the ability to
  26. ; generate source code from current the Z3TCAP in the environment by
  27. ; specifying 'Z3ENV' as the infile.
  28.  
  29. ; vers    equ    11        ; 26 Jan 90  jth
  30. ; Rewritten to do translation and loading in loops.  Fixed missing
  31. ; putud in help requests.  Added outfile specification, graphics
  32. ; support per VLIB4C.    Unless otherwise specified, the default
  33. ; outfile (INFILE.Z80) is now placed in the default directory.
  34.  
  35. ; vers    equ    10        ; 12 Jan 90  jth
  36. ; Original release.
  37.  
  38. ;
  39. ;  Basic equates
  40. ;
  41. FCB    EQU    5CH
  42. FCB2    EQU    6CH
  43. TBUFF    EQU    80H
  44. CTRLC    EQU    'C'-'@'
  45. ;
  46. ;  ASCII character equates
  47. ;
  48. NULL    EQU    0        ; Null
  49. BEL    EQU    7        ; Bell
  50. BS    EQU    8        ; Backspace
  51. TAB    EQU    9        ; Tab
  52. LF    EQU    10        ; Line feed
  53. CR    EQU    13        ; Carriage return
  54. EOF    EQU    1AH        ; EOF
  55. SPACE    EQU    32        ; Space
  56. ESC    EQU    27        ; Escape
  57. ;
  58. ; Z3LIB and SYSLIB references
  59. ;
  60.     .REQUEST    Z3LIB
  61.     EXT    Z3LOG
  62.  
  63.     .REQUEST    SYSLIB
  64.     EXT     CODEND,RETUD,COMPB,FILLB
  65.     EXT     MAFDC,MA2HC,PFN2,PRINT,COUT
  66.     EXT     GFA,F$OPEN,F$MAKE,F$READ,F$WRITE
  67.     EXT     F$CLOSE,F$EXIST,F$DELETE
  68.  
  69. ;
  70. ; Program start
  71. ;
  72.     JP    START
  73.     DB    'Z3ENV'        ; This is a ZCPR3 Utility
  74.     DB    1        ; External environmental descriptor
  75. Z3EADR:    DW    0
  76. ;
  77. START:    LD    (STACK),SP    ; Save CCP stack pointer
  78.     LD    SP,STACK    ; Local stack
  79.     LD    HL,EXIT        ; Save exit routine address
  80.     PUSH    HL        ; On the new stack
  81. ;
  82. ; Start of program -- display sign-on
  83. ;
  84.     CALL    PRINT
  85.     DB    'TCSRC vers '
  86.     DB    (VERS/10)+'0','.',(VERS    MOD 10)+'0',CR,LF
  87.     DB    'Creates a commented source code [.Z80] file',CR,LF
  88.     DB    'from the ZCPR3 environment or from '
  89.     DB    'a Z3TCAP[.Z3T] file.',CR,LF
  90.     DB    0
  91. ;
  92. ; Check for entry in FCB
  93. ;
  94.     LD    HL,FCB+1    ; Point to first character
  95.     LD    A,'/'
  96.     CP    (HL)        ; Help request?
  97.     JP    NZ,INIT        ; No
  98.     INC    HL        ; Point to next
  99.     CP    (HL)        ; Help request?
  100.     JP    NZ,INIT        ; No, continue
  101. ;
  102. ; Display help screen
  103. ;
  104. HELP:    CALL    PRINT
  105.     DB    CR,LF
  106.     DB    'Syntax:',TAB,'TCSRC '
  107.     DB    '[[dir:]infile[.Z3T]] [[dir:]outfile[.z80]]'
  108.     DB    CR,LF,LF
  109.     DB    TAB,'Default outfile name is infile.Z80.'
  110.     DB    CR,LF
  111.     DB    TAB,'Infile ''BLANK'' creates blank commented source code.'
  112.     DB    CR,LF
  113.     DB    TAB,'If no infile is specified, Z3TCAP.Z80 is created '
  114.     DB    CR,LF
  115.     DB    TAB,TAB,'from the environment.'
  116.     DB    CR,LF
  117.     DB    0
  118.     RET
  119. ;
  120. ; Initialize data area
  121. ;
  122. INIT:    XOR    A
  123.     LD    HL,DATA
  124.     LD    B,DATALEN
  125.     CALL    FILLB
  126. ;
  127. ; Set default infile file type if none
  128. ;
  129.     LD    DE,FCB+9    ; Point to file type
  130.     LD    A,(DE)        ; Get first character
  131.     CP    ' '        ; None if space
  132.     JR    NZ,LOAD1
  133. ;
  134.     LD    HL,INTYP    ; Point to default file type
  135.     LD    BC,3        ; File type length
  136.     LDIR            ; Otherwise set default filetype
  137. ;
  138. ; Check if infile specified
  139. ;
  140. LOAD1:    LD    A,(FCB+1)    ; Get first infile byte
  141.     CP    ' '        ; Anything?
  142.     JR    NZ,LOAD2    ; File specified, so continue
  143. ;
  144.     LD    HL,Z3TNAME    ; Point to default infile
  145.     LD    DE,FCB+1    ; Move it to infile FCB
  146.     LD    BC,8
  147.     LDIR
  148. ;
  149. ; Move default outfile FCB to OUTFCB
  150. ;
  151. LOAD2:    LD    HL,FCB2        ; Point to second FCB
  152.     LD    DE,OUTFCB    ; Point to outfile FCB
  153.     PUSH    DE        ; Save a copy
  154.     LD    BC,14        ; Move drive thru user bytes
  155.     LDIR
  156. ;
  157.     POP    DE        ; Restore OUTFCB pointer
  158.     LD    A,(DE)        ; Get drive
  159.     OR    A        ; Was it the default drive?
  160.     JR    NZ,LOAD3    ; Drive was specified
  161. ;
  162.     CALL    RETUD        ; Default, so get default du in BC
  163.     LD    A,B
  164.     INC    A        ; Make it A=1
  165.     LD    (OUTFCB),A    ; Save as default outfile drive
  166. ;
  167. LOAD3:    LD    A,(DE)        ; Save outfile drive for PDU routine
  168.     LD    (OUTDR),A
  169. ;
  170.     INC    DE        ; Point to filename
  171.     LD    A,(DE)        ; Do we have an outfile name specified?
  172.     CP    ' '
  173.     JR    NZ,LOAD4    ; Yes
  174. ;
  175. ; No outfile filename specified, use infile filename
  176. ;
  177.     LD    HL,FCB+1    ; Point to infile filename
  178.     LD    BC,8        ; Copy it to outfile filename
  179.     LDIR            ; Move it
  180. ;
  181. ; Set default outfile file type if none
  182. ;
  183. LOAD4:    LD    DE,OUTFCB+9
  184.     LD    A,(DE)        ; Filetype specified?
  185.     CP    ' '
  186.     JR    NZ,LOAD5    ; Yes
  187. ;
  188.     LD    HL,OUTTYP    ; Point to default file type
  189.     LD    BC,3        ; Copy default file type
  190.     LDIR
  191. ;
  192. ; Check if infile = 'BLANK'
  193. ;
  194. LOAD5:    LD    HL,FCB+1
  195.     LD    DE,BLANK    ; Point to 'BLANK   '
  196.     LD    B,8
  197.     CALL    COMPB
  198.     JR    NZ,LOAD6    ; Not blank, so continue
  199. ;
  200.     LD    HL,NEWTCP    ; Point to blank Z3TCAP area
  201.     LD    A,SPACE        ; Pad name area with spaces
  202.     LD    B,13
  203.     CALL    FILLB
  204. ;
  205.     PUSH    HL        ; Save pointer
  206.     LD    HL,NEWTCP+14    ; Point to B14
  207.     LD    A,80H        ; Make it an extended Z3TCAP
  208.     LD    (HL),A
  209.     POP    HL        ; Restore pointer
  210.     JR    SAVETCP
  211. ;
  212. ; Check for input file 'Z3TCAP'
  213. ;
  214. LOAD6:    LD    HL,FCB+1
  215.     LD    DE,Z3TNAME    ; Point to 'Z3TCAP  '
  216.     LD    B,8
  217.     CALL    COMPB
  218.     JR    NZ,LOAD7    ; Not Z3TCAP, so continue
  219. ;
  220.     LD    HL,(Z3EADR)    ; Get Z3ENV address
  221.     LD    DE,80h        ; Offset to Z3TCAP
  222.     ADD    HL,DE
  223. ;
  224. SAVETCP:LD    (TCPTR),HL    ; Save pointer
  225.     JR    MAIN0        ; And continue
  226. ;
  227. ; Look for Z3T file
  228. ;
  229. LOAD7:    LD    DE,FCB        ; Point to FCB
  230.     CALL    Z3LOG        ; Log into DU
  231.     CALL    F$EXIST        ; Look for file
  232.     JR    NZ,INREAD    ; File found
  233. ;
  234. ; Z3T file not found
  235. ;
  236. FNFERR:    CALL    PRINT
  237.     DB    CR,LF,'File ',0
  238.     LD    DE,FCB+1    ; Print file name
  239.     CALL    PFN2
  240.     CALL    PRINT
  241.     DB    ' Not Found',CR,LF,0
  242.     RET
  243. ;
  244. ; Read Z3T file
  245. ;
  246. INREAD:    CALL    F$OPEN        ; Open file
  247.     JR    NZ,FNFERR
  248.     CALL    F$READ        ; Read file into TBUFF
  249.     JR    Z,MAIN        ; Read without error
  250.     CALL    F$CLOSE        ; Close file
  251. ;
  252. ; Error in reading file
  253. ;
  254. RERR:    POP    AF        ; Clear stack
  255.     CALL    PRINT
  256.     DB    CR,LF,'File Read Error',CR,LF,0
  257.     RET
  258. ;
  259. ; Now make source code file
  260. ;
  261. MAIN:    LD    HL,TBUFF    ; Set pointer to Z3TCAP
  262.     LD    (TCPTR),HL
  263. ;
  264. MAIN0:    CALL    CODEND        ; Point to start of source file buffer
  265.     LD    (OUTFILE),HL    ; Save pointer
  266. ;
  267. ; Move terminal name
  268. ;
  269.     LD    HL,(TCPTR)    ; Get Z3TCAP pointer
  270.     LD    DE,Z3TERM    ; Point to TERMNAME in source code file
  271.     LD    BC,13        ; Length of name
  272.     LDIR            ; Move it
  273. ;
  274. ; Load terminal configuration bytes.
  275. ;
  276.     INC    HL        ; Point to B14
  277.     LD    DE,B14        ; Point to B14 in text
  278.     CALL    LDBIN        ; Load it in ASCII binary form
  279.     LD    DE,B15        ; Point to B15 in text
  280.     CALL    LDBIN        ; Load it in ASCII binary form
  281.     PUSH    HL        ; Save Z3T pointer on stack
  282. ;
  283. ; Translate terminal control strings into ASCII and load them
  284. ; to file buffer.
  285. ;
  286.     LD    HL,FILESTART    ; HL=text pointer
  287.     LD    DE,(OUTFILE)    ; DE=file buffer pointer
  288.     CALL    LOAD        ; Load text to buffer
  289. ;
  290. ; Move outfile filename
  291. ;
  292. ;;;;;
  293.     LD    HL,OUTFCB+1    ; Point to filename
  294.     LD    B,8        ; Eight characters max
  295.     CALL    FNLOOP        ; Move filename
  296.     LD    A,'.'        ; Separator
  297.     LD    (DE),A        ; Move it
  298.     INC    DE        ; Bump pointer
  299.     LD    HL,OUTFCB+9    ; Point to filetype
  300.     LD    B,3        ; Three characters max
  301.     CALL    FNLOOP        ; Move filetype
  302. ;
  303.     LD    HL,TNAME    ; HL=text pointer
  304.     CALL    LOAD        ; Load it
  305. ;
  306. ; Load arrow key characters
  307. ;
  308.     LD    B,4        ; 4 arrow keys
  309.     CALL    CLOAD
  310. ;
  311. ; Load delays
  312. ;
  313.     LD    B,3        ; 3 delays
  314.     CALL    DLOAD
  315. ;
  316. ; Load terminal control strings
  317. ;
  318.     LD    B,14        ; 14 strings
  319.     CALL    TCLOAD
  320. ;
  321. ; Load graphics delay
  322. ;
  323.     LD    B,1
  324.     CALL    DLOAD
  325. ;
  326. ; Load terminal control strings
  327. ;
  328.     LD    B,4        ; 4 strings
  329.     CALL    TCLOAD
  330. ;
  331. ; Load graphics characters
  332. ;
  333.     LD    B,13        ; 13 characters
  334.     CALL    CLOAD
  335. ;
  336. ; Pad end of file with EOF's
  337. ;
  338.     LD    A,EOF        ; EOF character
  339.     LD    B,128        ; At least a record's worth
  340.     EX    DE,HL        ; HL=destination pointer
  341.     CALL    FILLB
  342. ;
  343.     POP    HL        ; Restore stack pointer
  344. ;
  345. ; Create target file
  346. ;
  347. MAKE0:    LD    DE,OUTFCB    ; Point to FCB
  348.     CALL    Z3LOG
  349.     CALL    F$EXIST        ; Test of presence of file
  350.     JR    Z,MAKE2        ; Create file
  351. ;
  352.     CALL    GFA        ; Check attributes of existing file
  353.     AND    1        ; R/O?
  354.     JR    Z,MAKE1        ; No
  355. ;
  356.     CALL    PRINT
  357.     DB    CR,LF,'Existing File ',0
  358.     CALL    PDU        ; Display du
  359.     LD    DE,OUTFCB+1
  360.     CALL    PFN2        ; Display filename
  361.     CALL    PRINT
  362.     DB    ' is Read/Only',CR,LF,0
  363.     RET
  364. ;
  365. MAKE1:    CALL    F$DELETE    ; Delete file
  366. ;
  367. MAKE2:    CALL    F$MAKE        ; Create file
  368.     CP    0FFH        ; Error
  369.     JR    NZ,WRITEFILE
  370. ;
  371.     CALL    PRINT
  372.     DB    CR,LF,'File Create Error',CR,LF,0
  373.     RET
  374. ;
  375. ; Write block to file
  376. ;
  377. WRITEFILE:
  378.     LD    HL,(OUTFILE)    ; Point to file buffer
  379. ;
  380. WRITEF:    LD    DE,TBUFF    ; Copy into buffer
  381.     LD    BC,128        ; 128 bytes
  382.     LDIR
  383. ;
  384.     LD    DE,OUTFCB    ; Point to FCB
  385.     CALL    F$WRITE        ; Write record
  386.     JR    NZ,WERR
  387. ;
  388.     PUSH    HL        ; Save file pointer
  389.     LD    HL,TBUFF    ; Check TBUFF for EOF marker
  390.     LD    BC,128
  391.     LD    A,1AH        ; EOF marker
  392.     CPIR
  393.     POP    HL        ; Restore file pointer
  394.     JR    NZ,WRITEF    ; Loop till EOF
  395. ;
  396.     CALL    F$CLOSE        ; Close file
  397.     CALL    PRINT
  398.     DB    CR,LF,'File ',0
  399.     CALL    PDU        ; Display du
  400.     LD    DE,OUTFCB+1
  401.     CALL    PFN2        ; Display filename
  402.     CALL    PRINT
  403.     DB    ' Created',CR,LF,0
  404.     RET
  405. ;
  406. ; Can't write file
  407. ;
  408. WERR:    CALL    PRINT
  409.     DB    CR,LF,'File Write Error',CR,LF,0
  410.     RET
  411. ;
  412. ; Main exit point
  413. ;
  414. EXIT:    LD    SP,(STACK)    ; Restore CCP stack
  415.     RET            ; And return to system
  416.  
  417. ;-------------------------------
  418. ;
  419. ; Load terminal configuration byte As ASCII binary bits
  420. ;
  421. LDBIN:    LD    B,8        ; Do whole byte
  422.     LD    A,(HL)        ; Get byte
  423.     INC    HL        ; Point to next
  424. ;
  425. LDBLOOP:RLC    A        ; Look at next highest bit
  426.     PUSH    AF
  427.     AND    1        ; Just next bit
  428.     ADD    '0'        ; Make ASCII
  429.     LD    (DE),A        ; Load it
  430.     INC    DE        ; Bump destination pointer
  431.     POP    AF
  432.     DJNZ    LDBLOOP
  433.     RET
  434.  
  435. ;-------------------------------
  436. ;
  437. ; Load terminal control string
  438. ; Entry:  HL to source, DE points to destination
  439. ;
  440. LDSTR:    LD    C,0        ; Initialize comment counter
  441.     LD    A,(HL)        ; Get character
  442.     OR    A        ; String present?
  443.     JR    NZ,QFRST    ; Yes
  444. ;
  445.     INC    HL        ; No, bump pointer and quit
  446.     RET
  447. ;
  448. QFRST:    XOR    A        ; Reset quote flag
  449.     LD    (QF),A
  450. ;
  451. LSLOOP:    LD    A,(HL)        ; Get character
  452.     INC    HL        ; Bump source pointer
  453.     OR    A        ; End of string?
  454.     JR    NZ,LDS0        ; Not yet
  455. ;
  456.     LD    A,(QF)        ; Check quote flag
  457.     OR    A
  458.     JP    NZ,QCOMMA    ; Add quote, comma and quit
  459.     RET            ; Not in quotes
  460. ;
  461. LDS0:    CP    SPACE        ; Control character?
  462.     JR    C,LDS1        ; Yes
  463. ;
  464.     BIT    7,A        ; 80H or greater?
  465.     JR    Z,LDSD0        ; No
  466.     PUSH    AF        ; Save character
  467.     LD    A,(QF)
  468.     OR    A
  469.     CALL    NZ,QCOMMA    ; Add quote and comma
  470. ;
  471.     POP    AF
  472.     CALL    MA2HC
  473.     LD    A,'H'
  474.     LD    (DE),A
  475.     INC    DE        ; Bump destination pointer
  476.     INC    C        ; Increment counter
  477.     CALL    COMMA
  478.     JR    QFRST        ; Do next
  479. ;
  480. LDSD0:    PUSH    AF        ; Save character
  481.     LD    A,(QF)        ; Check quote flag
  482.     OR    A
  483.     JR    NZ,LDSD1    ; In quotes already
  484. ;
  485.     CALL    QUOTE        ; Add quote
  486.     LD    A,0FFH        ; And set flag
  487.     LD    (QF),A
  488. ;
  489. LDSD1:    POP    AF        ; Restore character
  490.     LD    (DE),A        ; Displayable, so load it
  491.     INC    DE        ; Bump destination pointer
  492.     INC    C        ; Increment counter
  493.     JR    LSLOOP        ; And do next
  494. ;
  495. ; Load escape string
  496. ;
  497. LDS1:    CP    ESC        ; Escape?
  498.     JR    NZ,LDS2        ; No
  499.     LD    A,(QF)        ; Check quote flag
  500.     OR    A
  501.     CALL    NZ,QCOMMA    ; Add end quote and comma
  502. ;
  503.     PUSH    HL        ; Save source pointer
  504.     PUSH    BC
  505.     LD    HL,ESCSTR    ; Load escape string
  506.     LD    BC,ESCLEN
  507.     LDIR
  508.     POP    BC
  509.     POP    HL
  510. ;
  511.     LD    A,ESCLEN    ; Account for string length
  512.     ADD    C
  513.     LD    C,A
  514.     JR    QFRST        ; Reset quote flag and do next
  515. ;
  516. ; Load control character
  517. ;
  518. LDS2:    PUSH    AF        ; Save character
  519.     LD    A,(QF)
  520.     OR    A
  521.     CALL    NZ,QCOMMA    ; In quotes, end with quote and comma
  522. ;
  523.     POP    AF
  524.     CALL    LDCC        ; Load control character
  525.     CALL    COMMA
  526.     JR    QFRST        ; Reset quote flag and do next
  527.  
  528. ;-------------------------------
  529. ;
  530. ; Load single character, with control (-40H) or hex (+80H) notation
  531. ; if required.
  532. ; Entry:  DE points to destination, HL to source
  533. ;
  534. LDCHR:    LD    C,0        ; Initialize comment counter
  535.     LD    A,(HL)        ; Get character
  536.     INC    HL        ; Point to next
  537.     OR    A        ; Character present?
  538.     JR    NZ,LDC0        ; Yes
  539. ;
  540. ZERO:    LD    A,'0'        ; Load an ASCII zero
  541.     LD    (DE),A
  542.     INC    DE        ; Bump destination pointer
  543.     INC    C        ; Increment counter
  544.     RET
  545. ;
  546. LDC0:    CP    SPACE        ; Control character?
  547.     JR    C,LDCC        ; Yes, load it
  548. ;
  549.     PUSH    AF        ; Save character
  550.     AND    7FH        ; Filter possible high bit
  551.     CALL    QUOTECQ        ; Load quoted character
  552.     POP    AF        ; Get character back
  553.     BIT    7,A        ; 80H or greater?
  554.     RET    Z        ; Quit if not
  555. ;
  556.     PUSH    HL
  557.     PUSH    BC
  558.     LD    HL,HISTR    ; Point to high character string
  559.     LD    BC,HILEN    ; Length of high character string
  560.     LDIR
  561.     POP    BC
  562.     POP    HL
  563. ;
  564.     LD    A,HILEN        ; Account for string length
  565.     ADD    C
  566.     LD    C,A
  567.     RET
  568. ;
  569. LDCC:    ADD    '@'        ; Make character ASCII
  570.     CALL    QUOTECQ        ; Load quoted character
  571. ;
  572.     PUSH    HL
  573.     PUSH    BC
  574.     LD    HL,CTRLSTR    ; Point to control character string
  575.     LD    BC,CCLEN    ; Length of control character string
  576.     LDIR
  577.     POP    BC
  578.     POP    HL
  579. ;
  580.     LD    A,CCLEN        ; Account for string length
  581.     ADD    C
  582.     LD    C,A
  583.     RET
  584.  
  585. ;-------------------------------
  586. ;
  587. ; Load quote and comma
  588. ;
  589. QCOMMA:    CALL    QUOTE        ; Load quote and fall thru
  590. ;
  591. ; Load comma
  592. ;
  593. COMMA:    PUSH    AF        ; Save character
  594.     LD    A,','        ; Load comma
  595.     JR    QUOTE0
  596. ;
  597. ; Load quote, character, quote
  598. ;
  599. QUOTECQ:
  600.     CALL    QUOTE        ; Load leading quote
  601.     LD    (DE),A        ; Load character
  602.     INC    DE        ; Bump dest pointer and fall thru
  603.     INC    C        ; Increment counter
  604. ;
  605. ; Load quote
  606. ;
  607. QUOTE:    PUSH    AF        ; Save character
  608.     LD    A,''''        ; Load quote
  609. ;
  610. QUOTE0:    LD    (DE),A
  611.     INC    DE        ; Bump destination pointer
  612.     INC    C        ; Increment counter
  613.     POP    AF
  614.     RET
  615.  
  616. ;-------------------------------
  617. ;
  618. ; Load number of characters in B
  619. ;
  620. CLOAD:    POP    IX        ; Save return address
  621. ;
  622. CLOOP:    EX    (SP),HL        ; HL=Z3T pointer
  623.     CALL    LDCHR        ; Load it
  624.     EX    (SP),HL        ; HL=text pointer
  625.     CALL    LOAD        ; Load text
  626.     DJNZ    CLOOP
  627.     JP    (IX)        ; Return
  628.  
  629. ;-------------------------------
  630. ;
  631. ; Load number of delays in B
  632. ;
  633. DLOAD:    POP    IX        ; Save return address
  634. ;
  635. DLOOP:    EX    (SP),HL        ; HL=Z3T pointer
  636.     LD    A,(HL)        ; Get it
  637.     INC    HL        ; Point to next
  638.     CALL    MAFDC        ; Load delay
  639.     EX    (SP),HL        ; HL=text pointer
  640.     CALL    LOAD        ; Load text
  641.     DJNZ    DLOOP
  642.     JP    (IX)        ; Return
  643.  
  644. ;-------------------------------
  645. ;
  646. ; Load number of terminal control strings in B
  647. ;
  648. TCLOAD:    POP    IX        ; Save return address
  649. ;
  650. TCLOOP:    EX    (SP),HL        ; HL=Z3T pointer
  651.     CALL    LDSTR        ; Load it
  652.     EX    (SP),HL        ; HL=text pointer
  653.     PUSH    HL        ; Save it
  654.     PUSH    BC        ; Save counter
  655.     LD    HL,TERM        ; Load string termination
  656.     LD    BC,TERMLEN
  657.     LDIR
  658.     POP    BC
  659.     LD    A,TERMLEN    ; Account for string length
  660.     ADD    C
  661.     LD    C,A
  662.     CALL    FORM        ; Space out comments
  663.     POP    HL        ; HL=text pointer
  664.     CALL    LOAD        ; Load text
  665.     DJNZ    TCLOOP
  666.     JP    (IX)        ; Return
  667.  
  668. ;-------------------------------
  669. ;
  670. ; Add spaces to place comments at or after line 33
  671. ;
  672. FORM:    LD    A,16        ; Set limit
  673.     SUB    C        ; How many spaces to go?
  674.     RET    Z        ; Ok if exactly 16
  675.     RET    C        ; None, ok
  676. ;
  677.     PUSH    BC        ; Save B
  678.     LD    B,A        ; Count in B
  679.     LD    A,SPACE
  680. ;
  681. FLOOP:    LD    (DE),A        ; Space out comments to line 33
  682.     INC    DE
  683.     DJNZ    FLOOP
  684.     POP    BC
  685.     RET
  686.  
  687. ;-------------------------------
  688. ;
  689. ; Move 0-terminated file text to file buffer
  690. ;
  691. LOAD:    LD    A,(HL)        ; Get character
  692.     INC    HL        ; Point to next
  693.     OR    A        ; Check for end
  694.     RET    Z        ; Yes, quit
  695. ;
  696.     LD    (DE),A        ; Move character
  697.     INC    DE        ; Bump pointer
  698.     JR    LOAD
  699.  
  700. ;-------------------------------
  701. ;
  702. ; Move filename and filetype to buffer
  703. ;
  704. FNLOOP:    LD    A,(HL)        ; Get a character
  705.     INC    HL
  706.     CP    ' '        ; Quit at first space
  707.     RET    Z        ; Finished
  708.     LD    (DE),A        ; Put it away
  709.     INC    DE        ; Point to next
  710.     DJNZ    FNLOOP
  711.     RET
  712.  
  713. ;-------------------------------
  714. ;
  715. ; Display outfile drive and user
  716. ;
  717. PDU:    LD    A,(OUTDR)    ; Get drive (A=1)
  718.     ADD    '@'        ; Make it ASCII
  719.     CALL    COUT        ; Display it
  720.     LD    A,(OUTFCB+13)    ; Get user
  721.     AND    7FH        ; Filter high bit
  722.     LD    B,'0'-1        ; Set counter
  723.     CP    10        ; Single digit?
  724.     JR    C,PDU1        ; Yes
  725. ;
  726. PDU0:    INC    B
  727.     SUB    10        ; Keep subtracting until CARRY set
  728.     JR    NC,PDU0
  729. ;
  730.     ADD    A,10        ; Get remaining units digit back
  731.     LD    C,A        ; Save it
  732.     LD    A,B        ; Tens digit
  733.     CALL    COUT        ; Display it
  734.     LD    A,C        ; Restore units digit
  735. ;
  736. PDU1:    ADD    A,'0'        ; Make ASCII
  737.     CALL    COUT
  738.     LD    A,':'
  739.     CALL    COUT
  740.     RET
  741.  
  742. ;-------------------------------
  743. ;
  744. ; Source code file
  745. ;
  746. FILESTART:
  747.     DB    ';',CR,LF
  748.     DB    '; Z3TCAP file:  ',0
  749. ;
  750. TNAME:    DB    CR,LF,';',CR,LF
  751.     DB    'ESC',TAB,'EQU',TAB,'27',TAB,TAB,'; Escape character'
  752.     DB    CR,LF
  753.     DB    ';',CR,LF
  754.     DB    '; The first character in the terminal name must not be '
  755.     DB    'a space.  For',CR,LF
  756.     DB    '; Z3TCAP.TCP library purposes only, the name terminates '
  757.     DB    'with a space',CR,LF
  758.     DB    '; and must be unique in the first eight characters.',CR,LF
  759.     DB    ';',CR,LF
  760.     DB    'TNAME:',TAB,'DB',TAB,''''
  761. ;
  762. Z3TERM:    DB    '     '        ; Break it so FILT won't insert TABs
  763.     DB    '     '
  764.     DB    '   ''',TAB,'; Name of terminal (13 chars)',CR,LF
  765.     DB    ';',CR,LF
  766.     DB    'GOFF:',TAB,'DB',TAB
  767. ;
  768. B13:    DB    'GOELD-TNAME',TAB,'; Graphics offset from Z3TCAP start'
  769.     DB    CR,LF
  770.     DB    ';',CR,LF
  771.     DB    '; Terminal configuration bytes B14 and B15 are defined '
  772.     DB    'and bits assigned',CR,LF
  773.     DB    '; as follows.  The remaining bits are not currently '
  774.     DB    'assigned.  Set these',CR,LF
  775.     DB    '; bits according to your terminal configuration.',CR,LF
  776.     DB    ';',CR,LF
  777.     DB    ';',TAB,'B14 b7: Z3TCAP Type.... '
  778.     DB    '0 = Standard TCAP  1 = Extended TCAP',CR,LF
  779.     DB    ';',CR,LF
  780.     DB    ';',TAB,'bit:',TAB,'76543210',CR,LF
  781.     DB    'B14:',TAB,'DB',TAB
  782. ;
  783. B14:    DB    '00000000B',TAB,'; Configuration '
  784.     DB    'byte B14',CR,LF
  785.     DB    ';',CR,LF
  786.     DB    ';',TAB,'B15 b0: Standout....... '
  787.     DB    '0 = Half-Intensity 1 = Reverse Video',CR,LF
  788.     DB    ';',TAB,'B15 b1: Power Up Delay. '
  789.     DB    '0 = None           1 = Ten-second delay',CR,LF
  790.     DB    ';',TAB,'B15 b2: No Auto Wrap... '
  791.     DB    '0 = Auto Wrap      1 = No Auto Wrap',CR,LF
  792.     DB    ';',TAB,'B15 b3: No Auto Scroll. '
  793.     DB    '0 = Auto Scroll    1 = No Auto Scroll',CR,LF
  794.     DB    ';',TAB,'B15 b4: ANSI........... '
  795.     DB    '0 = ASCII          1 = ANSI',CR,LF
  796.     DB    ';',CR,LF
  797.     DB    ';',TAB,'bit:',TAB,'76543210',CR,LF
  798.     DB    'B15:',TAB,'DB',TAB
  799. ;
  800. B15:    DB    '00000000B',TAB,'; Configuration '
  801.     DB    'byte B15',CR,LF
  802.     DB    ';',CR,LF
  803.     DB    '; Single character arrow keys or WordStar diamond'
  804.     DB    CR,LF
  805.     DB    ';',CR,LF
  806.     DB    TAB,'DB',TAB,0
  807. ;
  808. CUP0:    DB    TAB,TAB,'; Cursor up'
  809.     DB    CR,LF
  810.     DB    TAB,'DB',TAB,0
  811. ;
  812. CDN0:    DB    TAB,TAB,'; Cursor down'
  813.     DB    CR,LF
  814.     DB    TAB,'DB',TAB,0
  815. ;
  816. CRT0:    DB    TAB,TAB,'; Cursor right'
  817.     DB    CR,LF
  818.     DB    TAB,'DB',TAB,0
  819. ;
  820. CLF0:    DB    TAB,TAB,'; Cursor left'
  821.     DB    CR,LF
  822.     DB    ';',CR,LF
  823.     DB    '; Delays (in ms) after sending terminal control strings'
  824.     DB    CR,LF
  825.     DB    ';',CR,LF
  826.     DB    TAB,'DB',TAB
  827.     DB    0
  828. ;
  829. CLD:    DB    TAB,TAB,'; CL delay',CR,LF
  830.     DB    TAB,'DB',TAB
  831.     DB    0
  832. ;
  833. CMD:    DB    TAB,TAB,'; CM delay',CR,LF
  834.     DB    TAB,'DB',TAB
  835.     DB    0
  836. ;
  837. CED:    DB    TAB,TAB,'; CE delay',CR,LF
  838.     DB    ';',CR,LF
  839.     DB    '; Strings start here',CR,LF
  840.     DB    ';',CR,LF
  841.     DB    'CL:',TAB,'DB',TAB
  842.     DB    0
  843. ;
  844. CL0:    DB    '; Home cursor and clear screen',CR,LF
  845.     DB    'CM:',TAB,'DB',TAB
  846.     DB    0
  847. ;
  848. CM0:    DB    '; Cursor motion macro',CR,LF
  849.     DB    'CE:',TAB,'DB',TAB
  850.     DB    0
  851. ;
  852. CE0:    DB    '; Erase from cursor to end-of-line',CR,LF
  853.     DB    'SO:',TAB,'DB',TAB
  854.     DB    0
  855. ;
  856. SO0:    DB    '; Start standout mode',CR,LF
  857.     DB    'SE:',TAB,'DB',TAB
  858.     DB    0
  859. ;
  860. SE0:    DB    '; End standout mode',CR,LF
  861.     DB    'TI:',TAB,'DB',TAB
  862.     DB    0
  863. ;
  864. TI0:    DB    '; Terminal initialization',CR,LF
  865.     DB    'TE:',TAB,'DB',TAB
  866.     DB    0
  867. ;
  868. TE0:    DB    '; Terminal deinitialization',CR,LF
  869.     DB    ';',CR,LF
  870.     DB    '; Extensions to standard Z3TCAP',CR,LF
  871.     DB    ';',CR,LF
  872.     DB    'LD:',TAB,'DB',TAB
  873.     DB    0
  874. ;
  875. LD0:    DB    '; Delete line at cursor position',CR,LF
  876.     DB    'LI:',TAB,'DB',TAB
  877.     DB    0
  878. ;
  879. LI0:    DB    '; Insert line at cursor position',CR,LF
  880.     DB    'CD:',TAB,'DB',TAB
  881.     DB    0
  882. ;
  883. CD0:    DB    '; Erase from cursor to end-of-screen',CR,LF
  884.     DB    ';',CR,LF
  885.     DB    '; The attribute string contains the four command '
  886.     DB    'characters to set',CR,LF
  887.     DB    '; the following four attributes for this terminal in the '
  888.     DB    'following',CR,LF
  889.     DB    '; order:  ',TAB,'Normal, Blink, Reverse, Underscore',CR,LF
  890.     DB    ';',CR,LF
  891.     DB    'SA:',TAB,'DB',TAB
  892.     DB    0
  893. ;
  894. SA0:    DB    '; Set screen attributes macro',CR,LF
  895.     DB    'AT:',TAB,'DB',TAB
  896.     DB    0
  897. ;
  898. AT0:    DB    '; Attribute string',CR,LF
  899.     DB    'RC:',TAB,'DB',TAB
  900.     DB    0
  901. ;
  902. RC0:    DB    '; Read current cursor position',CR,LF
  903.     DB    'RL:',TAB,'DB',TAB
  904.     DB    0
  905. ;
  906. RL0:    DB    '; Read line until cursor',CR,LF
  907.     DB    ';',CR,LF
  908.     DB    '; Graphics TCAP area',CR,LF
  909.     DB    ';',CR,LF
  910.     DB    'GOELD:',TAB,'DB',TAB
  911.     DB    0
  912. ;
  913. GOELD0:    DB    TAB,TAB,'; Graphics On/Off delay in ms',CR,LF
  914.     DB    ';',CR,LF
  915.     DB    '; Graphics strings',CR,LF
  916.     DB    ';',CR,LF
  917.     DB    'GO:',TAB,'DB',TAB
  918.     DB    0
  919. ;
  920. GO0:    DB    '; Graphics mode On',CR,LF
  921.     DB    'GE:',TAB,'DB',TAB
  922.     DB    0
  923. ;
  924. GE0:    DB    '; Graphics mode Off',CR,LF
  925.     DB    'CDO:',TAB,'DB',TAB
  926.     DB    0
  927. ;
  928. CDO0:    DB    '; Cursor Off',CR,LF
  929.     DB    'CDE:',TAB,'DB',TAB
  930.     DB    0
  931. ;
  932. CDE0:    DB    '; Cursor On',CR,LF
  933.     DB    ';',CR,LF
  934.     DB    '; Graphics characters',CR,LF
  935.     DB    ';',CR,LF
  936.     DB    'GULC:',TAB,'DB',TAB
  937.     DB    0
  938. ;
  939. GULC0:    DB    TAB,TAB,'; Upper left corner',CR,LF
  940.     DB    'GURC:',TAB,'DB',TAB
  941.     DB    0
  942. ;
  943. GURC0:    DB    TAB,TAB,'; Upper right corner',CR,LF
  944.     DB    'GLLC:',TAB,'DB',TAB
  945.     DB    0
  946. ;
  947. GLLC0:    DB    TAB,TAB,'; Lower left corner',CR,LF
  948.     DB    'GLRC:',TAB,'DB',TAB
  949.     DB    0
  950. ;
  951. GLRC0:    DB    TAB,TAB,'; Lower right corner',CR,LF
  952.     DB    'GHL:',TAB,'DB',TAB
  953.     DB    0
  954. ;
  955. GHL0:    DB    TAB,TAB,'; Horizontal line',CR,LF
  956.     DB    'GVL:',TAB,'DB',TAB
  957.     DB    0
  958. ;
  959. GVL0:    DB    TAB,TAB,'; Vertical line',CR,LF
  960.     DB    'GFB:',TAB,'DB',TAB
  961.     DB    0
  962. ;
  963. GFB0:    DB    TAB,TAB,'; Full block',CR,LF
  964.     DB    'GHB:',TAB,'DB',TAB
  965.     DB    0
  966. ;
  967. GHB0:    DB    TAB,TAB,'; Hashed block',CR,LF
  968.     DB    'GUI:',TAB,'DB',TAB
  969.     DB    0
  970. ;
  971. GUI0:    DB    TAB,TAB,'; Upper intersect',CR,LF
  972.     DB    'GLI:',TAB,'DB',TAB
  973.     DB    0
  974. ;
  975. GLI0:    DB    TAB,TAB,'; Lower intersect',CR,LF
  976.     DB    'GIS:',TAB,'DB',TAB
  977.     DB    0
  978. ;
  979. GIS0:    DB    TAB,TAB,'; Mid intersect',CR,LF
  980.     DB    'GRTI:',TAB,'DB',TAB
  981.     DB    0
  982. ;
  983. GRTI0:    DB    TAB,TAB,'; Right intersect',CR,LF
  984.     DB    'GLTI:',TAB,'DB',TAB
  985.     DB    0
  986. ;
  987. GLTI0:    DB    TAB,TAB,'; Left intersect',CR,LF
  988.     DB    ';',CR,LF
  989.     DB    ';  Fill remaining space with zeros',CR,LF
  990.     DB    ';',CR,LF
  991.     DB    TAB,' REPT',TAB,'128-($-TNAME)',CR,LF
  992.     DB    TAB,'DB',TAB,'0',CR,LF
  993.     DB    TAB,' ENDM',CR,LF
  994.     DB    CR,LF
  995.     DB    TAB,'END',CR,LF
  996.     DB    ';',CR,LF
  997.     DB    '; End of Z3TCAP',CR,LF
  998.     DB    ';',CR,LF,LF
  999.     DB    0
  1000.  
  1001. ;--------------------------------
  1002. ;
  1003. ; Initialized data area
  1004. ;
  1005. BLANK:    DB    'BLANK   '    ; Filename for blank source
  1006. Z3TNAME:DB    'Z3TCAP  '    ; Default infile filename
  1007. INTYP:    DB    'Z3T'        ; Default infile filetype
  1008. OUTTYP:    DB    'Z80'        ; Default outfile filetype
  1009. ;
  1010. CTRLSTR:DB    '-40H'        ; Control notation for arrow keys
  1011. CCLEN    EQU    $-CTRLSTR    ; Length of control character string
  1012. ESCSTR:    DB    'ESC,'        ; Escape character string
  1013. ESCLEN    EQU    $-ESCSTR    ; Length of escape character string
  1014. HISTR:    DB    '+80H'        ; String for character > 80H
  1015. HILEN    EQU    $-HISTR        ; Length of hi character string
  1016. TERM:    DB    '0 '        ; String termination
  1017. TERMLEN    EQU    $-TERM        ; Length of termination string
  1018.  
  1019. ;--------------------------------
  1020. ;
  1021. ; Uninitialized data area, initialized at INIT
  1022. ;
  1023.     DSEG
  1024. DATA    EQU    $        ; Start of data area to be initialized
  1025. OUTDR:    DS    1        ; Outfile drive
  1026. OUTFCB:    DS    36        ; Outfile FCB
  1027. TCPTR:    DS    2        ; Pointer to start of Z3TCAP
  1028. OUTFILE:DS    2        ; Pointer to start of source file buffer
  1029. QF:    DS    1        ; ON if character within quote string
  1030. NEWTCP:    DS    128        ; Blank TCAP for NEWFILE
  1031. ;
  1032. DATALEN    EQU    $-DATA        ; Length of data area to be initialized
  1033. ;
  1034.     DS    48        ; Local stack
  1035. STACK:    DS    2        ; CCP stack pointer
  1036. ;
  1037.     END
  1038.