summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/midtunit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine/midtunit.c')
-rw-r--r--src/mame/machine/midtunit.c446
1 files changed, 223 insertions, 223 deletions
diff --git a/src/mame/machine/midtunit.c b/src/mame/machine/midtunit.c
index c8938c83f07..72069918ada 100644
--- a/src/mame/machine/midtunit.c
+++ b/src/mame/machine/midtunit.c
@@ -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;
+ }
+}