]> cloudbase.mooo.com Git - kermit-80.git/blob - cpxsyo.asm
Bugfix in outmdm (output buffer flush)
[kermit-80.git] / cpxsyo.asm
1 IF NOT lasm
2 .printx * CPXSYO.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 ; This file contains the system dependent part for Sanyo MBC 1100
22 ; systems, and has been extracted from the CPMSYO.ASM code (kermit
23 ; version 3.5)
24 ;
25 ; revision history:
26 ;
27 ; edit 1, 27 October, 1987, by OBSchou. Extracted Sanyo code from CPMSYO.ASM
28 ; and massaged fort CP/M kermit V4.09
29 ;
30 ; Keep module name, edit number, and last revision date in memory.
31 family: db 'CPXSYO.ASM (1) 27-Oct-87 $'
32 ;\f
33
34 ; Assembly time message to let me know I'm building the right version.
35 ; LASM generates an 'S' error along with the message, which is messy, but
36 ; better than trying to put everything inside a IF m80 OR mac80 conditional,
37 ; because LASM doesn't like nested IF's, either.
38
39 IF sanyo
40 .printx * Assembling Kermit-80 for Sanyo MBC 1100 *
41 ENDIF
42
43 iobyte EQU 03H ;Location of I/O byte
44
45 if sanyo
46 baudrt EQU 0DAH ;BAUD RATE MEMORY LOCATION
47 MNPORT EQU 0DCH ;COMMUNICATIONS PORT
48 MNPRTS EQU 0DDH ;COMMUNICATIONS PORT STATUS
49 OUTPUT EQU 01H ;OUTPUT READY BIT
50 INPUT EQU 02H ;INPUT READY BIT
51 ENDIF;SANYO
52
53 defesc EQU '\'-100O ;The default escape character.
54
55 ; Select initial setting for VT-52 emulation flag.
56 vtval EQU 1
57
58
59 sysxin: ;system initialisation not covered by sysinit
60 ret ; return from system-dependent routine
61
62 ;\f
63
64 ;
65 ; system-dependent termination processing
66 ; If we've changed anything, this is our last chance to put it back.
67 sysexit:
68 ret
69
70 ;
71 ; system-dependent processing for start of CONNECT command
72 ;
73 syscon:
74 ret
75
76 ;\f
77
78 ;
79 ; syscls - system-dependent close routine
80 ; called when exiting transparent session.
81 ;
82 syscls:
83 ret
84 ;\f
85
86 ;
87 ; sysinh - help for system-dependent special functions.
88 ; called in response to <escape>?, after listing all the
89 ; system-independent escape sequences.
90 ;
91 sysinh:
92 lxi d,inhlps ; we got options...
93 call prtstr ; print them.
94 ret
95 inhlps:
96 db '$' ;[hh] table terminator
97
98 ;
99 ; sysint - system dependent special functions
100 ; called when transparent escape character has been typed;
101 ; the second character of the sequence is in A (and in B).
102 ; returns:
103 ; non-skip: sequence has been processed
104 ; skip: sequence was not recognized
105 sysint:
106 ani 137O ; convert lower case to upper, for testing...
107 ret
108
109 ; sysflt - system-dependent filter.
110 ; called with the character in E.
111 ; preserves bc, de, hl.
112 ; note: <xon>,<xoff>,<del>, and <nul> are always discarded.
113 sysflt:
114 mov a,e ; get character for testing
115 ret
116
117 ; mdmflt - modem filter [30]
118 ; called with character to be sent to printer in E
119 ; with parity set as appropriate.
120 ; return with accumulator = 0 do do nothing,
121 ; <> 0 to send char in E.
122 mdmflt:
123 mov a,e ;[30] get character to test
124 ret
125
126
127 ; prtflt - printer filter [30]
128 ; called with character to be sent to printer in E
129 ; returns with a = 0 to do nothing
130 ; a <> 0 to print it.
131 ;
132 ; this routine for those printer that automatically insert
133 ; a lf on cr, or cr for lf. Should this be shifted to
134 ; the system indep. stuff, in say 4.06?
135 prtflt:
136 mov a,e ; [30] get character to test
137 ret
138
139
140 ;\f
141
142 ;
143 ; system-dependent processing for BYE command.
144 ; for apmmdm, heath, and lobo, hang up the phone.
145 sysbye:
146 ret
147 ;\f
148
149 ; This is the system-dependent command to change the baud rate.
150 ; DE contains the two-byte value from the baud rate table; this
151 ; value is also stored in 'speed'.
152 sysspd:
153 ret
154
155 ;\f
156
157 ; Speed tables
158 ; (Note that speed tables MUST be in alphabetical order for later
159 ; lookup procedures, and must begin with a value showing the total
160 ; number of entries. The speed help tables are just for us poor
161 ; humans.
162
163 ; db string length,string,divisor (2 identical bytes or 1 word)
164 ; [Toad Hall]
165
166 IF sanyo
167 spdtbl EQU 0 ; No speed table for the Sanyo
168 sphtbl EQU 0 ; ditto help for speed.
169
170 ; The following conditionals were once a huge if not statement. There
171 ; wasn't enough room to add the lobo to the list, so it had to be broken
172 ; into 2, which you can't do with an if not. I redid it as two ifs and
173 ; applied them to those that wouldn't set baud. [Hal Hostetler]
174 ;\f
175
176 ; This is the system-dependent SET PORT command.
177 ; HL contains the argument from the command table.
178 sysprt:
179 ret
180 ;\f
181
182 ;
183 ; Port table not applicable tot he Sanyo...
184 prttbl EQU 0
185 prhtbl EQU 0 ;
186
187 ;\f
188
189 ;
190 ; selmdm - select modem port
191 ; selcon - select console port
192 ; selmdm is called before using inpmdm or outmdm;
193 ; selcon is called before using inpcon or outcon.
194 ; For iobyt systems, diddle the I/O byte to select console or comm port;
195 ; For Decision I, switches Multi I/O board to console or modem serial
196 ; port. [Toad Hall]
197 ; For the rest, does nothing.
198 ; preserves bc, de, hl.
199 selmdm:
200 ret
201
202 selcon:
203 ret
204 ;\f
205
206 ; Get character from console, or return zero.
207 ; result is returned in A. destroys bc, de, hl.
208 ;
209 inpcon:
210 mvi c,dconio ;Direct console I/O BDOS call.
211 mvi e,0FFH ;Input.
212 call BDOS
213 ret
214 ;\f
215
216 ;
217 ; Output character in E to the console.
218 ; destroys bc, de, hl
219 ;
220 outcon:
221 mvi c,dconio ;Console output bdos call.
222 call bdos ;Output the char to the console.
223 ret
224 ;\f
225
226 ;
227 ; outmdm - output a char from E to the modem.
228 ; the parity bit has been set as necessary.
229 ; returns nonskip; bc, de, hl preserved.
230 outmdm:
231 IF inout
232 in mnprts ;Get the output done flag.
233 ani output ;Is it set?
234 jz outmdm ;If not, loop until it is.
235 mov a,e
236 out mnport ;Output it.
237 ret
238 ENDIF;inout
239
240 ;\f
241
242 ;
243 ; get character from modem; return zero if none available.
244 ; for IOBYT systems, the modem port has already been selected.
245 ; destroys bc, de, hl.
246 inpmdm:
247 IF inout
248 ;Note: modem port should already be selected for mdI. [Toad Hall]
249 in mnprts ;Get the port status into A.
250 ani input ;See if the input ready bit is on.
251 rz ;If not then return.
252 in mnport ;If so, get the char.
253 ENDIF;inout
254 ret ; return with character in A
255
256
257 ;
258 ; flsmdm - flush comm line.
259 ; Modem is selected.
260 ; Currently, just gets characters until none are available.
261
262 flsmdm: call inpmdm ; Try to get a character
263 ora a ; Got one?
264 jnz flsmdm ; If so, try for another
265 ret ; Receiver is drained. Return.
266
267
268 ;\f
269
270 ;
271 ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not.
272 lptstat:
273 xra a ; assume it is ok.. this may not be necessary
274 ret
275 ;\f
276
277 ;
278 ; outlpt - output character in E to printer
279 ; console is selected.
280 ; preserves de.
281 outlpt:
282 push d ; save DE in either case
283 call prtflt ; go through printer filter [30]
284 ana a ; if A = 0 do nothing,
285 jz outlp1 ; [30] if a=0 do nothing
286 mvi c,lstout
287 call bdos ;Char to printer
288 outlp1: pop d ; restore saved register pair
289 ret
290 ;\f
291
292 ;
293 ; Screen manipulation routines
294 ; csrpos - move to row B, column C
295 ;
296 ; csrpos for terminals that use a leadin sequence followed
297 ; by (row + 31.) and (column + 31.)
298 ;
299 csrpos: push b ; save coordinates
300 lxi d,curldn ; get cursor leadin sequence
301 call prtstr ; print it
302 pop h ; restore coordinates
303 mov a,h ; get row
304 adi (' '-1) ; space is row one
305 mov e,a
306 push h
307 call outcon ; output row
308 pop h
309 mov a,l ; get column
310 adi (' '-1) ; space is column one
311 mov e,a
312 jmp outcon ; output it and return
313 ENDIF;NOT (robin OR dmII OR osi OR vector OR termin)
314
315 ret ; Can the Sany do cursor opsitioning??
316
317 ;
318 ;
319 ; delchr - make delete look like a backspace. Unless delete is a printing
320 ; character, we just need to print a backspace. (we'll output clrspc
321 ; afterwards)
322 ; For Kaypro and Vector General, delete puts a blotch on the screen.
323 ; For Apple and Osborne 1, delete moves but doesn't print.
324 delchr:
325 mvi e,bs
326 call outcon
327
328 ; erase the character at the current cursor position
329 clrspc: mvi e,' '
330 call outcon
331 mvi e,bs ;get a backspace
332 jmp outcon
333
334 ; erase the current line
335 clrlin: lxi d,eralin
336 jmp prtstr
337
338 ; erase the whole screen, and go home. preserves b (but not c)
339 clrtop: lxi d,erascr
340 jmp prtstr
341
342
343
344 IF SANYO
345 outlin: DB ESC,'E',ESC,'H',CR,LF,TAB ;WHATEVER
346 sysver: DB 'KERMIT-80 V3.9 [SANYO MBC-1100]',CR,LF,'$' ;VERSION HEADING
347 DELSTR: DB ESC,'K','$' ;WHATS A STRING?
348 eralin: DB ESC,'P','$' ;CLEAR SPACE
349 ;CLRLIN: DB ESC,'K','$' ;CLEAR LINE
350 erascr: DB ESC,'E',ESC,'H','$' ;CLEAR SCREEN AND CURSOR HOME
351 curldn: db esc,'=','$',0 ;cursor lead in
352 ;SCRNP: DB ESC,'=',24H,25H,'$' ;SPOT FOR SCREEN PACKETS
353 ;SCRNRT: DB ESC,'=',25H,25H,'$' ;SPOT FOR # OF RETRIES
354 ;SCRFLN: DB ESC,'=',26H,25H,'$' ;SPOT FOR FILE NAME
355 ;SCRST: DB ESC,'=',28H,25H,'$' ;SPOT FOR STATUS
356 ;SCREND: DB ESC,'=',2AH,25H,'$' ;SPOT FOR PROMPT
357 ;SCRERR: DB ESC,'=',2DH,25H,'$' ;SPOT FOR ERRORS
358 ttab: ;NO TRANSLATION TABLE
359 ta: DB ESC,'A',0,0 ;CURSOR UP
360 tb: DB ESC,'B',0,0 ;CURSOR DOWN
361 tc: DB ESC,'D',0,0 ;CURSOR RIGHT
362 td: DB ESC,'C',0,0 ;CURSOR LEFT
363 te: DB ESC,'E',0,0 ;CLEAR SCREEN
364 tf: DB 0,0,0,0 ;WHAT???
365 tg: DB 0,0,0,0 ;WHAT???
366 th: DB ESC,'H',0,0 ;CURSOR HOME
367 ti: DB ESC,'A',ESC,'C',0,0 ;REVERSE LINEFEED??
368 tj: DB ESC,'J',0,0 ;CLEAR TO END OF SCREEN
369 tk: DB ESC,'K',0,0 ;CLEAR TO END OF LINE
370 ENDIF;SANYO
371
372 ovlend equ $ ; End of overlay
373
374 END
375 \1a
376 \1a
377 \1a
378 \1a
379 \1a
380 \1a
381 \1a
382 \1a
383 \1a
384 \1a
385 \1a
386 \1a
387 \1a
388 \1a
389