diff --git a/src/mame/drivers/coco3.cpp b/src/mame/drivers/coco3.cpp index 4bdb82a89c9..0e0d91faca3 100644 --- a/src/mame/drivers/coco3.cpp +++ b/src/mame/drivers/coco3.cpp @@ -292,10 +292,7 @@ MACHINE_CONFIG_START(coco3_state::coco3) // video hardware MCFG_DEFAULT_LAYOUT(layout_coco3) - MCFG_DEVICE_ADD(GIME_TAG, GIME_NTSC, XTAL(28'636'363)) - MCFG_GIME_MAINCPU(MAINCPU_TAG) - MCFG_GIME_RAM(RAM_TAG) - MCFG_GIME_EXT(CARTRIDGE_TAG) + MCFG_DEVICE_ADD(GIME_TAG, GIME_NTSC, XTAL(28'636'363), MAINCPU_TAG, RAM_TAG, CARTRIDGE_TAG, MAINCPU_TAG) MCFG_GIME_HSYNC_CALLBACK(WRITELINE(PIA0_TAG, pia6821_device, ca1_w)) MCFG_GIME_FSYNC_CALLBACK(WRITELINE(PIA0_TAG, pia6821_device, cb1_w)) MCFG_GIME_IRQ_CALLBACK(WRITELINE(*this, coco3_state, gime_irq_w)) @@ -343,10 +340,7 @@ MACHINE_CONFIG_START(coco3_state::coco3p) MCFG_DEVICE_CLOCK(XTAL(28'475'000) / 32) // An additional 4.433618 MHz XTAL is required for PAL color encoding - MCFG_DEVICE_REPLACE(GIME_TAG, GIME_PAL, XTAL(28'475'000)) - MCFG_GIME_MAINCPU(MAINCPU_TAG) - MCFG_GIME_RAM(RAM_TAG) - MCFG_GIME_EXT(CARTRIDGE_TAG) + MCFG_DEVICE_REPLACE(GIME_TAG, GIME_PAL, XTAL(28'475'000), MAINCPU_TAG, RAM_TAG, CARTRIDGE_TAG, MAINCPU_TAG) MCFG_GIME_HSYNC_CALLBACK(WRITELINE(PIA0_TAG, pia6821_device, ca1_w)) MCFG_GIME_FSYNC_CALLBACK(WRITELINE(PIA0_TAG, pia6821_device, cb1_w)) MCFG_GIME_IRQ_CALLBACK(WRITELINE(*this, coco3_state, gime_irq_w)) diff --git a/src/mame/video/gime.cpp b/src/mame/video/gime.cpp index 96a88dd36b2..d872831ad84 100644 --- a/src/mame/video/gime.cpp +++ b/src/mame/video/gime.cpp @@ -114,9 +114,10 @@ gime_device::gime_device(const machine_config &mconfig, device_type type, const , m_write_irq(*this) , m_write_firq(*this) , m_read_floating_bus(*this) - , m_maincpu_tag(nullptr) - , m_ram_tag(nullptr) - , m_ext_tag(nullptr) + , 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) { } @@ -128,21 +129,6 @@ gime_device::gime_device(const machine_config &mconfig, device_type type, const void gime_device::device_start(void) { - // find the RAM device - make sure that it is started - m_ram = machine().device(m_ram_tag); - if (!m_ram->started()) - throw device_missing_dependencies(); - - // find the CART device - make sure that it is started - m_cart_device = machine().device(m_ext_tag); - if (!m_cart_device->started()) - throw device_missing_dependencies(); - - // find the CPU device - make sure that it is started - m_cpu = machine().device(m_maincpu_tag); - if (!m_cpu->started()) - throw device_missing_dependencies(); - // inherited device_start - need to do this after checking dependencies super::device_start(); @@ -172,7 +158,6 @@ void gime_device::device_start(void) m_read_floating_bus.resolve_safe(0); // set up ROM/RAM pointers - m_rom = machine().root_device().memregion(m_maincpu_tag)->base(); m_cart_rom = m_cart_device->get_cart_base(); m_cart_size = m_cart_device->get_cart_size(); @@ -573,7 +558,7 @@ void gime_device::update_memory(int bank) } else { - memory = &m_rom[(block & 3) * 0x2000]; + memory = &m_rom->base()[(block & 3) * 0x2000]; } is_read_only = true; } @@ -2022,28 +2007,14 @@ const uint8_t gime_device::hires_font[128][12] = // VARIATIONS //************************************************************************** -namespace -{ - class gime_ntsc_device : public gime_device - { - public: - gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : gime_device(mconfig, GIME_NTSC, tag, owner, clock, ntsc_round_fontdata8x12) - { - } - }; +DEFINE_DEVICE_TYPE(GIME_NTSC, gime_ntsc_device, "gime_ntsc", "TCC1014 (VC2645QC) GIME (NTSC)") +DEFINE_DEVICE_TYPE(GIME_PAL, gime_pal_device, "gime_pal", "TCC1014 (VC2645QC) GIME (PAL)") - class gime_pal_device : public gime_device - { - public: - gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : gime_device(mconfig, GIME_PAL, tag, owner, clock, pal_round_fontdata8x12) - { - } - }; -}; +gime_ntsc_device::gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : gime_device(mconfig, GIME_NTSC, tag, owner, clock, ntsc_round_fontdata8x12) { } + +gime_pal_device::gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : gime_device(mconfig, GIME_PAL, tag, owner, clock, pal_round_fontdata8x12) { } -DEFINE_DEVICE_TYPE_PRIVATE(GIME_NTSC, gime_device, gime_ntsc_device, "gime_ntsc", "TCC1014 (VC2645QC) GIME (NTSC)") -DEFINE_DEVICE_TYPE_PRIVATE(GIME_PAL, gime_device, gime_pal_device, "gime_pal", "TCC1014 (VC2645QC) GIME (PAL)") template class device_finder; template class device_finder; diff --git a/src/mame/video/gime.h b/src/mame/video/gime.h index 6361bd1269d..8c74b88c993 100644 --- a/src/mame/video/gime.h +++ b/src/mame/video/gime.h @@ -36,15 +36,6 @@ #define MCFG_GIME_FLOATING_BUS_CALLBACK(_read) \ devcb = &downcast(*device).set_floating_bus_rd_callback(DEVCB_##_read); -#define MCFG_GIME_MAINCPU(_tag) \ - downcast(*device).set_maincpu_tag(_tag); - -#define MCFG_GIME_RAM(_tag) \ - downcast(*device).set_ram_tag(_tag); - -#define MCFG_GIME_EXT(_tag) \ - downcast(*device).set_ext_tag(_tag); - //************************************************************************** // GIME CORE @@ -58,9 +49,6 @@ public: template devcb_base &set_irq_wr_callback(Object &&cb) { return m_write_irq.set_callback(std::forward(cb)); } template devcb_base &set_firq_wr_callback(Object &&cb) { return m_write_firq.set_callback(std::forward(cb)); } template devcb_base &set_floating_bus_rd_callback(Object &&cb) { return m_read_floating_bus.set_callback(std::forward(cb)); } - void set_maincpu_tag(const char *tag) { m_maincpu_tag = tag; } - void set_ram_tag(const char *tag) { m_ram_tag = tag; } - void set_ext_tag(const char *tag) { m_ext_tag = tag; } // read/write DECLARE_READ8_MEMBER( read ) { return read(offset); } @@ -109,7 +97,7 @@ protected: virtual void record_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline) override; virtual void record_partial_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline, int32_t start_clock, int32_t end_clock) override; -private: +protected: typedef mc6847_friend_device super; struct scanline_record @@ -168,35 +156,36 @@ private: devcb_read8 m_read_floating_bus; // device state - uint8_t m_gime_registers[16]; - uint8_t m_mmu[16]; - uint8_t m_ff22_value; - uint8_t m_interrupt_value; - uint8_t m_irq; - uint8_t m_firq; - uint16_t m_timer_value; + uint8_t m_gime_registers[16]; + uint8_t m_mmu[16]; + uint8_t m_ff22_value; + uint8_t m_interrupt_value; + uint8_t m_irq; + uint8_t m_firq; + uint16_t m_timer_value; bool m_is_blinking; bool m_composite_phase_invert; // video state bool m_legacy_video; - uint32_t m_video_position; - uint8_t m_line_in_row; + uint32_t m_video_position; + uint8_t m_line_in_row; scanline_record m_scanlines[25+192+26]; bool m_displayed_rgb; // palette state - uint8_t m_palette_rotated[1024][16]; - uint16_t m_palette_rotated_position; + uint8_t m_palette_rotated[1024][16]; + uint16_t m_palette_rotated_position; bool m_palette_rotated_position_used; // incidentals - ram_device * m_ram; + required_device m_maincpu; + required_device m_ram; emu_timer * m_gime_clock_timer; - cococart_slot_device * m_cart_device; + required_device m_cart_device; memory_bank * m_read_banks[9]; memory_bank * m_write_banks[9]; - uint8_t * m_rom; + required_memory_region m_rom; uint8_t * m_cart_rom; uint32_t m_cart_size; pixel_t m_composite_palette[64]; @@ -204,10 +193,6 @@ private: pixel_t m_rgb_palette[64]; uint8_t m_dummy_bank[0x2000]; - const char *m_maincpu_tag; /* tag of main CPU */ - const char *m_ram_tag; /* tag of RAM device */ - const char *m_ext_tag; /* tag of expansion device */ - // timer constants static const device_timer_id TIMER_FRAME = 0; static const device_timer_id TIMER_HSYNC_OFF = 1; @@ -296,7 +281,39 @@ private: // VARIATIONS //************************************************************************** -DECLARE_DEVICE_TYPE(GIME_NTSC, gime_device) -DECLARE_DEVICE_TYPE(GIME_PAL, gime_device) +class gime_ntsc_device : public gime_device +{ +public: + template + gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&ram_tag, V &&ext_tag, W &®ion_tag) + : gime_ntsc_device(mconfig, tag, owner, clock) + { + m_maincpu.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)); + } + + gime_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +class gime_pal_device : public gime_device +{ +public: + template + gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&ram_tag, V &&ext_tag, W &®ion_tag) + : gime_pal_device(mconfig, tag, owner, clock) + { + m_maincpu.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)); + } + + gime_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +DECLARE_DEVICE_TYPE(GIME_NTSC, gime_ntsc_device) +DECLARE_DEVICE_TYPE(GIME_PAL, gime_pal_device) #endif //MAME_VIDEO_GIME_H