]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/ascii.180
WIP
[z180-stamp-cpm3.git] / cbios / ascii.180
CommitLineData
d6829fd3
L
1\r
2; Interrupt drivers for ASCI0 and ASCI1\r
3\r
6dd88c25 4 global as0_dev,as1_dev\r
d6829fd3 5\r
1c7e3963 6 extrn @ctbl,f_cpu\r
81ba3c84
L
7 extrn ff_empty,ff_get,ff_full,ff_put\r
8 extrn ff_puth,ff_cnt,ff_gech\r
d6829fd3 9 extrn bufinit\r
1c7e3963
L
10 extrn isv_sw,ijphl,add_hla,div32_r\r
11 extrn b_st_a,b_ld_a\r
d6829fd3
L
12\r
13\r
14\r
1c7e3963
L
15 maclib z180reg.inc\r
16 maclib config.inc\r
17 maclib ioctl.inc\r
18 maclib modebaud.inc\r
d6829fd3
L
19\r
20\r
1c7e3963 21 m2b mbxon_bit,mb$xon$xoff\r
d6829fd3
L
22\r
23;-----------------------------------------------------\r
24\r
25 dseg\r
26\r
6dd88c25
L
27 dw asci0_out\r
28 dw asci0_osta\r
29 dw asci0_inp\r
30 dw asci0_ista\r
31 dw asci_ioctl\r
32as0_dev:\r
1c7e3963
L
33 db 0 ;absolute device #\r
34 db 0 ;relative device\r
35 db 0 ;iflags\r
36 db 0 ;fflags\r
37 db M_CS8 ;cflags\r
6dd88c25
L
38o.absdev equ 0\r
39o.reldev equ 1\r
1c7e3963
L
40o.iflags equ 2\r
41o.fflags equ 3\r
42o.cflags equ 4\r
43\r
44 db 0\r
45 db 0\r
46oint.iflags equ as0_dev+o.iflags-s0.inbuf\r
47oint.fflags equ as0_dev+o.fflags-s0.inbuf\r
48 mkbuf s0.rx_id, s0.inbuf, s0.rx_len\r
49 mkbuf s0.tx_id, s0.outbuf,s0.tx_len\r
50\r
6dd88c25
L
51\r
52 dw asci1_out\r
53 dw asci1_osta\r
54 dw asci1_inp\r
55 dw asci1_ista\r
56 dw asci_ioctl\r
57as1_dev:\r
1c7e3963
L
58 db 0 ;absolute device #\r
59 db 1 ;relative device\r
60 db 0 ;iflags\r
61 db 0 ;fflags\r
62 db M_CS8 ;cflags\r
6dd88c25 63\r
6dd88c25 64 db 0\r
6dd88c25 65 db 0\r
d6829fd3 66 mkbuf s1.rx_id, s1.inbuf, s1.rx_len\r
81ba3c84 67 mkbuf s1.tx_id, s1.outbuf,s1.tx_len\r
d6829fd3
L
68\r
69\r
70\r
71 dseg\r
72\r
6dd88c25
L
73\r
74ioctl_ftab:\r
1c7e3963
L
75 dw func_tcinit ;(00h) CP/M 3 DEVINI function\r
76 dw func_tcgeta ;(01h) Get the current serial port settings.\r
77 dw func_tcseta ;(02h) Set the current serial port settings.\r
78 dw func_tcsetaw ;(03h) Allow the output buffer to drain\r
79 dw func_tcsetaf ;(04h) Allow the output buffer to drain, discard pending input\r
80 dw func_tcsbrk ;(05h) Sending a break (250ms .. 500ms)\r
81 dw func_tcsbrkp ;(06h) arg is timeinterval in 0.1sec\r
82 dw func_tiocsbrk ;(07h) Turn break on\r
83 dw func_tioccbrk ;(08h) Turn break off\r
84 dw func_tcxonc ;(09h) Software flow control (TCOOFF, TCOON, TCIOFF, TCION)\r
85 dw func_tcflsh ;(0Ah) Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)\r
86 dw func_fionread ;(0Bh) Get the number of bytes in the input buffer.\r
87 dw func_tiocoutq ;(0Ch) Get the number of bytes in the output buffer.\r
88 dw func_tiocmget ;(0Dh) get the status of modem bits.\r
89 dw func_tiocmbis ;(0Eh) set the indicated modem bits.\r
90 dw func_tiocmbic ;(0Fh) clear the indicated modem bits.\r
91 dw func_tiocmset ;(10h) set the status of modem bits.\r
92 dw func_tiocgsoftcar ;(11h) Get the status of the CLOCAL flag in the c_cflag field\r
93 dw func_tiocssoftcar ;(12h) Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.\r
94\r
6dd88c25
L
95IOCTL_MAX equ ($-ioctl_ftab)/2\r
96 dw nofunc\r
97\r
1c7e3963 98\r
d6829fd3 99;--------------------------------------------------------------\r
d6829fd3 100;\r
6dd88c25
L
101; b: device number\r
102; c: command\r
103; de: ioctl arg pointer\r
104; hl: ptr to driver local data\r
d6829fd3
L
105;\r
106\r
6dd88c25
L
107asci_ioctl:\r
108 push hl\r
109 ex (sp),ix\r
110 ld (ix+o.absdev),b\r
111 ld hl,ioctl_ftab\r
112 ld a,IOCTL_MAX\r
113 cp c\r
114 jr c,$+3\r
115 ld a,c\r
116 add a,a\r
117 call add_hla\r
118 ld a,(hl)\r
119 inc hl\r
120 ld h,(hl)\r
121 ld l,a\r
122 call ijphl\r
123 pop ix\r
124nofunc:\r
1c7e3963 125 or a\r
6dd88c25
L
126 ret\r
127\r
6dd88c25 128;--------------------------------------------------------------\r
1c7e3963 129; CP/M 3 DEVINI function\r
6dd88c25 130; Init Serial I/O for input and output (ASCI 0/1)\r
d6829fd3 131\r
1c7e3963
L
132func_tcinit:\r
133 call asci_stop\r
134\r
135init_st:\r
136 ld c,asext0 ;Enable baud rate generator\r
137 ld a,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS +M_BREAKEN\r
138 bit CCTS_OFLOW,(ix+o.fflags)\r
139 jr nz,$+4\r
140 or M_CTS0DIS\r
141 call out_asci_reg\r
d6829fd3 142\r
6dd88c25 143 ld b,(ix+o.absdev)\r
1c7e3963
L
144 ld c,8 ;\r
145 mlt bc ;\r
146 ld hl,@ctbl+7 ;\r
147 add hl,bc ;\r
148 ld a,(hl) ;get baudrate index\r
149 call as_br_div\r
150 ld c,astc0l\r
151 ld a,l\r
152 call out_asci_reg\r
153 inc c\r
154 ld a,h\r
155 call out_asci_reg\r
156\r
157\r
158 ld c,cntlb0\r
159 ld a,M_MPBT ;No MP Mode, X16\r
160 bit PARODD,(ix+o.iflags)\r
161 jr z,$+4\r
162 or M_PEO\r
163 call out_asci_reg\r
164\r
165 ld c,cntla0\r
166 ld a,(ix+o.cflags)\r
167 srlan CS8\r
168 ld hl,mod_tab\r
169 call add_hla\r
170 ld a,(hl)\r
171 or a,M_RE+M_TE+M_RTS0+M_EFR ;Rx/Tx enable\r
172 call out_asci_reg\r
173\r
174 push ix\r
6dd88c25
L
175 bit 0,(ix+o.reldev)\r
176 jr nz,init_1\r
177 ld hl,rtxisvjmp0 ;rx/tx int vector\r
178 ld (ivtab + IV$ASCI0),hl ;\r
d6829fd3 179 ld ix,s0.outbuf\r
1c7e3963
L
180 call bufinit\r
181 ld ix,s0.inbuf\r
6dd88c25
L
182 jr init_2\r
183init_1:\r
184 ld hl,rtxisvjmp1 ;rx/tx int vector\r
185 ld (ivtab + IV$ASCI1),hl ;\r
d6829fd3 186 ld ix,s1.outbuf\r
1c7e3963
L
187 call bufinit\r
188 ld ix,s1.inbuf\r
6dd88c25 189init_2:\r
d6829fd3 190 call bufinit\r
1c7e3963
L
191 pop ix\r
192 call asci_start\r
193 ret\r
194\r
195;--------------------------------------------------------------\r
196\r
197mod_tab:\r
198 db 000B ; 7N1\r
199 db 100B ; 8N1\r
200 db 001B ; 7N2\r
201 db 101B ; 8N2\r
202 db 010B ; 7P1\r
203 db 110B ; 8P1\r
204 db 011B ; 7P2\r
205 db 111B ; 8P2\r
206\r
207\r
208;--------------------------------------------------------------\r
209; Get the current serial port settings.\r
210\r
211func_tcgeta:\r
212 ld a,d\r
213 or e\r
214 ld a,0ffh\r
215 jr z,fgeta_e\r
216\r
217 ld a,(ix+o.iflags)\r
218 call b_st_a\r
219 inc de\r
220 ld a,(ix+o.fflags)\r
221 call b_st_a\r
222 inc de\r
223\r
224 ld b,(ix+o.absdev)\r
225 ld c,8 ;\r
226 mlt bc ;\r
227 ld hl,@ctbl+7 ;\r
228 add hl,bc ;\r
229 ld a,(hl) ;get baudrate index\r
230 and M_CBAUD\r
231 ld b,a\r
232 ld a,(ix+o.cflags)\r
233 and ~M_CBAUD\r
234 or b\r
235 call b_st_a\r
236 dec de\r
237 dec de\r
238 xor a\r
239fgeta_e:\r
240 ret\r
241\r
242\r
243;--------------------------------------------------------------\r
244; Set the current serial port settings.\r
245\r
246func_tcseta:\r
247 ld a,d\r
248 or e\r
249 ld a,0ffh\r
250 jr z,fseta_e\r
251\r
252 call asci_stop\r
253\r
254 call b_ld_a\r
255 ld (ix+o.iflags),a\r
256 inc de\r
257 call b_ld_a\r
258 ld (ix+o.fflags),a\r
259 inc de\r
260\r
261 ld b,(ix+o.absdev)\r
262 ld c,8 ;\r
263 mlt bc ;\r
264 ld hl,@ctbl+7 ;\r
265 add hl,bc ;\r
266 call b_ld_a\r
267 ld (ix+o.cflags),a\r
268 and M_CBAUD\r
269 ld (hl),a ;set baudrate index\r
270 dec de\r
271 dec de\r
272 push de\r
273 call init_st\r
274 pop de\r
275 xor a\r
276fseta_e:\r
277 ret\r
278\r
279\r
280;--------------------------------------------------------------\r
281; Allow the output buffer to drain\r
282\r
283func_tcsetaw:\r
284\r
285;--------------------------------------------------------------\r
286; Allow the output buffer to drain, discard pending input\r
287\r
288func_tcsetaf:\r
289\r
290;--------------------------------------------------------------\r
291; Sending a break (250ms .. 500ms)\r
292\r
293func_tcsbrk:\r
294\r
295;--------------------------------------------------------------\r
296; arg is timeinterval in 0.1sec\r
297\r
298func_tcsbrkp:\r
299\r
300;--------------------------------------------------------------\r
301; Turn break on\r
302\r
303func_tiocsbrk:\r
304\r
305;--------------------------------------------------------------\r
306; Turn break off\r
307\r
308func_tioccbrk:\r
309\r
310;--------------------------------------------------------------\r
311; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)\r
312\r
313func_tcxonc:\r
314\r
315;--------------------------------------------------------------\r
316; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)\r
317\r
318func_tcflsh:\r
319\r
320;--------------------------------------------------------------\r
321; Get the number of bytes in the input buffer.\r
322\r
323func_fionread:\r
324\r
325;--------------------------------------------------------------\r
326; Get the number of bytes in the output buffer.\r
327\r
328func_tiocoutq:\r
329\r
330;--------------------------------------------------------------\r
331; get the status of modem bits.\r
332\r
333func_tiocmget:\r
334\r
335;--------------------------------------------------------------\r
336; set the indicated modem bits.\r
337\r
338func_tiocmbis:\r
339\r
340;--------------------------------------------------------------\r
341; clear the indicated modem bits.\r
342\r
343func_tiocmbic:\r
344\r
345;--------------------------------------------------------------\r
346; set the status of modem bits.\r
347\r
348func_tiocmset:\r
349\r
350;--------------------------------------------------------------\r
351; Get the status of the CLOCAL flag in the c_cflag field\r
352\r
353func_tiocgsoftcar:\r
354\r
355;--------------------------------------------------------------\r
356; Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.\r
357\r
358func_tiocssoftcar:\r
359\r
360 or 0ffh\r
361 ret\r
362\r
363;--------------------------------------------------------------\r
364\r
365asci_stop:\r
366 ld c,stat0 ;Disable rx/tx interrupts\r
367 xor a ;\r
368 call out_asci_reg\r
369\r
370 ld c,cntla0 ;Disable receiver and transmitter\r
371 ld a,M_RTS0+M_EFR ;RTS/CKA1\r
372 jr out_asci_reg\r
373\r
374;--------------------------------------------------------------\r
375\r
376asci_start:\r
377 ld c,stat0 ;\r
d6829fd3 378 ld a,M_RIE\r
1c7e3963
L
379 jr out_asci_reg\r
380\r
381;--------------------------------------------------------------\r
382; output to asci0/1 register\r
383;\r
384; c: register address\r
385; a: value\r
386;\r
387\r
388out_asci_reg:\r
389 push bc\r
390 ld b,a\r
391 ld a,c\r
392 cp astc0l ;astc0/1 are 16 bit\r
393 jr c,$+5\r
394 add a,(ix+o.reldev)\r
395 add a,(ix+o.reldev)\r
396 ld c,a\r
397 ld a,b\r
398 ld b,0\r
399 out (c),a\r
400 pop bc\r
d6829fd3
L
401 ret\r
402\r
1c7e3963
L
403;--------------------------------------------------------------\r
404; baud rate divider\r
405;\r
406; a: index\r
407; return\r
408; hl: divider\r
409\r
410as_br_div:\r
411 push de\r
412 push bc\r
413 and 0fh\r
414 add a,a ;get factor\r
415 ld hl,bd150_tab\r
416 call add_hla\r
417 ld c,(hl)\r
418 inc hl\r
419 ld b,(hl)\r
420 ld hl,(f_cpu)\r
421 ld de,(f_cpu+2)\r
422 call div32_r\r
423 ld bc,32*150\r
424 call div32_r\r
425 ld de,2\r
426 or a\r
427 sbc hl,de\r
428 pop bc\r
429 pop de\r
430 ret nc\r
431 ld hl,0\r
432 ret\r
433\r
434bd150_tab:\r
435; factor index baudrate orig. cp/m\r
436 dw 19200/150 ; 0 19200 -\r
437 dw 28800/150 ; 1 28800 50\r
438 dw 38400/150 ; 2 38400 75\r
439 dw 57600/150 ; 3 57600 110\r
440 dw 11520/15 ; 4 115200 134.5\r
441 dw 150/150 ; 5 150\r
442 dw 300/150 ; 6 300\r
443 dw 600/150 ; 7 600\r
444 dw 1200/150 ; 8 1200\r
445 dw 1800/150 ; 9 1800\r
446 dw 2400/150 ;10 2400\r
447 dw 3600/150 ;11 3600\r
448 dw 4800/150 ;12 4800\r
449 dw 7200/150 ;13 7200\r
450 dw 9600/150 ;14 9600\r
451 dw 19200/150 ;15 19200\r
452\r
453\r
454;--------------------------------------------------------------\r
455\r
456 if 0\r
457\r
458initab0:\r
459 db 1,stat0,0 ;Disable rx/tx interrupts\r
460 ;Enable baud rate generator\r
461 db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS\r
462 db 2,astc0l\r
463init_br_off equ $ - initab0\r
464 dw 28\r
465 db 1,cntlb0,M_MPBT ;No MP Mode, X16\r
466 db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
467 db 0\r
468\r
469initab1:\r
470 db 1,stat1,0 ;Disable rx/tx ints, disable CTS1\r
471 db 1,asext1,M_BRGMOD ;Enable baud rate generator\r
472 db 2,astc1l,low 3, high 3\r
473 db 1,cntlb1,M_MPBT ;No MP Mode, X16\r
474 db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
475 db 0\r
476 endif\r
d6829fd3 477\r
d6829fd3
L
478;--------------------------------------------------------------\r
479\r
480 dseg\r
6dd88c25 481asci0_ista:\r
d6829fd3
L
482 push ix\r
483 ld ix,s0.inbuf ;\r
484 call ff_empty\r
485 pop ix\r
486 ret\r
487\r
488;--------------------------------------------------------------\r
489\r
6dd88c25 490asci1_ista:\r
d6829fd3
L
491 push ix\r
492 ld ix,s1.inbuf ;\r
493 call ff_empty\r
494 pop ix\r
495 ret\r
496\r
497;--------------------------------------------------------------\r
498; Get an input character\r
499\r
6dd88c25 500asci0_inp:\r
d6829fd3
L
501 push ix\r
502 ld ix,s0.inbuf ;\r
81ba3c84
L
503 call ff_gech\r
504 ld a,b\r
505 cp s0.rx_len/4\r
e827bfb9 506 jr nc,a0i_1\r
b8ad769f
L
507 di\r
508 in0 a,(cntla0)\r
46c2044d
L
509 and ~M_RTS0 ;assert RTS\r
510 or M_EFR ;don't reset error flags\r
b8ad769f 511 ei\r
46c2044d 512 out0 (cntla0),a\r
b8ad769f 513a0i_1:\r
81ba3c84 514 ld a,c\r
d6829fd3
L
515 pop ix\r
516 ret\r
517\r
518;--------------------------------------------------------------\r
519; Get an input character\r
520\r
6dd88c25 521asci1_inp:\r
d6829fd3
L
522 push ix\r
523 ld ix,s1.inbuf ;\r
81ba3c84 524 call ff_gech\r
d6829fd3
L
525 pop ix\r
526 ret\r
527\r
528;--------------------------------------------------------------\r
529; Output status\r
530\r
6dd88c25 531asci0_osta:\r
d6829fd3
L
532 push ix\r
533 ld ix,s0.outbuf ;\r
534 call ff_full\r
535 pop ix\r
536 ret\r
537\r
538;--------------------------------------------------------------\r
539; Output status\r
540\r
6dd88c25 541asci1_osta:\r
d6829fd3
L
542 push ix\r
543 ld ix,s1.outbuf ;\r
544 call ff_full\r
545 pop ix\r
546 ret\r
547\r
548;--------------------------------------------------------------\r
549; put character in c in buffer\r
550; destroys hl, bc\r
551; returns output char in a\r
552\r
6dd88c25 553asci0_out:\r
d6829fd3
L
554 push ix ;\r
555 ld ix,s0.outbuf ;\r
81ba3c84
L
556 call ff_puth\r
557 pop ix ;\r
d6829fd3
L
558 di ;\r
559 in0 c,(stat0) ;\r
560 set TIE,c ;\r
561 out0 (stat0),c ;\r
562 ei ;\r
d6829fd3
L
563 ret\r
564\r
565;--------------------------------------------------------------\r
566; put character in c in buffer\r
567; destroys hl, bc\r
568; returns output char in a\r
569\r
6dd88c25 570asci1_out:\r
d6829fd3
L
571 push ix ;\r
572 ld ix,s1.outbuf ;\r
81ba3c84
L
573 call ff_puth\r
574 pop ix ;\r
d6829fd3
L
575 di ;\r
576 in0 c,(stat1) ;\r
577 set TIE,c ;\r
578 out0 (stat1),c ;\r
579 ei ;\r
d6829fd3
L
580 ret\r
581\r
582\r
6dd88c25
L
583;--------------------------------------------------------------\r
584\r
585 cseg\r
586rtxisvjmp0:\r
587 call isv_sw\r
588 dw rxtxi0\r
589rtxisvjmp1:\r
590 call isv_sw\r
591 dw rxtxi1\r
592\r
593;--------------------------------------------------------------\r
46c2044d 594; ASCI 0 Transmit/Receive interupt routines\r
d6829fd3
L
595\r
596 dseg\r
597rxtxi0:\r
46c2044d 598 push ix\r
6dd88c25
L
599rxtxi0_lp0:\r
600 ld ix,s0.inbuf ;\r
601rxtxi0_lp1:\r
602 in0 a,(stat0) ;receive flag set?\r
81ba3c84 603 jp p,rxtxi0_1 ;RDRF == Bit 7\r
6dd88c25
L
604 and M_OVRN+M_PERR+M_FE\r
605 ld e,a\r
81ba3c84 606\r
6dd88c25 607 in0 a,(asext0)\r
46c2044d
L
608 and M_BREAK\r
609 or e\r
610 ld e,a\r
d6829fd3 611\r
46c2044d 612 in0 d,(cntla0) ;\r
b8ad769f 613 res EFR,d ;\r
6dd88c25
L
614 out0 (cntla0),d\r
615\r
d6829fd3 616\r
81ba3c84 617 ld c,(ix+o.in_idx) ;\r
d6829fd3 618 ld b,0\r
81ba3c84 619 ld hl,s0.inbuf ;\r
d6829fd3 620 add hl,bc\r
6dd88c25 621\r
46c2044d 622 in0 a,(rdr0) ;\r
b8ad769f 623 ld (hl),a\r
6dd88c25
L
624 ;todo: break detection\r
625 ;todo: parity, framing overrun error\r
626\r
627\r
1c7e3963 628 ld e,(ix+oint.fflags)\r
6dd88c25
L
629 bit IXON,e\r
630 jr z,rxtxi0_2\r
631\r
632 ;todo: test XON/XOFF\r
633\r
634rxtxi0_2:\r
d6829fd3 635\r
46c2044d
L
636\r
637 ld a,c ;increment buffer in pointer\r
638 inc a ;\r
81ba3c84
L
639 ld b,(ix+o.mask) ;\r
640 and b ;\r
b8ad769f 641 ld c,a\r
81ba3c84
L
642\r
643 sub (ix+o.out_idx) ;\r
6dd88c25
L
644 jr z,rxtxi0_lp1 ;skip if buffer is full\r
645\r
646 ld (ix+o.in_idx),c ;\r
647\r
81ba3c84
L
648 jr nc,$+3 ;\r
649 adc b ;\r
6dd88c25 650\r
81ba3c84 651 cp s0.tx_len*3/4\r
6dd88c25
L
652 jr c,rxi0_noflow\r
653\r
654 bit CRTS_IFLOW,e\r
655 jr z,rxtxi0_4\r
656\r
657 set EFR,d\r
658 set RTS0,d ;RTS inactive\r
46c2044d 659 out0 (cntla0),d ;\r
6dd88c25
L
660\r
661rxtxi0_4:\r
662 bit IXOFF,e\r
663 jr z,rxtxi0_lp1\r
664 ;todo: send XOFF\r
665\r
666rxi0_noflow:\r
667 jr rxtxi0_lp1\r
81ba3c84 668\r
d6829fd3 669\r
46c2044d 670rxtxi0_1:\r
6dd88c25 671 ld e,a\r
46c2044d 672 bit TDRE,e ;TX int?\r
81ba3c84
L
673 jr z,rxtxi0_e ;\r
674\r
b8ad769f 675\r
d6829fd3
L
676 ld ix,s0.outbuf ;\r
677\r
678 ld a,(ix+o.out_idx) ;\r
679 cp (ix+o.in_idx) ;if index.in == index.out\r
680 jr z,?0ti_2 ; buffer empty\r
681\r
682 ld hl,s0.outbuf ;\r
683 ld c,a\r
684 ld b,0\r
685 add hl,bc\r
81ba3c84
L
686 ld b,(hl)\r
687 out0 (tdr0),b ; 7\r
d6829fd3
L
688\r
689 inc a\r
690 and (ix+o.mask)\r
691 ld (ix+o.out_idx),a\r
6dd88c25 692 jr rxtxi0_lp0\r
81ba3c84 693\r
d6829fd3
L
694?0ti_2:\r
695 res TIE,e ;disable tx-int\r
696 out0 (stat0),e ; 5\r
46c2044d
L
697\r
698rxtxi0_e:\r
d6829fd3
L
699 pop ix\r
700 ret\r
701\r
81ba3c84 702\r
6dd88c25 703;--------------------------------------------------------------\r
d6829fd3
L
704; ASCI 1 Transmit/Receive interupt routines\r
705\r
706 dseg\r
707rxtxi1:\r
b8ad769f 708 in0 e,(stat1) ;receive flag set? 5\r
81ba3c84 709 jp p,txi1_0 ;\r
d6829fd3
L
710\r
711 in0 d,(rdr1) ;todo: break detection 9\r
712 bit FE,e ;framing error?\r
713 jr nz,??ri_1\r
714\r
715 push ix\r
716 ld ix,s1.inbuf ;\r
717 ld hl,s1.inbuf ;\r
718 ld c,(ix+o.in_idx) ;\r
719 ld b,0\r
720 add hl,bc\r
721 ld (hl),d\r
722\r
723 ld a,c ;\r
724 inc a\r
725 and (ix+o.mask)\r
726 cp (ix+o.out_idx) ;\r
727 jr z,$+5 ;skip if buffer is full\r
728 ld (ix+o.in_idx),a\r
729 pop ix\r
730??ri_1:\r
731 in0 a,(cntla1) ; 1\r
732 res EFR,a ;\r
733 out0 (cntla1),a ; 1\r
734 ret\r
735\r
81ba3c84 736txi1_0:\r
d6829fd3
L
737 push ix\r
738 ld ix,s1.outbuf ;\r
739\r
740 ld a,(ix+o.out_idx) ;\r
741 cp (ix+o.in_idx) ;if index.in == index.out\r
742 jr z,??ti_2 ; buffer empty\r
743\r
744 ld hl,s1.outbuf ;\r
745 ld c,a\r
746 ld b,0\r
747 add hl,bc\r
748 ld l,(hl)\r
749 out0 (tdr1),l ; 7\r
750\r
751 inc a\r
752 and (ix+o.mask)\r
753 ld (ix+o.out_idx),a\r
754 jr ??ti_3\r
755??ti_2:\r
756 res TIE,e ;disable tx-int\r
757 out0 (stat1),e ; 5\r
758??ti_3:\r
759 pop ix\r
760 ret\r
761\r
762\r
763\r
764 end\r