From 06ed986b2ca70dfd9c2a3a2abde8b14513799044 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Tue, 24 Dec 2019 09:31:02 +0100 Subject: [PATCH] -williams: Eliminated MACHINE_*_OVERRIDE and VIDEO_START_OVERRIDE. Eliminated magic switches on tilemap config for williams2. Added numerous subclasses to reduce optional device usage and reduce custom driver init callbacks, nw --- src/mame/drivers/williams.cpp | 500 +++++++++++++++++----------------- src/mame/includes/williams.h | 410 +++++++++++++++++++--------- src/mame/machine/williams.cpp | 141 +++++----- src/mame/video/williams.cpp | 211 +++++++------- 4 files changed, 696 insertions(+), 566 deletions(-) diff --git a/src/mame/drivers/williams.cpp b/src/mame/drivers/williams.cpp index dbe1342bf1f..d4949eaf9c3 100644 --- a/src/mame/drivers/williams.cpp +++ b/src/mame/drivers/williams.cpp @@ -521,28 +521,39 @@ Reference video: https://www.youtube.com/watch?v=R5OeC6Wc_yI * *************************************/ -void williams_state::defender_map(address_map &map) +void defender_state::main_map(address_map &map) { map(0x0000, 0xbfff).ram().share("videoram"); map(0xc000, 0xcfff).m(m_bankc000, FUNC(address_map_bank_device::amap8)); - map(0xd000, 0xdfff).w(FUNC(williams_state::defender_bank_select_w)); + map(0xd000, 0xdfff).w(FUNC(defender_state::bank_select_w)); map(0xd000, 0xffff).rom(); } - -void williams_state::defender_bankc000_map(address_map &map) +void defender_state::bankc000_map(address_map &map) { map(0x0000, 0x000f).mirror(0x03e0).writeonly().share("paletteram"); - map(0x03ff, 0x03ff).w(FUNC(williams_state::williams_watchdog_reset_w)); - map(0x0010, 0x001f).mirror(0x03e0).w(FUNC(williams_state::defender_video_control_w)); - map(0x0400, 0x04ff).mirror(0x0300).ram().w(FUNC(williams_state::williams_cmos_w)).share("nvram"); - map(0x0800, 0x0bff).r(FUNC(williams_state::williams_video_counter_r)); + 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 + * + *************************************/ + +void mayday_state::main_map(address_map &map) +{ + defender_state::main_map(map); + /* install a handler to catch protection checks */ + map(0xa190, 0xa191).r(FUNC(mayday_state::protection_r)); +} /************************************* @@ -551,18 +562,18 @@ void williams_state::defender_bankc000_map(address_map &map) * *************************************/ -void williams_state::williams_map(address_map &map) +void williams_state::base_map(address_map &map) { map(0x0000, 0x8fff).bankr("mainbank").writeonly().share("videoram"); map(0x9000, 0xbfff).ram(); map(0xc000, 0xc00f).mirror(0x03f0).writeonly().share("paletteram"); map(0xc804, 0xc807).mirror(0x00f0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); map(0xc80c, 0xc80f).mirror(0x00f0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0xc900, 0xc9ff).w(FUNC(williams_state::williams_vram_select_w)); - map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(williams_state::williams_blitter_w)); - map(0xcb00, 0xcbff).r(FUNC(williams_state::williams_video_counter_r)); - map(0xcbff, 0xcbff).w(FUNC(williams_state::williams_watchdog_reset_w)); - map(0xcc00, 0xcfff).ram().w(FUNC(williams_state::williams_cmos_w)).share("nvram"); + map(0xc900, 0xc9ff).w(FUNC(williams_state::vram_select_w)); + map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(williams_state::blitter_w)); + map(0xcb00, 0xcbff).r(FUNC(williams_state::video_counter_r)); + map(0xcbff, 0xcbff).w(FUNC(williams_state::watchdog_reset_w)); + map(0xcc00, 0xcfff).ram().w(FUNC(williams_state::cmos_w)).share("nvram"); map(0xd000, 0xffff).rom(); } @@ -574,23 +585,27 @@ void williams_state::williams_map(address_map &map) * *************************************/ -void williams_state::sinistar_map(address_map &map) +void sinistar_state::main_map(address_map &map) { - map(0x0000, 0x8fff).bankr("mainbank").writeonly().share("videoram"); - map(0x9000, 0xbfff).ram(); - map(0xc000, 0xc00f).mirror(0x03f0).writeonly().share("paletteram"); - map(0xc804, 0xc807).mirror(0x00f0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0xc80c, 0xc80f).mirror(0x00f0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0xc900, 0xc9ff).w(FUNC(williams_state::sinistar_vram_select_w)); - map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(williams_state::williams_blitter_w)); - map(0xcb00, 0xcbff).r(FUNC(williams_state::williams_video_counter_r)); - map(0xcbff, 0xcbff).w(FUNC(williams_state::williams_watchdog_reset_w)); - map(0xcc00, 0xcfff).ram().w(FUNC(williams_state::williams_cmos_w)).share("nvram"); + base_map(map); + map(0xc900, 0xc9ff).w(FUNC(sinistar_state::vram_select_w)); map(0xd000, 0xdfff).ram(); map(0xe000, 0xffff).rom(); } +/************************************* + * + * Bubbles memory handlers + * + *************************************/ + +void bubbles_state::main_map(address_map &map) +{ + base_map(map); + /* bubbles has a full 8-bit-wide CMOS */ + map(0xcc00, 0xcfff).w(FUNC(bubbles_state::cmos_w)).share("nvram"); +} /************************************* * @@ -598,9 +613,9 @@ void williams_state::sinistar_map(address_map &map) * *************************************/ -void spdball_state::spdball_map(address_map &map) +void spdball_state::main_map(address_map &map) { - williams_map(map); + base_map(map); /* install extra input handlers */ map(0xc800, 0xc800).portr("AN0"); map(0xc801, 0xc801).portr("AN1"); @@ -618,7 +633,7 @@ void spdball_state::spdball_map(address_map &map) * *************************************/ -void blaster_state::blaster_map(address_map &map) +void blaster_state::main_map(address_map &map) { map(0x0000, 0x3fff).bankr("mainbank").writeonly().share("videoram"); map(0x4000, 0x8fff).bankr("blaster_bankb").writeonly(); @@ -629,14 +644,14 @@ void blaster_state::blaster_map(address_map &map) map(0xc000, 0xc00f).mirror(0x03f0).writeonly().share("paletteram"); map(0xc804, 0xc807).mirror(0x00f0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); map(0xc80c, 0xc80f).mirror(0x00f0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0xc900, 0xc93f).w(FUNC(blaster_state::blaster_vram_select_w)); - map(0xc940, 0xc97f).w(FUNC(blaster_state::blaster_remap_select_w)); - map(0xc980, 0xc9bf).w(FUNC(blaster_state::blaster_bank_select_w)); - map(0xc9c0, 0xc9ff).w(FUNC(blaster_state::blaster_video_control_w)); - map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(blaster_state::williams_blitter_w)); - map(0xcb00, 0xcbff).r(FUNC(blaster_state::williams_video_counter_r)); - map(0xcbff, 0xcbff).w(FUNC(blaster_state::williams_watchdog_reset_w)); - map(0xcc00, 0xcfff).ram().w(FUNC(blaster_state::williams_cmos_w)).share("nvram"); + map(0xc900, 0xc93f).w(FUNC(blaster_state::vram_select_w)); + map(0xc940, 0xc97f).w(FUNC(blaster_state::remap_select_w)); + map(0xc980, 0xc9bf).w(FUNC(blaster_state::bank_select_w)); + map(0xc9c0, 0xc9ff).w(FUNC(blaster_state::video_control_w)); + map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(blaster_state::blitter_w)); + map(0xcb00, 0xcbff).r(FUNC(blaster_state::video_counter_r)); + map(0xcbff, 0xcbff).w(FUNC(blaster_state::watchdog_reset_w)); + map(0xcc00, 0xcfff).ram().w(FUNC(blaster_state::cmos_w)).share("nvram"); map(0xd000, 0xffff).rom(); } @@ -648,48 +663,48 @@ void blaster_state::blaster_map(address_map &map) * *************************************/ -void williams2_state::williams2_common_map(address_map &map) +void williams2_state::common_map(address_map &map) { map(0x0000, 0xbfff).ram().share("videoram"); map(0x0000, 0x7fff).bankr("mainbank"); map(0x8000, 0x87ff).m(m_bank8000, FUNC(address_map_bank_device::amap8)); - map(0xc000, 0xc7ff).ram().w(FUNC(williams2_state::williams2_tileram_w)).share("williams2_tile"); - map(0xc800, 0xc87f).w(FUNC(williams2_state::williams2_bank_select_w)); - map(0xc880, 0xc887).mirror(0x0078).w(FUNC(williams2_state::williams_blitter_w)); - map(0xc900, 0xc97f).w(FUNC(williams2_state::williams2_watchdog_reset_w)); + map(0xc000, 0xc7ff).ram().w(FUNC(williams2_state::tileram_w)).share("williams2_tile"); + map(0xc800, 0xc87f).w(FUNC(williams2_state::bank_select_w)); + map(0xc880, 0xc887).mirror(0x0078).w(FUNC(williams2_state::blitter_w)); + map(0xc900, 0xc97f).w(FUNC(williams2_state::watchdog_reset_w)); map(0xc980, 0xc983).mirror(0x0070).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); map(0xc984, 0xc987).mirror(0x0070).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); - map(0xc98c, 0xc98f).mirror(0x0070).w(FUNC(williams2_state::williams2_7segment_w)); - map(0xcb00, 0xcb1f).w(FUNC(williams2_state::williams2_fg_select_w)); - map(0xcb20, 0xcb3f).w(FUNC(williams2_state::williams2_bg_select_w)); - map(0xcb40, 0xcb5f).w(FUNC(williams2_state::williams2_xscroll_low_w)); - map(0xcb60, 0xcb7f).w(FUNC(williams2_state::williams2_xscroll_high_w)); - map(0xcb80, 0xcb9f).w(FUNC(williams2_state::defender_video_control_w)); - map(0xcba0, 0xcbbf).w(FUNC(williams2_state::williams2_blit_window_enable_w)); - map(0xcbe0, 0xcbef).r(FUNC(williams2_state::williams_video_counter_r)); - map(0xcc00, 0xcfff).ram().w(FUNC(williams2_state::williams_cmos_w)).share("nvram"); + map(0xc98c, 0xc98f).mirror(0x0070).w(FUNC(williams2_state::segments_w)); + map(0xcb00, 0xcb1f).w(FUNC(williams2_state::fg_select_w)); + map(0xcb20, 0xcb3f).w(FUNC(williams2_state::bg_select_w)); + map(0xcb40, 0xcb5f).w(FUNC(williams2_state::xscroll_low_w)); + map(0xcb60, 0xcb7f).w(FUNC(williams2_state::xscroll_high_w)); + map(0xcb80, 0xcb9f).w(FUNC(williams2_state::video_control_w)); + map(0xcba0, 0xcbbf).w(FUNC(williams2_state::blit_window_enable_w)); + map(0xcbe0, 0xcbef).r(FUNC(williams2_state::video_counter_r)); + map(0xcc00, 0xcfff).ram().w(FUNC(williams2_state::cmos_w)).share("nvram"); } -void williams2_state::williams2_bank8000_map(address_map &map) +void williams2_state::bank8000_map(address_map &map) { map(0x0000, 0x07ff).bankrw("vram8000"); - map(0x0800, 0x0fff).ram().w(FUNC(williams2_state::williams2_paletteram_w)).share("paletteram"); + map(0x0800, 0x0fff).ram().w(FUNC(williams2_state::paletteram_w)).share("paletteram"); } /* mysticm and inferno: D000-DFFF is RAM */ -void williams2_state::williams2_d000_ram_map(address_map &map) +void williams_d000_ram_state::d000_map(address_map &map) { - williams2_common_map(map); + common_map(map); map(0xd000, 0xdfff).ram(); map(0xe000, 0xffff).rom(); } /* tshoot and joust2: D000-DFFF is ROM */ -void williams2_state::williams2_d000_rom_map(address_map &map) +void williams_d000_rom_state::d000_map(address_map &map) { - williams2_common_map(map); + common_map(map); map(0xd000, 0xffff).rom(); } @@ -701,7 +716,7 @@ void williams2_state::williams2_d000_rom_map(address_map &map) * *************************************/ -void williams_state::defender_sound_map(address_map &map) +void defender_state::sound_map(address_map &map) { map(0x0000, 0x007f).ram(); /* internal RAM */ map(0x0400, 0x0403).mirror(0x8000).rw(m_pia[2], FUNC(pia6821_device::read), FUNC(pia6821_device::write)); @@ -718,7 +733,7 @@ void williams_state::sound_map(address_map &map) } /* Same as above, but for second sound board */ -void blaster_state::sound_map_b(address_map &map) +void blaster_state::sound2_map(address_map &map) { map(0x0000, 0x007f).ram(); /* internal RAM */ map(0x0080, 0x00ff).ram(); /* MC6810 RAM */ @@ -734,7 +749,7 @@ void blaster_state::sound_map_b(address_map &map) * *************************************/ -void williams2_state::williams2_sound_map(address_map &map) +void williams2_state::sound_map(address_map &map) { map(0x0000, 0x007f).ram(); /* internal RAM */ map(0x0080, 0x00ff).ram(); /* MC6810 RAM */ @@ -1090,10 +1105,10 @@ static INPUT_PORTS_START( sinistar ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_START("49WAYX") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYX") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_X ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) - PORT_START("49WAYY") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYY") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE INPUT_PORTS_END @@ -1152,10 +1167,10 @@ static INPUT_PORTS_START( blaster ) PORT_START("INP2") PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_START("49WAYX") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYX") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_X ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) - PORT_START("49WAYY") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYY") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE INPUT_PORTS_END @@ -1178,10 +1193,10 @@ static INPUT_PORTS_START( blastkit ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_START("49WAYX") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYX") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_X ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) - PORT_START("49WAYY") /* converted by williams_49way_port_0_r() */ + PORT_START("49WAYY") /* converted by port_0_49way_r() */ PORT_BIT( 0xff, 0x38, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0x6f) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_REVERSE PORT_START("IN3") @@ -1489,23 +1504,22 @@ GFXDECODE_END * *************************************/ -void williams_state::williams(machine_config &config) +void williams_state::williams_base(machine_config &config) { /* basic machine hardware */ MC6809E(config, m_maincpu, MASTER_CLOCK/3/4); - m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::williams_map); + m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::base_map); M6808(config, m_soundcpu, SOUND_CLOCK); // internal clock divider of 4, effective frequency is 894.886kHz m_soundcpu->set_addrmap(AS_PROGRAM, &williams_state::sound_map); - MCFG_MACHINE_START_OVERRIDE(williams_state,williams) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // 5101 (Defender), 5114 or 6514 (later games) + battery // 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(williams_state::williams_va11_callback), "screen", 0, 32); + TIMER(config, "scan_timer").configure_scanline(FUNC(williams_state::va11_callback), "screen", 0, 32); // also set a timer to go off on scanline 240 - TIMER(config, "240_timer").configure_scanline(FUNC(williams_state::williams_count240_callback), "screen", 0, 240); + TIMER(config, "240_timer").configure_scanline(FUNC(williams_state::count240_callback), "screen", 0, 240); WATCHDOG_TIMER(config, m_watchdog); @@ -1513,11 +1527,9 @@ void williams_state::williams(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_video_attributes(VIDEO_UPDATE_SCANLINE | VIDEO_ALWAYS_UPDATE); m_screen->set_raw(MASTER_CLOCK*2/3, 512, 6, 298, 260, 7, 247); - m_screen->set_screen_update(FUNC(williams_state::screen_update_williams)); + m_screen->set_screen_update(FUNC(williams_state::screen_update)); - MCFG_VIDEO_START_OVERRIDE(williams_state,williams) - - PALETTE(config, m_palette, FUNC(williams_state::williams_palette), 256); + PALETTE(config, m_palette, FUNC(williams_state::palette_init), 256); /* sound hardware */ SPEAKER(config, "speaker").front_center(); @@ -1537,7 +1549,7 @@ void williams_state::williams(machine_config &config) PIA6821(config, m_pia[1], 0); m_pia[1]->readpa_handler().set_ioport("IN2"); - m_pia[1]->writepb_handler().set(FUNC(williams_state::williams_snd_cmd_w)); + m_pia[1]->writepb_handler().set(FUNC(williams_state::snd_cmd_w)); m_pia[1]->irqa_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<0>)); m_pia[1]->irqb_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<1>)); @@ -1548,26 +1560,22 @@ void williams_state::williams(machine_config &config) } -void williams_state::defender(machine_config &config) +void defender_state::defender(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::defender_map); + m_maincpu->set_addrmap(AS_PROGRAM, &defender_state::main_map); + m_soundcpu->set_addrmap(AS_PROGRAM, &defender_state::sound_map); - m_soundcpu->set_addrmap(AS_PROGRAM, &williams_state::defender_sound_map); - - ADDRESS_MAP_BANK(config, "bankc000").set_map(&williams_state::defender_bankc000_map).set_options(ENDIANNESS_BIG, 8, 16, 0x1000); - - MCFG_MACHINE_START_OVERRIDE(williams_state,defender) - MCFG_MACHINE_RESET_OVERRIDE(williams_state,defender) + 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); } -void williams_state::jin(machine_config &config) // needs a different screen size or the credit text is clipped +void defender_state::jin(machine_config &config) // needs a different screen size or the credit text is clipped { defender(config); /* basic machine hardware */ @@ -1575,9 +1583,9 @@ void williams_state::jin(machine_config &config) // needs a different screen si } -void williams_state::williams_muxed(machine_config &config) +void williams_muxed_state::williams_muxed(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ @@ -1602,10 +1610,10 @@ void williams_state::williams_muxed(machine_config &config) void spdball_state::spdball(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &spdball_state::spdball_map); + m_maincpu->set_addrmap(AS_PROGRAM, &spdball_state::main_map); /* pia */ PIA6821(config, m_pia[3], 0); @@ -1616,7 +1624,7 @@ void spdball_state::spdball(machine_config &config) void williams_state::lottofun(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ @@ -1628,27 +1636,36 @@ void williams_state::lottofun(machine_config &config) } -void williams_state::sinistar(machine_config &config) +void sinistar_state::sinistar(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::sinistar_map); + m_maincpu->set_addrmap(AS_PROGRAM, &sinistar_state::main_map); /* sound hardware */ HC55516(config, "cvsd", 0).add_route(ALL_OUTPUTS, "speaker", 0.8); /* pia */ - m_pia[0]->readpa_handler().set(FUNC(williams_state::williams_49way_port_0_r)); + m_pia[0]->readpa_handler().set(FUNC(williams_state::port_0_49way_r)); m_pia[2]->ca2_handler().set("cvsd", FUNC(hc55516_device::digit_w)); m_pia[2]->cb2_handler().set("cvsd", FUNC(hc55516_device::clock_w)); } -void williams_state::playball(machine_config &config) +void bubbles_state::bubbles(machine_config &config) // has a full 8-bit NVRAM equipped { - williams(config); + williams_base(config); + + /* basic machine hardware */ + m_maincpu->set_addrmap(AS_PROGRAM, &bubbles_state::main_map); +} + + +void playball_state::playball(machine_config &config) +{ + williams_base(config); /* basic machine hardware */ @@ -1659,7 +1676,7 @@ void williams_state::playball(machine_config &config) HC55516(config, "cvsd", 0).add_route(ALL_OUTPUTS, "speaker", 0.8); /* pia */ - m_pia[1]->writepb_handler().set(FUNC(williams_state::playball_snd_cmd_w)); + m_pia[1]->writepb_handler().set(FUNC(playball_state::snd_cmd_w)); m_pia[2]->ca2_handler().set("cvsd", FUNC(hc55516_device::digit_w)); m_pia[2]->cb2_handler().set("cvsd", FUNC(hc55516_device::clock_w)); @@ -1668,16 +1685,13 @@ void williams_state::playball(machine_config &config) void blaster_state::blastkit(machine_config &config) { - williams(config); + williams_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &blaster_state::blaster_map); - - MCFG_MACHINE_START_OVERRIDE(blaster_state,blaster) + m_maincpu->set_addrmap(AS_PROGRAM, &blaster_state::main_map); /* video hardware */ - MCFG_VIDEO_START_OVERRIDE(blaster_state,blaster) - m_screen->set_screen_update(FUNC(blaster_state::screen_update_blaster)); + m_screen->set_screen_update(FUNC(blaster_state::screen_update)); /* pia */ m_pia[0]->readpa_handler().set("mux_a", FUNC(ls157_x2_device::output_r)); @@ -1687,7 +1701,7 @@ void blaster_state::blastkit(machine_config &config) LS157_X2(config, m_muxa, 0); m_muxa->a_in_callback().set_ioport("IN3"); - m_muxa->b_in_callback().set(FUNC(williams_state::williams_49way_port_0_r)); + m_muxa->b_in_callback().set(FUNC(williams_state::port_0_49way_r)); } @@ -1697,7 +1711,7 @@ void blaster_state::blaster(machine_config &config) /* basic machine hardware */ M6808(config, m_soundcpu_b, SOUND_CLOCK); // internal clock divider of 4, effective frequency is 894.886kHz - m_soundcpu_b->set_addrmap(AS_PROGRAM, &blaster_state::sound_map_b); + m_soundcpu_b->set_addrmap(AS_PROGRAM, &blaster_state::sound2_map); /* pia */ m_pia[0]->readpb_handler().set("mux_b", FUNC(ls157_device::output_r)).mask(0x0f); @@ -1706,7 +1720,7 @@ void blaster_state::blaster(machine_config &config) m_pia[0]->cb2_handler().append("mux_b", FUNC(ls157_device::select_w)); // IC7 (for PA0-PA3) + IC5 (for PA4-PA7) - m_muxa->a_in_callback().set(FUNC(williams_state::williams_49way_port_0_r)); + m_muxa->a_in_callback().set(FUNC(williams_state::port_0_49way_r)); m_muxa->b_in_callback().set_ioport("IN3"); LS157(config, m_muxb, 0); // IC3 @@ -1715,7 +1729,7 @@ void blaster_state::blaster(machine_config &config) INPUT_MERGER_ANY_HIGH(config, "soundirq_b").output_handler().set_inputline(m_soundcpu_b, M6808_IRQ_LINE); - m_pia[1]->writepb_handler().set(FUNC(blaster_state::blaster_snd_cmd_w)); + m_pia[1]->writepb_handler().set(FUNC(blaster_state::snd_cmd_w)); m_pia[2]->writepa_handler().set("ldac", FUNC(dac_byte_interface::data_w)); @@ -1739,26 +1753,23 @@ void blaster_state::blaster(machine_config &config) } -void williams2_state::williams2(machine_config &config) +void williams2_state::williams2_base(machine_config &config) { /* basic machine hardware */ MC6809E(config, m_maincpu, MASTER_CLOCK/3/4); - m_maincpu->set_addrmap(AS_PROGRAM, &williams2_state::williams2_d000_ram_map); M6808(config, m_soundcpu, MASTER_CLOCK/3); /* yes, this is different from the older games */ - m_soundcpu->set_addrmap(AS_PROGRAM, &williams2_state::williams2_sound_map); + m_soundcpu->set_addrmap(AS_PROGRAM, &williams2_state::sound_map); - ADDRESS_MAP_BANK(config, "bank8000").set_map(&williams2_state::williams2_bank8000_map).set_options(ENDIANNESS_BIG, 8, 12, 0x800); + ADDRESS_MAP_BANK(config, "bank8000").set_map(&williams2_state::bank8000_map).set_options(ENDIANNESS_BIG, 8, 12, 0x800); - MCFG_MACHINE_START_OVERRIDE(williams2_state,williams2) - MCFG_MACHINE_RESET_OVERRIDE(williams2_state,williams2) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // 5114 + battery // 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(williams2_state::williams2_va11_callback), "screen", 0, 32); + TIMER(config, "scan_timer").configure_scanline(FUNC(williams2_state::va11_callback), "screen", 0, 32); // also set a timer to go off on scanline 254 - TIMER(config, "254_timer").configure_scanline(FUNC(williams2_state::williams2_endscreen_callback), "screen", 8, 246); + TIMER(config, "254_timer").configure_scanline(FUNC(williams2_state::endscreen_callback), "screen", 8, 246); WATCHDOG_TIMER(config, m_watchdog); @@ -1769,9 +1780,7 @@ void williams2_state::williams2(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_video_attributes(VIDEO_UPDATE_SCANLINE | VIDEO_ALWAYS_UPDATE); m_screen->set_raw(MASTER_CLOCK*2/3, 512, 8, 284, 260, 8, 248); - m_screen->set_screen_update(FUNC(williams2_state::screen_update_williams2)); - - MCFG_VIDEO_START_OVERRIDE(williams2_state,williams2) + m_screen->set_screen_update(FUNC(williams2_state::screen_update)); /* sound hardware */ SPEAKER(config, "speaker").front_center(); @@ -1780,18 +1789,17 @@ void williams2_state::williams2(machine_config &config) vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT); vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT); - /* pia */ INPUT_MERGER_ANY_HIGH(config, "mainirq").output_handler().set_inputline(m_maincpu, M6809_IRQ_LINE); - INPUT_MERGER_ANY_HIGH(config, "soundirq").output_handler().set_inputline(m_soundcpu, M6808_IRQ_LINE); + /* pia */ PIA6821(config, m_pia[0], 0); m_pia[0]->readpa_handler().set_ioport("IN0"); m_pia[0]->readpb_handler().set_ioport("IN1"); PIA6821(config, m_pia[1], 0); m_pia[1]->readpa_handler().set_ioport("IN2"); - m_pia[1]->writepb_handler().set(FUNC(williams2_state::williams2_snd_cmd_w)); + m_pia[1]->writepb_handler().set(FUNC(williams2_state::snd_cmd_w)); m_pia[1]->cb2_handler().set(m_pia[2], FUNC(pia6821_device::ca1_w)); m_pia[1]->irqa_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<0>)); m_pia[1]->irqb_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<1>)); @@ -1805,9 +1813,12 @@ void williams2_state::williams2(machine_config &config) } -void williams2_state::inferno(machine_config &config) +void inferno_state::inferno(machine_config &config) { - williams2(config); + williams2_base(config); + m_maincpu->set_addrmap(AS_PROGRAM, &inferno_state::d000_map); + + /* pia */ m_pia[0]->readpa_handler().set("mux", FUNC(ls157_x2_device::output_r)); m_pia[0]->ca2_handler().set("mux", FUNC(ls157_x2_device::select_w)); @@ -1816,12 +1827,10 @@ void williams2_state::inferno(machine_config &config) m_mux->b_in_callback().set_ioport("INP2"); } - -void williams2_state::mysticm(machine_config &config) +void mysticm_state::mysticm(machine_config &config) { - williams2(config); - - /* basic machine hardware */ + williams2_base(config); + m_maincpu->set_addrmap(AS_PROGRAM, &mysticm_state::d000_map); /* pia */ m_pia[0]->irqa_handler().set_inputline("maincpu", M6809_FIRQ_LINE); @@ -1834,12 +1843,10 @@ void williams2_state::mysticm(machine_config &config) void tshoot_state::tshoot(machine_config &config) { - williams2(config); + williams2_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &tshoot_state::williams2_d000_rom_map); - - MCFG_MACHINE_START_OVERRIDE(tshoot_state,tshoot) + m_maincpu->set_addrmap(AS_PROGRAM, &tshoot_state::d000_map); /* pia */ m_pia[0]->readpa_handler().set("mux", FUNC(ls157_x2_device::output_r)); @@ -1861,24 +1868,21 @@ void tshoot_state::tshoot(machine_config &config) void joust2_state::joust2(machine_config &config) { - williams2(config); + williams2_base(config); /* basic machine hardware */ - m_maincpu->set_addrmap(AS_PROGRAM, &joust2_state::williams2_d000_rom_map); + m_maincpu->set_addrmap(AS_PROGRAM, &joust2_state::d000_map); WILLIAMS_CVSD_SOUND(config, m_cvsd_sound).add_route(ALL_OUTPUTS, "speaker", 1.0); - MCFG_MACHINE_START_OVERRIDE(joust2_state,joust2) - MCFG_MACHINE_RESET_OVERRIDE(joust2_state,joust2) - /* pia */ m_pia[0]->readpa_handler().set_ioport("IN0").mask(0xf0); m_pia[0]->readpa_handler().append("mux", FUNC(ls157_device::output_r)).mask(0x0f); m_pia[0]->ca2_handler().set("mux", FUNC(ls157_device::select_w)); m_pia[1]->readpa_handler().set_ioport("IN2"); - m_pia[1]->writepb_handler().set(FUNC(joust2_state::joust2_snd_cmd_w)); - m_pia[1]->ca2_handler().set(FUNC(joust2_state::joust2_pia_3_cb1_w)); + m_pia[1]->writepb_handler().set(FUNC(joust2_state::snd_cmd_w)); + m_pia[1]->ca2_handler().set(FUNC(joust2_state::pia_3_cb1_w)); m_pia[1]->cb2_handler().set(m_pia[2], FUNC(pia6821_device::ca1_w)); m_pia[1]->irqa_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<0>)); m_pia[1]->irqb_handler().set("mainirq", FUNC(input_merger_any_high_device::in_w<1>)); @@ -3149,37 +3153,24 @@ ROM_END -/************************************* - * - * Configuration macros - * - *************************************/ - -#define CONFIGURE_BLITTER(x,c) \ - m_blitter_config = x; \ - m_blitter_clip_address = c - -#define CONFIGURE_TILEMAP(x) \ - m_williams2_tilemap_config = x - - - /************************************* * * Defender hardware driver init * *************************************/ -void williams_state::init_defender() +void defender_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); + m_blitter_config = WILLIAMS_BLITTER_NONE; + m_blitter_clip_address = 0x0000; } -void williams_state::init_defndjeu() +void defndjeu_state::driver_init() { uint8_t *rom = memregion("maincpu")->base(); - CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); + m_blitter_config = WILLIAMS_BLITTER_NONE; + m_blitter_clip_address = 0x0000; /* apply simple decryption by swapping bits 0 and 7 */ for (int i = 0xd000; i < 0x19000; i++) @@ -3187,13 +3178,11 @@ void williams_state::init_defndjeu() } -void williams_state::init_mayday() +void mayday_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); - - /* install a handler to catch protection checks */ - m_maincpu->space(AS_PROGRAM).install_read_handler(0xa190, 0xa191, read8sm_delegate(*this, FUNC(williams_state::mayday_protection_r))); - m_mayday_protection = m_videoram + 0xa190; + m_blitter_config = WILLIAMS_BLITTER_NONE; + m_blitter_clip_address = 0x0000; + m_protection = m_videoram + 0xa190; } @@ -3206,78 +3195,87 @@ void williams_state::init_mayday() void williams_state::init_stargate() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000); + m_blitter_config = WILLIAMS_BLITTER_NONE; + m_blitter_clip_address = 0x0000; } void williams_state::init_robotron() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } -void williams_state::init_joust() +void williams_muxed_state::init_joust() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } -void williams_state::init_bubbles() +void bubbles_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); - - /* bubbles has a full 8-bit-wide CMOS */ - m_maincpu->space(AS_PROGRAM).install_write_handler(0xcc00, 0xcfff, write8sm_delegate(*this, FUNC(williams_state::bubbles_cmos_w))); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } -void williams_state::init_splat() +void williams_muxed_state::init_splat() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0xc000; } -void williams_state::init_sinistar() +void sinistar_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0x7400); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0x7400; } -void williams_state::init_playball() +void playball_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } -void blaster_state::init_blaster() +void blaster_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0x9700); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0x9700; } void spdball_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } -void williams_state::init_alienar() +void williams_muxed_state::init_alienar() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; m_maincpu->space(AS_PROGRAM).nop_write(0xcbff, 0xcbff); } -void williams_state::init_alienaru() +void williams_muxed_state::init_alienaru() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; m_maincpu->space(AS_PROGRAM).nop_write(0xcbff, 0xcbff); } void williams_state::init_lottofun() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC1, 0xc000); + m_blitter_config = WILLIAMS_BLITTER_SC1; + m_blitter_clip_address = 0xc000; } @@ -3288,31 +3286,31 @@ void williams_state::init_lottofun() * *************************************/ -void williams2_state::init_mysticm() +void mysticm_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0x9000); - CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_MYSTICM); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0x9000; } -void williams2_state::init_tshoot() +void tshoot_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0x9000); - CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0x9000; } -void williams2_state::init_inferno() +void inferno_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0x9000); - CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0x9000; } -void joust2_state::init_joust2() +void joust2_state::driver_init() { - CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC2, 0x9000); - CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_JOUST2); + m_blitter_config = WILLIAMS_BLITTER_SC2; + m_blitter_clip_address = 0x9000; } @@ -3324,80 +3322,80 @@ void joust2_state::init_joust2() *************************************/ /* Defender hardware games */ -GAME( 1980, defender, 0, defender, defender, williams_state, init_defender, ROT0, "Williams", "Defender (Red label)", MACHINE_SUPPORTS_SAVE ) // developers left Williams in 1981 and formed Vid Kidz -GAME( 1980, defenderg, defender, defender, defender, williams_state, init_defender, ROT0, "Williams", "Defender (Green label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, defenderb, defender, defender, defender, williams_state, init_defender, ROT0, "Williams", "Defender (Blue label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, defenderw, defender, defender, defender, williams_state, init_defender, ROT0, "Williams", "Defender (White label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, defenderj, defender, defender, defender, williams_state, init_defender, ROT0, "Williams (Taito Corporation license)", "T.T Defender", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, defndjeu, defender, defender, defender, williams_state, init_defndjeu, ROT0, "bootleg (Jeutel)", "Defender (bootleg)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) -GAME( 1980, tornado1, defender, defender, defender, williams_state, init_defndjeu, ROT0, "bootleg (Jeutel)", "Tornado (set 1, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, tornado2, defender, defender, defender, williams_state, init_defndjeu, ROT0, "bootleg (Jeutel)", "Tornado (set 2, Defender bootleg)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // bad dump? -GAME( 1980, zero, defender, defender, defender, williams_state, init_defndjeu, ROT0, "bootleg (Jeutel)", "Zero (set 1, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, zero2, defender, defender, defender, williams_state, init_defndjeu, ROT0, "bootleg (Amtec)", "Zero (set 2, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, defcmnd, defender, defender, defender, williams_state, init_defender, ROT0, "bootleg", "Defense Command (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1981, defence, defender, defender, defender, williams_state, init_defender, ROT0, "bootleg (Outer Limits)", "Defence Command (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1981, startrkd, defender, defender, defender, williams_state, init_defender, ROT0, "bootleg", "Star Trek (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1980, attackf, defender, defender, defender, williams_state, init_defender, ROT0, "bootleg (FAMARE S.A.)", "Attack (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) -GAME( 1981, galwars2, defender, defender, defender, williams_state, init_defender, ROT0, "bootleg (Sonic)", "Galaxy Wars II (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) // Sega Sonic - Sega S.A., only displays Sonic on title screen +GAME( 1980, defender, 0, defender, defender, defender_state, empty_init, ROT0, "Williams", "Defender (Red label)", MACHINE_SUPPORTS_SAVE ) // developers left Williams in 1981 and formed Vid Kidz +GAME( 1980, defenderg, defender, defender, defender, defender_state, empty_init, ROT0, "Williams", "Defender (Green label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, defenderb, defender, defender, defender, defender_state, empty_init, ROT0, "Williams", "Defender (Blue label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, defenderw, defender, defender, defender, defender_state, empty_init, ROT0, "Williams", "Defender (White label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, defenderj, defender, defender, defender, defender_state, empty_init, ROT0, "Williams (Taito Corporation license)", "T.T Defender", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, defndjeu, defender, defender, defender, defndjeu_state, empty_init, ROT0, "bootleg (Jeutel)", "Defender (bootleg)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, tornado1, defender, defender, defender, defndjeu_state, empty_init, ROT0, "bootleg (Jeutel)", "Tornado (set 1, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, tornado2, defender, defender, defender, defndjeu_state, empty_init, ROT0, "bootleg (Jeutel)", "Tornado (set 2, Defender bootleg)", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // bad dump? +GAME( 1980, zero, defender, defender, defender, defndjeu_state, empty_init, ROT0, "bootleg (Jeutel)", "Zero (set 1, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, zero2, defender, defender, defender, defndjeu_state, empty_init, ROT0, "bootleg (Amtec)", "Zero (set 2, Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, defcmnd, defender, defender, defender, defender_state, empty_init, ROT0, "bootleg", "Defense Command (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, defence, defender, defender, defender, defender_state, empty_init, ROT0, "bootleg (Outer Limits)", "Defence Command (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, startrkd, defender, defender, defender, defender_state, empty_init, ROT0, "bootleg", "Star Trek (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1980, attackf, defender, defender, defender, defender_state, empty_init, ROT0, "bootleg (FAMARE S.A.)", "Attack (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, galwars2, defender, defender, defender, defender_state, empty_init, ROT0, "bootleg (Sonic)", "Galaxy Wars II (Defender bootleg)", MACHINE_SUPPORTS_SAVE ) // Sega Sonic - Sega S.A., only displays Sonic on title screen -GAME( 1980, mayday, 0, defender, mayday, williams_state, init_mayday, ROT0, "Hoei", "Mayday (set 1)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // \ original by Hoei, which one of these 3 sets is bootleg/licensed/original is unknown -GAME( 1980, maydaya, mayday, defender, mayday, williams_state, init_mayday, ROT0, "Hoei", "Mayday (set 2)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // > these games have an unemulated protection chip of some sort which is hacked around in /machine/williams.cpp "mayday_protection_r" function -GAME( 1980, maydayb, mayday, defender, mayday, williams_state, init_mayday, ROT0, "Hoei", "Mayday (set 3)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // / -GAME( 1980, batlzone, mayday, defender, mayday, williams_state, init_mayday, ROT0, "bootleg (Video Game)", "Battle Zone (bootleg of Mayday)", MACHINE_SUPPORTS_SAVE )// the bootleg may or may not use the same protection chip, or some hack around it. +GAME( 1980, mayday, 0, defender, mayday, mayday_state, empty_init, ROT0, "Hoei", "Mayday (set 1)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // \ original by Hoei, which one of these 3 sets is bootleg/licensed/original is unknown +GAME( 1980, maydaya, mayday, defender, mayday, mayday_state, empty_init, ROT0, "Hoei", "Mayday (set 2)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // > these games have an unemulated protection chip of some sort which is hacked around in /machine/williams.cpp "protection_r" function +GAME( 1980, maydayb, mayday, defender, mayday, mayday_state, empty_init, ROT0, "Hoei", "Mayday (set 3)", MACHINE_SUPPORTS_SAVE | MACHINE_UNEMULATED_PROTECTION ) // / +GAME( 1980, batlzone, mayday, defender, mayday, mayday_state, empty_init, ROT0, "bootleg (Video Game)", "Battle Zone (bootleg of Mayday)", MACHINE_SUPPORTS_SAVE )// the bootleg may or may not use the same protection chip, or some hack around it. -GAME( 1981, colony7, 0, defender, colony7, williams_state, init_defender, ROT270, "Taito", "Colony 7 (set 1)", MACHINE_SUPPORTS_SAVE ) -GAME( 1981, colony7a, colony7, defender, colony7, williams_state, init_defender, ROT270, "Taito", "Colony 7 (set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, colony7, 0, defender, colony7, defender_state, empty_init, ROT270, "Taito", "Colony 7 (set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, colony7a, colony7, defender, colony7, defender_state, empty_init, ROT270, "Taito", "Colony 7 (set 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, jin, 0, jin, jin, williams_state, init_defender, ROT90, "Falcon", "Jin", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, jin, 0, jin, jin, defender_state, empty_init, ROT90, "Falcon", "Jin", MACHINE_SUPPORTS_SAVE ) /* Standard Williams hardware */ -GAME( 1981, stargate, 0, williams, stargate, williams_state, init_stargate, ROT0, "Williams / Vid Kidz", "Stargate", MACHINE_SUPPORTS_SAVE ) +GAME( 1981, stargate, 0, williams_base, stargate, williams_state, init_stargate, ROT0, "Williams / Vid Kidz", "Stargate", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, robotron, 0, williams, robotron, williams_state, init_robotron, ROT0, "Williams / Vid Kidz", "Robotron: 2084 (Solid Blue label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, robotronyo, robotron, williams, robotron, williams_state, init_robotron, ROT0, "Williams / Vid Kidz", "Robotron: 2084 (Yellow/Orange label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, robotron, 0, williams_base, robotron, williams_state, init_robotron, ROT0, "Williams / Vid Kidz", "Robotron: 2084 (Solid Blue label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, robotronyo, robotron, williams_base, robotron, williams_state, init_robotron, ROT0, "Williams / Vid Kidz", "Robotron: 2084 (Yellow/Orange label)", MACHINE_SUPPORTS_SAVE ) // the 3 below are all noteworthy hacks of the Solid BLue set -GAME( 1987, robotron87, robotron, williams, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (1987 'shot-in-the-corner' bugfix)", MACHINE_SUPPORTS_SAVE ) // fixes a reset bug. -GAME( 2012, robotron12, robotron, williams, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (2012 'wave 201 start' hack)", MACHINE_SUPPORTS_SAVE ) // includes sitc bug fix, used for competitive play. -GAME( 2015, robotrontd, robotron, williams, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (2015 'tie-die V2' hack)", MACHINE_SUPPORTS_SAVE ) // inc. sitc fix, mods by some of the original developers, see backstory here http://www.robotron2084guidebook.com/gameplay/raceto100million/robo2k14_tie-die-romset/ (I guess there's a tie-die V1 before it was released to the public?) +GAME( 1987, robotron87, robotron, williams_base, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (1987 'shot-in-the-corner' bugfix)", MACHINE_SUPPORTS_SAVE ) // fixes a reset bug. +GAME( 2012, robotron12, robotron, williams_base, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (2012 'wave 201 start' hack)", MACHINE_SUPPORTS_SAVE ) // includes sitc bug fix, used for competitive play. +GAME( 2015, robotrontd, robotron, williams_base, robotron, williams_state, init_robotron, ROT0, "hack", "Robotron: 2084 (2015 'tie-die V2' hack)", MACHINE_SUPPORTS_SAVE ) // inc. sitc fix, mods by some of the original developers, see backstory here http://www.robotron2084guidebook.com/gameplay/raceto100million/robo2k14_tie-die-romset/ (I guess there's a tie-die V1 before it was released to the public?) -GAME( 1982, joust, 0, williams_muxed, joust, williams_state, init_joust, ROT0, "Williams", "Joust (White/Green label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, joustr, joust, williams_muxed, joust, williams_state, init_joust, ROT0, "Williams", "Joust (Solid Red label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, joustwr, joust, williams_muxed, joust, williams_state, init_joust, ROT0, "Williams", "Joust (White/Red label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, joust, 0, williams_muxed, joust, williams_muxed_state, init_joust, ROT0, "Williams", "Joust (White/Green label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, joustr, joust, williams_muxed, joust, williams_muxed_state, init_joust, ROT0, "Williams", "Joust (Solid Red label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, joustwr, joust, williams_muxed, joust, williams_muxed_state, init_joust, ROT0, "Williams", "Joust (White/Red label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, bubbles, 0, williams, bubbles, williams_state, init_bubbles, ROT0, "Williams", "Bubbles", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, bubblesr, bubbles, williams, bubbles, williams_state, init_bubbles, ROT0, "Williams", "Bubbles (Solid Red label)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, bubblesp, bubbles, williams, bubbles, williams_state, init_bubbles, ROT0, "Williams", "Bubbles (prototype version)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, bubbles, 0, bubbles, bubbles, bubbles_state, empty_init, ROT0, "Williams", "Bubbles", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, bubblesr, bubbles, bubbles, bubbles, bubbles_state, empty_init, ROT0, "Williams", "Bubbles (Solid Red label)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, bubblesp, bubbles, bubbles, bubbles, bubbles_state, empty_init, ROT0, "Williams", "Bubbles (prototype version)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, splat, 0, williams_muxed, splat, williams_state, init_splat, ROT0, "Williams", "Splat!", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, splat, 0, williams_muxed, splat, williams_muxed_state, init_splat, ROT0, "Williams", "Splat!", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, sinistar, 0, sinistar, sinistar, williams_state, init_sinistar, ROT270, "Williams", "Sinistar (revision 3)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, sinistar1, sinistar, sinistar, sinistar, williams_state, init_sinistar, ROT270, "Williams", "Sinistar (prototype version)", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, sinistar2, sinistar, sinistar, sinistar, williams_state, init_sinistar, ROT270, "Williams", "Sinistar (revision 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, sinistar, 0, sinistar, sinistar, sinistar_state, empty_init, ROT270, "Williams", "Sinistar (revision 3)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, sinistar1, sinistar, sinistar, sinistar, sinistar_state, empty_init, ROT270, "Williams", "Sinistar (prototype version)", MACHINE_SUPPORTS_SAVE ) +GAME( 1982, sinistar2, sinistar, sinistar, sinistar, sinistar_state, empty_init, ROT270, "Williams", "Sinistar (revision 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, playball, 0, playball, playball, williams_state, init_playball, ROT270, "Williams", "PlayBall! (prototype)", MACHINE_SUPPORTS_SAVE ) +GAME( 1983, playball, 0, playball, playball, playball_state, empty_init, ROT270, "Williams", "PlayBall! (prototype)", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, blaster, 0, blaster, blaster, blaster_state, init_blaster, ROT0, "Williams / Vid Kidz", "Blaster", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, blastero, blaster, blaster, blaster, blaster_state, init_blaster, ROT0, "Williams / Vid Kidz", "Blaster (location test)", MACHINE_SUPPORTS_SAVE ) -GAME( 1983, blasterkit, blaster, blastkit, blastkit, blaster_state, init_blaster, ROT0, "Williams / Vid Kidz", "Blaster (conversion kit)", MACHINE_SUPPORTS_SAVE ) // mono sound +GAME( 1983, blaster, 0, blaster, blaster, blaster_state, empty_init, ROT0, "Williams / Vid Kidz", "Blaster", MACHINE_SUPPORTS_SAVE ) +GAME( 1983, blastero, blaster, blaster, blaster, blaster_state, empty_init, ROT0, "Williams / Vid Kidz", "Blaster (location test)", MACHINE_SUPPORTS_SAVE ) +GAME( 1983, blasterkit, blaster, blastkit, blastkit, blaster_state, empty_init, ROT0, "Williams / Vid Kidz", "Blaster (conversion kit)", MACHINE_SUPPORTS_SAVE ) // mono sound -GAME( 1985, spdball, 0, spdball, spdball, spdball_state, driver_init, ROT0, "Williams", "Speed Ball - Contest at Neonworld (prototype)", MACHINE_SUPPORTS_SAVE ) +GAME( 1985, spdball, 0, spdball, spdball, spdball_state, empty_init, ROT0, "Williams", "Speed Ball - Contest at Neonworld (prototype)", MACHINE_SUPPORTS_SAVE ) -GAME( 1985, alienar, 0, williams_muxed, alienar, williams_state, init_alienar, ROT0, "Duncan Brown", "Alien Arena", MACHINE_SUPPORTS_SAVE ) -GAME( 1985, alienaru, alienar, williams_muxed, alienar, williams_state, init_alienaru, ROT0, "Duncan Brown", "Alien Arena (Stargate upgrade)", MACHINE_SUPPORTS_SAVE ) +GAME( 1985, alienar, 0, williams_muxed, alienar, williams_muxed_state, init_alienar, ROT0, "Duncan Brown", "Alien Arena", MACHINE_SUPPORTS_SAVE ) +GAME( 1985, alienaru, alienar, williams_muxed, alienar, williams_muxed_state, init_alienaru, ROT0, "Duncan Brown", "Alien Arena (Stargate upgrade)", MACHINE_SUPPORTS_SAVE ) -GAME( 1987, lottofun, 0, lottofun, lottofun, williams_state, init_lottofun, ROT0, "H.A.R. Management", "Lotto Fun", MACHINE_SUPPORTS_SAVE ) +GAME( 1987, lottofun, 0, lottofun, lottofun, williams_state, init_lottofun, ROT0, "H.A.R. Management", "Lotto Fun", MACHINE_SUPPORTS_SAVE ) /* 2nd Generation Williams hardware with tilemaps */ -GAME( 1983, mysticm, 0, mysticm, mysticm, williams2_state, init_mysticm, ROT0, "Williams", "Mystic Marathon", MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE) -GAME( 1983, mysticmp, mysticm, mysticm, mysticm, williams2_state, init_mysticm, ROT0, "Williams", "Mystic Marathon (prototype)", MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE ) // newest roms are 'proto 6' ? +GAME( 1983, mysticm, 0, mysticm, mysticm, mysticm_state, empty_init, ROT0, "Williams", "Mystic Marathon", MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE) +GAME( 1983, mysticmp, mysticm, mysticm, mysticm, mysticm_state, empty_init, ROT0, "Williams", "Mystic Marathon (prototype)", MACHINE_WRONG_COLORS | MACHINE_SUPPORTS_SAVE ) // newest roms are 'proto 6' ? -GAME( 1984, tshoot, 0, tshoot, tshoot, tshoot_state, init_tshoot, ROT0, "Williams", "Turkey Shoot (prototype)", MACHINE_SUPPORTS_SAVE ) +GAME( 1984, tshoot, 0, tshoot, tshoot, tshoot_state, empty_init, ROT0, "Williams", "Turkey Shoot (prototype)", MACHINE_SUPPORTS_SAVE ) -GAME( 1984, inferno, 0, inferno, inferno, williams2_state, init_inferno, ROT0, "Williams", "Inferno (Williams)", MACHINE_SUPPORTS_SAVE ) +GAME( 1984, inferno, 0, inferno, inferno, inferno_state, empty_init, ROT0, "Williams", "Inferno (Williams)", MACHINE_SUPPORTS_SAVE ) -GAME( 1986, joust2, 0, joust2, joust2, joust2_state, init_joust2, ROT270, "Williams", "Joust 2 - Survival of the Fittest (revision 2)", MACHINE_SUPPORTS_SAVE ) -GAME( 1986, joust2r1, joust2, joust2, joust2, joust2_state, init_joust2, ROT270, "Williams", "Joust 2 - Survival of the Fittest (revision 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1986, joust2, 0, joust2, joust2, joust2_state, empty_init, ROT270, "Williams", "Joust 2 - Survival of the Fittest (revision 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1986, joust2r1, joust2, joust2, joust2, joust2_state, empty_init, ROT270, "Williams", "Joust 2 - Survival of the Fittest (revision 1)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/williams.h b/src/mame/includes/williams.h index 1a8d2c7d9f2..51f02fb96c1 100644 --- a/src/mame/includes/williams.h +++ b/src/mame/includes/williams.h @@ -34,12 +34,6 @@ public: m_mainbank(*this, "mainbank"), m_maincpu(*this, "maincpu"), m_soundcpu(*this, "soundcpu"), - m_mux(*this, "mux"), - m_mux0(*this, "mux_0"), - m_mux1(*this, "mux_1"), - m_muxa(*this, "mux_a"), - m_muxb(*this, "mux_b"), - m_bankc000(*this, "bankc000"), m_watchdog(*this, "watchdog"), m_screen(*this, "screen"), m_palette(*this, "palette"), @@ -47,42 +41,28 @@ public: m_pia(*this, "pia_%u", 0U) { } - void playball(machine_config &config); - void defender(machine_config &config); - void sinistar(machine_config &config); void lottofun(machine_config &config); - void williams(machine_config &config); - void williams_muxed(machine_config &config); - void jin(machine_config &config); + void williams_base(machine_config &config); - void init_sinistar(); void init_stargate(); void init_playball(); - void init_defender(); - void init_mayday(); void init_lottofun(); - void init_alienaru(); - void init_defndjeu(); - void init_splat(); - void init_joust(); - void init_alienar(); void init_robotron(); - void init_bubbles(); - u8 williams_49way_port_0_r(); - void williams_snd_cmd_w(u8 data); - void defender_video_control_w(u8 data); - u8 williams_video_counter_r(); - DECLARE_WRITE8_MEMBER(williams_watchdog_reset_w); + u8 port_0_49way_r(); + u8 video_counter_r(); + virtual DECLARE_WRITE8_MEMBER(watchdog_reset_w); - TIMER_DEVICE_CALLBACK_MEMBER(williams_va11_callback); - TIMER_DEVICE_CALLBACK_MEMBER(williams_count240_callback); + virtual TIMER_DEVICE_CALLBACK_MEMBER(va11_callback); + TIMER_DEVICE_CALLBACK_MEMBER(count240_callback); - uint32_t screen_update_williams(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - DECLARE_VIDEO_START(williams); - void williams_palette(palette_device &palette) const; + virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void palette_init(palette_device &palette) const; protected: + virtual void machine_start() override; + virtual void video_start() override; + enum { //controlbyte (0xCA00) bit definitions @@ -99,7 +79,6 @@ protected: required_shared_ptr m_nvram; required_shared_ptr m_videoram; optional_memory_bank m_mainbank; - uint8_t *m_mayday_protection; uint8_t m_blitter_config; uint16_t m_blitter_clip_address; uint8_t m_blitter_window_enable; @@ -110,22 +89,14 @@ protected: uint8_t m_blitter_remap_index; const uint8_t *m_blitter_remap; std::unique_ptr m_blitter_remap_lookup; - void williams_vram_select_w(u8 data); - void williams_cmos_w(offs_t offset, u8 data); - void bubbles_cmos_w(offs_t offset, u8 data); - void defender_bank_select_w(u8 data); - u8 mayday_protection_r(offs_t offset); + virtual void vram_select_w(u8 data); + virtual void cmos_w(offs_t offset, u8 data); void sinistar_vram_select_w(u8 data); - DECLARE_WRITE8_MEMBER(williams_blitter_w); + DECLARE_WRITE8_MEMBER(blitter_w); - DECLARE_MACHINE_START(defender); - DECLARE_MACHINE_RESET(defender); - DECLARE_MACHINE_START(williams); - DECLARE_MACHINE_START(williams_common); + virtual TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w); - TIMER_CALLBACK_MEMBER(williams_deferred_snd_cmd_w); - - void playball_snd_cmd_w(u8 data); + virtual void snd_cmd_w(u8 data); DECLARE_WRITE_LINE_MEMBER(lottofun_coin_lock_w); @@ -136,24 +107,140 @@ protected: required_device m_maincpu; required_device m_soundcpu; - optional_device m_mux; - optional_device m_mux0; - optional_device m_mux1; - optional_device m_muxa; - optional_device m_muxb; - optional_device m_bankc000; required_device m_watchdog; required_device m_screen; optional_device m_palette; optional_shared_ptr m_paletteram; optional_device_array m_pia; - void defender_bankc000_map(address_map &map); - void defender_map(address_map &map); - void defender_sound_map(address_map &map); - void sinistar_map(address_map &map); - void sound_map(address_map &map); - void williams_map(address_map &map); + virtual void sound_map(address_map &map); + void base_map(address_map &map); +}; + +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") + { } + + void defender(machine_config &config); + void jin(machine_config &config); + +protected: + virtual void driver_init() override; + + virtual void main_map(address_map &map); + +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; + + void bank_select_w(u8 data); + void video_control_w(u8 data); + + required_device m_bankc000; +}; + +class defndjeu_state : public defender_state +{ +public: + defndjeu_state(const machine_config &mconfig, device_type type, const char *tag) : + defender_state(mconfig, type, tag) + { } + +private: + virtual void driver_init() override; +}; + +class mayday_state : public defender_state +{ +public: + mayday_state(const machine_config &mconfig, device_type type, const char *tag) : + defender_state(mconfig, type, tag) + { } + +private: + virtual void driver_init() override; + + virtual void main_map(address_map &map) override; + + uint8_t *m_protection; + u8 protection_r(offs_t offset); +}; + +class sinistar_state : public williams_state +{ +public: + sinistar_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_state(mconfig, type, tag) + { } + + void sinistar(machine_config &config); + +private: + virtual void driver_init() override; + + virtual void vram_select_w(u8 data) override; + + void main_map(address_map &map); +}; + +class bubbles_state : public williams_state +{ +public: + bubbles_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_state(mconfig, type, tag) + { } + + void bubbles(machine_config &config); + +private: + virtual void driver_init() override; + + void main_map(address_map &map); + + virtual void cmos_w(offs_t offset, u8 data) override; +}; + +class playball_state : public williams_state +{ +public: + playball_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_state(mconfig, type, tag) + { } + + void playball(machine_config &config); + +private: + virtual void driver_init() override; + + virtual void snd_cmd_w(u8 data) override; +}; + +class williams_muxed_state : public williams_state +{ +public: + williams_muxed_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_state(mconfig, type, tag), + m_mux0(*this, "mux_0"), + m_mux1(*this, "mux_1") + { } + + void williams_muxed(machine_config &config); + + void init_splat(); + void init_joust(); + void init_alienar(); + void init_alienaru(); + +private: + required_device m_mux0; + required_device m_mux1; }; class spdball_state : public williams_state @@ -165,10 +252,10 @@ public: void spdball(machine_config &config); - void driver_init() override; - private: - void spdball_map(address_map &map); + virtual void driver_init() override; + + void main_map(address_map &map); }; class blaster_state : public williams_state @@ -177,45 +264,48 @@ public: blaster_state(const machine_config &mconfig, device_type type, const char *tag) : williams_state(mconfig, type, tag), m_soundcpu_b(*this, "soundcpu_b"), - m_blaster_palette_0(*this, "blaster_pal0"), - m_blaster_scanline_control(*this, "blaster_scan"), - m_blaster_bankb(*this, "blaster_bankb") + m_palette_0(*this, "blaster_pal0"), + m_scanline_control(*this, "blaster_scan"), + m_bankb(*this, "blaster_bankb"), + m_muxa(*this, "mux_a"), + m_muxb(*this, "mux_b") { } void blastkit(machine_config &config); void blaster(machine_config &config); - void init_blaster(); - private: - optional_device m_soundcpu_b; - required_shared_ptr m_blaster_palette_0; - required_shared_ptr m_blaster_scanline_control; - optional_memory_bank m_blaster_bankb; + virtual void machine_start() override; + virtual void video_start() override; + virtual void driver_init() override; - rgb_t m_blaster_color0; - uint8_t m_blaster_video_control; + optional_device m_soundcpu_b; + required_shared_ptr m_palette_0; + required_shared_ptr m_scanline_control; + optional_memory_bank m_bankb; + required_device m_muxa; + optional_device m_muxb; + + rgb_t m_color0; + uint8_t m_video_control; uint8_t m_vram_bank; uint8_t m_rom_bank; - void blaster_vram_select_w(u8 data); - void blaster_bank_select_w(u8 data); - void blaster_remap_select_w(u8 data); - void blaster_video_control_w(u8 data); - TIMER_CALLBACK_MEMBER(blaster_deferred_snd_cmd_w); - void blaster_snd_cmd_w(u8 data); + virtual void vram_select_w(u8 data) override; + void bank_select_w(u8 data); + void remap_select_w(u8 data); + void video_control_w(u8 data); + virtual TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w) override; + virtual void snd_cmd_w(u8 data) override; - DECLARE_MACHINE_START(blaster); - DECLARE_VIDEO_START(blaster); - uint32_t screen_update_blaster(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override; inline void update_blaster_banking(); - void blaster_map(address_map &map); - void sound_map_b(address_map &map); + void main_map(address_map &map); + void sound2_map(address_map &map); }; - class williams2_state : public williams_state { public: @@ -223,61 +313,109 @@ public: williams_state(mconfig, type, tag), m_bank8000(*this, "bank8000"), m_gfxdecode(*this, "gfxdecode"), - m_williams2_tileram(*this, "williams2_tile") + m_tileram(*this, "williams2_tile") { } - void williams2(machine_config &config); - void mysticm(machine_config &config); - void inferno(machine_config &config); - - void init_mysticm(); - void init_tshoot(); - void init_inferno(); + void williams2_base(machine_config &config); protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + required_device m_bank8000; required_device m_gfxdecode; - required_shared_ptr m_williams2_tileram; + required_shared_ptr m_tileram; tilemap_t *m_bg_tilemap; uint16_t m_tilemap_xscroll; - uint8_t m_williams2_fg_color; - uint8_t m_williams2_tilemap_config; + uint8_t m_fg_color; - TILE_GET_INFO_MEMBER(get_tile_info); - void williams2_bank_select_w(u8 data); - DECLARE_WRITE8_MEMBER(williams2_watchdog_reset_w); - void williams2_7segment_w(u8 data); - void williams2_paletteram_w(offs_t offset, u8 data); - void williams2_fg_select_w(u8 data); - void williams2_bg_select_w(u8 data); - void williams2_tileram_w(offs_t offset, u8 data); - void williams2_xscroll_low_w(u8 data); - void williams2_xscroll_high_w(u8 data); - void williams2_blit_window_enable_w(u8 data); - TIMER_DEVICE_CALLBACK_MEMBER(williams2_va11_callback); - TIMER_DEVICE_CALLBACK_MEMBER(williams2_endscreen_callback); - TIMER_CALLBACK_MEMBER(williams2_deferred_snd_cmd_w); - void williams2_snd_cmd_w(u8 data); + virtual TILE_GET_INFO_MEMBER(get_tile_info); + void bank_select_w(u8 data); + virtual DECLARE_WRITE8_MEMBER(watchdog_reset_w) override; + void segments_w(u8 data); + void paletteram_w(offs_t offset, u8 data); + void fg_select_w(u8 data); + virtual void bg_select_w(u8 data); + void tileram_w(offs_t offset, u8 data); + void xscroll_low_w(u8 data); + void xscroll_high_w(u8 data); + void blit_window_enable_w(u8 data); + virtual TIMER_DEVICE_CALLBACK_MEMBER(va11_callback) override; + TIMER_DEVICE_CALLBACK_MEMBER(endscreen_callback); + virtual TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w) override; + virtual void snd_cmd_w(u8 data) override; - DECLARE_MACHINE_START(williams2); - DECLARE_MACHINE_RESET(williams2); - DECLARE_VIDEO_START(williams2); - uint32_t screen_update_williams2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override; - void williams2_bank8000_map(address_map &map); - void williams2_common_map(address_map &map); - void williams2_d000_ram_map(address_map &map); - void williams2_d000_rom_map(address_map &map); - void williams2_sound_map(address_map &map); + void bank8000_map(address_map &map); + void common_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) + { } -class tshoot_state : public williams2_state +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); +}; + +class inferno_state : public williams_d000_ram_state +{ +public: + inferno_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_d000_ram_state(mconfig, type, tag), + m_mux(*this, "mux") + { } + + void inferno(machine_config &config); + +private: + virtual void driver_init() override; + + required_device m_mux; +}; + +class mysticm_state : public williams_d000_ram_state +{ +public: + mysticm_state(const machine_config &mconfig, device_type type, const char *tag) : + williams_d000_ram_state(mconfig, type, tag) + { } + + void mysticm(machine_config &config); + +private: + virtual void driver_init() override; + + virtual TILE_GET_INFO_MEMBER(get_tile_info) override; + virtual void bg_select_w(u8 data) override; +}; + +class tshoot_state : public williams_d000_rom_state { public: tshoot_state(const machine_config &mconfig, device_type type, const char *tag) : - williams2_state(mconfig, type, tag), + williams_d000_rom_state(mconfig, type, tag), + m_mux(*this, "mux"), m_gun(*this, {"GUNX", "GUNY"}), m_grenade_lamp(*this, "Grenade_lamp"), m_gun_lamp(*this, "Gun_lamp"), @@ -290,11 +428,13 @@ public: template DECLARE_CUSTOM_INPUT_MEMBER(gun_r); private: + virtual void machine_start() override; + virtual void driver_init() override; + DECLARE_WRITE_LINE_MEMBER(maxvol_w); void lamp_w(u8 data); - DECLARE_MACHINE_START(tshoot); - + required_device m_mux; required_ioport_array<2> m_gun; output_finder<> m_grenade_lamp; output_finder<> m_gun_lamp; @@ -302,27 +442,31 @@ private: output_finder<> m_feather_blower; }; -class joust2_state : public williams2_state +class joust2_state : public williams_d000_rom_state { public: joust2_state(const machine_config &mconfig, device_type type, const char *tag) : - williams2_state(mconfig, type, tag), + williams_d000_rom_state(mconfig, type, tag), + m_mux(*this, "mux"), m_cvsd_sound(*this, "cvsd") { } void joust2(machine_config &config); - void init_joust2(); - private: - required_device m_cvsd_sound; - uint16_t m_joust2_current_sound_data; + virtual void machine_start() override; + virtual void driver_init() override; - DECLARE_MACHINE_START(joust2); - DECLARE_MACHINE_RESET(joust2); - TIMER_CALLBACK_MEMBER(joust2_deferred_snd_cmd_w); - DECLARE_WRITE8_MEMBER(joust2_snd_cmd_w); - DECLARE_WRITE_LINE_MEMBER(joust2_pia_3_cb1_w); + required_device m_mux; + required_device m_cvsd_sound; + uint16_t m_current_sound_data; + + virtual TILE_GET_INFO_MEMBER(get_tile_info) override; + virtual void bg_select_w(u8 data) override; + + virtual TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w) override; + virtual void snd_cmd_w(u8 data) override; + DECLARE_WRITE_LINE_MEMBER(pia_3_cb1_w); }; /*----------- defined in video/williams.cpp -----------*/ diff --git a/src/mame/machine/williams.cpp b/src/mame/machine/williams.cpp index 1c03c4f60ee..5395fa363fd 100644 --- a/src/mame/machine/williams.cpp +++ b/src/mame/machine/williams.cpp @@ -16,7 +16,7 @@ * *************************************/ -TIMER_DEVICE_CALLBACK_MEMBER(williams_state::williams_va11_callback) +TIMER_DEVICE_CALLBACK_MEMBER(williams_state::va11_callback) { int scanline = param; @@ -29,7 +29,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(williams_state::williams_va11_callback) } -TIMER_DEVICE_CALLBACK_MEMBER(williams_state::williams_count240_callback) +TIMER_DEVICE_CALLBACK_MEMBER(williams_state::count240_callback) { int scanline = param; @@ -44,7 +44,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(williams_state::williams_count240_callback) * *************************************/ -MACHINE_START_MEMBER(williams_state,williams_common) +void williams_state::machine_start() { /* configure the memory bank */ m_mainbank->configure_entry(1, memregion("maincpu")->base() + 0x10000); @@ -52,20 +52,13 @@ MACHINE_START_MEMBER(williams_state,williams_common) } -MACHINE_START_MEMBER(williams_state,williams) -{ - MACHINE_START_CALL_MEMBER(williams_common); -} - - - /************************************* * * Newer Williams interrupts * *************************************/ -TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::williams2_va11_callback) +TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::va11_callback) { int scanline = param; if (scanline == 256) @@ -77,7 +70,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::williams2_va11_callback) } -TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::williams2_endscreen_callback) +TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::endscreen_callback) { int scanline = param; @@ -93,7 +86,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(williams2_state::williams2_endscreen_callback) * *************************************/ -MACHINE_START_MEMBER(williams2_state,williams2) +void williams2_state::machine_start() { /* configure memory banks */ m_mainbank->configure_entries(1, 4, memregion("maincpu")->base() + 0x10000, 0x10000); @@ -102,10 +95,10 @@ MACHINE_START_MEMBER(williams2_state,williams2) } -MACHINE_RESET_MEMBER(williams2_state,williams2) +void williams2_state::machine_reset() { /* make sure our banking is reset */ - williams2_bank_select_w(0); + bank_select_w(0); } @@ -116,7 +109,7 @@ MACHINE_RESET_MEMBER(williams2_state,williams2) * *************************************/ -void williams_state::williams_vram_select_w(u8 data) +void williams_state::vram_select_w(u8 data) { /* VRAM/ROM banking from bit 0 */ m_mainbank->set_entry(data & 0x01); @@ -126,7 +119,7 @@ void williams_state::williams_vram_select_w(u8 data) } -void williams2_state::williams2_bank_select_w(u8 data) +void williams2_state::bank_select_w(u8 data) { /* the low two bits control the paging */ switch (data & 0x03) @@ -160,31 +153,31 @@ void williams2_state::williams2_bank_select_w(u8 data) * *************************************/ -TIMER_CALLBACK_MEMBER(williams_state::williams_deferred_snd_cmd_w) +TIMER_CALLBACK_MEMBER(williams_state::deferred_snd_cmd_w) { m_pia[2]->write_portb(param); m_pia[2]->cb1_w((param == 0xff) ? 0 : 1); } -void williams_state::williams_snd_cmd_w(u8 data) +void williams_state::snd_cmd_w(u8 data) { /* the high two bits are set externally, and should be 1 */ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(williams_state::williams_deferred_snd_cmd_w),this), data | 0xc0); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(williams_state::deferred_snd_cmd_w),this), data | 0xc0); } -void williams_state::playball_snd_cmd_w(u8 data) +void playball_state::snd_cmd_w(u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(williams_state::williams_deferred_snd_cmd_w),this), data); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(playball_state::deferred_snd_cmd_w),this), data); } -TIMER_CALLBACK_MEMBER(williams2_state::williams2_deferred_snd_cmd_w) +TIMER_CALLBACK_MEMBER(williams2_state::deferred_snd_cmd_w) { m_pia[2]->write_porta(param); } -void williams2_state::williams2_snd_cmd_w(u8 data) +void williams2_state::snd_cmd_w(u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(williams2_state::williams2_deferred_snd_cmd_w),this), data); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(williams2_state::deferred_snd_cmd_w),this), data); } @@ -214,7 +207,7 @@ void williams2_state::williams2_snd_cmd_w(u8 data) * 1000 = right/down full */ -u8 williams_state::williams_49way_port_0_r() +u8 williams_state::port_0_49way_r() { static const uint8_t translate49[7] = { 0x0, 0x4, 0x6, 0x7, 0xb, 0x9, 0x8 }; return (translate49[ioport("49WAYX")->read() >> 4] << 4) | translate49[ioport("49WAYY")->read() >> 4]; @@ -228,14 +221,14 @@ u8 williams_state::williams_49way_port_0_r() * *************************************/ -void williams_state::williams_cmos_w(offs_t offset, u8 data) +void williams_state::cmos_w(offs_t offset, u8 data) { /* only 4 bits are valid */ m_nvram[offset] = data | 0xf0; } -void williams_state::bubbles_cmos_w(offs_t offset, u8 data) +void bubbles_state::cmos_w(offs_t offset, u8 data) { /* bubbles has additional CMOS for a full 8 bits */ m_nvram[offset] = data; @@ -249,7 +242,7 @@ void williams_state::bubbles_cmos_w(offs_t offset, u8 data) * *************************************/ -WRITE8_MEMBER(williams_state::williams_watchdog_reset_w) +WRITE8_MEMBER(williams_state::watchdog_reset_w) { /* yes, the data bits are checked for this specific value */ if (data == 0x39) @@ -257,7 +250,7 @@ WRITE8_MEMBER(williams_state::williams_watchdog_reset_w) } -WRITE8_MEMBER(williams2_state::williams2_watchdog_reset_w) +WRITE8_MEMBER(williams2_state::watchdog_reset_w) { /* yes, the data bits are checked for this specific value */ if ((data & 0x3f) == 0x14) @@ -272,7 +265,7 @@ WRITE8_MEMBER(williams2_state::williams2_watchdog_reset_w) * *************************************/ -void williams2_state::williams2_7segment_w(u8 data) +void williams2_state::segments_w(u8 data) { int n; char dot; @@ -313,24 +306,19 @@ void williams2_state::williams2_7segment_w(u8 data) * *************************************/ -MACHINE_START_MEMBER(williams_state,defender) +void defender_state::machine_reset() { + bank_select_w(0); } -MACHINE_RESET_MEMBER(williams_state,defender) -{ - defender_bank_select_w(0); -} - - -void williams_state::defender_video_control_w(u8 data) +void defender_state::video_control_w(u8 data) { m_cocktail = data & 0x01; } -void williams_state::defender_bank_select_w(u8 data) +void defender_state::bank_select_w(u8 data) { m_bankc000->set_bank(data & 0x0f); } @@ -343,14 +331,14 @@ void williams_state::defender_bank_select_w(u8 data) * *************************************/ -u8 williams_state::mayday_protection_r(offs_t offset) +u8 mayday_state::protection_r(offs_t offset) { /* Mayday does some kind of protection check that is not currently understood */ /* However, the results of that protection check are stored at $a190 and $a191 */ /* These are compared against $a193 and $a194, respectively. Thus, to prevent */ - /* the protection from resetting the machine(), we just return $a193 for $a190, */ + /* the protection from resetting the machine, we just return $a193 for $a190, */ /* and $a194 for $a191. */ - return m_mayday_protection[offset + 3]; + return m_protection[offset + 3]; } @@ -361,10 +349,10 @@ u8 williams_state::mayday_protection_r(offs_t offset) * *************************************/ -void williams_state::sinistar_vram_select_w(u8 data) +void sinistar_state::vram_select_w(u8 data) { /* low two bits are standard */ - williams_vram_select_w(data); + williams_state::vram_select_w(data); /* window enable from bit 2 (clips to 0x7400) */ m_blitter_window_enable = data & 0x04; @@ -378,14 +366,14 @@ void williams_state::sinistar_vram_select_w(u8 data) * *************************************/ -MACHINE_START_MEMBER(blaster_state,blaster) +void blaster_state::machine_start() { /* banking is different for blaster */ m_mainbank->configure_entries(1, 16, memregion("maincpu")->base() + 0x18000, 0x4000); m_mainbank->configure_entry(0, m_videoram); - m_blaster_bankb->configure_entries(1, 16, memregion("maincpu")->base() + 0x10000, 0x0000); - m_blaster_bankb->configure_entry(0, &m_videoram[0x4000]); + m_bankb->configure_entries(1, 16, memregion("maincpu")->base() + 0x10000, 0x0000); + m_bankb->configure_entry(0, &m_videoram[0x4000]); /* register for save states */ save_item(NAME(m_vram_bank)); @@ -396,11 +384,11 @@ MACHINE_START_MEMBER(blaster_state,blaster) inline void blaster_state::update_blaster_banking() { m_mainbank->set_entry(m_vram_bank * (m_rom_bank + 1)); - m_blaster_bankb->set_entry(m_vram_bank * (m_rom_bank + 1)); + m_bankb->set_entry(m_vram_bank * (m_rom_bank + 1)); } -void blaster_state::blaster_vram_select_w(u8 data) +void blaster_state::vram_select_w(u8 data) { /* VRAM/ROM banking from bit 0 */ m_vram_bank = data & 0x01; @@ -414,14 +402,14 @@ void blaster_state::blaster_vram_select_w(u8 data) } -void blaster_state::blaster_bank_select_w(u8 data) +void blaster_state::bank_select_w(u8 data) { m_rom_bank = data & 0x0f; update_blaster_banking(); } -TIMER_CALLBACK_MEMBER(blaster_state::blaster_deferred_snd_cmd_w) +TIMER_CALLBACK_MEMBER(blaster_state::deferred_snd_cmd_w) { uint8_t l_data = param | 0x80; uint8_t r_data = (param >> 1 & 0x40) | (param & 0x3f) | 0x80; @@ -431,9 +419,9 @@ TIMER_CALLBACK_MEMBER(blaster_state::blaster_deferred_snd_cmd_w) } -void blaster_state::blaster_snd_cmd_w(u8 data) +void blaster_state::snd_cmd_w(u8 data) { - machine().scheduler().synchronize(timer_expired_delegate(FUNC(blaster_state::blaster_deferred_snd_cmd_w),this), data); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(blaster_state::deferred_snd_cmd_w),this), data); } @@ -451,15 +439,28 @@ WRITE_LINE_MEMBER(williams_state::lottofun_coin_lock_w) +/************************************* + * + * Williams 2nd-gen-specific routines + * + *************************************/ + +void williams2_state::video_control_w(u8 data) +{ + m_cocktail = data & 0x01; +} + + + /************************************* * * Turkey Shoot-specific routines * *************************************/ -MACHINE_START_MEMBER(tshoot_state,tshoot) +void tshoot_state::machine_start() { - MACHINE_START_CALL_MEMBER(williams2); + williams2_state::machine_start(); m_grenade_lamp.resolve(); m_gun_lamp.resolve(); m_p1_gun_recoil.resolve(); @@ -494,35 +495,29 @@ void tshoot_state::lamp_w(u8 data) * *************************************/ -MACHINE_START_MEMBER(joust2_state,joust2) +void joust2_state::machine_start() { - MACHINE_START_CALL_MEMBER(williams2); - save_item(NAME(m_joust2_current_sound_data)); + williams2_state::machine_start(); + save_item(NAME(m_current_sound_data)); } -MACHINE_RESET_MEMBER(joust2_state,joust2) -{ - MACHINE_RESET_CALL_MEMBER(williams2); -} - - -TIMER_CALLBACK_MEMBER(joust2_state::joust2_deferred_snd_cmd_w) +TIMER_CALLBACK_MEMBER(joust2_state::deferred_snd_cmd_w) { m_pia[2]->write_porta(param & 0xff); } -WRITE_LINE_MEMBER(joust2_state::joust2_pia_3_cb1_w) +WRITE_LINE_MEMBER(joust2_state::pia_3_cb1_w) { - m_joust2_current_sound_data = (m_joust2_current_sound_data & ~0x100) | ((state << 8) & 0x100); - m_cvsd_sound->write(m_joust2_current_sound_data); + m_current_sound_data = (m_current_sound_data & ~0x100) | ((state << 8) & 0x100); + m_cvsd_sound->write(m_current_sound_data); } -WRITE8_MEMBER(joust2_state::joust2_snd_cmd_w) +void joust2_state::snd_cmd_w(u8 data) { - m_joust2_current_sound_data = (m_joust2_current_sound_data & ~0xff) | (data & 0xff); - m_cvsd_sound->write(m_joust2_current_sound_data); - machine().scheduler().synchronize(timer_expired_delegate(FUNC(joust2_state::joust2_deferred_snd_cmd_w),this), m_joust2_current_sound_data); + m_current_sound_data = (m_current_sound_data & ~0xff) | (data & 0xff); + m_cvsd_sound->write(m_current_sound_data); + machine().scheduler().synchronize(timer_expired_delegate(FUNC(joust2_state::deferred_snd_cmd_w),this), m_current_sound_data); } diff --git a/src/mame/video/williams.cpp b/src/mame/video/williams.cpp index e7bdd55087b..6dfeaca70ba 100644 --- a/src/mame/video/williams.cpp +++ b/src/mame/video/williams.cpp @@ -167,23 +167,23 @@ void williams_state::state_save_register() } -VIDEO_START_MEMBER(williams_state,williams) +void williams_state::video_start() { blitter_init(m_blitter_config, nullptr); state_save_register(); } -VIDEO_START_MEMBER(blaster_state,blaster) +void blaster_state::video_start() { blitter_init(m_blitter_config, memregion("proms")->base()); state_save_register(); - save_item(NAME(m_blaster_color0)); - save_item(NAME(m_blaster_video_control)); + save_item(NAME(m_color0)); + save_item(NAME(m_video_control)); } -VIDEO_START_MEMBER(williams2_state,williams2) +void williams2_state::video_start() { blitter_init(m_blitter_config, nullptr); @@ -193,7 +193,7 @@ VIDEO_START_MEMBER(williams2_state,williams2) state_save_register(); save_item(NAME(m_tilemap_xscroll)); - save_item(NAME(m_williams2_fg_color)); + save_item(NAME(m_fg_color)); } @@ -204,7 +204,7 @@ VIDEO_START_MEMBER(williams2_state,williams2) * *************************************/ -uint32_t williams_state::screen_update_williams(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +uint32_t williams_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { rgb_t pens[16]; int x, y; @@ -231,32 +231,31 @@ uint32_t williams_state::screen_update_williams(screen_device &screen, bitmap_rg } -uint32_t blaster_state::screen_update_blaster(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +uint32_t blaster_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { rgb_t pens[16]; - int x, y; /* precompute the palette */ - for (x = 0; x < 16; x++) + for (int x = 0; x < 16; x++) pens[x] = m_palette->pen_color(m_paletteram[x]); /* if we're blitting from the top, start with a 0 for color 0 */ - if (cliprect.min_y == screen.visible_area().min_y || !(m_blaster_video_control & 1)) - m_blaster_color0 = m_palette->pen_color(m_blaster_palette_0[0] ^ 0xff); + if (cliprect.min_y == screen.visible_area().min_y || !(m_video_control & 1)) + m_color0 = m_palette->pen_color(m_palette_0[0] ^ 0xff); /* loop over rows */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - int erase_behind = m_blaster_video_control & m_blaster_scanline_control[y] & 2; + int erase_behind = m_video_control & m_scanline_control[y] & 2; uint8_t *source = &m_videoram[y]; uint32_t *dest = &bitmap.pix32(y); /* latch a new color0 pen? */ - if (m_blaster_video_control & m_blaster_scanline_control[y] & 1) - m_blaster_color0 = m_palette->pen_color(m_blaster_palette_0[y] ^ 0xff); + if (m_video_control & m_scanline_control[y] & 1) + m_color0 = m_palette->pen_color(m_palette_0[y] ^ 0xff); /* loop over columns */ - for (x = cliprect.min_x & ~1; x <= cliprect.max_x; x += 2) + for (int x = cliprect.min_x & ~1; x <= cliprect.max_x; x += 2) { int pix = source[(x/2) * 256]; @@ -265,34 +264,33 @@ uint32_t blaster_state::screen_update_blaster(screen_device &screen, bitmap_rgb3 source[(x/2) * 256] = 0; /* now draw */ - dest[x+0] = (pix & 0xf0) ? pens[pix >> 4] : rgb_t(m_blaster_color0 | pens[0]); - dest[x+1] = (pix & 0x0f) ? pens[pix & 0x0f] : rgb_t(m_blaster_color0 | pens[0]); + dest[x+0] = (pix & 0xf0) ? pens[pix >> 4] : rgb_t(m_color0 | pens[0]); + dest[x+1] = (pix & 0x0f) ? pens[pix & 0x0f] : rgb_t(m_color0 | pens[0]); } } return 0; } -uint32_t williams2_state::screen_update_williams2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +uint32_t williams2_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { rgb_t pens[16]; - int x, y; /* draw the background */ m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); /* fetch the relevant pens */ - for (x = 1; x < 16; x++) - pens[x] = m_palette->pen_color(m_williams2_fg_color * 16 + x); + for (int x = 1; x < 16; x++) + pens[x] = m_palette->pen_color(m_fg_color * 16 + x); /* loop over rows */ - for (y = cliprect.min_y; y <= cliprect.max_y; y++) + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { uint8_t *source = &m_videoram[y]; uint32_t *dest = &bitmap.pix32(y); /* loop over columns */ - for (x = cliprect.min_x & ~1; x <= cliprect.max_x; x += 2) + for (int x = cliprect.min_x & ~1; x <= cliprect.max_x; x += 2) { int pix = source[(x/2) * 256]; @@ -313,7 +311,7 @@ uint32_t williams2_state::screen_update_williams2(screen_device &screen, bitmap_ * *************************************/ -void williams_state::williams_palette(palette_device &palette) const +void williams_state::palette_init(palette_device &palette) const { static constexpr int resistances_rg[3] = { 1200, 560, 330 }; static constexpr int resistances_b[2] = { 560, 330 }; @@ -340,7 +338,7 @@ void williams_state::williams_palette(palette_device &palette) const -void williams2_state::williams2_paletteram_w(offs_t offset, u8 data) +void williams2_state::paletteram_w(offs_t offset, u8 data) { static const uint8_t ztable[16] = { @@ -365,9 +363,9 @@ void williams2_state::williams2_paletteram_w(offs_t offset, u8 data) } -void williams2_state::williams2_fg_select_w(u8 data) +void williams2_state::fg_select_w(u8 data) { - m_williams2_fg_color = data & 0x3f; + m_fg_color = data & 0x3f; } @@ -378,7 +376,7 @@ void williams2_state::williams2_fg_select_w(u8 data) * *************************************/ -u8 williams_state::williams_video_counter_r() +u8 williams_state::video_counter_r() { if (m_screen->vpos() < 0x100) return m_screen->vpos() & 0xfc; @@ -397,77 +395,78 @@ u8 williams_state::williams_video_counter_r() TILE_GET_INFO_MEMBER(williams2_state::get_tile_info) { int mask = m_gfxdecode->gfx(0)->elements() - 1; - int data = m_williams2_tileram[tile_index]; + int data = m_tileram[tile_index]; int y = (tile_index >> 1) & 7; - int color = 0; - switch (m_williams2_tilemap_config) - { - case WILLIAMS_TILEMAP_MYSTICM: - { - /* IC79 is a 74LS85 comparator that controls the low bit */ - int a = 1 | ((color & 1) << 2) | ((color & 1) << 3); - int b = ((y & 6) >> 1); - int casc = (y & 1); - color = (a > b) || ((a == b) && !casc); - break; - } - - case WILLIAMS_TILEMAP_TSHOOT: - /* IC79 is a 74LS157 selector jumpered to be enabled */ - color = y; - break; - - case WILLIAMS_TILEMAP_JOUST2: - /* IC79 is a 74LS157 selector jumpered to be disabled */ - color = 0; - break; - } + /* On tshoot and inferno, IC79 is a 74LS157 selector jumpered to be enabled */ + int color = y; SET_TILE_INFO_MEMBER(0, data & mask, color, (data & ~mask) ? TILE_FLIPX : 0); } - -void williams2_state::williams2_bg_select_w(u8 data) +TILE_GET_INFO_MEMBER(mysticm_state::get_tile_info) { - /* based on the tilemap config, only certain bits are used */ - /* the rest are determined by other factors */ - switch (m_williams2_tilemap_config) - { - case WILLIAMS_TILEMAP_MYSTICM: - /* IC79 is a 74LS85 comparator that controls the low bit */ - data &= 0x3e; - break; + int mask = m_gfxdecode->gfx(0)->elements() - 1; + int data = m_tileram[tile_index]; + int y = (tile_index >> 1) & 7; + int color = 0; // TODO: This seems highly suspect. Could it be why the palette doesn't work in mysticm? - case WILLIAMS_TILEMAP_TSHOOT: - /* IC79 is a 74LS157 selector jumpered to be enabled */ - data &= 0x38; - break; + /* IC79 is a 74LS85 comparator that controls the low bit */ + int a = 1 | ((color & 1) << 2) | ((color & 1) << 3); + int b = ((y & 6) >> 1); + int casc = (y & 1); + color = (a > b) || ((a == b) && !casc); - case WILLIAMS_TILEMAP_JOUST2: - /* IC79 is a 74LS157 selector jumpered to be disabled */ - data &= 0x3f; - break; - } - m_bg_tilemap->set_palette_offset(data * 16); + SET_TILE_INFO_MEMBER(0, data & mask, color, (data & ~mask) ? TILE_FLIPX : 0); } - -void williams2_state::williams2_tileram_w(offs_t offset, u8 data) +TILE_GET_INFO_MEMBER(joust2_state::get_tile_info) { - m_williams2_tileram[offset] = data; + int mask = m_gfxdecode->gfx(0)->elements() - 1; + int data = m_tileram[tile_index]; + + /* IC79 is a 74LS157 selector jumpered to be disabled */ + int color = 0; + + SET_TILE_INFO_MEMBER(0, data & mask, color, (data & ~mask) ? TILE_FLIPX : 0); +} + +/* based on the board type, only certain bits are used */ +/* the rest are determined by other factors */ + +void williams2_state::bg_select_w(u8 data) +{ + /* IC79 is a 74LS157 selector jumpered to be enabled */ + m_bg_tilemap->set_palette_offset((data & 0x38) << 4); +} + +void mysticm_state::bg_select_w(u8 data) +{ + /* IC79 is a 74LS85 comparator that controls the low bit */ + m_bg_tilemap->set_palette_offset((data & 0x3e) << 4); +} + +void joust2_state::bg_select_w(u8 data) +{ + /* IC79 is a 74LS157 selector jumpered to be disabled */ + m_bg_tilemap->set_palette_offset((data & 0x3f) << 4); +} + +void williams2_state::tileram_w(offs_t offset, u8 data) +{ + m_tileram[offset] = data; m_bg_tilemap->mark_tile_dirty(offset); } -void williams2_state::williams2_xscroll_low_w(u8 data) +void williams2_state::xscroll_low_w(u8 data) { m_tilemap_xscroll = (m_tilemap_xscroll & ~0x00f) | ((data & 0x80) >> 4) | (data & 0x07); m_bg_tilemap->set_scrollx(0, (m_tilemap_xscroll & 7) + ((m_tilemap_xscroll >> 3) * 6)); } -void williams2_state::williams2_xscroll_high_w(u8 data) +void williams2_state::xscroll_high_w(u8 data) { m_tilemap_xscroll = (m_tilemap_xscroll & 0x00f) | (data << 4); m_bg_tilemap->set_scrollx(0, (m_tilemap_xscroll & 7) + ((m_tilemap_xscroll >> 3) * 6)); @@ -481,16 +480,16 @@ void williams2_state::williams2_xscroll_high_w(u8 data) * *************************************/ -void blaster_state::blaster_remap_select_w(u8 data) +void blaster_state::remap_select_w(u8 data) { m_blitter_remap_index = data; m_blitter_remap = m_blitter_remap_lookup.get() + data * 256; } -void blaster_state::blaster_video_control_w(u8 data) +void blaster_state::video_control_w(u8 data) { - m_blaster_video_control = data; + m_video_control = data; } @@ -504,7 +503,6 @@ void blaster_state::blaster_video_control_w(u8 data) void williams_state::blitter_init(int blitter_config, const uint8_t *remap_prom) { static const uint8_t dummy_table[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }; - int i,j; /* by default, there is no clipping window - this will be touched only by games that have one */ m_blitter_window_enable = 0; @@ -516,20 +514,17 @@ void williams_state::blitter_init(int blitter_config, const uint8_t *remap_prom) m_blitter_remap_lookup = std::make_unique(256 * 256); m_blitter_remap_index = 0; m_blitter_remap = m_blitter_remap_lookup.get(); - for (i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) { const uint8_t *table = remap_prom ? (remap_prom + (i & 0x7f) * 16) : dummy_table; - for (j = 0; j < 256; j++) + for (int j = 0; j < 256; j++) m_blitter_remap_lookup[i * 256 + j] = (table[j >> 4] << 4) | table[j & 0x0f]; } } -WRITE8_MEMBER(williams_state::williams_blitter_w) +WRITE8_MEMBER(williams_state::blitter_w) { - int sstart, dstart, w, h, accesses; - int estimated_clocks_at_4MHz; - /* store the data */ m_blitterram[offset] = data; @@ -538,28 +533,29 @@ WRITE8_MEMBER(williams_state::williams_blitter_w) return; /* compute the starting locations */ - sstart = (m_blitterram[2] << 8) + m_blitterram[3]; - dstart = (m_blitterram[4] << 8) + m_blitterram[5]; + int sstart = (m_blitterram[2] << 8) + m_blitterram[3]; + int dstart = (m_blitterram[4] << 8) + m_blitterram[5]; /* compute the width and height */ - w = m_blitterram[6] ^ m_blitter_xor; - h = m_blitterram[7] ^ m_blitter_xor; + int w = m_blitterram[6] ^ m_blitter_xor; + int h = m_blitterram[7] ^ m_blitter_xor; /* adjust the width and height */ if (w == 0) w = 1; if (h == 0) h = 1; /* do the actual blit */ - accesses = blitter_core(space, sstart, dstart, w, h, data); + int accesses = blitter_core(space, sstart, dstart, w, h, data); /* based on the number of memory accesses needed to do the blit, compute how long the blit will take */ + int estimated_clocks_at_4MHz = 4; if(data & WMS_BLITTER_CONTROLBYTE_SLOW) { - estimated_clocks_at_4MHz = 4 + 4 * (accesses + 2); + estimated_clocks_at_4MHz += 4 * (accesses + 2); } else { - estimated_clocks_at_4MHz = 4 + 2 * (accesses + 3); + estimated_clocks_at_4MHz += 2 * (accesses + 3); } m_maincpu->adjust_icount(-((estimated_clocks_at_4MHz + 3) / 4)); @@ -575,7 +571,7 @@ WRITE8_MEMBER(williams_state::williams_blitter_w) } -void williams2_state::williams2_blit_window_enable_w(u8 data) +void williams2_state::blit_window_enable_w(u8 data) { m_blitter_window_enable = data & 0x01; } @@ -636,27 +632,24 @@ inline void williams_state::blit_pixel(address_space &space, int dstaddr, int sr int williams_state::blitter_core(address_space &space, int sstart, int dstart, int w, int h, int controlbyte) { - int source, sxadv, syadv; - int dest, dxadv, dyadv; - int x, y; int accesses = 0; /* compute how much to advance in the x and y loops */ - sxadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_SRC_STRIDE_256) ? 0x100 : 1; - syadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_SRC_STRIDE_256) ? 1 : w; - dxadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_DST_STRIDE_256) ? 0x100 : 1; - dyadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_DST_STRIDE_256) ? 1 : w; + int sxadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_SRC_STRIDE_256) ? 0x100 : 1; + int syadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_SRC_STRIDE_256) ? 1 : w; + int dxadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_DST_STRIDE_256) ? 0x100 : 1; + int dyadv = (controlbyte & WMS_BLITTER_CONTROLBYTE_DST_STRIDE_256) ? 1 : w; - int pixdata=0; + int pixdata = 0; /* loop over the height */ - for (y = 0; y < h; y++) + for (int y = 0; y < h; y++) { - source = sstart & 0xffff; - dest = dstart & 0xffff; + int source = sstart & 0xffff; + int dest = dstart & 0xffff; /* loop over the width */ - for (x = 0; x < w; x++) + for (int x = 0; x < w; x++) { if (!(controlbyte & WMS_BLITTER_CONTROLBYTE_SHIFT)) //no shift {