+ pop ix\r
+ call asci_start\r
+ ret\r
+\r
+;--------------------------------------------------------------\r
+\r
+mod_tab:\r
+ db 000B ; 7N1\r
+ db 100B ; 8N1\r
+ db 001B ; 7N2\r
+ db 101B ; 8N2\r
+ db 010B ; 7P1\r
+ db 110B ; 8P1\r
+ db 011B ; 7P2\r
+ db 111B ; 8P2\r
+\r
+\r
+;--------------------------------------------------------------\r
+; Get the current serial port settings.\r
+\r
+func_tcgeta:\r
+ call chk_ptr\r
+\r
+ ld a,(ix+o.iflags)\r
+ call b_st_a\r
+ inc de\r
+ ld a,(ix+o.fflags)\r
+ call b_st_a\r
+ inc de\r
+\r
+ ld b,(ix+o.absdev)\r
+ ld c,8 ;\r
+ mlt bc ;\r
+ ld hl,@ctbl+7 ;\r
+ add hl,bc ;\r
+ ld a,(hl) ;get baudrate index\r
+ and M_CBAUD\r
+ ld b,a\r
+ ld a,(ix+o.cflags)\r
+ and ~M_CBAUD\r
+ or b\r
+ call b_st_a\r
+ dec de\r
+ dec de\r
+ xor a\r
+ ret\r
+\r
+;--------------------------------------------------------------\r
+; Set the current serial port settings.\r
+\r
+func_tcseta:\r
+ call chk_ptr\r
+\r
+ call asci_stop\r
+\r
+ call b_ld_a\r
+ ld (ix+o.iflags),a\r
+ inc de\r
+ call b_ld_a\r
+ ld (ix+o.fflags),a\r
+ inc de\r
+\r
+ ld b,(ix+o.absdev)\r
+ ld c,8 ;\r
+ mlt bc ;\r
+ ld hl,@ctbl+7 ;\r
+ add hl,bc ;\r
+ call b_ld_a\r
+ ld (ix+o.cflags),a\r
+ and M_CBAUD\r
+ ld (hl),a ;set baudrate index\r
+ dec de\r
+ dec de\r
+ push de\r
+ call init_st\r
+ pop de\r
+ xor a\r
+ ret\r
+\r
+;--------------------------------------------------------------\r
+; Allow the output buffer to drain\r
+\r
+func_tcsetaw:\r
+\r
+;--------------------------------------------------------------\r
+; Allow the output buffer to drain, discard pending input\r
+\r
+func_tcsetaf:\r
+\r
+;--------------------------------------------------------------\r
+; Sending a break (250ms .. 500ms)\r
+\r
+func_tcsbrk:\r
+\r
+;--------------------------------------------------------------\r
+; arg is timeinterval in 0.1sec\r
+\r
+func_tcsbrkp:\r
+\r
+;--------------------------------------------------------------\r
+; Turn break on\r
+\r
+func_tiocsbrk:\r
+\r
+;--------------------------------------------------------------\r
+; Turn break off\r
+\r
+func_tioccbrk:\r
+\r
+;--------------------------------------------------------------\r
+; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)\r
+\r
+func_tcxonc:\r
+\r
+;--------------------------------------------------------------\r
+; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)\r
+\r
+func_tcflsh:\r
+\r
+;--------------------------------------------------------------\r
+; Get the number of bytes in the input buffer.\r
+\r
+func_fionread:\r
+\r
+;--------------------------------------------------------------\r
+; Get the number of bytes in the output buffer.\r
+\r
+func_tiocoutq:\r
+\r
+;--------------------------------------------------------------\r
+; get the status of modem bits.\r
+\r
+func_tiocmget:\r
+\r
+;--------------------------------------------------------------\r
+; set the indicated modem bits.\r
+\r
+func_tiocmbis:\r
+\r
+;--------------------------------------------------------------\r
+; clear the indicated modem bits.\r
+\r
+func_tiocmbic:\r
+\r
+;--------------------------------------------------------------\r
+; set the status of modem bits.\r
+\r
+func_tiocmset:\r
+\r
+;--------------------------------------------------------------\r
+; Get the status of the CLOCAL flag in the c_cflag field\r
+\r
+func_tiocgsoftcar:\r
+\r
+;--------------------------------------------------------------\r
+; Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.\r
+\r
+func_tiocssoftcar:\r
+\r
+ or 0ffh\r
+ ret\r
+\r
+;--------------------------------------------------------------\r
+\r
+chk_ptr:\r
+ ld a,e\r
+ or d\r
+ ret nz\r
+ cpl\r
+ pop hl\r
+ ret\r
+\r
+;--------------------------------------------------------------\r
+\r
+asci_stop:\r
+ ld c,stat0 ;Disable rx/tx interrupts\r
+ xor a ;\r
+ call out_asci_reg\r
+\r
+ ld c,cntla0 ;Disable receiver and transmitter\r
+ ld a,M_RTS0+M_EFR ;RTS/CKA1\r
+ jr out_asci_reg\r
+\r
+;--------------------------------------------------------------\r
+\r
+asci_start:\r
+ bit 0,(ix+o.reldev)\r
+ jr nz,asci_st1\r
+ in0 a,cntla0 ;asci0\r
+ and ~M_RTS0 ;Activate RTS\r
+ or M_EFR\r
+ out0 (cntla0),a\r
+asci_st1:\r
+ ld c,stat0 ;\r