home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / qterm / qtpat42.lbr / QT-MD34.ZY / QT-MD34.ZY
Text File  |  1991-05-29  |  7KB  |  307 lines

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