/****************************************************************************/
/*  call INT 14h to initialize RS-232					    */
/****************************************************************************/

init_rs232()
{
 union REGS  inregs, outregs;

/* CORE 90.08.14 Modify RS232C Setting (Same As SPEED Command) */
#ifdef NEC_PC9801 /*NEC_PC9801*/
    struct SREGS segregs ;
    unsigned int flags = 0 ;
    
    flags  = (((RS232 & 0x00e0)>> 5)+1)<<8 ; /* CORE 90.08.14 Set Baud Rate */
    flags |= ( (RS232 & 0x0003)<< 2)       ; /* CORE 90.08.14 Set Data Leng */
    flags |= ( (RS232 & 0x0018)<< 1)       ; /* CORE 90.08.14 Set Party Chk */
    flags |= 0x0040;                         /* CORE 90.08.14 Set Stop = 1  */
    segread (&segregs) ;                     /*              & X-Cntl = OFF */
    inregs.h.ah = 0 ;
    movedata(segregs.ds,(int)&flags,0x0060,0x0068,2);
    segregs.ds = 0x0060 ;
    int86x(0x19,&inregs,&outregs,&segregs);
#else /*NEC_PC9801*/
//    inregs.x.ax = RS232 & 0xff;
//    inregs.x.dx = RS232_COM;
//    int86( 0x14, &inregs, &outregs );

/* 
	Initialize COM port baud rate and parity settings
																		*/
if ( RS232_COM == 0 )
	_com1init(RS232);
else
	_com2init(RS232);

#endif /*NEC_PC9801*/

}  /*  of init_rs232()  */

decide_baud(ptr)
char *ptr;
{
	int i,j;
	int pat_len;
	char *p;
	for(i=0 ; i<10 ; i++) {
		pat_len = strlen(baud_pat[i]);
		if(!strnicmp(baud_pat[i],ptr,pat_len)) {
			baud = i;
			for(j=0;j < pat_len;j++) link_mg2[j]=*ptr++;
			if (pat_len == 3) link_mg2[3]=' ';
			RS232 &= 0x1f;
			RS232 |= (baud<<5);
			return(pat_len);
		}
	}
	p = index(ptr,',');
	if(!p) pat_len = strlen(ptr);
	else pat_len = p - ptr;
	return(pat_len);
}
