From 2fedd39d2baffe6adb881a2fda9067299f117bf8 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Mon, 28 May 2018 17:42:12 +0200 Subject: cclimber, battles, crystal, ql, n64, ibmpcjr, tia: Miscellaneous machine().device and MCFG cleanups. (nw) --- src/mame/audio/cclimber.h | 12 ------- src/mame/audio/galaxian.cpp | 3 +- src/mame/audio/galaxian.h | 2 +- src/mame/drivers/cclimber.cpp | 17 ++------- src/mame/drivers/crystal.cpp | 11 +++--- src/mame/drivers/galaga.cpp | 38 ++++++++++---------- src/mame/drivers/galaxian.cpp | 19 +++++----- src/mame/drivers/ql.cpp | 3 +- src/mame/includes/cclimber.h | 6 +++- src/mame/includes/galaxian.h | 3 ++ src/mame/includes/xevious.h | 77 +++++++++++++++++++++++++-------------- src/mame/machine/xevious.cpp | 84 +++++++++++++++++++------------------------ src/mame/video/n64.cpp | 16 ++++----- src/mame/video/pc_t1t.cpp | 4 +-- src/mame/video/pc_t1t.h | 2 ++ src/mame/video/tia.cpp | 4 +-- src/mame/video/tia.h | 17 +++++++++ src/mame/video/vrender0.h | 13 ++++--- src/mame/video/zx8301.h | 10 +++--- 19 files changed, 176 insertions(+), 165 deletions(-) diff --git a/src/mame/audio/cclimber.h b/src/mame/audio/cclimber.h index 9e84673dee4..3ea38fc8b77 100644 --- a/src/mame/audio/cclimber.h +++ b/src/mame/audio/cclimber.h @@ -14,20 +14,8 @@ #include "sound/samples.h" -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - DECLARE_DEVICE_TYPE(CCLIMBER_AUDIO, cclimber_audio_device) -//************************************************************************** -// DEVICE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_CCLIMBER_AUDIO_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, CCLIMBER_AUDIO, 0) - - // ======================> cclimber_audio_device class cclimber_audio_device : public device_t diff --git a/src/mame/audio/galaxian.cpp b/src/mame/audio/galaxian.cpp index bdb4d18816c..930a93c6f08 100644 --- a/src/mame/audio/galaxian.cpp +++ b/src/mame/audio/galaxian.cpp @@ -393,6 +393,7 @@ galaxian_sound_device::galaxian_sound_device(const machine_config &mconfig, cons : device_t(mconfig, GALAXIAN, tag, owner, clock) , device_sound_interface(mconfig, *this) , m_lfo_val(0) + , m_discrete(*this, GAL_AUDIO) { } @@ -404,8 +405,6 @@ void galaxian_sound_device::device_start() { m_lfo_val = 0; - m_discrete = machine().device(GAL_AUDIO); - save_item(NAME(m_lfo_val)); } diff --git a/src/mame/audio/galaxian.h b/src/mame/audio/galaxian.h index 4a84a2f9e66..58ae3e360c2 100644 --- a/src/mame/audio/galaxian.h +++ b/src/mame/audio/galaxian.h @@ -35,7 +35,7 @@ protected: private: // internal state uint8_t m_lfo_val; - discrete_device *m_discrete; + required_device m_discrete; }; DECLARE_DEVICE_TYPE(GALAXIAN, galaxian_sound_device) diff --git a/src/mame/drivers/cclimber.cpp b/src/mame/drivers/cclimber.cpp index eccd68e34b3..f68ebbeb86f 100644 --- a/src/mame/drivers/cclimber.cpp +++ b/src/mame/drivers/cclimber.cpp @@ -242,7 +242,6 @@ Dip location verified from manual for: cclimber, guzzler, swimmer #include "audio/cclimber.h" #include "cpu/z80/z80.h" -#include "machine/segacrpt_device.h" #include "sound/ay8910.h" #include "sound/samples.h" #include "screen.h" @@ -1147,7 +1146,7 @@ MACHINE_CONFIG_START(cclimber_state::cclimber) /* sound hardware */ SPEAKER(config, "speaker").front_center(); - MCFG_CCLIMBER_AUDIO_ADD("cclimber_audio") + MCFG_DEVICE_ADD("cclimber_audio", CCLIMBER_AUDIO, 0) MACHINE_CONFIG_END MACHINE_CONFIG_START(cclimber_state::cclimberx) @@ -2669,18 +2668,8 @@ void cclimber_state::init_toprollr() { m_opcodes = std::make_unique(0x6000*3); - segacrpt_z80_device* cpu = (segacrpt_z80_device*)machine().device(":maincpu"); - - // this seems to be a messy abuse / use of the encryption, investigate - if (!cpu) - { - fatalerror("can't find cpu!\n"); - } - else - { - cpu->set_region_p(memregion("user1")->base()); - cpu->set_decrypted_p(m_opcodes.get()); - } + m_encrypted_cpu->set_region_p(memregion("user1")->base()); + m_encrypted_cpu->set_decrypted_p(m_opcodes.get()); membank("bank1")->configure_entries(0, 3, memregion("user1")->base(), 0x6000); membank("bank1d")->configure_entries(0, 3, m_opcodes.get(), 0x6000); diff --git a/src/mame/drivers/crystal.cpp b/src/mame/drivers/crystal.cpp index d365094f7fa..560ca9defe6 100644 --- a/src/mame/drivers/crystal.cpp +++ b/src/mame/drivers/crystal.cpp @@ -251,6 +251,7 @@ public: m_reset_patch(*this, "reset_patch"), m_maincpu(*this, "maincpu"), m_vr0(*this, "vr0"), + m_video(*this, "vrender"), m_ds1302(*this, "rtc"), m_screen(*this, "screen") { } @@ -266,6 +267,7 @@ public: /* devices */ required_device m_maincpu; required_device m_vr0; + required_device m_video; required_device m_ds1302; required_device m_screen; @@ -928,8 +930,6 @@ void crystal_state::machine_start() void crystal_state::machine_reset() { - int i; - memset(m_sysregs, 0, 0x10000); memset(m_vidregs, 0, 0x10000); @@ -943,13 +943,13 @@ void crystal_state::machine_reset() m_DMActrl[0] = 0; m_DMActrl[1] = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { *TimerRegsPtr(i) = 0xff << 8; m_Timer[i]->adjust(attotime::never); } - machine().device("vrender")->set_areas(m_textureram, m_frameram); + m_video->set_areas(m_textureram, m_frameram); #ifdef IDLE_LOOP_SPEEDUP m_FlipCntRead = 0; #endif @@ -1503,8 +1503,7 @@ MACHINE_CONFIG_START(crystal_state::crystal) MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, crystal_state, screen_vblank_crystal)) MCFG_SCREEN_PALETTE("palette") - MCFG_DEVICE_ADD("vr0", VIDEO_VRENDER0, 0) - MCFG_VIDEO_VRENDER0_CPU("maincpu") + MCFG_DEVICE_ADD("vr0", VIDEO_VRENDER0, 0, "maincpu") MCFG_PALETTE_ADD_RRRRRGGGGGGBBBBB("palette") diff --git a/src/mame/drivers/galaga.cpp b/src/mame/drivers/galaga.cpp index 12b43c78e75..5e6361d9e15 100644 --- a/src/mame/drivers/galaga.cpp +++ b/src/mame/drivers/galaga.cpp @@ -825,10 +825,15 @@ void galaga_state::machine_reset() m_cpu3_interrupt_timer->adjust(m_screen->time_until_pos(64), 64); } -MACHINE_RESET_MEMBER(xevious_state,battles) +void battles_state::machine_reset() { galaga_state::machine_reset(); - battles_customio_init(); + + m_customio_command = 0; + m_customio_prev_command = 0; + m_customio_command_count = 0; + m_customio_data = 0; + m_sound_played = 0; } @@ -927,14 +932,14 @@ void galaga_state::galaga_mem4(address_map &map) map(0x1000, 0x107f).ram(); } -void xevious_state::battles_mem4(address_map &map) +void battles_state::battles_mem4(address_map &map) { map(0x0000, 0x0fff).rom(); - map(0x4000, 0x4003).r(this, FUNC(xevious_state::battles_input_port_r)); - map(0x4001, 0x4001).w(this, FUNC(xevious_state::battles_CPU4_coin_w)); - map(0x5000, 0x5000).w(this, FUNC(xevious_state::battles_noise_sound_w)); - map(0x6000, 0x6000).rw(this, FUNC(xevious_state::battles_customio3_r), FUNC(xevious_state::battles_customio3_w)); - map(0x7000, 0x7000).rw(this, FUNC(xevious_state::battles_customio_data3_r), FUNC(xevious_state::battles_customio_data3_w)); + map(0x4000, 0x4003).r(this, FUNC(battles_state::input_port_r)); + map(0x4001, 0x4001).w(this, FUNC(battles_state::cpu4_coin_w)); + map(0x5000, 0x5000).w(this, FUNC(battles_state::noise_sound_w)); + map(0x6000, 0x6000).rw(this, FUNC(battles_state::customio3_r), FUNC(battles_state::customio3_w)); + map(0x7000, 0x7000).rw(this, FUNC(battles_state::customio_data3_r), FUNC(battles_state::customio_data3_w)); map(0x8000, 0x80ff).ram(); } @@ -1835,11 +1840,10 @@ MACHINE_CONFIG_START(xevious_state::xevious) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) MACHINE_CONFIG_END -MACHINE_CONFIG_START(xevious_state::battles) +MACHINE_CONFIG_START(battles_state::battles) xevious(config); /* basic machine hardware */ - MCFG_DEVICE_REMOVE("50xx") MCFG_DEVICE_REMOVE("54xx") MCFG_DEVICE_REMOVE("06xx") @@ -1855,11 +1859,9 @@ MACHINE_CONFIG_START(xevious_state::battles) MCFG_SCREEN_MODIFY("screen") MCFG_SCREEN_VBLANK_CALLBACK(WRITELINE(*this, galaga_state, vblank_irq)) - MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, xevious_state, battles_interrupt_4)) - - MCFG_TIMER_DRIVER_ADD("battles_nmi", xevious_state, battles_nmi_generate) + MCFG_DEVCB_CHAIN_OUTPUT(WRITELINE(*this, battles_state, interrupt_4)) - MCFG_MACHINE_RESET_OVERRIDE(xevious_state,battles) + MCFG_TIMER_DRIVER_ADD("nmi", battles_state, nmi_generate) /* sound hardware */ MCFG_DEVICE_REMOVE("discrete") @@ -3451,11 +3453,11 @@ void xevious_state::init_xevios() } -void xevious_state::init_battles() +void battles_state::driver_init() { /* replace the Namco I/O handlers with interface to the 4th CPU */ - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x7000, 0x700f, read8_delegate(FUNC(xevious_state::battles_customio_data0_r),this), write8_delegate(FUNC(xevious_state::battles_customio_data0_w),this) ); - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x7100, 0x7100, read8_delegate(FUNC(xevious_state::battles_customio0_r),this), write8_delegate(FUNC(xevious_state::battles_customio0_w),this) ); + m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x7000, 0x700f, read8_delegate(FUNC(battles_state::customio_data0_r),this), write8_delegate(FUNC(battles_state::customio_data0_w),this) ); + m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x7100, 0x7100, read8_delegate(FUNC(battles_state::customio0_r),this), write8_delegate(FUNC(battles_state::customio0_w),this) ); init_xevious(); } @@ -3496,7 +3498,7 @@ GAME( 1984, gatsbee, galaga, gatsbee, gatsbee, galaga_state, init_galaga, GAME( 1981, nebulbee, galaga, galagab, galaga, galaga_state, init_galaga, ROT90, "bootleg", "Nebulous Bee", MACHINE_SUPPORTS_SAVE | MACHINE_IMPERFECT_GRAPHICS | MACHINE_IMPERFECT_SOUND ) GAME( 1982, xevios, xevious, xevious, xevious, xevious_state, init_xevios, ROT90, "bootleg", "Xevios", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) -GAME( 1982, battles, xevious, battles, xevious, xevious_state, init_battles, ROT90, "bootleg", "Battles (set 1)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) +GAME( 1982, battles, xevious, battles, xevious, battles_state, driver_init, ROT90, "bootleg", "Battles (set 1)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1982, battles2, xevious, xevious, xevious, xevious_state, init_xevios, ROT90, "bootleg", "Battles (set 2)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 1982, dzigzag, digdug, dzigzag, digdug, digdug_state, empty_init, ROT90, "bootleg", "Zig Zag (Dig Dug hardware)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/galaxian.cpp b/src/mame/drivers/galaxian.cpp index a129a2ec115..5ee24834755 100644 --- a/src/mame/drivers/galaxian.cpp +++ b/src/mame/drivers/galaxian.cpp @@ -662,7 +662,6 @@ TODO: #include "cpu/s2650/s2650.h" #include "cpu/z80/z80.h" #include "machine/watchdog.h" -#include "sound/discrete.h" #include "sound/sn76496.h" #include "sound/volt_reg.h" #include "screen.h" @@ -828,23 +827,23 @@ READ8_MEMBER(galaxian_state::konami_sound_timer_r) WRITE8_MEMBER(galaxian_state::konami_sound_filter_w) { - discrete_device *discrete = machine().device("konami"); - static const char *const ayname[2] = { "8910.0", "8910.1" }; - int which, chan; - /* the offset is used as data, 6 channels * 2 bits each */ /* AV0 .. AV5 ==> AY8910 #2 */ /* AV6 .. AV11 ==> AY8910 #1 */ - for (which = 0; which < 2; which++) - if (machine().device(ayname[which]) != nullptr) - for (chan = 0; chan < 3; chan++) + for (int which = 0; which < 2; which++) + { + if (m_ay8910[which] != nullptr) + { + for (int chan = 0; chan < 3; chan++) { uint8_t bits = (offset >> (2 * chan + 6 * (1 - which))) & 3; /* low bit goes to 0.22uF capacitor = 220000pF */ /* high bit goes to 0.047uF capacitor = 47000pF */ - discrete->write(space, NODE(3 * which + chan + 11), bits); + m_discrete->write(space, NODE(3 * which + chan + 11), bits); } + } + } } @@ -6082,7 +6081,7 @@ MACHINE_CONFIG_START(galaxian_state::mshuttle) MCFG_DEVICE_IO_MAP(mshuttle_portmap) /* sound hardware */ - MCFG_CCLIMBER_AUDIO_ADD("cclimber_audio") + MCFG_DEVICE_ADD("cclimber_audio", CCLIMBER_AUDIO, 0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/ql.cpp b/src/mame/drivers/ql.cpp index 36fd99564b8..fc27af7dab2 100644 --- a/src/mame/drivers/ql.cpp +++ b/src/mame/drivers/ql.cpp @@ -922,8 +922,7 @@ MACHINE_CONFIG_START(ql_state::ql) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) // devices - MCFG_DEVICE_ADD(ZX8301_TAG, ZX8301, X1) - MCFG_ZX8301_CPU(M68008_TAG) + MCFG_DEVICE_ADD(ZX8301_TAG, ZX8301, X1, M68008_TAG) MCFG_ZX8301_VSYNC_CALLBACK(WRITELINE(ZX8302_TAG, zx8302_device, vsync_w)) MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) diff --git a/src/mame/includes/cclimber.h b/src/mame/includes/cclimber.h index 7bdcfe6cb94..35f5a5d050d 100644 --- a/src/mame/includes/cclimber.h +++ b/src/mame/includes/cclimber.h @@ -3,6 +3,7 @@ #include "machine/74259.h" #include "machine/gen_latch.h" +#include "machine/segacrpt_device.h" class cclimber_state : public driver_device { @@ -11,6 +12,7 @@ public: : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), + m_encrypted_cpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), m_mainlatch(*this, "mainlatch"), @@ -24,10 +26,12 @@ public: m_swimmer_background_color(*this, "bgcolor"), m_toprollr_bg_videoram(*this, "bg_videoram"), m_toprollr_bg_coloram(*this, "bg_coloram"), - m_decrypted_opcodes(*this, "decrypted_opcodes") { } + m_decrypted_opcodes(*this, "decrypted_opcodes") + { } required_device m_maincpu; optional_device m_audiocpu; + optional_device m_encrypted_cpu; required_device m_gfxdecode; required_device m_palette; required_device m_mainlatch; diff --git a/src/mame/includes/galaxian.h b/src/mame/includes/galaxian.h index 15035db7d73..1ffb511f76f 100644 --- a/src/mame/includes/galaxian.h +++ b/src/mame/includes/galaxian.h @@ -12,6 +12,7 @@ #include "sound/ay8910.h" #include "sound/dac.h" #include "sound/digitalk.h" +#include "sound/discrete.h" #include "screen.h" /* we scale horizontally by 3 to render stars correctly */ @@ -53,6 +54,7 @@ public: , m_screen(*this, "screen") , m_palette(*this, "palette") , m_soundlatch(*this, "soundlatch") + , m_discrete(*this, "konami") , m_fake_select(*this, "FAKE_SELECT") , m_tenspot_game_dsw(*this, {"IN2_GAME0", "IN2_GAME1", "IN2_GAME2", "IN2_GAME3", "IN2_GAME4", "IN2_GAME5", "IN2_GAME6", "IN2_GAME7", "IN2_GAME8", "IN2_GAME9"}) , m_spriteram(*this, "spriteram") @@ -379,6 +381,7 @@ protected: required_device m_screen; required_device m_palette; optional_device m_soundlatch; + optional_device m_discrete; optional_ioport m_fake_select; optional_ioport_array<10> m_tenspot_game_dsw; diff --git a/src/mame/includes/xevious.h b/src/mame/includes/xevious.h index 6bc6b9235dc..79db4ae98c6 100644 --- a/src/mame/includes/xevious.h +++ b/src/mame/includes/xevious.h @@ -1,6 +1,11 @@ // license:BSD-3-Clause // copyright-holders:Nicola Salmoria +#ifndef MAME_INCLUDES_XEVIOUS +#define MAME_INCLUDES_XEVIOUS + +#pragma once + #include "machine/timer.h" class xevious_state : public galaga_state @@ -30,16 +35,12 @@ public: int32_t m_xevious_bs[2]; void init_xevious(); void init_xevios(); - void init_battles(); TILE_GET_INFO_MEMBER(get_fg_tile_info); TILE_GET_INFO_MEMBER(get_bg_tile_info); DECLARE_VIDEO_START(xevious); DECLARE_PALETTE_INIT(xevious); DECLARE_MACHINE_RESET(xevios); - DECLARE_MACHINE_RESET(battles); uint32_t screen_update_xevious(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - DECLARE_WRITE_LINE_MEMBER(battles_interrupt_4); - TIMER_DEVICE_CALLBACK_MEMBER(battles_nmi_generate); void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); DECLARE_WRITE8_MEMBER( xevious_fg_videoram_w ); DECLARE_WRITE8_MEMBER( xevious_fg_colorram_w ); @@ -49,32 +50,54 @@ public: DECLARE_WRITE8_MEMBER( xevious_bs_w ); DECLARE_READ8_MEMBER( xevious_bb_r ); - // Custom I/O - void battles_customio_init(); - - DECLARE_READ8_MEMBER( battles_customio0_r ); - DECLARE_READ8_MEMBER( battles_customio_data0_r ); - DECLARE_READ8_MEMBER( battles_customio3_r ); - DECLARE_READ8_MEMBER( battles_customio_data3_r ); - DECLARE_READ8_MEMBER( battles_input_port_r ); + optional_device m_subcpu3; + void xevious(machine_config &config); + void xevious_map(address_map &map); +}; - DECLARE_WRITE8_MEMBER( battles_customio0_w ); - DECLARE_WRITE8_MEMBER( battles_customio_data0_w ); - DECLARE_WRITE8_MEMBER( battles_customio3_w ); - DECLARE_WRITE8_MEMBER( battles_customio_data3_w ); - DECLARE_WRITE8_MEMBER( battles_CPU4_coin_w ); - DECLARE_WRITE8_MEMBER( battles_noise_sound_w ); +class battles_state : public xevious_state +{ +public: + battles_state(const machine_config &mconfig, device_type type, const char *tag) + : xevious_state(mconfig, type, tag), + m_nmi_timer(*this, "nmi") + { + } - uint8_t m_customio[16]; - char m_battles_customio_command; - char m_battles_customio_prev_command; - char m_battles_customio_command_count; - char m_battles_customio_data; - char m_battles_sound_played; + void driver_init() override; - optional_device m_subcpu3; - void xevious(machine_config &config); void battles(machine_config &config); + +protected: + void machine_reset() override; + + DECLARE_WRITE_LINE_MEMBER(interrupt_4); + TIMER_DEVICE_CALLBACK_MEMBER(nmi_generate); + void battles_mem4(address_map &map); - void xevious_map(address_map &map); + + // Custom I/O + DECLARE_READ8_MEMBER( customio0_r ); + DECLARE_READ8_MEMBER( customio_data0_r ); + DECLARE_READ8_MEMBER( customio3_r ); + DECLARE_READ8_MEMBER( customio_data3_r ); + DECLARE_READ8_MEMBER( input_port_r ); + + DECLARE_WRITE8_MEMBER( customio0_w ); + DECLARE_WRITE8_MEMBER( customio_data0_w ); + DECLARE_WRITE8_MEMBER( customio3_w ); + DECLARE_WRITE8_MEMBER( customio_data3_w ); + DECLARE_WRITE8_MEMBER( cpu4_coin_w ); + DECLARE_WRITE8_MEMBER( noise_sound_w ); + + required_device m_nmi_timer; + + uint8_t m_customio[16]; + char m_customio_command; + char m_customio_prev_command; + char m_customio_command_count; + char m_customio_data; + char m_sound_played; }; + +#endif // MAME_INCLUDES_XEVIOUS \ No newline at end of file diff --git a/src/mame/machine/xevious.cpp b/src/mame/machine/xevious.cpp index 385dc424191..bed5fd35111 100644 --- a/src/mame/machine/xevious.cpp +++ b/src/mame/machine/xevious.cpp @@ -20,23 +20,13 @@ ***************************************************************************/ -void xevious_state::battles_customio_init() +TIMER_DEVICE_CALLBACK_MEMBER(battles_state::nmi_generate) { - m_battles_customio_command = 0; - m_battles_customio_prev_command = 0; - m_battles_customio_command_count = 0; - m_battles_customio_data = 0; - m_battles_sound_played = 0; -} - + m_customio_prev_command = m_customio_command; -TIMER_DEVICE_CALLBACK_MEMBER(xevious_state::battles_nmi_generate) -{ - m_battles_customio_prev_command = m_battles_customio_command; - - if( m_battles_customio_command & 0x10 ) + if( m_customio_command & 0x10 ) { - if( m_battles_customio_command_count == 0 ) + if( m_customio_command_count == 0 ) { m_subcpu3->pulse_input_line(INPUT_LINE_NMI, attotime::zero); } @@ -51,29 +41,29 @@ TIMER_DEVICE_CALLBACK_MEMBER(xevious_state::battles_nmi_generate) m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero); m_subcpu3->pulse_input_line(INPUT_LINE_NMI, attotime::zero); } - m_battles_customio_command_count++; + m_customio_command_count++; } -READ8_MEMBER( xevious_state::battles_customio0_r ) +READ8_MEMBER( battles_state::customio0_r ) { - logerror("%s: custom I/O Read = %02x\n", machine().describe_context(), m_battles_customio_command); - return m_battles_customio_command; + logerror("%s: custom I/O Read = %02x\n", machine().describe_context(), m_customio_command); + return m_customio_command; } -READ8_MEMBER( xevious_state::battles_customio3_r ) +READ8_MEMBER( battles_state::customio3_r ) { int return_data; if( m_subcpu3->pc() == 0xAE ){ /* CPU4 0xAA - 0xB9 : waiting for MB8851 ? */ - return_data = ( (m_battles_customio_command & 0x10) << 3) + return_data = ( (m_customio_command & 0x10) << 3) | 0x00 - | (m_battles_customio_command & 0x0f); + | (m_customio_command & 0x0f); }else{ - return_data = ( (m_battles_customio_prev_command & 0x10) << 3) + return_data = ( (m_customio_prev_command & 0x10) << 3) | 0x60 - | (m_battles_customio_prev_command & 0x0f); + | (m_customio_prev_command & 0x0f); } logerror("%s: custom I/O Read = %02x\n", machine().describe_context(), return_data); @@ -81,62 +71,60 @@ READ8_MEMBER( xevious_state::battles_customio3_r ) } -WRITE8_MEMBER( xevious_state::battles_customio0_w ) +WRITE8_MEMBER( battles_state::customio0_w ) { - timer_device *timer = machine().device("battles_nmi"); - logerror("%s: custom I/O Write = %02x\n", machine().describe_context(), data); - m_battles_customio_command = data; - m_battles_customio_command_count = 0; + m_customio_command = data; + m_customio_command_count = 0; switch (data) { case 0x10: - timer->reset(); + m_nmi_timer->reset(); return; /* nop */ } - timer->adjust(attotime::from_usec(166), 0, attotime::from_usec(166)); + m_nmi_timer->adjust(attotime::from_usec(166), 0, attotime::from_usec(166)); } -WRITE8_MEMBER( xevious_state::battles_customio3_w ) +WRITE8_MEMBER( battles_state::customio3_w ) { logerror("%s: custom I/O Write = %02x\n", machine().describe_context(), data); - m_battles_customio_command = data; + m_customio_command = data; } -READ8_MEMBER( xevious_state::battles_customio_data0_r ) +READ8_MEMBER( battles_state::customio_data0_r ) { - logerror("%s: custom I/O parameter %02x Read = %02x\n", machine().describe_context(), offset, m_battles_customio_data); + logerror("%s: custom I/O parameter %02x Read = %02x\n", machine().describe_context(), offset, m_customio_data); - return m_battles_customio_data; + return m_customio_data; } -READ8_MEMBER( xevious_state::battles_customio_data3_r ) +READ8_MEMBER( battles_state::customio_data3_r ) { - logerror("%s: custom I/O parameter %02x Read = %02x\n", machine().describe_context(), offset, m_battles_customio_data); - return m_battles_customio_data; + logerror("%s: custom I/O parameter %02x Read = %02x\n", machine().describe_context(), offset, m_customio_data); + return m_customio_data; } -WRITE8_MEMBER( xevious_state::battles_customio_data0_w ) +WRITE8_MEMBER( battles_state::customio_data0_w ) { logerror("%s: custom I/O parameter %02x Write = %02x\n", machine().describe_context(), offset, data); - m_battles_customio_data = data; + m_customio_data = data; } -WRITE8_MEMBER( xevious_state::battles_customio_data3_w ) +WRITE8_MEMBER( battles_state::customio_data3_w ) { logerror("%s: custom I/O parameter %02x Write = %02x\n", machine().describe_context(), offset, data); - m_battles_customio_data = data; + m_customio_data = data; } -WRITE8_MEMBER( xevious_state::battles_CPU4_coin_w ) +WRITE8_MEMBER( battles_state::cpu4_coin_w ) { m_leds[0] = BIT(data, 1); // Start 1 m_leds[1] = BIT(data, 0); // Start 2 @@ -147,10 +135,10 @@ WRITE8_MEMBER( xevious_state::battles_CPU4_coin_w ) } -WRITE8_MEMBER( xevious_state::battles_noise_sound_w ) +WRITE8_MEMBER( battles_state::noise_sound_w ) { logerror("%s: 50%02x Write = %02x\n", machine().describe_context(), offset, data); - if( (m_battles_sound_played == 0) && (data == 0xFF) ){ + if( (m_sound_played == 0) && (data == 0xFF) ){ if( m_customio[0] == 0x40 ){ m_samples->start(0, 0); } @@ -158,11 +146,11 @@ WRITE8_MEMBER( xevious_state::battles_noise_sound_w ) m_samples->start(0, 1); } } - m_battles_sound_played = data; + m_sound_played = data; } -READ8_MEMBER( xevious_state::battles_input_port_r ) +READ8_MEMBER( battles_state::input_port_r ) { switch ( offset ) { @@ -175,7 +163,7 @@ READ8_MEMBER( xevious_state::battles_input_port_r ) } -WRITE_LINE_MEMBER(xevious_state::battles_interrupt_4) +WRITE_LINE_MEMBER(battles_state::interrupt_4) { if (state) m_subcpu3->set_input_line(0, HOLD_LINE); diff --git a/src/mame/video/n64.cpp b/src/mame/video/n64.cpp index f951d0ad280..453592ac63e 100644 --- a/src/mame/video/n64.cpp +++ b/src/mame/video/n64.cpp @@ -112,16 +112,14 @@ void n64_state::video_start() uint32_t n64_state::screen_update_n64(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - n64_periphs* n64 = machine().device("rcp"); - - //uint16_t* frame_buffer = (uint16_t*)&rdram[(n64->vi_origin & 0xffffff) >> 2]; - //uint8_t* cvg_buffer = &m_rdp.m_hidden_bits[((n64->vi_origin & 0xffffff) >> 2) >> 1]; - //int32_t vibuffering = ((n64->vi_control & 2) && fsaa && divot); + //uint16_t* frame_buffer = (uint16_t*)&rdram[(m_rcp_periphs->vi_origin & 0xffffff) >> 2]; + //uint8_t* cvg_buffer = &m_rdp.m_hidden_bits[((m_rcp_periphs->vi_origin & 0xffffff) >> 2) >> 1]; + //int32_t vibuffering = ((m_rcp_periphs->vi_control & 2) && fsaa && divot); //vibuffering = 0; // Disabled for now /* - if (vibuffering && ((n64->vi_control & 3) == 2)) + if (vibuffering && ((m_rcp_periphs->vi_control & 3) == 2)) { if (frame_buffer) { @@ -134,7 +132,7 @@ uint32_t n64_state::screen_update_n64(screen_device &screen, bitmap_rgb32 &bitma curpixel_cvg = ((pix & 1) << 2) | (cvg_buffer[pixels ^ BYTE_ADDR_XOR] & 3); // Reuse of this variable if (curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2) && fsaa) { - newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &cvg_buffer[pixels ^ BYTE_ADDR_XOR], n64->vi_width); + newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &cvg_buffer[pixels ^ BYTE_ADDR_XOR], m_rcp_periphs->vi_width); ViBuffer[i][j] = newc; } else @@ -154,13 +152,13 @@ uint32_t n64_state::screen_update_n64(screen_device &screen, bitmap_rgb32 &bitma m_rdp->mark_frame(); - if (n64->vi_blank) + if (m_rcp_periphs->vi_blank) { bitmap.fill(0, screen.visible_area()); return 0; } - n64->video_update(bitmap); + m_rcp_periphs->video_update(bitmap); return 0; } diff --git a/src/mame/video/pc_t1t.cpp b/src/mame/video/pc_t1t.cpp index d8ffb866c34..e8566ecabb1 100644 --- a/src/mame/video/pc_t1t.cpp +++ b/src/mame/video/pc_t1t.cpp @@ -13,7 +13,6 @@ #include "emu.h" #include "pc_t1t.h" -#include "machine/pic8259.h" #include "machine/ram.h" #include "screen.h" @@ -65,6 +64,7 @@ pcvideo_t1000_device::pcvideo_t1000_device(const machine_config &mconfig, const pcvideo_pcjr_device::pcvideo_pcjr_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : pc_t1t_device(mconfig, PCVIDEO_PCJR, tag, owner, clock), + m_pic8259(*this, ":pic8259"), m_jxkanji(nullptr) { } @@ -1034,5 +1034,5 @@ WRITE_LINE_MEMBER( pcvideo_pcjr_device::pcjr_vsync_changed ) { m_pc_framecnt++; } - machine().device("pic8259")->ir5_w(state); + m_pic8259->ir5_w(state); } diff --git a/src/mame/video/pc_t1t.h b/src/mame/video/pc_t1t.h index af219d5f567..f928d567c7a 100644 --- a/src/mame/video/pc_t1t.h +++ b/src/mame/video/pc_t1t.h @@ -6,6 +6,7 @@ #include "video/mc6845.h" #include "machine/ram.h" #include "machine/bankdev.h" +#include "machine/pic8259.h" #define T1000_SCREEN_NAME "screen" #define T1000_MC6845_NAME "mc6845_t1000" @@ -132,6 +133,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual void device_start() override; + required_device m_pic8259; uint8_t *m_jxkanji; private: diff --git a/src/mame/video/tia.cpp b/src/mame/video/tia.cpp index f7efaa80ea7..45650cb15fc 100644 --- a/src/mame/video/tia.cpp +++ b/src/mame/video/tia.cpp @@ -8,7 +8,6 @@ #include "emu.h" #include "tia.h" -#include "sound/tiaintf.h" #include "screen.h" static const int nusiz[8][3] = @@ -359,6 +358,7 @@ tia_video_device::tia_video_device(const machine_config &mconfig, device_type ty , m_databus_contents_cb(*this) , m_vsync_cb(*this) , m_maincpu(*this, "^maincpu") + , m_tia(*this, finder_base::DUMMY_TAG) { } @@ -2015,7 +2015,7 @@ WRITE8_MEMBER( tia_video_device::write ) case 0x18: /* AUDF1 */ case 0x19: /* AUDV0 */ case 0x1A: /* AUDV1 */ - machine().device("tia")->tia_sound_w(space, offset, data); + m_tia->tia_sound_w(space, offset, data); break; case 0x1B: diff --git a/src/mame/video/tia.h b/src/mame/video/tia.h index 81226a2e693..ddcc369e0eb 100644 --- a/src/mame/video/tia.h +++ b/src/mame/video/tia.h @@ -5,6 +5,8 @@ #pragma once +#include "sound/tiaintf.h" + //************************************************************************** // MACROS / CONSTANTS //************************************************************************** @@ -65,6 +67,8 @@ protected: // construction/destruction tia_video_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + template void set_tia_tag(T &&tag) { m_tia.set_tag(std::forward(tag)); } + // device-level overrides virtual void device_start() override; virtual void device_reset() override; @@ -117,6 +121,7 @@ private: devcb_write16 m_vsync_cb; required_device m_maincpu; + required_device m_tia; struct player_gfx p0gfx; struct player_gfx p1gfx; @@ -212,6 +217,12 @@ private: class tia_pal_video_device : public tia_video_device { public: + template tia_pal_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&tia_tag) + : tia_pal_video_device(mconfig, tag, owner, clock) + { + m_tia.set_tag(std::forward(tia_tag)); + } + tia_pal_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: @@ -224,6 +235,12 @@ private: class tia_ntsc_video_device : public tia_video_device { public: + template tia_ntsc_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&tia_tag) + : tia_ntsc_video_device(mconfig, tag, owner, clock) + { + m_tia.set_tag(std::forward(tia_tag)); + } + tia_ntsc_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: diff --git a/src/mame/video/vrender0.h b/src/mame/video/vrender0.h index 5291f311984..5fb05fef8ff 100644 --- a/src/mame/video/vrender0.h +++ b/src/mame/video/vrender0.h @@ -13,13 +13,16 @@ class vr0video_device : public device_t { public: + template vr0video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag) + : vr0video_device(mconfig, tag, owner, clock) + { + m_cpu.set_tag(std::forward(cpu_tag)); + } + vr0video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - ~vr0video_device() {} int vrender0_ProcessPacket(uint32_t PacketPtr, uint16_t *Dest, uint8_t *TEXTURE); - void set_cpu_tag(const char *tag) { m_cpu.set_tag(tag); } - protected: // device-level overrides virtual void device_start() override; @@ -61,8 +64,4 @@ private: DECLARE_DEVICE_TYPE(VIDEO_VRENDER0, vr0video_device) - -#define MCFG_VIDEO_VRENDER0_CPU(_tag) \ - downcast(*device).set_cpu_tag(_tag); - #endif // MAME_VIDEO_VRENDER0_H diff --git a/src/mame/video/zx8301.h b/src/mame/video/zx8301.h index 87e8264afd7..4c92403a519 100644 --- a/src/mame/video/zx8301.h +++ b/src/mame/video/zx8301.h @@ -41,9 +41,6 @@ // INTERFACE CONFIGURATION MACROS ///************************************************************************* -#define MCFG_ZX8301_CPU(_tag) \ - downcast(*device).set_cpu_tag(_tag); - #define MCFG_ZX8301_VSYNC_CALLBACK(_write) \ devcb = &downcast(*device).set_vsync_wr_callback(DEVCB_##_write); @@ -61,10 +58,15 @@ class zx8301_device : public device_t, { public: // construction/destruction + template zx8301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag) + : zx8301_device(mconfig, tag, owner, clock) + { + m_cpu.set_tag(std::forward(cpu_tag)); + } + zx8301_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); template devcb_base &set_vsync_wr_callback(Object &&cb) { return m_write_vsync.set_callback(std::forward(cb)); } - void set_cpu_tag(const char *tag) { m_cpu.set_tag(tag); } DECLARE_WRITE8_MEMBER( control_w ); DECLARE_READ8_MEMBER( data_r ); -- cgit v1.2.3