diff --git a/src/mame/drivers/segaorun.cpp b/src/mame/drivers/segaorun.cpp index 83f0470fe0e..032881409de 100644 --- a/src/mame/drivers/segaorun.cpp +++ b/src/mame/drivers/segaorun.cpp @@ -477,7 +477,7 @@ void segaorun_state::memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t // port on the memory mapper is read //------------------------------------------------- -uint8_t segaorun_state::mapper_sound_r() +READ8_MEMBER(segaorun_state::mapper_sound_r) { return 0; } @@ -488,7 +488,7 @@ uint8_t segaorun_state::mapper_sound_r() // port on the memory mapper is written //------------------------------------------------- -void segaorun_state::mapper_sound_w(uint8_t data) +WRITE8_MEMBER(segaorun_state::mapper_sound_w) { synchronize(TID_SOUND_WRITE, data); } @@ -1208,7 +1208,9 @@ MACHINE_CONFIG_START(segaorun_state::outrun_base) MCFG_I8255_IN_PORTC_CB(READ8(segaorun_state, unknown_portc_r)) MCFG_I8255_OUT_PORTC_CB(WRITE8(segaorun_state, video_control_w)) - MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segaorun_state, memory_mapper, mapper_sound_r, mapper_sound_w) + MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segaorun_state, memory_mapper) + MCFG_SEGA_315_5195_SOUND_READ_CALLBACK(READ8(segaorun_state, mapper_sound_r)) + MCFG_SEGA_315_5195_SOUND_WRITE_CALLBACK(WRITE8(segaorun_state, mapper_sound_w)) // video hardware MCFG_GFXDECODE_ADD("gfxdecode", "palette", segaorun) diff --git a/src/mame/drivers/segas16b.cpp b/src/mame/drivers/segas16b.cpp index 763e97e2fa0..a16ec64a46b 100644 --- a/src/mame/drivers/segas16b.cpp +++ b/src/mame/drivers/segas16b.cpp @@ -972,7 +972,7 @@ void segas16b_state::memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t // memory mapper chip //------------------------------------------------- -uint8_t segas16b_state::mapper_sound_r() +READ8_MEMBER(segas16b_state::mapper_sound_r) { return 0; } @@ -983,17 +983,17 @@ uint8_t segas16b_state::mapper_sound_r() // memory mapper chip //------------------------------------------------- -void segas16b_state::mapper_sound_w(uint8_t data) +WRITE8_MEMBER(segas16b_state::mapper_sound_w) { if (m_soundlatch != nullptr) - m_soundlatch->write(m_soundcpu->space(AS_PROGRAM), 0, data & 0xff); + m_soundlatch->write(space, 0, data); if (m_soundcpu != nullptr) m_soundcpu->set_input_line(0, HOLD_LINE); } WRITE16_MEMBER( segas16b_state::sound_w16 ) { - mapper_sound_w(data); + mapper_sound_w(space, 0, data & 0xff); } //************************************************************************** @@ -3713,7 +3713,9 @@ MACHINE_CONFIG_START(segas16b_state::system16b) MCFG_NVRAM_ADD_0FILL("nvram") - MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segas16b_state, memory_mapper, mapper_sound_r, mapper_sound_w) + MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segas16b_state, memory_mapper) + MCFG_SEGA_315_5195_SOUND_READ_CALLBACK(READ8(segas16b_state, mapper_sound_r)) + MCFG_SEGA_315_5195_SOUND_WRITE_CALLBACK(WRITE8(segas16b_state, mapper_sound_w)) // video hardware MCFG_GFXDECODE_ADD("gfxdecode", "palette", segas16b) diff --git a/src/mame/drivers/segas18.cpp b/src/mame/drivers/segas18.cpp index b75f38996b4..4084e9d453e 100644 --- a/src/mame/drivers/segas18.cpp +++ b/src/mame/drivers/segas18.cpp @@ -125,12 +125,12 @@ void segas18_state::memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t i * *************************************/ -uint8_t segas18_state::mapper_sound_r() +READ8_MEMBER(segas18_state::mapper_sound_r) { return m_mcu_data; } -void segas18_state::mapper_sound_w(uint8_t data) +WRITE8_MEMBER(segas18_state::mapper_sound_w) { m_soundlatch->write(m_soundcpu->space(AS_PROGRAM), 0, data & 0xff); m_soundcpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); @@ -1332,7 +1332,9 @@ MACHINE_CONFIG_START(segas18_state::system18) MCFG_NVRAM_ADD_0FILL("nvram") - MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segas18_state, memory_mapper, mapper_sound_r, mapper_sound_w) + MCFG_SEGA_315_5195_MAPPER_ADD("mapper", "maincpu", segas18_state, memory_mapper) + MCFG_SEGA_315_5195_SOUND_READ_CALLBACK(READ8(segas18_state, mapper_sound_r)) + MCFG_SEGA_315_5195_SOUND_WRITE_CALLBACK(WRITE8(segas18_state, mapper_sound_w)) MCFG_DEVICE_ADD("io", SEGA_315_5296, 16000000) MCFG_315_5296_IN_PORTA_CB(IOPORT("P1")) diff --git a/src/mame/drivers/segaxbd.cpp b/src/mame/drivers/segaxbd.cpp index 44aa54f0230..0dc2fe89ba9 100644 --- a/src/mame/drivers/segaxbd.cpp +++ b/src/mame/drivers/segaxbd.cpp @@ -466,7 +466,7 @@ void segaxbd_state::timer_ack_callback() // sound_data_w - write data to the sound CPU //------------------------------------------------- -void segaxbd_state::sound_data_w(uint8_t data) +WRITE8_MEMBER(segaxbd_state::sound_data_w) { synchronize(TID_SOUND_WRITE, data); } @@ -1714,7 +1714,7 @@ MACHINE_CONFIG_START(segaxbd_state::xboard_base_mconfig ) MCFG_SEGA_315_5250_COMPARE_TIMER_ADD("cmptimer_main") MCFG_SEGA_315_5250_TIMER_ACK(segaxbd_state, timer_ack_callback) - MCFG_SEGA_315_5250_SOUND_WRITE(segaxbd_state, sound_data_w) + MCFG_SEGA_315_5250_SOUND_WRITE_CALLBACK(WRITE8(segaxbd_state, sound_data_w)) MCFG_SEGA_315_5250_COMPARE_TIMER_ADD("cmptimer_subx") diff --git a/src/mame/includes/segaorun.h b/src/mame/includes/segaorun.h index da1164315f7..caea1210299 100644 --- a/src/mame/includes/segaorun.h +++ b/src/mame/includes/segaorun.h @@ -64,8 +64,8 @@ public: // memory mapping void memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t index); - uint8_t mapper_sound_r(); - void mapper_sound_w(uint8_t data); + DECLARE_READ8_MEMBER(mapper_sound_r); + DECLARE_WRITE8_MEMBER(mapper_sound_w); // main CPU read/write handlers DECLARE_READ16_MEMBER( misc_io_r ); diff --git a/src/mame/includes/segas16b.h b/src/mame/includes/segas16b.h index dd2417ad17c..b255aa228f8 100644 --- a/src/mame/includes/segas16b.h +++ b/src/mame/includes/segas16b.h @@ -69,8 +69,8 @@ public: // memory mapping void memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t index); - uint8_t mapper_sound_r(); - void mapper_sound_w(uint8_t data); + DECLARE_READ8_MEMBER(mapper_sound_r); + DECLARE_WRITE8_MEMBER(mapper_sound_w); // main CPU read/write handlers DECLARE_WRITE16_MEMBER( rom_5704_bank_w ); diff --git a/src/mame/includes/segas18.h b/src/mame/includes/segas18.h index 5a824ed8ba7..39bb655a12b 100644 --- a/src/mame/includes/segas18.h +++ b/src/mame/includes/segas18.h @@ -62,8 +62,8 @@ public: // memory mapping void memory_mapper(sega_315_5195_mapper_device &mapper, uint8_t index); - uint8_t mapper_sound_r(); - void mapper_sound_w(uint8_t data); + DECLARE_READ8_MEMBER(mapper_sound_r); + DECLARE_WRITE8_MEMBER(mapper_sound_w); // read/write handlers DECLARE_WRITE8_MEMBER( rom_5874_bank_w ); diff --git a/src/mame/includes/segaxbd.h b/src/mame/includes/segaxbd.h index 427f92ee7e2..a8306d44247 100644 --- a/src/mame/includes/segaxbd.h +++ b/src/mame/includes/segaxbd.h @@ -103,7 +103,7 @@ protected: // compare/timer chip callbacks void timer_ack_callback(); - void sound_data_w(uint8_t data); + DECLARE_WRITE8_MEMBER(sound_data_w); DECLARE_WRITE8_MEMBER(pc_0_w); DECLARE_WRITE8_MEMBER(pd_0_w); diff --git a/src/mame/machine/segaic16.cpp b/src/mame/machine/segaic16.cpp index 52529c9f93a..665fb2b3166 100644 --- a/src/mame/machine/segaic16.cpp +++ b/src/mame/machine/segaic16.cpp @@ -202,6 +202,8 @@ sega_315_5195_mapper_device::sega_315_5195_mapper_device(const machine_config &m : device_t(mconfig, SEGA_315_5195_MEM_MAPPER, tag, owner, clock) , m_cpu(*this, finder_base::DUMMY_TAG) , m_cpuregion(*this, finder_base::DUMMY_TAG) + , m_sound_read(*this) + , m_sound_write(*this) , m_space(nullptr) , m_decrypted_space(nullptr) , m_curregion(0) @@ -234,19 +236,6 @@ void sega_315_5195_mapper_device::static_set_mapper(device_t &device, mapper_del } -//------------------------------------------------- -// static_set_sound_readwrite - configuration -// helper to set the sound read/write callbacks -//------------------------------------------------- - -void sega_315_5195_mapper_device::static_set_sound_readwrite(device_t &device, sound_read_delegate read, sound_write_delegate write) -{ - sega_315_5195_mapper_device &mapper = downcast(device); - mapper.m_sound_read = read; - mapper.m_sound_write = write; -} - - //------------------------------------------------- // write - handle a write to the memory mapper //------------------------------------------------- @@ -525,8 +514,8 @@ void sega_315_5195_mapper_device::device_start() { // bind our handlers m_mapper.bind_relative_to(*owner()); - m_sound_read.bind_relative_to(*owner()); - m_sound_write.bind_relative_to(*owner()); + m_sound_read.resolve(); + m_sound_write.resolve(); // if we are mapping an FD1089, tell all the banks fd1089_base_device *fd1089 = dynamic_cast(m_cpu.target()); @@ -953,6 +942,7 @@ void sega_315_5249_divider_device::execute(int mode) sega_315_5250_compare_timer_device::sega_315_5250_compare_timer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, SEGA_315_5250_COMPARE_TIMER, tag, owner, clock) + , m_sound_write(*this) { } @@ -969,18 +959,6 @@ void sega_315_5250_compare_timer_device::static_set_timer_ack(device_t &device, } -//------------------------------------------------- -// static_set_sound_readwrite - configuration -// helper to set the sound read/write callbacks -//------------------------------------------------- - -void sega_315_5250_compare_timer_device::static_set_sound_write(device_t &device, sound_write_delegate write) -{ - sega_315_5250_compare_timer_device &timer = downcast(device); - timer.m_sound_write = write; -} - - //------------------------------------------------- // clock - clock the timer //------------------------------------------------- @@ -1065,7 +1043,7 @@ void sega_315_5250_compare_timer_device::device_start() { // bind our handlers m_timer_ack.bind_relative_to(*owner()); - m_sound_write.bind_relative_to(*owner()); + m_sound_write.resolve(); // save states save_item(NAME(m_regs)); diff --git a/src/mame/machine/segaic16.h b/src/mame/machine/segaic16.h index b8e73ac6c84..1f04ac3c061 100644 --- a/src/mame/machine/segaic16.h +++ b/src/mame/machine/segaic16.h @@ -21,11 +21,14 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_SEGA_315_5195_MAPPER_ADD(_tag, _cputag, _class, _mapper, _read, _write) \ +#define MCFG_SEGA_315_5195_MAPPER_ADD(_tag, _cputag, _class, _mapper) \ MCFG_DEVICE_ADD(_tag, SEGA_315_5195_MEM_MAPPER, 0) \ sega_315_5195_mapper_device::static_set_cputag(*device, "^" _cputag); \ - sega_315_5195_mapper_device::static_set_mapper(*device, sega_315_5195_mapper_device::mapper_delegate(&_class::_mapper, #_class "::" #_mapper, nullptr, (_class *)nullptr)); \ - sega_315_5195_mapper_device::static_set_sound_readwrite(*device, sega_315_5195_mapper_device::sound_read_delegate(&_class::_read, #_class "::" #_read, nullptr, (_class *)nullptr), sega_315_5195_mapper_device::sound_write_delegate(&_class::_write, #_class "::" #_write, nullptr, (_class *)nullptr)); + sega_315_5195_mapper_device::static_set_mapper(*device, sega_315_5195_mapper_device::mapper_delegate(&_class::_mapper, #_class "::" #_mapper, nullptr, (_class *)nullptr)); +#define MCFG_SEGA_315_5195_SOUND_READ_CALLBACK(_devcb) \ + devcb = &sega_315_5195_mapper_device::static_set_sound_read(*device, DEVCB_##_devcb); +#define MCFG_SEGA_315_5195_SOUND_WRITE_CALLBACK(_devcb) \ + devcb = &sega_315_5195_mapper_device::static_set_sound_write(*device, DEVCB_##_devcb); #define MCFG_SEGA_315_5248_MULTIPLIER_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SEGA_315_5248_MULTIPLIER, 0) @@ -37,8 +40,8 @@ MCFG_DEVICE_ADD(_tag, SEGA_315_5250_COMPARE_TIMER, 0) #define MCFG_SEGA_315_5250_TIMER_ACK(_class, _func) \ sega_315_5250_compare_timer_device::static_set_timer_ack(*device, sega_315_5250_compare_timer_device::timer_ack_delegate(&_class::_func, #_class "::" #_func, nullptr, (_class *)nullptr)); -#define MCFG_SEGA_315_5250_SOUND_WRITE(_class, _func) \ - sega_315_5250_compare_timer_device::static_set_sound_write(*device, sega_315_5250_compare_timer_device::sound_write_delegate(&_class::_func, #_class "::" #_func, nullptr, (_class *)nullptr)); +#define MCFG_SEGA_315_5250_SOUND_WRITE_CALLBACK(_devcb) \ + devcb = &sega_315_5250_compare_timer_device::static_set_sound_write(*device, DEVCB_##_devcb); //************************************************************************** @@ -87,8 +90,6 @@ class sega_315_5195_mapper_device : public device_t { public: typedef device_delegate mapper_delegate; - typedef device_delegate sound_read_delegate; - typedef device_delegate sound_write_delegate; // construction/destruction sega_315_5195_mapper_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); @@ -96,7 +97,14 @@ public: // static configuration helpers static void static_set_cputag(device_t &device, const char *cpu); static void static_set_mapper(device_t &device, mapper_delegate callback); - static void static_set_sound_readwrite(device_t &device, sound_read_delegate read, sound_write_delegate write); + template static devcb_base &static_set_sound_read(device_t &device, Object &&object) + { + return downcast(device).m_sound_read.set_callback(std::forward(object)); + } + template static devcb_base &static_set_sound_write(device_t &device, Object &&object) + { + return downcast(device).m_sound_write.set_callback(std::forward(object)); + } // public interface DECLARE_READ8_MEMBER( read ); @@ -166,8 +174,8 @@ private: required_device m_cpu; required_memory_region m_cpuregion; mapper_delegate m_mapper; - sound_read_delegate m_sound_read; - sound_write_delegate m_sound_write; + devcb_read8 m_sound_read; + devcb_write8 m_sound_write; // internal state address_space * m_space; @@ -232,7 +240,6 @@ private: class sega_315_5250_compare_timer_device : public device_t { public: - typedef device_delegate sound_write_delegate; typedef device_delegate timer_ack_delegate; // construction/destruction @@ -240,7 +247,10 @@ public: // static configuration helpers static void static_set_timer_ack(device_t &device, timer_ack_delegate callback); - static void static_set_sound_write(device_t &device, sound_write_delegate write); + template static devcb_base &static_set_sound_write(device_t &device, Object &&object) + { + return downcast(device).m_sound_write.set_callback(std::forward(object)); + } // public interface bool clock(); @@ -259,7 +269,7 @@ private: // configuration timer_ack_delegate m_timer_ack; - sound_write_delegate m_sound_write; + devcb_write8 m_sound_write; // internal state uint16_t m_regs[16];