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 / BEEHIVE / COMMS / QTERM42G.ARC / QT-PATCH.Z < prev    next >
Text File  |  1991-08-11  |  9KB  |  307 lines

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