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

  1. ; QTERM Version 4.x Patch Area
  2.  
  3. ; This is for the Morrow MD34, created by putting it's port addresses and
  4. ; baud rate code into the "generic" SIO patch. Since the MD34 screen is
  5. ; ADM-3A compatible, all the standard Televideo Screen codes will work
  6. ; as is, so they have been incorporated from the original TVI803 source.
  7.  
  8. ; Created by D. Goodenough, 7-29-89
  9.  
  10. .var    yes    0xff        ; true value
  11. .var    no    0        ; false value
  12.  
  13. .var    sio    yes        ; set yes to use the SIO, set no to use
  14.                 ; the other half of the DART
  15.  
  16. .if    sio
  17. .var    siod    0x70        ; Use RS232 socket at other end from
  18. .var    sioc    0x71        ;   Terminal
  19. .var    ctc    0x50
  20. .var    mode    0x3e
  21. .else
  22. .var    siod    0x62        ; Use RSs232 socket adjacent to Terminal
  23. .var    sioc    0x63
  24. .var    ctc    0x51
  25. .var    mode    0x7e
  26. .endif
  27.  
  28. .var    rxrdy    1        ; receiver ready
  29. .var    txrdy    4        ; transmitter ready
  30.  
  31. .var    ctcsel    0x53        ; ctc select / control port
  32.  
  33. .org    0x0110
  34. modist:    in    a,(sioc)    ;get modem input status
  35.     and    rxrdy        ; (result to Z:   no inp. character available
  36.     ret            ;   is 0 at bit-0 (low order) ===>   Z==1    )
  37.  
  38. .org    0x0120
  39. modin:    in    a,(siod)    ;read modem input character
  40.     ret
  41.  
  42. .org    0x0130
  43. modost:    in    a,(sioc)    ;get modem output status
  44.     and    txrdy        ; (result to Z:  bit-2 ... see above)
  45.     ret
  46.  
  47. .org    0x0140
  48. modout:    out    (siod),a    ;write modem output char.
  49.     ret
  50.  
  51. .org    0x0150
  52. sbreak:    ld    a,(setf)    ;start "break"
  53.     or    a        ;do we have valid data in r3,r4,r5
  54.     ret    z        ;no - don't do it
  55.     ld    hl,r5
  56.     set    4,(hl)        ; set the bit
  57.     jp    sioout        ; and go do it
  58.     
  59. .org    0x0160
  60. ebreak:    ld    a,(setf)    ;end "break"
  61.     or    a
  62.     ret    z        ; don't do it unless r3, r4, r5 are valid
  63.     ld    hl,r5
  64.     res    4,(hl)
  65.     jp    sioout        ; go clear the bit
  66.  
  67. .org    0x0170
  68. dtroff:    ld    a,(setf)    ;drop DTR
  69.     or    a
  70.     ret    z        ; don't do it unless r3, r4, r5 are valid
  71.     ld    hl,r5
  72.     res    7,(hl)
  73.     jp    sioout
  74.  
  75. .org    0x0180
  76. dtron:    ld    a,(setf)    ;raise DTR
  77.     or    a
  78.     ret    z        ; don't do it unless r3, r4, r5 are valid
  79.     ld    hl,r5
  80.     set    7,(hl)
  81.     jp    sioout
  82.  
  83. .org    0x0190
  84. setbd:    ld    e,a
  85.     ld    d,0
  86.     ld    hl,brtab
  87.     add    hl,de        ; index into baud rate table
  88.     ld    a,mode        ; 0x3e or 0x7e
  89.     out    (ctcsel),a    ; select the correct timer and mode
  90.     jp    finbd        ; go finish elsewhere
  91.  
  92. .org    0x01a0
  93. baudtb:
  94. b38400:    db    0,no        ;  38400 baud
  95. b19200:    db    0,no        ;  19200
  96. b9600:    db    0,yes        ;   9600
  97. b4800:    db    2,yes        ;   4800
  98. b2400:    db    4,yes        ;   2400
  99. b1200:    db    6,yes        ;   1200
  100. b600:    db    8,yes        ;    600
  101. b300:    db    10,yes        ;    300 baud
  102.  
  103. ;.org    0x01b0            ; don't need this - table above is 16 bytes
  104. setmod:    ld    (setf),a    ; flag we've done a set
  105.     jp    domod        ; have to do this elsewhere
  106.  
  107. ; Communication Mode Table.  Single byte values for 12 combinations of
  108. ;    number-of-bits(7/8), parity(none/even/odd), number-of-stop-bits(1/2).
  109.  
  110. .org    0x1c0
  111. modetb:
  112. n17:    db    0b10000000    ;0x80, 7n1
  113. n18:    db    0b11000000    ;0xc0, 8n1
  114. n27:    db    0b10001000    ;0x88, 7n2
  115. n28:    db    0b11001000    ;0xc8, 8n2
  116. e17:    db    0b10000011    ;0x83, 7e1
  117. e18:    db    0b11000011    ;0xc3, 8e1
  118. e27:    db    0b10001011    ;0x8b, 7e2
  119. e28:    db    0b11001011    ;0xcb, 8e2
  120. o17:    db    0b10000001    ;0x81, 7o1
  121. o18:    db    0b11000001    ;0xc8, 8o1
  122. o27:    db    0b10001001    ;0x89, 7o2
  123. o28:    db    0b11001001    ;0xc9, 8o2
  124.  
  125. ;.org    0x01cc        ; don't need this - we're contiguous
  126. resrvd:    db    0    ; reserved for future use
  127.  
  128. ;.org    0x01cd
  129. xfersz:    db    8    ;number of K to read/write during file xfers
  130.             ;Must be 1 / 2 / 4 / 8.  Best left as 8 unless
  131.             ;  disk is verrrrry slow.  Drop to smaller value
  132.             ;  if too many timeouts occur during "protocol"
  133.             ;  file transfers (xmodem or kermit).
  134.  
  135. ;.org    0x01ce
  136. speed:    db    4    ;cpu speed (Mhz; use 3 for 2.5)
  137.  
  138. ;.org    0x01cf
  139. escape:    db    '\\' & 0x1f    ;escape character (1ch=^\  Control-Backslash)
  140.  
  141. ;.org    0x01d0
  142. signon:            ;signon message
  143.     db    'Morrow MD34, '
  144. .if    sio
  145.     db    'SIO'
  146. .else
  147.     db    'MODEM'
  148. .endif
  149.     db    ' port\0'
  150.  
  151. .org    0x01f0
  152. clrs:    db    '\e*\0'    ;clear screen string (Escape '*')
  153.  
  154. .var    scrout    0x0109    ;(a routine to print to CON: the
  155.             ;   character in C)
  156. .var    decout    0x010c    ;(a routine to print to CON: a decimal value
  157.             ;   in HL.  Is available for VT100 and the like.)
  158.  
  159. .org    0x0200
  160. moveto:    push    hl    ;move cursor to position in HL (Row,Col)
  161.     ld    c,'\e'    ; lead-in with Esc (the ASCII one; not QTERM's)
  162.     call    scrout
  163.     ld    c,'='    ; 2nd lead-in is '='
  164.     call    scrout
  165.     pop    hl
  166.     push    hl
  167.     ld    a,h    ; row value (top row is 0.)
  168.     call    poff    ; add offset and send it to screen
  169.     pop    hl
  170.     ld    a,l    ; col value (leftmost col is 0.)
  171. poff:    add    a,' '    ; (adds 20h)
  172.     ld    c,a
  173.     jp    scrout    ; (scrout returns from 'moveto's call)
  174.  
  175. ; these next strings are used to do various screen functions. There are
  176. ; eight of them, and immediately preceding them is a flag byte. Each string
  177. ; has a bit in the byte, and if a capability is present, its bit should
  178. ; be set. This byte is an absolute necessity, as various programs use it
  179. ; to tell if various things are present.
  180.  
  181. .org    0x022f
  182. .extern    tcbits
  183. tcbits:    db    0b11111111    ; bits are:
  184.                 ; 0: bright        b_brite    1
  185.                 ; 1: dim        b_dim    2
  186.                 ; 2: delete line    b_delln    4
  187.                 ; 3: insert line    b_insln    8
  188.                 ; 4: delete character    b_delch    16
  189.                 ; 5: insert character    b_insch    32
  190.                 ; 6: clear end line    b_cleol    64
  191.                 ; 7: clear end screen    b_cleos    128
  192.  
  193.  
  194. ;.org    0x0230            ; don't need this: the byte above does it
  195. .extern    brites
  196. brites:    db    '\e(\0'
  197.  
  198. .org    0x0238
  199. .extern    dims
  200. dims:    db    '\e)\0'
  201.  
  202. .org    0x0240
  203. .extern    dlstr
  204. dlstr:    db    '\eR\0'
  205.  
  206. .org    0x0248
  207. .extern    ilstr
  208. ilstr:    db    '\eE\0'
  209.  
  210. .org    0x0250
  211. .extern    dcstr
  212. dcstr:    db    '\eW\0'
  213.  
  214. .org    0x0258
  215. .extern    icstr
  216. icstr:    db    '\eQ\0'
  217.  
  218. .org    0x0260
  219. .extern    ceol
  220. ceol:    db    '\eT\0'
  221.  
  222. .org    0x0268
  223. .extern    ceos
  224. ceos:    db    '\eY\0'
  225.  
  226. ; Entry and Exit hooks.  These are provided to perform custom initialisation
  227. ; on startup and on exit from QTERM.  They are invoked before any use is made
  228. ; of the screen or the port hardware.
  229.  
  230. .org    0x0270
  231. entry:    jp    do_ent        ; entry hook (270h .. 272h)
  232.  
  233. ;.org    0x0273            ; exit hook  (273h .. 275h)    
  234. exit:    ret
  235.  
  236. ; Extra patch area if needed.  276h .. 2ffh
  237.  
  238. .org    0x0276
  239. patcha: 
  240.  
  241. do_ent:    ld    a,(b1200)    ; entry hook (from 270h)
  242.     call    setbd        ; setup for 1200 baud
  243.     ld    a,(n18)        ; and 8n1 communications mode.
  244.     call    setmod
  245.     ret
  246.  
  247. domod:    ld    c,a        ; save byte in c
  248.     ld    hl,r3        ; look at byte for wr3
  249.     res    7,(hl)        ; turn off ms bit (Rx # bits / char)
  250.     add    a,a        ; move bit from 6 to 7 in a
  251.     and    0x80        ; mask off the rest
  252.     or    (hl)        ; or in the remainder
  253.     ld    (hl),a        ; and save it back
  254.     inc    hl
  255.     inc    hl        ; point hl at r4
  256.     ld    a,(hl)
  257.     and    0xf4        ; mask out bits we don't want
  258.     ld    b,a        ; save in b
  259.     ld    a,c        ; get set byte back
  260.     and    0x0b        ; get bits out of set byte that we want
  261.     or    b        ; or in the other bits
  262.     ld    (hl),a        ; and save it back
  263.     inc    hl
  264.     inc    hl        ; point hl at r5
  265.     ld    a,c
  266.     and    0x40        ; get the bit we want from c
  267.     res    6,(hl)        ; clear the bit in r5
  268.     or    (hl)
  269.     ld    (hl),a        ; put new composite value back
  270.  
  271. sioout:    ld    hl,siodat
  272.     ld    bc,6 * 256 + sioc
  273.     otir
  274.     ret
  275.  
  276. siodat:    db    3
  277. r3:    db    0b11000001    ; value for wr3 (0xc1)
  278.     db    4
  279. r4:    db    0b01000100    ; value for wr4 (0x44)
  280.     db    5
  281. r5:    db    0b11101010    ; value for wr5 (0xe5)
  282.  
  283. setf:    db    0        ; flag if we've done a set mode command
  284.  
  285. finbd:    ld    a,(hl)
  286.     out    (ctc),a
  287.     inc    hl
  288.     ld    a,(hl)
  289.     out    (ctc),a
  290.     ret
  291.  
  292. brtab:    dw    26        ; 9600         0
  293.     dw    52        ; 4800         2
  294.     dw    104        ; 2400         4
  295.     dw    208        ; 1200         6
  296.     dw    417        ; 600         8
  297.     dw    833        ; 300         10
  298.