From edb4c450a3a84aa9c97ae0764502241a22133228 Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 29 Sep 2021 23:01:56 -0400 Subject: [PATCH] pickin, botanic, squaitsa: Correct mapping for PSGs; add watchdog timer --- src/mame/drivers/bagman.cpp | 100 +++++++++++++++++++++++------------- src/mame/includes/bagman.h | 32 +++++++++--- 2 files changed, 90 insertions(+), 42 deletions(-) diff --git a/src/mame/drivers/bagman.cpp b/src/mame/drivers/bagman.cpp index 0c7d093797e..eb3ca0f0637 100644 --- a/src/mame/drivers/bagman.cpp +++ b/src/mame/drivers/bagman.cpp @@ -66,7 +66,7 @@ DIP locations verified for: #include "includes/bagman.h" #include "cpu/z80/z80.h" -#include "sound/ay8910.h" +#include "machine/watchdog.h" #include "screen.h" #include "speaker.h" @@ -149,20 +149,16 @@ void bagman_state::main_map(address_map &map) } - -void bagman_state::pickin_map(address_map &map) +void pickin_state::pickin_map(address_map &map) { map(0x0000, 0x5fff).rom(); map(0x7000, 0x77ff).ram(); - map(0x8800, 0x8bff).ram().w(FUNC(bagman_state::videoram_w)).share("videoram"); - map(0x9800, 0x9bff).ram().w(FUNC(bagman_state::colorram_w)).share("colorram"); // Includes spriteram - map(0x9c00, 0x9fff).nopw(); // Written to, but unused + map(0x8800, 0x8bff).ram().w(FUNC(pickin_state::videoram_w)).share("videoram"); + map(0x9800, 0x9bff).ram().w(FUNC(pickin_state::colorram_w)).share("colorram"); // Includes spriteram + map(0x9c00, 0x9fff).nopw(); // Written to in pickin, but unused map(0xa000, 0xa007).w("mainlatch", FUNC(ls259_device::write_d0)); map(0xa800, 0xa800).portr("DSW"); - - // Guess - map(0xb000, 0xb000).w("ay2", FUNC(ay8910_device::address_w)); - map(0xb800, 0xb800).rw("ay2", FUNC(ay8910_device::data_r), FUNC(ay8910_device::data_w)); + map(0xb800, 0xb800).r("watchdog", FUNC(watchdog_timer_device::reset_r)); } void bagman_state::main_portmap(address_map &map) @@ -173,6 +169,31 @@ void bagman_state::main_portmap(address_map &map) //map(0x56, 0x56).nopw(); } +uint8_t pickin_state::aysnd_r() +{ + uint8_t data = 0xff; + if (!m_mainlatch->q5_r()) + data &= m_aysnd[0]->data_r(); + if (!m_mainlatch->q6_r()) + data &= m_aysnd[1]->data_r(); + return data; +} + +void pickin_state::aysnd_w(offs_t offset, uint8_t data) +{ + if (!m_mainlatch->q5_r()) + m_aysnd[0]->address_data_w(offset, data); + if (!m_mainlatch->q6_r()) + m_aysnd[1]->address_data_w(offset, data); +} + +void pickin_state::pickin_portmap(address_map &map) +{ + map.global_mask(0xff); + map(0x08, 0x09).w(FUNC(pickin_state::aysnd_w)); + map(0x0c, 0x0c).r(FUNC(pickin_state::aysnd_r)); +} + static INPUT_PORTS_START( bagman ) @@ -528,32 +549,34 @@ void bagman_state::sbagmani(machine_config &config) m_mainlatch->q_out_cb<3>().set(FUNC(bagman_state::video_enable_w)); } -void bagman_state::pickin(machine_config &config) +void pickin_state::pickin(machine_config &config) { // Basic machine hardware Z80(config, m_maincpu, BAGMAN_H0); - m_maincpu->set_addrmap(AS_PROGRAM, &bagman_state::pickin_map); - m_maincpu->set_addrmap(AS_IO, &bagman_state::main_portmap); + m_maincpu->set_addrmap(AS_PROGRAM, &pickin_state::pickin_map); + m_maincpu->set_addrmap(AS_IO, &pickin_state::pickin_portmap); LS259(config, m_mainlatch); - m_mainlatch->q_out_cb<0>().set(FUNC(bagman_state::irq_mask_w)); - m_mainlatch->q_out_cb<1>().set(FUNC(bagman_state::flipscreen_x_w)); - m_mainlatch->q_out_cb<2>().set(FUNC(bagman_state::flipscreen_y_w)); - m_mainlatch->q_out_cb<3>().set(FUNC(bagman_state::video_enable_w)); - m_mainlatch->q_out_cb<4>().set(FUNC(bagman_state::coin_counter_w)); + m_mainlatch->q_out_cb<0>().set(FUNC(pickin_state::irq_mask_w)); + m_mainlatch->q_out_cb<1>().set(FUNC(pickin_state::flipscreen_x_w)); + m_mainlatch->q_out_cb<2>().set(FUNC(pickin_state::flipscreen_y_w)); + m_mainlatch->q_out_cb<3>().set(FUNC(pickin_state::video_enable_w)); + m_mainlatch->q_out_cb<4>().set(FUNC(pickin_state::coin_counter_w)); m_mainlatch->q_out_cb<5>().set_nop(); // ???? m_mainlatch->q_out_cb<6>().set_nop(); // ???? m_mainlatch->q_out_cb<7>().set_nop(); // ???? + WATCHDOG_TIMER(config, "watchdog"); + // Video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_raw(BAGMAN_HCLK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART); - screen.set_screen_update(FUNC(bagman_state::screen_update)); + screen.set_screen_update(FUNC(pickin_state::screen_update)); screen.set_palette(m_palette); - screen.screen_vblank().set(FUNC(bagman_state::vblank_irq)); + screen.screen_vblank().set(FUNC(pickin_state::vblank_irq)); GFXDECODE(config, m_gfxdecode, m_palette, gfx_pickin); - PALETTE(config, m_palette, FUNC(bagman_state::bagman_palette), 64); + PALETTE(config, m_palette, FUNC(pickin_state::bagman_palette), 64); // Sound hardware SPEAKER(config, "mono").front_center(); @@ -564,7 +587,10 @@ void bagman_state::pickin(machine_config &config) aysnd.add_route(ALL_OUTPUTS, "mono", 0.40); // Maybe - AY8910(config, "ay2", 1500000).add_route(ALL_OUTPUTS, "mono", 0.40); + ay8910_device &ay2(AY8910(config, "ay2", 1500000)); + ay2.port_a_read_callback().set_constant(0xff); // needed to avoid spurious credits on startup + ay2.port_b_read_callback().set_constant(0xff); + ay2.add_route(ALL_OUTPUTS, "mono", 0.40); } /* @@ -585,32 +611,34 @@ z80 */ -void bagman_state::botanic(machine_config &config) +void pickin_state::botanic(machine_config &config) { // Basic machine hardware Z80(config, m_maincpu, BAGMAN_H0); - m_maincpu->set_addrmap(AS_PROGRAM, &bagman_state::pickin_map); - m_maincpu->set_addrmap(AS_IO, &bagman_state::main_portmap); + m_maincpu->set_addrmap(AS_PROGRAM, &pickin_state::pickin_map); + m_maincpu->set_addrmap(AS_IO, &pickin_state::pickin_portmap); LS259(config, m_mainlatch); - m_mainlatch->q_out_cb<0>().set(FUNC(bagman_state::irq_mask_w)); - m_mainlatch->q_out_cb<1>().set(FUNC(bagman_state::flipscreen_x_w)); - m_mainlatch->q_out_cb<2>().set(FUNC(bagman_state::flipscreen_y_w)); - m_mainlatch->q_out_cb<3>().set(FUNC(bagman_state::video_enable_w)); - m_mainlatch->q_out_cb<4>().set(FUNC(bagman_state::coin_counter_w)); + m_mainlatch->q_out_cb<0>().set(FUNC(pickin_state::irq_mask_w)); + m_mainlatch->q_out_cb<1>().set(FUNC(pickin_state::flipscreen_x_w)); + m_mainlatch->q_out_cb<2>().set(FUNC(pickin_state::flipscreen_y_w)); + m_mainlatch->q_out_cb<3>().set(FUNC(pickin_state::video_enable_w)); + m_mainlatch->q_out_cb<4>().set(FUNC(pickin_state::coin_counter_w)); m_mainlatch->q_out_cb<5>().set_nop(); // ???? m_mainlatch->q_out_cb<6>().set_nop(); // ???? m_mainlatch->q_out_cb<7>().set_nop(); // ???? + WATCHDOG_TIMER(config, "watchdog"); + // Video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_raw(BAGMAN_HCLK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART); - screen.set_screen_update(FUNC(bagman_state::screen_update)); + screen.set_screen_update(FUNC(pickin_state::screen_update)); screen.set_palette(m_palette); - screen.screen_vblank().set(FUNC(bagman_state::vblank_irq)); + screen.screen_vblank().set(FUNC(pickin_state::vblank_irq)); GFXDECODE(config, m_gfxdecode, m_palette, gfx_bagman); - PALETTE(config, m_palette, FUNC(bagman_state::bagman_palette), 64); + PALETTE(config, m_palette, FUNC(pickin_state::bagman_palette), 64); // Sound hardware SPEAKER(config, "mono").front_center(); @@ -1247,10 +1275,10 @@ GAME( 1984, sbagman2, sbagman, sbagman, sbagman, bagman_state, empty_init, GAME( 1984, sbagmani, sbagman, sbagmani, sbagman, bagman_state, empty_init, ROT90, "Valadon Automation (Itisa license)", "Super Bagman (Itisa, Spain)", MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE ) // Different color PROMs, needs correct decoding GAME( 1984, sbagmans, sbagman, sbagman, sbagman, bagman_state, empty_init, ROT270, "Valadon Automation (Stern Electronics license)", "Super Bagman (Stern Electronics)", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, pickin, 0, pickin, pickin, bagman_state, empty_init, ROT270, "Valadon Automation", "Pickin'", MACHINE_SUPPORTS_SAVE ) +GAME( 1983, pickin, 0, pickin, pickin, pickin_state, empty_init, ROT270, "Valadon Automation", "Pickin'", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, botanic, 0, botanic, botanici, bagman_state, empty_init, ROT90, "Itisa", "Botanic (English / Spanish, set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1983, botanic, 0, botanic, botanici, pickin_state, empty_init, ROT90, "Itisa", "Botanic (English / Spanish, set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1983, botanic2, botanic, bagman, botanici2, bagman_state, empty_init, ROT90, "Itisa", "Botanic (English / Spanish, set 2)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE ) // At the title screen, Botanic in corrupted in the first loop, OK from the second on. Colors likely wrong, too. Has a leftover 5110. -GAME( 1984, botanicf, botanic, botanic, botanicf, bagman_state, empty_init, ROT270, "Itisa (Valadon Automation license)", "Botanic (French)", MACHINE_SUPPORTS_SAVE ) +GAME( 1984, botanicf, botanic, botanic, botanicf, pickin_state, empty_init, ROT270, "Itisa (Valadon Automation license)", "Botanic (French)", MACHINE_SUPPORTS_SAVE ) GAME( 1984, squaitsa, 0, botanic, squaitsa, squaitsa_state, empty_init, ROT0, "Itisa", "Squash (Itisa)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/bagman.h b/src/mame/includes/bagman.h index db5d786a530..87c1746f3a1 100644 --- a/src/mame/includes/bagman.h +++ b/src/mame/includes/bagman.h @@ -7,6 +7,7 @@ #include "machine/74259.h" +#include "sound/ay8910.h" #include "sound/tms5110.h" #include "emupal.h" #include "tilemap.h" @@ -26,10 +27,8 @@ public: m_colorram(*this, "colorram") { } - void botanic(machine_config &config); void sbagman(machine_config &config); void bagman(machine_config &config); - void pickin(machine_config &config); void sbagmani(machine_config &config); void init_bagmans3(); @@ -67,9 +66,7 @@ protected: void bagman_base(machine_config &config); void main_map(address_map &map); void main_portmap(address_map &map); - void pickin_map(address_map &map); -private: required_device m_maincpu; required_device m_mainlatch; required_device m_gfxdecode; @@ -77,6 +74,7 @@ private: optional_device m_tmsprom; optional_device m_tmslatch; +private: required_shared_ptr m_videoram; required_shared_ptr m_colorram; @@ -96,11 +94,33 @@ private: }; -class squaitsa_state : public bagman_state +class pickin_state : public bagman_state +{ +public: + pickin_state(const machine_config &mconfig, device_type type, const char *tag) : + bagman_state(mconfig, type, tag), + m_aysnd(*this, {"aysnd", "ay2"}) + { } + + void pickin(machine_config &config); + void botanic(machine_config &config); + +private: + uint8_t aysnd_r(); + void aysnd_w(offs_t offset, uint8_t data); + + void pickin_map(address_map &map); + void pickin_portmap(address_map &map); + + required_device_array m_aysnd; +}; + + +class squaitsa_state : public pickin_state { public: squaitsa_state(const machine_config &mconfig, device_type type, const char *tag) : - bagman_state(mconfig, type, tag), + pickin_state(mconfig, type, tag), m_dial(*this, "DIAL_P%u", 1), m_res{ 0, 0 }, m_old_val{ 0, 0 }