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 / QTERM / QTP-XER2.AZM / QTP-XER2.ASM
Assembly Source File  |  2000-06-30  |  10KB  |  329 lines

  1. ; QTERM Version 4.x Patch Area
  2. ; Code as adapted from QTERM.COM from QTERM33A.LBR posted by David Goodenough
  3. ;  to BOSKUG RCP/M circa 12/27/88, and QTERM Vers. 4.x patch listing 8-Feb-89.
  4.  
  5. ; D. Presberg dissasembled this with Z8E, 21-Jan-89.  Code labels taken from
  6. ;  D. Goodenough "qterm.z" example circa 8-Feb-89.
  7.  
  8. ; This edit is for Kaypro-II and -4 ('83 version without graphics).  Kaypro
  9. ;  (and Xerox BB-I) use an SIO chip, port A, with a separate baud rate
  10. ;  generator:  status port at 04, data port at 06, baud rate port at 0.
  11. ;  15-Feb-89, D. Presberg, BCS/BOSKUG.
  12.  
  13. ; D. Goodenough added break, dtr and mode stuff  2-23-89
  14.  
  15. ; Modified for Xerox 820-II, 16/8. Clears screen at start, at end, and re-
  16. ;  sets alternate video at end; all terminal capabilities supported.
  17. ;  By Tim Carney 17-Apr-89.
  18.  
  19. sioc    equ    6        ; sio control port
  20. siod    equ    4        ; sio data port
  21.  
  22. yes    equ    0ffh        ; true value
  23. no    equ    0        ; false value
  24.  
  25.     org    110h
  26. modist:    in    a,(sioc)    ;get modem input status  (Kaypro status port)
  27.     and    01h        ; (result to Z:   no inp. character available
  28.     ret            ;   is 0 at bit-0 (low order) ===>   Z==1    )
  29.  
  30.     org    120h
  31. modin:    in    a,(siod)    ;read modem input character (Kaypro data port)
  32.     ret
  33.  
  34.     org    130h
  35. modost:    in    a,(sioc)    ;get modem output status  (Kaypro status port)
  36.     and    04h        ; (result to Z:  bit-2 ... see above)
  37.     ret
  38.  
  39.     org    140h
  40. modout:    out    (siod),a    ;write modem output char. (Kaypro data port)
  41.     ret
  42.  
  43.     org    150h
  44. sbreak:    ld    a,(setf)    ;start "break"
  45.     or    a        ;do we have valid data in r3,r4,r5
  46.     ret    z        ;no - don't do it
  47.     jp    exmlp        ; start break takes a bit extra, see below
  48.     
  49.     org    160h
  50. ebreak:    ld    a,(setf)    ;end "break"
  51.     or    a
  52.     ret    z        ; don't do it unless r3, r4, r5 are valid
  53.     ld    hl,r5
  54.     res    4,(hl)
  55.     jp    sioout
  56.  
  57.     org    170h
  58. dtroff:    ld    a,(setf)    ;drop DTR
  59.     or    a
  60.     ret    z        ; don't do it unless r3, r4, r5 are valid
  61.     ld    hl,r5
  62.     res    7,(hl)
  63.     jp    sioout
  64.  
  65.     org    180h
  66. dtron:    ld    a,(setf)    ;raise DTR
  67.     or    a
  68.     ret    z        ; don't do it unless r3, r4, r5 are valid
  69.     ld    hl,r5
  70.     set    7,(hl)
  71.     jp    sioout
  72.  
  73.     org    190h
  74. setbd:    out    (00h),a        ;set baud rate (value in A) (Kaypro baud
  75.     ret            ;rate port)
  76.  
  77. ; The Baud Rate Table has entries from 38400 baud down to 300 baud.
  78. ;   There are 2 bytes per entry.  The second byte determines if the entry is
  79. ;   enabled or disabled (ffh=enabled; 00=disabled).  The first byte is passed
  80. ;   as the A value to the setbd subroutine.
  81.  
  82. ; Kaypro-II/4 has advertised values for rates up to 19200.  Not all available
  83. ;   low speeds are used by QTERM, however.
  84.  
  85.     org    1a0h
  86. baudtb:
  87.  
  88. b38400:    defb    0,no        ;  38400 baud
  89. b19200:    defb    0fh,yes        ;  19200
  90. b9600:    defb    0eh,yes        ;   9600
  91. b4800:    defb    0ch,yes        ;   4800
  92. b2400:    defb    0ah,yes        ;   2400
  93. b1200:    defb    07h,yes        ;   1200
  94. b600:    defb    06h,yes        ;    600
  95. b300:    defb    05h,yes        ;    300 baud
  96. ; (Kaypro goes down to 150, 134.5, 110, 75, and 50 baud, but QTERM doesn't.)
  97.  
  98.     org    1b0h
  99. setmod:    ld    (setf),a    ; flag we've done a set
  100.     ld    c,a        ; save byte in c
  101.     ld    hl,r3        ; look at byte for wr3
  102.     res    7,(hl)        ; turn off ms bit (Rx # bits / char)
  103.     add    a,a        ; move bit from 6 to 7 in a
  104.     and    80h        ; mask off the rest
  105.     or    (hl)        ; or in the remainder
  106.     jp    finmod        ; have to finish this elsewhere
  107.  
  108. ; Communication Mode Table.  Single byte values for 12 combinations of
  109. ;    number-of-bits(7/8), parity(none/even/odd), number-of-stop-bits(1/2).
  110.  
  111.     org    1c0h
  112. modetb:
  113.  
  114. n17:    defb    10000000b    ;080h, 7n1
  115. n18:    defb    11000000b    ;0c0h, 8n1
  116. n27:    defb    10001000b    ;088h, 7n2
  117. n28:    defb    11001000b    ;0c8h, 8n2
  118. e17:    defb    10000011b    ;083h, 7e1
  119. e18:    defb    11000011b    ;0c3h, 8e1
  120. e27:    defb    10001011b    ;08bh, 7e2
  121. e28:    defb    11001011b    ;0cbh, 8e2
  122. o17:    defb    10000001b    ;081h, 7o1
  123. o18:    defb    11000001b    ;0c8h, 8o1
  124. o27:    defb    10001001b    ;089h, 7o2
  125. o28:    defb    11001001b    ;0c9h, 8o2
  126.  
  127.     org    1cch
  128. smlbuf:    defb    no    ; set this 'yes' if you run out of ram - this feature
  129.             ; is not yet implemented, but in time (i.e. V4.1)
  130.             ; it will be. QTERM is a real memory hog - it needs
  131.             ; well in excess of 48K TPA. If you have a full blown
  132.             ; Z-system with oodles of RSX additions, you may
  133.             ; run out of space. By setting this true, you can get
  134.             ; QTERM to shrink some buffers and fit itself into
  135.             ; about 42K, the price paid is somewhat more
  136.             ; frequent disk access when reading and writing files.
  137.  
  138.     org    1cdh
  139. xfersz:    defb    8    ;number of K to read/write during file xfers
  140.             ;Must be 1 / 2 / 4 / 8.  Best left as 8 unless
  141.             ;  disk is verrrrry slow.  Drop to smaller value
  142.             ;  if too many timeouts occur during "protocol"
  143.             ;  file transfers (xmodem or kermit).
  144.  
  145.     org    1ceh
  146. speed:    defb    4    ;cpu speed (Mhz; use 3 for 2.5, 4 for Xerox).
  147.             ; (5Mhz Assumes Advent speedup kit in Kaypro.)
  148.  
  149.     org    1cfh
  150. escape:    defb    1bh    ;escape character (1ch=^\  Control-Backslash)
  151.             ;use 1bh (^[=ESC) for Xerox.
  152.     org    1d0h
  153. signon:            ;signon message
  154.     defb    '(Xerox 16/8 1984) '
  155.     defb    0
  156.  
  157.     org    1f0h
  158. clrs:    defb    1ah    ;clear screen string (Control-Z)
  159.     defb    0
  160.  
  161. scrout    equ    109h    ;(a routine to print to CON: the
  162.             ;   character in C)
  163. decout    equ    10ch    ;(a routine to print to CON: a decimal value
  164.             ;   in HL.  Is available for VT100 and the like.)
  165.  
  166.     org    200h
  167. moveto:    push    hl    ;move cursor to position in HL (Row,Col)
  168.     ld    c,1bh    ; lead-in with Esc (the ASCII one; not QTERM's)
  169.     call    scrout
  170.     ld    c,'='    ; 2nd lead-in is '='
  171.     call    scrout
  172.     pop    hl
  173.     push    hl
  174.     ld    a,h    ; row value (top row is 0.)
  175.     call    poff    ; add offset and send it to screen
  176.     pop    hl
  177.     ld    a,l    ; col value (leftmost col is 0.)
  178. poff:    add    a,' '    ; (adds 20h)
  179.     ld    c,a
  180.     jp    scrout    ; (scrout returns from 'moveto's call)
  181.  
  182. ; Terminal Capability Bits.  The eight bits stand for each of the following
  183. ;   strings.   They count from 01h=bright to 80h=clear-to-end-of-screen.
  184.  
  185. b_brit    equ    00000001b    ; 0: bright (1.)    -- NOT mandatory
  186. b_dim    equ    00000010b    ; 1: dim    (2.)    -- NOT mandatory
  187. b_dlln    equ    00000100b    ; 2: delete line (4.)    -- important
  188. b_inln    equ    00001000b    ; 3: insert line (8.)    -- important
  189. b_dlch    equ    00010000b    ; 4: delete character (16.)-- unused by QTERM
  190. b_inch    equ    00100000b    ; 5: insert character (32.)-- NOT mandatory
  191. b_clel    equ    01000000b    ; 6: clear to end-of-line(64.) -- important
  192. b_cles    equ    10000000b    ; 7: clear to end-of-screen(128.)-- important
  193.  
  194.     org    22fh
  195. tcbits:    defb    0ffh        ; capability bits- all functions supported
  196.                 ; by Xerox.
  197.  
  198. ; (Kaypro-II/4, non-graphics version, cannot do in-place insertion or deletion
  199. ;   of single characters:  it can only overwrite characters at the current
  200. ;   cursor position and move the cursor non-destructively, etc..  It can
  201. ;   do in-place insertion and deletion of lines, and its clear-to-end-of-
  202. ;   -screen and -line leaves the cursor as-is.  It also has clear-screen-and-
  203. ;   -home-the-cursor: see clrs, above.  It, of course, has no graphical screen
  204. ;   attributes, such as bright and dim.)
  205.  
  206.     org    230h
  207. brites:    defb    27        ;bright string (none for '83 Kaypro)
  208.     defb    40        ;Xerox ESC-(, alternate video disable
  209.     defb    0        ;code.
  210.  
  211.     org    238h
  212. dims:    defb    27        ;dim string    (none for '83 Kaypro)
  213.     defb    41        ;Xerox ESC-) ESC-8 (enable alternate
  214.     defb    27        ;video,set to dim characters).
  215.     defb    56
  216.     defb    0
  217.  
  218.  
  219.  
  220.     org    240h
  221. dlstr:    defb    1bh    ;delete line
  222.     defb    'R'
  223.     defb    0
  224.  
  225.     org    248h
  226. ilstr:    defb    1bh    ;insert line
  227.     defb    'E'
  228.     defb    0
  229.  
  230.     org    250h
  231. dcstr:    defb    27    ;delete character (none for '83 Kaypro)
  232.     defb    'W'    ;Xerox ESC-W del character string.
  233.     defb    0
  234.  
  235.     org    258h
  236. icstr:    defb    27    ;insert character (none for '83 Kaypro)
  237.     defb    'Q'    ;Xerox ESC-Q ins character string.
  238.     defb    0
  239.  
  240.  
  241.     org    260h
  242. ceol:    defb    18h    ;clear to end of line (Control-X)
  243.     defb    0
  244.  
  245.     org    268h
  246. ceos:    defb    17    ;clear to end-of-screen (Control-W)
  247.     defb    0    ;Xerox uses CTRL-Q
  248.  
  249.  
  250. ; Entry and Exit hooks.  These are provided to perform custom initialisation
  251. ; on startup and on exit from QTERM.  They are invoked before any use is made
  252. ; of the screen or the port hardware.
  253.  
  254.     org    270h
  255. entry:    jp    do_ent        ; entry hook (270h .. 272h)
  256.  
  257.  
  258.  
  259.     org    273h        ; exit hook  (273h .. 275h)    
  260. exit:    jp    do_exit         ; Exit routine-Xerox 820-II, 16/8.
  261.  
  262. ; Extra patch area if needed.  276h .. 2ffh
  263.  
  264.     org    276h
  265. patcha: 
  266.  
  267. do_ent:    ld    c,26        ;Send clear screen and home cursor
  268.     call    scrout        ;to console...
  269.     jp    start
  270.  
  271. start:    ld    a,(b1200)    ; entry hook (from 270h)
  272.     call    setbd        ;   Kaypro-II/4 setup for 1200 baud
  273.     ld    a,(n18)        ; and 8n1 communications mode.
  274.     call    setmod
  275.     ret
  276.  
  277. exmlp:    ld    a,1        ; wait till transmitter is really finished
  278.     out    (siod),a
  279.     in    a,(siod)
  280.     rra
  281.     jr    nc,exmlp    ; loop till buffer empty
  282.     ld    hl,r5
  283.     set    4,(hl)        ; now go set the break bit.
  284.  
  285. sioout:    ld    hl,siodat
  286.     ld    bc,6 * 256 + sioc
  287.     otir
  288.     ret
  289.  
  290. finmod:    ld    (hl),a        ; and save it back
  291.     inc    hl
  292.     inc    hl        ; point hl at r4
  293.     ld    a,(hl)
  294.     and    0f4h        ; mask out bits we don't want
  295.     ld    b,a        ; save in b
  296.     ld    a,c        ; get set byte back
  297.     and    0bh        ; get bits out of set byte that we want
  298.     or    b        ; or in the other bits
  299.     ld    (hl),a        ; and save it back
  300.     inc    hl
  301.     inc    hl        ; point hl at r5
  302.     ld    a,c
  303.     and    40h        ; get the bit we want from c
  304.     res    6,(hl)        ; clear the bit in r5
  305.     or    (hl)
  306.     ld    (hl),a        ; put new composite value back
  307.     jp    sioout        ; go send the values
  308.  
  309. siodat:    defb    3
  310. r3:    defb    11000001b    ; value for wr3 (0c1h)
  311.     defb    4
  312. r4:    defb    01000100b    ; value for wr4 (044h)
  313.     defb    5
  314. r5:    defb    11101010b    ; value for wr5 (0e5h)
  315.  
  316. setf:    defb    0        ; flag if we've done a set mode command
  317.  
  318.     org     02c5h
  319. do_exit:
  320.     ld    c,26        ; Xerox specific.Clear screen, home cursor
  321.     call    scrout
  322.     ld    c,27        ; Change alternate video mode to inverse.
  323.     call    scrout        ; (52 or 54=blink, 53=graphics, 55=inverse    
  324.     ld    c,55        ; 56=dim).
  325.     call    scrout
  326.     ret
  327.  
  328.     end
  329.