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

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