From abef4f38dd796837c0ec949c387cdb707af3629c Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Tue, 5 Jun 2018 11:52:23 +0200 Subject: [PATCH] Fix recent coco3 regressions, nw --- src/mame/drivers/coco12.cpp | 2 +- src/mame/machine/6883sam.cpp | 8 ++------ src/mame/machine/6883sam.h | 26 ++++++++++---------------- src/mame/video/gime.cpp | 19 +++++++++++++++---- src/mame/video/gime.h | 13 ++++++++----- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/mame/drivers/coco12.cpp b/src/mame/drivers/coco12.cpp index 054829720a8..3fb12d89c6e 100644 --- a/src/mame/drivers/coco12.cpp +++ b/src/mame/drivers/coco12.cpp @@ -460,7 +460,7 @@ MACHINE_CONFIG_START(coco12_state::coco) MCFG_PIA_IRQA_HANDLER(WRITELINE(*this, coco_state, pia1_firq_a)) MCFG_PIA_IRQB_HANDLER(WRITELINE(*this, coco_state, pia1_firq_b)) - MCFG_SAM6883_ADD(SAM_TAG, XTAL(14'318'181), MAINCPU_TAG, AS_PROGRAM) + MCFG_DEVICE_ADD(SAM_TAG, SAM6883, XTAL(14'318'181), MAINCPU_TAG) MCFG_SAM6883_RES_CALLBACK(READ8(*this, coco12_state, sam_read)) // Becker Port device diff --git a/src/mame/machine/6883sam.cpp b/src/mame/machine/6883sam.cpp index ce77948b83c..03d86b20a1f 100644 --- a/src/mame/machine/6883sam.cpp +++ b/src/mame/machine/6883sam.cpp @@ -74,8 +74,6 @@ DEFINE_DEVICE_TYPE(SAM6883, sam6883_device, "sam6883", "MC6883 SAM") sam6883_device::sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, SAM6883, tag, owner, clock) , sam6883_friend_device_interface(mconfig, *this, 4) - , m_cpu_tag(nullptr) - , m_cpu_space_ref(AS_PROGRAM) , m_cpu_space(nullptr) , m_read_res(*this) , m_space_0000(*this) @@ -92,7 +90,7 @@ sam6883_device::sam6883_device(const machine_config &mconfig, const char *tag, d sam6883_friend_device_interface::sam6883_friend_device_interface(const machine_config &mconfig, device_t &device, int divider) : device_interface(device, "sam6883") - , m_cpu(nullptr) + , m_cpu(device, finder_base::DUMMY_TAG) , m_sam_state(0x0000) , m_divider(divider) { @@ -105,9 +103,7 @@ sam6883_friend_device_interface::sam6883_friend_device_interface(const machine_c void sam6883_device::device_start() { - // find the CPU - m_cpu = machine().device(m_cpu_tag); - m_cpu_space = &m_cpu->space(m_cpu_space_ref); + m_cpu_space = &m_cpu->space(AS_PROGRAM); // resolve callbacks m_read_res.resolve_safe(0); diff --git a/src/mame/machine/6883sam.h b/src/mame/machine/6883sam.h index 0817ab37503..7675588498e 100644 --- a/src/mame/machine/6883sam.h +++ b/src/mame/machine/6883sam.h @@ -14,10 +14,6 @@ #pragma once -#define MCFG_SAM6883_ADD(_tag, _clock, _cputag, _cpuspace) \ - MCFG_DEVICE_ADD(_tag, SAM6883, _clock) \ - downcast(*device).configure_cpu(_cputag, _cpuspace); - #define MCFG_SAM6883_RES_CALLBACK(_read) \ devcb = &downcast(*device).set_res_rd_callback(DEVCB_##_read); @@ -52,10 +48,10 @@ protected: static const uint16_t SAM_STATE_V0 = 0x0001; // incidentals - cpu_device * m_cpu; + required_device m_cpu; // device state - uint16_t m_sam_state; + uint16_t m_sam_state; // base clock divider (/4 for MC6883, /8 for GIME) int m_divider; @@ -89,16 +85,17 @@ protected: class sam6883_device : public device_t, public sam6883_friend_device_interface { public: - sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + template + sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag) + : sam6883_device(mconfig, tag, owner, clock) + { + m_cpu.set_tag(std::forward(cpu_tag)); + } + + sam6883_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); template devcb_base &set_res_rd_callback(Object &&cb) { return m_read_res.set_callback(std::forward(cb)); } - void configure_cpu(const char *tag, int space) - { - m_cpu_tag = tag; - m_cpu_space_ref = space; - } - // called to configure banks void configure_bank(int bank, uint8_t *memory, uint32_t memory_size, bool is_read_only); void configure_bank(int bank, read8_delegate rhandler, write8_delegate whandler); @@ -170,9 +167,6 @@ private: void point_specific_bank(const sam_bank &bank, uint32_t offset, uint32_t mask, memory_bank *&memory_bank, uint32_t addrstart, uint32_t addrend, bool is_write); }; - const char * m_cpu_tag; - int m_cpu_space_ref; - // incidentals address_space * m_cpu_space; devcb_read8 m_read_res; diff --git a/src/mame/video/gime.cpp b/src/mame/video/gime.cpp index d872831ad84..473138ce8b3 100644 --- a/src/mame/video/gime.cpp +++ b/src/mame/video/gime.cpp @@ -117,7 +117,8 @@ gime_device::gime_device(const machine_config &mconfig, device_type type, const , m_maincpu(*this, finder_base::DUMMY_TAG) , m_ram(*this, finder_base::DUMMY_TAG) , m_cart_device(*this, finder_base::DUMMY_TAG) - , m_rom(*this, finder_base::DUMMY_TAG) + , m_rom(nullptr) + , m_rom_region(*this, finder_base::DUMMY_TAG) { } @@ -129,7 +130,16 @@ gime_device::gime_device(const machine_config &mconfig, device_type type, const void gime_device::device_start(void) { - // inherited device_start - need to do this after checking dependencies + if (!m_ram->started()) + throw device_missing_dependencies(); + + if (!m_cart_device->started()) + throw device_missing_dependencies(); + + if (!m_cpu->started()) + throw device_missing_dependencies(); + + // inherited device_start - need to do this after checking dependencies super::device_start(); // initialize variables @@ -158,7 +168,8 @@ void gime_device::device_start(void) m_read_floating_bus.resolve_safe(0); // set up ROM/RAM pointers - m_cart_rom = m_cart_device->get_cart_base(); + m_rom = m_rom_region->base(); + m_cart_rom = m_cart_device->get_cart_base(); m_cart_size = m_cart_device->get_cart_size(); // populate palettes @@ -558,7 +569,7 @@ void gime_device::update_memory(int bank) } else { - memory = &m_rom->base()[(block & 3) * 0x2000]; + memory = &m_rom[(block & 3) * 0x2000]; } is_read_only = true; } diff --git a/src/mame/video/gime.h b/src/mame/video/gime.h index 8c74b88c993..d2269c06d82 100644 --- a/src/mame/video/gime.h +++ b/src/mame/video/gime.h @@ -185,7 +185,8 @@ protected: required_device m_cart_device; memory_bank * m_read_banks[9]; memory_bank * m_write_banks[9]; - required_memory_region m_rom; + uint8_t * m_rom; + required_memory_region m_rom_region; uint8_t * m_cart_rom; uint32_t m_cart_size; pixel_t m_composite_palette[64]; @@ -289,9 +290,10 @@ public: : gime_ntsc_device(mconfig, tag, owner, clock) { m_maincpu.set_tag(std::forward(cpu_tag)); - m_ram.set_tag(std::forward(ram_tag)); + m_cpu.set_tag(std::forward(cpu_tag)); + m_ram.set_tag(std::forward(ram_tag)); m_cart_device.set_tag(std::forward(ext_tag)); - m_rom.set_tag(std::forward(region_tag)); + m_rom_region.set_tag(std::forward(region_tag)); } gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); @@ -305,9 +307,10 @@ public: : gime_pal_device(mconfig, tag, owner, clock) { m_maincpu.set_tag(std::forward(cpu_tag)); - m_ram.set_tag(std::forward(ram_tag)); + m_cpu.set_tag(std::forward(cpu_tag)); + m_ram.set_tag(std::forward(ram_tag)); m_cart_device.set_tag(std::forward(ext_tag)); - m_rom.set_tag(std::forward(region_tag)); + m_rom_region.set_tag(std::forward(region_tag)); } gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);