midtunit.c, midwunit.c, midyunit.c: reduced tagmap lookups (nw)

This commit is contained in:
Osso 2015-01-08 18:41:40 +01:00
parent 50ea0b3706
commit 35642262d8
6 changed files with 397 additions and 375 deletions

View File

@ -14,25 +14,35 @@ public:
{
TIMER_DMA
};
midtunit_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_nvram(*this, "nvram"),
m_gfxrom(*this, "gfxrom"),
m_cvsd_sound(*this, "cvsd"),
m_adpcm_sound(*this, "adpcm") ,
m_maincpu(*this, "maincpu"),
m_palette(*this, "palette"),
m_dcs(*this, "dcs"),
m_generic_paletteram_16(*this, "paletteram") { }
required_shared_ptr<UINT16> m_nvram;
required_memory_region m_gfxrom;
optional_device<williams_cvsd_sound_device> m_cvsd_sound;
optional_device<williams_adpcm_sound_device> m_adpcm_sound;
DECLARE_WRITE16_MEMBER(midtunit_cmos_enable_w);
DECLARE_WRITE16_MEMBER(midtunit_cmos_w);
midtunit_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_palette(*this, "palette"),
m_dcs(*this, "dcs"),
m_cvsd_sound(*this, "cvsd"),
m_adpcm_sound(*this, "adpcm") ,
m_generic_paletteram_16(*this, "paletteram"),
m_nvram(*this, "nvram"),
m_gfxrom(*this, "gfxrom"),
m_ports(*this, tunit_ports) { }
required_device<cpu_device> m_maincpu;
required_device<palette_device> m_palette;
optional_device<dcs_audio_device> m_dcs;
optional_device<williams_cvsd_sound_device> m_cvsd_sound;
optional_device<williams_adpcm_sound_device> m_adpcm_sound;
required_shared_ptr<UINT16> m_generic_paletteram_16;
required_shared_ptr<UINT16> m_nvram;
required_memory_region m_gfxrom;
required_ioport_array<4> m_ports;
DECLARE_IOPORT_ARRAY(tunit_ports);
DECLARE_WRITE16_MEMBER(midtunit_cmos_enable_w);
DECLARE_WRITE16_MEMBER(midtunit_cmos_w);
DECLARE_READ16_MEMBER(midtunit_cmos_r);
DECLARE_READ16_MEMBER(midtunit_input_r);
DECLARE_READ16_MEMBER(midtunit_sound_state_r);
@ -63,50 +73,49 @@ public:
DECLARE_READ16_MEMBER(midwunit_control_r);
DECLARE_WRITE16_MEMBER(midtunit_paletteram_w);
DECLARE_WRITE16_MEMBER(midxunit_paletteram_w);
DECLARE_READ16_MEMBER(midxunit_paletteram_r);
DECLARE_READ16_MEMBER(midtunit_dma_r);
DECLARE_WRITE16_MEMBER(midtunit_dma_w);
TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update);
DECLARE_DRIVER_INIT(mktunit);
DECLARE_DRIVER_INIT(mkturbo);
DECLARE_DRIVER_INIT(nbajamte);
DECLARE_DRIVER_INIT(nbajam);
DECLARE_DRIVER_INIT(jdreddp);
DECLARE_DRIVER_INIT(mk2);
DECLARE_MACHINE_RESET(midtunit);
DECLARE_VIDEO_START(midtunit);
required_device<cpu_device> m_maincpu;
required_device<palette_device> m_palette;
optional_device<dcs_audio_device> m_dcs;
required_shared_ptr<UINT16> m_generic_paletteram_16;
void register_state_saving();
void init_tunit_generic(int sound);
void init_nbajam_common(int te_protection);
/* CMOS-related variables */
UINT8 cmos_write_enable;
/* sound-related variables */
UINT8 chip_type;
UINT8 fake_sound_state;
/* protection */
UINT8 mk_prot_index;
UINT16 mk2_prot_data;
const UINT32 *nbajam_prot_table;
UINT16 nbajam_prot_queue[5];
UINT8 nbajam_prot_index;
const UINT8 *jdredd_prot_table;
UINT8 jdredd_prot_index;
UINT8 jdredd_prot_max;
UINT8 m_gfx_rom_large;
DECLARE_READ16_MEMBER(midxunit_paletteram_r);
DECLARE_READ16_MEMBER(midtunit_dma_r);
DECLARE_WRITE16_MEMBER(midtunit_dma_w);
TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update);
DECLARE_DRIVER_INIT(mktunit);
DECLARE_DRIVER_INIT(mkturbo);
DECLARE_DRIVER_INIT(nbajamte);
DECLARE_DRIVER_INIT(nbajam);
DECLARE_DRIVER_INIT(jdreddp);
DECLARE_DRIVER_INIT(mk2);
DECLARE_MACHINE_RESET(midtunit);
DECLARE_VIDEO_START(midtunit);
void register_state_saving();
void init_tunit_generic(int sound);
void init_nbajam_common(int te_protection);
/* CMOS-related variables */
UINT8 m_cmos_write_enable;
/* sound-related variables */
UINT8 m_chip_type;
UINT8 m_fake_sound_state;
/* protection */
UINT8 m_mk_prot_index;
UINT16 m_mk2_prot_data;
const UINT32 *m_nbajam_prot_table;
UINT16 m_nbajam_prot_queue[5];
UINT8 m_nbajam_prot_index;
const UINT8 *m_jdredd_prot_table;
UINT8 m_jdredd_prot_index;
UINT8 m_jdredd_prot_max;
UINT8 m_gfx_rom_large;
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
};

