From fbc8d7178ccf2f97d69323425643fb8717c4c6e3 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 24 Jul 2023 11:47:05 +0200 Subject: gottlieb: merge driver files --- src/mame/gottlieb/exterm.cpp | 184 +++++++++++++++++- src/mame/gottlieb/exterm.h | 84 --------- src/mame/gottlieb/exterm_v.cpp | 108 ----------- src/mame/gottlieb/gottlieb.cpp | 393 ++++++++++++++++++++++++++++++++++++++- src/mame/gottlieb/gottlieb.h | 168 ----------------- src/mame/gottlieb/gottlieb_v.cpp | 234 ----------------------- src/mame/pinball/icecold.cpp | 45 +++-- 7 files changed, 591 insertions(+), 625 deletions(-) delete mode 100644 src/mame/gottlieb/exterm.h delete mode 100644 src/mame/gottlieb/exterm_v.cpp delete mode 100644 src/mame/gottlieb/gottlieb.h delete mode 100644 src/mame/gottlieb/gottlieb_v.cpp diff --git a/src/mame/gottlieb/exterm.cpp b/src/mame/gottlieb/exterm.cpp index 25d8bf59d1a..0abdb016532 100644 --- a/src/mame/gottlieb/exterm.cpp +++ b/src/mame/gottlieb/exterm.cpp @@ -63,16 +63,94 @@ ****************************************************************************/ #include "emu.h" -#include "exterm.h" #include "cpu/m6502/m6502.h" +#include "cpu/tms34010/tms34010.h" +#include "machine/gen_latch.h" #include "machine/nvram.h" +#include "machine/timer.h" #include "machine/watchdog.h" #include "sound/dac.h" +#include "sound/ymopm.h" +#include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + +class exterm_state : public driver_device +{ +public: + exterm_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_audioslave(*this, "audioslave"), + m_soundlatch(*this, "soundlatch%u", 1), + m_slave(*this, "slave"), + m_ym2151(*this, "ymsnd"), + m_nmi_timer(*this, "snd_nmi_timer"), + m_master_videoram(*this, "master_videoram"), + m_slave_videoram(*this, "slave_videoram"), + m_dial(*this, "DIAL%u", 0U), + m_input(*this, "P%u", 1U) + { } + + void exterm(machine_config &config); + +protected: + virtual void machine_start() override; + +private: + required_device m_maincpu; + required_device m_audiocpu; + required_device m_audioslave; + required_device_array m_soundlatch; + required_device m_slave; + required_device m_ym2151; + required_device m_nmi_timer; + + required_shared_ptr m_master_videoram; + required_shared_ptr m_slave_videoram; + + required_ioport_array<2> m_dial; + required_ioport_array<2> m_input; + + uint8_t m_aimpos[2]{}; + uint8_t m_trackball_old[2]{}; + uint8_t m_sound_control = 0U; + uint16_t m_last = 0U; + + void host_data_w(offs_t offset, uint16_t data); + uint16_t host_data_r(offs_t offset); + template uint16_t trackball_port_r(); + void output_port_0_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_latch_w(uint8_t data); + void sound_nmi_rate_w(uint8_t data); + uint8_t sound_nmi_to_slave_r(); + void sound_control_w(uint8_t data); + void ym2151_data_latch_w(uint8_t data); + void exterm_palette(palette_device &palette) const; + TIMER_DEVICE_CALLBACK_MEMBER(master_sound_nmi_callback); + TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); + TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg_master); + TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_master); + TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg_slave); + TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_slave); + void master_map(address_map &map); + void slave_map(address_map &map); + void sound_master_map(address_map &map); + void sound_slave_map(address_map &map); +}; + + + +/************************************* + * + * Initialization + * + *************************************/ void exterm_state::machine_start() { @@ -83,6 +161,106 @@ void exterm_state::machine_start() } + +/************************************* + * + * Palette setup + * + *************************************/ + +void exterm_state::exterm_palette(palette_device &palette) const +{ + // initialize 555 RGB lookup + for (int i = 0; i < 32768; i++) + palette.set_pen_color(i + 0x800, pal5bit(i >> 10), pal5bit(i >> 5), pal5bit(i >> 0)); +} + + + +/************************************* + * + * Master shift register + * + *************************************/ + +TMS340X0_TO_SHIFTREG_CB_MEMBER(exterm_state::to_shiftreg_master) +{ + memcpy(shiftreg, &m_master_videoram[address >> 4], 256 * sizeof(uint16_t)); +} + + +TMS340X0_FROM_SHIFTREG_CB_MEMBER(exterm_state::from_shiftreg_master) +{ + memcpy(&m_master_videoram[address >> 4], shiftreg, 256 * sizeof(uint16_t)); +} + + +TMS340X0_TO_SHIFTREG_CB_MEMBER(exterm_state::to_shiftreg_slave) +{ + memcpy(shiftreg, &m_slave_videoram[address >> 4], 256 * 2 * sizeof(uint8_t)); +} + + +TMS340X0_FROM_SHIFTREG_CB_MEMBER(exterm_state::from_shiftreg_slave) +{ + memcpy(&m_slave_videoram[address >> 4], shiftreg, 256 * 2 * sizeof(uint8_t)); +} + + + +/************************************* + * + * Main video refresh + * + *************************************/ + +TMS340X0_SCANLINE_IND16_CB_MEMBER(exterm_state::scanline_update) +{ + uint16_t *const bgsrc = &m_master_videoram[(params->rowaddr << 8) & 0xff00]; + uint16_t *const dest = &bitmap.pix(scanline); + tms340x0_device::display_params fgparams; + int coladdr = params->coladdr; + int fgcoladdr = 0; + + /* get parameters for the slave CPU */ + m_slave->get_display_params(&fgparams); + + /* compute info about the slave vram */ + uint16_t *fgsrc = nullptr; + if (fgparams.enabled && scanline >= fgparams.veblnk && scanline < fgparams.vsblnk && fgparams.heblnk < fgparams.hsblnk) + { + fgsrc = &m_slave_videoram[((fgparams.rowaddr << 8) + (fgparams.yoffset << 7)) & 0xff80]; + fgcoladdr = (fgparams.coladdr >> 1); + } + + /* copy the non-blanked portions of this scanline */ + for (int x = params->heblnk; x < params->hsblnk; x += 2) + { + uint16_t bgdata, fgdata = 0; + + if (fgsrc != nullptr) + fgdata = fgsrc[fgcoladdr++ & 0x7f]; + + bgdata = bgsrc[coladdr++ & 0xff]; + if ((bgdata & 0xe000) == 0xe000) + dest[x + 0] = bgdata & 0x7ff; + else if ((fgdata & 0x00ff) != 0) + dest[x + 0] = fgdata & 0x00ff; + else + dest[x + 0] = (bgdata & 0x8000) ? (bgdata & 0x7ff) : (bgdata + 0x800); + + bgdata = bgsrc[coladdr++ & 0xff]; + if ((bgdata & 0xe000) == 0xe000) + dest[x + 1] = bgdata & 0x7ff; + else if ((fgdata & 0xff00) != 0) + dest[x + 1] = fgdata >> 8; + else + dest[x + 1] = (bgdata & 0x8000) ? (bgdata & 0x7ff) : (bgdata + 0x800); + } +} + + + /************************************* * * Master/slave communications @@ -136,6 +314,7 @@ uint16_t exterm_state::trackball_port_r() } + /************************************* * * Output port handlers @@ -362,6 +541,7 @@ static INPUT_PORTS_START( exterm ) INPUT_PORTS_END + /************************************* * * Machine drivers @@ -461,6 +641,8 @@ ROM_START( exterm ) ROM_LOAD16_BYTE( "v101p1", 0x1e0001, 0x10000, CRC(557bfc84) SHA1(8d0f1b40adbf851a85f626663956f3726ca8026d) ) ROM_END +} // anonymous namespace + /************************************* diff --git a/src/mame/gottlieb/exterm.h b/src/mame/gottlieb/exterm.h deleted file mode 100644 index dac86d18e72..00000000000 --- a/src/mame/gottlieb/exterm.h +++ /dev/null @@ -1,84 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Alex Pasadyn,Zsolt Vasvari,Aaron Giles -/************************************************************************* - - Gottlieb Exterminator hardware - -*************************************************************************/ -#ifndef MAME_GOTTLIEB_EXTERM_H -#define MAME_GOTTLIEB_EXTERM_H - -#pragma once - -#include "cpu/tms34010/tms34010.h" -#include "machine/gen_latch.h" -#include "machine/timer.h" -#include "sound/ymopm.h" -#include "emupal.h" - -class exterm_state : public driver_device -{ -public: - exterm_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_audioslave(*this, "audioslave"), - m_soundlatch(*this, "soundlatch%u", 1), - m_slave(*this, "slave"), - m_ym2151(*this, "ymsnd"), - m_nmi_timer(*this, "snd_nmi_timer"), - m_master_videoram(*this, "master_videoram"), - m_slave_videoram(*this, "slave_videoram"), - m_dial(*this, "DIAL%u", 0U), - m_input(*this, "P%u", 1U) - { } - - void exterm(machine_config &config); - -protected: - virtual void machine_start() override; - -private: - required_device m_maincpu; - required_device m_audiocpu; - required_device m_audioslave; - required_device_array m_soundlatch; - required_device m_slave; - required_device m_ym2151; - required_device m_nmi_timer; - - required_shared_ptr m_master_videoram; - required_shared_ptr m_slave_videoram; - - required_ioport_array<2> m_dial; - required_ioport_array<2> m_input; - - uint8_t m_aimpos[2]{}; - uint8_t m_trackball_old[2]{}; - uint8_t m_sound_control = 0U; - uint16_t m_last = 0U; - - void host_data_w(offs_t offset, uint16_t data); - uint16_t host_data_r(offs_t offset); - template uint16_t trackball_port_r(); - void output_port_0_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_latch_w(uint8_t data); - void sound_nmi_rate_w(uint8_t data); - uint8_t sound_nmi_to_slave_r(); - void sound_control_w(uint8_t data); - void ym2151_data_latch_w(uint8_t data); - void exterm_palette(palette_device &palette) const; - TIMER_DEVICE_CALLBACK_MEMBER(master_sound_nmi_callback); - TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update); - TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg_master); - TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_master); - TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg_slave); - TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_slave); - void master_map(address_map &map); - void slave_map(address_map &map); - void sound_master_map(address_map &map); - void sound_slave_map(address_map &map); -}; - -#endif // MAME_GOTTLIEB_EXTERM_H diff --git a/src/mame/gottlieb/exterm_v.cpp b/src/mame/gottlieb/exterm_v.cpp deleted file mode 100644 index 044073b6db8..00000000000 --- a/src/mame/gottlieb/exterm_v.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Alex Pasadyn,Zsolt Vasvari,Aaron Giles -/*************************************************************************** - - Gottlieb Exterminator hardware - -***************************************************************************/ - -#include "emu.h" -#include "exterm.h" - - -/************************************* - * - * Palette setup - * - *************************************/ - -void exterm_state::exterm_palette(palette_device &palette) const -{ - // initialize 555 RGB lookup - for (int i = 0; i < 32768; i++) - palette.set_pen_color(i + 0x800, pal5bit(i >> 10), pal5bit(i >> 5), pal5bit(i >> 0)); -} - - - -/************************************* - * - * Master shift register - * - *************************************/ - -TMS340X0_TO_SHIFTREG_CB_MEMBER(exterm_state::to_shiftreg_master) -{ - memcpy(shiftreg, &m_master_videoram[address >> 4], 256 * sizeof(uint16_t)); -} - - -TMS340X0_FROM_SHIFTREG_CB_MEMBER(exterm_state::from_shiftreg_master) -{ - memcpy(&m_master_videoram[address >> 4], shiftreg, 256 * sizeof(uint16_t)); -} - - -TMS340X0_TO_SHIFTREG_CB_MEMBER(exterm_state::to_shiftreg_slave) -{ - memcpy(shiftreg, &m_slave_videoram[address >> 4], 256 * 2 * sizeof(uint8_t)); -} - - -TMS340X0_FROM_SHIFTREG_CB_MEMBER(exterm_state::from_shiftreg_slave) -{ - memcpy(&m_slave_videoram[address >> 4], shiftreg, 256 * 2 * sizeof(uint8_t)); -} - - - -/************************************* - * - * Main video refresh - * - *************************************/ - -TMS340X0_SCANLINE_IND16_CB_MEMBER(exterm_state::scanline_update) -{ - uint16_t *const bgsrc = &m_master_videoram[(params->rowaddr << 8) & 0xff00]; - uint16_t *const dest = &bitmap.pix(scanline); - tms340x0_device::display_params fgparams; - int coladdr = params->coladdr; - int fgcoladdr = 0; - - /* get parameters for the slave CPU */ - m_slave->get_display_params(&fgparams); - - /* compute info about the slave vram */ - uint16_t *fgsrc = nullptr; - if (fgparams.enabled && scanline >= fgparams.veblnk && scanline < fgparams.vsblnk && fgparams.heblnk < fgparams.hsblnk) - { - fgsrc = &m_slave_videoram[((fgparams.rowaddr << 8) + (fgparams.yoffset << 7)) & 0xff80]; - fgcoladdr = (fgparams.coladdr >> 1); - } - - /* copy the non-blanked portions of this scanline */ - for (int x = params->heblnk; x < params->hsblnk; x += 2) - { - uint16_t bgdata, fgdata = 0; - - if (fgsrc != nullptr) - fgdata = fgsrc[fgcoladdr++ & 0x7f]; - - bgdata = bgsrc[coladdr++ & 0xff]; - if ((bgdata & 0xe000) == 0xe000) - dest[x + 0] = bgdata & 0x7ff; - else if ((fgdata & 0x00ff) != 0) - dest[x + 0] = fgdata & 0x00ff; - else - dest[x + 0] = (bgdata & 0x8000) ? (bgdata & 0x7ff) : (bgdata + 0x800); - - bgdata = bgsrc[coladdr++ & 0xff]; - if ((bgdata & 0xe000) == 0xe000) - dest[x + 1] = bgdata & 0x7ff; - else if ((fgdata & 0xff00) != 0) - dest[x + 1] = fgdata >> 8; - else - dest[x + 1] = (bgdata & 0x8000) ? (bgdata & 0x7ff) : (bgdata + 0x800); - } -} diff --git a/src/mame/gottlieb/gottlieb.cpp b/src/mame/gottlieb/gottlieb.cpp index 96ee4038043..7ac37a3675f 100644 --- a/src/mame/gottlieb/gottlieb.cpp +++ b/src/mame/gottlieb/gottlieb.cpp @@ -197,23 +197,178 @@ VBlank duration: 1/VSYNC * (16/256) = 1017.6 us ***************************************************************************/ #include "emu.h" -#include "gottlieb.h" +#include "gottlieb_a.h" +#include "cpu/i86/i86.h" +#include "cpu/m6502/m6502.h" +#include "machine/ldpr8210.h" #include "machine/nvram.h" #include "machine/rescap.h" #include "machine/watchdog.h" #include "sound/dac.h" +#include "sound/samples.h" +#include "video/resnet.h" + +#include "emupal.h" +#include "screen.h" #include "speaker.h" +#include "tilemap.h" + +#define LOG_AUDIO_DECODE (0) -#define LOG_AUDIO_DECODE (0) +#define SYSTEM_CLOCK XTAL(20'000'000) +#define CPU_CLOCK XTAL(15'000'000) +#define NTSC_CLOCK XTAL(14'318'181) +#define LASERDISC_CLOCK PERIOD_OF_555_ASTABLE(16000, 10000, 0.001e-6) -#define SYSTEM_CLOCK XTAL(20'000'000) -#define CPU_CLOCK XTAL(15'000'000) -#define NTSC_CLOCK XTAL(14'318'181) -#define LASERDISC_CLOCK PERIOD_OF_555_ASTABLE(16000, 10000, 0.001e-6) +#define AUDIORAM_SIZE 0x400 -#define AUDIORAM_SIZE 0x400 +#define GOTTLIEB_VIDEO_HCOUNT 318 +#define GOTTLIEB_VIDEO_HBLANK 256 +#define GOTTLIEB_VIDEO_VCOUNT 256 +#define GOTTLIEB_VIDEO_VBLANK 240 + +namespace { + +class gottlieb_state : public driver_device +{ +public: + gottlieb_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_laserdisc(*this, "laserdisc") + , m_r1_sound(*this, "r1sound") + , m_r2_sound(*this, "r2sound") + , m_knocker_sample(*this, "knocker_sam") + , m_videoram(*this, "videoram") + , m_charram(*this, "charram") + , m_spriteram(*this, "spriteram") + , m_gfxdecode(*this, "gfxdecode") + , m_screen(*this, "screen") + , m_palette(*this, "palette") + , m_paletteram(*this, "paletteram") + , m_track_x(*this, "TRACKX") + , m_track_y(*this, "TRACKY") + , m_leds(*this, "led%u", 0U) + , m_knockers(*this, "knocker%d", 0U) + { } + + void gottlieb_core(machine_config &config); + void cobram3(machine_config &config); + void screwloo(machine_config &config); + void gottlieb2(machine_config &config); + void gottlieb2_ram_rom(machine_config &config); + void reactor(machine_config &config); + void tylz(machine_config &config); + void g2laser(machine_config &config); + void qbert(machine_config &config); + void qbert_knocker(machine_config &config); + void gottlieb1(machine_config &config); + void gottlieb1_rom(machine_config &config); + void gottlieb1_votrax(machine_config &config); + + void init_romtiles(); + void init_screwloo(); + void init_vidvince(); + void init_ramtiles(); + void init_stooges(); + void init_qbert(); + void init_qbertqub(); + + template DECLARE_CUSTOM_INPUT_MEMBER(track_delta_r); + DECLARE_CUSTOM_INPUT_MEMBER(stooges_joystick_r); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + void analog_reset_w(u8 data); + void general_output_w(u8 data); + void reactor_output_w(u8 data); + void stooges_output_w(u8 data); + void qbertqub_output_w(u8 data); + void qbert_output_w(u8 data); + void qbert_knocker(u8 knock); + u8 laserdisc_status_r(offs_t offset); + void laserdisc_select_w(u8 data); + void laserdisc_command_w(u8 data); + void sound_w(u8 data); + void palette_w(offs_t offset, u8 data); + void video_control_w(u8 data); + void laserdisc_video_control_w(u8 data); + void videoram_w(offs_t offset, u8 data); + void charram_w(offs_t offset, u8 data); + TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILE_GET_INFO_MEMBER(get_screwloo_bg_tile_info); + DECLARE_VIDEO_START(screwloo); + uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(interrupt); + TIMER_CALLBACK_MEMBER(laserdisc_philips_callback); + TIMER_CALLBACK_MEMBER(laserdisc_bit_off_callback); + TIMER_CALLBACK_MEMBER(laserdisc_bit_callback); + TIMER_CALLBACK_MEMBER(nmi_clear); + void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); + inline void audio_end_state(); + void audio_process_clock(bool logit); + void audio_handle_zero_crossing(const attotime &zerotime, bool logit); + void laserdisc_audio_process(int samplerate, int samples, const int16_t *ch0, const int16_t *ch1); + + void gottlieb_base_map(address_map &map); + void gottlieb_ram_map(address_map &map); + void gottlieb_ram_rom_map(address_map &map); + void gottlieb_rom_map(address_map &map); + void reactor_map(address_map &map); + + // devices + required_device m_maincpu; + optional_device m_laserdisc; + optional_device m_r1_sound; + optional_device m_r2_sound; + optional_device m_knocker_sample; + + required_shared_ptr m_videoram; + required_shared_ptr m_charram; + required_shared_ptr m_spriteram; + + required_device m_gfxdecode; + required_device m_screen; + required_device m_palette; + required_shared_ptr m_paletteram; + + optional_ioport m_track_x; + optional_ioport m_track_y; + output_finder<3> m_leds; // only used by reactor + output_finder<1> m_knockers; // only used by qbert + + u8 m_knocker_prev = 0U; + u8 m_joystick_select = 0U; + u8 m_track[2]{}; + emu_timer *m_laserdisc_bit_timer = nullptr; + emu_timer *m_laserdisc_bit_off_timer = nullptr; + emu_timer *m_laserdisc_philips_timer = nullptr; + emu_timer *m_nmi_clear_timer = nullptr; + u8 m_laserdisc_select = 0U; + u8 m_laserdisc_status = 0U; + uint16_t m_laserdisc_philips_code = 0U; + std::unique_ptr m_laserdisc_audio_buffer; + uint16_t m_laserdisc_audio_address = 0U; + int16_t m_laserdisc_last_samples[2]{}; + attotime m_laserdisc_last_time; + attotime m_laserdisc_last_clock; + u8 m_laserdisc_zero_seen = 0U; + u8 m_laserdisc_audio_bits = 0U; + u8 m_laserdisc_audio_bit_count = 0U; + u8 m_gfxcharlo = 0U; + u8 m_gfxcharhi = 0U; + u8 m_background_priority = 0U; + u8 m_spritebank = 0U; + u8 m_transparent0 = 0U; + tilemap_t *m_bg_tilemap = nullptr; + double m_weights[4]{}; +}; @@ -227,6 +382,7 @@ void gottlieb_state::machine_start() { m_leds.resolve(); m_knockers.resolve(); + /* register for save states */ save_item(NAME(m_joystick_select)); save_item(NAME(m_track)); @@ -271,6 +427,54 @@ void gottlieb_state::machine_start() } +void gottlieb_state::video_start() +{ + static const int resistances[4] = { 2000, 1000, 470, 240 }; + + /* compute palette information */ + /* note that there really are pullup/pulldown resistors, but this situation is complicated */ + /* by the use of transistors, so we ignore that and just use the realtive resistor weights */ + compute_resistor_weights(0, 255, -1.0, + 4, resistances, m_weights, 180, 0, + 4, resistances, m_weights, 180, 0, + 4, resistances, m_weights, 180, 0); + m_transparent0 = false; + + /* configure the background tilemap */ + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(gottlieb_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_bg_tilemap->set_transparent_pen(0); + + /* save some state */ + save_item(NAME(m_background_priority)); + save_item(NAME(m_spritebank)); + save_item(NAME(m_transparent0)); +} + + +VIDEO_START_MEMBER(gottlieb_state,screwloo) +{ + static const int resistances[4] = { 2000, 1000, 470, 240 }; + + /* compute palette information */ + /* note that there really are pullup/pulldown resistors, but this situation is complicated */ + /* by the use of transistors, so we ignore that and just use the realtive resistor weights */ + compute_resistor_weights(0, 255, -1.0, + 4, resistances, m_weights, 180, 0, + 4, resistances, m_weights, 180, 0, + 4, resistances, m_weights, 180, 0); + m_transparent0 = false; + + /* configure the background tilemap */ + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(gottlieb_state::get_screwloo_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_bg_tilemap->set_transparent_pen(0); + + /* save some state */ + save_item(NAME(m_background_priority)); + save_item(NAME(m_spritebank)); + save_item(NAME(m_transparent0)); +} + + void gottlieb_state::machine_reset() { /* if we have a laserdisc, reset our philips code callback for the next line 17 */ @@ -280,6 +484,179 @@ void gottlieb_state::machine_reset() +/************************************* + * + * Palette RAM writes + * + *************************************/ + +void gottlieb_state::palette_w(offs_t offset, u8 data) +{ + int val; + + m_paletteram[offset] = data; + + /* blue & green are encoded in the even bytes */ + val = m_paletteram[offset & ~1]; + int const g = combine_weights(m_weights, BIT(val, 4), BIT(val, 5), BIT(val, 6), BIT(val, 7)); + int const b = combine_weights(m_weights, BIT(val, 0), BIT(val, 1), BIT(val, 2), BIT(val, 3)); + + /* red is encoded in the odd bytes */ + val = m_paletteram[offset | 1]; + int const r = combine_weights(m_weights, BIT(val, 0), BIT(val, 1), BIT(val, 2), BIT(val, 3)); + + /* alpha is set to 0 if laserdisc video is enabled */ + int const a = (m_transparent0 && offset / 2 == 0) ? 0 : 255; + m_palette->set_pen_color(offset / 2, rgb_t(a, r, g, b)); +} + + + +/************************************* + * + * Video controls + * + *************************************/ + +void gottlieb_state::video_control_w(u8 data) +{ + /* bit 0 controls foreground/background priority */ + if (m_background_priority != (BIT(data, 0))) + m_screen->update_partial(m_screen->vpos()); + m_background_priority = BIT(data, 0); + + /* bit 1 controls horizontal flip screen */ + flip_screen_x_set(BIT(data, 1)); + + /* bit 2 controls vertical flip screen */ + flip_screen_y_set(BIT(data, 2)); +} + + +void gottlieb_state::laserdisc_video_control_w(u8 data) +{ + /* bit 0 works like the other games */ + video_control_w(BIT(data, 0)); + + /* bit 1 controls the sprite bank. */ + m_spritebank = BIT(data, 1); + + /* bit 2 video enable (0 = black screen) */ + /* bit 3 genlock control (1 = show laserdisc image) */ + m_laserdisc->overlay_enable((data & 0x04) ? true : false); + m_laserdisc->video_enable(((data & 0x0c) == 0x0c) ? true : false); + + /* configure the palette if the laserdisc is enabled */ + m_transparent0 = BIT(data, 3); + palette_w(0, m_paletteram[0]); +} + + + +/************************************* + * + * Video RAM and character RAM access + * + *************************************/ + +void gottlieb_state::videoram_w(offs_t offset, u8 data) +{ + m_videoram[offset] = data; + m_bg_tilemap->mark_tile_dirty(offset); +} + + +void gottlieb_state::charram_w(offs_t offset, u8 data) +{ + if (m_charram[offset] != data) + { + m_charram[offset] = data; + m_gfxdecode->gfx(0)->mark_dirty(offset / 32); + } +} + + +TILE_GET_INFO_MEMBER(gottlieb_state::get_bg_tile_info) +{ + int code = m_videoram[tile_index]; + if ((code & 0x80) == 0) + tileinfo.set(m_gfxcharlo, code, 0, 0); + else + tileinfo.set(m_gfxcharhi, code, 0, 0); +} + +TILE_GET_INFO_MEMBER(gottlieb_state::get_screwloo_bg_tile_info) +{ + int code = m_videoram[tile_index]; + if ((code & 0xc0) == 0) + tileinfo.set(m_gfxcharlo, code, 0, 0); + else + tileinfo.set(m_gfxcharhi, code, 0, 0); +} + + + +/************************************* + * + * Sprite rendering + * + *************************************/ + +void gottlieb_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + rectangle clip = cliprect; + int offs; + + /* this is a temporary guess until the sprite hardware is better understood */ + /* there is some additional clipping, but this may not be it */ + clip.min_x = 8; + + for (offs = 0; offs < 256; offs += 4) + { + /* coordinates hand tuned to make the position correct in Q*Bert Qubes start */ + /* of level animation. */ + int sx = (m_spriteram[offs + 1]) - 4; + int sy = (m_spriteram[offs]) - 13; + int code = (255 ^ m_spriteram[offs + 2]) + 256 * m_spritebank; + + if (flip_screen_x()) sx = 233 - sx; + if (flip_screen_y()) sy = 228 - sy; + + m_gfxdecode->gfx(2)->transpen(bitmap,clip, + code, 0, + flip_screen_x(), flip_screen_y(), + sx,sy, 0); + } +} + + + +/************************************* + * + * Video update + * + *************************************/ + +uint32_t gottlieb_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + /* if the background has lower priority, render it first, else clear the screen */ + if (!m_background_priority) + m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); + else + bitmap.fill(m_palette->pen(0), cliprect); + + /* draw the sprites */ + draw_sprites(bitmap, cliprect); + + /* if the background has higher priority, render it now */ + if (m_background_priority) + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + return 0; +} + + + /************************************* * * Input ports @@ -2644,6 +3021,8 @@ void gottlieb_state::init_vidvince() m_gfxcharhi = 0; } +} // anonymous namespace + /************************************* diff --git a/src/mame/gottlieb/gottlieb.h b/src/mame/gottlieb/gottlieb.h deleted file mode 100644 index a979c578db3..00000000000 --- a/src/mame/gottlieb/gottlieb.h +++ /dev/null @@ -1,168 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabrice Frances, Nicola Salmoria, Aaron Giles -/*************************************************************************** - - Gottlieb hardware - -***************************************************************************/ - -#include "gottlieb_a.h" -#include "cpu/i86/i86.h" -#include "cpu/m6502/m6502.h" -#include "sound/samples.h" -#include "machine/ldpr8210.h" -#include "emupal.h" -#include "screen.h" -#include "tilemap.h" - - -#define GOTTLIEB_VIDEO_HCOUNT 318 -#define GOTTLIEB_VIDEO_HBLANK 256 -#define GOTTLIEB_VIDEO_VCOUNT 256 -#define GOTTLIEB_VIDEO_VBLANK 240 - - - - -// ======================> gottlieb_state - -// shared driver state -class gottlieb_state : public driver_device -{ -public: - gottlieb_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_maincpu(*this, "maincpu") - , m_laserdisc(*this, "laserdisc") - , m_r1_sound(*this, "r1sound") - , m_r2_sound(*this, "r2sound") - , m_knocker_sample(*this, "knocker_sam") - , m_videoram(*this, "videoram") - , m_charram(*this, "charram") - , m_spriteram(*this, "spriteram") - , m_gfxdecode(*this, "gfxdecode") - , m_screen(*this, "screen") - , m_palette(*this, "palette") - , m_paletteram(*this, "paletteram") - , m_track_x(*this, "TRACKX") - , m_track_y(*this, "TRACKY") - , m_leds(*this, "led%u", 0U) - , m_knockers(*this, "knocker%d", 0U) - { } - - void gottlieb_core(machine_config &config); - void cobram3(machine_config &config); - void screwloo(machine_config &config); - void gottlieb2(machine_config &config); - void gottlieb2_ram_rom(machine_config &config); - void reactor(machine_config &config); - void tylz(machine_config &config); - void g2laser(machine_config &config); - void qbert(machine_config &config); - void qbert_knocker(machine_config &config); - void gottlieb1(machine_config &config); - void gottlieb1_rom(machine_config &config); - void gottlieb1_votrax(machine_config &config); - - void init_romtiles(); - void init_screwloo(); - void init_vidvince(); - void init_ramtiles(); - void init_stooges(); - void init_qbert(); - void init_qbertqub(); - - template DECLARE_CUSTOM_INPUT_MEMBER(track_delta_r); - DECLARE_CUSTOM_INPUT_MEMBER(stooges_joystick_r); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - -private: - void qbert_knocker(u8 knock); - - void analog_reset_w(u8 data); - void general_output_w(u8 data); - void reactor_output_w(u8 data); - void stooges_output_w(u8 data); - void qbertqub_output_w(u8 data); - void qbert_output_w(u8 data); - u8 laserdisc_status_r(offs_t offset); - void laserdisc_select_w(u8 data); - void laserdisc_command_w(u8 data); - void sound_w(u8 data); - void palette_w(offs_t offset, u8 data); - void video_control_w(u8 data); - void laserdisc_video_control_w(u8 data); - void videoram_w(offs_t offset, u8 data); - void charram_w(offs_t offset, u8 data); - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILE_GET_INFO_MEMBER(get_screwloo_bg_tile_info); - DECLARE_VIDEO_START(screwloo); - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(interrupt); - TIMER_CALLBACK_MEMBER(laserdisc_philips_callback); - TIMER_CALLBACK_MEMBER(laserdisc_bit_off_callback); - TIMER_CALLBACK_MEMBER(laserdisc_bit_callback); - TIMER_CALLBACK_MEMBER(nmi_clear); - void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect); - inline void audio_end_state(); - void audio_process_clock(bool logit); - void audio_handle_zero_crossing(const attotime &zerotime, bool logit); - void laserdisc_audio_process(int samplerate, int samples, const int16_t *ch0, const int16_t *ch1); - - void gottlieb_base_map(address_map &map); - void gottlieb_ram_map(address_map &map); - void gottlieb_ram_rom_map(address_map &map); - void gottlieb_rom_map(address_map &map); - void reactor_map(address_map &map); - - // devices - required_device m_maincpu; - optional_device m_laserdisc; - optional_device m_r1_sound; - optional_device m_r2_sound; - optional_device m_knocker_sample; - - required_shared_ptr m_videoram; - required_shared_ptr m_charram; - required_shared_ptr m_spriteram; - - required_device m_gfxdecode; - required_device m_screen; - required_device m_palette; - required_shared_ptr m_paletteram; - - optional_ioport m_track_x; - optional_ioport m_track_y; - output_finder<3> m_leds; // only used by reactor - output_finder<1> m_knockers; // only used by qbert - - u8 m_knocker_prev = 0U; - u8 m_joystick_select = 0U; - u8 m_track[2]{}; - emu_timer *m_laserdisc_bit_timer = nullptr; - emu_timer *m_laserdisc_bit_off_timer = nullptr; - emu_timer *m_laserdisc_philips_timer = nullptr; - emu_timer *m_nmi_clear_timer = nullptr; - u8 m_laserdisc_select = 0U; - u8 m_laserdisc_status = 0U; - uint16_t m_laserdisc_philips_code = 0U; - std::unique_ptr m_laserdisc_audio_buffer; - uint16_t m_laserdisc_audio_address = 0U; - int16_t m_laserdisc_last_samples[2]{}; - attotime m_laserdisc_last_time; - attotime m_laserdisc_last_clock; - u8 m_laserdisc_zero_seen = 0U; - u8 m_laserdisc_audio_bits = 0U; - u8 m_laserdisc_audio_bit_count = 0U; - u8 m_gfxcharlo = 0U; - u8 m_gfxcharhi = 0U; - u8 m_background_priority = 0U; - u8 m_spritebank = 0U; - u8 m_transparent0 = 0U; - tilemap_t *m_bg_tilemap = nullptr; - double m_weights[4]{}; -}; diff --git a/src/mame/gottlieb/gottlieb_v.cpp b/src/mame/gottlieb/gottlieb_v.cpp deleted file mode 100644 index 98e3eff5170..00000000000 --- a/src/mame/gottlieb/gottlieb_v.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabrice Frances, Nicola Salmoria, Aaron Giles -/*************************************************************************** - - Gottlieb hardware - -***************************************************************************/ - -#include "emu.h" -#include "gottlieb.h" -#include "video/resnet.h" - - -/************************************* - * - * Palette RAM writes - * - *************************************/ - -void gottlieb_state::palette_w(offs_t offset, u8 data) -{ - int val; - - m_paletteram[offset] = data; - - /* blue & green are encoded in the even bytes */ - val = m_paletteram[offset & ~1]; - int const g = combine_weights(m_weights, BIT(val, 4), BIT(val, 5), BIT(val, 6), BIT(val, 7)); - int const b = combine_weights(m_weights, BIT(val, 0), BIT(val, 1), BIT(val, 2), BIT(val, 3)); - - /* red is encoded in the odd bytes */ - val = m_paletteram[offset | 1]; - int const r = combine_weights(m_weights, BIT(val, 0), BIT(val, 1), BIT(val, 2), BIT(val, 3)); - - /* alpha is set to 0 if laserdisc video is enabled */ - int const a = (m_transparent0 && offset / 2 == 0) ? 0 : 255; - m_palette->set_pen_color(offset / 2, rgb_t(a, r, g, b)); -} - - -/************************************* - * - * Video controls - * - *************************************/ - -void gottlieb_state::video_control_w(u8 data) -{ - /* bit 0 controls foreground/background priority */ - if (m_background_priority != (BIT(data, 0))) - m_screen->update_partial(m_screen->vpos()); - m_background_priority = BIT(data, 0); - - /* bit 1 controls horizontal flip screen */ - flip_screen_x_set(BIT(data, 1)); - - /* bit 2 controls vertical flip screen */ - flip_screen_y_set(BIT(data, 2)); -} - - -void gottlieb_state::laserdisc_video_control_w(u8 data) -{ - /* bit 0 works like the other games */ - video_control_w(BIT(data, 0)); - - /* bit 1 controls the sprite bank. */ - m_spritebank = BIT(data, 1); - - /* bit 2 video enable (0 = black screen) */ - /* bit 3 genlock control (1 = show laserdisc image) */ - m_laserdisc->overlay_enable((data & 0x04) ? true : false); - m_laserdisc->video_enable(((data & 0x0c) == 0x0c) ? true : false); - - /* configure the palette if the laserdisc is enabled */ - m_transparent0 = BIT(data, 3); - palette_w(0, m_paletteram[0]); -} - - -/************************************* - * - * Video RAM and character RAM access - * - *************************************/ - -void gottlieb_state::videoram_w(offs_t offset, u8 data) -{ - m_videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); -} - - -void gottlieb_state::charram_w(offs_t offset, u8 data) -{ - if (m_charram[offset] != data) - { - m_charram[offset] = data; - m_gfxdecode->gfx(0)->mark_dirty(offset / 32); - } -} - - -/************************************* - * - * Palette RAM writes - * - *************************************/ - -TILE_GET_INFO_MEMBER(gottlieb_state::get_bg_tile_info) -{ - int code = m_videoram[tile_index]; - if ((code & 0x80) == 0) - tileinfo.set(m_gfxcharlo, code, 0, 0); - else - tileinfo.set(m_gfxcharhi, code, 0, 0); -} - -TILE_GET_INFO_MEMBER(gottlieb_state::get_screwloo_bg_tile_info) -{ - int code = m_videoram[tile_index]; - if ((code & 0xc0) == 0) - tileinfo.set(m_gfxcharlo, code, 0, 0); - else - tileinfo.set(m_gfxcharhi, code, 0, 0); -} - - -void gottlieb_state::video_start() -{ - static const int resistances[4] = { 2000, 1000, 470, 240 }; - - /* compute palette information */ - /* note that there really are pullup/pulldown resistors, but this situation is complicated */ - /* by the use of transistors, so we ignore that and just use the realtive resistor weights */ - compute_resistor_weights(0, 255, -1.0, - 4, resistances, m_weights, 180, 0, - 4, resistances, m_weights, 180, 0, - 4, resistances, m_weights, 180, 0); - m_transparent0 = false; - - /* configure the background tilemap */ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(gottlieb_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - m_bg_tilemap->set_transparent_pen(0); - - /* save some state */ - save_item(NAME(m_background_priority)); - save_item(NAME(m_spritebank)); - save_item(NAME(m_transparent0)); -} - -VIDEO_START_MEMBER(gottlieb_state,screwloo) -{ - static const int resistances[4] = { 2000, 1000, 470, 240 }; - - /* compute palette information */ - /* note that there really are pullup/pulldown resistors, but this situation is complicated */ - /* by the use of transistors, so we ignore that and just use the realtive resistor weights */ - compute_resistor_weights(0, 255, -1.0, - 4, resistances, m_weights, 180, 0, - 4, resistances, m_weights, 180, 0, - 4, resistances, m_weights, 180, 0); - m_transparent0 = false; - - /* configure the background tilemap */ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(gottlieb_state::get_screwloo_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - m_bg_tilemap->set_transparent_pen(0); - - /* save some state */ - save_item(NAME(m_background_priority)); - save_item(NAME(m_spritebank)); - save_item(NAME(m_transparent0)); -} - - - -/************************************* - * - * Sprite rendering - * - *************************************/ - -void gottlieb_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - rectangle clip = cliprect; - int offs; - - /* this is a temporary guess until the sprite hardware is better understood */ - /* there is some additional clipping, but this may not be it */ - clip.min_x = 8; - - for (offs = 0; offs < 256; offs += 4) - { - /* coordinates hand tuned to make the position correct in Q*Bert Qubes start */ - /* of level animation. */ - int sx = (m_spriteram[offs + 1]) - 4; - int sy = (m_spriteram[offs]) - 13; - int code = (255 ^ m_spriteram[offs + 2]) + 256 * m_spritebank; - - if (flip_screen_x()) sx = 233 - sx; - if (flip_screen_y()) sy = 228 - sy; - - m_gfxdecode->gfx(2)->transpen(bitmap,clip, - code, 0, - flip_screen_x(), flip_screen_y(), - sx,sy, 0); - } -} - - - -/************************************* - * - * Video update - * - *************************************/ - -uint32_t gottlieb_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - /* if the background has lower priority, render it first, else clear the screen */ - if (!m_background_priority) - m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); - else - bitmap.fill(m_palette->pen(0), cliprect); - - /* draw the sprites */ - draw_sprites(bitmap, cliprect); - - /* if the background has higher priority, render it now */ - if (m_background_priority) - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - return 0; -} diff --git a/src/mame/pinball/icecold.cpp b/src/mame/pinball/icecold.cpp index add488baf27..df830141730 100644 --- a/src/mame/pinball/icecold.cpp +++ b/src/mame/pinball/icecold.cpp @@ -14,7 +14,6 @@ How to play 6. To miss, press the wrong button, it says OOPS. 7. After 3 misses, the game ends. - ****************************************************************************/ #include "emu.h" @@ -33,20 +32,20 @@ namespace { class icecold_state : public driver_device { public: - icecold_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_ay8910(*this, "ay%u", 0U), - m_pia1(*this, "pia1"), - m_digit_outputs(*this, "digit%u", 0U), - m_lamp_outputs(*this, "lamp%u", 1U), - m_lmotor_output(*this, "lmotor"), - m_rmotor_output(*this, "rmotor"), - m_in_play(*this, "in_play"), - m_good_game(*this, "good_game"), - m_game_over(*this, "game_over"), - m_tilt_output(*this, "tilt"), - m_start_output(*this, "start") + icecold_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_ay8910(*this, "ay%u", 0U), + m_pia1(*this, "pia1"), + m_digit_outputs(*this, "digit%u", 0U), + m_lamp_outputs(*this, "lamp%u", 1U), + m_lmotor_output(*this, "lmotor"), + m_rmotor_output(*this, "rmotor"), + m_in_play(*this, "in_play"), + m_good_game(*this, "good_game"), + m_game_over(*this, "game_over"), + m_tilt_output(*this, "tilt"), + m_start_output(*this, "start") { } void icecold(machine_config &config); @@ -54,6 +53,10 @@ public: DECLARE_INPUT_CHANGED_MEMBER( test_switch_press ); DECLARE_CUSTOM_INPUT_MEMBER( motors_limit_r ); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + private: void scanlines_w(uint8_t data); void digit_w(uint8_t data); @@ -66,10 +69,6 @@ private: void ay8910_1_b_w(uint8_t data); void motors_w(uint8_t data); - // driver_device overrides - virtual void machine_start() override; - virtual void machine_reset() override; - // devices required_device m_maincpu; required_device_array m_ay8910; @@ -86,10 +85,10 @@ private: output_finder<> m_tilt_output; output_finder<> m_start_output; - uint8_t m_digit = 0; // scanlines from i8279 - uint8_t m_sound_latch = 0; // sound bus latch - uint8_t m_ay_ctrl = 0; // ay controls line - uint8_t m_motors_ctrl = 0; // motors control + uint8_t m_digit = 0; // scanlines from i8279 + uint8_t m_sound_latch = 0; // sound bus latch + uint8_t m_ay_ctrl = 0; // ay controls line + uint8_t m_motors_ctrl = 0; // motors control int m_sint = 0; // SINT line int m_motenbl = 0; // /MOTENBL line int m_ball_gate_sw = 0; // ball gate switch -- cgit v1.2.3