@Override
    public void set_nmi_line(int state) {
    	if (m6809.nmi_state == state) return;
    	m6809.nmi_state = state;
    	if(errorlog!=null) fprintf(errorlog, "M6809#%d set_nmi_line %d\n", cpu_getactivecpu(), state);
    	if( state == CLEAR_LINE ) return;
    
    	/* if the stack was not yet initialized */
        if( (m6809.int_state & M6809_LDS)==0 ) return;
    
        m6809.int_state &= ~M6809_SYNC;
    	/* HJB 990225: state already saved by CWAI? */
    	if(( m6809.int_state & M6809_CWAI )!=0)
    	{
    		m6809.int_state &= ~M6809_CWAI;
    		m6809.extra_cycles += 7;	/* subtract +7 cycles next time */
        }
    	else
    	{
    		m6809.cc |= CC_E; 				/* save entire state */
    		PUSHWORD(m6809.pc);
    		PUSHWORD(m6809.u);
    		PUSHWORD(m6809.y);
    		PUSHWORD(m6809.x);
    		PUSHBYTE(m6809.dp);
    		PUSHBYTE(m6809.b);
    		PUSHBYTE(m6809.a);
    		PUSHBYTE(m6809.cc);
    		m6809.extra_cycles += 19;	/* subtract +19 cycles next time */
    	}
    	m6809.cc |= CC_IF | CC_II;			/* inhibit FIRQ and IRQ */
    	m6809.pc = RM16(0xfffc);
    	CHANGE_PC();
        if(m6809log!=null) fprintf(m6809log,"M6809#%d nmi_line :PC:%d,PPC:%d,A:%d,B:%d,D:%d,DP:%d,U:%d,S:%d,X:%d,Y:%d,CC:%d,EA:%d\n", cpu_getactivecpu(),m6809.pc,m6809.ppc,m6809.a,m6809.b,getDreg(),m6809.dp,m6809.u,m6809.s,m6809.x,m6809.y,m6809.cc,ea);
 
    }