(MESS) pokemini.c: Cleanups (nw)

This commit is contained in:
Wilbert Pol 2013-01-26 12:27:52 +00:00
parent 8f7c390e90
commit d60c12e84f
2 changed files with 116 additions and 108 deletions

View File

@ -48,10 +48,13 @@ class pokemini_state : public driver_device
{
public:
pokemini_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu")
,
m_p_ram(*this, "p_ram"){ }
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_p_ram(*this, "p_ram")
, m_speaker(*this, SPEAKER_TAG)
, m_i2cmem(*this, "i2cmem")
, m_inputs(*this, "INPUTS")
{ }
required_device<cpu_device> m_maincpu;
required_shared_ptr<UINT8> m_p_ram;
@ -75,6 +78,14 @@ public:
TIMER_CALLBACK_MEMBER(pokemini_prc_counter_callback);
DECLARE_WRITE8_MEMBER(pokemini_hwreg_w);
DECLARE_READ8_MEMBER(pokemini_hwreg_r);
protected:
required_device<speaker_sound_device> m_speaker;
required_device<i2cmem_device> m_i2cmem;
required_ioport m_inputs;
void pokemini_check_irqs();
void pokemini_update_sound();
};

View File

@ -10,135 +10,134 @@
#include "includes/pokemini.h"
static void pokemini_check_irqs( running_machine &machine )
void pokemini_state::pokemini_check_irqs()
{
pokemini_state *state = machine.driver_data<pokemini_state>();
int irq_set[4] = { 1, 0, 0, 0 };
int prio, vector;
/* Check IRQ $03-$04 */
prio = ( state->m_pm_reg[0x20] >> 6 ) & 0x03;
prio = ( m_pm_reg[0x20] >> 6 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x40 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x40 )
irq_set[prio] = 0x04;
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x80 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x80 )
irq_set[prio] = 0x03;
}
/* Check IRQ $05-$06 */
prio = ( state->m_pm_reg[0x20] >> 4 ) & 0x03;
prio = ( m_pm_reg[0x20] >> 4 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x10 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x10 )
irq_set[prio] = 0x06;
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x20 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x20 )
irq_set[prio] = 0x05;
}
/* Check IRQ $07-$08 */
prio = ( state->m_pm_reg[0x20] >> 2 ) & 0x03;
prio = ( m_pm_reg[0x20] >> 2 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x04 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x04 )
irq_set[prio] = 0x08;
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x08 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x08 )
irq_set[prio] = 0x07;
}
/* Check IRQ $09-$0A */
prio = ( state->m_pm_reg[0x20] >> 0 ) & 0x03;
prio = ( m_pm_reg[0x20] >> 0 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x01 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x01 )
irq_set[prio] = 0x0A;
if ( state->m_pm_reg[0x23] & state->m_pm_reg[0x27] & 0x02 )
if ( m_pm_reg[0x23] & m_pm_reg[0x27] & 0x02 )
irq_set[prio] = 0x09;
}
/* Check IRQ $0B-$0E */
prio = ( state->m_pm_reg[0x21] >> 6 ) & 0x03;
prio = ( m_pm_reg[0x21] >> 6 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x04 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x04 )
irq_set[prio] = 0x0E;
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x08 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x08 )
irq_set[prio] = 0x0D;
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x10 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x10 )
irq_set[prio] = 0x0C;
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x20 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x20 )
irq_set[prio] = 0x0B;
}
/* Check IRQ $0F-$10 */
prio = ( state->m_pm_reg[0x22] >> 0 ) & 0x03;
prio = ( m_pm_reg[0x22] >> 0 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x40 )
if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x40 )
irq_set[prio] = 0x10;
if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x80 )
if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x80 )
irq_set[prio] = 0x0F;
}
/* Check IRQ $13-$14 */
prio = ( state->m_pm_reg[0x21] >> 4 ) & 0x03;
prio = ( m_pm_reg[0x21] >> 4 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x01 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x01 )
irq_set[prio] = 0x14;
if ( state->m_pm_reg[0x24] & state->m_pm_reg[0x28] & 0x02 )
if ( m_pm_reg[0x24] & m_pm_reg[0x28] & 0x02 )
irq_set[prio] = 0x13;
}
/* Check IRQ $15-$1C */
prio = ( state->m_pm_reg[0x21] >> 2 ) & 0x03;
prio = ( m_pm_reg[0x21] >> 2 ) & 0x03;
if ( ! irq_set[prio] )
{
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x01 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x01 )
irq_set[prio] = 0x1C;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x02 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x02 )
irq_set[prio] = 0x1B;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x04 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x04 )
irq_set[prio] = 0x1A;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x08 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x08 )
irq_set[prio] = 0x19;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x10 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x10 )
irq_set[prio] = 0x18;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x20 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x20 )
irq_set[prio] = 0x17;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x40 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x40 )
irq_set[prio] = 0x16;
if ( state->m_pm_reg[0x25] & state->m_pm_reg[0x29] & 0x80 )
if ( m_pm_reg[0x25] & m_pm_reg[0x29] & 0x80 )
irq_set[prio] = 0x15;
}
/* Check IRQ $1D-$1F */
prio = ( state->m_pm_reg[0x21] >> 0 ) & 0x03;
if ( ! irq_set[prio] && ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x07 ) )
prio = ( m_pm_reg[0x21] >> 0 ) & 0x03;
if ( ! irq_set[prio] && ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x07 ) )
{
if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x01 )
if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x01 )
irq_set[prio] = 0x1F;
if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x02 )
if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x02 )
irq_set[prio] = 0x1E;
if ( state->m_pm_reg[0x26] & state->m_pm_reg[0x2A] & 0x04 )
if ( m_pm_reg[0x26] & m_pm_reg[0x2A] & 0x04 )
irq_set[prio] = 0x1D;
}
@ -155,36 +154,34 @@ static void pokemini_check_irqs( running_machine &machine )
{
//logerror("Triggering IRQ with vector %02x\n", vector );
/* Trigger interrupt and set vector */
machine.device("maincpu")->execute().set_input_line_and_vector(0, ASSERT_LINE, vector );
m_maincpu->set_input_line_and_vector(0, ASSERT_LINE, vector );
}
else
{
machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE );
m_maincpu->set_input_line(0, CLEAR_LINE );
}
}
static void pokemini_update_sound( running_machine &machine )
void pokemini_state::pokemini_update_sound()
{
pokemini_state *state = machine.driver_data<pokemini_state>();
device_t *speaker = machine.device(SPEAKER_TAG);
/* Check if sound should be muted */
if ( state->m_pm_reg[0x70] & 0x03 )
if ( m_pm_reg[0x70] & 0x03 )
{
speaker_level_w( speaker, 0 );
speaker_level_w( m_speaker, 0 );
}
else
{
///static const int levels[4] = { 0, 1, 1, 2 };
int level; /// silence clang warning/// = levels[ state->m_pm_reg[0x71] & 0x03 ];
int level; /// silence clang warning/// = levels[ m_pm_reg[0x71] & 0x03 ];
// if ( ( ( state->m_pm_reg[0x48] & 0x80 ) && ( state->m_pm_reg[0x4E] | ( state->m_pm_reg[0x4F] << 8 ) ) > ( state->m_pm_reg[0x4C] | ( state->m_pm_reg[0x4D] << 8 ) ) )
// || ( ( state->m_pm_reg[0x48] & 0x80 ) && state->m_pm_reg[0x4F] > state->m_pm_reg[0x4D] ) )
// if ( ( ( m_pm_reg[0x48] & 0x80 ) && ( m_pm_reg[0x4E] | ( m_pm_reg[0x4F] << 8 ) ) > ( m_pm_reg[0x4C] | ( m_pm_reg[0x4D] << 8 ) ) )
// || ( ( m_pm_reg[0x48] & 0x80 ) && m_pm_reg[0x4F] > m_pm_reg[0x4D] ) )
// {
level = 0;
// }
speaker_level_w( speaker, level );
speaker_level_w( m_speaker, level );
}
}
@ -234,7 +231,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_256hz_timer_callback)
}
}
pokemini_check_irqs( machine() );
pokemini_check_irqs();
}
}
}
@ -253,7 +250,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_callback)
if ( m_pm_reg[0x37] == 0xFF )
{
m_pm_reg[0x27] |= 0x08;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x36] = m_pm_reg[0x32];
m_pm_reg[0x37] = m_pm_reg[0x33];
}
@ -261,7 +258,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_callback)
else
{
m_pm_reg[0x27] |= 0x04;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x36] = m_pm_reg[0x32];
}
}
@ -275,7 +272,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer1_hi_callback)
if ( m_pm_reg[0x37] == 0xFF )
{
m_pm_reg[0x27] |= 0x08;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x37] = m_pm_reg[0x33];
}
}
@ -294,7 +291,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_callback)
if ( m_pm_reg[0x3F] == 0xFF )
{
m_pm_reg[0x27] |= 0x20;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x3E] = m_pm_reg[0x3A];
m_pm_reg[0x3F] = m_pm_reg[0x3B];
}
@ -302,7 +299,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_callback)
else
{
m_pm_reg[0x27] |= 0x10;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x3E] = m_pm_reg[0x3A];
}
}
@ -316,7 +313,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer2_hi_callback)
if ( m_pm_reg[0x3F] == 0xFF )
{
m_pm_reg[0x27] |= 0x20;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x3F] = m_pm_reg[0x3B];
}
}
@ -335,7 +332,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_callback)
if ( m_pm_reg[0x4F] == 0xFF )
{
m_pm_reg[0x27] |= 0x02;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x4E] = m_pm_reg[0x4A];
m_pm_reg[0x4F] = m_pm_reg[0x4B];
}
@ -351,9 +348,9 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_callback)
if ( ( m_pm_reg[0x4E] == m_pm_reg[0x4C] ) && ( m_pm_reg[0x4F] == m_pm_reg[0x4D] ) )
{
m_pm_reg[0x27] |= 0x01;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
}
pokemini_update_sound( machine() );
pokemini_update_sound();
}
}
@ -365,7 +362,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_hi_callback)
if ( m_pm_reg[0x4F] == 0xFF )
{
m_pm_reg[0x27] |= 0x02;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
m_pm_reg[0x4F] = m_pm_reg[0x4B];
}
@ -374,9 +371,9 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_timer3_hi_callback)
if( m_pm_reg[0x4F] == m_pm_reg[0x4D] )
{
m_pm_reg[0x27] |= 0x01;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
}
pokemini_update_sound( machine() );
pokemini_update_sound();
}
}
@ -454,7 +451,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = data & 0x07;
int cycles = ( m_pm_reg[0x19] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer1->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer1->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check for prescaler change for the high counter */
@ -463,7 +460,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( data >> 4 ) & 0x07;
int cycles = ( m_pm_reg[0x19] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer1_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer1_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check if timer1 low should be enabled */
@ -504,7 +501,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = m_pm_reg[0x18] & 0x07;
int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer1->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer1->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check for prescaler change for the low counter */
@ -513,7 +510,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( m_pm_reg[0x18] >> 4 ) & 0x07;
int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer1_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer1_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
{
@ -583,7 +580,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = data & 0x07;
int cycles = ( m_pm_reg[0x1B] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer2->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer2->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check for prescaler change for the high counter */
@ -592,7 +589,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( data >> 4 ) & 0x07;
int cycles = ( m_pm_reg[0x1B] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer2_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer2_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check if timer2 low should be enabled */
@ -629,7 +626,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = m_pm_reg[0x1A] & 0x07;
int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer2->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer2->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
if ( ( m_pm_reg[0x1A] & 0x08 ) && ( m_pm_reg[0x38] & 0x04 ) &&
( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) ||
@ -649,7 +646,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( m_pm_reg[0x1A] >> 4 ) & 0x07;
int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer2_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer2_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
if ( ( m_pm_reg[0x1A] & 0x80 ) && ( m_pm_reg[0x39] & 0x04 ) && ! ( m_pm_reg[0x38] & 0x80 ) &&
( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) ||
@ -683,7 +680,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = data & 0x07;
int cycles = ( m_pm_reg[0x1D] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer3->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer3->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check for prescaler change for the high counter */
@ -692,7 +689,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( data >> 4 ) & 0x07;
int cycles = ( m_pm_reg[0x1D] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer3_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer3_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
}
/* Check if timer2 low should be enabled */
@ -729,7 +726,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = m_pm_reg[0x1C] & 0x07;
int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer3->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer3->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
if ( ( m_pm_reg[0x1C] & 0x08 ) && ( m_pm_reg[0x48] & 0x04 ) &&
( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) ||
@ -749,7 +746,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
int index = ( m_pm_reg[0x1C] >> 4 ) & 0x07;
int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index];
m_timers.timer3_hi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(cycles));
m_timers.timer3_hi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(cycles));
if ( ( m_pm_reg[0x1C] & 0x80 ) && ( m_pm_reg[0x49] & 0x04 ) && ! ( m_pm_reg[0x48] & 0x80 ) &&
( ( ( m_pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) ||
@ -770,7 +767,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 6-7 R/W VDraw/VBlank trigger Interrupt #1-#2
*/
m_pm_reg[0x20] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x21: /* Event #15-#22 priority
Bit 0-1 R/W Unknown
@ -778,14 +775,14 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 4-7 R/W Unknown
*/
m_pm_reg[0x21] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x22: /* Event #9-#14 priority
Bit 0-1 R/W All #9 - #14 events - Interrupt #9-#14
Bit 2-7 Unused
*/
m_pm_reg[0x22] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x23: /* Event #1-#8 enable
Bit 0 R/W Timer 3 overflow (mirror) - Enable Interrupt #8
@ -798,14 +795,14 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 R/W V-Blank trigger - Enable Interrupt #1
*/
m_pm_reg[0x23] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x24: /* Event #9-#12 enable
Bit 0-5 R/W Unknown
Bit 6-7 Unused
*/
m_pm_reg[0x24] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x25: /* Event #15-#22 enable
Bit 0 R/W Press key "A" event - Enable interrupt #22
@ -818,7 +815,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 R/W Press power button event - Enable interrupt #15
*/
m_pm_reg[0x25] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x26: /* Event #13-#14 enable
Bit 0-2 R/W Unknown
@ -828,7 +825,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 R/W IR receiver - low to high trigger - Enable interrupt #13
*/
m_pm_reg[0x26] = data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
break;
case 0x27: /* Interrupt active flag #1-#8
Bit 0 Timer 3 overflow (mirror) / Clear interrupt #8
@ -841,7 +838,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 VBlank trigger / Clear interrupt #1
*/
m_pm_reg[0x27] &= ~data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
return;
case 0x28: /* Interrupt active flag #9-#12
Bit 0-1 Unknown
@ -852,7 +849,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 6-7 Unknown
*/
m_pm_reg[0x28] &= ~data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
return;
case 0x29: /* Interrupt active flag #15-#22
Bit 0 Press key "A" event / Clear interrupt #22
@ -865,7 +862,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 Press power button event / Clear interrupt #15
*/
m_pm_reg[0x29] &= ~data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
return;
case 0x2A: /* Interrupt active flag #13-#14
Bit 0-5 Unknown
@ -873,7 +870,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 Unknown / Clear interrupt #13
*/
m_pm_reg[0x2A] &= ~data;
pokemini_check_irqs(machine());
pokemini_check_irqs();
return;
case 0x30: /* Timer 1 control 1
Bit 0 R/W Unknown
@ -947,7 +944,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
*/
case 0x35: /* Timer 1 sound-pivot (high, unused)
*/
logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", machine().firstcpu->pc( ), offset, data );
logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", m_maincpu->pc(), offset, data );
break;
case 0x36: /* Timer 1 counter (low), read only
*/
@ -1026,7 +1023,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
*/
case 0x3D: /* Timer 2 sound-pivot (high, unused)
*/
logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", machine().firstcpu->pc( ), offset, data );
logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", m_maincpu->pc(), offset, data );
break;
case 0x3E: /* Timer 2 counter (low), read only
Bit 0-7 R/W Timer 2 counter value bit 0-7
@ -1086,7 +1083,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
m_timers.timer3_hi->enable( 0 );
}
m_pm_reg[0x48] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x49: /* Timer 3 control 2
Bit 0 R/W Unknown
@ -1112,25 +1109,25 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
m_timers.timer3_hi->enable( 0 );
}
m_pm_reg[0x49] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x4A: /* Timer 3 preset value (low)
Bit 0-7 R/W Timer 3 preset value bit 0-7
*/
m_pm_reg[0x4A] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x4B: /* Timer 3 preset value (high)
Bit 0-7 R/W Timer 3 preset value bit 8-15
*/
m_pm_reg[0x4B] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x4C: /* Timer 3 sound-pivot (low)
Bit 0-7 R/W Timer 3 sound-pivot value bit 0-7
*/
m_pm_reg[0x4C] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x4D: /* Timer 3 sound-pivot (high)
Bit 0-7 R/W Timer 3 sound-pivot value bit 8-15
@ -1141,7 +1138,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Pulse-Width of 100% = Same as preset-value
*/
m_pm_reg[0x4D] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x4E: /* Timer 3 counter (low), read only
Bit 0-7 R/W Timer 3 counter value bit 0-7
@ -1184,14 +1181,14 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 7 R/W IR received bit (mirror, if device not selected: 0)
*/
if ( m_pm_reg[0x60] & 0x04 )
i2cmem_sda_write(machine().device("i2cmem"), ( data & 0x04 ) ? 1 : 0 );
m_i2cmem->set_sda_line( ( data & 0x04 ) ? 1 : 0 );
if ( m_pm_reg[0x60] & 0x08 )
i2cmem_scl_write(machine().device("i2cmem"), ( data & 0x08 ) ? 1 : 0 );
m_i2cmem->set_scl_line( ( data & 0x08 ) ? 1 : 0 );
break;
case 0x70: /* Sound related */
m_pm_reg[0x70] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x71: /* Sound volume
Bit 0-1 R/W Sound volume
@ -1203,7 +1200,7 @@ WRITE8_MEMBER(pokemini_state::pokemini_hwreg_w)
Bit 3-7 Unused
*/
m_pm_reg[0x71] = data;
pokemini_update_sound(machine());
pokemini_update_sound();
break;
case 0x80: /* LCD control
Bit 0 R/W Invert colors; 0 - normal, 1 - inverted
@ -1344,11 +1341,11 @@ READ8_MEMBER(pokemini_state::pokemini_hwreg_r)
switch( offset )
{
case 0x52: return ioport("INPUTS")->read();
case 0x52: return m_inputs->read();
case 0x61:
if ( ! ( m_pm_reg[0x60] & 0x04 ) )
{
data = ( data & ~ 0x04 ) | ( i2cmem_sda_read( machine().device("i2cmem")) ? 0x04 : 0x00 );
data = ( data & ~ 0x04 ) | ( m_i2cmem->read_sda_line() ? 0x04 : 0x00 );
}
if ( ! ( m_pm_reg[0x60] & 0x08 ) )
@ -1405,7 +1402,7 @@ DEVICE_IMAGE_LOAD( pokemini_cart )
TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback)
{
address_space &space = machine().device( "maincpu")->memory().space( AS_PROGRAM );
address_space &space = m_maincpu->space( AS_PROGRAM );
m_prc.count++;
/* Check for overflow */
@ -1511,7 +1508,7 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback)
/* Set PRC Render interrupt */
m_pm_reg[0x27] |= 0x40;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
/* Check if the rendered data should be copied to the LCD */
if ( m_prc.copy_enabled )
@ -1535,12 +1532,12 @@ TIMER_CALLBACK_MEMBER(pokemini_state::pokemini_prc_counter_callback)
/* Set PRC Copy interrupt */
m_pm_reg[0x27] |= 0x80;
pokemini_check_irqs( machine() );
pokemini_check_irqs();
}
}
/* Set possible input irqs */
m_pm_reg[0x29] |= ~ machine().root_device().ioport( "INPUTS" )->read();
m_pm_reg[0x29] |= ~ m_inputs->read();
}
}