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 / ENTERPRS / CPM / TERMS / QTPATCH.ARC / QT-XEROX.Z < prev    next >
Text File  |  1989-09-08  |  8KB  |  269 lines

  1. ; QTERM Version 4.x Patch Area For Xerox 820-II 16/8
  2. ;
  3. ; Based on Kaypro patch area as generated by David Goodenough and
  4. ; David Presberg
  5. ;
  6. ; Modified for Xerox 820-II, 16/8. Clears screen at start, at end, and re-
  7. ;  sets alternate video at end; all terminal capabilities supported.
  8. ;  By Tim Carney 17-Apr-89.
  9.  
  10. .var    sioc    6        ; sio control port
  11. .var    siod    4        ; sio data port
  12.  
  13. .var    baud    0
  14.  
  15. .var    yes    0xff        ; true value
  16. .var    no    0        ; false value
  17.  
  18. .org    0x0110
  19. modist:    in    a,(sioc)    ;get modem input status  (Kaypro status port)
  20.     and    1        ; (result to Z:   no inp. character available
  21.     ret            ;   is 0 at bit-0 (low order) ===>   Z==1    )
  22.  
  23. .org    0x0120
  24. modin:    in    a,(siod)    ;read modem input character (Kaypro data port)
  25.     ret
  26.  
  27. .org    0x0130
  28. modost:    in    a,(sioc)    ;get modem output status  (Kaypro status port)
  29.     and    4        ; (result to Z:  bit-2 ... see above)
  30.     ret
  31.  
  32. .org    0x0140
  33. modout:    out    (siod),a    ;write modem output char. (Kaypro data port)
  34.     ret
  35.  
  36. .org    0x0150
  37. sbreak:    ld    a,(setf)    ;start "break"
  38.     or    a        ;do we have valid data in r3,r4,r5
  39.     ret    z        ;no - don't do it
  40.     ld    hl,r5
  41.     set    4,(hl)
  42.     jp    sioout        ; go send stuff to SIO, to cause a break
  43.     
  44. .org    0x0160
  45. ebreak:    ld    a,(setf)    ;end "break"
  46.     or    a
  47.     ret    z        ; don't do it unless r3, r4, r5 are valid
  48.     ld    hl,r5
  49.     res    4,(hl)
  50.     jp    sioout
  51.  
  52. .org    0x0170
  53. dtroff:    ld    a,(setf)    ;drop DTR
  54.     or    a
  55.     ret    z        ; don't do it unless r3, r4, r5 are valid
  56.     ld    hl,r5
  57.     res    7,(hl)
  58.     jp    sioout
  59.  
  60. .org    0x0180
  61. dtron:    ld    a,(setf)    ;raise DTR
  62.     or    a
  63.     ret    z        ; don't do it unless r3, r4, r5 are valid
  64.     ld    hl,r5
  65.     set    7,(hl)
  66.     jp    sioout
  67.  
  68. .org    0x0190
  69. setbd:    out    (baud),a    ;set baud rate (value in A)
  70.     ret
  71.  
  72. ; The Baud Rate Table has entries from 38400 baud down to 300 baud.
  73. ;   There are 2 bytes per entry.  The second byte determines if the entry is
  74. ;   enabled or disabled (ffh=enabled; 00=disabled).  The first byte is passed
  75. ;   as the A value to the setbd subroutine.
  76.  
  77. ; Xerox 820-II has advertised values for rates up to 19200.  Not all
  78. ; available low speeds are used by QTERM, however.
  79.  
  80. .org    0x01a0
  81. baudtb:
  82. b38400:    db    0,no        ;  38400 baud
  83. b19200:    db    0xf,yes        ;  19200
  84. b9600:    db    0xe,yes        ;   9600
  85. b4800:    db    0xc,yes        ;   4800
  86. b2400:    db    0xa,yes        ;   2400
  87. b1200:    db    0x7,yes        ;   1200
  88. b600:    db    0x6,yes        ;    600
  89. b300:    db    0x5,yes        ;    300 baud
  90.  
  91. .org    0x01b0
  92. setmod:    ld    (setf),a    ; flag we've done a set
  93.     jp    finmod        ; have to finish this elsewhere
  94.  
  95. ; Communication Mode Table.  Single byte values for 12 combinations of
  96. ;    number-of-bits(7/8), parity(none/even/odd), number-of-stop-bits(1/2).
  97.  
  98. .org    0x01c0
  99. modetb:
  100. n17:    db    0b10000000    ;080h, 7n1
  101. n18:    db    0b11000000    ;0c0h, 8n1
  102. n27:    db    0b10001000    ;088h, 7n2
  103. n28:    db    0b11001000    ;0c8h, 8n2
  104. e17:    db    0b10000011    ;083h, 7e1
  105. e18:    db    0b11000011    ;0c3h, 8e1
  106. e27:    db    0b10001011    ;08bh, 7e2
  107. e28:    db    0b11001011    ;0cbh, 8e2
  108. o17:    db    0b10000001    ;081h, 7o1
  109. o18:    db    0b11000001    ;0c8h, 8o1
  110. o27:    db    0b10001001    ;089h, 7o2
  111. o28:    db    0b11001001    ;0c9h, 8o2
  112.  
  113. ;.org    0x01cc
  114. resrvd:    db    0    ; reserved for future expansion
  115.  
  116. ;.org    0x01cd
  117. xfersz:    db    8    ;number of K to read/write during file xfers
  118.             ;Must be 1 / 2 / 4 / 8.  Best left as 8 unless
  119.             ;  disk is verrrrry slow.  Drop to smaller value
  120.             ;  if too many timeouts occur during "protocol"
  121.             ;  file transfers (xmodem or kermit).
  122.  
  123. ;.org    0x01ce
  124. speed:    db    4    ;cpu speed (Mhz; use 3 for 2.5, 4 for Xerox).
  125.  
  126. ;.org    0x01cf
  127. escape:    db    '\e'    ;escape character use 1bh (^[=ESC) for Xerox.
  128.  
  129. ;.org    0x01d0
  130. signon:            ;signon message
  131.     db    'Xerox 820-II 16/8 1984\0'
  132.  
  133. .org    0x01f0
  134. clrs:    db    'z' & 0x1f, 0    ;clear screen string (Control-Z)
  135.  
  136. .var    scrout    0x0109    ;(a routine to print to CON: the
  137.             ;   character in C)
  138. .var    decout    0x010c    ;(a routine to print to CON: a decimal value
  139.             ;   in HL.  Is available for VT100 and the like.)
  140.  
  141. .org    0x0200
  142. moveto:    push    hl    ;move cursor to position in HL (Row,Col)
  143.     ld    c,'\e'    ; lead-in with Esc (the ASCII one; not QTERM's)
  144.     call    scrout
  145.     ld    c,'='    ; 2nd lead-in is '='
  146.     call    scrout
  147.     pop    hl
  148.     push    hl
  149.     ld    a,h    ; row value (top row is 0.)
  150.     call    poff    ; add offset and send it to screen
  151.     pop    hl
  152.     ld    a,l    ; col value (leftmost col is 0.)
  153. poff:    add    a,' '    ; (adds 0x20)
  154.     ld    c,a
  155.     jp    scrout    ; (scrout returns from 'moveto's call)
  156.  
  157. ; Terminal Capability Bits.  The eight bits stand for each of the following
  158. ;   strings.   They count from 01h=bright to 80h=clear-to-end-of-screen.
  159.  
  160. .var    b_brit    0b00000001    ; 0: bright (1.)    -- NOT mandatory
  161. .var    b_dim    0b00000010    ; 1: dim    (2.)    -- NOT mandatory
  162. .var    b_dlln    0b00000100    ; 2: delete line (4.)    -- important
  163. .var    b_inln    0b00001000    ; 3: insert line (8.)    -- important
  164. .var    b_dlch    0b00010000    ; 4: delete character (16.)-- unused by QTERM
  165. .var    b_inch    0b00100000    ; 5: insert character (32.)-- NOT mandatory
  166. .var    b_clel    0b01000000    ; 6: clear to end-of-line(64.) -- important
  167. .var    b_cles    0b10000000    ; 7: clear to end-of-screen(128.)-- important
  168.  
  169. .org    0x022f
  170. tcbits:    db    0xff        ; capability bits- all functions supported
  171.                 ; by Xerox.
  172.  
  173. .org    0x0230
  174. brites:    db    '\e(\0'        ;Xerox ESC-(, alternate video disable code.
  175.  
  176. .org    0x0238
  177. dims:    db    '\e)\e8\0'    ;Xerox ESC-) ESC-8 (enable alternate
  178.                 ;video,set to dim characters).
  179.  
  180. .org    0x0240
  181. dlstr:    db    '\eE\0'        ;delete line
  182.  
  183. .org    0x0248
  184. ilstr:    db    '\eE\0'        ;insert line
  185.  
  186. .org    0x0250
  187. dcstr:    db    '\eW\0'        ;Xerox ESC-W del character string.
  188.  
  189. .org    0x0258
  190. icstr:    db    '\eQ\0'        ;Xerox ESC-Q ins character string.
  191.  
  192. .org    0x0260
  193. ceol:    db    'x' & 0x1f, 0    ;clear to end of line (Control-X)
  194.  
  195. .org    0x0268
  196. ceos:    db    'q' & 0x1f, 0    ;clear to end-of-screen (Control-Q)
  197.  
  198. ; Entry and Exit hooks.  These are provided to perform custom initialisation
  199. ; on startup and on exit from QTERM.  They are invoked before any use is made
  200. ; of the screen or the port hardware.
  201.  
  202. .org    0x0270
  203. entry:    jp    do_ent        ; entry hook (270h .. 272h)
  204.  
  205. ;.org    0x0273            ; exit hook  (273h .. 275h)    
  206. exit:    jp    do_exit         ; Exit routine-Xerox 820-II, 16/8.
  207.  
  208. ; Extra patch area if needed.  276h .. 2ffh
  209.  
  210. ;.org    0x0276
  211. patcha:
  212.  
  213. do_ent:    ld    c,'z' & 0x1f    ;Send clear screen and home cursor
  214.     call    scrout        ;to console...
  215.  
  216. start:    ld    a,(b1200)    ; entry hook (from 270h)
  217.     call    setbd        ; setup for 1200 baud
  218.     ld    a,(n18)        ; and 8n1 communications mode.
  219.     call    setmod
  220.     ret
  221.  
  222. sioout:    ld    hl,siodat
  223.     ld    bc,6 * 256 + sioc
  224.     otir
  225.     ret
  226.  
  227. finmod:    ld    c,a        ; save byte in c
  228.     ld    hl,r3        ; look at byte for wr3
  229.     res    7,(hl)        ; turn off ms bit (Rx # bits / char)
  230.     add    a,a        ; move bit from 6 to 7 in a
  231.     and    0x80        ; mask off the rest
  232.     or    (hl)        ; or in the remainder
  233.     ld    (hl),a        ; and save it back
  234.     inc    hl
  235.     inc    hl        ; point hl at r4
  236.     ld    a,(hl)
  237.     and    0xf4        ; mask out bits we don't want
  238.     ld    b,a        ; save in b
  239.     ld    a,c        ; get set byte back
  240.     and    0xb        ; get bits out of set byte that we want
  241.     or    b        ; or in the other bits
  242.     ld    (hl),a        ; and save it back
  243.     inc    hl
  244.     inc    hl        ; point hl at r5
  245.     ld    a,c
  246.     and    0x40        ; get the bit we want from c
  247.     res    6,(hl)        ; clear the bit in r5
  248.     or    (hl)
  249.     ld    (hl),a        ; put new composite value back
  250.     jp    sioout        ; go send the values
  251.  
  252. siodat:    db    3
  253. r3:    db    0b11000001    ; value for wr3 (0xc1)
  254.     db    4
  255. r4:    db    0b01000100    ; value for wr4 (0x44)
  256.     db    5
  257. r5:    db    0b11101010    ; value for wr5 (0xe5)
  258.  
  259. setf:    db    0        ; flag if we've done a set mode command
  260.  
  261. do_exit:
  262.     ld    c,'z' & 0x1f    ; Xerox specific.Clear screen, home cursor
  263.     call    scrout
  264.     ld    c,'\e'        ; Change alternate video mode to inverse.
  265.     call    scrout        ; (52 or 54=blink, 53=graphics, 55=inverse
  266.     ld    c,55        ; 56=dim).
  267.     call    scrout
  268.     ret
  269.