View File

@ -10,44 +10,54 @@
class midwunit_state : public midtunit_state
{
public:
midwunit_state(const machine_config &mconfig, device_type type, const char *tag)
: midtunit_state(mconfig, type, tag),
m_nvram(*this, "nvram"),
m_midway_serial_pic(*this, "serial_pic") { }
required_shared_ptr<UINT16> m_nvram;
required_device<midway_serial_pic_device> m_midway_serial_pic;
UINT8 m_cmos_write_enable;
UINT16 m_iodata[8];
UINT8 m_ioshuffle[16];
UINT8 m_uart[8];
UINT8 m_security_bits;
UINT16 *m_umk3_palette;
DECLARE_WRITE16_MEMBER(midwunit_cmos_enable_w);
DECLARE_WRITE16_MEMBER(midwunit_cmos_w);
DECLARE_READ16_MEMBER(midwunit_cmos_r);
public:
midwunit_state(const machine_config &mconfig, device_type type, const char *tag)
: midtunit_state(mconfig, type, tag),
m_midway_serial_pic(*this, "serial_pic"),
m_nvram(*this, "nvram"),
m_ports(*this, wunit_ports)
{ }
required_device<midway_serial_pic_device> m_midway_serial_pic;
required_shared_ptr<UINT16> m_nvram;
required_ioport_array<4> m_ports;
DECLARE_IOPORT_ARRAY(wunit_ports);
UINT8 m_cmos_write_enable;
UINT16 m_iodata[8];
UINT8 m_ioshuffle[16];
UINT8 m_uart[8];
UINT8 m_security_bits;
UINT16 *m_umk3_palette;
DECLARE_WRITE16_MEMBER(midwunit_cmos_enable_w);
DECLARE_WRITE16_MEMBER(midwunit_cmos_w);
DECLARE_READ16_MEMBER(midwunit_cmos_r);
DECLARE_WRITE16_MEMBER(midwunit_io_w);
DECLARE_READ16_MEMBER(midwunit_io_r);
DECLARE_READ16_MEMBER(midwunit_security_r);
DECLARE_WRITE16_MEMBER(midwunit_security_w);
DECLARE_READ16_MEMBER(midwunit_sound_r);
DECLARE_READ16_MEMBER(midwunit_sound_state_r);
DECLARE_WRITE16_MEMBER(midwunit_sound_w);
DECLARE_WRITE16_MEMBER(umk3_palette_hack_w);
DECLARE_WRITE16_MEMBER(wwfmania_io_0_w);
DECLARE_DRIVER_INIT(mk3r10);
DECLARE_DRIVER_INIT(nbahangt);
DECLARE_DRIVER_INIT(wwfmania);
DECLARE_WRITE16_MEMBER(midwunit_sound_w);
DECLARE_WRITE16_MEMBER(umk3_palette_hack_w);
DECLARE_WRITE16_MEMBER(wwfmania_io_0_w);
DECLARE_DRIVER_INIT(mk3r10);
DECLARE_DRIVER_INIT(nbahangt);
DECLARE_DRIVER_INIT(wwfmania);
DECLARE_DRIVER_INIT(umk3);
DECLARE_DRIVER_INIT(mk3);
DECLARE_DRIVER_INIT(openice);
DECLARE_DRIVER_INIT(rmpgwt);
DECLARE_DRIVER_INIT(umk3r11);
DECLARE_DRIVER_INIT(mk3r20);
DECLARE_MACHINE_RESET(midwunit);
DECLARE_VIDEO_START(midwunit);
void register_state_saving();
void init_wunit_generic();
void init_mk3_common();
DECLARE_DRIVER_INIT(rmpgwt);
DECLARE_DRIVER_INIT(umk3r11);
DECLARE_DRIVER_INIT(mk3r20);
DECLARE_MACHINE_RESET(midwunit);
DECLARE_VIDEO_START(midwunit);
void register_state_saving();
void init_wunit_generic();
void init_mk3_common();
};

View File

@ -45,24 +45,29 @@ public:
m_oki(*this, "oki"),
m_palette(*this, "palette"),
m_narc_sound(*this, "narcsnd"),
m_cvsd_sound(*this, "cvsd"),
m_adpcm_sound(*this, "adpcm"),
m_generic_paletteram_16(*this, "paletteram"),
m_gfx_rom(*this, "gfx_rom", 16) { }
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
m_cvsd_sound(*this, "cvsd"),
m_adpcm_sound(*this, "adpcm"),
m_generic_paletteram_16(*this, "paletteram"),
m_gfx_rom(*this, "gfx_rom", 16),
m_ports(*this, ports) { }
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
optional_device<okim6295_device> m_oki;
required_device<palette_device> m_palette;
optional_device<williams_narc_sound_device> m_narc_sound;
optional_device<williams_cvsd_sound_device> m_cvsd_sound;
optional_device<williams_adpcm_sound_device> m_adpcm_sound;
required_shared_ptr<UINT16> m_generic_paletteram_16;
optional_shared_ptr<UINT8> m_gfx_rom;
UINT16 *m_cmos_ram;
UINT32 m_cmos_page;
required_shared_ptr<UINT16> m_generic_paletteram_16;
optional_shared_ptr<UINT8> m_gfx_rom;
optional_ioport_array<6> m_ports;
DECLARE_IOPORT_ARRAY(ports);
UINT16 *m_cmos_ram;
UINT32 m_cmos_page;
UINT16 m_prot_result;
UINT16 m_prot_sequence[3];
UINT8 m_prot_index;

View File

@ -25,42 +25,42 @@
* State saving
*
*************************************/
void midtunit_state::register_state_saving()
{
save_item(NAME(cmos_write_enable));
save_item(NAME(fake_sound_state));
save_item(NAME(mk_prot_index));
save_item(NAME(mk2_prot_data));
save_item(NAME(nbajam_prot_queue));
save_item(NAME(nbajam_prot_index));
save_item(NAME(jdredd_prot_index));
save_item(NAME(jdredd_prot_max));
}
void midtunit_state::register_state_saving()
{
save_item(NAME(m_cmos_write_enable));
save_item(NAME(m_fake_sound_state));
save_item(NAME(m_mk_prot_index));
save_item(NAME(m_mk2_prot_data));
save_item(NAME(m_nbajam_prot_queue));
save_item(NAME(m_nbajam_prot_index));
save_item(NAME(m_jdredd_prot_index));
save_item(NAME(m_jdredd_prot_max));
}
/*************************************
*
* CMOS reads/writes
*
*************************************/
WRITE16_MEMBER(midtunit_state::midtunit_cmos_enable_w)
{
cmos_write_enable = 1;
}
WRITE16_MEMBER(midtunit_state::midtunit_cmos_w)
{
if (1)/*cmos_write_enable)*/
{
COMBINE_DATA(m_nvram+offset);
cmos_write_enable = 0;
}
else
{
WRITE16_MEMBER(midtunit_state::midtunit_cmos_enable_w)
{
m_cmos_write_enable = 1;
}
WRITE16_MEMBER(midtunit_state::midtunit_cmos_w)
{
if (1)/*m_cmos_write_enable*/
{
COMBINE_DATA(m_nvram+offset);
m_cmos_write_enable = 0;
}
else
{
logerror("%08X:Unexpected CMOS W @ %05X\n", space.device().safe_pc(), offset);
popmessage("Bad CMOS write");
}
@ -76,18 +76,18 @@ READ16_MEMBER(midtunit_state::midtunit_cmos_r)
/*************************************
*
* Generic input ports
*
*************************************/
READ16_MEMBER(midtunit_state::midtunit_input_r)
{
static const char *const portnames[] = { "IN0", "IN1", "IN2", "DSW" };
return ioport(portnames[offset])->read();
}
* Generic input ports
*
*************************************/
IOPORT_ARRAY_MEMBER(midtunit_state::tunit_ports) { "IN0", "IN1", "IN2", "DSW" };
READ16_MEMBER(midtunit_state::midtunit_input_r)
{
return m_ports[offset]->read();
}
/*************************************
*
@ -106,22 +106,22 @@ static const UINT8 mk_prot_values[] =
0x16, 0x2d, 0x1a, 0x34, 0x28, 0x10, 0x21, 0x03,
0xff
};
READ16_MEMBER(midtunit_state::mk_prot_r)
{
logerror("%08X:Protection R @ %05X = %04X\n", space.device().safe_pc(), offset, mk_prot_values[mk_prot_index] << 9);
/* just in case */
if (mk_prot_index >= sizeof(mk_prot_values))
{
logerror("%08X:Unexpected protection R @ %05X\n", space.device().safe_pc(), offset);
mk_prot_index = 0;
}
return mk_prot_values[mk_prot_index++] << 9;
}
WRITE16_MEMBER(midtunit_state::mk_prot_w)
READ16_MEMBER(midtunit_state::mk_prot_r)
{
logerror("%08X:Protection R @ %05X = %04X\n", space.device().safe_pc(), offset, mk_prot_values[m_mk_prot_index] << 9);
/* just in case */
if (m_mk_prot_index >= sizeof(mk_prot_values))
{
logerror("%08X:Unexpected protection R @ %05X\n", space.device().safe_pc(), offset);
m_mk_prot_index = 0;
}
return mk_prot_values[m_mk_prot_index++] << 9;
}
WRITE16_MEMBER(midtunit_state::mk_prot_w)
{
if (ACCESSING_BITS_8_15)
{
@ -129,21 +129,21 @@ WRITE16_MEMBER(midtunit_state::mk_prot_w)
int i;
/* find the desired first value and stop then */
for (i = 0; i < sizeof(mk_prot_values); i++)
if (mk_prot_values[i] == first_val)
{
mk_prot_index = i;
break;
}
for (i = 0; i < sizeof(mk_prot_values); i++)
if (mk_prot_values[i] == first_val)
{
m_mk_prot_index = i;
break;
}
/* just in case */
if (i == sizeof(mk_prot_values))
{
logerror("%08X:Unhandled protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
mk_prot_index = 0;
}
logerror("%08X:Protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
if (i == sizeof(mk_prot_values))
{
logerror("%08X:Unhandled protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
m_mk_prot_index = 0;
}
logerror("%08X:Protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
}
}
@ -174,23 +174,23 @@ READ16_MEMBER(midtunit_state::mk2_prot_const_r)
{
return 2;
}
READ16_MEMBER(midtunit_state::mk2_prot_r)
{
return mk2_prot_data;
}
READ16_MEMBER(midtunit_state::mk2_prot_shift_r)
{
return mk2_prot_data >> 1;
}
WRITE16_MEMBER(midtunit_state::mk2_prot_w)
{
COMBINE_DATA(&mk2_prot_data);
}
READ16_MEMBER(midtunit_state::mk2_prot_r)
{
return m_mk2_prot_data;
}
READ16_MEMBER(midtunit_state::mk2_prot_shift_r)
{
return m_mk2_prot_data >> 1;
}
WRITE16_MEMBER(midtunit_state::mk2_prot_w)
{
COMBINE_DATA(&m_mk2_prot_data);
}
/*************************************
*
@ -237,29 +237,29 @@ static const UINT32 nbajamte_prot_values[128] =
0x30180c26, 0x31381c0e, 0x32393c3e, 0x33192c16, 0x343a3d1e, 0x351a2d36, 0x361b0d06, 0x373b1d2e,
0x381c2e17, 0x393c3e3f, 0x3a3d1e0f, 0x3b1d0e27, 0x3c3e1f2f, 0x3d1e0f07, 0x3e1f2f37, 0x3f3f3f1f
};
READ16_MEMBER(midtunit_state::nbajam_prot_r)
{
int result = nbajam_prot_queue[nbajam_prot_index];
if (nbajam_prot_index < 4)
nbajam_prot_index++;
return result;
}
WRITE16_MEMBER(midtunit_state::nbajam_prot_w)
{
int table_index = (offset >> 6) & 0x7f;
UINT32 protval = nbajam_prot_table[table_index];
nbajam_prot_queue[0] = data;
nbajam_prot_queue[1] = ((protval >> 24) & 0xff) << 9;
nbajam_prot_queue[2] = ((protval >> 16) & 0xff) << 9;
nbajam_prot_queue[3] = ((protval >> 8) & 0xff) << 9;
nbajam_prot_queue[4] = ((protval >> 0) & 0xff) << 9;
nbajam_prot_index = 0;
}
READ16_MEMBER(midtunit_state::nbajam_prot_r)
{
int result = m_nbajam_prot_queue[m_nbajam_prot_index];
if (m_nbajam_prot_index < 4)
m_nbajam_prot_index++;
return result;
}
WRITE16_MEMBER(midtunit_state::nbajam_prot_w)
{
int table_index = (offset >> 6) & 0x7f;
UINT32 protval = m_nbajam_prot_table[table_index];
m_nbajam_prot_queue[0] = data;
m_nbajam_prot_queue[1] = ((protval >> 24) & 0xff) << 9;
m_nbajam_prot_queue[2] = ((protval >> 16) & 0xff) << 9;
m_nbajam_prot_queue[3] = ((protval >> 8) & 0xff) << 9;
m_nbajam_prot_queue[4] = ((protval >> 0) & 0xff) << 9;
m_nbajam_prot_index = 0;
}
/*************************************
*
@ -313,54 +313,54 @@ WRITE16_MEMBER(midtunit_state::jdredd_prot_w)
{
logerror("%08X:jdredd_prot_w(%04X,%04X)\n", space.device().safe_pcbase(), offset*16, data);
switch (offset)
{
case TOWORD(0x10740):
jdredd_prot_index = 0;
jdredd_prot_table = jdredd_prot_values_10740;
jdredd_prot_max = sizeof(jdredd_prot_values_10740);
logerror("-- reset prot table 10740\n");
break;
case TOWORD(0x13240):
jdredd_prot_index = 0;
jdredd_prot_table = jdredd_prot_values_13240;
jdredd_prot_max = sizeof(jdredd_prot_values_13240);
logerror("-- reset prot table 13240\n");
break;
case TOWORD(0x76540):
jdredd_prot_index = 0;
jdredd_prot_table = jdredd_prot_values_76540;
jdredd_prot_max = sizeof(jdredd_prot_values_76540);
logerror("-- reset prot table 76540\n");
break;
case TOWORD(0x77760):
jdredd_prot_index = 0;
jdredd_prot_table = jdredd_prot_values_77760;
jdredd_prot_max = sizeof(jdredd_prot_values_77760);
logerror("-- reset prot table 77760\n");
break;
case TOWORD(0x80020):
jdredd_prot_index = 0;
jdredd_prot_table = jdredd_prot_values_80020;
jdredd_prot_max = sizeof(jdredd_prot_values_80020);
logerror("-- reset prot table 80020\n");
break;
}
switch (offset)
{
case TOWORD(0x10740):
m_jdredd_prot_index = 0;
m_jdredd_prot_table = jdredd_prot_values_10740;
m_jdredd_prot_max = sizeof(jdredd_prot_values_10740);
logerror("-- reset prot table 10740\n");
break;
case TOWORD(0x13240):
m_jdredd_prot_index = 0;
m_jdredd_prot_table = jdredd_prot_values_13240;
m_jdredd_prot_max = sizeof(jdredd_prot_values_13240);
logerror("-- reset prot table 13240\n");
break;
case TOWORD(0x76540):
m_jdredd_prot_index = 0;
m_jdredd_prot_table = jdredd_prot_values_76540;
m_jdredd_prot_max = sizeof(jdredd_prot_values_76540);
logerror("-- reset prot table 76540\n");
break;
case TOWORD(0x77760):
m_jdredd_prot_index = 0;
m_jdredd_prot_table = jdredd_prot_values_77760;
m_jdredd_prot_max = sizeof(jdredd_prot_values_77760);
logerror("-- reset prot table 77760\n");
break;
case TOWORD(0x80020):
m_jdredd_prot_index = 0;
m_jdredd_prot_table = jdredd_prot_values_80020;
m_jdredd_prot_max = sizeof(jdredd_prot_values_80020);
logerror("-- reset prot table 80020\n");
break;
}
}
READ16_MEMBER(midtunit_state::jdredd_prot_r)
{
UINT16 result = 0xffff;
if (jdredd_prot_table && jdredd_prot_index < jdredd_prot_max)
result = jdredd_prot_table[jdredd_prot_index++] << 9;
logerror("%08X:jdredd_prot_r(%04X) = %04X\n", space.device().safe_pcbase(), offset*16, result);
return result;
{
UINT16 result = 0xffff;
if (m_jdredd_prot_table && m_jdredd_prot_index < m_jdredd_prot_max)
result = m_jdredd_prot_table[m_jdredd_prot_index++] << 9;
logerror("%08X:jdredd_prot_r(%04X) = %04X\n", space.device().safe_pcbase(), offset*16, result);
return result;
}
@ -389,13 +389,13 @@ READ16_MEMBER(midtunit_state::jdredd_hack_r)
void midtunit_state::init_tunit_generic(int sound)
{
/* register for state saving */
register_state_saving();
/* load sound ROMs and set up sound handlers */
chip_type = sound;
/* default graphics functionality */
register_state_saving();
/* load sound ROMs and set up sound handlers */
m_chip_type = sound;
/* default graphics functionality */
m_gfx_rom_large = 0;
}
@ -434,18 +434,18 @@ void midtunit_state::init_nbajam_common(int te_protection)
{
/* common init */
init_tunit_generic(SOUND_ADPCM_LARGE);
/* protection */
if (!te_protection)
{
nbajam_prot_table = nbajam_prot_values;
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b14020, 0x1b2503f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
}
else
{
nbajam_prot_table = nbajamte_prot_values;
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b15f40, 0x1b37f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b95f40, 0x1bb7f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
}
/* protection */
if (!te_protection)
{
m_nbajam_prot_table = nbajam_prot_values;
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b14020, 0x1b2503f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
}
else
{
m_nbajam_prot_table = nbajamte_prot_values;
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b15f40, 0x1b37f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b95f40, 0x1bb7f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
}
/* sound chip protection (hidden RAM) */
if (!te_protection)
@ -520,13 +520,13 @@ DRIVER_INIT_MEMBER(midtunit_state,mk2)
*
*************************************/
MACHINE_RESET_MEMBER(midtunit_state,midtunit)
{
/* reset sound */
switch (chip_type)
{
case SOUND_ADPCM:
case SOUND_ADPCM_LARGE:
MACHINE_RESET_MEMBER(midtunit_state,midtunit)
{
/* reset sound */
switch (m_chip_type)
{
case SOUND_ADPCM:
case SOUND_ADPCM_LARGE:
m_adpcm_sound->reset_write(1);
m_adpcm_sound->reset_write(0);
break;
@ -547,28 +547,28 @@ MACHINE_RESET_MEMBER(midtunit_state,midtunit)
*************************************/
READ16_MEMBER(midtunit_state::midtunit_sound_state_r)
{
/* logerror("%08X:Sound status read\n", space.device().safe_pc());*/
if (chip_type == SOUND_DCS)
return m_dcs->control_r() >> 4;
if (fake_sound_state)
{
fake_sound_state--;
return 0;
}
return ~0;
{
/* logerror("%08X:Sound status read\n", space.device().safe_pc());*/
if (m_chip_type == SOUND_DCS)
return m_dcs->control_r() >> 4;
if (m_fake_sound_state)
{
m_fake_sound_state--;
return 0;
}
return ~0;
}
READ16_MEMBER(midtunit_state::midtunit_sound_r)
{
logerror("%08X:Sound data read\n", space.device().safe_pc());
if (chip_type == SOUND_DCS)
return m_dcs->data_r() & 0xff;
return ~0;
{
logerror("%08X:Sound data read\n", space.device().safe_pc());
if (m_chip_type == SOUND_DCS)
return m_dcs->data_r() & 0xff;
return ~0;
}
WRITE16_MEMBER(midtunit_state::midtunit_sound_w)
@ -579,26 +579,26 @@ WRITE16_MEMBER(midtunit_state::midtunit_sound_w)
logerror("%08X:Unexpected write to sound (lo) = %04X\n", space.device().safe_pc(), data);
return;
}
/* call through based on the sound type */
if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
switch (chip_type)
{
case SOUND_ADPCM:
case SOUND_ADPCM_LARGE:
/* call through based on the sound type */
if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
switch (m_chip_type)
{
case SOUND_ADPCM:
case SOUND_ADPCM_LARGE:
m_adpcm_sound->reset_write(~data & 0x100);
m_adpcm_sound->write(space, offset, data & 0xff);
/* the games seem to check for $82 loops, so this should be just barely enough */
fake_sound_state = 128;
break;
case SOUND_DCS:
m_adpcm_sound->write(space, offset, data & 0xff);
/* the games seem to check for $82 loops, so this should be just barely enough */
m_fake_sound_state = 128;
break;
case SOUND_DCS:
logerror("%08X:Sound write = %04X\n", space.device().safe_pc(), data);
m_dcs->reset_w(~data & 0x100);
m_dcs->data_w(data & 0xff);
/* the games seem to check for $82 loops, so this should be just barely enough */
fake_sound_state = 128;
break;
}
}
m_dcs->reset_w(~data & 0x100);
m_dcs->data_w(data & 0xff);
/* the games seem to check for $82 loops, so this should be just barely enough */
m_fake_sound_state = 128;
break;
}
}

View File

@ -110,26 +110,26 @@ WRITE16_MEMBER(midwunit_state::midwunit_io_w)
/*************************************
*
* General I/O reads
*
*************************************/
READ16_MEMBER(midwunit_state::midwunit_io_r)
{
static const char *const portnames[] = { "IN0", "IN1", "DSW", "IN2" };
/* apply I/O shuffling */
offset = m_ioshuffle[offset % 16];
*
*************************************/
IOPORT_ARRAY_MEMBER(midwunit_state::wunit_ports) { "IN0", "IN1", "DSW", "IN2" };
READ16_MEMBER(midwunit_state::midwunit_io_r)
{
/* apply I/O shuffling */
offset = m_ioshuffle[offset % 16];
switch (offset)
{
case 0:
case 1:
case 2:
case 3:
return ioport(portnames[offset])->read();
case 4:
return (m_midway_serial_pic->status_r(space,0) << 12) | midwunit_sound_state_r(space,0,0xffff);
case 1:
case 2:
case 3:
return m_ports[offset]->read();
case 4:
return (m_midway_serial_pic->status_r(space,0) << 12) | midwunit_sound_state_r(space,0,0xffff);
default:
logerror("%08X:Unknown I/O read from %d\n", space.device().safe_pc(), offset);

View File

@ -107,33 +107,31 @@ READ16_MEMBER(midyunit_state::midyunit_protection_r)
/*************************************
*
* Generic input ports
*
*************************************/
READ16_MEMBER(midyunit_state::midyunit_input_r)
{
static const char *const portnames[] = { "IN0", "IN1", "IN2", "DSW", "UNK0", "UNK1" };
return ioport(portnames[offset])->read();
}
*
*************************************/
IOPORT_ARRAY_MEMBER(midyunit_state::ports) { "IN0", "IN1", "IN2", "DSW", "UNK0", "UNK1" };
READ16_MEMBER(midyunit_state::midyunit_input_r)
{
return m_ports[offset]->read();
}
/*************************************
*
* Special Terminator 2 input ports
*
*************************************/
READ16_MEMBER(midyunit_state::term2_input_r)
{
static const char *const portnames[] = { "IN0", "IN1", NULL, "DSW", "UNK0", "UNK1" };
if (offset != 2)
return ioport(portnames[offset])->read();
switch (m_term2_analog_select)
{
READ16_MEMBER(midyunit_state::term2_input_r)
{
if (offset != 2)
return m_ports[offset]->read();
switch (m_term2_analog_select)
{
default:
case 0: return ioport("STICK0_X")->read();
case 1: return ioport("STICK0_Y")->read();
@ -499,13 +497,13 @@ void midyunit_state::term2_init_common(write16_delegate hack_w)
/* special inputs */
m_maincpu->space(AS_PROGRAM).install_read_handler(0x01c00000, 0x01c0005f, read16_delegate(FUNC(midyunit_state::term2_input_r), this));
m_maincpu->space(AS_PROGRAM).install_write_handler(0x01e00000, 0x01e0001f, write16_delegate(FUNC(midyunit_state::term2_sound_w), this));
/* HACK: this prevents the freeze on the movies */
/* until we figure whats causing it, this is better than nothing */
m_t2_hack_mem = m_maincpu->space(AS_PROGRAM).install_write_handler(0x010aa0e0, 0x010aa0ff, hack_w);
}
m_maincpu->space(AS_PROGRAM).install_write_handler(0x01e00000, 0x01e0001f, write16_delegate(FUNC(midyunit_state::term2_sound_w), this));
/* HACK: this prevents the freeze on the movies */
/* until we figure what's causing it, this is better than nothing */
m_t2_hack_mem = m_maincpu->space(AS_PROGRAM).install_write_handler(0x010aa0e0, 0x010aa0ff, hack_w);
}
DRIVER_INIT_MEMBER(midyunit_state,term2) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2_hack_w),this)); }
DRIVER_INIT_MEMBER(midyunit_state,term2la3) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2la3_hack_w),this)); }
DRIVER_INIT_MEMBER(midyunit_state,term2la2) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2la2_hack_w),this)); }