summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author angelosa <salese_corp_ltd@email.it>2017-04-26 04:40:38 +0200
committer angelosa <salese_corp_ltd@email.it>2017-04-26 04:42:00 +0200
commit66ac95eb053102bbf4fbf28371a15ded2b5bd221 (patch)
tree4725920fb0fdfc5732bb9d26a6659dcd3b261084
parentf3f2fdd50a5d63eff559e54b8dcf4ce5c5a4fbfd (diff)
cobra.cpp: fix some input issues (nw)
-rw-r--r--src/mame/drivers/cobra.cpp136
1 files changed, 98 insertions, 38 deletions
diff --git a/src/mame/drivers/cobra.cpp b/src/mame/drivers/cobra.cpp
index 97fd810c3ba..84dbf06dc1c 100644
--- a/src/mame/drivers/cobra.cpp
+++ b/src/mame/drivers/cobra.cpp
@@ -495,15 +495,18 @@ class cobra_jvs : public jvs_device
public:
cobra_jvs(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- DECLARE_WRITE_LINE_MEMBER(coin_1_w);
- DECLARE_WRITE_LINE_MEMBER(coin_2_w);
-
+ //DECLARE_WRITE_LINE_MEMBER(coin_1_w);
+ //DECLARE_WRITE_LINE_MEMBER(coin_2_w);
+ static void static_set_main_board(device_t &device, bool enable);
+ void increase_coin_counter(uint8_t which);
+
protected:
virtual bool switches(uint8_t *&buf, uint8_t count_players, uint8_t bytes_per_switch) override;
virtual bool coin_counters(uint8_t *&buf, uint8_t count) override;
virtual void function_list(uint8_t *&buf) override;
private:
+ bool is_main_board;
int m_coin_counter[2];
optional_ioport m_test_port;
optional_ioport_array<2> m_player_ports;
@@ -520,6 +523,13 @@ cobra_jvs::cobra_jvs(const machine_config &mconfig, const char *tag, device_t *o
m_coin_counter[1] = 0;
}
+void cobra_jvs::static_set_main_board(device_t &device, bool enable)
+{
+ cobra_jvs &jvsdev = downcast<cobra_jvs &>(device);
+ jvsdev.is_main_board = enable;
+}
+
+#if 0
WRITE_LINE_MEMBER(cobra_jvs::coin_1_w)
{
if(state)
@@ -531,20 +541,42 @@ WRITE_LINE_MEMBER(cobra_jvs::coin_2_w)
if(state)
m_coin_counter[1]++;
}
+#endif
-void cobra_jvs::function_list(uint8_t *&buf)
+void cobra_jvs::increase_coin_counter(uint8_t which)
{
+ m_coin_counter[which]++;
+}
+
+// TODO: this certainly isn't correct, all three JVS points to the same capabilities!
+void cobra_jvs::function_list(uint8_t *&buf)
+{
+ if(this->is_main_board == false)
+ return;
+
// SW input - 2 players, 13 bits
- *buf++ = 0x01; *buf++ = 2; *buf++ = 13; *buf++ = 0;
+ *buf++ = 0x01;
+ *buf++ = 2;
+ *buf++ = 13;
+ *buf++ = 0;
// Coin input - 2 slots
- *buf++ = 0x02; *buf++ = 2; *buf++ = 0; *buf++ = 0;
-
+ *buf++ = 0x02;
+ *buf++ = 2;
+ *buf++ = 0;
+ *buf++ = 0;
+
// Analog input - 8 channels
- *buf++ = 0x03; *buf++ = 8; *buf++ = 16; *buf++ = 0;
+ *buf++ = 0x03;
+ *buf++ = 8;
+ *buf++ = 16;
+ *buf++ = 0;
// Driver out - 6 channels
- *buf++ = 0x12; *buf++ = 6; *buf++ = 0; *buf++ = 0;
+ *buf++ = 0x12;
+ *buf++ = 6;
+ *buf++ = 0;
+ *buf++ = 0;
}
bool cobra_jvs::switches(uint8_t *&buf, uint8_t count_players, uint8_t bytes_per_switch)
@@ -553,6 +585,9 @@ bool cobra_jvs::switches(uint8_t *&buf, uint8_t count_players, uint8_t bytes_per
printf("jvs switch read: num players %d, bytes %d\n", count_players, bytes_per_switch);
#endif
+ if(this->is_main_board == false)
+ return false;
+
if (count_players > 2 || bytes_per_switch > 2)
return false;
@@ -574,10 +609,15 @@ bool cobra_jvs::coin_counters(uint8_t *&buf, uint8_t count)
#if LOG_JVS
printf("jvs coin counter read: count %d\n", count);
#endif
-
+
+ if(this->is_main_board == false)
+ return false;
+
+ //printf("recv %04x\n",m_coin_counter[0]);
+
if (count > 2)
return false;
-
+
*buf++ = m_coin_counter[0] >> 8; *buf++ = m_coin_counter[0];
if(count > 1)
@@ -656,6 +696,9 @@ public:
m_gfxcpu(*this, "gfxcpu"),
m_gfx_pagetable(*this, "pagetable"),
m_k001604(*this, "k001604"),
+ m_jvs1(*this, "cobra_jvs1"),
+ m_jvs2(*this, "cobra_jvs2"),
+ m_jvs3(*this, "cobra_jvs3"),
m_ata(*this, "ata"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
@@ -672,6 +715,9 @@ public:
required_device<ppc_device> m_gfxcpu;
required_shared_ptr<uint64_t> m_gfx_pagetable;
required_device<k001604_device> m_k001604;
+ required_device<cobra_jvs> m_jvs1;
+ required_device<cobra_jvs> m_jvs2;
+ required_device<cobra_jvs> m_jvs3;
required_device<ata_interface_device> m_ata;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
@@ -788,6 +834,7 @@ public:
DECLARE_DRIVER_INIT(racjamdx);
DECLARE_DRIVER_INIT(bujutsu);
DECLARE_DRIVER_INIT(cobra);
+ DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
@@ -3152,6 +3199,17 @@ ADDRESS_MAP_END
/*****************************************************************************/
+INPUT_CHANGED_MEMBER(cobra_state::coin_inserted)
+{
+ if(newval)
+ {
+ uint8_t coin_chute = (uint8_t)(uintptr_t)param & 1;
+ m_jvs1->increase_coin_counter(coin_chute);
+ m_jvs2->increase_coin_counter(coin_chute);
+ m_jvs3->increase_coin_counter(coin_chute);
+ }
+}
+
INPUT_PORTS_START( cobra )
PORT_START("TEST")
PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_HIGH) /* Test Button */
@@ -3165,43 +3223,43 @@ INPUT_PORTS_START( cobra )
PORT_START("P1")
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_START1 )
- PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("P1 Service") PORT_CODE(KEYCODE_7)
+ PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_SERVICE1 )
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1)
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1)
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1)
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
- PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_PLAYER(1)
+ PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Punch")
+ PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 Kick")
+ PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Guard")
+ PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("P2")
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_START2 )
- PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("P2 Service") PORT_CODE(KEYCODE_8)
+ PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_SERVICE2 )
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
- PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
- PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2)
- PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2)
- PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
- PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_PLAYER(2)
+ PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Punch")
+ PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Kick")
+ PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Guard")
+ PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED )
+ PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("COINS")
- PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_WRITE_LINE_DEVICE_MEMBER("cobra_jvs1", cobra_jvs, coin_1_w)
- PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_WRITE_LINE_DEVICE_MEMBER("cobra_jvs1", cobra_jvs, coin_2_w)
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_CHANGED_MEMBER(DEVICE_SELF, cobra_state,coin_inserted, 0)//PORT_WRITE_LINE_DEVICE_MEMBER("cobra_jvs1", cobra_jvs, coin_1_w)
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_CHANGED_MEMBER(DEVICE_SELF, cobra_state,coin_inserted, 1) //PORT_WRITE_LINE_DEVICE_MEMBER("cobra_jvs1", cobra_jvs, coin_2_w)
INPUT_PORTS_END
WRITE_LINE_MEMBER(cobra_state::ide_interrupt)
@@ -3316,9 +3374,11 @@ static MACHINE_CONFIG_START( cobra, cobra_state )
MCFG_DEVICE_ADD("cobra_jvs_host", COBRA_JVS_HOST, 4000000)
MCFG_JVS_DEVICE_ADD("cobra_jvs1", COBRA_JVS, "cobra_jvs_host")
+ cobra_jvs::static_set_main_board(*device, true);
MCFG_JVS_DEVICE_ADD("cobra_jvs2", COBRA_JVS, "cobra_jvs_host")
+ cobra_jvs::static_set_main_board(*device, true);
MCFG_JVS_DEVICE_ADD("cobra_jvs3", COBRA_JVS, "cobra_jvs_host")
-
+ cobra_jvs::static_set_main_board(*device, true);
MACHINE_CONFIG_END
/*****************************************************************************/
@@ -3596,5 +3656,5 @@ ROM_END
/*************************************************************************/
-GAME( 1997, bujutsu, 0, cobra, cobra, cobra_state, bujutsu, ROT0, "Konami", "Fighting Bujutsu", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
-GAME( 1997, racjamdx, 0, cobra, cobra, cobra_state, racjamdx, ROT0, "Konami", "Racing Jam DX", MACHINE_NOT_WORKING | MACHINE_NO_SOUND )
+GAME( 1997, bujutsu, 0, cobra, cobra, cobra_state, bujutsu, ROT0, "Konami", "Fighting Bujutsu", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND )
+GAME( 1997, racjamdx, 0, cobra, cobra, cobra_state, racjamdx, ROT0, "Konami", "Racing Jam DX", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND )