diff options
author | angelosa <salese_corp_ltd@email.it> | 2017-11-04 03:45:34 +0100 |
---|---|---|
committer | angelosa <salese_corp_ltd@email.it> | 2017-11-04 03:46:25 +0100 |
commit | d3d35364367d099ea851914bc9d78de025e51115 (patch) | |
tree | 0f598d4110caec9de1e53749ead2bcf997f0e659 | |
parent | cf9bfa70969842d7d062366110285fd8eb2b02bd (diff) |
MT #06193 (nw)
-rw-r--r-- | src/mame/drivers/shanghai.cpp | 125 |
1 files changed, 50 insertions, 75 deletions
diff --git a/src/mame/drivers/shanghai.cpp b/src/mame/drivers/shanghai.cpp index 8985698bff4..e393b75b670 100644 --- a/src/mame/drivers/shanghai.cpp +++ b/src/mame/drivers/shanghai.cpp @@ -7,9 +7,11 @@ Shanghai driver by Nicola Salmoria TODO: -- games are currently too fast (especially noticeable with kothello screen transitions), either irqs actually - fires every two frames or a HD63484 SR bit isn't behaving correctly; +- games are currently too fast (especially noticeable with kothello screen transitions), maybe unemulated HD63484 wait state penalties? - minor glitch with gfx copy on shanghai stage info panel (garbage on right); +- irq ack, shanghai and shangha2 uses it, kothello auto acks, maybe latter really runs on NMI instead + (vector 2 matches same pattern as shanghai games); +- shanghai: IC37 returns bad in service mode; * kothello @@ -20,11 +22,10 @@ displayed. ***************************************************************************/ #include "emu.h" -#include "audio/seibu.h" - #include "cpu/nec/nec.h" -#include "sound/2203intf.h" #include "video/hd63484.h" +#include "audio/seibu.h" +#include "sound/2203intf.h" #include "screen.h" #include "speaker.h" @@ -34,15 +35,17 @@ class shanghai_state : public driver_device public: shanghai_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu") { } - - required_device<cpu_device> m_maincpu; - - DECLARE_WRITE16_MEMBER(shanghai_coin_w); + m_maincpu(*this, "maincpu"), + m_screen(*this,"screen") + { } + DECLARE_WRITE8_MEMBER(shanghai_coin_w); DECLARE_PALETTE_INIT(shanghai); - - INTERRUPT_GEN_MEMBER(interrupt); + INTERRUPT_GEN_MEMBER(half_vblank_irq); + +private: + required_device<cpu_device> m_maincpu; + required_device<screen_device> m_screen; }; @@ -50,12 +53,10 @@ PALETTE_INIT_MEMBER(shanghai_state,shanghai) { int i; - for (i = 0;i < palette.entries();i++) { int bit0,bit1,bit2,r,g,b; - /* red component */ bit0 = (i >> 2) & 0x01; bit1 = (i >> 3) & 0x01; @@ -76,18 +77,17 @@ PALETTE_INIT_MEMBER(shanghai_state,shanghai) } } -INTERRUPT_GEN_MEMBER(shanghai_state::interrupt) +INTERRUPT_GEN_MEMBER(shanghai_state::half_vblank_irq) { - device.execute().set_input_line_and_vector(0,HOLD_LINE,0x80); + // definitely running at vblank / 2 (hd63484 irq mask not used) + if(m_screen->frame_number() & 1) + device.execute().set_input_line_and_vector(0,HOLD_LINE,0x80); } -WRITE16_MEMBER(shanghai_state::shanghai_coin_w) +WRITE8_MEMBER(shanghai_state::shanghai_coin_w) { - if (ACCESSING_BITS_0_7) - { - machine().bookkeeping().coin_counter_w(0,data & 1); - machine().bookkeeping().coin_counter_w(1,data & 2); - } + machine().bookkeeping().coin_counter_w(0,data & 1); + machine().bookkeeping().coin_counter_w(1,data & 2); } static ADDRESS_MAP_START( shanghai_map, AS_PROGRAM, 16, shanghai_state ) @@ -110,7 +110,7 @@ static ADDRESS_MAP_START( shanghai_portmap, AS_IO, 16, shanghai_state ) AM_RANGE(0x40, 0x41) AM_READ_PORT("P1") AM_RANGE(0x44, 0x45) AM_READ_PORT("P2") AM_RANGE(0x48, 0x49) AM_READ_PORT("SYSTEM") - AM_RANGE(0x4c, 0x4d) AM_WRITE(shanghai_coin_w) + AM_RANGE(0x4c, 0x4d) AM_WRITE8(shanghai_coin_w,0x00ff) ADDRESS_MAP_END @@ -121,7 +121,7 @@ static ADDRESS_MAP_START( shangha2_portmap, AS_IO, 16, shanghai_state ) AM_RANGE(0x30, 0x31) AM_DEVREADWRITE("hd63484", hd63484_device, status_r, address_w) AM_RANGE(0x32, 0x33) AM_DEVREADWRITE("hd63484", hd63484_device, data_r, data_w) AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("ymsnd", ym2203_device, read, write, 0x00ff) - AM_RANGE(0x50, 0x51) AM_WRITE(shanghai_coin_w) + AM_RANGE(0x50, 0x51) AM_WRITE8(shanghai_coin_w,0x00ff) ADDRESS_MAP_END static ADDRESS_MAP_START( kothello_map, AS_PROGRAM, 16, shanghai_state ) @@ -241,38 +241,41 @@ static INPUT_PORTS_START( kothello ) PORT_DIPSETTING( 0x00, "4" ) INPUT_PORTS_END - -static INPUT_PORTS_START( shanghai ) +static INPUT_PORTS_START( shanghai_common ) PORT_START("P1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Select Button") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Cancel Button") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 Help Button") PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("P2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Select Button") + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Cancel Button") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Help Button") PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - + PORT_START("SYSTEM") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) +INPUT_PORTS_END +static INPUT_PORTS_START( shanghai ) + PORT_INCLUDE( shanghai_common ) + PORT_START("DSW1") PORT_SERVICE_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW1:8" ) PORT_DIPNAME( 0x02, 0x02, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW1:7") @@ -322,35 +325,7 @@ static INPUT_PORTS_START( shanghai ) INPUT_PORTS_END static INPUT_PORTS_START( shangha2 ) - PORT_START("P1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - - PORT_START("P2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - - PORT_START("SYSTEM") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 ) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_INCLUDE( shanghai_common ) PORT_START("DSW1") PORT_SERVICE_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW2:8" ) @@ -409,7 +384,7 @@ static MACHINE_CONFIG_START( shanghai ) MCFG_CPU_ADD("maincpu", V30, XTAL_16MHz/2) /* NEC D70116C-8 */ MCFG_CPU_PROGRAM_MAP(shanghai_map) MCFG_CPU_IO_MAP(shanghai_portmap) - MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, interrupt) + MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, half_vblank_irq) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -445,7 +420,7 @@ static MACHINE_CONFIG_START( shangha2 ) MCFG_CPU_ADD("maincpu", V30, XTAL_16MHz/2) /* ? */ MCFG_CPU_PROGRAM_MAP(shangha2_map) MCFG_CPU_IO_MAP(shangha2_portmap) - MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, interrupt) + MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, half_vblank_irq) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -479,7 +454,7 @@ static MACHINE_CONFIG_START( kothello ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", V30, XTAL_16MHz) MCFG_CPU_PROGRAM_MAP(kothello_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, interrupt) + MCFG_CPU_VBLANK_INT_DRIVER("screen", shanghai_state, half_vblank_irq) MCFG_CPU_ADD("audiocpu", Z80, XTAL_16MHz/4) MCFG_CPU_PROGRAM_MAP(kothello_sound_map) @@ -573,7 +548,7 @@ ROM_START( shanghai ) ROM_LOAD16_BYTE( "shg-21a.ic21", 0xa0000, 0x10000, CRC(4ab06d32) SHA1(02667d1270b101386b947d5b9bfe64052e498041) ) ROM_LOAD16_BYTE( "shg-28a.ic28", 0xc0001, 0x10000, CRC(983ec112) SHA1(110e120e35815d055d6108a7603e83d2d990c666) ) ROM_LOAD16_BYTE( "shg-27a.ic27", 0xc0000, 0x10000, CRC(41af0945) SHA1(dfc4638a17f716ccc8e59f275571d6dc1093a745) ) - ROM_LOAD16_BYTE( "shg-37b.ic37", 0xe0001, 0x10000, CRC(ead3d66c) SHA1(f9be9a4773ea6c9ba931f7aa8c79121caacc231c) ) /* Single byte difference from IC37 below 0xD58C == 0x01 */ + ROM_LOAD16_BYTE( "shg-37b.ic37", 0xe0001, 0x10000, BAD_DUMP CRC(ead3d66c) SHA1(f9be9a4773ea6c9ba931f7aa8c79121caacc231c) ) /* Single byte difference from IC37 below 0xD58C == 0x01 */ ROM_LOAD16_BYTE( "shg-36b.ic36", 0xe0000, 0x10000, CRC(a1d6af96) SHA1(01c4c22bf03b3d260fffcbc6dfc5f2dd2bcba14a) ) ROM_END |