コード例 #1
0
ファイル: bitbngr.c プロジェクト: LibXenonProject/mame-lx
void bitbanger_device::set_input_line(UINT8 line)
{
	/* normalize */
	line = line ? ASSERT_LINE : CLEAR_LINE;

	/* only act when the state changes */
	if (m_current_input != line)
	{
		m_current_input = line;
		if (!m_input_callback.isnull())
		{
			m_input_callback(line ? ASSERT_LINE : CLEAR_LINE);
		}
	}
}
コード例 #2
0
ファイル: adc083x.c プロジェクト: Ilgrim/MAMEHub
UINT8 adc083x_device::conversion()
{
	int result;
	int positive_channel = ADC083X_AGND;
	int negative_channel = ADC083X_AGND;
	double positive = 0;
	double negative = 0;
	double gnd = m_input_callback( this, ADC083X_AGND );
	double vref = m_input_callback( this, ADC083X_VREF );

	if( type() == ADC0831 )
	{
		positive_channel = ADC083X_CH0;
		negative_channel = ADC083X_CH1;
	}
	else if( type() == ADC0832 )
	{
		positive_channel = ADC083X_CH0 + m_odd;
		if( m_sgl == 0 )
		{
			negative_channel = positive_channel ^ 1;
		}
		else
		{
			negative_channel = ADC083X_AGND;
		}
	}
	else if( type() == ADC0834 )
	{
		positive_channel = ADC083X_CH0 + m_odd + ( m_sel1 * 2 );
		if( m_sgl == 0 )
		{
			negative_channel = positive_channel ^ 1;
		}
		else
		{
			negative_channel = ADC083X_AGND;
		}
	}
	else if( type() == ADC0838 )
	{
		positive_channel = ADC083X_CH0 + m_odd + ( m_sel0 * 2 ) + ( m_sel1 * 4 );
		if( m_sgl == 0 )
		{
			negative_channel = positive_channel ^ 1;
		}
		else
		{
			negative_channel = ADC083X_COM;
		}
	}

	if( positive_channel != ADC083X_AGND )
	{
		positive = m_input_callback( this, positive_channel ) - gnd;
	}

	if( negative_channel != ADC083X_AGND )
	{
		negative = m_input_callback( this, negative_channel ) - gnd;
	}

	result = (int) ( ( ( positive - negative ) * 255 ) / vref );
	if( result < 0 )
	{
		result = 0;
	}
	else if( result > 255 )
	{
		result = 255;
	}

	return result;
}