]> cloudbase.mooo.com Git - kermit-80.git/blob - cpxmrl.asm
Bugfix in outmdm (output buffer flush)
[kermit-80.git] / cpxmrl.asm
1 IF NOT lasm
2 .printx * CPXMRL.ASM *
3 ENDIF ; NOT lasm
4 ; KERMIT - (Celtic for "FREE")
5 ;
6 ; This is the CP/M-80 implementation of the Columbia University
7 ; KERMIT file transfer protocol.
8 ;
9 ; Version 4.0
10 ;
11 ; Copyright June 1981,1982,1983,1984,1985
12 ; Columbia University
13 ;
14 ; Originally written by Bill Catchings of the Columbia University Center for
15 ; Computing Activities, 612 W. 115th St., New York, NY 10025.
16 ;
17 ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben,
18 ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many
19 ; others.
20 ;
21 ; CPXMRL.ASM created 16 July, 1987 from submitted code by William Rose.
22 ;
23 ; Kermit system dependent file for Rair Black Box (British Telecom
24 ; Merlin, ICL PC etc) originally submitted by William Rose, and
25 ; modified by OBSchou to work with the Kermit-80 V4.08 and later
26 ; files. Wills original overlay file a stripped down CPXSYS.ASM
27 ; file.
28 ;
29 ; KERSYS.ASM - version 0.6A dated 17 Jun 87.
30 ;
31 ; Cutdown CP4SYS.ASM for Telecom Merlin M2215 only. (ICL PC, Rair Black Box)
32 ;
33 ; This uses TTY1: only, and cannot alter it's parameters. It resets the
34 ; interrupt flag to prevent use of the buffer, and is generally a kludge.
35 ; However it runs at 4800 baud, and tidying the code might get 9600.
36 ;
37 ; Revision History (Last entry first)
38 ;
39 ; edit 2, 22 July by OBSchou to massage frile to fit with CPXCOM.ASM
40 ;
41 ; edit 1, 17 July by OBSchou for Will Rose, to make file suitable for V4.08
42 ; overlay etc.
43 ;
44 ; Keep module name, edit number, and last revision date in memory.
45 ;
46 family: db 'CPXMRL.ASM (2) 22-Jun-87 $' ; Telecom Merlin added
47
48 ;
49 ; Assembly time message to let me know I'm building the right version.
50 ;
51
52 IF m2215
53 .printx * Assembling Kermit-80 for Merlin M2215 *
54 ENDIF
55
56 IF m2215 ;equates removed because interrupts stopped port access
57 ;iobase equ 14h ; base address of TTY1
58 ;mnport equ iobase ; rx and tx data ports
59 ;mnprts equ iobase+1 ; status port
60 ;mnmode equ iobase+2 ; mode port
61 ;mncmd equ iobase+3 ; PCI command port
62 ;txrdy equ 1 ; tx ready bit set if free
63 ;output equ txrdy
64 ;rxrdy equ 2 ; RX ready bit
65 ;input equ rxrdy
66 z80 equ false ; For Merlin M2215
67 ENDIF
68
69
70 sysxin: ; Continue system initialisation fro sysinit
71
72 IF FALSE ; unable to penetrate the 8085 interrupts
73 in mncmd ; clear command register counter
74 mvi a,4eh ; 0100$1110 - 1 stop bit, 8 data bits,
75 ; / by 16 counter
76 out mnmode
77 mvi a,30h+7 ; 0011$0000 - select internal rate generator
78 ; use 1200 baud by default
79 out mnmode
80 mvi a,27h ; 0010$0111 - enable tx and rx, RTS and DTR low
81 out mncmd
82 mvi h, 12
83 mvi l, 12
84 shld speed ; to show its been set up
85
86 ENDIF
87
88 ret
89
90 porbuf: ds 3 ; original port settings
91
92 ;
93 ; system-dependent KERMIT termination processing
94 ; If we've changed anything, this is our last chance to put it back.
95 ;
96 sysexit:
97 ret
98
99 ;
100 ; system-dependent processing for start of CONNECT command
101 ;
102 syscon:
103 ret
104
105 conmsg: ; Messages printed when entering transparent (CONNECT) mode:
106
107 db '$'
108
109 ;
110 ; syscls - system-dependent close routine
111 ; called when exiting transparent session.
112 ;
113 syscls:
114 ret
115
116 ;
117 ; sysinh - help for system-dependent special functions.
118 ; called in response to <escape>?, after listing all the
119 ; system-independent escape sequences.
120 ;
121 sysinh:
122 ; still can't pentrate interrupts
123 ret
124
125 ; Additional, system-dependent help for transparent mode
126 ; (two-character escape sequences)
127 ;
128 inhlps:
129
130 IF m2215
131 db cr, lf, 'B Transmit a BREAK'
132 ENDIF
133
134 db '$' ; string terminator
135
136 ;
137 ; sysint - system dependent special functions
138 ; called when transparent escape character has been typed;
139 ; the second character of the sequence is in A (and in B).
140 ; returns:
141 ; non-skip: sequence has been processed
142 ; skip: seqence was not recognized
143 ;
144 sysint: ani 137O ; convert lower case to upper, for testing...
145
146 IF FALSE ; as always
147 cpi 'B' ; send break ?
148 jz sendbr
149 ENDIF
150 jmp rskp ; take skip return - command not recognised
151
152 ; Actual commands
153
154 IF FALSE ;as always
155 sendbr:
156 in mnprts
157 ani 04h ; make sure shift reg is clear
158 jz sendbr
159
160 mvi a,2fh ; set for a break
161 out mncmd
162 mvi a,100 ; wait a bit
163 call delay
164 mvi a,27h ; restore mode
165 out mncmd
166
167 ret
168 ENDIF
169
170 ret
171
172 ;
173 ; sysflt - system-dependent filter
174 ; called with character in E.
175 ; if this character should not be printed, return with A = zero.
176 ; preserves bc, de, hl.
177 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
178 ;
179 sysflt:
180 mov a,e ; get character for testing
181 ret
182
183 ;
184 ; mdmflt - modem filter
185 ; called with character to be sent to printer in E
186 ; with parity set as appropriate.
187 ; return with accumulator = 0 do do nothing,
188 ; <> 0 to send char in E.
189 mdmflt:
190 mov a,e ; get character to test
191 ret
192
193 ;
194 ; prtflt - printer filter
195 ; called with character to be sent to printer in E
196 ; returns with a = 0 to do nothing
197 ; a <> 0 to print it.
198 ;
199 ; this routine for those printer that automatically insert
200 ; a lf on cr, or cr for lf. Should this be shifted to
201 ; the system indep. stuff, in say 4.06?
202 ;
203 prtflt:
204 mov a,e ; get character to test
205
206 IF FALSE ; strip out lf from printer stream
207 ani 7fh ; make sure it is parity less
208 cpi lf ; is it a line feed?
209 rnz ; no, print it
210 ; xra a ; yes, don't.
211
212 ENDIF
213
214 ret
215
216 ;
217 ; system-dependent processing for BYE command.
218 ;
219 sysbye:
220 ret
221
222 ;
223 ; This is the system-dependent command to change the baud rate.
224 ; DE contains the two-byte value from the baud rate table; both
225 ; bytes of this value are also stored in 'speed'.
226 ;
227 sysspd:
228
229 IF FALSE ; as always
230 in mncmd ; clear register counter
231 mvi a,4eh ; set for 1 stop, 8 data bits
232 out mnmode ; save in mode 1 port
233 mvi a,30h ; set bits for rate etc..
234 add e ; add baud rate (bits 0 - 3)
235 out mnmode ; set mode port 2
236 mvi a,27h ; set tx/rx ready, RTS CTS active
237 out mncmd
238 ret
239 ENDIF
240 ret ; if routine not supported
241 ;
242 ; Speed tables
243 ; (Note that speed tables MUST be in alphabetical order for later
244 ; lookup procedures, and must begin with a value showing the total
245 ; number of entries. The speed help tables are just for us poor
246 ; humans.
247 ;
248 ; db string length, string, divisor (2 bytes or 1 word, ab)
249 ; the data byte a is return in A and E, and b in D
250 ; only byte 'a' is the key for the table
251
252 IF FALSE ; as always
253 spdtbl: db 16 ; sixteen entries for PCI
254 db 3,'110$', 2,2
255 db 4,'1200$', 7,7
256 db 3,'134$', 3,3
257 db 3,'150$', 4,4
258 db 4,'1800$', 8,8
259 db 5,'19200$', 15,15
260 db 4,'2000$', 9,9
261 db 4,'2400$', 10,10
262 db 3,'300$', 5,5
263 db 4,'3600$', 11,11
264 db 4,'4800$', 12,12
265 db 2,'50$', 0,0
266 db 3,'600$', 6,6
267 db 4,'7200$', 13,13
268 db 2,'75$', 1,1
269 db 4,'9600$', 14,14
270
271 sphtbl: db ' 50 75 110 134 150 300 600 1200 '
272 db cr,lf,'1800 2000 2400 3600 4800 7200 9600 19200$'
273 ENDIF
274
275 IF m2215
276 spdtbl equ 0 ; routine unsupported
277 sphtbl equ 0
278 ENDIF
279
280 ;
281 ; This is the system-dependent SET PORT command.
282 ; HL contains the argument from the command table.
283 ;
284 sysprt:
285
286 IF m2215
287 prttbl equ 0 ; SET PORT is not supported
288 prhtbl equ 0 ; Merlin M2215 could, I suppose
289 ENDIF
290
291 ;
292 ; selmdm - select modem port
293 ; selcon - select console port
294 ; selmdm is called before using inpmdm or outmdm;
295 ; selcon is called before using inpcon or outcon.
296 ; For iobyt systems, diddle the I/O byte to select console or comm port;
297 ; For the rest, does nothing.
298 ; preserves bc, de, hl.
299 ;
300 selmdm:
301 ret
302
303 selcon:
304 ret
305
306 ;
307 ; Get character from console, or return zero.
308 ; result is returned in A. destroys bc, de, hl.
309 ;
310 inpcon:
311 call 0f55dh ;CONST BIOS vector
312 ora a ;set flags
313 rz
314 call 0f56eh ;CONIN BIOS vector
315 ret
316
317 ;
318 ; Output character in E to the console.
319 ; destroys bc, de, hl
320 ;
321 outcon:
322 mov c, e
323 call 0f57fh ;CONOUT BIOS vector
324 ret
325
326 ;
327 ; outmdm - output a char from E to the modem.
328 ; the parity bit has been set as necessary.
329 ; returns nonskip; bc, de, hl preserved.
330 ;
331 outmdm:
332
333 IF m2215
334 push psw
335 push h
336 push d
337 push b
338
339 mov c, e
340 mvi a, 1 ; ie: tty1:
341 mov d, a
342 call 0f6a2h ;PUN BIOS vector
343
344 pop b
345 pop d
346 pop h
347 pop psw
348 ENDIF
349
350 ret
351
352 ;
353 ; for IOBYT systems, the modem port has already been selected.
354 ; destroys bc, de, hl.
355 ;
356 inpmdm:
357
358 IF m2215
359 ; check status
360 lda 0fa32h ; ie. tty1:
361 ora a
362 rz
363
364 mvi a, 1 ; RDR BIOS vector
365 mov d, a
366 call 0f651h
367 ; ani 7fh
368
369 push a
370 di
371 mvi a, 0
372 sta 0fa32h ; remove interrupt flag
373 sta 0f2d3h ; zero buffer counter
374 lda 0f2d4h
375 sta 0f2d5h
376 ei
377 nop
378 pop a
379
380 ret
381 ENDIF
382
383 ;
384 ; flsmdm - flush comm line.
385 ; Modem is selected.
386 ; Currently, just gets characters until none are available.
387 ;
388 flsmdm:
389
390 call inpmdm ; Try to get a character
391 ora a ; Got one?
392 jnz flsmdm ; If so, try for another
393 ret ; Receiver is drained. Return.
394
395
396 ;\f
397
398 ;
399 ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
400 lptstat:
401 IF iobyte ;[33]
402 call bprtst ; get status
403 ENDIF ;iobyte[33]
404
405 IF NOT iobyte ;[33]
406 xra a ; assume it is ok.. this may not be necessary
407 ENDIF ;iobyte [33]
408 ret
409 ;
410 ; outlpt - output character in E to printer
411 ; console is selected.
412 ; preserves de.
413 ;
414 outlpt:
415 push d ; save DE in either case
416 call prtflt ; go through printer filter [30]
417 ana a ; if A = 0 do nothing,
418 jz outlp1 ; if a=0 do nothing
419
420 outlp1: pop d ; restore saved register pair
421 ret
422
423 ; delchr - make delete look like a backspace. Unless delete is a printing
424 ; character, we just need to print a backspace. (we'll output clrspc
425 ; afterwards)
426 delchr:
427
428 mvi e,bs ;get a backspace
429 jmp outcon
430
431 ; erase the character at the current cursor position
432 clrspc: mvi e,' '
433 call outcon
434 mvi e,bs ;get a backspace
435 jmp outcon
436
437 ; erase the current line
438 clrlin: lxi d,eralin
439 jmp prtstr
440
441 ; erase the whole screen, and go home. preserves b (but not c)
442 clrtop: lxi d,erascr
443 jmp prtstr
444
445
446 IF m2215
447 sysver: db 'BT Merlin M2215, port TTY1:, settings unchanged.$'
448 ENDIF
449
450 tstmsg: db 'Test message',cr,lf,'$'
451
452 IF lasm
453 LINK CPXVDU.ASM ; link to the Terminal definition tables
454 ENDIF ;lasm