From 65b5718e0c0c9d37d83864e169dd67734f6ee7ee Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 15 Apr 2024 03:51:12 +1000 Subject: midway/williams.cpp, midway/wmg.cpp: Fixed crash in Defender, further cleanup. * midway/williams.cpp: Fixed Defender crash on initialised view. * midway/williams.cpp, midway/wmg.cpp: Eliminated address_map_bank_device. * midway/williams.cpp: Got rid of unnecessary williams2_state derived classes. * midway/wmg.cpp: Removed dependency on defender_state. --- src/mame/midway/williams.cpp | 44 ++++++++++++------------ src/mame/midway/williams.h | 76 +++++++++++++++--------------------------- src/mame/midway/williams_m.cpp | 5 ++- src/mame/midway/wmg.cpp | 69 +++++++++++++++++++------------------- 4 files changed, 87 insertions(+), 107 deletions(-) diff --git a/src/mame/midway/williams.cpp b/src/mame/midway/williams.cpp index a95cfb663d6..1ee2a9aad91 100644 --- a/src/mame/midway/williams.cpp +++ b/src/mame/midway/williams.cpp @@ -511,24 +511,27 @@ Reference videos: https://www.youtube.com/watch?v=R5OeC6Wc_yI void defender_state::main_map(address_map &map) { map(0x0000, 0xbfff).ram().share(m_videoram); - map(0xc000, 0xcfff).m(m_bankc000, FUNC(address_map_bank_device::amap8)); + map(0xc000, 0xcfff).view(m_rom_view); + m_rom_view[0](0xc000, 0xc00f).mirror(0x03e0).writeonly().share(m_paletteram); + m_rom_view[0](0xc3ff, 0xc3ff).w(FUNC(defender_state::watchdog_reset_w)); + m_rom_view[0](0xc010, 0xc01f).mirror(0x03e0).w(FUNC(defender_state::video_control_w)); + m_rom_view[0](0xc400, 0xc4ff).mirror(0x0300).ram().w(FUNC(defender_state::cmos_w)).share("nvram"); + m_rom_view[0](0xc800, 0xcbff).r(FUNC(defender_state::video_counter_r)); + m_rom_view[0](0xcc00, 0xcc03).mirror(0x03e0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); + m_rom_view[0](0xcc04, 0xcc07).mirror(0x03e0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); + m_rom_view[1](0xc000, 0xcfff).rom().region("maincpu", 0x10000); + m_rom_view[2](0xc000, 0xcfff).rom().region("maincpu", 0x11000); + m_rom_view[3](0xc000, 0xcfff).rom().region("maincpu", 0x12000); + m_rom_view[4](0xc000, 0xcfff).rom().region("maincpu", 0x13000); + m_rom_view[5](0xc000, 0xcfff).rom().region("maincpu", 0x14000); + m_rom_view[6](0xc000, 0xcfff).rom().region("maincpu", 0x15000); + m_rom_view[7](0xc000, 0xcfff).rom().region("maincpu", 0x16000); + m_rom_view[8](0xc000, 0xcfff).rom().region("maincpu", 0x17000); + m_rom_view[9](0xc000, 0xcfff).rom().region("maincpu", 0x18000); map(0xd000, 0xdfff).w(FUNC(defender_state::bank_select_w)); map(0xd000, 0xffff).rom(); } -void defender_state::bankc000_map(address_map &map) -{ - map(0x0000, 0x000f).mirror(0x03e0).writeonly().share(m_paletteram); - map(0x03ff, 0x03ff).w(FUNC(defender_state::watchdog_reset_w)); - map(0x0010, 0x001f).mirror(0x03e0).w(FUNC(defender_state::video_control_w)); - map(0x0400, 0x04ff).mirror(0x0300).ram().w(FUNC(defender_state::cmos_w)).share("nvram"); - map(0x0800, 0x0bff).r(FUNC(defender_state::video_counter_r)); - map(0x0c00, 0x0c03).mirror(0x03e0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0x0c04, 0x0c07).mirror(0x03e0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0x1000, 0x9fff).rom().region("maincpu", 0x10000); - map(0xa000, 0xffff).noprw(); -} - /************************************* * * Mayday memory handlers @@ -661,7 +664,7 @@ void williams2_state::common_map(address_map &map) } // mysticm and inferno: D000-DFFF is RAM -void williams_d000_ram_state::d000_map(address_map &map) +void williams2_state::d000_ram_map(address_map &map) { common_map(map); map(0xd000, 0xdfff).ram(); @@ -669,7 +672,7 @@ void williams_d000_ram_state::d000_map(address_map &map) } // tshoot and joust2: D000-DFFF is ROM -void williams_d000_rom_state::d000_map(address_map &map) +void williams2_state::d000_rom_map(address_map &map) { common_map(map); map(0xd000, 0xffff).rom(); @@ -1619,7 +1622,6 @@ void defender_state::defender(machine_config &config) { williams_b0(config); - ADDRESS_MAP_BANK(config, m_bankc000).set_map(&defender_state::bankc000_map).set_options(ENDIANNESS_BIG, 8, 16, 0x1000); m_screen->set_visarea(12, 304-1, 7, 247-1); } @@ -1870,7 +1872,7 @@ void williams2_state::williams2_base(machine_config &config) void inferno_state::inferno(machine_config &config) { williams2_base(config); - m_maincpu->set_addrmap(AS_PROGRAM, &inferno_state::d000_map); + m_maincpu->set_addrmap(AS_PROGRAM, &inferno_state::d000_ram_map); // pia m_pia[0]->readpa_handler().set("mux", FUNC(ls157_x2_device::output_r)); @@ -1886,7 +1888,7 @@ void inferno_state::inferno(machine_config &config) void mysticm_state::mysticm(machine_config &config) { williams2_base(config); - m_maincpu->set_addrmap(AS_PROGRAM, &mysticm_state::d000_map); + m_maincpu->set_addrmap(AS_PROGRAM, &mysticm_state::d000_ram_map); m_screen->set_raw(MASTER_CLOCK*2/3, 512, 8, 284, 256, 8, 248); m_screen->set_screen_update(FUNC(mysticm_state::screen_update)); @@ -1904,7 +1906,7 @@ void tshoot_state::tshoot(machine_config &config) williams2_base(config); // basic machine hardware - m_maincpu->set_addrmap(AS_PROGRAM, &tshoot_state::d000_map); + m_maincpu->set_addrmap(AS_PROGRAM, &tshoot_state::d000_rom_map); // pia m_pia[0]->readpa_handler().set("mux", FUNC(ls157_x2_device::output_r)); @@ -1928,7 +1930,7 @@ void joust2_state::joust2(machine_config &config) williams2_base(config); // basic machine hardware - m_maincpu->set_addrmap(AS_PROGRAM, &joust2_state::d000_map); + m_maincpu->set_addrmap(AS_PROGRAM, &joust2_state::d000_rom_map); S11_OBG(config, m_bg).add_route(ALL_OUTPUTS, "speaker", 2.0); // D-11298-3035 'pinbot style' older BG sound board // Jumpers for the board: W1=? W2=open W3=present W4=open W5=open W6=open W7=present diff --git a/src/mame/midway/williams.h b/src/mame/midway/williams.h index a62e3a6afa1..53585307537 100644 --- a/src/mame/midway/williams.h +++ b/src/mame/midway/williams.h @@ -17,7 +17,6 @@ #include "cpu/m6809/m6809.h" #include "machine/6821pia.h" #include "machine/74157.h" -#include "machine/bankdev.h" #include "machine/ticket.h" #include "machine/timer.h" #include "machine/watchdog.h" @@ -42,7 +41,6 @@ public: m_pia(*this, "pia_%u", 0U), m_nvram(*this, "nvram"), m_videoram(*this, "videoram"), - m_mainbank(*this, "mainbank"), m_rom_view(*this, "rom_view"), m_49way_x(*this, "49WAYX"), m_49way_y(*this, "49WAYY") @@ -100,7 +98,6 @@ protected: required_shared_ptr m_nvram; required_shared_ptr m_videoram; - optional_memory_bank m_mainbank; memory_view m_rom_view; @@ -140,8 +137,7 @@ class defender_state : public williams_state { public: defender_state(const machine_config &mconfig, device_type type, const char *tag) : - williams_state(mconfig, type, tag), - m_bankc000(*this, "bankc000") + williams_state(mconfig, type, tag) { } void defender(machine_config &config); @@ -155,13 +151,9 @@ protected: void video_control_w(u8 data); - required_device m_bankc000; - private: - virtual void machine_start() override { } virtual void machine_reset() override; - void bankc000_map(address_map &map); virtual void sound_map(address_map &map) override; virtual void sound_map_6802(address_map &map); @@ -285,7 +277,8 @@ public: blaster_state(const machine_config &mconfig, device_type type, const char *tag) : williams_state(mconfig, type, tag), m_muxa(*this, "mux_a"), - m_muxb(*this, "mux_b") + m_muxb(*this, "mux_b"), + m_mainbank(*this, "mainbank") { } void blastkit(machine_config &config); @@ -299,6 +292,7 @@ protected: private: required_device m_muxa; optional_device m_muxb; + required_memory_bank m_mainbank; rgb_t m_color0; uint8_t m_video_control; @@ -319,10 +313,21 @@ private: class williams2_state : public williams_state { public: + INPUT_CHANGED_MEMBER(rgb_gain) + { + if (param < 3) + m_gain[param] = float(newval) / 100.0f; + else + m_offset[param - 3] = (float(newval) / 100.0f) - 1.0f; + rebuild_palette(); + } + +protected: williams2_state(const machine_config &mconfig, device_type type, const char *tag) : williams_state(mconfig, type, tag), m_gfxdecode(*this, "gfxdecode"), m_tileram(*this, "tileram"), + m_mainbank(*this, "mainbank"), m_palette_view(*this, "palette_view"), m_gain( { 0.25f, 0.25f, 0.25f }), m_offset({ 0.00f, 0.00f, 0.00f }) @@ -330,22 +335,13 @@ public: void williams2_base(machine_config &config); - INPUT_CHANGED_MEMBER(rgb_gain) - { - if (param < 3) - m_gain[param] = float(newval) / 100.0f; - else - m_offset[param - 3] = (float(newval) / 100.0f) - 1.0f; - rebuild_palette(); - } - -protected: virtual void machine_start() override; virtual void machine_reset() override; virtual void video_start() override; required_device m_gfxdecode; required_shared_ptr m_tileram; + required_memory_bank m_mainbank; memory_view m_palette_view; @@ -379,39 +375,19 @@ protected: virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override; void common_map(address_map &map); + void d000_rom_map(address_map &map); + void d000_ram_map(address_map &map); virtual void sound_map(address_map &map) override; void video_control_w(u8 data); }; -class williams_d000_rom_state : public williams2_state -{ -public: - williams_d000_rom_state(const machine_config &mconfig, device_type type, const char *tag) : - williams2_state(mconfig, type, tag) - { } - -protected: - void d000_map(address_map &map); -}; - -class williams_d000_ram_state : public williams2_state -{ -public: - williams_d000_ram_state(const machine_config &mconfig, device_type type, const char *tag) : - williams2_state(mconfig, type, tag) - { } - -protected: - void d000_map(address_map &map); -}; - // Inferno -class inferno_state : public williams_d000_ram_state +class inferno_state : public williams2_state { public: inferno_state(const machine_config &mconfig, device_type type, const char *tag) : - williams_d000_ram_state(mconfig, type, tag), + williams2_state(mconfig, type, tag), m_mux(*this, "mux") { } @@ -422,11 +398,11 @@ private: }; // Mystic Marathon -class mysticm_state : public williams_d000_ram_state +class mysticm_state : public williams2_state { public: mysticm_state(const machine_config &mconfig, device_type type, const char *tag) : - williams_d000_ram_state(mconfig, type, tag) + williams2_state(mconfig, type, tag) { // overwrite defaults for mysticm m_gain = { 0.8f, 0.73f, 0.81f }; @@ -448,11 +424,11 @@ private: }; // Turkey Shoot -class tshoot_state : public williams_d000_rom_state +class tshoot_state : public williams2_state { public: tshoot_state(const machine_config &mconfig, device_type type, const char *tag) : - williams_d000_rom_state(mconfig, type, tag), + williams2_state(mconfig, type, tag), m_mux(*this, "mux"), m_gun(*this, {"GUNX", "GUNY"}), m_grenade_lamp(*this, "Grenade_lamp"), @@ -480,11 +456,11 @@ private: }; // Joust 2 -class joust2_state : public williams_d000_rom_state +class joust2_state : public williams2_state { public: joust2_state(const machine_config &mconfig, device_type type, const char *tag) : - williams_d000_rom_state(mconfig, type, tag), + williams2_state(mconfig, type, tag), m_mux(*this, "mux"), m_bg(*this, "bg") { } diff --git a/src/mame/midway/williams_m.cpp b/src/mame/midway/williams_m.cpp index 1428be448aa..6e5bb62dbc6 100644 --- a/src/mame/midway/williams_m.cpp +++ b/src/mame/midway/williams_m.cpp @@ -327,7 +327,10 @@ void defender_state::video_control_w(u8 data) void defender_state::bank_select_w(u8 data) { - m_bankc000->set_bank(data & 0x0f); + if ((data & 0x0f) < 10) + m_rom_view.select(data & 0x0f); + else + m_rom_view.disable(); } diff --git a/src/mame/midway/wmg.cpp b/src/mame/midway/wmg.cpp index e2803245dfc..a5f35e9823d 100644 --- a/src/mame/midway/wmg.cpp +++ b/src/mame/midway/wmg.cpp @@ -81,15 +81,17 @@ of save-state is also needed. namespace { -class wmg_state : public defender_state +class wmg_state : public williams_state { public: wmg_state(const machine_config &mconfig, device_type type, const char *tag) - : defender_state(mconfig, type, tag) - , m_p_ram(*this, "nvram") + : williams_state(mconfig, type, tag) + , m_p_ram(*this, "nvram", 0x2000, ENDIANNESS_BIG) , m_keyboard(*this, "X%d", 0U) + , m_mainbank(*this, "mainbank") , m_codebank(*this, "codebank") , m_soundbank(*this, "soundbank") + , m_io_view(*this, "io_view") { } void wmg(machine_config &config); @@ -101,10 +103,12 @@ protected: virtual void machine_reset() override; private: - required_shared_ptr m_p_ram; + memory_share_creator m_p_ram; required_ioport_array<17> m_keyboard; + required_memory_bank m_mainbank; required_memory_bank m_codebank; required_memory_bank m_soundbank; + memory_view m_io_view; uint8_t m_wmg_c400 = 0U; uint8_t m_wmg_d000 = 0U; @@ -123,7 +127,6 @@ private: void wmg_cpu1(address_map &map); void wmg_cpu2(address_map &map); void wmg_banked_map(address_map &map); - }; @@ -138,7 +141,22 @@ void wmg_state::wmg_cpu1(address_map &map) map(0x0000, 0xbfff).ram().share(m_videoram); map(0x0000, 0x8fff).view(m_rom_view); m_rom_view[0](0x0000, 0x8fff).bankr(m_mainbank); - map(0xc000, 0xcfff).m(m_bankc000, FUNC(address_map_bank_device::amap8)); + map(0xc000, 0xcfff).view(m_io_view); + m_io_view[0](0xc000, 0xc00f).mirror(0x03e0).writeonly().share(m_paletteram); + m_io_view[0](0xc010, 0xc01f).mirror(0x03e0).lw8(NAME([this] (u8 data) { m_cocktail = BIT(data, 0); })); // TODO: should this really be here? m_cocktail is set in wmg_vram_select_w + m_io_view[0](0xc400, 0xc400).w(FUNC(wmg_state::wmg_c400_w)); + m_io_view[0](0xc401, 0xc401).w(FUNC(wmg_state::wmg_sound_reset_w)); + m_io_view[0](0xc804, 0xc807).r(FUNC(wmg_state::wmg_pia_0_r)).w(m_pia[0], FUNC(pia6821_device::write)); + m_io_view[0](0xc80c, 0xc80f).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); + m_io_view[0](0xc900, 0xc9ff).nopr().w(FUNC(wmg_state::wmg_vram_select_w)); + m_io_view[0](0xca00, 0xca07).w(FUNC(wmg_state::wmg_blitter_w)); + m_io_view[0](0xcb00, 0xcbff).r(FUNC(wmg_state::video_counter_r)); + m_io_view[0](0xcbff, 0xcbff).w(FUNC(wmg_state::watchdog_reset_w)); + m_io_view[0](0xcc00, 0xcfff).rw(FUNC(wmg_state::wmg_nvram_r), FUNC(wmg_state::wmg_nvram_w)); + m_io_view[1](0xc000, 0xcfff).rom().region("maincpu", 0x58000); // Defender ROMs + m_io_view[2](0xc000, 0xcfff).rom().region("maincpu", 0x59000); + m_io_view[3](0xc000, 0xcfff).rom().region("maincpu", 0x5a000); + m_io_view[4](0xc000, 0xcfff).rom().region("maincpu", 0x5b000); map(0xd000, 0xffff).bankr(m_codebank); map(0xd000, 0xd000).w(FUNC(wmg_state::wmg_d000_w)); } @@ -151,24 +169,6 @@ void wmg_state::wmg_cpu2(address_map &map) map(0xf000, 0xffff).bankr(m_soundbank); } -void wmg_state::wmg_banked_map(address_map &map) -{ - map(0x0000, 0x000f).mirror(0x03e0).writeonly().share(m_paletteram); - map(0x0010, 0x001f).mirror(0x03e0).w(FUNC(wmg_state::video_control_w)); - map(0x0400, 0x0400).w(FUNC(wmg_state::wmg_c400_w)); - map(0x0401, 0x0401).w(FUNC(wmg_state::wmg_sound_reset_w)); - map(0x0804, 0x0807).r(FUNC(wmg_state::wmg_pia_0_r)).w(m_pia[0], FUNC(pia6821_device::write)); - map(0x080c, 0x080f).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0x0900, 0x09ff).nopr().w(FUNC(wmg_state::wmg_vram_select_w)); - map(0x0a00, 0x0a07).w(FUNC(wmg_state::wmg_blitter_w)); - map(0x0b00, 0x0bff).r(FUNC(wmg_state::video_counter_r)); - map(0x0bff, 0x0bff).w(FUNC(wmg_state::watchdog_reset_w)); - map(0x0c00, 0x0fff).rw(FUNC(wmg_state::wmg_nvram_r), FUNC(wmg_state::wmg_nvram_w)); - map(0x1000, 0x4fff).rom().region("maincpu", 0x58000); // Defender roms - // This one is actually banked in CPU 1, but its not something Mame can handle very well. Placed here instead. - map(0xd000, 0xefff).ram().share("nvram"); -} - /*************************************************************** * * Inputs, banked. One set for each game. @@ -407,23 +407,21 @@ void wmg_state::wmg_d000_w(u8 data) case 1: case 2: case 3: - m_bankc000->set_bank(data); + m_io_view.select(data); break; case 7: - m_bankc000->set_bank(4); + m_io_view.select(4); break; default: - printf("Unknown bank %X selected\n",data); + logerror("Unknown bank %X selected\n",data); } } - else - // everything else - choose i/o space - if (data == 0) + else if (data == 0) { - /* install the i/o devices into c000-cfff */ - m_bankc000->set_bank(0); + // everything else - choose i/o space + m_io_view.select(0); } m_wmg_d000 = data; @@ -432,6 +430,8 @@ void wmg_state::wmg_d000_w(u8 data) void wmg_state::machine_start() { + williams_state::machine_start(); + uint8_t *cpu = memregion("maincpu")->base(); uint8_t *snd = memregion("soundcpu")->base(); m_mainbank->configure_entries(0, 8, &cpu[0x00000], 0x10000); // Gfx etc @@ -445,10 +445,11 @@ void wmg_state::machine_start() void wmg_state::machine_reset() { + williams_state::machine_reset(); + m_wmg_c400 = 0xff; m_wmg_d000 = 0xff; m_port_select = 0; - m_rom_view.disable(); wmg_c400_w(0); m_maincpu->reset(); } @@ -519,8 +520,6 @@ void wmg_state::wmg(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); - ADDRESS_MAP_BANK(config, m_bankc000).set_map(&wmg_state::wmg_banked_map).set_options(ENDIANNESS_BIG, 8, 16, 0x1000); - // set a timer to go off every 32 scanlines, to toggle the VA11 line and update the screen TIMER(config, "scan_timer").configure_scanline(FUNC(wmg_state::va11_callback), "screen", 0, 32); -- cgit v1.2.3