コード例 #1
0
ファイル: a2mouse.cpp プロジェクト: bradhugh/mame
/**
 * @brief return the mouse motion flags
 *
 * Advance the mouse x and y coordinates to the dx and dy
 * coordinates by either toggling MX2 or MX1 first for a
 * y movement, or MY2 or MY1 for x movement.
 * There are four read phases counted by m_mouse.phase
 *
 * @return lookup value from madr_a32
 */
UINT16 alto2_cpu_device::mouse_read()
{
    UINT16 data;

    m_mouse.latch = (m_mouse.latch << 1) & MLATCH;
    data = m_madr_a32[m_mouse.latch];

    switch (m_mouse.phase) {
    case 0:
        m_mouse.latch ^= MOVEX(m_mouse.dx - m_mouse.x);
        m_mouse.latch ^= MOVEY(m_mouse.dy - m_mouse.y);
        break;
    case 1:
        m_mouse.latch |= MACTIVE;
        m_mouse.x += SIGN(m_mouse.dx - m_mouse.x);
        m_mouse.y += SIGN(m_mouse.dy - m_mouse.y);
        break;
    case 2:
        m_mouse.latch ^= MOVEX(m_mouse.dx - m_mouse.x);
        m_mouse.latch ^= MOVEY(m_mouse.dy - m_mouse.y);
        break;
    case 3:
        m_mouse.latch |= MACTIVE;
        m_mouse.x += SIGN(m_mouse.dx - m_mouse.x);
        m_mouse.y += SIGN(m_mouse.dy - m_mouse.y);
    }
    m_mouse.phase = (m_mouse.phase + 1) % 4;
    return data;
}
コード例 #2
0
ファイル: mouse.c プロジェクト: VrRm/salto_simulator
/**
 * @brief return the mouse motion flags
 *
 * Advance the mouse x and y coordinates to the dx and dy
 * coordinates by either toggling MX2 or MX1 first for a
 * y movement, MY2 or MY1 for x movement.
 *
 * @result lookup value from madr_a32
 */
int mouse_read(void)
{
	static int arg;
	int data;

	mouse.latch = (mouse.latch << 1) & MLATCH;
	data = madr_a32[mouse.latch];

	switch (arg & 3) {
	case 0:
		mouse.latch |= MOVEX(mouse.dx - mouse.x);
		mouse.latch |= MOVEY(mouse.dy - mouse.y);
		break;
	case 1:
		mouse.latch |= MACTIVE;
		if (mouse.x < mouse.dx)
			mouse.x++;
		else if (mouse.x > mouse.dx)
			mouse.x--;
		if (mouse.y < mouse.dy)
			mouse.y++;
		else if (mouse.y > mouse.dy)
			mouse.y--;
		break;
	case 2:
		mouse.latch ^= MOVEX(mouse.dx - mouse.x);
		mouse.latch ^= MOVEY(mouse.dy - mouse.y);
		break;
	default:
		mouse.latch &= ~MACTIVE;
		if (mouse.x < mouse.dx)
			mouse.x++;
		else if (mouse.x > mouse.dx)
			mouse.x--;
		if (mouse.y < mouse.dy)
			mouse.y++;
		else if (mouse.y > mouse.dy)
			mouse.y--;
	}
	arg++;

	return data;
}