diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp index 2f8999363cb..fe6193f86fd 100644 --- a/src/devices/cpu/unsp/unsp.cpp +++ b/src/devices/cpu/unsp/unsp.cpp @@ -35,10 +35,10 @@ DEFINE_DEVICE_TYPE(UNSP_20, unsp_20_device, "unsp_20", "SunPlus u'nSP (ISA 2.0)" /* size of the execution code cache */ #define CACHE_SIZE (64 * 1024 * 1024) -unsp_device::unsp_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock) +unsp_device::unsp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) : cpu_device(mconfig, type, tag, owner, clock) , m_core(nullptr) - , m_program_config("program", ENDIANNESS_BIG, 16, 23, -1) + , m_program_config("program", ENDIANNESS_BIG, 16, 23, -1, internal) , m_program(nullptr) , m_debugger_temp(0) #if UNSP_LOG_OPCODES || UNSP_LOG_REGS @@ -62,42 +62,52 @@ unsp_device::unsp_device(const machine_config& mconfig, device_type type, const } unsp_device::unsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : unsp_device(mconfig, UNSP, tag, owner, clock) + : unsp_device(mconfig, UNSP, tag, owner, clock, address_map_constructor()) { m_iso = 10; } unsp_11_device::unsp_11_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : unsp_device(mconfig, UNSP_11, tag, owner, clock) + : unsp_device(mconfig, UNSP_11, tag, owner, clock, address_map_constructor()) { m_iso = 11; } -unsp_11_device::unsp_11_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock) - : unsp_device(mconfig, type, tag, owner, clock) +unsp_11_device::unsp_11_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) + : unsp_device(mconfig, type, tag, owner, clock, internal) { m_iso = 11; } unsp_12_device::unsp_12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : unsp_11_device(mconfig, UNSP_12, tag, owner, clock) + : unsp_11_device(mconfig, UNSP_12, tag, owner, clock, address_map_constructor()) { m_iso = 12; } -unsp_12_device::unsp_12_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock) - : unsp_11_device(mconfig, type, tag, owner, clock) +unsp_12_device::unsp_12_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) + : unsp_11_device(mconfig, type, tag, owner, clock, internal) { m_iso = 12; } unsp_20_device::unsp_20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : unsp_12_device(mconfig, UNSP_20, tag, owner, clock) + : unsp_12_device(mconfig, UNSP_20, tag, owner, clock, address_map_constructor()) { m_iso = 20; } +unsp_20_device::unsp_20_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) + : unsp_12_device(mconfig, UNSP_20, tag, owner, clock, internal) +{ + m_iso = 20; +} + +unsp_device::~unsp_device() +{ +} + // these are just for logging, can be removed once all ops are implemented char const* const unsp_device::regs[] = { diff --git a/src/devices/cpu/unsp/unsp.h b/src/devices/cpu/unsp/unsp.h index 0a9583e8fa4..1a42d68ed02 100644 --- a/src/devices/cpu/unsp/unsp.h +++ b/src/devices/cpu/unsp/unsp.h @@ -92,15 +92,8 @@ class unsp_device : public cpu_device public: // construction/destruction - unsp_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock); - unsp_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock); - - // HACK: IRQ line state can only be modified directly by hardware on-board the SPG SoC itself. - // Therefore, to avoid an unnecessary scheduler sync when the external spg2xx_device sets or - // clears an interrupt line, we provide this direct accessor. - // A more correct but longer-term solution will be to move spg2xx_device to be internal to - // a subclass of unsp_device rather than its own standalone device. - void set_state_unsynced(int inputnum, int state); + unsp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~unsp_device(); uint8_t get_csb(); @@ -117,6 +110,8 @@ public: #endif protected: + unsp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal); + // device-level overrides virtual void device_start() override; virtual void device_reset() override; @@ -140,6 +135,11 @@ protected: // device_disasm_interface overrides virtual std::unique_ptr create_disassembler() override; + // HACK: IRQ line state can only be modified directly by hardware on-board the SPG SoC itself. + // Therefore, to avoid an unnecessary scheduler sync when the derived spg2xx_device sets or + // clears an interrupt line, we provide this direct accessor. + void set_state_unsynced(int inputnum, int state); + enum : uint32_t { REG_SP = 0, @@ -327,7 +327,9 @@ class unsp_11_device : public unsp_device public: // construction/destruction unsp_11_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - unsp_11_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock); + +protected: + unsp_11_device(const machine_config& mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal); private: }; @@ -337,9 +339,10 @@ class unsp_12_device : public unsp_11_device public: // construction/destruction unsp_12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - unsp_12_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock); -private: +protected: + unsp_12_device(const machine_config& mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal); + virtual void execute_fxxx_101_group(uint16_t op) override; virtual void execute_exxx_group(uint16_t op) override; @@ -352,7 +355,9 @@ public: // construction/destruction unsp_20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); -private: +protected: + unsp_20_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal); + virtual std::unique_ptr create_disassembler() override; virtual void execute_extended_group(uint16_t op) override; diff --git a/src/devices/machine/spg110.cpp b/src/devices/machine/spg110.cpp index 5564c20db61..5dd98326166 100644 --- a/src/devices/machine/spg110.cpp +++ b/src/devices/machine/spg110.cpp @@ -16,10 +16,9 @@ DEFINE_DEVICE_TYPE(SPG110, spg110_device, "spg110", "SPG110 System-on-a-Chip") -spg110_device::spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) +spg110_device::spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) + : unsp_device(mconfig, type, tag, owner, clock, internal) , device_mixer_interface(mconfig, *this, 2) - , m_cpu(*this, finder_base::DUMMY_TAG) , m_screen(*this, finder_base::DUMMY_TAG) , m_spg_io(*this, "spg_io") , m_spg_video(*this, "spg_video") @@ -37,13 +36,13 @@ spg110_device::spg110_device(const machine_config &mconfig, device_type type, co spg110_device::spg110_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : spg110_device(mconfig, SPG110, tag, owner, clock) + : spg110_device(mconfig, SPG110, tag, owner, clock, address_map_constructor(FUNC(spg110_device::internal_map), this)) { } WRITE_LINE_MEMBER(spg110_device::videoirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ0_LINE, state); + set_state_unsynced(UNSP_IRQ0_LINE, state); } void spg110_device::configure_spg_io(spg2xx_io_device* io) @@ -67,22 +66,22 @@ void spg110_device::configure_spg_io(spg2xx_io_device* io) READ16_MEMBER(spg110_device::space_r) { - address_space &cpuspace = m_cpu->space(AS_PROGRAM); + address_space &cpuspace = this->space(AS_PROGRAM); return cpuspace.read_word(offset); } WRITE_LINE_MEMBER(spg110_device::audioirq_w) { - m_cpu->set_state_unsynced(UNSP_FIQ_LINE, state); + set_state_unsynced(UNSP_FIQ_LINE, state); } void spg110_device::device_add_mconfig(machine_config &config) { - SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); configure_spg_io(m_spg_io); - SPG110_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG110_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->write_video_irq_callback().set(FUNC(spg110_device::videoirq_w)); SPG110_AUDIO(config, m_spg_audio, DERIVED_CLOCK(1, 1)); @@ -94,7 +93,7 @@ void spg110_device::device_add_mconfig(machine_config &config) } -void spg110_device::map(address_map &map) +void spg110_device::internal_map(address_map &map) { map(0x000000, 0x000fff).ram(); @@ -160,6 +159,8 @@ void spg110_device::map(address_map &map) void spg110_device::device_start() { + unsp_device::device_start(); + m_porta_out.resolve_safe(); m_portb_out.resolve_safe(); m_portc_out.resolve_safe(); @@ -169,10 +170,10 @@ void spg110_device::device_start() m_adc_in[0].resolve_safe(0x0fff); m_adc_in[1].resolve_safe(0x0fff); m_chip_sel.resolve_safe(); - } void spg110_device::device_reset() { + unsp_device::device_reset(); } diff --git a/src/devices/machine/spg110.h b/src/devices/machine/spg110.h index 541052d1f51..df32eea96e0 100644 --- a/src/devices/machine/spg110.h +++ b/src/devices/machine/spg110.h @@ -13,23 +13,19 @@ #include "spg110_video.h" #include "spg2xx_audio.h" -class spg110_device : public device_t, public device_mixer_interface +class spg110_device : public unsp_device, public device_mixer_interface { public: - spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); spg110_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template - spg110_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&screen_tag) + template + spg110_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) : spg110_device(mconfig, tag, owner, clock) { - m_cpu.set_tag(std::forward(cpu_tag)); - m_screen.set_tag(std::forward(screen_tag)); + m_screen.set_tag(std::forward(screen_tag)); } - void map(address_map &map); - auto porta_out() { return m_porta_out.bind(); } auto portb_out() { return m_portb_out.bind(); } auto portc_out() { return m_portc_out.bind(); } @@ -45,14 +41,16 @@ public: DECLARE_WRITE_LINE_MEMBER(vblank) { m_spg_video->vblank(state); } protected: + spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal); + + void internal_map(address_map &map); + virtual void device_start() override; virtual void device_reset() override; virtual void device_add_mconfig(machine_config &config) override; private: - - required_device m_cpu; required_device m_screen; required_device m_spg_io; diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp index 6d9d18fb3a2..5acaa464456 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -18,13 +18,14 @@ DEFINE_DEVICE_TYPE(SPG24X, spg24x_device, "spg24x", "SPG240-series System-on-a-C DEFINE_DEVICE_TYPE(SPG28X, spg28x_device, "spg28x", "SPG280-series System-on-a-Chip") -spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) +spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t sprite_limit, address_map_constructor internal) + : unsp_device(mconfig, type, tag, owner, clock, internal) , device_mixer_interface(mconfig, *this, 2) , m_spg_audio(*this, "spgaudio") , m_spg_io(*this, "spgio") , m_spg_sysdma(*this, "spgsysdma") , m_spg_video(*this, "spgvideo") + , m_sprite_limit(sprite_limit) , m_rowscrolloffset(15) , m_porta_out(*this) , m_portb_out(*this) @@ -37,22 +38,21 @@ spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, co , m_eeprom_r(*this) , m_uart_tx(*this) , m_chip_sel(*this) - , m_cpu(*this, finder_base::DUMMY_TAG) , m_screen(*this, finder_base::DUMMY_TAG) { } spg24x_device::spg24x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : spg2xx_device(mconfig, SPG24X, tag, owner, clock, 256) + : spg2xx_device(mconfig, SPG24X, tag, owner, clock, 256, address_map_constructor(FUNC(spg24x_device::internal_map), this)) { } spg28x_device::spg28x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : spg2xx_device(mconfig, SPG28X, tag, owner, clock, 64) + : spg2xx_device(mconfig, SPG28X, tag, owner, clock, 64, address_map_constructor(FUNC(spg28x_device::internal_map), this)) { } -void spg2xx_device::map(address_map &map) +void spg2xx_device::internal_map(address_map &map) { map(0x000000, 0x0027ff).ram(); map(0x002800, 0x0028ff).rw(m_spg_video, FUNC(spg2xx_video_device::video_r), FUNC(spg2xx_video_device::video_w)); @@ -69,6 +69,8 @@ void spg2xx_device::map(address_map &map) void spg2xx_device::device_start() { + unsp_device::device_start(); + m_porta_out.resolve_safe(); m_portb_out.resolve_safe(); m_portc_out.resolve_safe(); @@ -88,48 +90,49 @@ void spg2xx_device::device_start() void spg2xx_device::device_reset() { + unsp_device::device_reset(); } WRITE_LINE_MEMBER(spg2xx_device::videoirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ0_LINE, state); + set_state_unsynced(UNSP_IRQ0_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::timerirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ2_LINE, state); + set_state_unsynced(UNSP_IRQ2_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::uartirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ3_LINE, state); + set_state_unsynced(UNSP_IRQ3_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::audioirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ4_LINE, state); + set_state_unsynced(UNSP_IRQ4_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::extirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, state); + set_state_unsynced(UNSP_IRQ5_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::ffreq1_w) { - m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, state); + set_state_unsynced(UNSP_IRQ6_LINE, state); } WRITE_LINE_MEMBER(spg2xx_device::ffreq2_w) { - m_cpu->set_state_unsynced(UNSP_IRQ7_LINE, state); + set_state_unsynced(UNSP_IRQ7_LINE, state); } READ16_MEMBER(spg2xx_device::space_r) { - address_space &cpuspace = m_cpu->space(AS_PROGRAM); + address_space &cpuspace = this->space(AS_PROGRAM); return cpuspace.read_word(offset); } @@ -164,12 +167,12 @@ void spg24x_device::device_add_mconfig(machine_config &config) m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); - SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); configure_spg_io(m_spg_io); - SPG2XX_SYSDMA(config, m_spg_sysdma, DERIVED_CLOCK(1, 1), m_cpu); + SPG2XX_SYSDMA(config, m_spg_sysdma, DERIVED_CLOCK(1, 1), DEVICE_SELF); - SPG24X_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG24X_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->sprlimit_read_callback().set(FUNC(spg24x_device::get_sprlimit)); m_spg_video->rowscrolloffset_read_callback().set(FUNC(spg24x_device::get_rowscrolloffset)); m_spg_video->write_video_irq_callback().set(FUNC(spg24x_device::videoirq_w)); @@ -184,12 +187,12 @@ void spg28x_device::device_add_mconfig(machine_config &config) m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); - SPG28X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG28X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); configure_spg_io(m_spg_io); - SPG2XX_SYSDMA(config, m_spg_sysdma, DERIVED_CLOCK(1, 1), m_cpu); + SPG2XX_SYSDMA(config, m_spg_sysdma, DERIVED_CLOCK(1, 1), DEVICE_SELF); - SPG24X_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + SPG24X_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->sprlimit_read_callback().set(FUNC(spg28x_device::get_sprlimit)); m_spg_video->rowscrolloffset_read_callback().set(FUNC(spg28x_device::get_rowscrolloffset)); m_spg_video->write_video_irq_callback().set(FUNC(spg28x_device::videoirq_w)); diff --git a/src/devices/machine/spg2xx.h b/src/devices/machine/spg2xx.h index 806e8395c4d..2d26d6ef135 100644 --- a/src/devices/machine/spg2xx.h +++ b/src/devices/machine/spg2xx.h @@ -41,16 +41,12 @@ #include "spg2xx_video.h" #include "screen.h" -class spg2xx_device : public device_t, public device_mixer_interface +class spg2xx_device : public unsp_device, public device_mixer_interface { public: - spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - void set_pal(bool pal) { m_pal_flag = pal ? 1 : 0; } void set_rowscroll_offset(int offset) { m_rowscrolloffset = offset; } - void map(address_map &map); - auto porta_out() { return m_porta_out.bind(); } auto portb_out() { return m_portb_out.bind(); } auto portc_out() { return m_portc_out.bind(); } @@ -79,11 +75,9 @@ public: uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return m_spg_video->screen_update(screen, bitmap, cliprect); } protected: - spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint32_t sprite_limit) - : spg2xx_device(mconfig, type, tag, owner, clock) - { - m_sprite_limit = sprite_limit; - } + spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t sprite_limit, address_map_constructor internal); + + void internal_map(address_map &map); DECLARE_WRITE_LINE_MEMBER(videoirq_w); DECLARE_WRITE_LINE_MEMBER(audioirq_w); @@ -95,8 +89,6 @@ protected: DECLARE_READ16_MEMBER(space_r); - void spg2xx_map(address_map &map); - virtual void device_start() override; virtual void device_reset() override; @@ -126,7 +118,6 @@ protected: emu_timer *m_screenpos_timer; - required_device m_cpu; required_device m_screen; void configure_spg_io(spg2xx_io_device* io); @@ -149,12 +140,11 @@ protected: class spg24x_device : public spg2xx_device { public: - template - spg24x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&screen_tag) + template + spg24x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) : spg24x_device(mconfig, tag, owner, clock) { - m_cpu.set_tag(std::forward(cpu_tag)); - m_screen.set_tag(std::forward(screen_tag)); + m_screen.set_tag(std::forward(screen_tag)); } spg24x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); @@ -166,12 +156,11 @@ public: class spg28x_device : public spg2xx_device { public: - template - spg28x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag, U &&screen_tag) + template + spg28x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) : spg28x_device(mconfig, tag, owner, clock) { - m_cpu.set_tag(std::forward(cpu_tag)); - m_screen.set_tag(std::forward(screen_tag)); + m_screen.set_tag(std::forward(screen_tag)); } spg28x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); diff --git a/src/devices/machine/sunplus_gcm394.cpp b/src/devices/machine/sunplus_gcm394.cpp index 36852099090..367fb9da077 100644 --- a/src/devices/machine/sunplus_gcm394.cpp +++ b/src/devices/machine/sunplus_gcm394.cpp @@ -61,7 +61,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::system_dma_trigger_w) { for (int i = 0; i < length; i++) { - address_space& mem = m_cpu->space(AS_PROGRAM); + address_space &mem = this->space(AS_PROGRAM); uint16_t val = mem.read_word(source); mem.write_word(dest, val); dest += 1; @@ -71,7 +71,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::system_dma_trigger_w) { for (int i = 0; i < length; i++) { - address_space& mem = m_cpu->space(AS_PROGRAM); + address_space &mem = this->space(AS_PROGRAM); uint16_t val = mem.read_word(source); mem.write_word(dest, val); dest += 1; @@ -230,7 +230,7 @@ WRITE16_MEMBER(sunplus_gcm394_base_device::unk_w) } } -void sunplus_gcm394_base_device::map(address_map &map) +void sunplus_gcm394_base_device::internal_map(address_map &map) { map(0x000000, 0x006fff).ram(); map(0x007000, 0x007fff).rw(FUNC(sunplus_gcm394_base_device::unk_r), FUNC(sunplus_gcm394_base_device::unk_w)); // catch unhandled @@ -389,6 +389,8 @@ void sunplus_gcm394_base_device::map(address_map &map) void sunplus_gcm394_base_device::device_start() { + unsp_20_device::device_start(); + m_porta_in.resolve_safe(0); m_portb_in.resolve_safe(0); @@ -398,6 +400,8 @@ void sunplus_gcm394_base_device::device_start() void sunplus_gcm394_base_device::device_reset() { + unsp_20_device::device_reset(); + for (int i = 0; i < 7; i++) { m_dma_params[i] = 0x0000; @@ -477,9 +481,9 @@ void sunplus_gcm394_base_device::device_reset() void sunplus_gcm394_base_device::checkirq6() { if (m_7935 & 0x0100) - m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, ASSERT_LINE); + set_state_unsynced(UNSP_IRQ6_LINE, ASSERT_LINE); else - m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, CLEAR_LINE); + set_state_unsynced(UNSP_IRQ6_LINE, CLEAR_LINE); } void sunplus_gcm394_base_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) @@ -498,12 +502,12 @@ void sunplus_gcm394_base_device::device_timer(emu_timer &timer, device_timer_id WRITE_LINE_MEMBER(sunplus_gcm394_base_device::audioirq_w) { - //m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, state); + //set_state_unsynced(UNSP_IRQ5_LINE, state); } WRITE_LINE_MEMBER(sunplus_gcm394_base_device::videoirq_w) { - m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, state); + set_state_unsynced(UNSP_IRQ5_LINE, state); } uint16_t sunplus_gcm394_base_device::read_space(uint32_t offset) @@ -522,7 +526,7 @@ void sunplus_gcm394_base_device::device_add_mconfig(machine_config &config) m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); - GCM394_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), m_cpu, m_screen); + GCM394_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->write_video_irq_callback().set(FUNC(sunplus_gcm394_base_device::videoirq_w)); m_spg_video->space_read_callback().set(FUNC(sunplus_gcm394_base_device::read_space)); } diff --git a/src/devices/machine/sunplus_gcm394.h b/src/devices/machine/sunplus_gcm394.h index 62cac1380f1..dd5dad14fe5 100644 --- a/src/devices/machine/sunplus_gcm394.h +++ b/src/devices/machine/sunplus_gcm394.h @@ -18,13 +18,12 @@ #include "spg2xx_audio.h" -class sunplus_gcm394_base_device : public device_t, public device_mixer_interface +class sunplus_gcm394_base_device : public unsp_20_device, public device_mixer_interface { public: sunplus_gcm394_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) + : unsp_20_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(sunplus_gcm394_base_device::internal_map), this)) , device_mixer_interface(mconfig, *this, 2) - , m_cpu(*this, finder_base::DUMMY_TAG) , m_screen(*this, finder_base::DUMMY_TAG) , m_spg_video(*this, "spgvideo") , m_spg_audio(*this, "spgaudio") @@ -33,8 +32,6 @@ public: { } - void map(address_map &map); - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { return m_spg_video->screen_update(screen, bitmap, cliprect); } auto porta_in() { return m_porta_in.bind(); } @@ -49,7 +46,8 @@ protected: virtual void device_start() override; virtual void device_reset() override; - required_device m_cpu; + void internal_map(address_map &map); + required_device m_screen; required_device m_spg_video; required_device m_spg_audio; @@ -238,15 +236,14 @@ private: class sunplus_gcm394_device : public sunplus_gcm394_base_device { public: - template - sunplus_gcm394_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock, T&& cpu_tag, U&& screen_tag) + template + sunplus_gcm394_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) : sunplus_gcm394_device(mconfig, tag, owner, clock) { - m_cpu.set_tag(std::forward(cpu_tag)); - m_screen.set_tag(std::forward(screen_tag)); + m_screen.set_tag(std::forward(screen_tag)); } - sunplus_gcm394_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock); + sunplus_gcm394_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); }; diff --git a/src/mame/drivers/clickstart.cpp b/src/mame/drivers/clickstart.cpp index bc2e948d9dc..6c2801132df 100644 --- a/src/mame/drivers/clickstart.cpp +++ b/src/mame/drivers/clickstart.cpp @@ -43,7 +43,6 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") - , m_spg(*this, "spg") , m_cart(*this, "cartslot") , m_system_region(*this, "maincpu") , m_io_mouse_x(*this, "MOUSEX") @@ -93,9 +92,8 @@ private: void update_mouse_buffer(); - required_device m_maincpu; + required_device m_maincpu; required_device m_screen; - required_device m_spg; required_device m_cart; required_memory_region m_system_region; required_ioport m_io_mouse_x; @@ -180,7 +178,7 @@ void clickstart_state::handle_uart_tx() if (m_uart_tx_fifo_count == 0) return; - m_spg->uart_rx(m_uart_tx_fifo[m_uart_tx_fifo_start]); + m_maincpu->uart_rx(m_uart_tx_fifo[m_uart_tx_fifo_start]); m_uart_tx_fifo_start = (m_uart_tx_fifo_start + 1) % ARRAY_LENGTH(m_uart_tx_fifo); m_uart_tx_fifo_count--; } @@ -341,7 +339,6 @@ WRITE8_MEMBER(clickstart_state::chip_sel_w) void clickstart_state::mem_map(address_map &map) { map(0x000000, 0x3fffff).r(FUNC(clickstart_state::rom_r)); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } static INPUT_PORTS_START( clickstart ) @@ -401,31 +398,29 @@ INPUT_PORTS_END void clickstart_state::clickstart(machine_config &config) { - UNSP(config, m_maincpu, XTAL(27'000'000)); + SPG28X(config, m_maincpu, XTAL(27'000'000), m_screen); m_maincpu->set_addrmap(AS_PROGRAM, &clickstart_state::mem_map); + m_maincpu->porta_out().set(FUNC(clickstart_state::porta_w)); + m_maincpu->portb_out().set(FUNC(clickstart_state::portb_w)); + m_maincpu->portc_out().set(FUNC(clickstart_state::portc_w)); + m_maincpu->porta_in().set(FUNC(clickstart_state::porta_r)); + m_maincpu->portb_in().set(FUNC(clickstart_state::portb_r)); + m_maincpu->portc_in().set(FUNC(clickstart_state::portc_r)); + m_maincpu->adc_in<0>().set_constant(0x0fff); + m_maincpu->chip_select().set(FUNC(clickstart_state::chip_sel_w)); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(320, 262); m_screen->set_visarea(0, 320-1, 0, 240-1); - m_screen->set_screen_update("spg", FUNC(spg2xx_device::screen_update)); - m_screen->screen_vblank().set(m_spg, FUNC(spg2xx_device::vblank)); + m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); + m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - SPG28X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); - m_spg->porta_out().set(FUNC(clickstart_state::porta_w)); - m_spg->portb_out().set(FUNC(clickstart_state::portb_w)); - m_spg->portc_out().set(FUNC(clickstart_state::portc_w)); - m_spg->porta_in().set(FUNC(clickstart_state::porta_r)); - m_spg->portb_in().set(FUNC(clickstart_state::portb_r)); - m_spg->portc_in().set(FUNC(clickstart_state::portc_r)); - m_spg->adc_in<0>().set_constant(0x0fff); - m_spg->chip_select().set(FUNC(clickstart_state::chip_sel_w)); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); - GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "clickstart_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); m_cart->set_device_load(device_image_load_delegate(&clickstart_state::device_image_load_cart, this)); diff --git a/src/mame/drivers/spg110.cpp b/src/mame/drivers/spg110.cpp index 8ac0de20dfa..263e67a5e0b 100644 --- a/src/mame/drivers/spg110.cpp +++ b/src/mame/drivers/spg110.cpp @@ -27,7 +27,6 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") - , m_spg(*this, "spg") { } void spg110_base(machine_config &config); @@ -35,10 +34,8 @@ public: DECLARE_CUSTOM_INPUT_MEMBER(plunger_r); protected: - - required_device m_maincpu; + required_device m_maincpu; required_device m_screen; - required_device m_spg; virtual void mem_map(address_map &map); }; @@ -50,7 +47,6 @@ protected: void spg110_game_state::mem_map(address_map &map) { map(0x004000, 0x3fffff).rom().region("maincpu", 0x8000); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg110_device::map)); } static INPUT_PORTS_START( jak_capb ) @@ -336,27 +332,25 @@ INPUT_PORTS_END void spg110_game_state::spg110_base(machine_config &config) { - UNSP(config, m_maincpu, XTAL(27'000'000)); + SPG110(config, m_maincpu, XTAL(27'000'000), m_screen); m_maincpu->set_addrmap(AS_PROGRAM, &spg110_game_state::mem_map); + m_maincpu->porta_in().set_ioport("PA"); + m_maincpu->portb_in().set_ioport("PB"); + m_maincpu->portc_in().set_ioport("PC"); + m_maincpu->adc_in<0>().set_ioport("JOYX"); + m_maincpu->adc_in<1>().set_ioport("JOYY"); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(320, 262); m_screen->set_visarea(0, 320-1, 0, 240-1); - m_screen->set_screen_update("spg", FUNC(spg110_device::screen_update)); - m_screen->screen_vblank().set(m_spg, FUNC(spg110_device::vblank)); - - SPG110(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); - m_spg->porta_in().set_ioport("PA"); - m_spg->portb_in().set_ioport("PB"); - m_spg->portc_in().set_ioport("PC"); - m_spg->adc_in<0>().set_ioport("JOYX"); - m_spg->adc_in<1>().set_ioport("JOYY"); + m_screen->set_screen_update("maincpu", FUNC(spg110_device::screen_update)); + m_screen->screen_vblank().set(m_maincpu, FUNC(spg110_device::vblank)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); } ROM_START( jak_capb ) diff --git a/src/mame/drivers/sunplus_gcm394.cpp b/src/mame/drivers/sunplus_gcm394.cpp index 6bfcb0dd472..8bc1bca7ee3 100644 --- a/src/mame/drivers/sunplus_gcm394.cpp +++ b/src/mame/drivers/sunplus_gcm394.cpp @@ -16,7 +16,6 @@ #include "emu.h" #include "machine/sunplus_gcm394.h" -#include "machine/spg2xx.h" #include "screen.h" #include "speaker.h" @@ -29,7 +28,6 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") - , m_spg(*this, "spg") , m_bank(*this, "cartbank") , m_io_p1(*this, "P1") , m_io_p2(*this, "P2") @@ -43,9 +41,8 @@ protected: void switch_bank(uint32_t bank); - required_device m_maincpu; + required_device m_maincpu; required_device m_screen; - required_device m_spg; optional_memory_bank m_bank; @@ -78,24 +75,22 @@ READ16_MEMBER(gcm394_game_state::portb_r) void gcm394_game_state::base(machine_config &config) { - GCM394(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); - m_spg->porta_in().set(FUNC(gcm394_game_state::porta_r)); - m_spg->portb_in().set(FUNC(gcm394_game_state::portb_r)); - - UNSP_20(config, m_maincpu, XTAL(27'000'000)); // code at 8019 uses extended opcode, so must be 2.0+? + GCM394(config, m_maincpu, XTAL(27'000'000), m_screen); m_maincpu->set_addrmap(AS_PROGRAM, &gcm394_game_state::mem_map_4m); + m_maincpu->porta_in().set(FUNC(gcm394_game_state::porta_r)); + m_maincpu->portb_in().set(FUNC(gcm394_game_state::portb_r)); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(320, 262); m_screen->set_visarea(0, 320-1, 0, 240-1); - m_screen->set_screen_update("spg", FUNC(sunplus_gcm394_device::screen_update)); - m_screen->screen_vblank().set(m_spg, FUNC(sunplus_gcm394_device::vblank)); + m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); + m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); } @@ -125,7 +120,6 @@ void gcm394_game_state::machine_reset() void gcm394_game_state::mem_map_4m(address_map &map) { map(0x000000, 0x01ffff).bankr("cartbank"); - map(0x000000, 0x007fff).m(m_spg, FUNC(sunplus_gcm394_device::map)); // smartfp really expects the ROM at 0 to map here, so maybe this is how the newer SoC works map(0x020000, 0x3fffff).bankr("cartbank"); diff --git a/src/mame/drivers/vii.cpp b/src/mame/drivers/vii.cpp index 0bdbf330a4c..ddb70ff9c39 100644 --- a/src/mame/drivers/vii.cpp +++ b/src/mame/drivers/vii.cpp @@ -151,7 +151,6 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") - , m_spg(*this, "spg") , m_bank(*this, "cartbank") , m_io_p1(*this, "P1") , m_io_p2(*this, "P2") @@ -200,9 +199,8 @@ protected: DECLARE_WRITE16_MEMBER(jakks_porta_w); DECLARE_WRITE16_MEMBER(jakks_portb_w); - required_device m_maincpu; + required_device m_maincpu; required_device m_screen; - required_device m_spg; optional_memory_bank m_bank; DECLARE_READ16_MEMBER(walle_portc_r); @@ -574,19 +572,16 @@ READ16_MEMBER(spg2xx_game_state::rad_portc_r) void spg2xx_game_state::mem_map_4m(address_map &map) { map(0x000000, 0x3fffff).bankr("cartbank"); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } void spg2xx_game_state::mem_map_2m(address_map &map) { map(0x000000, 0x1fffff).mirror(0x200000).bankr("cartbank"); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } void spg2xx_game_state::mem_map_1m(address_map &map) { map(0x000000, 0x0fffff).mirror(0x300000).bankr("cartbank"); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } static INPUT_PORTS_START( vii ) @@ -1877,7 +1872,7 @@ void vii_state::poll_controls() if (memcmp(old_input, m_controller_input, 8)) { for(int i = 0; i < 8; i++) - m_spg->uart_rx(m_controller_input[i]); + m_maincpu->uart_rx(m_controller_input[i]); } } @@ -1899,25 +1894,23 @@ DEVICE_IMAGE_LOAD_MEMBER(vii_state, vii_cart) void spg2xx_game_state::spg2xx_base(machine_config &config) { - UNSP(config, m_maincpu, XTAL(27'000'000)); - m_maincpu->set_addrmap(AS_PROGRAM, &spg2xx_game_state::mem_map_4m); - SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(320, 262); m_screen->set_visarea(0, 320-1, 0, 240-1); - m_screen->set_screen_update("spg", FUNC(spg2xx_device::screen_update)); - m_screen->screen_vblank().set(m_spg, FUNC(spg2xx_device::vblank)); + m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); + m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); } void spg2xx_game_state::non_spg_base(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); + m_maincpu->set_addrmap(AS_PROGRAM, &spg2xx_game_state::mem_map_4m); spg2xx_base(config); } @@ -1932,13 +1925,14 @@ void spg2xx_game_state::spg2xx_basep(machine_config &config) void vii_state::vii(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); + m_maincpu->set_addrmap(AS_PROGRAM, &vii_state::mem_map_4m); spg2xx_base(config); - m_spg->portb_out().set(FUNC(vii_state::vii_portb_w)); - m_spg->eeprom_w().set(FUNC(vii_state::eeprom_w)); - m_spg->eeprom_r().set(FUNC(vii_state::eeprom_r)); + m_maincpu->portb_out().set(FUNC(vii_state::vii_portb_w)); + m_maincpu->eeprom_w().set(FUNC(vii_state::eeprom_w)); + m_maincpu->eeprom_r().set(FUNC(vii_state::eeprom_r)); NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_1); @@ -1951,16 +1945,16 @@ void vii_state::vii(machine_config &config) void icanguit_state::icanguit(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set(FUNC(icanguit_state::porta_r)); - m_spg->portb_in().set(FUNC(icanguit_state::portb_r)); - m_spg->portc_in().set(FUNC(icanguit_state::portc_r)); - m_spg->porta_out().set(FUNC(icanguit_state::guit_porta_w)); - m_spg->portb_out().set(FUNC(icanguit_state::portb_w)); - m_spg->portc_out().set(FUNC(icanguit_state::portc_w)); + m_maincpu->porta_in().set(FUNC(icanguit_state::porta_r)); + m_maincpu->portb_in().set(FUNC(icanguit_state::portb_r)); + m_maincpu->portc_in().set(FUNC(icanguit_state::portc_r)); + m_maincpu->porta_out().set(FUNC(icanguit_state::guit_porta_w)); + m_maincpu->portb_out().set(FUNC(icanguit_state::portb_w)); + m_maincpu->portc_out().set(FUNC(icanguit_state::portc_w)); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "icanguit_cart"); @@ -1973,16 +1967,16 @@ void icanguit_state::icanguit(machine_config &config) void icanguit_state::icanpian(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set(FUNC(icanguit_state::porta_r)); - m_spg->portb_in().set(FUNC(icanguit_state::portb_r)); - m_spg->portc_in().set(FUNC(icanguit_state::portc_r)); - m_spg->porta_out().set(FUNC(icanguit_state::porta_w)); - m_spg->portb_out().set(FUNC(icanguit_state::portb_w)); - m_spg->portc_out().set(FUNC(icanguit_state::portc_w)); + m_maincpu->porta_in().set(FUNC(icanguit_state::porta_r)); + m_maincpu->portb_in().set(FUNC(icanguit_state::portb_r)); + m_maincpu->portc_in().set(FUNC(icanguit_state::portc_r)); + m_maincpu->porta_out().set(FUNC(icanguit_state::porta_w)); + m_maincpu->portb_out().set(FUNC(icanguit_state::portb_w)); + m_maincpu->portc_out().set(FUNC(icanguit_state::portc_w)); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "icanpian_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); @@ -1994,13 +1988,13 @@ void icanguit_state::icanpian(machine_config &config) void tvgogo_state::tvgogo(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set_ioport("P1"); - m_spg->portb_in().set_ioport("P2"); - m_spg->portc_in().set_ioport("P3"); + m_maincpu->porta_in().set_ioport("P1"); + m_maincpu->portb_in().set_ioport("P2"); + m_maincpu->portc_in().set_ioport("P3"); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "tvgogo_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); @@ -2013,22 +2007,22 @@ void tvgogo_state::tvgogo(machine_config &config) void spg2xx_game_state::wireless60(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_out().set(FUNC(spg2xx_game_state::wireless60_porta_w)); - m_spg->portb_out().set(FUNC(spg2xx_game_state::wireless60_portb_w)); - m_spg->porta_in().set(FUNC(spg2xx_game_state::wireless60_porta_r)); + m_maincpu->porta_out().set(FUNC(spg2xx_game_state::wireless60_porta_w)); + m_maincpu->portb_out().set(FUNC(spg2xx_game_state::wireless60_portb_w)); + m_maincpu->porta_in().set(FUNC(spg2xx_game_state::wireless60_porta_r)); } void spg2xx_game_state::jakks(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set(FUNC(spg2xx_game_state::jakks_porta_r)); - m_spg->porta_out().set(FUNC(spg2xx_game_state::jakks_porta_w)); - m_spg->portb_out().set(FUNC(spg2xx_game_state::jakks_portb_w)); + m_maincpu->porta_in().set(FUNC(spg2xx_game_state::jakks_porta_r)); + m_maincpu->porta_out().set(FUNC(spg2xx_game_state::jakks_porta_w)); + m_maincpu->portb_out().set(FUNC(spg2xx_game_state::jakks_portb_w)); } void spg2xx_game_state::jakks_i2c(machine_config &config) @@ -2060,12 +2054,12 @@ void jakks_gkr_state::jakks_gkr(machine_config &config) { jakks(config); - m_spg->porta_in().set(FUNC(jakks_gkr_state::jakks_porta_key_io_r)); - m_spg->porta_out().set(FUNC(jakks_gkr_state::jakks_porta_key_io_w)); - m_spg->portc_in().set_ioport("P3"); - m_spg->portc_out().set(FUNC(jakks_gkr_state::gkr_portc_w)); + m_maincpu->porta_in().set(FUNC(jakks_gkr_state::jakks_porta_key_io_r)); + m_maincpu->porta_out().set(FUNC(jakks_gkr_state::jakks_porta_key_io_w)); + m_maincpu->portc_in().set_ioport("P3"); + m_maincpu->portc_out().set(FUNC(jakks_gkr_state::gkr_portc_w)); - m_spg->set_rowscroll_offset(0); + m_maincpu->set_rowscroll_offset(0); JAKKS_GAMEKEY_SLOT(config, m_cart, 0, jakks_gamekey, nullptr); } @@ -2136,8 +2130,8 @@ void jakks_gkr_state::jakks_gkr_sw_i2c(machine_config &config) { jakks_gkr_i2c(config); m_maincpu->set_addrmap(AS_PROGRAM, &jakks_gkr_state::mem_map_1m); - m_spg->adc_in<0>().set_ioport("JOYX"); - m_spg->adc_in<1>().set_ioport("JOYY"); + m_maincpu->adc_in<0>().set_ioport("JOYX"); + m_maincpu->adc_in<1>().set_ioport("JOYY"); SOFTWARE_LIST(config, "jakks_gamekey_sw").set_original("jakks_gamekey_sw"); } @@ -2145,8 +2139,8 @@ void jakks_gkr_state::jakks_gkr_wp(machine_config &config) { jakks_gkr(config); m_maincpu->set_addrmap(AS_PROGRAM, &jakks_gkr_state::mem_map_1m); - m_spg->adc_in<0>().set_ioport("JOYX"); - m_spg->adc_in<1>().set_ioport("JOYY"); + m_maincpu->adc_in<0>().set_ioport("JOYX"); + m_maincpu->adc_in<1>().set_ioport("JOYY"); //SOFTWARE_LIST(config, "jakks_gamekey_wp").set_original("jakks_gamekey_wp"); // NO KEYS RELEASED } @@ -2154,7 +2148,7 @@ void jakks_gkr_state::jakks_gkr_nm_i2c(machine_config &config) { jakks_gkr_i2c(config); m_maincpu->set_addrmap(AS_PROGRAM, &jakks_gkr_state::mem_map_1m); - m_spg->adc_in<0>().set_ioport("DIALX"); + m_maincpu->adc_in<0>().set_ioport("DIALX"); SOFTWARE_LIST(config, "jakks_gamekey_nm").set_original("jakks_gamekey_nm"); } @@ -2162,8 +2156,8 @@ void jakks_gkr_state::jakks_gkr_wf_i2c(machine_config &config) { jakks_gkr_i2c(config); m_maincpu->set_addrmap(AS_PROGRAM, &jakks_gkr_state::mem_map_1m); - //m_spg->adc_in<0>().set_ioport("DIALX"); // wheel does not seem to map here - //m_spg->adc_in<1>().set_ioport("DIALY"); + //m_maincpu->adc_in<0>().set_ioport("DIALX"); // wheel does not seem to map here + //m_maincpu->adc_in<1>().set_ioport("DIALY"); //SOFTWARE_LIST(config, "jakks_gamekey_wf").set_original("jakks_gamekey_wf"); // no game keys were released } @@ -2172,74 +2166,74 @@ void spg2xx_game_state::lexizeus(machine_config &config) { non_spg_base(config); m_maincpu->set_addrmap(AS_PROGRAM, &spg2xx_game_state::mem_map_4m); - m_spg->porta_in().set_ioport("P1"); - m_spg->portb_in().set_ioport("P2"); - m_spg->portc_in().set_ioport("P3"); + m_maincpu->porta_in().set_ioport("P1"); + m_maincpu->portb_in().set_ioport("P2"); + m_maincpu->portc_in().set_ioport("P3"); } void spg2xx_game_state::walle(machine_config &config) { jakks_i2c(config); m_maincpu->set_addrmap(AS_PROGRAM, &spg2xx_game_state::mem_map_2m); - m_spg->portc_in().set_ioport("P3"); - m_spg->portc_out().set(FUNC(spg2xx_game_state::walle_portc_w)); + m_maincpu->portc_in().set_ioport("P3"); + m_maincpu->portc_out().set(FUNC(spg2xx_game_state::walle_portc_w)); } void spg2xx_game_state::rad_skat(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set_ioport("P1"); - m_spg->portb_in().set_ioport("P2"); - m_spg->portc_in().set_ioport("P3"); - m_spg->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); - m_spg->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); + m_maincpu->porta_in().set_ioport("P1"); + m_maincpu->portb_in().set_ioport("P2"); + m_maincpu->portc_in().set_ioport("P3"); + m_maincpu->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); + m_maincpu->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_1); } void dreamlif_state::dreamlif(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set_ioport("P1"); - m_spg->portb_in().set(FUNC(dreamlif_state::portb_r)); - m_spg->portb_out().set(FUNC(dreamlif_state::portb_w)); + m_maincpu->porta_in().set_ioport("P1"); + m_maincpu->portb_in().set(FUNC(dreamlif_state::portb_r)); + m_maincpu->portb_out().set(FUNC(dreamlif_state::portb_w)); } void spg2xx_game_state::rad_skatp(machine_config &config) { rad_skat(config); - m_spg->set_pal(true); + m_maincpu->set_pal(true); } void spg2xx_game_state::rad_sktv(machine_config &config) { - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set(FUNC(spg2xx_game_state::rad_porta_r)); - m_spg->portb_in().set(FUNC(spg2xx_game_state::rad_portb_r)); - m_spg->portc_in().set(FUNC(spg2xx_game_state::rad_portc_r)); - m_spg->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); - m_spg->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); + m_maincpu->porta_in().set(FUNC(spg2xx_game_state::rad_porta_r)); + m_maincpu->portb_in().set(FUNC(spg2xx_game_state::rad_portb_r)); + m_maincpu->portc_in().set(FUNC(spg2xx_game_state::rad_portc_r)); + m_maincpu->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); + m_maincpu->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_1); } void spg2xx_game_state::rad_crik(machine_config &config) { - SPG28X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); + SPG28X(config, m_maincpu, XTAL(27'000'000), m_screen); spg2xx_base(config); - m_spg->porta_in().set_ioport("P1"); - m_spg->portb_in().set_ioport("P2"); - m_spg->portc_in().set_ioport("P3"); - m_spg->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); - m_spg->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); + m_maincpu->porta_in().set_ioport("P1"); + m_maincpu->portb_in().set_ioport("P2"); + m_maincpu->portc_in().set_ioport("P3"); + m_maincpu->eeprom_w().set(FUNC(spg2xx_game_state::eeprom_w)); + m_maincpu->eeprom_r().set(FUNC(spg2xx_game_state::eeprom_r)); NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_1); } diff --git a/src/mame/drivers/vsmile.cpp b/src/mame/drivers/vsmile.cpp index d498fe82653..da899fefec8 100644 --- a/src/mame/drivers/vsmile.cpp +++ b/src/mame/drivers/vsmile.cpp @@ -67,14 +67,14 @@ void vsmile_state::machine_reset() WRITE8_MEMBER(vsmile_state::ctrl_tx_w) { //printf("Ctrl Tx: %02x\n", data); - m_spg->uart_rx(data); + m_maincpu->uart_rx(data); } template WRITE_LINE_MEMBER(vsmile_state::ctrl_rts_w) { //printf("Ctrl%d RTS: %d\n", Which, state); m_ctrl_rts[Which] = state; - m_spg->extint_w(Which, state); + m_maincpu->extint_w(Which, state); } WRITE8_MEMBER(vsmile_state::uart_rx) @@ -149,7 +149,6 @@ READ16_MEMBER(vsmilem_state::porta_r) void vsmile_base_state::mem_map(address_map &map) { map(0x000000, 0x3fffff).rw(m_bankdev, FUNC(address_map_bank_device::read16), FUNC(address_map_bank_device::write16)); - map(0x000000, 0x003fff).m(m_spg, FUNC(spg2xx_device::map)); } void vsmile_state::banked_map(address_map &map) @@ -216,25 +215,16 @@ static void vsmile_cart(device_slot_interface &device) void vsmile_base_state::vsmile_base(machine_config &config) { - UNSP(config, m_maincpu, XTAL(27'000'000)); - m_maincpu->set_addrmap(AS_PROGRAM, &vsmile_base_state::mem_map); - m_maincpu->set_force_no_drc(true); - SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_size(320, 262); m_screen->set_visarea(0, 320-1, 0, 240-1); - m_screen->set_screen_update("spg", FUNC(spg2xx_device::screen_update)); - m_screen->screen_vblank().set(m_spg, FUNC(spg2xx_device::vblank)); + m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); + m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); SPEAKER(config, "lspeaker").front_left(); SPEAKER(config, "rspeaker").front_right(); - SPG24X(config, m_spg, XTAL(27'000'000), m_maincpu, m_screen); - m_spg->chip_select().set(FUNC(vsmile_base_state::chip_sel_w)); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); - ADDRESS_MAP_BANK(config, m_bankdev); m_bankdev->set_endianness(ENDIANNESS_LITTLE); m_bankdev->set_data_width(16); @@ -246,15 +236,21 @@ void vsmile_base_state::vsmile_base(machine_config &config) void vsmile_state::vsmile(machine_config &config) { + SPG24X(config, m_maincpu, XTAL(27'000'000), m_screen); + m_maincpu->set_addrmap(AS_PROGRAM, &vsmile_state::mem_map); + m_maincpu->set_force_no_drc(true); + m_maincpu->chip_select().set(FUNC(vsmile_state::chip_sel_w)); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->portb_in().set(FUNC(vsmile_state::portb_r)); + m_maincpu->portc_in().set(FUNC(vsmile_state::portc_r)); + m_maincpu->portc_out().set(FUNC(vsmile_state::portc_w)); + m_maincpu->uart_tx().set(FUNC(vsmile_state::uart_rx)); + vsmile_base(config); m_bankdev->set_addrmap(AS_PROGRAM, &vsmile_state::banked_map); - m_spg->portb_in().set(FUNC(vsmile_state::portb_r)); - m_spg->portc_in().set(FUNC(vsmile_state::portc_r)); - m_spg->portc_out().set(FUNC(vsmile_state::portc_w)); - m_spg->uart_tx().set(FUNC(vsmile_state::uart_rx)); - VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "joy"); m_ctrl[0]->rts_cb().set(FUNC(vsmile_state::ctrl_rts_w<0>)); m_ctrl[0]->data_cb().set(FUNC(vsmile_state::ctrl_tx_w)); @@ -270,14 +266,14 @@ void vsmile_state::vsmile(machine_config &config) void vsmile_state::vsmilep(machine_config &config) { vsmile(config); - m_spg->set_pal(true); + m_maincpu->set_pal(true); } void vsmilem_state::vsmilem(machine_config &config) { vsmile(config); - m_spg->porta_out().set(FUNC(vsmilem_state::porta_w)); - m_spg->porta_in().set(FUNC(vsmilem_state::porta_r)); + m_maincpu->porta_out().set(FUNC(vsmilem_state::porta_w)); + m_maincpu->porta_in().set(FUNC(vsmilem_state::porta_r)); } /************************************ diff --git a/src/mame/drivers/vsmileb.cpp b/src/mame/drivers/vsmileb.cpp index 782c88f3054..d83a0ada9b8 100644 --- a/src/mame/drivers/vsmileb.cpp +++ b/src/mame/drivers/vsmileb.cpp @@ -53,8 +53,8 @@ INPUT_CHANGED_MEMBER(vsmileb_state::pad_button_changed) { value |= (uint16_t)(uintptr_t)param; } - m_spg->uart_rx((uint8_t)(value >> 8)); - m_spg->uart_rx((uint8_t)value); + m_maincpu->uart_rx((uint8_t)(value >> 8)); + m_maincpu->uart_rx((uint8_t)value); } template INPUT_CHANGED_MEMBER(vsmileb_state::sw_mode) @@ -63,8 +63,8 @@ template INPUT_CHANGED_MEMBER(vsmileb_state::sw_mode) { m_mode = V; const uint16_t value = m_mode | 0x0080; - m_spg->uart_rx((uint8_t)(value >> 8)); - m_spg->uart_rx((uint8_t)value); + m_maincpu->uart_rx((uint8_t)(value >> 8)); + m_maincpu->uart_rx((uint8_t)value); } } @@ -122,24 +122,26 @@ INPUT_PORTS_END void vsmileb_state::vsmileb(machine_config &config) { + SPG28X(config, m_maincpu, XTAL(27'000'000), m_screen); + m_maincpu->set_addrmap(AS_PROGRAM, &vsmileb_state::mem_map); + m_maincpu->set_force_no_drc(true); + m_maincpu->chip_select().set(FUNC(vsmileb_state::chip_sel_w)); + m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->porta_in().set(FUNC(vsmileb_state::porta_r)); + m_maincpu->portb_in().set(FUNC(vsmileb_state::portb_r)); + vsmile_base(config); m_bankdev->set_addrmap(AS_PROGRAM, &vsmileb_state::banked_map); - SPG28X(config.replace(), m_spg, XTAL(27'000'000), m_maincpu, m_screen); - m_spg->chip_select().set(FUNC(vsmileb_state::chip_sel_w)); - m_spg->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_spg->add_route(ALL_OUTPUTS, "rspeaker", 0.5); - m_spg->porta_in().set(FUNC(vsmileb_state::porta_r)); - m_spg->portb_in().set(FUNC(vsmileb_state::portb_r)); - SOFTWARE_LIST(config, "cart_list").set_original("vsmileb_cart"); } void vsmileb_state::vsmilebp(machine_config &config) { vsmileb(config); - m_spg->set_pal(true); + m_maincpu->set_pal(true); } /************************************ diff --git a/src/mame/includes/vsmile.h b/src/mame/includes/vsmile.h index 0069803295f..08364314240 100644 --- a/src/mame/includes/vsmile.h +++ b/src/mame/includes/vsmile.h @@ -36,7 +36,6 @@ class vsmile_base_state : public driver_device public: vsmile_base_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) - , m_spg(*this, "spg") , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") , m_bankdev(*this, "bank") @@ -55,8 +54,7 @@ protected: DECLARE_READ16_MEMBER(bank3_r); - required_device m_spg; - required_device m_maincpu; + required_device m_maincpu; required_device m_screen; required_device m_bankdev; required_device m_cart;