summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2018-06-02 11:23:55 +0200
committer mooglyguy <therealmogminer@gmail.com>2018-06-02 11:23:55 +0200
commit63d057a35f1ef4e23ac06ae22aedd3d4bffa7159 (patch)
tree6957c13b36de3dbade39f7af0129d5536dadf4bf
parentf61f823ed6f640745e616c8cec235bb212191cd4 (diff)
32x: Eliminated machine().device, nw
-rw-r--r--src/mame/drivers/megadriv.cpp6
-rw-r--r--src/mame/includes/megadriv.h2
-rw-r--r--src/mame/machine/mega32x.cpp36
-rw-r--r--src/mame/machine/mega32x.h21
-rw-r--r--src/mame/machine/megadriv.cpp5
5 files changed, 47 insertions, 23 deletions
diff --git a/src/mame/drivers/megadriv.cpp b/src/mame/drivers/megadriv.cpp
index 54e5b909360..df731fefd05 100644
--- a/src/mame/drivers/megadriv.cpp
+++ b/src/mame/drivers/megadriv.cpp
@@ -609,7 +609,7 @@ MACHINE_CONFIG_START(md_cons_state::genesis_32x)
MCFG_SEGA315_5313_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
MCFG_SEGA315_5313_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
- MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0)
+ MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0, m_maincpu, m_scan_timer)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
MCFG_SCREEN_MODIFY("megadriv")
@@ -650,7 +650,7 @@ MACHINE_CONFIG_START(md_cons_state::mdj_32x)
MCFG_SEGA315_5313_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
MCFG_SEGA315_5313_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
- MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0)
+ MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0, m_maincpu, m_scan_timer)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
MCFG_SCREEN_MODIFY("megadriv")
@@ -691,7 +691,7 @@ MACHINE_CONFIG_START(md_cons_state::md_32x)
MCFG_SEGA315_5313_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
MCFG_SEGA315_5313_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
- MCFG_DEVICE_ADD("sega32x", SEGA_32X_PAL, 0)
+ MCFG_DEVICE_ADD("sega32x", SEGA_32X_PAL, 0, m_maincpu, m_scan_timer)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
MCFG_SCREEN_MODIFY("megadriv")
diff --git a/src/mame/includes/megadriv.h b/src/mame/includes/megadriv.h
index e2f239afcd3..95c9d44caf2 100644
--- a/src/mame/includes/megadriv.h
+++ b/src/mame/includes/megadriv.h
@@ -45,6 +45,7 @@ public:
m_maincpu(*this,"maincpu"),
m_z80snd(*this,"genesis_snd_z80"),
m_ymsnd(*this,"ymsnd"),
+ m_scan_timer(*this, "md_scan_timer"),
m_vdp(*this,"gen_vdp"),
m_snsnd(*this, "snsnd"),
m_megadrive_ram(*this,"megadrive_ram"),
@@ -53,6 +54,7 @@ public:
required_device<m68000_base_device> m_maincpu;
optional_device<cpu_device> m_z80snd;
optional_device<ym2612_device> m_ymsnd;
+ required_device<timer_device> m_scan_timer;
required_device<sega315_5313_device> m_vdp;
required_device<sn76496_base_device> m_snsnd;
optional_shared_ptr<uint16_t> m_megadrive_ram;
diff --git a/src/mame/machine/mega32x.cpp b/src/mame/machine/mega32x.cpp
index 8eef8453af2..9985e39ecac 100644
--- a/src/mame/machine/mega32x.cpp
+++ b/src/mame/machine/mega32x.cpp
@@ -231,10 +231,12 @@ DEFINE_DEVICE_TYPE(SEGA_32X_PAL, sega_32x_pal_device, "sega_32x_pal", "Sega 3
sega_32x_device::sega_32x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, m_sh2_shared(*this, "sh2_shared")
+ , m_main_cpu(*this, finder_base::DUMMY_TAG)
, m_master_cpu(*this, "32x_master_sh2")
, m_slave_cpu(*this, "32x_slave_sh2")
, m_ldac(*this, "ldac")
, m_rdac(*this, "rdac")
+ , m_scan_timer(*this, finder_base::DUMMY_TAG)
, m_palette(*this, finder_base::DUMMY_TAG)
{
}
@@ -419,7 +421,7 @@ WRITE16_MEMBER( sega_32x_device::_32x_68k_a15106_w )
READ16_MEMBER( sega_32x_device::_32x_dreq_common_r )
{
- address_space& _68kspace = machine().device("maincpu")->memory().space(AS_PROGRAM);
+ address_space& _68kspace = m_main_cpu->space(AS_PROGRAM);
switch (offset)
{
@@ -490,7 +492,7 @@ READ16_MEMBER( sega_32x_device::_32x_dreq_common_r )
WRITE16_MEMBER( sega_32x_device::_32x_dreq_common_w )
{
- address_space& _68kspace = machine().device("maincpu")->memory().space(AS_PROGRAM);
+ address_space& _68kspace = m_main_cpu->space(AS_PROGRAM);
switch (offset)
{
@@ -693,14 +695,14 @@ WRITE16_MEMBER( sega_32x_device::_32x_68k_a15100_w )
- machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
}
else
{
m_32x_adapter_enabled = 0;
space.install_rom(0x0000000, 0x03fffff, machine().root_device().memregion("gamecart")->base());
- machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
}
}
@@ -960,7 +962,7 @@ uint16_t sega_32x_device::get_hposition(void)
attotime time_elapsed_since_megadriv_scanline_timer;
uint16_t value4;
- time_elapsed_since_megadriv_scanline_timer = machine().device<timer_device>(":md_scan_timer")->time_elapsed();
+ time_elapsed_since_megadriv_scanline_timer = m_scan_timer->time_elapsed();
if (time_elapsed_since_megadriv_scanline_timer.attoseconds() < (ATTOSECONDS_PER_SECOND/m_framerate /m_total_scanlines))
{
@@ -1058,7 +1060,7 @@ WRITE16_MEMBER( sega_32x_device::_32x_common_vdp_regs_w )
{
// what happens if the z80 accesses it, what authorization do we use? which address space do we get?? the z80 *can* write here and to the framebuffer via the window
- address_space& _68kspace = machine().device("maincpu")->memory().space(AS_PROGRAM);
+ address_space& _68kspace = m_main_cpu->space(AS_PROGRAM);
if (&space!= &_68kspace)
{
@@ -1897,24 +1899,24 @@ void sega_32x_device::device_reset()
if (m_32x_adapter_enabled == 0)
{
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_rom(0x0000000, 0x03fffff, machine().root_device().memregion(":gamecart")->base());
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
+ m_main_cpu->space(AS_PROGRAM).install_rom(0x0000000, 0x03fffff, machine().root_device().memregion(":gamecart")->base());
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0x000070, 0x000073, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_hint_vector_w),this)); // h interrupt vector
};
m_a15100_reg = 0x0000;
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15100, 0xa15101, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15100_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15100_w),this)); // framebuffer control regs
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15102, 0xa15103, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15102_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15102_w),this)); // send irq to sh2
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15104, 0xa15105, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15104_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15104_w),this)); // 68k BANK rom set
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15106, 0xa15107, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15106_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15106_w),this)); // dreq stuff
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15108, 0xa15113, read16_delegate(FUNC(sega_32x_device::_32x_dreq_common_r),this), write16_delegate(FUNC(sega_32x_device::_32x_dreq_common_w),this)); // dreq src / dst / length /fifo
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15100, 0xa15101, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15100_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15100_w),this)); // framebuffer control regs
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15102, 0xa15103, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15102_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15102_w),this)); // send irq to sh2
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15104, 0xa15105, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15104_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15104_w),this)); // 68k BANK rom set
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15106, 0xa15107, read16_delegate(FUNC(sega_32x_device::_32x_68k_a15106_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a15106_w),this)); // dreq stuff
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15108, 0xa15113, read16_delegate(FUNC(sega_32x_device::_32x_dreq_common_r),this), write16_delegate(FUNC(sega_32x_device::_32x_dreq_common_w),this)); // dreq src / dst / length /fifo
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa1511a, 0xa1511b, read16_delegate(FUNC(sega_32x_device::_32x_68k_a1511a_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a1511a_w),this)); // SEGA TV
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa1511a, 0xa1511b, read16_delegate(FUNC(sega_32x_device::_32x_68k_a1511a_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_a1511a_w),this)); // SEGA TV
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15120, 0xa1512f, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_commsram_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_commsram_w),this)); // comms reg 0-7
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_readwrite_handler(0xa15130, 0xa1513f, read16_delegate(FUNC(sega_32x_device::_32x_pwm_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_pwm_w),this));
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15120, 0xa1512f, read16_delegate(FUNC(sega_32x_device::_32x_68k_m_commsram_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_m_commsram_w),this)); // comms reg 0-7
+ m_main_cpu->space(AS_PROGRAM).install_readwrite_handler(0xa15130, 0xa1513f, read16_delegate(FUNC(sega_32x_device::_32x_pwm_r),this), write16_delegate(FUNC(sega_32x_device::_32x_68k_pwm_w),this));
- machine().device(":maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0a130ec, 0x0a130ef, read16_delegate(FUNC(sega_32x_device::_32x_68k_MARS_r),this)); // system ID
+ m_main_cpu->space(AS_PROGRAM).install_read_handler(0x0a130ec, 0x0a130ef, read16_delegate(FUNC(sega_32x_device::_32x_68k_MARS_r),this)); // system ID
diff --git a/src/mame/machine/mega32x.h b/src/mame/machine/mega32x.h
index 169f339bc13..c7047ab9d44 100644
--- a/src/mame/machine/mega32x.h
+++ b/src/mame/machine/mega32x.h
@@ -6,8 +6,10 @@
#pragma once
+#include "cpu/m68000/m68000.h"
#include "cpu/sh/sh2.h"
#include "cpu/sh/sh2comn.h"
+#include "machine/timer.h"
#include "sound/dac.h"
class sega_32x_device : public device_t
@@ -107,6 +109,7 @@ public:
void sh2_main_map(address_map &map);
void sh2_slave_map(address_map &map);
+
protected:
sega_32x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
@@ -118,10 +121,12 @@ protected:
void update_total_scanlines(bool mode3) { m_total_scanlines = mode3 ? (m_base_total_scanlines * 2) : m_base_total_scanlines; } // this gets set at each EOF
/* our main vblank handler resets this */
+ required_device<m68000_base_device> m_main_cpu;
required_device<sh2_device> m_master_cpu;
required_device<sh2_device> m_slave_cpu;
required_device<dac_word_interface> m_ldac;
required_device<dac_word_interface> m_rdac;
+ required_device<timer_device> m_scan_timer;
int m_32x_hcount_compare_val;
int m_32x_vblank_flag;
@@ -202,6 +207,14 @@ private:
class sega_32x_ntsc_device : public sega_32x_device
{
public:
+ template <typename T, typename U>
+ sega_32x_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&main_cpu_tag, U &&timer_tag)
+ : sega_32x_ntsc_device(mconfig, tag, owner, clock)
+ {
+ m_main_cpu.set_tag(std::forward<T>(main_cpu_tag));
+ m_scan_timer.set_tag(std::forward<U>(timer_tag));
+ }
+
sega_32x_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
@@ -212,6 +225,14 @@ protected:
class sega_32x_pal_device : public sega_32x_device
{
public:
+ template <typename T, typename U>
+ sega_32x_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&main_cpu_tag, U &&timer_tag)
+ : sega_32x_pal_device(mconfig, tag, owner, clock)
+ {
+ m_main_cpu.set_tag(std::forward<T>(main_cpu_tag));
+ m_scan_timer.set_tag(std::forward<U>(timer_tag));
+ }
+
sega_32x_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
diff --git a/src/mame/machine/megadriv.cpp b/src/mame/machine/megadriv.cpp
index 01250dc6f0b..23dd1c0a956 100644
--- a/src/mame/machine/megadriv.cpp
+++ b/src/mame/machine/megadriv.cpp
@@ -808,7 +808,7 @@ MACHINE_RESET_MEMBER(md_base_state,megadriv)
if (!m_vdp->m_use_alt_timing)
{
- m_vdp->m_megadriv_scanline_timer = machine().device<timer_device>("md_scan_timer");
+ m_vdp->m_megadriv_scanline_timer = m_scan_timer;
m_vdp->m_megadriv_scanline_timer->adjust(attotime::zero);
}
@@ -878,7 +878,7 @@ IRQ_CALLBACK_MEMBER(md_base_state::genesis_int_callback)
}
MACHINE_CONFIG_START(md_base_state::megadriv_timers)
- MCFG_TIMER_DEVICE_ADD("md_scan_timer", "gen_vdp", sega315_5313_device, megadriv_scanline_timer_callback)
+ MCFG_TIMER_DEVICE_ADD(m_scan_timer, "gen_vdp", sega315_5313_device, megadriv_scanline_timer_callback)
MACHINE_CONFIG_END
@@ -998,7 +998,6 @@ void md_base_state::megadriv_init_common()
/* Look to see if this system has the standard Sound Z80 */
if (m_z80snd)
{
- //printf("GENESIS Sound Z80 cpu found '%s'\n", machine().device("genesis_snd_z80")->tag());
m_genz80.z80_prgram = std::make_unique<uint8_t[]>(0x2000);
membank("bank1")->set_base(m_genz80.z80_prgram.get());
save_item(NAME(m_genz80.z80_is_reset));