static BLOCK	DIA_save=NULL;

typedef struct _DIA {
    struct _DIA	*next;
    EVENT	*ep;
    short	mode;
    int		no;
    short	hit;
    char	*mac;
    char	*str;
} DIANODE;

DIANODE	*topdia=NULL;

void	DIA_hit(DIANODE *np)
{
    int     no;
    EVENT   *ep;
    DIANODE *tp;

    no = macval(np->mac);
    for ( tp = topdia ; tp != NULL ; tp = tp->next ) {
	if ( tp->mode == DIA_SW && strcmp(tp->mac,np->mac) == 0 ) {
	    if ( (tp->hit != FALSE && tp->no != no) ||
		 (tp->hit == FALSE && tp->no == no) ) {
		ep = tp->ep;
		tp->hit = (tp->hit == FALSE ? TRUE:FALSE);
		MOS_disp(FALSE);
		DSP_xline(ep->x1,ep->y1,ep->x2,ep->y2,8,4);
		MOS_disp(TRUE);
	    }
	}
    }
}

void	DIA_sw(int x,int y,int col,int chr,int no,char *ttl,char *mac)
{
    DIANODE *np;

    if ( (np = (DIANODE *)malloc(sizeof(DIANODE))) == NULL )
	return;

    np->next = topdia;
    topdia = np;
    np->ep = EVT_big_sw(x,y,ttl,7,8,col,chr,600,DIA_event,(int)np);
    np->mode = DIA_SW;
    np->no = no;
    np->hit = FALSE;
    np->mac = strdup(mac);
    np->str = NULL;
}

void	DIA_open(int x1,int y1,int x2,int y2,int col)
{
    MOS_disp(FALSE);
    MOS_push(x1,y1,x2,y2);
    DIA_save = DSP_push_vram(x1,y1,x2,y2);
    DSP_rbox(x1,y1,x2,y2,7,8,col);
    MOS_setpos((x1+x2)/2,(y1+y2)/2);
}
void	DIA_close()
{
    if ( DIA_save != NULL ) {
	EVT_level_free(600);
	MOS_disp(FALSE);
	DSP_pop_vram(DIA_save);
	MOS_push(ERR,ERR,ERR,ERR);
	DIA_save = NULL;
    }
}
