summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2014-03-29 07:20:28 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2014-03-29 07:20:28 +0000
commit7e11ce8ac2993f5d391935432c3eef3b150ad76a (patch)
treeb034586c4ed381bd8dd7d36121c9783c2d04f11e
parentebf0deb2b35506d02bd7de08c5507b6a34e6c4b8 (diff)
(MESS) 32x: replaced direct references to 32x inside the MD VDP with
calls to suitable delegates. it's not the perfect solution (the mixing should not happen inside the MD VDP as it does now), but it is a step in the right direction. nw.
-rw-r--r--src/mame/includes/megadriv.h16
-rw-r--r--src/mame/machine/megadriv.c2
-rw-r--r--src/mame/machine/megavdp.c22
-rw-r--r--src/mame/machine/megavdp.h28
-rw-r--r--src/mess/drivers/megadriv.c33
-rw-r--r--src/mess/includes/md_cons.h4
6 files changed, 75 insertions, 30 deletions
diff --git a/src/mame/includes/megadriv.h b/src/mame/includes/megadriv.h
index 24ca1333d59..ff853cefaaf 100644
--- a/src/mame/includes/megadriv.h
+++ b/src/mame/includes/megadriv.h
@@ -404,22 +404,6 @@ private:
required_device<cpu_device> m_bioscpu;
};
-class _32x_state : public md_base_state
-{
-public:
- _32x_state(const machine_config &mconfig, device_type type, const char *tag)
- : md_base_state(mconfig, type, tag) { }
-
-};
-
-class segacd_state : public _32x_state // use _32x_state as base to make easier the combo 32X + SCD
-{
-public:
- segacd_state(const machine_config &mconfig, device_type type, const char *tag)
- : _32x_state(mconfig, type, tag)
- { }
-};
-
/* machine/megavdp.c */
extern UINT16 (*vdp_get_word_from_68k_mem)(running_machine &machine, UINT32 source, address_space& space);
diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c
index 2d59bf24b5d..c2dbc5e6d12 100644
--- a/src/mame/machine/megadriv.c
+++ b/src/mame/machine/megadriv.c
@@ -1193,7 +1193,7 @@ void md_base_state::screen_eof_megadriv(screen_device &screen, bool state)
{
m_vdp->vdp_handle_eof();
m_vdp->m_megadriv_scanline_timer->adjust(attotime::zero);
-
+
if (m_32x)
m_32x->m_32x_hcount_compare_val = -1;
}
diff --git a/src/mame/machine/megavdp.c b/src/mame/machine/megavdp.c
index d9079eca9bd..abc7f144a83 100644
--- a/src/mame/machine/megavdp.c
+++ b/src/mame/machine/megavdp.c
@@ -2,8 +2,6 @@
#include "emu.h"
#include "megavdp.h"
-#include "mega32x.h"
-#include "video/315_5124.h"
/* still have dependencies on the following external gunk */
@@ -109,6 +107,10 @@ void sega_genesis_vdp_device::device_start()
m_genesis_vdp_lv6irqline_callback.resolve_safe();
m_genesis_vdp_lv4irqline_callback.resolve_safe();
+ m_32x_scanline_func.bind_relative_to(*owner());
+ m_32x_interrupt_func.bind_relative_to(*owner());
+ m_32x_scanline_helper_func.bind_relative_to(*owner());
+
m_vram = auto_alloc_array(machine(), UINT16, 0x10000/2);
m_cram = auto_alloc_array(machine(), UINT16, 0x80/2);
m_vsram = auto_alloc_array(machine(), UINT16, 0x80/2);
@@ -2504,7 +2506,6 @@ void sega_genesis_vdp_device::genesis_render_videoline_to_videobuffer(int scanli
/* This converts our render buffer to real screen colours */
void sega_genesis_vdp_device::genesis_render_videobuffer_to_screenbuffer(int scanline)
{
- sega_32x_device *_32xdev = machine().device<sega_32x_device>("sega32x"); // take this out of the VDP eventually
UINT16 *lineptr;
if (!m_use_alt_timing)
@@ -2580,12 +2581,13 @@ void sega_genesis_vdp_device::genesis_render_videobuffer_to_screenbuffer(int sca
}
}
}
-
- if (_32xdev)
+
+ if (!m_32x_scanline_helper_func.isnull())
+ m_32x_scanline_helper_func(scanline);
+ if (!m_32x_scanline_func.isnull())
{
- _32xdev->_32x_render_videobuffer_to_screenbuffer_helper(scanline);
for (int x = 0; x < 320; x++)
- _32xdev->_32x_render_videobuffer_to_screenbuffer(x, m_video_renderline[x] & 0x20000, lineptr[x]);
+ m_32x_scanline_func(x, m_video_renderline[x] & 0x20000, lineptr[x]);
}
}
@@ -2610,8 +2612,6 @@ void sega_genesis_vdp_device::vdp_handle_scanline_callback(int scanline)
to rounding errors in the timer calculation we're not quite there. Let's assume we are
still in the previous scanline for now.
*/
- sega_32x_device *_32xdev = machine().device<sega_32x_device>("sega32x"); // take this out of the VDP eventually
-
if (genesis_get_scanline_counter() != (megadrive_total_scanlines - 1))
{
@@ -2673,8 +2673,8 @@ void sega_genesis_vdp_device::vdp_handle_scanline_callback(int scanline)
}
// 32x interrupts!
- if (_32xdev)
- _32xdev->_32x_interrupt_cb(genesis_get_scanline_counter(), m_irq6_scanline);
+ if (!m_32x_interrupt_func.isnull())
+ m_32x_interrupt_func(genesis_get_scanline_counter(), m_irq6_scanline);
}
diff --git a/src/mame/machine/megavdp.h b/src/mame/machine/megavdp.h
index 1149c17c73a..8e75563bf22 100644
--- a/src/mame/machine/megavdp.h
+++ b/src/mame/machine/megavdp.h
@@ -167,9 +167,25 @@
#define MCFG_SEGAGEN_VDP_PALETTE(_palette_tag) \
sega_genesis_vdp_device::static_set_palette_tag(*device, "^" _palette_tag);
+
UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32 source, address_space & space68k);
+// Temporary solution while 32x VDP mixing and scanline interrupting is moved outside MD VDP
+typedef device_delegate<void (int x, UINT32 priority, UINT16 &lineptr)> md_32x_scanline_delegate;
+typedef device_delegate<void (int scanline, int irq6)> md_32x_interrupt_delegate;
+typedef device_delegate<void (int scanline)> md_32x_scanline_helper_delegate;
+
+#define MCFG_SEGAGEN_VDP_32X_SCANLINE_CB(_class, _method) \
+ sega_genesis_vdp_device::static_set_md_32x_scanline(*device, md_32x_scanline_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
+
+#define MCFG_SEGAGEN_VDP_32X_INTERRUPT_CB(_class, _method) \
+ sega_genesis_vdp_device::static_set_md_32x_interrupt(*device, md_32x_interrupt_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
+
+#define MCFG_SEGAGEN_VDP_32X_SCANLINE_HELPER_CB(_class, _method) \
+ sega_genesis_vdp_device::static_set_md_32x_scanline_helper(*device, md_32x_scanline_helper_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
+
+
class sega_genesis_vdp_device : public sega315_5124_device
{
public:
@@ -181,7 +197,11 @@ public:
static void set_genesis_vdp_alt_timing(device_t &device, int use_alt_timing);
static void set_genesis_vdp_palwrite_base(device_t &device, int palwrite_base);
static void static_set_palette_tag(device_t &device, const char *tag);
-
+
+ static void static_set_md_32x_scanline(device_t &device, md_32x_scanline_delegate callback) { downcast<sega_genesis_vdp_device &>(device).m_32x_scanline_func = callback; }
+ static void static_set_md_32x_interrupt(device_t &device, md_32x_interrupt_delegate callback) { downcast<sega_genesis_vdp_device &>(device).m_32x_interrupt_func = callback; }
+ static void static_set_md_32x_scanline_helper(device_t &device, md_32x_scanline_helper_delegate callback) { downcast<sega_genesis_vdp_device &>(device).m_32x_scanline_helper_func = callback; }
+
int m_use_alt_timing; // use MAME scanline timer instead, render only one scanline to a single line buffer, to be rendered by a partial update call.. experimental
int m_palwrite_base; // if we want to write to the actual MAME palette..
@@ -232,7 +252,11 @@ protected:
devcb2_write_line m_genesis_vdp_sndirqline_callback;
devcb2_write_line m_genesis_vdp_lv6irqline_callback;
devcb2_write_line m_genesis_vdp_lv4irqline_callback;
-
+
+ md_32x_scanline_delegate m_32x_scanline_func;
+ md_32x_interrupt_delegate m_32x_interrupt_func;
+ md_32x_scanline_helper_delegate m_32x_scanline_helper_func;
+
private:
int m_vdp_command_pending; // 2nd half of command pending..
diff --git a/src/mess/drivers/megadriv.c b/src/mess/drivers/megadriv.c
index f4151715bc3..dd69e9d5485 100644
--- a/src/mess/drivers/megadriv.c
+++ b/src/mess/drivers/megadriv.c
@@ -432,12 +432,35 @@ DEVICE_IMAGE_LOAD_MEMBER( md_base_state, _32x_cart )
}
+void md_cons_state::_32x_scanline_callback(int x, UINT32 priority, UINT16 &lineptr)
+{
+ if (m_32x)
+ m_32x->_32x_render_videobuffer_to_screenbuffer(x, priority, lineptr);
+}
+
+void md_cons_state::_32x_interrupt_callback(int scanline, int irq6)
+{
+ if (m_32x)
+ m_32x->_32x_interrupt_cb(scanline, irq6);
+}
+
+void md_cons_state::_32x_scanline_helper_callback(int scanline)
+{
+ if (m_32x)
+ m_32x->_32x_render_videobuffer_to_screenbuffer_helper(scanline);
+}
+
static MACHINE_CONFIG_START( genesis_32x, md_cons_state )
MCFG_FRAGMENT_ADD( md_ntsc )
MCFG_MACHINE_START_OVERRIDE( md_cons_state, md_common )
MCFG_MACHINE_RESET_OVERRIDE( md_cons_state, ms_megadriv )
+ MCFG_DEVICE_MODIFY("gen_vdp")
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_CB(md_cons_state, _32x_scanline_callback);
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
+ MCFG_SEGAGEN_VDP_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
+
MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
@@ -472,6 +495,11 @@ static MACHINE_CONFIG_START( mdj_32x, md_cons_state )
MCFG_MACHINE_START_OVERRIDE( md_cons_state, md_common )
MCFG_MACHINE_RESET_OVERRIDE( md_cons_state, ms_megadriv )
+ MCFG_DEVICE_MODIFY("gen_vdp")
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_CB(md_cons_state, _32x_scanline_callback);
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
+ MCFG_SEGAGEN_VDP_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
+
MCFG_DEVICE_ADD("sega32x", SEGA_32X_NTSC, 0)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
@@ -506,6 +534,11 @@ static MACHINE_CONFIG_START( md_32x, md_cons_state )
MCFG_MACHINE_START_OVERRIDE( md_cons_state, md_common )
MCFG_MACHINE_RESET_OVERRIDE( md_cons_state, ms_megadriv )
+ MCFG_DEVICE_MODIFY("gen_vdp")
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_CB(md_cons_state, _32x_scanline_callback);
+ MCFG_SEGAGEN_VDP_32X_SCANLINE_HELPER_CB(md_cons_state, _32x_scanline_helper_callback);
+ MCFG_SEGAGEN_VDP_32X_INTERRUPT_CB(md_cons_state, _32x_interrupt_callback);
+
MCFG_DEVICE_ADD("sega32x", SEGA_32X_PAL, 0)
MCFG_SEGA_32X_PALETTE("gen_vdp:palette")
diff --git a/src/mess/includes/md_cons.h b/src/mess/includes/md_cons.h
index ec0a779cef7..10e41673117 100644
--- a/src/mess/includes/md_cons.h
+++ b/src/mess/includes/md_cons.h
@@ -25,4 +25,8 @@ public:
DECLARE_MACHINE_START( md_common ); // setup ioport_port
DECLARE_MACHINE_START( ms_megadriv ); // setup ioport_port + install cartslot handlers
DECLARE_MACHINE_RESET( ms_megadriv );
+
+ void _32x_scanline_callback(int x, UINT32 priority, UINT16 &lineptr);
+ void _32x_interrupt_callback(int scanline, int irq6);
+ void _32x_scanline_helper_callback(int scanline);
};