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 / QTERM41E.LBR / QT-PATCH.ZZ / QT-PATCH.Z
Text File  |  2000-06-30  |  9KB  |  296 lines

  1. ; QTERM Version 4.x Patch Area.
  2.  
  3. ; This is an example of the Kaypro patch code. It is included because
  4. ; it uses a SIO for serial communications, and can be changed to work
  5. ; with any other SIO / DART system with very little work. All that is
  6. ; needed is to disable the baud rate code, modify the terminal depen-
  7. ; dancy stuff, and alter siod and sioc to match the port addresses of
  8. ; the SIO (data and control) as needed, and it should work.
  9.  
  10. ; This should be assembled with ZSM (available on all fashionable BBS's)
  11. ; like this:
  12. ; A>ZSM QT-PATCH
  13. ; and installed with ZPATCH:
  14. ; A>ZPATCH QTERM QT-PATCH
  15.  
  16. ; This is a ZSM version of the more generic QTERMPAT.AZM generated by
  17. ; D. Presberg & D. Goodenough
  18.  
  19. ; Code as adapted from QTERM.COM from QTERM33A.LBR posted by David Goodenough
  20. ;  to BOSKUG RCP/M circa 12/27/88, and QTERM Vers. 4.x patch listing 8-Feb-89.
  21.  
  22. ; D. Presberg dissasembled this with Z8E, 21-Jan-89.  Code labels taken from
  23. ;  D. Goodenough "qterm.z" example circa 8-Feb-89.
  24.  
  25. ; This edit is for Kaypro-II and -4 ('83 version without graphics).  Kaypro
  26. ;  (and Xerox BB-I) use an SIO chip, port A, with a separate baud rate
  27. ;  generator:  status port at 04, data port at 06, baud rate port at 0.
  28. ;  15-Feb-89, D. Presberg, BCS/BOSKUG.
  29.  
  30. ; D. Goodenough added break, dtr and mode stuff  2-23-89
  31.  
  32. .var    sioc    6        ; sio control port
  33. .var    siod    4        ; sio data port
  34. .var    baud    0        ; baud rate port
  35.  
  36. .var    yes    0xff        ; true value
  37. .var    no    0        ; false value
  38.  
  39. .org    0x0110
  40. modist:    in    a,(sioc)    ;get modem input status  (Kaypro status port)
  41.     and    1        ; (result to Z:   no inp. character available
  42.     ret            ;   is 0 at bit-0 (low order) ===>   Z==1    )
  43.  
  44. .org    0x0120
  45. modin:    in    a,(siod)    ;read modem input character (Kaypro data port)
  46.     ret
  47.  
  48. .org    0x0130
  49. modost:    in    a,(sioc)    ;get modem output status  (Kaypro status port)
  50.     and    4        ; (result to Z:  bit-2 ... see above)
  51.     ret
  52.  
  53. .org    0x0140
  54. modout:    out    (siod),a    ;write modem output char. (Kaypro data port)
  55.     ret
  56.  
  57. .org    0x0150
  58. sbreak:    ld    a,(setf)    ;start "break"
  59.     or    a        ;do we have valid data in r3,r4,r5
  60.     ret    z        ;no - don't do it
  61.     jp    exmlp        ; start break takes a bit extra, see below
  62.     
  63. .org    0x0160
  64. ebreak:    ld    a,(setf)    ;end "break"
  65.     or    a
  66.     ret    z        ; don't do it unless r3, r4, r5 are valid
  67.     ld    hl,r5
  68.     res    4,(hl)
  69.     jp    sioout
  70.  
  71. .org    0x0170
  72. dtroff:    ld    a,(setf)    ;drop DTR
  73.     or    a
  74.     ret    z        ; don't do it unless r3, r4, r5 are valid
  75.     ld    hl,r5
  76.     res    7,(hl)
  77.     jp    sioout
  78.  
  79. .org    0x0180
  80. dtron:    ld    a,(setf)    ;raise DTR
  81.     or    a
  82.     ret    z        ; don't do it unless r3, r4, r5 are valid
  83.     ld    hl,r5
  84.     set    7,(hl)
  85.     jp    sioout
  86.  
  87. .org    0x0190
  88. setbd:    out    (baud),a    ;set baud rate (value in A) (Kaypro baud
  89.     ret            ;                rate port)
  90.  
  91. ; The Baud Rate Table has entries from 38400 baud down to 300 baud.
  92. ;   There are 2 bytes per entry.  The second byte determines if the entry is
  93. ;   enabled or disabled (ffh=enabled; 00=disabled).  The first byte is passed
  94. ;   as the A value to the setbd subroutine.
  95.  
  96. ; Kaypro-II/4 has advertised values for rates up to 19200.  Not all available
  97. ;   low speeds are used by QTERM, however.
  98.  
  99. .org    0x01a0
  100.  
  101. baudtb:
  102. b38400:    db    0,no        ;  38400 baud
  103. b19200:    db    0xf,yes        ;  19200
  104. b9600:    db    0xe,yes        ;   9600
  105. b4800:    db    0xc,yes        ;   4800
  106. b2400:    db    0xa,yes        ;   2400
  107. b1200:    db    7,yes        ;   1200
  108. b600:    db    6,yes        ;    600
  109. b300:    db    5,yes        ;    300 baud
  110.  
  111. ; (Kaypro goes down to 150, 134.5, 110, 75, and 50 baud, but QTERM doesn't.)
  112.  
  113. ;.org    0x01b0            ; don't need this - table above is 16 bytes
  114. setmod:    ld    (setf),a    ; flag we've done a set
  115.     jp    domod        ; have to do this elsewhere
  116.  
  117. ; Communication Mode Table.  Single byte values for 12 combinations of
  118. ;    number-of-bits(7/8), parity(none/even/odd), number-of-stop-bits(1/2).
  119.  
  120. .org    0x1c0
  121.  
  122. modetb:
  123. n17:    db    0b10000000    ;0x80, 7n1
  124. n18:    db    0b11000000    ;0xc0, 8n1
  125. n27:    db    0b10001000    ;0x88, 7n2
  126. n28:    db    0b11001000    ;0xc8, 8n2
  127. e17:    db    0b10000011    ;0x83, 7e1
  128. e18:    db    0b11000011    ;0xc3, 8e1
  129. e27:    db    0b10001011    ;0x8b, 7e2
  130. e28:    db    0b11001011    ;0xcb, 8e2
  131. o17:    db    0b10000001    ;0x81, 7o1
  132. o18:    db    0b11000001    ;0xc8, 8o1
  133. o27:    db    0b10001001    ;0x89, 7o2
  134. o28:    db    0b11001001    ;0xc9, 8o2
  135.  
  136. ;.org    0x01cc        ; don't need this - we're contiguous
  137. reserv:    db    0    ; this space is reserved for future use
  138.  
  139. ;.org    0x01cd
  140. xfersz:    db    8    ;number of K to read/write during file xfers
  141.             ;Must be 1 / 2 / 4 / 8.  Best left as 8 unless
  142.             ;  disk is verrrrry slow.  Drop to smaller value
  143.             ;  if too many timeouts occur during "protocol"
  144.             ;  file transfers (xmodem or kermit).
  145.  
  146. ;.org    0x01ce
  147. speed:    db    5    ;cpu speed (Mhz; use 3 for 2.5)
  148.             ; (5Mhz Assumes Advent speedup kit in Kaypro.)
  149.  
  150. ;.org    0x01cf
  151. escape:    db    '\\' & 0x1f    ;escape character (1ch=^\  Control-Backslash)
  152.  
  153. ;.org    0x01d0
  154. signon:            ;signon message
  155.     db    'Kaypro-II/4 1983\0'
  156.  
  157. .org    0x01f0
  158. clrs:    db    'z' & 0x1f, 0    ;clear screen string (Control-Z)
  159. ;clrs:    db    '\eE\0'    ; <esc> E on VT52 systems????
  160.  
  161. .var    scrout    0x0109    ;(a routine to print to CON: the
  162.             ;   character in C)
  163. .var    decout    0x010c    ;(a routine to print to CON: a decimal value
  164.             ;   in HL.  Is available for VT100 and the like.)
  165.  
  166. .org    0x0200
  167. moveto:    push    hl    ;move cursor to position in HL (Row,Col)
  168.     ld    c,'\e'    ; lead-in with Esc (the ASCII one; not QTERM's)
  169.     call    scrout
  170.     ld    c,'='    ; 2nd lead-in is '=' : change this to 'Y' for VT52
  171.     call    scrout    ; screens (Superbrain is one such, also Heath/Zenith
  172.     pop    hl    ; systems)
  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. .var    b_brit    0b00000001    ; 0: bright (1.)    -- NOT mandatory
  186. .var    b_dim    0b00000010    ; 1: dim    (2.)    -- NOT mandatory
  187. .var    b_dlln    0b00000100    ; 2: delete line (4.)    -- important
  188. .var    b_inln    0b00001000    ; 3: insert line (8.)    -- important
  189. .var    b_dlch    0b00010000    ; 4: delete character (16.)-- unused by QTERM
  190. .var    b_inch    0b00100000    ; 5: insert character (32.)-- NOT mandatory
  191. .var    b_clel    0b01000000    ; 6: clear to end-of-line(64.) -- important
  192. .var    b_cles    0b10000000    ; 7: clear to end-of-screen(128.)-- important
  193.  
  194. .org    0x022f
  195. tcbits:    db    b_dlln + b_inln + b_clel + b_cles    ; capability bits
  196.  
  197. ; (Kaypro-II/4, non-graphics version, cannot do in-place insertion or deletion
  198. ;   of single characters:  it can only overwrite characters at the current
  199. ;   cursor position and move the cursor non-destructively, etc..  It can
  200. ;   do in-place insertion and deletion of lines, and its clear-to-end-of-
  201. ;   -screen and -line leaves the cursor as-is.  It also has clear-screen-and-
  202. ;   -home-the-cursor: see clrs, above.  It, of course, has no graphical screen
  203. ;   attributes, such as bright and dim.)
  204.  
  205. ;.org    0x0230
  206. brites:    db    0    ;bright string (none for '83 Kaypro)
  207.  
  208. .org    0x0238
  209. dims:    db    0    ;dim string    (none for '83 Kaypro)
  210.  
  211. .org    0x0240
  212. dlstr:    db    '\eR\0'    ;delete line
  213.  
  214. .org    0x0248
  215. ilstr:    db    '\eE\0'    ;insert line
  216.  
  217. .org    0x0250
  218. dcstr:    db    0    ;delete character (none for '83 Kaypro)
  219.  
  220. .org    0x0258
  221. icstr:    db    0    ;insert character (none for '83 Kaypro)
  222.  
  223. .org    0x0260
  224. ceol:    db    'x' & 0x1f, 0    ;clear to end of line (Control-X)
  225.  
  226. .org    0x0268
  227. ceos:    db    'w' & 0x1f, 0    ;clear to end-of-screen (Control-W)
  228.  
  229. ; Entry and Exit hooks.  These are provided to perform custom initialisation
  230. ; on startup and on exit from QTERM.  They are invoked before any use is made
  231. ; of the screen or the port hardware.
  232.  
  233. .org    0x0270
  234. entry:    jp    do_ent        ; entry hook (270h .. 272h)
  235.  
  236. ;.org    0x0273            ; exit hook  (273h .. 275h)    
  237. exit:    ret            ;   Kaypro-II/4 doesn't need anything.
  238.  
  239. ; Extra patch area if needed.  276h .. 2ffh
  240.  
  241. .org    0x0276
  242. patcha: 
  243.  
  244. do_ent:    ld    a,(b1200)    ; entry hook (from 270h)
  245.     call    setbd        ;   Kaypro-II/4 setup for 1200 baud
  246.     ld    a,(n18)        ; and 8n1 communications mode.
  247.     call    setmod
  248.     ret
  249.  
  250. exmlp:    ld    a,1        ; wait till transmitter is really finished
  251.     out    (siod),a
  252.     in    a,(siod)
  253.     rra
  254.     jr    nc,exmlp    ; loop till buffer empty
  255.     ld    hl,r5
  256.     set    4,(hl)        ; now go set the break bit.
  257.  
  258. sioout:    ld    hl,siodat
  259.     ld    bc,6 * 256 + sioc
  260.     otir
  261.     ret
  262.  
  263. domod:    ld    c,a        ; save byte in c
  264.     ld    hl,r3        ; look at byte for wr3
  265.     res    7,(hl)        ; turn off ms bit (Rx # bits / char)
  266.     add    a,a        ; move bit from 6 to 7 in a
  267.     and    0x80        ; mask off the rest
  268.     or    (hl)        ; or in the remainder
  269.     ld    (hl),a        ; and save it back
  270.     inc    hl
  271.     inc    hl        ; point hl at r4
  272.     ld    a,(hl)
  273.     and    0xf4        ; mask out bits we don't want
  274.     ld    b,a        ; save in b
  275.     ld    a,c        ; get set byte back
  276.     and    0x0b        ; get bits out of set byte that we want
  277.     or    b        ; or in the other bits
  278.     ld    (hl),a        ; and save it back
  279.     inc    hl
  280.     inc    hl        ; point hl at r5
  281.     ld    a,c
  282.     and    0x40        ; get the bit we want from c
  283.     res    6,(hl)        ; clear the bit in r5
  284.     or    (hl)
  285.     ld    (hl),a        ; put new composite value back
  286.     jp    sioout        ; go send the values
  287.  
  288. siodat:    db    3
  289. r3:    db    0b11000001    ; value for wr3 (0xc1)
  290.     db    4
  291. r4:    db    0b01000100    ; value for wr4 (0x44)
  292.     db    5
  293. r5:    db    0b11101010    ; value for wr5 (0xe5)
  294.  
  295. setf:    db    0        ; flag if we've done a set mode command
  296.