diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2014-05-13 09:16:33 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2014-05-13 09:16:33 +0000 |
commit | c1b7ad0ae5e2b7c3359f0f9d4088ba47bb131f26 (patch) | |
tree | f49943476b9fc3cfd49d0b3eb255bcf3e0bee401 /src/emu | |
parent | 8e291797f286d0f3c6b2618eabe27418105682e2 (diff) |
voodoo converted to devcb2, Aaron ignore this one :) (nw)
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/video/vooddefs.h | 4 | ||||
-rw-r--r-- | src/emu/video/voodoo.c | 94 | ||||
-rw-r--r-- | src/emu/video/voodoo.h | 59 |
3 files changed, 91 insertions, 66 deletions
diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index 6e80fdb001e..22bfb94e1f4 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -1447,7 +1447,6 @@ struct pci_state fifo_state fifo; /* PCI FIFO */ UINT32 init_enable; /* initEnable value */ UINT8 stall_state; /* state of the system if we're stalled */ - devcb_resolved_write_line stall_callback; /* callback for stalling/unstalling */ UINT8 op_pending; /* true if an operation is pending */ attotime op_end_time; /* time when the pending operation ends */ emu_timer * continue_timer; /* timer to use to continue processing */ @@ -1563,7 +1562,6 @@ struct fbi_state UINT8 vblank_swap_pending; /* a swap is pending, waiting for a vblank */ UINT8 vblank_swap; /* swap when we hit this count */ UINT8 vblank_dont_swap; /* don't actually swap when we hit this point */ - devcb_resolved_write_line vblank_client; /* client callback */ /* triangle setup info */ UINT8 cheating_allowed; /* allow cheating? */ @@ -1692,7 +1690,7 @@ struct banshee_info struct voodoo_state { UINT8 index; /* index of board */ - device_t *device; /* pointer to our containing device */ + voodoo_device *device; /* pointer to our containing device */ screen_device *screen; /* the screen we are acting on */ device_t *cpu; /* the CPU we interact with */ UINT8 type; /* type of system */ diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index ab0096077e8..46bc0a579c8 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -977,15 +977,15 @@ static TIMER_CALLBACK( vblank_off_callback ) { v->reg[intrCtrl].u |= 0x200; // VSYNC int (falling) active - if (!v->fbi.vblank_client.isnull()) - v->fbi.vblank_client(FALSE); + if (!v->device->m_vblank.isnull()) + v->device->m_vblank(FALSE); } } else { - if (!v->fbi.vblank_client.isnull()) - v->fbi.vblank_client(FALSE); + if (!v->device->m_vblank.isnull()) + v->device->m_vblank(FALSE); } /* go to the end of the next frame */ @@ -1033,14 +1033,14 @@ static TIMER_CALLBACK( vblank_callback ) { v->reg[intrCtrl].u |= 0x100; // VSYNC int (rising) active - if (!v->fbi.vblank_client.isnull()) - v->fbi.vblank_client(TRUE); + if (!v->device->m_vblank.isnull()) + v->device->m_vblank(TRUE); } } else { - if (!v->fbi.vblank_client.isnull()) - v->fbi.vblank_client(TRUE); + if (!v->device->m_vblank.isnull()) + v->device->m_vblank(TRUE); } } @@ -2148,8 +2148,8 @@ static void check_stalled_cpu(voodoo_state *v, attotime current_time) v->pci.stall_state = NOT_STALLED; /* either call the callback, or trigger the trigger */ - if (!v->pci.stall_callback.isnull()) - v->pci.stall_callback(FALSE); + if (!v->device->m_stall.isnull()) + v->device->m_stall(FALSE); else v->device->machine().scheduler().trigger(v->trigger); } @@ -2172,8 +2172,8 @@ static void stall_cpu(voodoo_state *v, int state, attotime current_time) v->stats.stalls++; /* either call the callback, or spin the CPU */ - if (!v->pci.stall_callback.isnull()) - v->pci.stall_callback(TRUE); + if (!v->device->m_stall.isnull()) + v->device->m_stall(TRUE); else v->cpu->execute().spin_until_trigger(v->trigger); @@ -2530,8 +2530,8 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data) v->reg[intrCtrl].u &= ~0x80000000; // TODO: rename vblank_client for less confusion? - if (!v->fbi.vblank_client.isnull()) - v->fbi.vblank_client(TRUE); + if (!v->device->m_vblank.isnull()) + v->device->m_vblank(TRUE); break; /* gamma table access -- Voodoo/Voodoo2 only */ @@ -4858,10 +4858,9 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_io_w ) device start callback -------------------------------------------------*/ -static void common_start_voodoo(device_t *device, UINT8 type) +void voodoo_device::common_start_voodoo(UINT8 type) { - const voodoo_config *config = (const voodoo_config *)device->static_config(); - voodoo_state *v = get_safe_token(device); + voodoo_state *v = get_safe_token(this); const raster_info *info; void *fbmem, *tmumem[2]; UINT32 tmumem0; @@ -4873,17 +4872,17 @@ static void common_start_voodoo(device_t *device, UINT8 type) assert(config->fbmem > 0); /* store a pointer back to the device */ - v->device = device; + v->device = this; v->type = type; /* copy config data */ - v->freq = device->clock(); - v->fbi.vblank_client.resolve(config->vblank,*device); - v->pci.stall_callback.resolve(config->stall,*device); + v->freq = clock(); + v->device->m_vblank.resolve(); + v->device->m_stall.resolve(); /* create a multiprocessor work queue */ - v->poly = poly_alloc(device->machine(), 64, sizeof(poly_extra_data), 0); - v->thread_stats = auto_alloc_array(device->machine(), stats_block, WORK_MAX_THREADS); + v->poly = poly_alloc(machine(), 64, sizeof(poly_extra_data), 0); + v->thread_stats = auto_alloc_array(machine(), stats_block, WORK_MAX_THREADS); /* create a table of precomputed 1/n and log2(n) values */ /* n ranges from 1.0000 to 2.0000 */ @@ -4951,18 +4950,18 @@ static void common_start_voodoo(device_t *device, UINT8 type) } /* set the type, and initialize the chip mask */ - device_iterator iter(device->machine().root_device()); + device_iterator iter(machine().root_device()); v->index = 0; for (device_t *scan = iter.first(); scan != NULL; scan = iter.next()) - if (scan->type() == device->type()) + if (scan->type() == this->type()) { - if (scan == device) + if (scan == this) break; v->index++; } - v->screen = downcast<screen_device *>(device->machine().device(config->screen)); + v->screen = downcast<screen_device *>(machine().device(m_screen)); assert_always(v->screen != NULL, "Unable to find screen attached to voodoo"); - v->cpu = device->machine().device(config->cputag); + v->cpu = machine().device(m_cputag); assert_always(v->cpu != NULL, "Unable to find CPU attached to voodoo"); v->chipmask = 0x01; v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq; @@ -4977,26 +4976,26 @@ static void common_start_voodoo(device_t *device, UINT8 type) v->pci.fifo.size = 64*2; v->pci.fifo.in = v->pci.fifo.out = 0; v->pci.stall_state = NOT_STALLED; - v->pci.continue_timer = v->device->machine().scheduler().timer_alloc(FUNC(stall_cpu_callback), v); + v->pci.continue_timer = machine().scheduler().timer_alloc(FUNC(stall_cpu_callback), v); /* allocate memory */ - tmumem0 = config->tmumem0; + tmumem0 = m_tmumem0; if (v->type <= TYPE_VOODOO_2) { /* separate FB/TMU memory */ - fbmem = auto_alloc_array(device->machine(), UINT8, config->fbmem << 20); - tmumem[0] = auto_alloc_array(device->machine(), UINT8, config->tmumem0 << 20); - tmumem[1] = (config->tmumem1 != 0) ? auto_alloc_array(device->machine(), UINT8, config->tmumem1 << 20) : NULL; + fbmem = auto_alloc_array(machine(), UINT8, m_fbmem << 20); + tmumem[0] = auto_alloc_array(machine(), UINT8, m_tmumem0 << 20); + tmumem[1] = (m_tmumem1 != 0) ? auto_alloc_array(machine(), UINT8, m_tmumem1 << 20) : NULL; } else { /* shared memory */ - tmumem[0] = tmumem[1] = fbmem = auto_alloc_array(device->machine(), UINT8, config->fbmem << 20); - tmumem0 = config->fbmem; + tmumem[0] = tmumem[1] = fbmem = auto_alloc_array(machine(), UINT8, m_fbmem << 20); + tmumem0 = m_fbmem; } /* set up frame buffer */ - init_fbi(v, &v->fbi, fbmem, config->fbmem << 20); + init_fbi(v, &v->fbi, fbmem, m_fbmem << 20); /* build shared TMU tables */ init_tmu_shared(&v->tmushare); @@ -5004,9 +5003,9 @@ static void common_start_voodoo(device_t *device, UINT8 type) /* set up the TMUs */ init_tmu(v, &v->tmu[0], &v->reg[0x100], tmumem[0], tmumem0 << 20); v->chipmask |= 0x02; - if (config->tmumem1 != 0 || v->type == TYPE_VOODOO_3) + if (m_tmumem1 != 0 || v->type == TYPE_VOODOO_3) { - init_tmu(v, &v->tmu[1], &v->reg[0x200], tmumem[1], config->tmumem1 << 20); + init_tmu(v, &v->tmu[1], &v->reg[0x200], tmumem[1], m_tmumem1 << 20); v->chipmask |= 0x04; } @@ -5033,7 +5032,7 @@ static void common_start_voodoo(device_t *device, UINT8 type) soft_reset(v); /* register for save states */ - init_save_state(device); + init_save_state(this); } @@ -5666,7 +5665,14 @@ static void dump_rasterizer_stats(voodoo_state *v) } voodoo_device::voodoo_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + m_fbmem(0), + m_tmumem0(0), + m_tmumem1(0), + m_screen(NULL), + m_cputag(NULL), + m_vblank(*this), + m_stall(*this) { m_token = global_alloc_clear(voodoo_state); } @@ -5723,7 +5729,7 @@ voodoo_1_device::voodoo_1_device(const machine_config &mconfig, const char *tag, void voodoo_1_device::device_start() { - common_start_voodoo(this, TYPE_VOODOO_1); + common_start_voodoo(TYPE_VOODOO_1); } @@ -5740,7 +5746,7 @@ voodoo_2_device::voodoo_2_device(const machine_config &mconfig, const char *tag, void voodoo_2_device::device_start() { - common_start_voodoo(this, TYPE_VOODOO_2); + common_start_voodoo(TYPE_VOODOO_2); } @@ -5762,7 +5768,7 @@ voodoo_banshee_device::voodoo_banshee_device(const machine_config &mconfig, devi void voodoo_banshee_device::device_start() { - common_start_voodoo(this, TYPE_VOODOO_BANSHEE); + common_start_voodoo(TYPE_VOODOO_BANSHEE); } @@ -5779,7 +5785,7 @@ voodoo_3_device::voodoo_3_device(const machine_config &mconfig, const char *tag, void voodoo_3_device::device_start() { - common_start_voodoo(this, TYPE_VOODOO_3); + common_start_voodoo(TYPE_VOODOO_3); } diff --git a/src/emu/video/voodoo.h b/src/emu/video/voodoo.h index 26362bb168d..2e9c1afea1a 100644 --- a/src/emu/video/voodoo.h +++ b/src/emu/video/voodoo.h @@ -39,13 +39,13 @@ enum struct voodoo_config { - UINT8 fbmem; - UINT8 tmumem0; - UINT8 tmumem1; - const char * screen; - const char * cputag; - devcb_write_line vblank; - devcb_write_line stall; + UINT8 l_fbmem; + UINT8 l_tmumem0; + UINT8 l_tmumem1; + const char * l_screen; + const char * l_cputag; + devcb_write_line l_vblank; + devcb_write_line l_stall; }; @@ -54,21 +54,24 @@ struct voodoo_config DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MCFG_3DFX_VOODOO_1_ADD(_tag, _clock, _config) \ - MCFG_DEVICE_ADD(_tag, VOODOO_1, _clock) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_VOODOO_FBMEM(_value) \ + voodoo_device::static_set_fbmem(*device, _value); -#define MCFG_3DFX_VOODOO_2_ADD(_tag, _clock, _config) \ - MCFG_DEVICE_ADD(_tag, VOODOO_2, _clock) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_VOODOO_TMUMEM(_value1, _value2) \ + voodoo_device::static_set_tmumem(*device, _value1, _value2); -#define MCFG_3DFX_VOODOO_BANSHEE_ADD(_tag, _clock, _config) \ - MCFG_DEVICE_ADD(_tag, VOODOO_BANSHEE, _clock) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_VOODOO_SCREEN_TAG(_tag) \ + voodoo_device::static_set_screen_tag(*device, _tag); -#define MCFG_3DFX_VOODOO_3_ADD(_tag, _clock, _config) \ - MCFG_DEVICE_ADD(_tag, VOODOO_3, _clock) \ - MCFG_DEVICE_CONFIG(_config) +#define MCFG_VOODOO_CPU_TAG(_tag) \ + voodoo_device::static_set_cpu_tag(*device, _tag); + +#define MCFG_VOODOO_VBLANK_CB(_devcb) \ + devcb = &voodoo_device::static_set_vblank_callback(*device, DEVCB2_##_devcb); + +#define MCFG_VOODOO_STALL_CB(_devcb) \ + devcb = &voodoo_device::static_set_stall_callback(*device, DEVCB2_##_devcb); + /*************************************************************************** FUNCTION PROTOTYPES @@ -87,11 +90,29 @@ public: voodoo_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); ~voodoo_device(); + + static void static_set_fbmem(device_t &device, int value) { downcast<voodoo_device &>(device).m_fbmem = value; } + static void static_set_tmumem(device_t &device, int value1, int value2) { downcast<voodoo_device &>(device).m_tmumem0 = value1; downcast<voodoo_device &>(device).m_tmumem1 = value2; } + static void static_set_screen_tag(device_t &device, const char *tag) { downcast<voodoo_device &>(device).m_screen = tag; } + static void static_set_cpu_tag(device_t &device, const char *tag) { downcast<voodoo_device &>(device).m_cputag = tag; } + template<class _Object> static devcb2_base &static_set_vblank_callback(device_t &device, _Object object) { return downcast<voodoo_device &>(device).m_vblank.set_callback(object); } + template<class _Object> static devcb2_base &static_set_stall_callback(device_t &device, _Object object) { return downcast<voodoo_device &>(device).m_stall.set_callback(object); } + DECLARE_READ32_MEMBER( voodoo_r ); DECLARE_WRITE32_MEMBER( voodoo_w ); // access to legacy token struct voodoo_state *token() const { assert(m_token != NULL); return m_token; } + void common_start_voodoo(UINT8 type); + + UINT8 m_fbmem; + UINT8 m_tmumem0; + UINT8 m_tmumem1; + const char * m_screen; + const char * m_cputag; + devcb2_write_line m_vblank; + devcb2_write_line m_stall; + protected: // device-level overrides virtual void device_config_complete(); |