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-ALB.Z < prev    next >
Text File  |  1989-09-08  |  8KB  |  323 lines

  1. ; QT-ALB.Z - Ampro Little Board overlay for QTERM 4.X
  2. ; Written By Larry Schnitger
  3. ; adapted for ZSM by David Goodenough.
  4. ; baud rate code added from IMP overlay by David Goodenough
  5. ;
  6. ; This overlay file was modeled after the Ampro Little Board overlay
  7. ; for use with MEX, the communications software from NiteOwl Software.
  8. ; The patch points indicated by the QTERM documentation have been 
  9. ; worked into the overlay, some routines have been moved around to fit
  10. ; the QTERM architecture, and others have been deleted since they do
  11. ; not apply to the QTERM program.
  12. ;
  13. ; TO USE: First edit this file with your favorite ASCII editor, changing
  14. ;               routines to conform to your hardware and changing
  15. ;               equates to conform to your implementation selections.
  16. ;               Then assemble with ZSM, to create a .O file, finally
  17. ;               apply the overlay using ZPATCH to the original .COM
  18. ;               file to produce the patched .COM file.
  19. ;
  20. ; Commands to do the above are:
  21. ;
  22. ;        A>ZSM QT-ALB
  23. ;        A>ZPATCH QTERM QT-ALB
  24. ;
  25. .var    yes    -1
  26. .var    no    0
  27. ;
  28. .var    sioc    0x8c    ; sio control port
  29. .var    siod    0x88    ; sio data port
  30. .var    rxrdy    1    ; receiver ready
  31. .var    txrdy    4    ; transmitter ready
  32. .var    baud    0x50    ; baud rate port - CTC
  33. ;
  34. .var    scrout    0x0109    ; QTERM print char routine address
  35. .var    decout    0x010c    ; QTERM print number routine address
  36. ;
  37. ;       Code begins here...
  38. ;
  39. ; Modem input status routine:
  40. ;
  41. .org    0x0110
  42. modist:    in    a,(sioc)    ;get modem input status
  43.     and    rxrdy
  44.     ret
  45.  
  46. .org    0x0120
  47. modin:    in    a,(siod)    ;read modem input character
  48.     ret
  49.  
  50. .org    0x0130
  51. modost:    in    a,(sioc)    ;get modem output status
  52.     and    txrdy
  53.     ret
  54.  
  55. .org    0x0140
  56. modout:    out    (siod),a    ;write modem output char.
  57.     ret
  58.  
  59. .org    0x0150
  60. sbreak:    ld    a,(setf)    ;start "break"
  61.     or    a        ;do we have valid data in r3,r4,r5
  62.     ret    z        ;no - don't do it
  63.     ld    hl,r5
  64.     set    4,(hl)
  65.     jp    sioout
  66.     
  67. .org    0x0160
  68. ebreak:    ld    a,(setf)    ;end "break"
  69.     or    a
  70.     ret    z        ; don't do it unless r3, r4, r5 are valid
  71.     ld    hl,r5
  72.     res    4,(hl)
  73.     jp    sioout
  74.  
  75. .org    0x0170
  76. dtroff:    ld    a,(setf)    ;drop DTR (actually CTS)
  77.     or    a
  78.     ret    z        ; don't do it unless r3, r4, r5 are valid
  79.     ld    hl,r5
  80.     res    7,(hl)
  81.     jp    sioout
  82.  
  83. .org    0x0180
  84. dtron:    ld    a,(setf)    ;raise DTR
  85.     or    a
  86.     ret    z        ; don't do it unless r3, r4, r5 are valid
  87.     ld    hl,r5
  88.     set    7,(hl)
  89.     jp    sioout
  90.  
  91. ;
  92. ; Set Baud Rate routine:
  93. ;
  94. .org    0x0190
  95. setbd:
  96.     jp    opctc        ; index into our table, and talk to the CTC
  97. ;
  98. ; Baud rate table:
  99. ;
  100. .org    0x01a0
  101.  
  102. baudtb:
  103. b38400:    db    0,no        ;  38400 baud
  104. b19200:    db    0,no        ;  19200
  105. b9600:    db    8,yes        ;   9600
  106. b4800:    db    6,yes        ;   4800
  107. b2400:    db    4,yes        ;   2400
  108. b1200:    db    2,yes        ;   1200
  109. b600:    db    0,no        ;    600
  110. b300:    db    0,yes        ;    300 baud
  111.  
  112. ;
  113. ; Communications mode setting routine:
  114. ;
  115. ;.org    0x01b0            ; don't need this - table above is 16 bytes
  116. setmod:    ld    (setf),a    ; flag we've done a set
  117.     jp    domod        ; have to do this elsewhere
  118.  
  119. ; Communication Mode Table.  Single byte values for 12 combinations of
  120. ;    number-of-bits(7/8), parity(none/even/odd), number-of-stop-bits(1/2).
  121.  
  122. .org    0x1c0
  123.  
  124. modetb:
  125. n17:    db    0b10000000    ;0x80, 7n1
  126. n18:    db    0b11000000    ;0xc0, 8n1
  127. n27:    db    0b10001000    ;0x88, 7n2
  128. n28:    db    0b11001000    ;0xc8, 8n2
  129. e17:    db    0b10000011    ;0x83, 7e1
  130. e18:    db    0b11000011    ;0xc3, 8e1
  131. e27:    db    0b10001011    ;0x8b, 7e2
  132. e28:    db    0b11001011    ;0xcb, 8e2
  133. o17:    db    0b10000001    ;0x81, 7o1
  134. o18:    db    0b11000001    ;0xc8, 8o1
  135. o27:    db    0b10001001    ;0x89, 7o2
  136. o28:    db    0b11001001    ;0xc9, 8o2
  137.  
  138. ;.org    0x01cc        ; don't need this - we're contiguous
  139. resrvd:    db    0    ; reserved for future use.
  140.  
  141. ;.org    0x01cd
  142. xfersz:    db    8    ;number of K to read/write during file xfers
  143.             ;Must be 1 / 2 / 4 / 8.  Best left as 8 unless
  144.             ;  disk is verrrrry slow.  Drop to smaller value
  145.             ;  if too many timeouts occur during "protocol"
  146.             ;  file transfers (xmodem or kermit).
  147.  
  148. ;.org    0x01ce
  149. speed:    db    4    ;cpu speed
  150.  
  151. ;.org    0x01cf
  152. escape:    db    '\\' & 0x1f    ;escape character (1ch=^\  Control-Backslash)
  153.  
  154. ; signon message - terminate with a null byte
  155.  
  156. ;.org    0x01d0
  157. signon:            ;signon message
  158.     db    'Ampro Little Board\0'
  159.  
  160. ; From here on down, the stuff is terminal dependant. I've made three .vars
  161. ; one each for Televideo, VT52 and ANSI (i.e. VT100 / VT220 etc)
  162. ; set _EXACTLY_ one to be true, this will provide a bare bones overlay.
  163. ; If the spirit moves, feel free to alter the terminal capabilities at the
  164. ; bottom
  165.  
  166. .var    tvi    yes        ; Televideo: also C128, Kaypro, ADM 3A
  167.                 ; ADM 31, Wyse (all models), Liberty
  168.                 ; Freedom (all models)
  169. .var    vt52    no        ; Heath / Zenith 19 / 89 / 90, Intertec
  170.                 ; superbrain
  171. .var    vt100    no        ; Any ansi compatible tube
  172.  
  173. .org    0x01f0
  174. clrs:
  175. .if    tvi
  176.     db    'z' & 0x1f, 0    ;clear screen string (Control-Z)
  177. .elif    vt52
  178.     db    '\eE\0'
  179. .elif    vt100
  180.     db    '\e[H\e[2J\0'
  181. .endif
  182.  
  183. .org    0x0200
  184. .if    tvi | vt52
  185. moveto:    push    hl    ;move cursor to position in HL (Row,Col)
  186.     ld    c,'\e'    ; lead-in with Esc (the ASCII one; not QTERM's)
  187.     call    scrout
  188.     ld    c,[ tvi ? '=' : 'Y' ]    ; 2nd lead-in is '=' or 'Y'
  189.     call    scrout
  190.     pop    hl
  191.     push    hl
  192.     ld    a,h    ; row value (top row is 0.)
  193.     call    poff    ; add offset and send it to screen
  194.     pop    hl
  195.     ld    a,l    ; col value (leftmost col is 0.)
  196. poff:    add    a,' '    ; (adds 20h)
  197.     ld    c,a
  198.     jp    scrout    ; (scrout returns from 'moveto's call)
  199. .elif    vt100
  200.     push    hl
  201.     ld    c,'\e'
  202.     call    scrout
  203.     ld    c,'['
  204.     call    scrout
  205.     pop    hl
  206.     push    hl
  207.     ld    h,0
  208.     inc    l
  209.     call    decout
  210.     ld    c,';'
  211.     call    scrout
  212.     pop    hl
  213.     ld    l,h
  214.     ld    h,0
  215.     inc    l
  216.     call    decout
  217.     ld    c,'H'
  218.     jp    scrout
  219. .endif
  220.  
  221. .org    0x22f
  222. tcbits:
  223.     db    0b00000000        ; must be zero for "generic" overlay
  224. ;          ||||||||
  225. ;          |||||||+------ bright (end highlight)
  226. ;          ||||||+------- dim (start highlight)
  227. ;          |||||+-------- delete line
  228. ;          ||||+--------- insert line
  229. ;          |||+---------- delete character
  230. ;          ||+----------- insert character
  231. ;          |+------------ clear to end of line
  232. ;          +------------- clear to end of screen
  233. ;
  234. ;
  235. ;.org    0x0230
  236. brites:    db    0    ;bright string
  237.  
  238. .org    0x0238
  239. dims:    db    0    ;dim string
  240.  
  241. .org    0x0240
  242. dlstr:    db    0    ;delete line
  243.  
  244. .org    0x0248
  245. ilstr:    db    0    ;insert line
  246.  
  247. .org    0x0250
  248. dcstr:    db    0    ;delete character
  249.  
  250. .org    0x0258
  251. icstr:    db    0    ;insert character
  252.  
  253. .org    0x0260
  254. ceol:    db    0    ;clear to end of line
  255.  
  256. .org    0x0268
  257. ceos:    db    0    ;clear to end-of-screen
  258.  
  259. ; Entry and Exit hooks.  These are provided to perform custom initialisation
  260. ; on startup and on exit from QTERM.  They are invoked before any use is made
  261. ; of the screen or the port hardware.
  262.  
  263. .org    0x0270
  264. entry:    jp    do_ent        ; entry hook (270h .. 272h)
  265.  
  266. ;.org    0x0273            ; exit hook  (273h .. 275h)    
  267. exit:    ret            ; don't need anything.
  268.  
  269. ; Extra patch area if needed.  276h .. 2ffh
  270.  
  271. .org    0x0276
  272. patcha: 
  273.  
  274. do_ent:    ld    a,(b1200)    ; entry hook (from 270h)
  275.     call    setbd        ; setup for 1200 baud
  276.     ld    a,(n18)        ; and 8n1 communications mode.
  277.     call    setmod
  278.     ret
  279.  
  280. domod:    ld    c,a        ; save byte in c
  281.     ld    hl,r3        ; look at byte for wr3
  282.     res    7,(hl)        ; turn off ms bit (Rx # bits / char)
  283.     add    a,a        ; move bit from 6 to 7 in a
  284.     and    0x80        ; mask off the rest
  285.     or    (hl)        ; or in the remainder
  286.     ld    (hl),a        ; and save it back
  287.     inc    hl
  288.     inc    hl        ; point hl at r4
  289.     ld    a,(hl)
  290.     and    0xf4        ; mask out bits we don't want
  291.     ld    b,a        ; save in b
  292.     ld    a,c        ; get set byte back
  293.     and    0x0b        ; get bits out of set byte that we want
  294.     or    b        ; or in the other bits
  295.     ld    (hl),a        ; and save it back
  296.     inc    hl
  297.     inc    hl        ; point hl at r5
  298.     ld    a,c
  299.     and    0x40        ; get the bit we want from c
  300.     res    6,(hl)        ; clear the bit in r5
  301.     or    (hl)
  302.     ld    (hl),a        ; put new composite value back
  303.  
  304. sioout:    ld    hl,siodat
  305.     ld    bc,6 * 256 + sioc
  306.     otir
  307.     ret
  308.  
  309. siodat:    db    3
  310. r3:    db    0b11000001    ; value for wr3 (0xc1)
  311.     db    4
  312. r4:    db    0b01000100    ; value for wr4 (0x44)
  313.     db    5
  314. r5:    db    0b11101010    ; value for wr5 (0xe5)
  315.  
  316. setf:    db    0        ; flag if we've done a set mode command
  317.  
  318. bv300:    dw    0x0734
  319. bv1200:    dw    0x4768
  320. bv2400:    dw    0x4734
  321. bv4800:    dw    0x471a
  322. bv9600:    dw    0x470d
  323.