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-OTRON.Z < prev    next >
Text File  |  1989-09-08  |  7KB  |  269 lines

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