68230pit updates: [R. Belmont]

- Don't forget all externally driven line states when the DDR changes
- Return proper port values when line states are pushed instead of pulled
This commit is contained in:
arbee 2017-01-11 21:38:29 -05:00
parent 7c85d0abcf
commit 9d6025015e
3 changed files with 59 additions and 7 deletions

View File

@ -137,9 +137,9 @@ void pit68230_device::device_start ()
// resolve callbacks
m_pa_out_cb.resolve_safe();
m_pa_in_cb.resolve_safe(0);
m_pa_in_cb.resolve();
m_pb_out_cb.resolve_safe();
m_pb_in_cb.resolve_safe(0);
m_pb_in_cb.resolve();
m_pc_out_cb.resolve_safe();
m_pc_in_cb.resolve(); // A temporary way to check if handler is installed with isnull(). TODO: Need better fix.
m_h1_out_cb.resolve_safe();
@ -292,9 +292,15 @@ void pit68230_device::pa_update_bit(uint8_t bit, uint8_t state)
return;
}
if (state)
{
m_padr |= (1 << bit);
m_pail |= (1 << bit);
}
else
{
m_padr &= ~(1 << bit);
m_pail &= ~(1 << bit);
}
}
void pit68230_device::pb_update_bit(uint8_t bit, uint8_t state)
@ -307,9 +313,15 @@ void pit68230_device::pb_update_bit(uint8_t bit, uint8_t state)
return;
}
if (state)
{
m_pbdr |= (1 << bit);
m_pbil |= (1 << bit);
}
else
{
m_pbdr &= ~(1 << bit);
m_pbil &= ~(1 << bit);
}
}
// TODO: Make sure port C is in the right alternate mode
@ -323,9 +335,15 @@ void pit68230_device::pc_update_bit(uint8_t bit, uint8_t state)
return;
}
if (state)
{
m_pcdr |= (1 << bit);
m_pcil |= (1 << bit);
}
else
{
m_pcdr &= ~(1 << bit);
m_pcil &= ~(1 << bit);
}
}
void pit68230_device::update_tin(uint8_t state)
@ -772,7 +790,14 @@ uint8_t pit68230_device::rr_pitreg_pbcr()
uint8_t pit68230_device::rr_pitreg_padr()
{
m_padr &= m_paddr;
m_padr |= (m_pa_in_cb() & ~m_paddr);
if (!m_pa_in_cb.isnull())
{
m_padr |= (m_pa_in_cb() & ~m_paddr);
}
else
{
m_padr |= (m_pail & ~m_paddr);
}
LOGDR(("%s %s <- %02x\n",tag(), FUNCNAME, m_padr));
return m_padr;
}
@ -787,19 +812,31 @@ uint8_t pit68230_device::rr_pitreg_padr()
uint8_t pit68230_device::rr_pitreg_pbdr()
{
m_pbdr &= m_pbddr;
m_pbdr |= (m_pb_in_cb() & ~m_pbddr);
if (!m_pb_in_cb.isnull())
{
m_pbdr |= (m_pb_in_cb() & ~m_pbddr);
}
else
{
m_pbdr |= (m_pbil & ~m_pbddr);
}
LOGDR(("%s %s <- %02x\n",tag(), FUNCNAME, m_pbdr));
//LOGDR(("%s %s <- %02x\n",tag(), FUNCNAME, m_pbdr));
return m_pbdr;
}
uint8_t pit68230_device::rr_pitreg_pcdr()
{
m_pcdr &= m_pcddr;
if (!m_pc_in_cb.isnull()) // Port C has alternate functions that may set bits apart from callback
{
m_pcdr &= m_pcddr;
m_pcdr |= (m_pc_in_cb() & ~m_pcddr);
}
else
{
m_pcdr |= (m_pcil & ~m_pcddr);
}
if (m_pcdr != 0) { LOGDR(("%s %s <- %02x\n",tag(), FUNCNAME, m_pcdr)); }
return m_pcdr;
}

View File

@ -332,6 +332,9 @@ protected:
uint8_t m_padr; // Port A Data register
uint8_t m_pbdr; // Port B Data register
uint8_t m_pcdr; // Port C Data register
uint8_t m_pail; // Port A input lines
uint8_t m_pbil; // Port B input lines
uint8_t m_pcil; // Port C input lines
uint8_t m_psr; // Port Status Register
uint8_t m_tcr; // Timer Control Register
uint8_t m_tivr; // Timer Interrupt Vector register

View File

@ -55,9 +55,15 @@ public:
DECLARE_WRITE_LINE_MEMBER(h4_w);
DECLARE_WRITE8_MEMBER(portb_w);
DECLARE_WRITE8_MEMBER(portc_w);
DECLARE_WRITE_LINE_MEMBER(timerirq_w)
{
m_maincpu->set_input_line(M68K_IRQ_4, state);
}
private:
u8 m_tin;
u8 m_h4;
};
void micro20_state::machine_start()
@ -80,13 +86,18 @@ void micro20_state::machine_reset()
TIMER_DEVICE_CALLBACK_MEMBER(micro20_state::micro20_timer)
{
m_pit->update_tin(m_tin);
m_pit->update_tin(m_tin ? ASSERT_LINE : CLEAR_LINE);
if ((!m_h4) && (m_tin))
{
m_maincpu->set_input_line(M68K_IRQ_6, HOLD_LINE);
}
m_tin ^= 1;
}
WRITE_LINE_MEMBER(micro20_state::h4_w)
{
printf("h4_w: %d\n", state);
m_h4 = state ^ 1;
}
WRITE_LINE_MEMBER(micro20_state::m68k_reset_callback)
@ -155,6 +166,7 @@ static MACHINE_CONFIG_START( micro20, micro20_state )
MCFG_WD1772_ADD(FDC_TAG, XTAL_16_67MHz / 2)
MCFG_DEVICE_ADD(PIT_TAG, PIT68230, XTAL_16_67MHz / 2)
MCFG_PIT68230_TIMER_IRQ_CB(WRITELINE(micro20_state, timerirq_w))
MCFG_PIT68230_H4_CB(WRITELINE(micro20_state, h4_w))
MCFG_PIT68230_PB_OUTPUT_CB(WRITE8(micro20_state, portb_w))
MCFG_PIT68230_PC_OUTPUT_CB(WRITE8(micro20_state, portc_w))