From 939e03a7244cf5fe2f9db604832e7fda5d1d5971 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Fri, 14 Mar 2014 12:52:02 +0000 Subject: [PATCH] (MESS) ql: zx8301 devcb2. (nw) --- src/mess/drivers/ql.c | 16 +++------------ src/mess/video/zx8301.c | 30 +++++----------------------- src/mess/video/zx8301.h | 44 +++++++++++++++-------------------------- 3 files changed, 24 insertions(+), 66 deletions(-) diff --git a/src/mess/drivers/ql.c b/src/mess/drivers/ql.c index a069ce2ff3b..691a8796d4b 100644 --- a/src/mess/drivers/ql.c +++ b/src/mess/drivers/ql.c @@ -707,18 +707,6 @@ INPUT_PORTS_END // DEVICE CONFIGURATION //************************************************************************** -//------------------------------------------------- -// ZX8301_INTERFACE( ql_zx8301_intf ) -//------------------------------------------------- - -static ZX8301_INTERFACE( ql_zx8301_intf ) -{ - M68008_TAG, - SCREEN_TAG, - DEVCB_DEVICE_LINE_MEMBER(ZX8302_TAG, zx8302_device, vsync_w) -}; - - //------------------------------------------------- // ZX8302_INTERFACE( ql_zx8302_intf ) //------------------------------------------------- @@ -996,7 +984,9 @@ static MACHINE_CONFIG_START( ql, ql_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) // devices - MCFG_ZX8301_ADD(ZX8301_TAG, X1, ql_zx8301_intf) + MCFG_DEVICE_ADD(ZX8301_TAG, ZX8301, X1) + MCFG_ZX8301_CPU(M68008_TAG) + MCFG_ZX8301_VSYNC_CALLBACK(DEVWRITELINE(ZX8302_TAG, zx8302_device, vsync_w)) MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) MCFG_ZX8302_ADD(ZX8302_TAG, X1, ql_zx8302_intf) MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(ql_floppy_interface) diff --git a/src/mess/video/zx8301.c b/src/mess/video/zx8301.c index 5544df7aef6..bfe98071a80 100644 --- a/src/mess/video/zx8301.c +++ b/src/mess/video/zx8301.c @@ -19,7 +19,6 @@ */ -#include "emu.h" #include "zx8301.h" @@ -62,6 +61,7 @@ static ADDRESS_MAP_START( zx8301, AS_0, 8, zx8301_device ) AM_RANGE(0x00000, 0x1ffff) AM_RAM ADDRESS_MAP_END + //------------------------------------------------- // memory_space_config - return a description of // any address spaces owned by this device @@ -73,27 +73,6 @@ const address_space_config *zx8301_device::memory_space_config(address_spacenum } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void zx8301_device::device_config_complete() -{ - // inherit a copy of the static data - const zx8301_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - memset(&out_vsync_cb, 0, sizeof(out_vsync_cb)); - } -} - - //************************************************************************** // INLINE HELPERS @@ -133,6 +112,7 @@ zx8301_device::zx8301_device(const machine_config &mconfig, const char *tag, dev device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, NULL, *ADDRESS_MAP_NAME(zx8301)), + m_write_vsync(*this), m_dispoff(1), m_mode8(0), m_base(0), @@ -150,11 +130,11 @@ zx8301_device::zx8301_device(const machine_config &mconfig, const char *tag, dev void zx8301_device::device_start() { // get the CPU - m_cpu = machine().device(cpu_tag); + m_cpu = machine().device(m_cpu_tag); assert(m_cpu != NULL); // resolve callbacks - m_out_vsync_func.resolve(out_vsync_cb, *this); + m_write_vsync.resolve_safe(); // allocate timers m_vsync_timer = timer_alloc(TIMER_VSYNC); @@ -184,7 +164,7 @@ void zx8301_device::device_timer(emu_timer &timer, device_timer_id id, int param { case TIMER_VSYNC: //m_vsync = !m_vsync; - m_out_vsync_func(m_vsync); + m_write_vsync(m_vsync); break; case TIMER_FLASH: diff --git a/src/mess/video/zx8301.h b/src/mess/video/zx8301.h index 242fc7e793a..96521f8723b 100644 --- a/src/mess/video/zx8301.h +++ b/src/mess/video/zx8301.h @@ -37,12 +37,7 @@ #ifndef __ZX8301__ #define __ZX8301__ - - -///************************************************************************* -// MACROS / CONSTANTS -///************************************************************************* - +#include "emu.h" @@ -50,12 +45,11 @@ // INTERFACE CONFIGURATION MACROS ///************************************************************************* -#define MCFG_ZX8301_ADD(_tag, _clock, _config) \ - MCFG_DEVICE_ADD(_tag, ZX8301, _clock) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_ZX8301_CPU(_cpu_tag) \ + zx8301_device::static_set_cpu_tag(*device, _cpu_tag); -#define ZX8301_INTERFACE(name) \ - const zx8301_interface(name) = +#define MCFG_ZX8301_VSYNC_CALLBACK(_write) \ + devcb = &zx8301_device::set_vsync_wr_callback(*device, DEVCB2_##_write); @@ -63,28 +57,19 @@ // TYPE DEFINITIONS ///************************************************************************* -// ======================> zx8301_interface - -struct zx8301_interface -{ - const char *cpu_tag; - const char *screen_tag; - - devcb_write_line out_vsync_cb; -}; - - // ======================> zx8301_device class zx8301_device : public device_t, public device_memory_interface, - public device_video_interface, - public zx8301_interface + public device_video_interface { public: // construction/destruction zx8301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + template static devcb2_base &set_vsync_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_vsync.set_callback(object); } + static void static_set_cpu_tag(device_t &device, const char *tag) { downcast(device).m_cpu_tag = tag; } + DECLARE_WRITE8_MEMBER( control_w ); DECLARE_READ8_MEMBER( data_r ); DECLARE_WRITE8_MEMBER( data_w ); @@ -95,7 +80,6 @@ protected: // device-level overrides virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual void device_config_complete(); // device_config_memory_interface overrides virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; @@ -110,11 +94,15 @@ protected: void draw_line_mode8(bitmap_rgb32 &bitmap, int y, UINT16 da); private: - static const device_timer_id TIMER_VSYNC = 0; - static const device_timer_id TIMER_FLASH = 1; + enum + { + TIMER_VSYNC, + TIMER_FLASH + }; - devcb_resolved_write_line m_out_vsync_func; + devcb2_write_line m_write_vsync; + const char *m_cpu_tag; cpu_device *m_cpu; //address_space *m_data;