コード例 #1
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void set_pc_bit(const device_config *device, int bit, int state)
{
	i8255a_t *i8255a = get_safe_token(device);

	/* set output latch bit */
	i8255a->output[PORT_C] &= ~(1 << bit);
	i8255a->output[PORT_C] |= state << bit;

	switch (group_mode(i8255a, GROUP_A))
	{
	case MODE_1:
		if (port_mode(i8255a, PORT_A) == MODE_OUTPUT)
		{
			switch (bit)
			{
			case 3: set_intr(i8255a, PORT_A, state); break;
			case 6: set_inte(i8255a, PORT_A, state); break;
			case 7: set_obf(i8255a, PORT_A, state); break;
			}
		}
		else
		{
			switch (bit)
			{
			case 3: set_intr(i8255a, PORT_A, state); break;
			case 4: set_inte(i8255a, PORT_A, state); break;
			case 5: set_ibf(i8255a, PORT_A, state); break;
			}
		}
		break;

	case MODE_2:
		switch (bit)
		{
		case 3: set_intr(i8255a, PORT_A, state); break;
		case 4: set_inte2(i8255a, state); break;
		case 5: set_ibf(i8255a, PORT_A, state); break;
		case 6: set_inte1(i8255a, state); break;
		case 7: set_obf(i8255a, PORT_A, state); break;
		}
		break;
	}

	if (group_mode(i8255a, GROUP_B) == MODE_1)
	{
		switch (bit)
		{
		case 0: set_intr(i8255a, PORT_B, state); break;
		case 1:
			if (port_mode(i8255a, PORT_B) == MODE_OUTPUT)
				set_obf(i8255a, PORT_B, state);
			else
				set_ibf(i8255a, PORT_B, state);
			break;
		case 2: set_inte(i8255a, PORT_B, state); break;
		}
	}

	output_pc(i8255a);
}
コード例 #2
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void set_mode(const device_config *device, UINT8 data)
{
	i8255a_t *i8255a = get_safe_token(device);

	i8255a->control = data;

	/* group A */
	i8255a->output[PORT_A] = 0;
	i8255a->input[PORT_A] = 0;
	i8255a->ibf[PORT_A] = 0;
	i8255a->obf[PORT_A] = 1;
	i8255a->inte[PORT_A] = 0;
	i8255a->inte1 = 0;
	i8255a->inte2 = 0;

	if (LOG) logerror("8255A '%s' Group A Mode: %u\n", device->tag, group_mode(i8255a, GROUP_A));
	if (LOG) logerror("8255A '%s' Port A Mode: %s\n", device->tag, (port_mode(i8255a, PORT_A) == MODE_OUTPUT) ? "output" : "input");
	if (LOG) logerror("8255A '%s' Port C Upper Mode: %s\n", device->tag, (port_c_upper_mode(i8255a) == MODE_OUTPUT) ? "output" : "input");
	if (LOG) logerror("8255A '%s' Group B Mode: %u\n", device->tag, group_mode(i8255a, GROUP_B));
	if (LOG) logerror("8255A '%s' Port B Mode: %s\n", device->tag, (port_mode(i8255a, PORT_B) == MODE_OUTPUT) ? "output" : "input");
	if (LOG) logerror("8255A '%s' Port C Lower Mode: %s\n", device->tag, (port_c_lower_mode(i8255a) == MODE_OUTPUT) ? "output" : "input");

	/* group B */
	i8255a->output[PORT_B] = 0;
	i8255a->input[PORT_B] = 0;
	i8255a->ibf[PORT_B] = 0;
	i8255a->obf[PORT_B] = 1;
	i8255a->inte[PORT_B] = 0;

	i8255a->output[PORT_C] = 0;
	i8255a->input[PORT_C] = 0;

	output_pc(i8255a);
}
コード例 #3
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
void i8255_device::set_mode(uint8_t data)
{
	m_control = data;

	// group A
	m_output[PORT_A] = 0;
	m_input[PORT_A] = 0;
	m_ibf[PORT_A] = 0;
	m_obf[PORT_A] = 1;
	m_inte[PORT_A] = 0;
	m_inte1 = 0;
	m_inte2 = 0;

	if (port_mode(PORT_A) == MODE_OUTPUT)
	{
		m_out_pa_cb((offs_t)0, m_output[PORT_A]);
	}
	else
	{
		// TTL inputs float high
		m_out_pa_cb((offs_t)0, 0xff);
	}

	if (LOG)
	{
		logerror("I8255 '%s' Group A Mode: %u\n", tag(), group_mode(GROUP_A));
		logerror("I8255 '%s' Port A Mode: %s\n", tag(), (port_mode(PORT_A) == MODE_OUTPUT) ? "output" : "input");
		logerror("I8255 '%s' Port C Upper Mode: %s\n", tag(), (port_c_upper_mode() == MODE_OUTPUT) ? "output" : "input");
		logerror("I8255 '%s' Group B Mode: %u\n", tag(), group_mode(GROUP_B));
		logerror("I8255 '%s' Port B Mode: %s\n", tag(), (port_mode(PORT_B) == MODE_OUTPUT) ? "output" : "input");
		logerror("I8255 '%s' Port C Lower Mode: %s\n", tag(), (port_c_lower_mode() == MODE_OUTPUT) ? "output" : "input");
	}

	// group B
	m_output[PORT_B] = 0;
	m_input[PORT_B] = 0;
	m_ibf[PORT_B] = 0;
	m_obf[PORT_B] = 1;
	m_inte[PORT_B] = 0;

	if (port_mode(PORT_B) == MODE_OUTPUT)
	{
		m_out_pb_cb((offs_t)0, m_output[PORT_B]);
	}
	else
	{
		// TTL inputs float high
		m_out_pb_cb((offs_t)0, 0xff);
	}

	m_output[PORT_C] = 0;
	m_input[PORT_C] = 0;

	output_pc();
}
コード例 #4
0
ファイル: i8255.cpp プロジェクト: RafTacker/mame
void i8255_device::set_mode(uint8_t data)
{
	m_control = data;

	// group A
	m_output[PORT_A] = 0;
	m_input[PORT_A] = 0;
	m_ibf[PORT_A] = 0;
	m_obf[PORT_A] = 1;
	m_inte[PORT_A] = 0;
	m_inte1 = 0;
	m_inte2 = 0;

	if (port_mode(PORT_A) == MODE_OUTPUT)
	{
		m_out_pa_cb((offs_t)0, m_output[PORT_A]);
	}
	else
	{
		// TTL inputs floating
		m_out_pa_cb((offs_t)0, m_tri_pa_cb(0));
	}

	LOG("I8255 Group A Mode: %u\n", group_mode(GROUP_A));
	LOG("I8255 Port A Mode: %s\n", (port_mode(PORT_A) == MODE_OUTPUT) ? "output" : "input");
	LOG("I8255 Port C Upper Mode: %s\n", (port_c_upper_mode() == MODE_OUTPUT) ? "output" : "input");
	LOG("I8255 Group B Mode: %u\n", group_mode(GROUP_B));
	LOG("I8255 Port B Mode: %s\n", (port_mode(PORT_B) == MODE_OUTPUT) ? "output" : "input");
	LOG("I8255 Port C Lower Mode: %s\n", (port_c_lower_mode() == MODE_OUTPUT) ? "output" : "input");

	// group B
	m_output[PORT_B] = 0;
	m_input[PORT_B] = 0;
	m_ibf[PORT_B] = 0;
	m_obf[PORT_B] = 1;
	m_inte[PORT_B] = 0;

	if (port_mode(PORT_B) == MODE_OUTPUT)
	{
		m_out_pb_cb((offs_t)0, m_output[PORT_B]);
	}
	else
	{
		// TTL inputs floating
		m_out_pb_cb((offs_t)0, m_tri_pb_cb(0));
	}

	m_output[PORT_C] = 0;
	m_input[PORT_C] = 0;

	output_pc();
}
コード例 #5
0
ファイル: port_api.c プロジェクト: DanKupiniak/mbed
void port_dir(port_t *obj, PinDirection dir)
{
    obj->dir = dir;

    /* Set default pin mode for pins given by mask */
    switch (dir) {
        case PIN_INPUT:
            port_mode(obj, Input);
            break;
        case PIN_OUTPUT:
            port_mode(obj, PushPull);
            break;
    }
}
コード例 #6
0
ファイル: main.c プロジェクト: alex1818/rtk-8711af
void main(void)
{
    int i;
    int value_new, value_tmp, value_old;
    int stable;

    port_mode(&port0, PullNone);
    // Only PortA or PortB is available now
    port_init(&port0, PortA, 0xFF, PIN_INPUT);

    value_old = port_read(&port0); 
    while(1){
        // De-bonse
        value_new = port_read(&port0); 
        stable = 0;
        while (stable < 3){
            value_tmp = port_read(&port0); 
            if (value_new != value_tmp) {
                value_new = value_tmp;
                stable = 0;
            }
            else {
                stable++;
            }
        } 

        if (value_old != value_new) {
            DBG_8195A("0x%x\r\n", value_new);
            value_old = value_new;
        }
        wait_ms(50);
    }
}
コード例 #7
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
uint8_t i8255_device::read_mode1(int port)
{
	uint8_t data;

	if (port_mode(port) == MODE_OUTPUT)
	{
		// read data from output latch
		data = m_output[port];
	}
	else
	{
		// read data from input latch
		data = m_input[port];

		// clear input buffer full flag
		set_ibf(port, 0);

		// clear interrupt
		set_intr(port, 0);

		// clear input latch
		m_input[port] = 0;
	}

	return data;
}
コード例 #8
0
UINT8 i8255_device::pa_r()
{
	UINT8 data = 0xff;

	if (port_mode(PORT_A) == MODE_OUTPUT)
	{
		data = m_output[PORT_A];
	}

	return data;
}
コード例 #9
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void write_mode0(i8255a_t *i8255a, int port, UINT8 data)
{
	if (port_mode(i8255a, port) == MODE_OUTPUT)
	{
		/* latch output data */
		i8255a->output[port] = data;

		/* write data to port */
		devcb_call_write8(&i8255a->out_port_func[port], 0, data);
	}
}
コード例 #10
0
void i8255_device::write_mode0(int port, UINT8 data)
{
	if (port_mode(port) == MODE_OUTPUT)
	{
		// latch output data
		m_output[port] = data;

		// write data to port
		m_out_port_func[port](0, data);
	}
}
コード例 #11
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
uint8_t i8255_device::pb_r()
{
	uint8_t data = 0xff;

	if (port_mode(PORT_B) == MODE_OUTPUT)
	{
		data = m_output[PORT_B];
	}

	return data;
}
コード例 #12
0
ファイル: main.c プロジェクト: alex1818/rtk-8711af
void main(void)
{
    int i;

    port_mode(&port0, PullNone);
    // Only PortA or PortB is available now
    port_init(&port0, PortA, 0xFF, PIN_OUTPUT);

    while(1){
        for (i=0;i<LED_PATTERN_NUM;i++) {
            port_write(&port0, led_pattern[i]);
            wait_ms(200);
        }
    }
}
コード例 #13
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
void i8255_device::write_mode0(int port, uint8_t data)
{
	if (port_mode(port) == MODE_OUTPUT)
	{
		// latch output data
		m_output[port] = data;

		// write data to port
		if (port == PORT_A)
			m_out_pa_cb((offs_t)0, m_output[port]);
		else if (port == PORT_B)
			m_out_pb_cb((offs_t)0, m_output[port]);
		else
			m_out_pc_cb((offs_t)0, m_output[port]);
	}
}
コード例 #14
0
void i8255_device::write_mode1(int port, UINT8 data)
{
	if (port_mode(port) == MODE_OUTPUT)
	{
		// latch output data
		m_output[port] = data;

		// write data to port
		m_out_port_func[port](0, data);

		// set output buffer full flag
		set_obf(port, 0);

		// clear interrupt
		set_intr(port, 0);
	}
}
コード例 #15
0
UINT8 i8255_device::read_mode0(int port)
{
	UINT8 data = 0;

	if (port_mode(port) == MODE_OUTPUT)
	{
		// read data from output latch
		data = m_output[port];
	}
	else
	{
		// read data from port
		data = m_in_port_func[port](0);
	}

	return data;
}
コード例 #16
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static UINT8 read_mode0(i8255a_t *i8255a, int port)
{
	UINT8 data = 0;

	if (port_mode(i8255a, port) == MODE_OUTPUT)
	{
		/* read data from output latch */
		data = i8255a->output[port];
	}
	else
	{
		/* read data from port */
		data = devcb_call_read8(&i8255a->in_port_func[port], 0);
	}

	return data;
}
コード例 #17
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void write_mode1(i8255a_t *i8255a, int port, UINT8 data)
{
	if (port_mode(i8255a, port) == MODE_OUTPUT)
	{
		/* latch output data */
		i8255a->output[port] = data;

		/* write data to port */
		devcb_call_write8(&i8255a->out_port_func[port], 0, data);

		/* set output buffer full flag */
		set_obf(i8255a, port, 0);

		/* clear interrupt */
		set_intr(i8255a, port, 0);
	}
}
コード例 #18
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
uint8_t i8255_device::read_mode0(int port)
{
	uint8_t data;

	if (port_mode(port) == MODE_OUTPUT)
	{
		// read data from output latch
		data = m_output[port];
	}
	else
	{
		// read data from port
		data = (port == PORT_A) ? m_in_pa_cb(0) : ((port == PORT_B) ? m_in_pb_cb(0) : m_in_pc_cb(0));
	}

	return data;
}
コード例 #19
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
inline void i8255_device::check_interrupt(int port)
{
	switch (group_mode(port))
	{
	case MODE_1:
		switch (port_mode(port))
		{
		case MODE_INPUT:
			set_intr(port, (m_inte[port] && m_ibf[port]));
			break;

		case MODE_OUTPUT:
			set_intr(port, (m_inte[port] && m_obf[port]));
			break;
		}
		break;

	case MODE_2:
		set_intr(port, ((m_inte1 && m_obf[port]) || (m_inte2 && m_ibf[port])));
		break;
	}
}
コード例 #20
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void check_interrupt(i8255a_t *i8255a, int port)
{
	switch (group_mode(i8255a, port))
	{
	case MODE_1:
		switch (port_mode(i8255a, port))
		{
		case MODE_INPUT:
			if (i8255a->inte[port] && i8255a->ibf[port])
			{
				if (LOG) logerror("8255A Port %c INTR: 1\n", 'A' + port);

				i8255a->intr[port] = 1;
			}
			break;

		case MODE_OUTPUT:
			if (i8255a->inte[port] && i8255a->obf[port])
			{
				if (LOG) logerror("8255A Port %c INTR: 1\n", 'A' + port);

				i8255a->intr[port] = 1;
			}
			break;
		}
		break;

	case MODE_2:
		if ((i8255a->inte1 && i8255a->obf[port]) || (i8255a->inte2 && i8255a->ibf[port]))
		{
			if (LOG) logerror("8255A Port %c INTR: 1\n", 'A' + port);

			i8255a->intr[port] = 1;
		}
		break;
	}

	output_pc(i8255a);
}
コード例 #21
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
void i8255_device::write_mode1(int port, uint8_t data)
{
	if (port_mode(port) == MODE_OUTPUT)
	{
		// latch output data
		m_output[port] = data;

		// write data to port
		if (port == PORT_A)
			m_out_pa_cb((offs_t)0, m_output[port]);
		else if (port == PORT_B)
			m_out_pb_cb((offs_t)0, m_output[port]);
		else
			m_out_pc_cb((offs_t)0, m_output[port]);

		// set output buffer full flag
		set_obf(port, 0);

		// clear interrupt
		set_intr(port, 0);
	}
}
コード例 #22
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static UINT8 read_mode1(i8255a_t *i8255a, int port)
{
	UINT8 data = 0;

	if (port_mode(i8255a, port) == MODE_OUTPUT)
	{
		/* read data from output latch */
		data = i8255a->output[port];
	}
	else
	{
		/* read data from input latch */
		data = i8255a->input[port];

		/* clear input buffer full flag */
		set_ibf(i8255a, port, 0);

		/* clear interrupt */
		set_intr(i8255a, port, 0);
	}

	return data;
}
コード例 #23
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static void output_pc(i8255a_t *i8255a)
{
	UINT8 data = 0;
	UINT8 mask = 0;

	/* PC upper */
	switch (group_mode(i8255a, GROUP_A))
	{
	case MODE_0:
		if (port_c_upper_mode(i8255a) == MODE_OUTPUT)
		{
			mask |= 0xf0;
		}
		break;

	case MODE_1:
		data |= i8255a->intr[PORT_A] ? 0x08 : 0x00;

		if (port_mode(i8255a, PORT_A) == MODE_OUTPUT)
		{
			data |= i8255a->obf[PORT_A] ? 0x80 : 0x00;
			mask |= 0x30;
		}
		else
		{
			data |= i8255a->ibf[PORT_A] ? 0x20 : 0x00;
			mask |= 0xc0;
		}
		break;

	case MODE_2:
		data |= i8255a->intr[PORT_A] ? 0x08 : 0x00;
		data |= i8255a->ibf[PORT_A] ? 0x20 : 0x00;
		data |= i8255a->obf[PORT_A] ? 0x80 : 0x00;
		break;
	}

	/* PC lower */
	switch (group_mode(i8255a, GROUP_B))
	{
	case MODE_0:
		if (port_c_lower_mode(i8255a) == MODE_OUTPUT)
		{
			mask |= 0x0f;
		}
		break;

	case MODE_1:
		data |= i8255a->intr[PORT_B] ? 0x01 : 0x00;

		if (port_mode(i8255a, PORT_B) == MODE_OUTPUT)
		{
			data |= i8255a->obf[PORT_B] ? 0x02 : 0x00;
		}
		else
		{
			data |= i8255a->ibf[PORT_B] ? 0x02 : 0x00;
		}
	}

	data |= i8255a->output[PORT_C] & mask;

	devcb_call_write8(&i8255a->out_port_func[PORT_C], 0, data);
}
コード例 #24
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
void i8255_device::set_pc_bit(int bit, int state)
{
	// set output latch bit
	m_output[PORT_C] &= ~(1 << bit);
	m_output[PORT_C] |= state << bit;

	switch (group_mode(GROUP_A))
	{
	case MODE_1:
		if (port_mode(PORT_A) == MODE_OUTPUT)
		{
			switch (bit)
			{
			case 3: set_intr(PORT_A, state); break;
			case 6: set_inte(PORT_A, state); break;
			case 7: set_obf(PORT_A, state); break;
			default: break;
			}
		}
		else
		{
			switch (bit)
			{
			case 3: set_intr(PORT_A, state); break;
			case 4: set_inte(PORT_A, state); break;
			case 5: set_ibf(PORT_A, state); break;
			default: break;
			}
		}
		break;

	case MODE_2:
		switch (bit)
		{
		case 3: set_intr(PORT_A, state); break;
		case 4: set_inte2(state); break;
		case 5: set_ibf(PORT_A, state); break;
		case 6: set_inte1(state); break;
		case 7: set_obf(PORT_A, state); break;
		default: break;
		}
		break;
	}

	if (group_mode(GROUP_B) == MODE_1)
	{
		switch (bit)
		{
		case 0: set_intr(PORT_B, state); break;
		case 1:
			if (port_mode(PORT_B) == MODE_OUTPUT)
				set_obf(PORT_B, state);
			else
				set_ibf(PORT_B, state);
			break;
		case 2: set_inte(PORT_B, state); break;
		default: break;
		}
	}

	output_pc();
}
コード例 #25
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
void i8255_device::output_pc()
{
	uint8_t data = 0;
	uint8_t mask = 0;
	uint8_t b_mask = 0x0f;

	// PC upper
	switch (group_mode(GROUP_A))
	{
	case MODE_0:
		if (port_c_upper_mode() == MODE_OUTPUT)
		{
			mask |= 0xf0;
		}
		else
		{
			// TTL inputs float high
			data |= 0xf0;
		}
		break;

	case MODE_1:
		data |= m_intr[PORT_A] ? 0x08 : 0x00;

		if (port_mode(PORT_A) == MODE_OUTPUT)
		{
			data |= m_obf[PORT_A] ? 0x80 : 0x00;
			mask |= 0x30;
		}
		else
		{
			data |= m_ibf[PORT_A] ? 0x20 : 0x00;
			mask |= 0xc0;
		}
		break;

	case MODE_2:
		b_mask = 0x07;
		data |= m_intr[PORT_A] ? 0x08 : 0x00;
		data |= m_ibf[PORT_A] ? 0x20 : 0x00;
		data |= m_obf[PORT_A] ? 0x80 : 0x00;
		break;
	}

	// PC lower
	switch (group_mode(GROUP_B))
	{
	case MODE_0:
		if (port_c_lower_mode() == MODE_OUTPUT)
		{
			mask |= b_mask;
		}
		else
		{
			// TTL inputs float high
			data |= b_mask;
		}
		break;

	case MODE_1:
		data |= m_intr[PORT_B] ? 0x01 : 0x00;

		if (port_mode(PORT_B) == MODE_OUTPUT)
		{
			data |= m_obf[PORT_B] ? 0x02 : 0x00;
		}
		else
		{
			data |= m_ibf[PORT_B] ? 0x02 : 0x00;
		}
	}

	data |= m_output[PORT_C] & mask;

	m_out_pc_cb((offs_t)0, data);
}
コード例 #26
0
ファイル: i8255.cpp プロジェクト: crazii/mameui
uint8_t i8255_device::read_pc()
{
	uint8_t data = 0;
	uint8_t mask = 0;
	uint8_t b_mask = 0x0f;

	// PC upper
	switch (group_mode(GROUP_A))
	{
	case MODE_0:
		if (port_c_upper_mode() == MODE_OUTPUT)
		{
			// read data from output latch
			data |= m_output[PORT_C] & 0xf0;
		}
		else
		{
			// read data from port
			mask |= 0xf0;
		}
		break;

	case MODE_1:
		data |= m_intr[PORT_A] ? 0x08 : 0x00;

		if (port_mode(PORT_A) == MODE_OUTPUT)
		{
			data |= m_obf[PORT_A] ? 0x80 : 0x00;
			data |= m_inte[PORT_A] ? 0x40 : 0x00;
			mask |= 0x30;
		}
		else
		{
			data |= m_ibf[PORT_A] ? 0x20 : 0x00;
			data |= m_inte[PORT_A] ? 0x10 : 0x00;
			mask |= 0xc0;
		}
		break;

	case MODE_2:
		b_mask = 0x07;
		data |= m_intr[PORT_A] ? 0x08 : 0x00;
		data |= m_inte2 ? 0x10 : 0x00;
		data |= m_ibf[PORT_A] ? 0x20 : 0x00;
		data |= m_inte1 ? 0x40 : 0x00;
		data |= m_obf[PORT_A] ? 0x80 : 0x00;
		break;
	}

	// PC lower
	switch (group_mode(GROUP_B))
	{
	case MODE_0:
		if (port_c_lower_mode() == MODE_OUTPUT)
		{
			// read data from output latch
			data |= m_output[PORT_C] & b_mask;
		}
		else
		{
			// read data from port
			mask |= b_mask;
		}
		break;

	case MODE_1:
		data |= m_inte[PORT_B] ? 0x04 : 0x00;
		data |= m_intr[PORT_B] ? 0x01 : 0x00;

		if (port_mode(PORT_B) == MODE_OUTPUT)
		{
			data |= m_obf[PORT_B] ? 0x02 : 0x00;
		}
		else
		{
			data |= m_ibf[PORT_B] ? 0x02 : 0x00;
		}
	}

	if (mask)
	{
		// read data from port
		data |= m_in_pc_cb(0) & mask;
	}

	return data;
}
コード例 #27
0
ファイル: i8255a.c プロジェクト: Paulodx/sdl-mame-wii
static UINT8 read_pc(i8255a_t *i8255a)
{
	UINT8 data = 0;
	UINT8 mask = 0;

	/* PC upper */
	switch (group_mode(i8255a, GROUP_A))
	{
	case MODE_0:
		if (port_c_upper_mode(i8255a) == MODE_OUTPUT)
		{
			/* read data from output latch */
			data |= i8255a->output[PORT_C] & 0xf0;
		}
		else
		{
			/* read data from port */
			mask |= 0xf0;
		}
		break;

	case MODE_1:
		data |= i8255a->intr[PORT_A] ? 0x08 : 0x00;

		if (port_mode(i8255a, PORT_A) == MODE_OUTPUT)
		{
			data |= i8255a->obf[PORT_A] ? 0x80 : 0x00;
			data |= i8255a->inte[PORT_A] ? 0x40 : 0x00;
			mask |= 0x30;
		}
		else
		{
			data |= i8255a->ibf[PORT_A] ? 0x20 : 0x00;
			data |= i8255a->inte[PORT_A] ? 0x10 : 0x00;
			mask |= 0xc0;
		}
		break;

	case MODE_2:
		data |= i8255a->intr[PORT_A] ? 0x08 : 0x00;
		data |= i8255a->inte2 ? 0x10 : 0x00;
		data |= i8255a->ibf[PORT_A] ? 0x20 : 0x00;
		data |= i8255a->inte1 ? 0x40 : 0x00;
		data |= i8255a->obf[PORT_A] ? 0x80 : 0x00;
		break;
	}

	/* PC lower */
	switch (group_mode(i8255a, GROUP_B))
	{
	case MODE_0:
		if (port_c_lower_mode(i8255a) == MODE_OUTPUT)
		{
			/* read data from output latch */
			data |= i8255a->output[PORT_C] & 0x0f;
		}
		else
		{
			/* read data from port */
			mask |= 0x0f;
		}
		break;

	case MODE_1:
		data |= i8255a->inte[PORT_B] ? 0x04 : 0x00;
		data |= i8255a->intr[PORT_B] ? 0x01 : 0x00;

		if (port_mode(i8255a, PORT_B) == MODE_OUTPUT)
		{
			data |= i8255a->obf[PORT_B] ? 0x02 : 0x00;
		}
		else
		{
			data |= i8255a->ibf[PORT_B] ? 0x02 : 0x00;
		}
	}

	if (mask)
	{
		/* read data from port */
		data |= devcb_call_read8(&i8255a->in_port_func[PORT_C], 0) & mask;
	}

	return data;
}