summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Alex W. Jackson <alex.w.jackson@gmail.com>2014-12-03 17:02:03 -0500
committerGravatarGravatar Alex W. Jackson <alex.w.jackson@gmail.com>2014-12-03 17:02:03 -0500
commit89d0dd3e2b09fe513621f5c365c95cb83f33bcbd (patch) (github)
tree45dea648f43b0c425cd4b762aa9bdaf62f1abc04
parent6d098b92d720649eea245c85724e5b46ed4a5d8b (diff)
downloadmame-89d0dd3e2b09fe513621f5c365c95cb83f33bcbd.tar.bz2
mame-89d0dd3e2b09fe513621f5c365c95cb83f33bcbd.zip
mjkjidai.c: replace custom sound with MSM5205; add dip locations; modernize (nw)
-rw-r--r--src/mame/drivers/mjkjidai.c311
-rw-r--r--src/mame/includes/mjkjidai.h68
-rw-r--r--src/mame/video/mjkjidai.c20
3 files changed, 148 insertions, 251 deletions
diff --git a/src/mame/drivers/mjkjidai.c b/src/mame/drivers/mjkjidai.c
index 966685c3e9f..0948458cb67 100644
--- a/src/mame/drivers/mjkjidai.c
+++ b/src/mame/drivers/mjkjidai.c
@@ -26,112 +26,41 @@ TODO:
#include "sound/sn76496.h"
#include "includes/mjkjidai.h"
-/* Start of ADPCM custom chip code */
-
-const device_type MJKJIDAI = &device_creator<mjkjidai_adpcm_device>;
-
-mjkjidai_adpcm_device::mjkjidai_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, MJKJIDAI, "Mahjong Kyou Jidai ADPCM Custom", tag, owner, clock, "mjkjidai_adpcm", __FILE__),
- device_sound_interface(mconfig, *this),
- m_stream(NULL),
- m_current(0),
- m_end(0),
- m_nibble(0),
- m_playing(0),
- m_base(NULL)
-{
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-void mjkjidai_adpcm_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void mjkjidai_adpcm_device::device_start()
+WRITE8_MEMBER(mjkjidai_state::adpcm_w)
{
- m_playing = 0;
- m_stream = machine().sound().stream_alloc(*this, 0, 1, clock());
- m_base = machine().root_device().memregion("adpcm")->base();
- m_adpcm.reset();
-
- save_item(NAME(m_current));
- save_item(NAME(m_end));
- save_item(NAME(m_nibble));
- save_item(NAME(m_playing));
+ m_adpcm_pos = (data & 0x07) * 0x1000 * 2;
+ m_adpcm_end = m_adpcm_pos + 0x1000 * 2;
+ m_msm->reset_w(0);
}
-//-------------------------------------------------
-// sound_stream_update - handle a stream update
-//-------------------------------------------------
-
-void mjkjidai_adpcm_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+WRITE_LINE_MEMBER(mjkjidai_state::adpcm_int)
{
- stream_sample_t *dest = outputs[0];
-
- while (m_playing && samples > 0)
+ if (m_adpcm_pos >= m_adpcm_end)
{
- int val = (m_base[m_current] >> m_nibble) & 15;
-
- m_nibble ^= 4;
- if (m_nibble == 4)
- {
- m_current++;
- if (m_current >= m_end)
- m_playing = 0;
- }
-
- *dest++ = m_adpcm.clock(val) << 4;
- samples--;
+ m_msm->reset_w(1);
}
- while (samples > 0)
+ else
{
- *dest++ = 0;
- samples--;
+ UINT8 const data = m_adpcmrom[m_adpcm_pos / 2];
+ m_msm->data_w(m_adpcm_pos & 1 ? data & 0xf : data >> 4);
+ m_adpcm_pos++;
}
}
-void mjkjidai_adpcm_device::mjkjidai_adpcm_play (int offset, int length)
-{
- m_current = offset;
- m_end = offset + length/2;
- m_nibble = 4;
- m_playing = 1;
-}
-
-WRITE8_MEMBER(mjkjidai_state::adpcm_w)
-{
- m_mjk_adpcm->mjkjidai_adpcm_play ((data & 0x07) * 0x1000, 0x1000 * 2);
-}
-/* End of ADPCM custom chip code */
-
-
-READ8_MEMBER(mjkjidai_state::keyboard_r)
+CUSTOM_INPUT_MEMBER(mjkjidai_state::keyboard_r)
{
- int res = 0x3f,i;
- static const char *const keynames[] = { "PL2_1", "PL2_2", "PL2_3", "PL2_4", "PL2_5", "PL2_6", "PL1_1", "PL1_2", "PL1_3", "PL1_4", "PL1_5", "PL1_6" };
+ int res = 0x3f;
-// logerror("%04x: keyboard_r\n", space.device().safe_pc());
-
- for (i = 0; i < 12; i++)
+ for (int i = 0; i < 12; i++)
{
- if (~m_keyb & (1 << i))
+ if (~m_keyb & (0x800 >> i))
{
- res = ioport(keynames[i])->read() & 0x3f;
+ res = m_row[i]->read();
break;
}
}
- res |= (ioport("IN3")->read() & 0xc0);
-
return res;
}
@@ -152,21 +81,18 @@ static ADDRESS_MAP_START( mjkjidai_map, AS_PROGRAM, 8, mjkjidai_state )
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xdfff) AM_RAM AM_SHARE("nvram") // cleared and initialized on startup if bit 6 of port 00 is 0
- AM_RANGE(0xe000, 0xe01f) AM_RAM AM_SHARE("spriteram1") // shared with tilemap ram
- AM_RANGE(0xe800, 0xe81f) AM_RAM AM_SHARE("spriteram2") // shared with tilemap ram
- AM_RANGE(0xf000, 0xf01f) AM_RAM AM_SHARE("spriteram3") // shared with tilemap ram
AM_RANGE(0xe000, 0xf7ff) AM_RAM_WRITE(mjkjidai_videoram_w) AM_SHARE("videoram")
ADDRESS_MAP_END
static ADDRESS_MAP_START( mjkjidai_io_map, AS_IO, 8, mjkjidai_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
- AM_RANGE(0x00, 0x00) AM_READ(keyboard_r)
+ AM_RANGE(0x00, 0x00) AM_READ_PORT("KEYBOARD")
AM_RANGE(0x01, 0x01) AM_READNOP // ???
AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2")
AM_RANGE(0x01, 0x02) AM_WRITE(keyboard_select_w)
AM_RANGE(0x10, 0x10) AM_WRITE(mjkjidai_ctrl_w) // rom bank, coin counter, flip screen etc
- AM_RANGE(0x11, 0x11) AM_READ_PORT("IN0")
- AM_RANGE(0x12, 0x12) AM_READ_PORT("IN1")
+ AM_RANGE(0x11, 0x11) AM_READ_PORT("DSW1")
+ AM_RANGE(0x12, 0x12) AM_READ_PORT("DSW2")
AM_RANGE(0x20, 0x20) AM_DEVWRITE("sn1", sn76489_device, write)
AM_RANGE(0x30, 0x30) AM_DEVWRITE("sn2", sn76489_device, write)
AM_RANGE(0x40, 0x40) AM_WRITE(adpcm_w)
@@ -174,147 +100,146 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( mjkjidai )
- PORT_START("IN0")
- PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
+ PORT_START("DSW1")
+ PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:1")
+ PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:2")
+ PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
- PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:3")
+ PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
+ PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:4")
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:5")
+ PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x04, 0x04, "Test Mode" ) PORT_DIPLOCATION("SW1:6")
+ PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
- PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:7")
+ PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
-
- PORT_START("IN1")
- PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
+ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8")
PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
+
+ PORT_START("DSW2")
+ PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:1")
+ PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:2")
+ PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:3")
+ PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
+ PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:4")
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:5")
+ PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:6")
+ PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
+ PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:7")
+ PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x00, DEF_STR( On ) )
+ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:8")
+ PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("IN2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
- PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) // service mode
+ PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
PORT_DIPNAME( 0x20, 0x20, "Statistics" )
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START3 )
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START4 )
+ PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("IN3")
+ PORT_START("KEYBOARD")
+ PORT_BIT( 0x3f, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(DEVICE_SELF, mjkjidai_state, keyboard_r, NULL)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) // reinitialize NVRAM and reset the game
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
- PORT_START("PL1_1")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x3e, IP_ACTIVE_LOW, IPT_UNUSED )
-
- PORT_START("PL1_2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
- PORT_BIT( 0x38, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_START("ROW.0")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_B )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_C )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_D )
+ PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL1_3")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_M )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_N )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
+ PORT_START("ROW.1")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_E )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_G )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_H )
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL1_4")
+ PORT_START("ROW.2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_I )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_J )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_L )
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL1_5")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_E )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_G )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_H )
+ PORT_START("ROW.3")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_M )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_N )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL1_6")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_B )
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_C )
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_D )
- PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_START("ROW.4")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
+ PORT_BIT( 0x38, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_1")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
+ PORT_START("ROW.5")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x3e, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_2")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) PORT_PLAYER(2)
- PORT_BIT( 0x38, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_START("ROW.6")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2)
+ PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_3")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_M ) PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_N ) PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) PORT_PLAYER(2)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) PORT_PLAYER(2)
+ PORT_START("ROW.7")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_G ) PORT_PLAYER(2)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_H ) PORT_PLAYER(2)
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_4")
+ PORT_START("ROW.8")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_I ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_J ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_L ) PORT_PLAYER(2)
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_5")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_G ) PORT_PLAYER(2)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_H ) PORT_PLAYER(2)
+ PORT_START("ROW.9")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_M ) PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_N ) PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) PORT_PLAYER(2)
+ PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) PORT_PLAYER(2)
PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
- PORT_START("PL2_6")
- PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(2)
- PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2)
- PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2)
- PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2)
- PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_START("ROW.10")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) PORT_PLAYER(2)
+ PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) PORT_PLAYER(2)
+ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) PORT_PLAYER(2)
+ PORT_BIT( 0x38, IP_ACTIVE_LOW, IPT_UNUSED )
+
+ PORT_START("ROW.11")
+ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
+ PORT_BIT( 0x3e, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END
@@ -350,10 +275,19 @@ GFXDECODE_END
INTERRUPT_GEN_MEMBER(mjkjidai_state::vblank_irq)
{
- if(m_nmi_mask)
+ if(m_nmi_enable)
device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
}
+void mjkjidai_state::machine_start()
+{
+ membank("bank1")->configure_entries(0, 4, memregion("maincpu")->base() + 0x8000, 0x4000);
+}
+
+void mjkjidai_state::machine_reset()
+{
+ m_adpcm_pos = m_adpcm_end = 0;
+}
static MACHINE_CONFIG_START( mjkjidai, mjkjidai_state )
@@ -386,7 +320,9 @@ static MACHINE_CONFIG_START( mjkjidai, mjkjidai_state )
MCFG_SOUND_ADD("sn2", SN76489, 10000000/4)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
- MCFG_SOUND_ADD("adpcm", MJKJIDAI, 6000)
+ MCFG_SOUND_ADD("msm", MSM5205, 384000)
+ MCFG_MSM5205_VCLK_CB(WRITELINE(mjkjidai_state, adpcm_int))
+ MCFG_MSM5205_PRESCALER_SELECTOR(MSM5205_S64_4B) /* 6kHz */
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
@@ -399,11 +335,10 @@ MACHINE_CONFIG_END
***************************************************************************/
ROM_START( mjkjidai )
- ROM_REGION( 0x1c000, "maincpu", 0 )
+ ROM_REGION( 0x18000, "maincpu", 0 )
ROM_LOAD( "mkj-00.14g", 0x00000, 0x8000, CRC(188a27e9) SHA1(2306ad112aaf8d9ac77a89d0e4c3a17f36945130) )
- ROM_LOAD( "mkj-01.15g", 0x08000, 0x4000, CRC(a6a5e9c7) SHA1(974f4343f4347a0065f833c1fdcc47e96d42932d) ) /* banked, there is code flowing from 7fff to this bank */
- ROM_CONTINUE( 0x10000, 0x4000 )
- ROM_LOAD( "mkj-02.16g", 0x14000, 0x8000, CRC(fb312927) SHA1(b71db72ba881474f9c2523d0617757889af9f28e) )
+ ROM_LOAD( "mkj-01.15g", 0x08000, 0x8000, CRC(a6a5e9c7) SHA1(974f4343f4347a0065f833c1fdcc47e96d42932d) )
+ ROM_LOAD( "mkj-02.16g", 0x10000, 0x8000, CRC(fb312927) SHA1(b71db72ba881474f9c2523d0617757889af9f28e) )
ROM_REGION( 0x30000, "gfx1", 0 )
ROM_LOAD( "mkj-20.4e", 0x00000, 0x8000, CRC(8fc66bce) SHA1(4f1006bc5168e39eb7a1f6a4b3c3f5aaa3c1c7dd) )
diff --git a/src/mame/includes/mjkjidai.h b/src/mame/includes/mjkjidai.h
index 3f91af23bce..87ad53902c4 100644
--- a/src/mame/includes/mjkjidai.h
+++ b/src/mame/includes/mjkjidai.h
@@ -1,77 +1,49 @@
#include "machine/nvram.h"
-#include "sound/okiadpcm.h"
-
-class mjkjidai_adpcm_device;
+#include "sound/msm5205.h"
class mjkjidai_state : public driver_device
{
public:
mjkjidai_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
- m_spriteram1(*this, "spriteram1"),
- m_spriteram2(*this, "spriteram2"),
- m_spriteram3(*this, "spriteram3"),
- m_videoram(*this, "videoram"),
m_maincpu(*this, "maincpu"),
- m_mjk_adpcm(*this, "adpcm"),
+ m_msm(*this, "msm"),
m_nvram(*this, "nvram"),
m_gfxdecode(*this, "gfxdecode"),
- m_palette(*this, "palette") { }
-
- required_shared_ptr<UINT8> m_spriteram1;
- required_shared_ptr<UINT8> m_spriteram2;
- required_shared_ptr<UINT8> m_spriteram3;
- required_shared_ptr<UINT8> m_videoram;
+ m_palette(*this, "palette"),
+ m_adpcmrom(*this, "adpcm"),
+ m_videoram(*this, "videoram"),
+ m_row(*this, "ROW") { }
required_device<cpu_device> m_maincpu;
- required_device<mjkjidai_adpcm_device> m_mjk_adpcm;
+ required_device<msm5205_device> m_msm;
required_device<nvram_device> m_nvram;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
+ required_region_ptr<UINT8> m_adpcmrom;
+ required_shared_ptr<UINT8> m_videoram;
+
+ required_ioport_array<12> m_row;
+
+ int m_adpcm_pos;
+ int m_adpcm_end;
int m_keyb;
- int m_nvram_init_count;
- int m_display_enable;
+ bool m_nmi_enable;
+ bool m_display_enable;
tilemap_t *m_bg_tilemap;
- UINT8 m_nmi_mask;
- DECLARE_READ8_MEMBER(keyboard_r);
+ DECLARE_CUSTOM_INPUT_MEMBER(keyboard_r);
DECLARE_WRITE8_MEMBER(keyboard_select_w);
DECLARE_WRITE8_MEMBER(mjkjidai_videoram_w);
DECLARE_WRITE8_MEMBER(mjkjidai_ctrl_w);
DECLARE_WRITE8_MEMBER(adpcm_w);
+ DECLARE_WRITE_LINE_MEMBER(adpcm_int);
TILE_GET_INFO_MEMBER(get_tile_info);
+ virtual void machine_start();
+ virtual void machine_reset();
virtual void video_start();
UINT32 screen_update_mjkjidai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(vblank_irq);
void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
};
-
-class mjkjidai_adpcm_device : public device_t,
- public device_sound_interface
-{
-public:
- mjkjidai_adpcm_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mjkjidai_adpcm_device() {}
-
- void mjkjidai_adpcm_play (int offset, int length);
-
-protected:
- // device-level overrides
- virtual void device_config_complete();
- virtual void device_start();
-
- // sound stream update overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-private:
- // internal state
- oki_adpcm_state m_adpcm;
- sound_stream *m_stream;
- UINT32 m_current;
- UINT32 m_end;
- UINT8 m_nibble;
- UINT8 m_playing;
- UINT8 *m_base;
-};
-
-extern const device_type MJKJIDAI;
diff --git a/src/mame/video/mjkjidai.c b/src/mame/video/mjkjidai.c
index eb668c02590..87a4e15640b 100644
--- a/src/mame/video/mjkjidai.c
+++ b/src/mame/video/mjkjidai.c
@@ -45,12 +45,10 @@ WRITE8_MEMBER(mjkjidai_state::mjkjidai_videoram_w)
WRITE8_MEMBER(mjkjidai_state::mjkjidai_ctrl_w)
{
- UINT8 *rom = memregion("maincpu")->base();
-
// logerror("%04x: port c0 = %02x\n",space.device().safe_pc(),data);
/* bit 0 = NMI enable */
- m_nmi_mask = data & 1;
+ m_nmi_enable = data & 1;
/* bit 1 = flip screen */
flip_screen_set(data & 0x02);
@@ -62,15 +60,7 @@ WRITE8_MEMBER(mjkjidai_state::mjkjidai_ctrl_w)
coin_counter_w(machine(), 0,data & 0x20);
/* bits 6-7 select ROM bank */
- if (data & 0xc0)
- {
- membank("bank1")->set_base(rom + 0x10000-0x4000 + ((data & 0xc0) << 8));
- }
- else
- {
- /* there is code flowing from 7fff to this bank so they have to be contiguous in memory */
- membank("bank1")->set_base(rom + 0x08000);
- }
+ membank("bank1")->set_entry(data >> 6);
}
@@ -83,9 +73,9 @@ WRITE8_MEMBER(mjkjidai_state::mjkjidai_ctrl_w)
void mjkjidai_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
{
- UINT8 *spriteram = m_spriteram1;
- UINT8 *spriteram_2 = m_spriteram2;
- UINT8 *spriteram_3 = m_spriteram3;
+ UINT8 *spriteram = &m_videoram[0];
+ UINT8 *spriteram_2 = &m_videoram[0x800];
+ UINT8 *spriteram_3 = &m_videoram[0x1000];
int offs;
for (offs = 0x20-2;offs >= 0;offs -= 2)