home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / spectrum / qt-plus3.z < prev    next >
Encoding:
Text File  |  1994-06-08  |  5.6 KB  |  277 lines

  1. ; QTERM patch file for the Sinclair ZX Spectrum +3, running Locomotive
  2. ; CP/M Plus.
  3.  
  4. ; Russell Marks, 94/06/07  (rm1ajy3@gre.ac.uk from Oct. 94, probably)
  5.  
  6. ; You'll need this file (qt-plus3.z) as well as qterm.com, zsm.com and
  7. ; zpatch.com. Qterm.com is in qterm43e.lbr, the latter two are in
  8. ; qtpat42.lbr. (See /pub/cpm/starter-kit and /pub/cpm/gendoc/os-cpm.faq
  9. ; if you don't know what a '.lbr' file is.)
  10.  
  11. ; Then do this to make a speccy qterm.com:
  12.  
  13. ; A>zsm qt-plus3.z
  14. ; ZSM  V2.3 - (C) Copyright  DPG  1987
  15. ;
  16. ; A>zpatch qterm.com qt-plus3.o
  17. ; ZPATCH  V2.3 - (C) Copyright  DPG  1987
  18. ;
  19. ; Then try it out, but you'll have to set up the SIO with setsio
  20. ; before starting, as I haven't bothered to add the SIO config.
  21. ; patch bits yet. Sorry.
  22.  
  23. ; Cheers, and good luck! (From a CP/M newbie of three weeks)
  24.  
  25.  
  26. ; This patch mostly uses the I/O functions supplied by the bdos
  27. ; which deal with AUX:, so you may be able to get them to work with
  28. ; the external modem port (that plugs into the expansion bit on the
  29. ; back). However it's intended for use with the nasty old internal
  30. ; 6-pin weirdo serial port, and has only been tested on such.
  31.  
  32. ; the escape char is ^\, which is EXTEND + EDIT unless you've remapped
  33. ; your keyboard.
  34.  
  35.  
  36. ; Since the +3 is a strange beast, this isn't quite as easy as it should
  37. ; be. I initially tried a straight patch using bdos calls, which worked
  38. ; but only responded to keypresses if the key was held down for a fair
  39. ; time (half a second or so). This patch kludges round that by only
  40. ; allowing the 'modem input status' routine to really check the SIO
  41. ; status every 8 tries, which seems to give a reasonable time for the
  42. ; interrupt-driven keyboard read routine in CP/M to do its' work.
  43. ; (It disables interrupts when checking the 'serial port', you see.)
  44. ; However, this slows down the serial input a fair bit, so I also check
  45. ; if the last time it really checked the input status there was a char.
  46. ; ready. If so, it skips the delay and allows the real SIO check to
  47. ; happen straight away. This is the best compromise I can come up with,
  48. ; and it's quite useable, I think. It also works ok for file transfers.
  49.  
  50. .org 0x0110
  51. modist:
  52. jp kludge    ;jump to large-ish routine described above
  53.  
  54. .org 0x0120
  55. modin:
  56. ld c,3
  57. call 5        ;bdos, read char. from AUX
  58. ret
  59.  
  60. .org 0x130
  61. modost:
  62. ld c,8
  63. call 5
  64. and a
  65. ret
  66.  
  67. .org 0x0140
  68. modout:
  69. ld c,4
  70. ld e,a
  71. call 5
  72. ret
  73.  
  74.  
  75. ;no break for now
  76. .org 0x0150
  77. sbreak:
  78. ret
  79.  
  80. .org 0x0160
  81. ebreak:
  82. ret
  83.  
  84.  
  85. ;no dtr raise/drop for now
  86. .org 0x0170
  87. dtroff:
  88. ret
  89.  
  90. .org 0x0180
  91. dtron:
  92. ret
  93.  
  94.  
  95. ;set baud rate - uh, guess :)
  96. ;you'll have to use 'setsio' for now.
  97. .org 0x0190
  98. setbd:
  99. ret
  100.  
  101. .org 0x01a0
  102. baudtb:
  103. b38400:    db 0,0
  104. b19200:    db 0,0
  105. b9600:    db 0,0
  106. b4800:    db 0,0
  107. b2400:    db 0,0
  108. b1200:    db 0,0
  109. b600:    db 0,0
  110. b300:    db 0,0
  111.  
  112.  
  113. ;more of the same
  114. .org 0x01b0
  115. setmod:
  116. ret
  117.  
  118. ; [from qt-patch.z, in case I decide to do this stuff sometime]
  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 0x01c0
  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.  
  139. .org 0x01cc
  140. resvd:    db 0
  141. xfersz:    db 8
  142. speed:    db 4        ;3.55 MHz, rounded up
  143. escape:    db '\\' & 0x1f    ;escape char. - ^\, better known as EXTEND MODE + EDIT
  144.  
  145. .org 0x1d0
  146. signon:
  147. db 'Sinclair ZX Spectrum +3',0
  148.  
  149. .org 0x1f0
  150. clrs:    db '\eH\eJ',0    ;clear screen with ESC H ESC J
  151.  
  152. .var scrout 0x109
  153.  
  154. ; move to h,l on screen
  155. .org 0x200
  156. moveto:
  157. push hl
  158. ld c,27
  159. call scrout
  160. ld c,'Y'
  161. call scrout
  162. pop hl
  163. push hl
  164. ld a,h
  165. call addprn
  166. pop hl
  167. ld a,l
  168.  
  169. addprn:
  170. add a,32
  171. ld c,a
  172. jp scrout
  173.  
  174.  
  175. ; [from qt-patch.z]
  176. ; Terminal Capability Bits.  The eight bits stand for each of the following
  177. ;   strings.   They count from 01h=bright to 80h=clear-to-end-of-screen.
  178.  
  179. .var    b_brit    0b00000001    ; 0: bright (1.)    -- NOT mandatory
  180. .var    b_dim    0b00000010    ; 1: dim    (2.)    -- NOT mandatory
  181. .var    b_dlln    0b00000100    ; 2: delete line (4.)    -- important
  182. .var    b_inln    0b00001000    ; 3: insert line (8.)    -- important
  183. .var    b_dlch    0b00010000    ; 4: delete character (16.)-- unused by QTERM
  184. .var    b_inch    0b00100000    ; 5: insert character (32.)-- NOT mandatory
  185. .var    b_clel    0b01000000    ; 6: clear to end-of-line(64.) -- important
  186. .var    b_cles    0b10000000    ; 7: clear to end-of-screen(128.)-- important
  187.  
  188. .org 0x022f
  189. trmcap:    db b_brit + b_dim + b_dlln + b_inln + b_dlch + b_clel + b_cles
  190.  
  191. ; Here I render the bright/dim as underline, as reverse video is damned
  192. ; hard to read on a TV. :(  Change to ESC q and ESC p respectively if
  193. ; you want rev. video.
  194.  
  195. .org 0x0230
  196. brites: db '\eu',0    ;stop underline
  197.  
  198. .org 0x0238
  199. dims:    db '\er',0    ;start underline
  200.  
  201. .org 0x0240
  202. dlstr:    db '\eM',0    ;delete line
  203.  
  204. .org 0x0248
  205. ilstr:    db '\eL',0    ;insert line
  206.  
  207. .org 0x0250
  208. dcstr:    db '\eN',0    ;delete char. - unused?
  209.  
  210. .org 0x0258
  211. icstr:    db 0        ;speccy doesn't have one
  212.  
  213. .org 0x0260
  214. ceol:    db '\eK',0    ;clear to end of line
  215.  
  216. .org 0x0268
  217. ceos:    db '\eJ',0    ;clear to end of screen
  218.  
  219.  
  220. ;now the various hooks.
  221. ;these are in xyzzy mode at the moment, i.e. nothing happens. :)
  222.  
  223. .org 0x0270
  224. entry:
  225. ret
  226.  
  227. .org 0x0273
  228. exit:
  229. ret
  230.  
  231. .org 0x0276
  232. user:
  233. ret
  234.  
  235. ;maybe I should fix the cursors or summink, but I can't be bothered
  236. .org 0x0279
  237. kbmap:
  238. ret
  239.  
  240.  
  241. ;extra patch area from 0x280
  242.  
  243. .var cinit 8
  244.  
  245. ;the input-status-delay kludge
  246. .org 0x0280
  247. kludge:
  248. ld a,(lastb)
  249. and a
  250. jr nz,rcheck
  251.  
  252. ld a,(count)
  253. dec a
  254. ld (count),a
  255. jr z,rcheck
  256.  
  257. xor a
  258. ret
  259.  
  260. rcheck:
  261. ld a,cinit
  262. ld (count),a
  263. ld c,7
  264. call 5        ;actually check it
  265. and a
  266. push af
  267. ld a,1
  268. jr nz,skip
  269. xor a
  270. skip:
  271. ld (lastb),a
  272. pop af
  273. ret
  274.  
  275. count: db cinit
  276. lastb: db 0
  277.