Merge pull request #33 from ramiropolla/upd7810

upd7810: interrupt-related fixes
This commit is contained in:
Miodrag Milanović 2014-11-05 08:11:05 +01:00
commit ecbc6c810e
3 changed files with 40 additions and 42 deletions

View File

@ -567,8 +567,8 @@ UINT8 upd7810_device::RP(offs_t port)
data = (data & ~0x02) | (m_rxd & 1 ? 0x02 : 0x00);
if (m_mcc & 0x04) /* PC2 = SCK input/output */
data = (data & ~0x04) | (m_sck & 1 ? 0x04 : 0x00);
if (m_mcc & 0x08) /* PC3 = TI input */
data = (data & ~0x08) | (m_ti & 1 ? 0x08 : 0x00);
if (m_mcc & 0x08) /* PC3 = TI/INT2 input */
data = (data & ~0x08) | (m_int2 & 1 ? 0x08 : 0x00);
if (m_mcc & 0x10) /* PC4 = TO output */
data = (data & ~0x10) | (m_to & 1 ? 0x10 : 0x00);
if (m_mcc & 0x20) /* PC5 = CI input */
@ -648,8 +648,8 @@ void upd7810_device::WP(offs_t port, UINT8 data)
data = (data & ~0x02) | (m_rxd & 1 ? 0x02 : 0x00);
if (m_mcc & 0x04) /* PC2 = SCK input/output */
data = (data & ~0x04) | (m_sck & 1 ? 0x04 : 0x00);
if (m_mcc & 0x08) /* PC3 = TI input */
data = (data & ~0x08) | (m_ti & 1 ? 0x08 : 0x00);
if (m_mcc & 0x08) /* PC3 = TI/INT2 input */
data = (data & ~0x08) | (m_int2 & 1 ? 0x08 : 0x00);
if (m_mcc & 0x10) /* PC4 = TO output */
data = (data & ~0x10) | (m_to & 1 ? 0x10 : 0x00);
if (m_mcc & 0x20) /* PC5 = CI input */
@ -709,6 +709,14 @@ void upd7810_device::upd7810_take_irq()
return;
/* check the interrupts in priority sequence */
if (IRR & INTNMI)
{
/* Nonmaskable interrupt */
irqline = INPUT_LINE_NMI;
vector = 0x0004;
IRR &= ~INTNMI;
}
else
if ((IRR & INTFT0) && 0 == (MKL & 0x02))
{
vector = 0x0008;
@ -1608,6 +1616,7 @@ void upd7810_device::base_device_start()
save_item(NAME(m_ovcf));
save_item(NAME(m_ovcs));
save_item(NAME(m_edges));
save_item(NAME(m_nmi));
save_item(NAME(m_int1));
save_item(NAME(m_int2));
@ -1789,6 +1798,7 @@ void upd7810_device::device_reset()
m_co1 = 0;
m_irr = 0;
m_itf = 0;
m_nmi = 0;
m_int1 = 0;
m_int2 = 0;
@ -1962,37 +1972,31 @@ void upd7801_device::execute_set_input(int irqline, int state)
void upd7810_device::execute_set_input(int irqline, int state)
{
if (state != CLEAR_LINE)
{
if (irqline == INPUT_LINE_NMI)
{
/* no nested NMIs ? */
// if (0 == (IRR & INTNMI))
{
switch (irqline) {
case INPUT_LINE_NMI:
/* NMI is falling edge sensitive */
if ( m_nmi == ASSERT_LINE && state == CLEAR_LINE )
IRR |= INTNMI;
SP--;
WM( SP, PSW );
SP--;
WM( SP, PCH );
SP--;
WM( SP, PCL );
IFF = 0;
PSW &= ~(SK|L0|L1);
PC = 0x0004;
}
}
else
if (irqline == UPD7810_INTF1)
m_nmi = state;
break;
case UPD7810_INTF1:
/* INT1 is rising edge sensitive */
if ( m_int1 == CLEAR_LINE && state == ASSERT_LINE )
IRR |= INTF1;
else
if ( irqline == UPD7810_INTF2 && ( MKL & 0x20 ) )
m_int1 = state;
break;
case UPD7810_INTF2:
/* INT2 is falling edge sensitive */
if ( m_int2 == ASSERT_LINE && state == CLEAR_LINE )
IRR |= INTF2;
// gamemaster hack
else
if (irqline == UPD7810_INTFE1)
IRR |= INTFE1;
else
m_int2 = state;
break;
default:
logerror("upd7810_set_irq_line invalid irq line #%d\n", irqline);
break;
}
/* resetting interrupt requests is done with the SKIT/SKNIT opcodes only! */
}

View File

@ -294,8 +294,9 @@ protected:
UINT8 m_co1;
UINT16 m_irr; /* interrupt request register */
UINT16 m_itf; /* interrupt test flag register */
int m_int1; /* keep track of current int1 state. Needed for 7801 irq checking. */
int m_int2; /* keep track to current int2 state. Needed for 7801 irq checking. */
int m_nmi; /* keep track of current nmi state. Needed for 7810 irq checking. */
int m_int1; /* keep track of current int1 state. Needed for irq checking. */
int m_int2; /* keep track to current int2 state. Needed for irq checking. */
/* internal helper variables */
UINT16 m_txs; /* transmitter shift register */

View File

@ -28,7 +28,6 @@ public:
DECLARE_WRITE8_MEMBER(gmaster_port_w);
DECLARE_DRIVER_INIT(gmaster) { memset(&m_video, 0, sizeof(m_video)); memset(m_ram, 0, sizeof(m_ram)); }
UINT32 screen_update_gmaster(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(gmaster_interrupt);
private:
virtual void machine_start();
@ -278,16 +277,10 @@ void gmaster_state::machine_start()
}
INTERRUPT_GEN_MEMBER(gmaster_state::gmaster_interrupt)
{
m_maincpu->set_input_line(UPD7810_INTFE1, ASSERT_LINE);
}
static MACHINE_CONFIG_START( gmaster, gmaster_state )
MCFG_CPU_ADD("maincpu", UPD7810, XTAL_12MHz/2/*?*/) // upd78c11 in the unit
MCFG_CPU_PROGRAM_MAP(gmaster_mem)
MCFG_CPU_IO_MAP( gmaster_io)
MCFG_CPU_VBLANK_INT_DRIVER("screen", gmaster_state, gmaster_interrupt)
MCFG_SCREEN_ADD("screen", LCD)
MCFG_SCREEN_REFRESH_RATE(60)