summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/voodoo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/video/voodoo.cpp')
-rw-r--r--src/devices/video/voodoo.cpp2875
1 files changed, 1399 insertions, 1476 deletions
diff --git a/src/devices/video/voodoo.cpp b/src/devices/video/voodoo.cpp
index 4304b5ebf32..7fe0b94a007 100644
--- a/src/devices/video/voodoo.cpp
+++ b/src/devices/video/voodoo.cpp
@@ -143,7 +143,7 @@ bits(7:4) and bit(24)), X, and Y:
#include "emu.h"
-#include "video/polylgcy.h"
+
#include "video/rgbutil.h"
#include "voodoo.h"
#include "vooddefs.h"
@@ -194,50 +194,6 @@ UINT32 voodoo_reciplog[(2 << RECIPLOG_LOOKUP_BITS) + 2];
-/*************************************
- *
- * Prototypes
- *
- *************************************/
-
-static void init_fbi(voodoo_state *v, fbi_state *f, void *memory, int fbmem);
-static void init_tmu_shared(tmu_shared_state *s);
-static void init_tmu(voodoo_state *v, tmu_state *t, voodoo_reg *reg, void *memory, int tmem);
-static void soft_reset(voodoo_state *v);
-static void recompute_video_memory(voodoo_state *v);
-static void check_stalled_cpu(voodoo_state *v, attotime current_time);
-static void flush_fifos(voodoo_state *v, attotime current_time);
-static TIMER_CALLBACK( stall_cpu_callback );
-static void stall_cpu(voodoo_state *v, int state, attotime current_time);
-static TIMER_CALLBACK( vblank_callback );
-static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data);
-static INT32 lfb_direct_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask);
-static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask);
-static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data);
-static INT32 banshee_2d_w(voodoo_state *v, offs_t offset, UINT32 data);
-
-/* command handlers */
-static INT32 fastfill(voodoo_state *v);
-static INT32 swapbuffer(voodoo_state *v, UINT32 data);
-static INT32 triangle(voodoo_state *v);
-static INT32 begin_triangle(voodoo_state *v);
-static INT32 draw_triangle(voodoo_state *v);
-
-/* triangle helpers */
-static INT32 setup_and_draw_triangle(voodoo_state *v);
-static INT32 triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int texcount);
-
-/* rasterizer management */
-static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo);
-static raster_info *find_rasterizer(voodoo_state *v, int texcount);
-static void dump_rasterizer_stats(voodoo_state *v);
-
-/* generic rasterizers */
-static void raster_fastfill(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
-static void raster_generic_0tmu(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
-static void raster_generic_1tmu(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
-static void raster_generic_2tmu(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid);
-
/*************************************
@@ -262,7 +218,7 @@ static void raster_generic_2tmu(void *dest, INT32 scanline, const poly_extent *e
*************************************/
#define RASTERIZER_ENTRY(fbzcp, alpha, fog, fbz, tex0, tex1) \
- { NULL, raster_##fbzcp##_##alpha##_##fog##_##fbz##_##tex0##_##tex1, FALSE, 0, 0, 0, fbzcp, alpha, fog, fbz, tex0, tex1 },
+ { NULL, voodoo_device::raster_##fbzcp##_##alpha##_##fog##_##fbz##_##tex0##_##tex1, FALSE, 0, 0, 0, fbzcp, alpha, fog, fbz, tex0, tex1 },
static const raster_info predef_raster_table[] =
{
@@ -278,100 +234,84 @@ static const raster_info predef_raster_table[] =
INLINE FUNCTIONS
***************************************************************************/
-/*-------------------------------------------------
- get_safe_token - makes sure that the passed
- in device is, in fact, a voodoo device
--------------------------------------------------*/
-
-static inline voodoo_state *get_safe_token(device_t *device)
-{
- assert(device != nullptr);
- assert((device->type() == VOODOO_1) || (device->type() == VOODOO_2) || (device->type() == VOODOO_BANSHEE) || (device->type() == VOODOO_3));
-
- return (voodoo_state *)downcast<voodoo_device *>(device)->token();
-}
-
-
-
/*************************************
*
* Video update
*
*************************************/
-int voodoo_update(device_t *device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
+int voodoo_device::voodoo_update(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- voodoo_state *v = get_safe_token(device);
- int changed = v->fbi.video_changed;
- int drawbuf = v->fbi.frontbuf;
+ int changed = fbi.video_changed;
+ int drawbuf = fbi.frontbuf;
int statskey;
int x, y;
/* reset the video changed flag */
- v->fbi.video_changed = FALSE;
+ fbi.video_changed = FALSE;
/* if we are blank, just fill with black */
- if (v->type <= TYPE_VOODOO_2 && FBIINIT1_SOFTWARE_BLANK(v->reg[fbiInit1].u))
+ if (vd_type <= TYPE_VOODOO_2 && FBIINIT1_SOFTWARE_BLANK(reg[fbiInit1].u))
{
bitmap.fill(0, cliprect);
return changed;
}
/* if the CLUT is dirty, recompute the pens array */
- if (v->fbi.clut_dirty)
+ if (fbi.clut_dirty)
{
UINT8 rtable[32], gtable[64], btable[32];
/* Voodoo/Voodoo-2 have an internal 33-entry CLUT */
- if (v->type <= TYPE_VOODOO_2)
+ if (vd_type <= TYPE_VOODOO_2)
{
/* kludge: some of the Midway games write 0 to the last entry when they obviously mean FF */
- if ((v->fbi.clut[32] & 0xffffff) == 0 && (v->fbi.clut[31] & 0xffffff) != 0)
- v->fbi.clut[32] = 0x20ffffff;
+ if ((fbi.clut[32] & 0xffffff) == 0 && (fbi.clut[31] & 0xffffff) != 0)
+ fbi.clut[32] = 0x20ffffff;
/* compute the R/G/B pens first */
for (x = 0; x < 32; x++)
{
/* treat X as a 5-bit value, scale up to 8 bits, and linear interpolate for red/blue */
y = (x << 3) | (x >> 2);
- rtable[x] = (v->fbi.clut[y >> 3].r() * (8 - (y & 7)) + v->fbi.clut[(y >> 3) + 1].r() * (y & 7)) >> 3;
- btable[x] = (v->fbi.clut[y >> 3].b() * (8 - (y & 7)) + v->fbi.clut[(y >> 3) + 1].b() * (y & 7)) >> 3;
+ rtable[x] = (fbi.clut[y >> 3].r() * (8 - (y & 7)) + fbi.clut[(y >> 3) + 1].r() * (y & 7)) >> 3;
+ btable[x] = (fbi.clut[y >> 3].b() * (8 - (y & 7)) + fbi.clut[(y >> 3) + 1].b() * (y & 7)) >> 3;
/* treat X as a 6-bit value with LSB=0, scale up to 8 bits, and linear interpolate */
y = (x * 2) + 0;
y = (y << 2) | (y >> 4);
- gtable[x*2+0] = (v->fbi.clut[y >> 3].g() * (8 - (y & 7)) + v->fbi.clut[(y >> 3) + 1].g() * (y & 7)) >> 3;
+ gtable[x*2+0] = (fbi.clut[y >> 3].g() * (8 - (y & 7)) + fbi.clut[(y >> 3) + 1].g() * (y & 7)) >> 3;
/* treat X as a 6-bit value with LSB=1, scale up to 8 bits, and linear interpolate */
y = (x * 2) + 1;
y = (y << 2) | (y >> 4);
- gtable[x*2+1] = (v->fbi.clut[y >> 3].g() * (8 - (y & 7)) + v->fbi.clut[(y >> 3) + 1].g() * (y & 7)) >> 3;
+ gtable[x*2+1] = (fbi.clut[y >> 3].g() * (8 - (y & 7)) + fbi.clut[(y >> 3) + 1].g() * (y & 7)) >> 3;
}
}
/* Banshee and later have a 512-entry CLUT that can be bypassed */
else
{
- int which = (v->banshee.io[io_vidProcCfg] >> 13) & 1;
- int bypass = (v->banshee.io[io_vidProcCfg] >> 11) & 1;
+ int which = (banshee.io[io_vidProcCfg] >> 13) & 1;
+ int bypass = (banshee.io[io_vidProcCfg] >> 11) & 1;
/* compute R/G/B pens first */
for (x = 0; x < 32; x++)
{
/* treat X as a 5-bit value, scale up to 8 bits */
y = (x << 3) | (x >> 2);
- rtable[x] = bypass ? y : v->fbi.clut[which * 256 + y].r();
- btable[x] = bypass ? y : v->fbi.clut[which * 256 + y].b();
+ rtable[x] = bypass ? y : fbi.clut[which * 256 + y].r();
+ btable[x] = bypass ? y : fbi.clut[which * 256 + y].b();
/* treat X as a 6-bit value with LSB=0, scale up to 8 bits */
y = (x * 2) + 0;
y = (y << 2) | (y >> 4);
- gtable[x*2+0] = bypass ? y : v->fbi.clut[which * 256 + y].g();
+ gtable[x*2+0] = bypass ? y : fbi.clut[which * 256 + y].g();
/* treat X as a 6-bit value with LSB=1, scale up to 8 bits, and linear interpolate */
y = (x * 2) + 1;
y = (y << 2) | (y >> 4);
- gtable[x*2+1] = bypass ? y : v->fbi.clut[which * 256 + y].g();
+ gtable[x*2+1] = bypass ? y : fbi.clut[which * 256 + y].g();
}
}
@@ -381,45 +321,45 @@ int voodoo_update(device_t *device, bitmap_rgb32 &bitmap, const rectangle &clipr
int r = rtable[(x >> 11) & 0x1f];
int g = gtable[(x >> 5) & 0x3f];
int b = btable[x & 0x1f];
- v->fbi.pen[x] = rgb_t(r, g, b);
+ fbi.pen[x] = rgb_t(r, g, b);
}
/* no longer dirty */
- v->fbi.clut_dirty = FALSE;
+ fbi.clut_dirty = FALSE;
changed = TRUE;
}
/* debugging! */
- if (device->machine().input().code_pressed(KEYCODE_L))
- drawbuf = v->fbi.backbuf;
+ if (machine().input().code_pressed(KEYCODE_L))
+ drawbuf = fbi.backbuf;
/* copy from the current front buffer */
for (y = cliprect.min_y; y <= cliprect.max_y; y++)
- if (y >= v->fbi.yoffs)
+ if (y >= fbi.yoffs)
{
- UINT16 *src = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[drawbuf]) + (y - v->fbi.yoffs) * v->fbi.rowpixels - v->fbi.xoffs;
+ UINT16 *src = (UINT16 *)(fbi.ram + fbi.rgboffs[drawbuf]) + (y - fbi.yoffs) * fbi.rowpixels - fbi.xoffs;
UINT32 *dst = &bitmap.pix32(y);
for (x = cliprect.min_x; x <= cliprect.max_x; x++)
- dst[x] = v->fbi.pen[src[x]];
+ dst[x] = fbi.pen[src[x]];
}
/* update stats display */
- statskey = (device->machine().input().code_pressed(KEYCODE_BACKSLASH) != 0);
- if (statskey && statskey != v->stats.lastkey)
- v->stats.display = !v->stats.display;
- v->stats.lastkey = statskey;
+ statskey = (machine().input().code_pressed(KEYCODE_BACKSLASH) != 0);
+ if (statskey && statskey != stats.lastkey)
+ stats.display = !stats.display;
+ stats.lastkey = statskey;
/* display stats */
- if (v->stats.display)
- device->popmessage(v->stats.buffer, 0, 0);
+ if (stats.display)
+ popmessage(stats.buffer, 0, 0);
/* update render override */
- v->stats.render_override = device->machine().input().code_pressed(KEYCODE_ENTER);
- if (DEBUG_DEPTH && v->stats.render_override)
+ stats.render_override = machine().input().code_pressed(KEYCODE_ENTER);
+ if (DEBUG_DEPTH && stats.render_override)
{
for (y = cliprect.min_y; y <= cliprect.max_y; y++)
{
- UINT16 *src = (UINT16 *)(v->fbi.ram + v->fbi.auxoffs) + (y - v->fbi.yoffs) * v->fbi.rowpixels - v->fbi.xoffs;
+ UINT16 *src = (UINT16 *)(fbi.ram + fbi.auxoffs) + (y - fbi.yoffs) * fbi.rowpixels - fbi.xoffs;
UINT32 *dst = &bitmap.pix32(y);
for (x = cliprect.min_x; x <= cliprect.max_x; x++)
dst[x] = ((src[x] << 8) & 0xff0000) | ((src[x] >> 0) & 0xff00) | ((src[x] >> 8) & 0xff);
@@ -436,26 +376,27 @@ int voodoo_update(device_t *device, bitmap_rgb32 &bitmap, const rectangle &clipr
*
*************************************/
-int voodoo_get_type(device_t *device)
+
+int voodoo_device::voodoo_get_type()
{
- voodoo_state *v = get_safe_token(device);
- return v->type;
+ voodoo_device *vd = this;
+ return vd->vd_type;
}
-int voodoo_is_stalled(device_t *device)
+int voodoo_device::voodoo_is_stalled()
{
- voodoo_state *v = get_safe_token(device);
- return (v->pci.stall_state != NOT_STALLED);
+ voodoo_device *vd = this;
+ return (vd->pci.stall_state != NOT_STALLED);
}
-void voodoo_set_init_enable(device_t *device, UINT32 newval)
+void voodoo_device::voodoo_set_init_enable(UINT32 newval)
{
- voodoo_state *v = get_safe_token(device);
- v->pci.init_enable = newval;
+ voodoo_device *vd = this;
+ vd->pci.init_enable = newval;
if (LOG_REGISTERS)
- device->logerror("VOODOO.%d.REG:initEnable write = %08X\n", v->index, newval);
+ logerror("VOODOO.%d.REG:initEnable write = %08X\n", vd->index, newval);
}
@@ -466,7 +407,7 @@ void voodoo_set_init_enable(device_t *device, UINT32 newval)
*
*************************************/
-static void init_fbi(voodoo_state *v, fbi_state *f, void *memory, int fbmem)
+void voodoo_device::init_fbi(voodoo_device* vd,fbi_state *f, void *memory, int fbmem)
{
int pen;
@@ -484,20 +425,20 @@ static void init_fbi(voodoo_state *v, fbi_state *f, void *memory, int fbmem)
/* init the pens */
f->clut_dirty = TRUE;
- if (v->type <= TYPE_VOODOO_2)
+ if (vd->vd_type <= TYPE_VOODOO_2)
{
for (pen = 0; pen < 32; pen++)
- v->fbi.clut[pen] = rgb_t(pen, pal5bit(pen), pal5bit(pen), pal5bit(pen));
- v->fbi.clut[32] = rgb_t(32,0xff,0xff,0xff);
+ vd->fbi.clut[pen] = rgb_t(pen, pal5bit(pen), pal5bit(pen), pal5bit(pen));
+ vd->fbi.clut[32] = rgb_t(32,0xff,0xff,0xff);
}
else
{
for (pen = 0; pen < 512; pen++)
- v->fbi.clut[pen] = rgb_t(pen,pen,pen);
+ vd->fbi.clut[pen] = rgb_t(pen,pen,pen);
}
/* allocate a VBLANK timer */
- f->vblank_timer = v->device->machine().scheduler().timer_alloc(FUNC(vblank_callback), v);
+ f->vblank_timer = vd->device->machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(voodoo_device::vblank_callback),vd), vd);
f->vblank = FALSE;
/* initialize the memory FIFO */
@@ -505,11 +446,11 @@ static void init_fbi(voodoo_state *v, fbi_state *f, void *memory, int fbmem)
f->fifo.size = f->fifo.in = f->fifo.out = 0;
/* set the fog delta mask */
- f->fogdelta_mask = (v->type < TYPE_VOODOO_2) ? 0xff : 0xfc;
+ f->fogdelta_mask = (vd->vd_type < TYPE_VOODOO_2) ? 0xff : 0xfc;
}
-static void init_tmu_shared(tmu_shared_state *s)
+void voodoo_device::init_tmu_shared(tmu_shared_state *s)
{
int val;
@@ -554,14 +495,14 @@ static void init_tmu_shared(tmu_shared_state *s)
}
-static void init_tmu(voodoo_state *v, tmu_state *t, voodoo_reg *reg, void *memory, int tmem)
+void voodoo_device::init_tmu(voodoo_device* vd, tmu_state *t, voodoo_reg *reg, void *memory, int tmem)
{
/* allocate texture RAM */
t->ram = (UINT8 *)memory;
t->mask = tmem - 1;
t->reg = reg;
t->regdirty = TRUE;
- t->bilinear_mask = (v->type >= TYPE_VOODOO_2) ? 0xff : 0xf0;
+ t->bilinear_mask = (vd->vd_type >= TYPE_VOODOO_2) ? 0xff : 0xf0;
/* mark the NCC tables dirty and configure their registers */
t->ncc[0].dirty = t->ncc[1].dirty = TRUE;
@@ -569,31 +510,31 @@ static void init_tmu(voodoo_state *v, tmu_state *t, voodoo_reg *reg, void *memor
t->ncc[1].reg = &t->reg[nccTable+12];
/* create pointers to all the tables */
- t->texel[0] = v->tmushare.rgb332;
+ t->texel[0] = vd->tmushare.rgb332;
t->texel[1] = t->ncc[0].texel;
- t->texel[2] = v->tmushare.alpha8;
- t->texel[3] = v->tmushare.int8;
- t->texel[4] = v->tmushare.ai44;
+ t->texel[2] = vd->tmushare.alpha8;
+ t->texel[3] = vd->tmushare.int8;
+ t->texel[4] = vd->tmushare.ai44;
t->texel[5] = t->palette;
- t->texel[6] = (v->type >= TYPE_VOODOO_2) ? t->palettea : nullptr;
+ t->texel[6] = (vd->vd_type >= TYPE_VOODOO_2) ? t->palettea : nullptr;
t->texel[7] = nullptr;
- t->texel[8] = v->tmushare.rgb332;
+ t->texel[8] = vd->tmushare.rgb332;
t->texel[9] = t->ncc[0].texel;
- t->texel[10] = v->tmushare.rgb565;
- t->texel[11] = v->tmushare.argb1555;
- t->texel[12] = v->tmushare.argb4444;
- t->texel[13] = v->tmushare.int8;
+ t->texel[10] = vd->tmushare.rgb565;
+ t->texel[11] = vd->tmushare.argb1555;
+ t->texel[12] = vd->tmushare.argb4444;
+ t->texel[13] = vd->tmushare.int8;
t->texel[14] = t->palette;
t->texel[15] = nullptr;
t->lookup = t->texel[0];
/* attach the palette to NCC table 0 */
t->ncc[0].palette = t->palette;
- if (v->type >= TYPE_VOODOO_2)
+ if (vd->vd_type >= TYPE_VOODOO_2)
t->ncc[0].palettea = t->palettea;
/* set up texture address calculations */
- if (v->type <= TYPE_VOODOO_2)
+ if (vd->vd_type <= TYPE_VOODOO_2)
{
t->texaddr_mask = 0x0fffff;
t->texaddr_shift = 3;
@@ -606,181 +547,180 @@ static void init_tmu(voodoo_state *v, tmu_state *t, voodoo_reg *reg, void *memor
}
-static void voodoo_postload(voodoo_state *v)
+void voodoo_device::voodoo_postload(voodoo_device *vd)
{
int index, subindex;
- v->fbi.clut_dirty = TRUE;
- for (index = 0; index < ARRAY_LENGTH(v->tmu); index++)
+ vd->fbi.clut_dirty = TRUE;
+ for (index = 0; index < ARRAY_LENGTH(vd->tmu); index++)
{
- v->tmu[index].regdirty = TRUE;
- for (subindex = 0; subindex < ARRAY_LENGTH(v->tmu[index].ncc); subindex++)
- v->tmu[index].ncc[subindex].dirty = TRUE;
+ vd->tmu[index].regdirty = TRUE;
+ for (subindex = 0; subindex < ARRAY_LENGTH(vd->tmu[index].ncc); subindex++)
+ vd->tmu[index].ncc[subindex].dirty = TRUE;
}
/* recompute video memory to get the FBI FIFO base recomputed */
- if (v->type <= TYPE_VOODOO_2)
- recompute_video_memory(v);
+ if (vd->vd_type <= TYPE_VOODOO_2)
+ recompute_video_memory(vd);
}
-static void init_save_state(device_t *device)
+static void init_save_state(voodoo_device *vd)
{
- voodoo_state *v = get_safe_token(device);
int index, subindex;
- device->machine().save().register_postload(save_prepost_delegate(FUNC(voodoo_postload), v));
+ vd->machine().save().register_postload(save_prepost_delegate(FUNC(voodoo_device::voodoo_postload), vd));
/* register states: core */
- device->save_item(NAME(v->extra_cycles));
- device->save_pointer(NAME(&v->reg[0].u), ARRAY_LENGTH(v->reg));
- device->save_item(NAME(v->alt_regmap));
+ vd->save_item(NAME(vd->extra_cycles));
+ vd->save_pointer(NAME(&vd->reg[0].u), ARRAY_LENGTH(vd->reg));
+ vd->save_item(NAME(vd->alt_regmap));
/* register states: pci */
- device->save_item(NAME(v->pci.fifo.in));
- device->save_item(NAME(v->pci.fifo.out));
- device->save_item(NAME(v->pci.init_enable));
- device->save_item(NAME(v->pci.stall_state));
- device->save_item(NAME(v->pci.op_pending));
- device->save_item(NAME(v->pci.op_end_time));
- device->save_item(NAME(v->pci.fifo_mem));
+ vd->save_item(NAME(vd->pci.fifo.in));
+ vd->save_item(NAME(vd->pci.fifo.out));
+ vd->save_item(NAME(vd->pci.init_enable));
+ vd->save_item(NAME(vd->pci.stall_state));
+ vd->save_item(NAME(vd->pci.op_pending));
+ vd->save_item(NAME(vd->pci.op_end_time));
+ vd->save_item(NAME(vd->pci.fifo_mem));
/* register states: dac */
- device->save_item(NAME(v->dac.reg));
- device->save_item(NAME(v->dac.read_result));
+ vd->save_item(NAME(vd->dac.reg));
+ vd->save_item(NAME(vd->dac.read_result));
/* register states: fbi */
- device->save_pointer(NAME(v->fbi.ram), v->fbi.mask + 1);
- device->save_item(NAME(v->fbi.rgboffs));
- device->save_item(NAME(v->fbi.auxoffs));
- device->save_item(NAME(v->fbi.frontbuf));
- device->save_item(NAME(v->fbi.backbuf));
- device->save_item(NAME(v->fbi.swaps_pending));
- device->save_item(NAME(v->fbi.video_changed));
- device->save_item(NAME(v->fbi.yorigin));
- device->save_item(NAME(v->fbi.lfb_base));
- device->save_item(NAME(v->fbi.lfb_stride));
- device->save_item(NAME(v->fbi.width));
- device->save_item(NAME(v->fbi.height));
- device->save_item(NAME(v->fbi.xoffs));
- device->save_item(NAME(v->fbi.yoffs));
- device->save_item(NAME(v->fbi.vsyncscan));
- device->save_item(NAME(v->fbi.rowpixels));
- device->save_item(NAME(v->fbi.vblank));
- device->save_item(NAME(v->fbi.vblank_count));
- device->save_item(NAME(v->fbi.vblank_swap_pending));
- device->save_item(NAME(v->fbi.vblank_swap));
- device->save_item(NAME(v->fbi.vblank_dont_swap));
- device->save_item(NAME(v->fbi.cheating_allowed));
- device->save_item(NAME(v->fbi.sign));
- device->save_item(NAME(v->fbi.ax));
- device->save_item(NAME(v->fbi.ay));
- device->save_item(NAME(v->fbi.bx));
- device->save_item(NAME(v->fbi.by));
- device->save_item(NAME(v->fbi.cx));
- device->save_item(NAME(v->fbi.cy));
- device->save_item(NAME(v->fbi.startr));
- device->save_item(NAME(v->fbi.startg));
- device->save_item(NAME(v->fbi.startb));
- device->save_item(NAME(v->fbi.starta));
- device->save_item(NAME(v->fbi.startz));
- device->save_item(NAME(v->fbi.startw));
- device->save_item(NAME(v->fbi.drdx));
- device->save_item(NAME(v->fbi.dgdx));
- device->save_item(NAME(v->fbi.dbdx));
- device->save_item(NAME(v->fbi.dadx));
- device->save_item(NAME(v->fbi.dzdx));
- device->save_item(NAME(v->fbi.dwdx));
- device->save_item(NAME(v->fbi.drdy));
- device->save_item(NAME(v->fbi.dgdy));
- device->save_item(NAME(v->fbi.dbdy));
- device->save_item(NAME(v->fbi.dady));
- device->save_item(NAME(v->fbi.dzdy));
- device->save_item(NAME(v->fbi.dwdy));
- device->save_item(NAME(v->fbi.lfb_stats.pixels_in));
- device->save_item(NAME(v->fbi.lfb_stats.pixels_out));
- device->save_item(NAME(v->fbi.lfb_stats.chroma_fail));
- device->save_item(NAME(v->fbi.lfb_stats.zfunc_fail));
- device->save_item(NAME(v->fbi.lfb_stats.afunc_fail));
- device->save_item(NAME(v->fbi.lfb_stats.clip_fail));
- device->save_item(NAME(v->fbi.lfb_stats.stipple_count));
- device->save_item(NAME(v->fbi.sverts));
- for (index = 0; index < ARRAY_LENGTH(v->fbi.svert); index++)
+ vd->save_pointer(NAME(vd->fbi.ram), vd->fbi.mask + 1);
+ vd->save_item(NAME(vd->fbi.rgboffs));
+ vd->save_item(NAME(vd->fbi.auxoffs));
+ vd->save_item(NAME(vd->fbi.frontbuf));
+ vd->save_item(NAME(vd->fbi.backbuf));
+ vd->save_item(NAME(vd->fbi.swaps_pending));
+ vd->save_item(NAME(vd->fbi.video_changed));
+ vd->save_item(NAME(vd->fbi.yorigin));
+ vd->save_item(NAME(vd->fbi.lfb_base));
+ vd->save_item(NAME(vd->fbi.lfb_stride));
+ vd->save_item(NAME(vd->fbi.width));
+ vd->save_item(NAME(vd->fbi.height));
+ vd->save_item(NAME(vd->fbi.xoffs));
+ vd->save_item(NAME(vd->fbi.yoffs));
+ vd->save_item(NAME(vd->fbi.vsyncscan));
+ vd->save_item(NAME(vd->fbi.rowpixels));
+ vd->save_item(NAME(vd->fbi.vblank));
+ vd->save_item(NAME(vd->fbi.vblank_count));
+ vd->save_item(NAME(vd->fbi.vblank_swap_pending));
+ vd->save_item(NAME(vd->fbi.vblank_swap));
+ vd->save_item(NAME(vd->fbi.vblank_dont_swap));
+ vd->save_item(NAME(vd->fbi.cheating_allowed));
+ vd->save_item(NAME(vd->fbi.sign));
+ vd->save_item(NAME(vd->fbi.ax));
+ vd->save_item(NAME(vd->fbi.ay));
+ vd->save_item(NAME(vd->fbi.bx));
+ vd->save_item(NAME(vd->fbi.by));
+ vd->save_item(NAME(vd->fbi.cx));
+ vd->save_item(NAME(vd->fbi.cy));
+ vd->save_item(NAME(vd->fbi.startr));
+ vd->save_item(NAME(vd->fbi.startg));
+ vd->save_item(NAME(vd->fbi.startb));
+ vd->save_item(NAME(vd->fbi.starta));
+ vd->save_item(NAME(vd->fbi.startz));
+ vd->save_item(NAME(vd->fbi.startw));
+ vd->save_item(NAME(vd->fbi.drdx));
+ vd->save_item(NAME(vd->fbi.dgdx));
+ vd->save_item(NAME(vd->fbi.dbdx));
+ vd->save_item(NAME(vd->fbi.dadx));
+ vd->save_item(NAME(vd->fbi.dzdx));
+ vd->save_item(NAME(vd->fbi.dwdx));
+ vd->save_item(NAME(vd->fbi.drdy));
+ vd->save_item(NAME(vd->fbi.dgdy));
+ vd->save_item(NAME(vd->fbi.dbdy));
+ vd->save_item(NAME(vd->fbi.dady));
+ vd->save_item(NAME(vd->fbi.dzdy));
+ vd->save_item(NAME(vd->fbi.dwdy));
+ vd->save_item(NAME(vd->fbi.lfb_stats.pixels_in));
+ vd->save_item(NAME(vd->fbi.lfb_stats.pixels_out));
+ vd->save_item(NAME(vd->fbi.lfb_stats.chroma_fail));
+ vd->save_item(NAME(vd->fbi.lfb_stats.zfunc_fail));
+ vd->save_item(NAME(vd->fbi.lfb_stats.afunc_fail));
+ vd->save_item(NAME(vd->fbi.lfb_stats.clip_fail));
+ vd->save_item(NAME(vd->fbi.lfb_stats.stipple_count));
+ vd->save_item(NAME(vd->fbi.sverts));
+ for (index = 0; index < ARRAY_LENGTH(vd->fbi.svert); index++)
{
- device->save_item(NAME(v->fbi.svert[index].x), index);
- device->save_item(NAME(v->fbi.svert[index].y), index);
- device->save_item(NAME(v->fbi.svert[index].a), index);
- device->save_item(NAME(v->fbi.svert[index].r), index);
- device->save_item(NAME(v->fbi.svert[index].g), index);
- device->save_item(NAME(v->fbi.svert[index].b), index);
- device->save_item(NAME(v->fbi.svert[index].z), index);
- device->save_item(NAME(v->fbi.svert[index].wb), index);
- device->save_item(NAME(v->fbi.svert[index].w0), index);
- device->save_item(NAME(v->fbi.svert[index].s0), index);
- device->save_item(NAME(v->fbi.svert[index].t0), index);
- device->save_item(NAME(v->fbi.svert[index].w1), index);
- device->save_item(NAME(v->fbi.svert[index].s1), index);
- device->save_item(NAME(v->fbi.svert[index].t1), index);
+ vd->save_item(NAME(vd->fbi.svert[index].x), index);
+ vd->save_item(NAME(vd->fbi.svert[index].y), index);
+ vd->save_item(NAME(vd->fbi.svert[index].a), index);
+ vd->save_item(NAME(vd->fbi.svert[index].r), index);
+ vd->save_item(NAME(vd->fbi.svert[index].g), index);
+ vd->save_item(NAME(vd->fbi.svert[index].b), index);
+ vd->save_item(NAME(vd->fbi.svert[index].z), index);
+ vd->save_item(NAME(vd->fbi.svert[index].wb), index);
+ vd->save_item(NAME(vd->fbi.svert[index].w0), index);
+ vd->save_item(NAME(vd->fbi.svert[index].s0), index);
+ vd->save_item(NAME(vd->fbi.svert[index].t0), index);
+ vd->save_item(NAME(vd->fbi.svert[index].w1), index);
+ vd->save_item(NAME(vd->fbi.svert[index].s1), index);
+ vd->save_item(NAME(vd->fbi.svert[index].t1), index);
}
- device->save_item(NAME(v->fbi.fifo.size));
- device->save_item(NAME(v->fbi.fifo.in));
- device->save_item(NAME(v->fbi.fifo.out));
- for (index = 0; index < ARRAY_LENGTH(v->fbi.cmdfifo); index++)
+ vd->save_item(NAME(vd->fbi.fifo.size));
+ vd->save_item(NAME(vd->fbi.fifo.in));
+ vd->save_item(NAME(vd->fbi.fifo.out));
+ for (index = 0; index < ARRAY_LENGTH(vd->fbi.cmdfifo); index++)
{
- device->save_item(NAME(v->fbi.cmdfifo[index].enable), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].count_holes), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].base), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].end), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].rdptr), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].amin), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].amax), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].depth), index);
- device->save_item(NAME(v->fbi.cmdfifo[index].holes), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].enable), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].count_holes), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].base), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].end), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].rdptr), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].amin), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].amax), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].depth), index);
+ vd->save_item(NAME(vd->fbi.cmdfifo[index].holes), index);
}
- device->save_item(NAME(v->fbi.fogblend));
- device->save_item(NAME(v->fbi.fogdelta));
- device->save_item(NAME(v->fbi.clut));
+ vd->save_item(NAME(vd->fbi.fogblend));
+ vd->save_item(NAME(vd->fbi.fogdelta));
+ vd->save_item(NAME(vd->fbi.clut));
/* register states: tmu */
- for (index = 0; index < ARRAY_LENGTH(v->tmu); index++)
+ for (index = 0; index < ARRAY_LENGTH(vd->tmu); index++)
{
- tmu_state *tmu = &v->tmu[index];
+ tmu_state *tmu = &vd->tmu[index];
if (tmu->ram == nullptr)
continue;
- if (tmu->ram != v->fbi.ram)
- device->save_pointer(NAME(tmu->ram), tmu->mask + 1, index);
- device->save_item(NAME(tmu->starts), index);
- device->save_item(NAME(tmu->startt), index);
- device->save_item(NAME(tmu->startw), index);
- device->save_item(NAME(tmu->dsdx), index);
- device->save_item(NAME(tmu->dtdx), index);
- device->save_item(NAME(tmu->dwdx), index);
- device->save_item(NAME(tmu->dsdy), index);
- device->save_item(NAME(tmu->dtdy), index);
- device->save_item(NAME(tmu->dwdy), index);
+ if (tmu->ram != vd->fbi.ram)
+ vd->save_pointer(NAME(tmu->ram), tmu->mask + 1, index);
+ vd->save_item(NAME(tmu->starts), index);
+ vd->save_item(NAME(tmu->startt), index);
+ vd->save_item(NAME(tmu->startw), index);
+ vd->save_item(NAME(tmu->dsdx), index);
+ vd->save_item(NAME(tmu->dtdx), index);
+ vd->save_item(NAME(tmu->dwdx), index);
+ vd->save_item(NAME(tmu->dsdy), index);
+ vd->save_item(NAME(tmu->dtdy), index);
+ vd->save_item(NAME(tmu->dwdy), index);
for (subindex = 0; subindex < ARRAY_LENGTH(tmu->ncc); subindex++)
{
- device->save_item(NAME(tmu->ncc[subindex].ir), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].ig), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].ib), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].qr), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].qg), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].qb), index * ARRAY_LENGTH(tmu->ncc) + subindex);
- device->save_item(NAME(tmu->ncc[subindex].y), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].ir), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].ig), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].ib), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].qr), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].qg), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].qb), index * ARRAY_LENGTH(tmu->ncc) + subindex);
+ vd->save_item(NAME(tmu->ncc[subindex].y), index * ARRAY_LENGTH(tmu->ncc) + subindex);
}
}
/* register states: banshee */
- if (v->type >= TYPE_VOODOO_BANSHEE)
+ if (vd->vd_type >= TYPE_VOODOO_BANSHEE)
{
- device->save_item(NAME(v->banshee.io));
- device->save_item(NAME(v->banshee.agp));
- device->save_item(NAME(v->banshee.vga));
- device->save_item(NAME(v->banshee.crtc));
- device->save_item(NAME(v->banshee.seq));
- device->save_item(NAME(v->banshee.gc));
- device->save_item(NAME(v->banshee.att));
- device->save_item(NAME(v->banshee.attff));
+ vd->save_item(NAME(vd->banshee.io));
+ vd->save_item(NAME(vd->banshee.agp));
+ vd->save_item(NAME(vd->banshee.vga));
+ vd->save_item(NAME(vd->banshee.crtc));
+ vd->save_item(NAME(vd->banshee.seq));
+ vd->save_item(NAME(vd->banshee.gc));
+ vd->save_item(NAME(vd->banshee.att));
+ vd->save_item(NAME(vd->banshee.attff));
}
}
@@ -792,27 +732,27 @@ static void init_save_state(device_t *device)
*
*************************************/
-static void accumulate_statistics(voodoo_state *v, const stats_block *stats)
+static void accumulate_statistics(voodoo_device *vd, const stats_block *stats)
{
/* apply internal voodoo statistics */
- v->reg[fbiPixelsIn].u += stats->pixels_in;
- v->reg[fbiPixelsOut].u += stats->pixels_out;
- v->reg[fbiChromaFail].u += stats->chroma_fail;
- v->reg[fbiZfuncFail].u += stats->zfunc_fail;
- v->reg[fbiAfuncFail].u += stats->afunc_fail;
+ vd->reg[fbiPixelsIn].u += stats->pixels_in;
+ vd->reg[fbiPixelsOut].u += stats->pixels_out;
+ vd->reg[fbiChromaFail].u += stats->chroma_fail;
+ vd->reg[fbiZfuncFail].u += stats->zfunc_fail;
+ vd->reg[fbiAfuncFail].u += stats->afunc_fail;
/* apply emulation statistics */
- v->stats.total_pixels_in += stats->pixels_in;
- v->stats.total_pixels_out += stats->pixels_out;
- v->stats.total_chroma_fail += stats->chroma_fail;
- v->stats.total_zfunc_fail += stats->zfunc_fail;
- v->stats.total_afunc_fail += stats->afunc_fail;
- v->stats.total_clipped += stats->clip_fail;
- v->stats.total_stippled += stats->stipple_count;
+ vd->stats.total_pixels_in += stats->pixels_in;
+ vd->stats.total_pixels_out += stats->pixels_out;
+ vd->stats.total_chroma_fail += stats->chroma_fail;
+ vd->stats.total_zfunc_fail += stats->zfunc_fail;
+ vd->stats.total_afunc_fail += stats->afunc_fail;
+ vd->stats.total_clipped += stats->clip_fail;
+ vd->stats.total_stippled += stats->stipple_count;
}
-static void update_statistics(voodoo_state *v, int accumulate)
+static void update_statistics(voodoo_device *vd, int accumulate)
{
int threadnum;
@@ -820,14 +760,14 @@ static void update_statistics(voodoo_state *v, int accumulate)
for (threadnum = 0; threadnum < WORK_MAX_THREADS; threadnum++)
{
if (accumulate)
- accumulate_statistics(v, &v->thread_stats[threadnum]);
- memset(&v->thread_stats[threadnum], 0, sizeof(v->thread_stats[threadnum]));
+ accumulate_statistics(vd, &vd->thread_stats[threadnum]);
+ memset(&vd->thread_stats[threadnum], 0, sizeof(vd->thread_stats[threadnum]));
}
/* accumulate/reset statistics from the LFB */
if (accumulate)
- accumulate_statistics(v, &v->fbi.lfb_stats);
- memset(&v->fbi.lfb_stats, 0, sizeof(v->fbi.lfb_stats));
+ accumulate_statistics(vd, &vd->fbi.lfb_stats);
+ memset(&vd->fbi.lfb_stats, 0, sizeof(vd->fbi.lfb_stats));
}
@@ -838,210 +778,208 @@ static void update_statistics(voodoo_state *v, int accumulate)
*
*************************************/
-static void swap_buffers(voodoo_state *v)
+void voodoo_device::swap_buffers(voodoo_device *vd)
{
int count;
- if (LOG_VBLANK_SWAP) v->device->logerror("--- swap_buffers @ %d\n", v->screen->vpos());
+ if (LOG_VBLANK_SWAP) vd->device->logerror("--- swap_buffers @ %d\n", vd->screen->vpos());
/* force a partial update */
- v->screen->update_partial(v->screen->vpos());
- v->fbi.video_changed = TRUE;
+ vd->screen->update_partial(vd->screen->vpos());
+ vd->fbi.video_changed = TRUE;
/* keep a history of swap intervals */
- count = v->fbi.vblank_count;
+ count = vd->fbi.vblank_count;
if (count > 15)
count = 15;
- v->reg[fbiSwapHistory].u = (v->reg[fbiSwapHistory].u << 4) | count;
+ vd->reg[fbiSwapHistory].u = (vd->reg[fbiSwapHistory].u << 4) | count;
/* rotate the buffers */
- if (v->type <= TYPE_VOODOO_2)
+ if (vd->vd_type <= TYPE_VOODOO_2)
{
- if (v->type < TYPE_VOODOO_2 || !v->fbi.vblank_dont_swap)
+ if (vd->vd_type < TYPE_VOODOO_2 || !vd->fbi.vblank_dont_swap)
{
- if (v->fbi.rgboffs[2] == ~0)
+ if (vd->fbi.rgboffs[2] == ~0)
{
- v->fbi.frontbuf = 1 - v->fbi.frontbuf;
- v->fbi.backbuf = 1 - v->fbi.frontbuf;
+ vd->fbi.frontbuf = 1 - vd->fbi.frontbuf;
+ vd->fbi.backbuf = 1 - vd->fbi.frontbuf;
}
else
{
- v->fbi.frontbuf = (v->fbi.frontbuf + 1) % 3;
- v->fbi.backbuf = (v->fbi.frontbuf + 1) % 3;
+ vd->fbi.frontbuf = (vd->fbi.frontbuf + 1) % 3;
+ vd->fbi.backbuf = (vd->fbi.frontbuf + 1) % 3;
}
}
}
else
- v->fbi.rgboffs[0] = v->reg[leftOverlayBuf].u & v->fbi.mask & ~0x0f;
+ vd->fbi.rgboffs[0] = vd->reg[leftOverlayBuf].u & vd->fbi.mask & ~0x0f;
/* decrement the pending count and reset our state */
- if (v->fbi.swaps_pending)
- v->fbi.swaps_pending--;
- v->fbi.vblank_count = 0;
- v->fbi.vblank_swap_pending = FALSE;
+ if (vd->fbi.swaps_pending)
+ vd->fbi.swaps_pending--;
+ vd->fbi.vblank_count = 0;
+ vd->fbi.vblank_swap_pending = FALSE;
/* reset the last_op_time to now and start processing the next command */
- if (v->pci.op_pending)
+ if (vd->pci.op_pending)
{
- v->pci.op_end_time = v->device->machine().time();
- flush_fifos(v, v->pci.op_end_time);
+ vd->pci.op_end_time = vd->device->machine().time();
+ flush_fifos(vd, vd->pci.op_end_time);
}
/* we may be able to unstall now */
- if (v->pci.stall_state != NOT_STALLED)
- check_stalled_cpu(v, v->device->machine().time());
+ if (vd->pci.stall_state != NOT_STALLED)
+ check_stalled_cpu(vd, vd->device->machine().time());
/* periodically log rasterizer info */
- v->stats.swaps++;
- if (LOG_RASTERIZERS && v->stats.swaps % 1000 == 0)
- dump_rasterizer_stats(v);
+ vd->stats.swaps++;
+ if (LOG_RASTERIZERS && vd->stats.swaps % 1000 == 0)
+ dump_rasterizer_stats(vd);
/* update the statistics (debug) */
- if (v->stats.display)
+ if (vd->stats.display)
{
- const rectangle &visible_area = v->screen->visible_area();
+ const rectangle &visible_area = vd->screen->visible_area();
int screen_area = visible_area.width() * visible_area.height();
- char *statsptr = v->stats.buffer;
+ char *statsptr = vd->stats.buffer;
int pixelcount;
int i;
- update_statistics(v, TRUE);
- pixelcount = v->stats.total_pixels_out;
+ update_statistics(vd, TRUE);
+ pixelcount = vd->stats.total_pixels_out;
- statsptr += sprintf(statsptr, "Swap:%6d\n", v->stats.swaps);
- statsptr += sprintf(statsptr, "Hist:%08X\n", v->reg[fbiSwapHistory].u);
- statsptr += sprintf(statsptr, "Stal:%6d\n", v->stats.stalls);
+ statsptr += sprintf(statsptr, "Swap:%6d\n", vd->stats.swaps);
+ statsptr += sprintf(statsptr, "Hist:%08X\n", vd->reg[fbiSwapHistory].u);
+ statsptr += sprintf(statsptr, "Stal:%6d\n", vd->stats.stalls);
statsptr += sprintf(statsptr, "Rend:%6d%%\n", pixelcount * 100 / screen_area);
- statsptr += sprintf(statsptr, "Poly:%6d\n", v->stats.total_triangles);
- statsptr += sprintf(statsptr, "PxIn:%6d\n", v->stats.total_pixels_in);
- statsptr += sprintf(statsptr, "POut:%6d\n", v->stats.total_pixels_out);
- statsptr += sprintf(statsptr, "Clip:%6d\n", v->stats.total_clipped);
- statsptr += sprintf(statsptr, "Stip:%6d\n", v->stats.total_stippled);
- statsptr += sprintf(statsptr, "Chro:%6d\n", v->stats.total_chroma_fail);
- statsptr += sprintf(statsptr, "ZFun:%6d\n", v->stats.total_zfunc_fail);
- statsptr += sprintf(statsptr, "AFun:%6d\n", v->stats.total_afunc_fail);
- statsptr += sprintf(statsptr, "RegW:%6d\n", v->stats.reg_writes);
- statsptr += sprintf(statsptr, "RegR:%6d\n", v->stats.reg_reads);
- statsptr += sprintf(statsptr, "LFBW:%6d\n", v->stats.lfb_writes);
- statsptr += sprintf(statsptr, "LFBR:%6d\n", v->stats.lfb_reads);
- statsptr += sprintf(statsptr, "TexW:%6d\n", v->stats.tex_writes);
+ statsptr += sprintf(statsptr, "Poly:%6d\n", vd->stats.total_triangles);
+ statsptr += sprintf(statsptr, "PxIn:%6d\n", vd->stats.total_pixels_in);
+ statsptr += sprintf(statsptr, "POut:%6d\n", vd->stats.total_pixels_out);
+ statsptr += sprintf(statsptr, "Clip:%6d\n", vd->stats.total_clipped);
+ statsptr += sprintf(statsptr, "Stip:%6d\n", vd->stats.total_stippled);
+ statsptr += sprintf(statsptr, "Chro:%6d\n", vd->stats.total_chroma_fail);
+ statsptr += sprintf(statsptr, "ZFun:%6d\n", vd->stats.total_zfunc_fail);
+ statsptr += sprintf(statsptr, "AFun:%6d\n", vd->stats.total_afunc_fail);
+ statsptr += sprintf(statsptr, "RegW:%6d\n", vd->stats.reg_writes);
+ statsptr += sprintf(statsptr, "RegR:%6d\n", vd->stats.reg_reads);
+ statsptr += sprintf(statsptr, "LFBW:%6d\n", vd->stats.lfb_writes);
+ statsptr += sprintf(statsptr, "LFBR:%6d\n", vd->stats.lfb_reads);
+ statsptr += sprintf(statsptr, "TexW:%6d\n", vd->stats.tex_writes);
statsptr += sprintf(statsptr, "TexM:");
for (i = 0; i < 16; i++)
- if (v->stats.texture_mode[i])
+ if (vd->stats.texture_mode[i])
*statsptr++ = "0123456789ABCDEF"[i];
*statsptr = 0;
}
/* update statistics */
- v->stats.stalls = 0;
- v->stats.total_triangles = 0;
- v->stats.total_pixels_in = 0;
- v->stats.total_pixels_out = 0;
- v->stats.total_chroma_fail = 0;
- v->stats.total_zfunc_fail = 0;
- v->stats.total_afunc_fail = 0;
- v->stats.total_clipped = 0;
- v->stats.total_stippled = 0;
- v->stats.reg_writes = 0;
- v->stats.reg_reads = 0;
- v->stats.lfb_writes = 0;
- v->stats.lfb_reads = 0;
- v->stats.tex_writes = 0;
- memset(v->stats.texture_mode, 0, sizeof(v->stats.texture_mode));
+ vd->stats.stalls = 0;
+ vd->stats.total_triangles = 0;
+ vd->stats.total_pixels_in = 0;
+ vd->stats.total_pixels_out = 0;
+ vd->stats.total_chroma_fail = 0;
+ vd->stats.total_zfunc_fail = 0;
+ vd->stats.total_afunc_fail = 0;
+ vd->stats.total_clipped = 0;
+ vd->stats.total_stippled = 0;
+ vd->stats.reg_writes = 0;
+ vd->stats.reg_reads = 0;
+ vd->stats.lfb_writes = 0;
+ vd->stats.lfb_reads = 0;
+ vd->stats.tex_writes = 0;
+ memset(vd->stats.texture_mode, 0, sizeof(vd->stats.texture_mode));
}
-static void adjust_vblank_timer(voodoo_state *v)
+static void adjust_vblank_timer(voodoo_device *vd)
{
- attotime vblank_period = v->screen->time_until_pos(v->fbi.vsyncscan);
+ attotime vblank_period = vd->screen->time_until_pos(vd->fbi.vsyncscan);
/* if zero, adjust to next frame, otherwise we may get stuck in an infinite loop */
if (vblank_period == attotime::zero)
- vblank_period = v->screen->frame_period();
- v->fbi.vblank_timer->adjust(vblank_period);
+ vblank_period = vd->screen->frame_period();
+ vd->fbi.vblank_timer->adjust(vblank_period);
}
-static TIMER_CALLBACK( vblank_off_callback )
+TIMER_CALLBACK_MEMBER( voodoo_device::vblank_off_callback )
{
- voodoo_state *v = (voodoo_state *)ptr;
-
- if (LOG_VBLANK_SWAP) v->device->logerror("--- vblank end\n");
+ if (LOG_VBLANK_SWAP) device->logerror("--- vblank end\n");
/* set internal state and call the client */
- v->fbi.vblank = FALSE;
+ fbi.vblank = FALSE;
// TODO: Vblank IRQ enable is VOODOO3 only?
- if (v->type >= TYPE_VOODOO_3)
+ if (vd_type >= TYPE_VOODOO_3)
{
- if (v->reg[intrCtrl].u & 0x8) // call IRQ handler if VSYNC interrupt (falling) is enabled
+ if (reg[intrCtrl].u & 0x8) // call IRQ handler if VSYNC interrupt (falling) is enabled
{
- v->reg[intrCtrl].u |= 0x200; // VSYNC int (falling) active
+ reg[intrCtrl].u |= 0x200; // VSYNC int (falling) active
- if (!v->device->m_vblank.isnull())
- v->device->m_vblank(FALSE);
+ if (!device->m_vblank.isnull())
+ device->m_vblank(FALSE);
}
}
else
{
- if (!v->device->m_vblank.isnull())
- v->device->m_vblank(FALSE);
+ if (!device->m_vblank.isnull())
+ device->m_vblank(FALSE);
}
/* go to the end of the next frame */
- adjust_vblank_timer(v);
+ adjust_vblank_timer(this);
}
-static TIMER_CALLBACK( vblank_callback )
+TIMER_CALLBACK_MEMBER( voodoo_device::vblank_callback )
{
- voodoo_state *v = (voodoo_state *)ptr;
-
- if (LOG_VBLANK_SWAP) v->device->logerror("--- vblank start\n");
+ if (LOG_VBLANK_SWAP) device->logerror("--- vblank start\n");
/* flush the pipes */
- if (v->pci.op_pending)
+ if (pci.op_pending)
{
- if (LOG_VBLANK_SWAP) v->device->logerror("---- vblank flush begin\n");
- flush_fifos(v, machine.time());
- if (LOG_VBLANK_SWAP) v->device->logerror("---- vblank flush end\n");
+ if (LOG_VBLANK_SWAP) device->logerror("---- vblank flush begin\n");
+ flush_fifos(this, machine().time());
+ if (LOG_VBLANK_SWAP) device->logerror("---- vblank flush end\n");
}
/* increment the count */
- v->fbi.vblank_count++;
- if (v->fbi.vblank_count > 250)
- v->fbi.vblank_count = 250;
- if (LOG_VBLANK_SWAP) v->device->logerror("---- vblank count = %d", v->fbi.vblank_count);
- if (v->fbi.vblank_swap_pending)
- if (LOG_VBLANK_SWAP) v->device->logerror(" (target=%d)", v->fbi.vblank_swap);
- if (LOG_VBLANK_SWAP) v->device->logerror("\n");
+ fbi.vblank_count++;
+ if (fbi.vblank_count > 250)
+ fbi.vblank_count = 250;
+ if (LOG_VBLANK_SWAP) device->logerror("---- vblank count = %d", fbi.vblank_count);
+ if (fbi.vblank_swap_pending)
+ if (LOG_VBLANK_SWAP) device->logerror(" (target=%d)", fbi.vblank_swap);
+ if (LOG_VBLANK_SWAP) device->logerror("\n");
/* if we're past the swap count, do the swap */
- if (v->fbi.vblank_swap_pending && v->fbi.vblank_count >= v->fbi.vblank_swap)
- swap_buffers(v);
+ if (fbi.vblank_swap_pending && fbi.vblank_count >= fbi.vblank_swap)
+ swap_buffers(this);
/* set a timer for the next off state */
- machine.scheduler().timer_set(v->screen->time_until_pos(0), FUNC(vblank_off_callback), 0, v);
+ machine().scheduler().timer_set(screen->time_until_pos(0), timer_expired_delegate(FUNC(voodoo_device::vblank_off_callback),this), 0, this);
+
+
/* set internal state and call the client */
- v->fbi.vblank = TRUE;
+ fbi.vblank = TRUE;
// TODO: Vblank IRQ enable is VOODOO3 only?
- if (v->type >= TYPE_VOODOO_3)
+ if (vd_type >= TYPE_VOODOO_3)
{
- if (v->reg[intrCtrl].u & 0x4) // call IRQ handler if VSYNC interrupt (rising) is enabled
+ if (reg[intrCtrl].u & 0x4) // call IRQ handler if VSYNC interrupt (rising) is enabled
{
- v->reg[intrCtrl].u |= 0x100; // VSYNC int (rising) active
+ reg[intrCtrl].u |= 0x100; // VSYNC int (rising) active
- if (!v->device->m_vblank.isnull())
- v->device->m_vblank(TRUE);
+ if (!device->m_vblank.isnull())
+ device->m_vblank(TRUE);
}
}
else
{
- if (!v->device->m_vblank.isnull())
- v->device->m_vblank(TRUE);
+ if (!device->m_vblank.isnull())
+ device->m_vblank(TRUE);
}
}
@@ -1053,23 +991,23 @@ static TIMER_CALLBACK( vblank_callback )
*
*************************************/
-static void reset_counters(voodoo_state *v)
+static void reset_counters(voodoo_device *vd)
{
- update_statistics(v, FALSE);
- v->reg[fbiPixelsIn].u = 0;
- v->reg[fbiChromaFail].u = 0;
- v->reg[fbiZfuncFail].u = 0;
- v->reg[fbiAfuncFail].u = 0;
- v->reg[fbiPixelsOut].u = 0;
+ update_statistics(vd, FALSE);
+ vd->reg[fbiPixelsIn].u = 0;
+ vd->reg[fbiChromaFail].u = 0;
+ vd->reg[fbiZfuncFail].u = 0;
+ vd->reg[fbiAfuncFail].u = 0;
+ vd->reg[fbiPixelsOut].u = 0;
}
-static void soft_reset(voodoo_state *v)
+void voodoo_device::soft_reset(voodoo_device *vd)
{
- reset_counters(v);
- v->reg[fbiTrianglesOut].u = 0;
- fifo_reset(&v->fbi.fifo);
- fifo_reset(&v->pci.fifo);
+ reset_counters(vd);
+ vd->reg[fbiTrianglesOut].u = 0;
+ fifo_reset(&vd->fbi.fifo);
+ fifo_reset(&vd->pci.fifo);
}
@@ -1080,103 +1018,103 @@ static void soft_reset(voodoo_state *v)
*
*************************************/
-static void recompute_video_memory(voodoo_state *v)
+void voodoo_device::recompute_video_memory(voodoo_device *vd)
{
- UINT32 buffer_pages = FBIINIT2_VIDEO_BUFFER_OFFSET(v->reg[fbiInit2].u);
- UINT32 fifo_start_page = FBIINIT4_MEMORY_FIFO_START_ROW(v->reg[fbiInit4].u);
- UINT32 fifo_last_page = FBIINIT4_MEMORY_FIFO_STOP_ROW(v->reg[fbiInit4].u);
+ UINT32 buffer_pages = FBIINIT2_VIDEO_BUFFER_OFFSET(vd->reg[fbiInit2].u);
+ UINT32 fifo_start_page = FBIINIT4_MEMORY_FIFO_START_ROW(vd->reg[fbiInit4].u);
+ UINT32 fifo_last_page = FBIINIT4_MEMORY_FIFO_STOP_ROW(vd->reg[fbiInit4].u);
UINT32 memory_config;
int buf;
/* memory config is determined differently between V1 and V2 */
- memory_config = FBIINIT2_ENABLE_TRIPLE_BUF(v->reg[fbiInit2].u);
- if (v->type == TYPE_VOODOO_2 && memory_config == 0)
- memory_config = FBIINIT5_BUFFER_ALLOCATION(v->reg[fbiInit5].u);
+ memory_config = FBIINIT2_ENABLE_TRIPLE_BUF(vd->reg[fbiInit2].u);
+ if (vd->vd_type == TYPE_VOODOO_2 && memory_config == 0)
+ memory_config = FBIINIT5_BUFFER_ALLOCATION(vd->reg[fbiInit5].u);
/* tiles are 64x16/32; x_tiles specifies how many half-tiles */
- v->fbi.tile_width = (v->type == TYPE_VOODOO_1) ? 64 : 32;
- v->fbi.tile_height = (v->type == TYPE_VOODOO_1) ? 16 : 32;
- v->fbi.x_tiles = FBIINIT1_X_VIDEO_TILES(v->reg[fbiInit1].u);
- if (v->type == TYPE_VOODOO_2)
+ vd->fbi.tile_width = (vd->vd_type == TYPE_VOODOO_1) ? 64 : 32;
+ vd->fbi.tile_height = (vd->vd_type == TYPE_VOODOO_1) ? 16 : 32;
+ vd->fbi.x_tiles = FBIINIT1_X_VIDEO_TILES(vd->reg[fbiInit1].u);
+ if (vd->vd_type == TYPE_VOODOO_2)
{
- v->fbi.x_tiles = (v->fbi.x_tiles << 1) |
- (FBIINIT1_X_VIDEO_TILES_BIT5(v->reg[fbiInit1].u) << 5) |
- (FBIINIT6_X_VIDEO_TILES_BIT0(v->reg[fbiInit6].u));
+ vd->fbi.x_tiles = (vd->fbi.x_tiles << 1) |
+ (FBIINIT1_X_VIDEO_TILES_BIT5(vd->reg[fbiInit1].u) << 5) |
+ (FBIINIT6_X_VIDEO_TILES_BIT0(vd->reg[fbiInit6].u));
}
- v->fbi.rowpixels = v->fbi.tile_width * v->fbi.x_tiles;
+ vd->fbi.rowpixels = vd->fbi.tile_width * vd->fbi.x_tiles;
-// logerror("VOODOO.%d.VIDMEM: buffer_pages=%X fifo=%X-%X tiles=%X rowpix=%d\n", v->index, buffer_pages, fifo_start_page, fifo_last_page, v->fbi.x_tiles, v->fbi.rowpixels);
+// logerror("VOODOO.%d.VIDMEM: buffer_pages=%X fifo=%X-%X tiles=%X rowpix=%d\n", vd->index, buffer_pages, fifo_start_page, fifo_last_page, vd->fbi.x_tiles, vd->fbi.rowpixels);
/* first RGB buffer always starts at 0 */
- v->fbi.rgboffs[0] = 0;
+ vd->fbi.rgboffs[0] = 0;
/* second RGB buffer starts immediately afterwards */
- v->fbi.rgboffs[1] = buffer_pages * 0x1000;
+ vd->fbi.rgboffs[1] = buffer_pages * 0x1000;
/* remaining buffers are based on the config */
switch (memory_config)
{
case 3: /* reserved */
- v->device->logerror("VOODOO.%d.ERROR:Unexpected memory configuration in recompute_video_memory!\n", v->index);
+ vd->device->logerror("VOODOO.%d.ERROR:Unexpected memory configuration in recompute_video_memory!\n", vd->index);
case 0: /* 2 color buffers, 1 aux buffer */
- v->fbi.rgboffs[2] = ~0;
- v->fbi.auxoffs = 2 * buffer_pages * 0x1000;
+ vd->fbi.rgboffs[2] = ~0;
+ vd->fbi.auxoffs = 2 * buffer_pages * 0x1000;
break;
case 1: /* 3 color buffers, 0 aux buffers */
- v->fbi.rgboffs[2] = 2 * buffer_pages * 0x1000;
- v->fbi.auxoffs = ~0;
+ vd->fbi.rgboffs[2] = 2 * buffer_pages * 0x1000;
+ vd->fbi.auxoffs = ~0;
break;
case 2: /* 3 color buffers, 1 aux buffers */
- v->fbi.rgboffs[2] = 2 * buffer_pages * 0x1000;
- v->fbi.auxoffs = 3 * buffer_pages * 0x1000;
+ vd->fbi.rgboffs[2] = 2 * buffer_pages * 0x1000;
+ vd->fbi.auxoffs = 3 * buffer_pages * 0x1000;
break;
}
/* clamp the RGB buffers to video memory */
for (buf = 0; buf < 3; buf++)
- if (v->fbi.rgboffs[buf] != ~0 && v->fbi.rgboffs[buf] > v->fbi.mask)
- v->fbi.rgboffs[buf] = v->fbi.mask;
+ if (vd->fbi.rgboffs[buf] != ~0 && vd->fbi.rgboffs[buf] > vd->fbi.mask)
+ vd->fbi.rgboffs[buf] = vd->fbi.mask;
/* clamp the aux buffer to video memory */
- if (v->fbi.auxoffs != ~0 && v->fbi.auxoffs > v->fbi.mask)
- v->fbi.auxoffs = v->fbi.mask;
+ if (vd->fbi.auxoffs != ~0 && vd->fbi.auxoffs > vd->fbi.mask)
+ vd->fbi.auxoffs = vd->fbi.mask;
/* osd_printf_debug("rgb[0] = %08X rgb[1] = %08X rgb[2] = %08X aux = %08X\n",
- v->fbi.rgboffs[0], v->fbi.rgboffs[1], v->fbi.rgboffs[2], v->fbi.auxoffs);*/
+ vd->fbi.rgboffs[0], vd->fbi.rgboffs[1], vd->fbi.rgboffs[2], vd->fbi.auxoffs);*/
/* compute the memory FIFO location and size */
- if (fifo_last_page > v->fbi.mask / 0x1000)
- fifo_last_page = v->fbi.mask / 0x1000;
+ if (fifo_last_page > vd->fbi.mask / 0x1000)
+ fifo_last_page = vd->fbi.mask / 0x1000;
/* is it valid and enabled? */
- if (fifo_start_page <= fifo_last_page && FBIINIT0_ENABLE_MEMORY_FIFO(v->reg[fbiInit0].u))
+ if (fifo_start_page <= fifo_last_page && FBIINIT0_ENABLE_MEMORY_FIFO(vd->reg[fbiInit0].u))
{
- v->fbi.fifo.base = (UINT32 *)(v->fbi.ram + fifo_start_page * 0x1000);
- v->fbi.fifo.size = (fifo_last_page + 1 - fifo_start_page) * 0x1000 / 4;
- if (v->fbi.fifo.size > 65536*2)
- v->fbi.fifo.size = 65536*2;
+ vd->fbi.fifo.base = (UINT32 *)(vd->fbi.ram + fifo_start_page * 0x1000);
+ vd->fbi.fifo.size = (fifo_last_page + 1 - fifo_start_page) * 0x1000 / 4;
+ if (vd->fbi.fifo.size > 65536*2)
+ vd->fbi.fifo.size = 65536*2;
}
/* if not, disable the FIFO */
else
{
- v->fbi.fifo.base = nullptr;
- v->fbi.fifo.size = 0;
+ vd->fbi.fifo.base = nullptr;
+ vd->fbi.fifo.size = 0;
}
/* reset the FIFO */
- fifo_reset(&v->fbi.fifo);
+ fifo_reset(&vd->fbi.fifo);
/* reset our front/back buffers if they are out of range */
- if (v->fbi.rgboffs[2] == ~0)
+ if (vd->fbi.rgboffs[2] == ~0)
{
- if (v->fbi.frontbuf == 2)
- v->fbi.frontbuf = 0;
- if (v->fbi.backbuf == 2)
- v->fbi.backbuf = 0;
+ if (vd->fbi.frontbuf == 2)
+ vd->fbi.frontbuf = 0;
+ if (vd->fbi.backbuf == 2)
+ vd->fbi.backbuf = 0;
}
}
@@ -1476,9 +1414,9 @@ static inline INT32 prepare_tmu(tmu_state *t)
*
*************************************/
-static int cmdfifo_compute_expected_depth(voodoo_state *v, cmdfifo_info *f)
+static int cmdfifo_compute_expected_depth(voodoo_device *vd, cmdfifo_info *f)
{
- UINT32 *fifobase = (UINT32 *)v->fbi.ram;
+ UINT32 *fifobase = (UINT32 *)vd->fbi.ram;
UINT32 readptr = f->rdptr;
UINT32 command = fifobase[readptr / 4];
int i, count = 0;
@@ -1616,9 +1554,9 @@ static int cmdfifo_compute_expected_depth(voodoo_state *v, cmdfifo_info *f)
*
*************************************/
-static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
+UINT32 voodoo_device::cmdfifo_execute(voodoo_device *vd, cmdfifo_info *f)
{
- UINT32 *fifobase = (UINT32 *)v->fbi.ram;
+ UINT32 *fifobase = (UINT32 *)vd->fbi.ram;
UINT32 readptr = f->rdptr;
UINT32 *src = &fifobase[readptr / 4];
UINT32 command = *src++;
@@ -1649,26 +1587,26 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
switch ((command >> 3) & 7)
{
case 0: /* NOP */
- if (LOG_CMDFIFO) v->device->logerror(" NOP\n");
+ if (LOG_CMDFIFO) vd->device->logerror(" NOP\n");
break;
case 1: /* JSR */
- if (LOG_CMDFIFO) v->device->logerror(" JSR $%06X\n", target);
+ if (LOG_CMDFIFO) vd->device->logerror(" JSR $%06X\n", target);
osd_printf_debug("JSR in CMDFIFO!\n");
src = &fifobase[target / 4];
break;
case 2: /* RET */
- if (LOG_CMDFIFO) v->device->logerror(" RET $%06X\n", target);
+ if (LOG_CMDFIFO) vd->device->logerror(" RET $%06X\n", target);
fatalerror("RET in CMDFIFO!\n");
case 3: /* JMP LOCAL FRAME BUFFER */
- if (LOG_CMDFIFO) v->device->logerror(" JMP LOCAL FRAMEBUF $%06X\n", target);
+ if (LOG_CMDFIFO) vd->device->logerror(" JMP LOCAL FRAMEBUF $%06X\n", target);
src = &fifobase[target / 4];
break;
case 4: /* JMP AGP */
- if (LOG_CMDFIFO) v->device->logerror(" JMP AGP $%06X\n", target);
+ if (LOG_CMDFIFO) vd->device->logerror(" JMP AGP $%06X\n", target);
fatalerror("JMP AGP in CMDFIFO!\n");
src = &fifobase[target / 4];
break;
@@ -1696,16 +1634,16 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
inc = (command >> 15) & 1;
target = (command >> 3) & 0xfff;
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 1: count=%d inc=%d reg=%04X\n", count, inc, target);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 1: count=%d inc=%d reg=%04X\n", count, inc, target);
- if (v->type >= TYPE_VOODOO_BANSHEE && (target & 0x800))
+ if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (target & 0x800))
{
// Banshee/Voodoo3 2D register writes
/* loop over all registers and write them one at a time */
for (i = 0; i < count; i++, target += inc)
{
- cycles += banshee_2d_w(v, target & 0xff, *src);
+ cycles += banshee_2d_w(vd, target & 0xff, *src);
//logerror(" 2d reg: %03x = %08X\n", target & 0x7ff, *src);
src++;
}
@@ -1714,7 +1652,7 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
{
/* loop over all registers and write them one at a time */
for (i = 0; i < count; i++, target += inc)
- cycles += register_w(v, target, *src++);
+ cycles += register_w(vd, target, *src++);
}
break;
@@ -1727,12 +1665,12 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
1 31:0 = Data word
*/
case 2:
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 2: mask=%X\n", (command >> 3) & 0x1ffffff);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 2: mask=%X\n", (command >> 3) & 0x1ffffff);
/* loop over all registers and write them one at a time */
for (i = 3; i <= 31; i++)
if (command & (1 << i))
- cycles += register_w(v, banshee2D_clip0Min + (i - 3), *src++);
+ cycles += register_w(vd, banshee2D_clip0Min + (i - 3), *src++);
break;
/*
@@ -1764,10 +1702,10 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
count = (command >> 6) & 15;
code = (command >> 3) & 7;
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 3: count=%d code=%d mask=%03X smode=%02X pc=%d\n", count, code, (command >> 10) & 0xfff, (command >> 22) & 0x3f, (command >> 28) & 1);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 3: count=%d code=%d mask=%03X smode=%02X pc=%d\n", count, code, (command >> 10) & 0xfff, (command >> 22) & 0x3f, (command >> 28) & 1);
/* copy relevant bits into the setup mode register */
- v->reg[sSetupMode].u = ((command >> 10) & 0xff) | ((command >> 6) & 0xf0000);
+ vd->reg[sSetupMode].u = ((command >> 10) & 0xff) | ((command >> 6) & 0xf0000);
/* loop over triangles */
for (i = 0; i < count; i++)
@@ -1834,8 +1772,8 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
/* for a series of individual triangles, initialize all the verts */
if ((code == 1 && i == 0) || (code == 0 && i % 3 == 0))
{
- v->fbi.sverts = 1;
- v->fbi.svert[0] = v->fbi.svert[1] = v->fbi.svert[2] = svert;
+ vd->fbi.sverts = 1;
+ vd->fbi.svert[0] = vd->fbi.svert[1] = vd->fbi.svert[2] = svert;
}
/* otherwise, add this to the list */
@@ -1843,15 +1781,15 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
{
/* for strip mode, shuffle vertex 1 down to 0 */
if (!(command & (1 << 22)))
- v->fbi.svert[0] = v->fbi.svert[1];
+ vd->fbi.svert[0] = vd->fbi.svert[1];
/* copy 2 down to 1 and add our new one regardless */
- v->fbi.svert[1] = v->fbi.svert[2];
- v->fbi.svert[2] = svert;
+ vd->fbi.svert[1] = vd->fbi.svert[2];
+ vd->fbi.svert[2] = svert;
/* if we have enough, draw */
- if (++v->fbi.sverts >= 3)
- cycles += setup_and_draw_triangle(v);
+ if (++vd->fbi.sverts >= 3)
+ cycles += setup_and_draw_triangle(vd);
}
}
@@ -1874,9 +1812,9 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
/* extract parameters */
target = (command >> 3) & 0xfff;
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 4: mask=%X reg=%04X pad=%d\n", (command >> 15) & 0x3fff, target, command >> 29);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 4: mask=%X reg=%04X pad=%d\n", (command >> 15) & 0x3fff, target, command >> 29);
- if (v->type >= TYPE_VOODOO_BANSHEE && (target & 0x800))
+ if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (target & 0x800))
{
// Banshee/Voodoo3 2D register writes
@@ -1886,7 +1824,7 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
{
if (command & (1 << i))
{
- cycles += banshee_2d_w(v, target + (i - 15), *src);
+ cycles += banshee_2d_w(vd, target + (i - 15), *src);
//logerror(" 2d reg: %03x = %08X\n", target & 0x7ff, *src);
src++;
}
@@ -1897,7 +1835,7 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
/* loop over all registers and write them one at a time */
for (i = 15; i <= 28; i++)
if (command & (1 << i))
- cycles += register_w(v, target + (i - 15), *src++);
+ cycles += register_w(vd, target + (i - 15), *src++);
}
/* account for the extra dummy words */
@@ -1928,17 +1866,17 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
{
case 0: // Linear FB
{
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 5: FB count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 5: FB count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
UINT32 addr = target * 4;
for (i=0; i < count; i++)
{
UINT32 data = *src++;
- v->fbi.ram[BYTE_XOR_LE(addr + 0)] = (UINT8)(data);
- v->fbi.ram[BYTE_XOR_LE(addr + 1)] = (UINT8)(data >> 8);
- v->fbi.ram[BYTE_XOR_LE(addr + 2)] = (UINT8)(data >> 16);
- v->fbi.ram[BYTE_XOR_LE(addr + 3)] = (UINT8)(data >> 24);
+ vd->fbi.ram[BYTE_XOR_LE(addr + 0)] = (UINT8)(data);
+ vd->fbi.ram[BYTE_XOR_LE(addr + 1)] = (UINT8)(data >> 8);
+ vd->fbi.ram[BYTE_XOR_LE(addr + 2)] = (UINT8)(data >> 16);
+ vd->fbi.ram[BYTE_XOR_LE(addr + 3)] = (UINT8)(data >> 24);
addr += 4;
}
@@ -1946,11 +1884,11 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
}
case 2: // 3D LFB
{
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 5: 3D LFB count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 5: 3D LFB count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
/* loop over words */
for (i = 0; i < count; i++)
- cycles += lfb_w(v, target++, *src++, 0xffffffff);
+ cycles += lfb_w(vd, target++, *src++, 0xffffffff);
break;
}
@@ -1971,11 +1909,11 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
case 3: // Texture Port
{
- if (LOG_CMDFIFO) v->device->logerror(" PACKET TYPE 5: textureRAM count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
+ if (LOG_CMDFIFO) vd->device->logerror(" PACKET TYPE 5: textureRAM count=%d dest=%08X bd2=%X bdN=%X\n", count, target, (command >> 26) & 15, (command >> 22) & 15);
/* loop over words */
for (i = 0; i < count; i++)
- cycles += texture_w(v, target++, *src++);
+ cycles += texture_w(vd, target++, *src++);
break;
}
@@ -2001,7 +1939,7 @@ static UINT32 cmdfifo_execute(voodoo_state *v, cmdfifo_info *f)
*
*************************************/
-static INT32 cmdfifo_execute_if_ready(voodoo_state *v, cmdfifo_info *f)
+INT32 voodoo_device::cmdfifo_execute_if_ready(voodoo_device* vd, cmdfifo_info *f)
{
int needed_depth;
int cycles;
@@ -2011,12 +1949,12 @@ static INT32 cmdfifo_execute_if_ready(voodoo_state *v, cmdfifo_info *f)
return -1;
/* see if we have enough for the current command */
- needed_depth = cmdfifo_compute_expected_depth(v, f);
+ needed_depth = cmdfifo_compute_expected_depth(vd, f);
if (f->depth < needed_depth)
return -1;
/* execute */
- cycles = cmdfifo_execute(v, f);
+ cycles = cmdfifo_execute(vd, f);
f->depth -= needed_depth;
return cycles;
}
@@ -2029,12 +1967,12 @@ static INT32 cmdfifo_execute_if_ready(voodoo_state *v, cmdfifo_info *f)
*
*************************************/
-static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 data)
+void voodoo_device::cmdfifo_w(voodoo_device *vd, cmdfifo_info *f, offs_t offset, UINT32 data)
{
UINT32 addr = f->base + offset * 4;
- UINT32 *fifobase = (UINT32 *)v->fbi.ram;
+ UINT32 *fifobase = (UINT32 *)vd->fbi.ram;
- if (LOG_CMDFIFO_VERBOSE) v->device->logerror("CMDFIFO_w(%04X) = %08X\n", offset, data);
+ if (LOG_CMDFIFO_VERBOSE) vd->device->logerror("CMDFIFO_w(%04X) = %08X\n", offset, data);
/* write the data */
if (addr < f->end)
@@ -2054,7 +1992,7 @@ static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 da
else if (addr < f->amin)
{
if (f->holes != 0)
- v->device->logerror("Unexpected CMDFIFO: AMin=%08X AMax=%08X Holes=%d WroteTo:%08X\n",
+ vd->device->logerror("Unexpected CMDFIFO: AMin=%08X AMax=%08X Holes=%d WroteTo:%08X\n",
f->amin, f->amax, f->holes, addr);
//f->amin = f->amax = addr;
f->holes += (addr - f->base) / 4;
@@ -2084,17 +2022,17 @@ static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 da
}
/* execute if we can */
- if (!v->pci.op_pending)
+ if (!vd->pci.op_pending)
{
- INT32 cycles = cmdfifo_execute_if_ready(v, f);
+ INT32 cycles = cmdfifo_execute_if_ready(vd, f);
if (cycles > 0)
{
- v->pci.op_pending = TRUE;
- v->pci.op_end_time = v->device->machine().time() + attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle);
+ vd->pci.op_pending = TRUE;
+ vd->pci.op_end_time = vd->device->machine().time() + attotime(0, (attoseconds_t)cycles * vd->attoseconds_per_cycle);
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index,
- v->device->machine().time().seconds(), (UINT32)(v->device->machine().time().attoseconds() >> 32), (UINT32)v->device->machine().time().attoseconds(),
- v->pci.op_end_time.seconds(), (UINT32)(v->pci.op_end_time.attoseconds() >> 32), (UINT32)v->pci.op_end_time.attoseconds());
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", vd->index,
+ vd->device->machine().time().seconds(), (UINT32)(vd->device->machine().time().attoseconds() >> 32), (UINT32)vd->device->machine().time().attoseconds(),
+ vd->pci.op_end_time.seconds(), (UINT32)(vd->pci.op_end_time.attoseconds() >> 32), (UINT32)vd->pci.op_end_time.attoseconds());
}
}
}
@@ -2108,83 +2046,83 @@ static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 da
*
*************************************/
-static TIMER_CALLBACK( stall_cpu_callback )
+TIMER_CALLBACK_MEMBER( voodoo_device::stall_cpu_callback )
{
- check_stalled_cpu((voodoo_state *)ptr, machine.time());
+ check_stalled_cpu(this, machine().time());
}
-static void check_stalled_cpu(voodoo_state *v, attotime current_time)
+void voodoo_device::check_stalled_cpu(voodoo_device* vd, attotime current_time)
{
int resume = FALSE;
/* flush anything we can */
- if (v->pci.op_pending)
- flush_fifos(v, current_time);
+ if (vd->pci.op_pending)
+ flush_fifos(vd, current_time);
/* if we're just stalled until the LWM is passed, see if we're ok now */
- if (v->pci.stall_state == STALLED_UNTIL_FIFO_LWM)
+ if (vd->pci.stall_state == STALLED_UNTIL_FIFO_LWM)
{
/* if there's room in the memory FIFO now, we can proceed */
- if (FBIINIT0_ENABLE_MEMORY_FIFO(v->reg[fbiInit0].u))
+ if (FBIINIT0_ENABLE_MEMORY_FIFO(vd->reg[fbiInit0].u))
{
- if (fifo_items(&v->fbi.fifo) < 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(v->reg[fbiInit0].u))
+ if (fifo_items(&vd->fbi.fifo) < 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(vd->reg[fbiInit0].u))
resume = TRUE;
}
- else if (fifo_space(&v->pci.fifo) > 2 * FBIINIT0_PCI_FIFO_LWM(v->reg[fbiInit0].u))
+ else if (fifo_space(&vd->pci.fifo) > 2 * FBIINIT0_PCI_FIFO_LWM(vd->reg[fbiInit0].u))
resume = TRUE;
}
/* if we're stalled until the FIFOs are empty, check now */
- else if (v->pci.stall_state == STALLED_UNTIL_FIFO_EMPTY)
+ else if (vd->pci.stall_state == STALLED_UNTIL_FIFO_EMPTY)
{
- if (FBIINIT0_ENABLE_MEMORY_FIFO(v->reg[fbiInit0].u))
+ if (FBIINIT0_ENABLE_MEMORY_FIFO(vd->reg[fbiInit0].u))
{
- if (fifo_empty(&v->fbi.fifo) && fifo_empty(&v->pci.fifo))
+ if (fifo_empty(&vd->fbi.fifo) && fifo_empty(&vd->pci.fifo))
resume = TRUE;
}
- else if (fifo_empty(&v->pci.fifo))
+ else if (fifo_empty(&vd->pci.fifo))
resume = TRUE;
}
/* resume if necessary */
- if (resume || !v->pci.op_pending)
+ if (resume || !vd->pci.op_pending)
{
- if (LOG_FIFO) v->device->logerror("VOODOO.%d.FIFO:Stall condition cleared; resuming\n", v->index);
- v->pci.stall_state = NOT_STALLED;
+ if (LOG_FIFO) vd->device->logerror("VOODOO.%d.FIFO:Stall condition cleared; resuming\n", vd->index);
+ vd->pci.stall_state = NOT_STALLED;
/* either call the callback, or trigger the trigger */
- if (!v->device->m_stall.isnull())
- v->device->m_stall(FALSE);
+ if (!vd->device->m_stall.isnull())
+ vd->device->m_stall(FALSE);
else
- v->device->machine().scheduler().trigger(v->trigger);
+ vd->device->machine().scheduler().trigger(vd->trigger);
}
/* if not, set a timer for the next one */
else
{
- v->pci.continue_timer->adjust(v->pci.op_end_time - current_time);
+ vd->pci.continue_timer->adjust(vd->pci.op_end_time - current_time);
}
}
-static void stall_cpu(voodoo_state *v, int state, attotime current_time)
+void voodoo_device::stall_cpu(voodoo_device *vd, int state, attotime current_time)
{
/* sanity check */
- if (!v->pci.op_pending) fatalerror("FIFOs not empty, no op pending!\n");
+ if (!vd->pci.op_pending) fatalerror("FIFOs not empty, no op pending!\n");
/* set the state and update statistics */
- v->pci.stall_state = state;
- v->stats.stalls++;
+ vd->pci.stall_state = state;
+ vd->stats.stalls++;
/* either call the callback, or spin the CPU */
- if (!v->device->m_stall.isnull())
- v->device->m_stall(TRUE);
+ if (!vd->device->m_stall.isnull())
+ vd->device->m_stall(TRUE);
else
- v->cpu->execute().spin_until_trigger(v->trigger);
+ vd->cpu->execute().spin_until_trigger(vd->trigger);
/* set a timer to clear the stall */
- v->pci.continue_timer->adjust(v->pci.op_end_time - current_time);
+ vd->pci.continue_timer->adjust(vd->pci.op_end_time - current_time);
}
@@ -2195,7 +2133,7 @@ static void stall_cpu(voodoo_state *v, int state, attotime current_time)
*
*************************************/
-static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
+INT32 voodoo_device::register_w(voodoo_device *vd, offs_t offset, UINT32 data)
{
UINT32 origdata = data;
INT32 cycles = 0;
@@ -2204,24 +2142,24 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
UINT8 chips;
/* statistics */
- v->stats.reg_writes++;
+ vd->stats.reg_writes++;
/* determine which chips we are addressing */
chips = (offset >> 8) & 0xf;
if (chips == 0)
chips = 0xf;
- chips &= v->chipmask;
+ chips &= vd->chipmask;
/* the first 64 registers can be aliased differently */
- if ((offset & 0x800c0) == 0x80000 && v->alt_regmap)
+ if ((offset & 0x800c0) == 0x80000 && vd->alt_regmap)
regnum = register_alias_map[offset & 0x3f];
else
regnum = offset & 0xff;
/* first make sure this register is readable */
- if (!(v->regaccess[regnum] & REGISTER_WRITE))
+ if (!(vd->regaccess[regnum] & REGISTER_WRITE))
{
- v->device->logerror("VOODOO.%d.ERROR:Invalid attempt to write %s\n", v->index, v->regnames[regnum]);
+ vd->device->logerror("VOODOO.%d.ERROR:Invalid attempt to write %s\n", vd->index, vd->regnames[regnum]);
return 0;
}
@@ -2232,227 +2170,227 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case fvertexAx:
data = float_to_int32(data, 4);
case vertexAx:
- if (chips & 1) v->fbi.ax = (INT16)data;
+ if (chips & 1) vd->fbi.ax = (INT16)data;
break;
case fvertexAy:
data = float_to_int32(data, 4);
case vertexAy:
- if (chips & 1) v->fbi.ay = (INT16)data;
+ if (chips & 1) vd->fbi.ay = (INT16)data;
break;
case fvertexBx:
data = float_to_int32(data, 4);
case vertexBx:
- if (chips & 1) v->fbi.bx = (INT16)data;
+ if (chips & 1) vd->fbi.bx = (INT16)data;
break;
case fvertexBy:
data = float_to_int32(data, 4);
case vertexBy:
- if (chips & 1) v->fbi.by = (INT16)data;
+ if (chips & 1) vd->fbi.by = (INT16)data;
break;
case fvertexCx:
data = float_to_int32(data, 4);
case vertexCx:
- if (chips & 1) v->fbi.cx = (INT16)data;
+ if (chips & 1) vd->fbi.cx = (INT16)data;
break;
case fvertexCy:
data = float_to_int32(data, 4);
case vertexCy:
- if (chips & 1) v->fbi.cy = (INT16)data;
+ if (chips & 1) vd->fbi.cy = (INT16)data;
break;
/* RGB data is 12.12 formatted fixed point */
case fstartR:
data = float_to_int32(data, 12);
case startR:
- if (chips & 1) v->fbi.startr = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.startr = (INT32)(data << 8) >> 8;
break;
case fstartG:
data = float_to_int32(data, 12);
case startG:
- if (chips & 1) v->fbi.startg = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.startg = (INT32)(data << 8) >> 8;
break;
case fstartB:
data = float_to_int32(data, 12);
case startB:
- if (chips & 1) v->fbi.startb = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.startb = (INT32)(data << 8) >> 8;
break;
case fstartA:
data = float_to_int32(data, 12);
case startA:
- if (chips & 1) v->fbi.starta = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.starta = (INT32)(data << 8) >> 8;
break;
case fdRdX:
data = float_to_int32(data, 12);
case dRdX:
- if (chips & 1) v->fbi.drdx = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.drdx = (INT32)(data << 8) >> 8;
break;
case fdGdX:
data = float_to_int32(data, 12);
case dGdX:
- if (chips & 1) v->fbi.dgdx = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dgdx = (INT32)(data << 8) >> 8;
break;
case fdBdX:
data = float_to_int32(data, 12);
case dBdX:
- if (chips & 1) v->fbi.dbdx = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dbdx = (INT32)(data << 8) >> 8;
break;
case fdAdX:
data = float_to_int32(data, 12);
case dAdX:
- if (chips & 1) v->fbi.dadx = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dadx = (INT32)(data << 8) >> 8;
break;
case fdRdY:
data = float_to_int32(data, 12);
case dRdY:
- if (chips & 1) v->fbi.drdy = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.drdy = (INT32)(data << 8) >> 8;
break;
case fdGdY:
data = float_to_int32(data, 12);
case dGdY:
- if (chips & 1) v->fbi.dgdy = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dgdy = (INT32)(data << 8) >> 8;
break;
case fdBdY:
data = float_to_int32(data, 12);
case dBdY:
- if (chips & 1) v->fbi.dbdy = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dbdy = (INT32)(data << 8) >> 8;
break;
case fdAdY:
data = float_to_int32(data, 12);
case dAdY:
- if (chips & 1) v->fbi.dady = (INT32)(data << 8) >> 8;
+ if (chips & 1) vd->fbi.dady = (INT32)(data << 8) >> 8;
break;
/* Z data is 20.12 formatted fixed point */
case fstartZ:
data = float_to_int32(data, 12);
case startZ:
- if (chips & 1) v->fbi.startz = (INT32)data;
+ if (chips & 1) vd->fbi.startz = (INT32)data;
break;
case fdZdX:
data = float_to_int32(data, 12);
case dZdX:
- if (chips & 1) v->fbi.dzdx = (INT32)data;
+ if (chips & 1) vd->fbi.dzdx = (INT32)data;
break;
case fdZdY:
data = float_to_int32(data, 12);
case dZdY:
- if (chips & 1) v->fbi.dzdy = (INT32)data;
+ if (chips & 1) vd->fbi.dzdy = (INT32)data;
break;
/* S,T data is 14.18 formatted fixed point, converted to 16.32 internally */
case fstartS:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].starts = data64;
- if (chips & 4) v->tmu[1].starts = data64;
+ if (chips & 2) vd->tmu[0].starts = data64;
+ if (chips & 4) vd->tmu[1].starts = data64;
break;
case startS:
- if (chips & 2) v->tmu[0].starts = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].starts = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].starts = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].starts = (INT64)(INT32)data << 14;
break;
case fstartT:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].startt = data64;
- if (chips & 4) v->tmu[1].startt = data64;
+ if (chips & 2) vd->tmu[0].startt = data64;
+ if (chips & 4) vd->tmu[1].startt = data64;
break;
case startT:
- if (chips & 2) v->tmu[0].startt = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].startt = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].startt = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].startt = (INT64)(INT32)data << 14;
break;
case fdSdX:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].dsdx = data64;
- if (chips & 4) v->tmu[1].dsdx = data64;
+ if (chips & 2) vd->tmu[0].dsdx = data64;
+ if (chips & 4) vd->tmu[1].dsdx = data64;
break;
case dSdX:
- if (chips & 2) v->tmu[0].dsdx = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].dsdx = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].dsdx = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].dsdx = (INT64)(INT32)data << 14;
break;
case fdTdX:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].dtdx = data64;
- if (chips & 4) v->tmu[1].dtdx = data64;
+ if (chips & 2) vd->tmu[0].dtdx = data64;
+ if (chips & 4) vd->tmu[1].dtdx = data64;
break;
case dTdX:
- if (chips & 2) v->tmu[0].dtdx = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].dtdx = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].dtdx = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].dtdx = (INT64)(INT32)data << 14;
break;
case fdSdY:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].dsdy = data64;
- if (chips & 4) v->tmu[1].dsdy = data64;
+ if (chips & 2) vd->tmu[0].dsdy = data64;
+ if (chips & 4) vd->tmu[1].dsdy = data64;
break;
case dSdY:
- if (chips & 2) v->tmu[0].dsdy = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].dsdy = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].dsdy = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].dsdy = (INT64)(INT32)data << 14;
break;
case fdTdY:
data64 = float_to_int64(data, 32);
- if (chips & 2) v->tmu[0].dtdy = data64;
- if (chips & 4) v->tmu[1].dtdy = data64;
+ if (chips & 2) vd->tmu[0].dtdy = data64;
+ if (chips & 4) vd->tmu[1].dtdy = data64;
break;
case dTdY:
- if (chips & 2) v->tmu[0].dtdy = (INT64)(INT32)data << 14;
- if (chips & 4) v->tmu[1].dtdy = (INT64)(INT32)data << 14;
+ if (chips & 2) vd->tmu[0].dtdy = (INT64)(INT32)data << 14;
+ if (chips & 4) vd->tmu[1].dtdy = (INT64)(INT32)data << 14;
break;
/* W data is 2.30 formatted fixed point, converted to 16.32 internally */
case fstartW:
data64 = float_to_int64(data, 32);
- if (chips & 1) v->fbi.startw = data64;
- if (chips & 2) v->tmu[0].startw = data64;
- if (chips & 4) v->tmu[1].startw = data64;
+ if (chips & 1) vd->fbi.startw = data64;
+ if (chips & 2) vd->tmu[0].startw = data64;
+ if (chips & 4) vd->tmu[1].startw = data64;
break;
case startW:
- if (chips & 1) v->fbi.startw = (INT64)(INT32)data << 2;
- if (chips & 2) v->tmu[0].startw = (INT64)(INT32)data << 2;
- if (chips & 4) v->tmu[1].startw = (INT64)(INT32)data << 2;
+ if (chips & 1) vd->fbi.startw = (INT64)(INT32)data << 2;
+ if (chips & 2) vd->tmu[0].startw = (INT64)(INT32)data << 2;
+ if (chips & 4) vd->tmu[1].startw = (INT64)(INT32)data << 2;
break;
case fdWdX:
data64 = float_to_int64(data, 32);
- if (chips & 1) v->fbi.dwdx = data64;
- if (chips & 2) v->tmu[0].dwdx = data64;
- if (chips & 4) v->tmu[1].dwdx = data64;
+ if (chips & 1) vd->fbi.dwdx = data64;
+ if (chips & 2) vd->tmu[0].dwdx = data64;
+ if (chips & 4) vd->tmu[1].dwdx = data64;
break;
case dWdX:
- if (chips & 1) v->fbi.dwdx = (INT64)(INT32)data << 2;
- if (chips & 2) v->tmu[0].dwdx = (INT64)(INT32)data << 2;
- if (chips & 4) v->tmu[1].dwdx = (INT64)(INT32)data << 2;
+ if (chips & 1) vd->fbi.dwdx = (INT64)(INT32)data << 2;
+ if (chips & 2) vd->tmu[0].dwdx = (INT64)(INT32)data << 2;
+ if (chips & 4) vd->tmu[1].dwdx = (INT64)(INT32)data << 2;
break;
case fdWdY:
data64 = float_to_int64(data, 32);
- if (chips & 1) v->fbi.dwdy = data64;
- if (chips & 2) v->tmu[0].dwdy = data64;
- if (chips & 4) v->tmu[1].dwdy = data64;
+ if (chips & 1) vd->fbi.dwdy = data64;
+ if (chips & 2) vd->tmu[0].dwdy = data64;
+ if (chips & 4) vd->tmu[1].dwdy = data64;
break;
case dWdY:
- if (chips & 1) v->fbi.dwdy = (INT64)(INT32)data << 2;
- if (chips & 2) v->tmu[0].dwdy = (INT64)(INT32)data << 2;
- if (chips & 4) v->tmu[1].dwdy = (INT64)(INT32)data << 2;
+ if (chips & 1) vd->fbi.dwdy = (INT64)(INT32)data << 2;
+ if (chips & 2) vd->tmu[0].dwdy = (INT64)(INT32)data << 2;
+ if (chips & 4) vd->tmu[1].dwdy = (INT64)(INT32)data << 2;
break;
/* setup bits */
@@ -2460,114 +2398,114 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
if (chips & 1)
{
rgb_t rgbdata(data);
- v->reg[sAlpha].f = rgbdata.a();
- v->reg[sRed].f = rgbdata.r();
- v->reg[sGreen].f = rgbdata.g();
- v->reg[sBlue].f = rgbdata.b();
+ vd->reg[sAlpha].f = rgbdata.a();
+ vd->reg[sRed].f = rgbdata.r();
+ vd->reg[sGreen].f = rgbdata.g();
+ vd->reg[sBlue].f = rgbdata.b();
}
break;
/* mask off invalid bits for different cards */
case fbzColorPath:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type < TYPE_VOODOO_2)
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type < TYPE_VOODOO_2)
data &= 0x0fffffff;
- if (chips & 1) v->reg[fbzColorPath].u = data;
+ if (chips & 1) vd->reg[fbzColorPath].u = data;
break;
case fbzMode:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type < TYPE_VOODOO_2)
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type < TYPE_VOODOO_2)
data &= 0x001fffff;
- if (chips & 1) v->reg[fbzMode].u = data;
+ if (chips & 1) vd->reg[fbzMode].u = data;
break;
case fogMode:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type < TYPE_VOODOO_2)
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type < TYPE_VOODOO_2)
data &= 0x0000003f;
- if (chips & 1) v->reg[fogMode].u = data;
+ if (chips & 1) vd->reg[fogMode].u = data;
break;
/* triangle drawing */
case triangleCMD:
- v->fbi.cheating_allowed = (v->fbi.ax != 0 || v->fbi.ay != 0 || v->fbi.bx > 50 || v->fbi.by != 0 || v->fbi.cx != 0 || v->fbi.cy > 50);
- v->fbi.sign = data;
- cycles = triangle(v);
+ vd->fbi.cheating_allowed = (vd->fbi.ax != 0 || vd->fbi.ay != 0 || vd->fbi.bx > 50 || vd->fbi.by != 0 || vd->fbi.cx != 0 || vd->fbi.cy > 50);
+ vd->fbi.sign = data;
+ cycles = triangle(vd);
break;
case ftriangleCMD:
- v->fbi.cheating_allowed = TRUE;
- v->fbi.sign = data;
- cycles = triangle(v);
+ vd->fbi.cheating_allowed = TRUE;
+ vd->fbi.sign = data;
+ cycles = triangle(vd);
break;
case sBeginTriCMD:
- cycles = begin_triangle(v);
+ cycles = begin_triangle(vd);
break;
case sDrawTriCMD:
- cycles = draw_triangle(v);
+ cycles = draw_triangle(vd);
break;
/* other commands */
case nopCMD:
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
if (data & 1)
- reset_counters(v);
+ reset_counters(vd);
if (data & 2)
- v->reg[fbiTrianglesOut].u = 0;
+ vd->reg[fbiTrianglesOut].u = 0;
break;
case fastfillCMD:
- cycles = fastfill(v);
+ cycles = fastfill(vd);
break;
case swapbufferCMD:
- poly_wait(v->poly, v->regnames[regnum]);
- cycles = swapbuffer(v, data);
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ cycles = swapbuffer(vd, data);
break;
case userIntrCMD:
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
//fatalerror("userIntrCMD\n");
- v->reg[intrCtrl].u |= 0x1800;
- v->reg[intrCtrl].u &= ~0x80000000;
+ vd->reg[intrCtrl].u |= 0x1800;
+ vd->reg[intrCtrl].u &= ~0x80000000;
// TODO: rename vblank_client for less confusion?
- if (!v->device->m_vblank.isnull())
- v->device->m_vblank(TRUE);
+ if (!vd->device->m_vblank.isnull())
+ vd->device->m_vblank(TRUE);
break;
/* gamma table access -- Voodoo/Voodoo2 only */
case clutData:
- if (v->type <= TYPE_VOODOO_2 && (chips & 1))
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1))
{
- poly_wait(v->poly, v->regnames[regnum]);
- if (!FBIINIT1_VIDEO_TIMING_RESET(v->reg[fbiInit1].u))
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (!FBIINIT1_VIDEO_TIMING_RESET(vd->reg[fbiInit1].u))
{
int index = data >> 24;
if (index <= 32)
{
- v->fbi.clut[index] = data;
- v->fbi.clut_dirty = TRUE;
+ vd->fbi.clut[index] = data;
+ vd->fbi.clut_dirty = TRUE;
}
}
else
- v->device->logerror("clutData ignored because video timing reset = 1\n");
+ vd->device->logerror("clutData ignored because video timing reset = 1\n");
}
break;
/* external DAC access -- Voodoo/Voodoo2 only */
case dacData:
- if (v->type <= TYPE_VOODOO_2 && (chips & 1))
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1))
{
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
if (!(data & 0x800))
- dacdata_w(&v->dac, (data >> 8) & 7, data & 0xff);
+ dacdata_w(&vd->dac, (data >> 8) & 7, data & 0xff);
else
- dacdata_r(&v->dac, (data >> 8) & 7);
+ dacdata_r(&vd->dac, (data >> 8) & 7);
}
break;
@@ -2576,35 +2514,35 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case vSync:
case backPorch:
case videoDimensions:
- if (v->type <= TYPE_VOODOO_2 && (chips & 1))
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1))
{
- poly_wait(v->poly, v->regnames[regnum]);
- v->reg[regnum].u = data;
- if (v->reg[hSync].u != 0 && v->reg[vSync].u != 0 && v->reg[videoDimensions].u != 0)
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ vd->reg[regnum].u = data;
+ if (vd->reg[hSync].u != 0 && vd->reg[vSync].u != 0 && vd->reg[videoDimensions].u != 0)
{
int hvis, vvis, htotal, vtotal, hbp, vbp;
- attoseconds_t refresh = v->screen->frame_period().attoseconds();
+ attoseconds_t refresh = vd->screen->frame_period().attoseconds();
attoseconds_t stdperiod, medperiod, vgaperiod;
attoseconds_t stddiff, meddiff, vgadiff;
rectangle visarea;
- if (v->type == TYPE_VOODOO_2)
+ if (vd->vd_type == TYPE_VOODOO_2)
{
- htotal = ((v->reg[hSync].u >> 16) & 0x7ff) + 1 + (v->reg[hSync].u & 0x1ff) + 1;
- vtotal = ((v->reg[vSync].u >> 16) & 0x1fff) + (v->reg[vSync].u & 0x1fff);
- hvis = v->reg[videoDimensions].u & 0x7ff;
- vvis = (v->reg[videoDimensions].u >> 16) & 0x7ff;
- hbp = (v->reg[backPorch].u & 0x1ff) + 2;
- vbp = (v->reg[backPorch].u >> 16) & 0x1ff;
+ htotal = ((vd->reg[hSync].u >> 16) & 0x7ff) + 1 + (vd->reg[hSync].u & 0x1ff) + 1;
+ vtotal = ((vd->reg[vSync].u >> 16) & 0x1fff) + (vd->reg[vSync].u & 0x1fff);
+ hvis = vd->reg[videoDimensions].u & 0x7ff;
+ vvis = (vd->reg[videoDimensions].u >> 16) & 0x7ff;
+ hbp = (vd->reg[backPorch].u & 0x1ff) + 2;
+ vbp = (vd->reg[backPorch].u >> 16) & 0x1ff;
}
else
{
- htotal = ((v->reg[hSync].u >> 16) & 0x3ff) + 1 + (v->reg[hSync].u & 0xff) + 1;
- vtotal = ((v->reg[vSync].u >> 16) & 0xfff) + (v->reg[vSync].u & 0xfff);
- hvis = v->reg[videoDimensions].u & 0x3ff;
- vvis = (v->reg[videoDimensions].u >> 16) & 0x3ff;
- hbp = (v->reg[backPorch].u & 0xff) + 2;
- vbp = (v->reg[backPorch].u >> 16) & 0xff;
+ htotal = ((vd->reg[hSync].u >> 16) & 0x3ff) + 1 + (vd->reg[hSync].u & 0xff) + 1;
+ vtotal = ((vd->reg[vSync].u >> 16) & 0xfff) + (vd->reg[vSync].u & 0xfff);
+ hvis = vd->reg[videoDimensions].u & 0x3ff;
+ vvis = (vd->reg[videoDimensions].u >> 16) & 0x3ff;
+ hbp = (vd->reg[backPorch].u & 0xff) + 2;
+ vbp = (vd->reg[backPorch].u >> 16) & 0xff;
}
/* create a new visarea */
@@ -2628,61 +2566,61 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
if (vgadiff < 0) vgadiff = -vgadiff;
osd_printf_debug("hSync=%08X vSync=%08X backPorch=%08X videoDimensions=%08X\n",
- v->reg[hSync].u, v->reg[vSync].u, v->reg[backPorch].u, v->reg[videoDimensions].u);
+ vd->reg[hSync].u, vd->reg[vSync].u, vd->reg[backPorch].u, vd->reg[videoDimensions].u);
osd_printf_debug("Horiz: %d-%d (%d total) Vert: %d-%d (%d total) -- ", visarea.min_x, visarea.max_x, htotal, visarea.min_y, visarea.max_y, vtotal);
/* configure the screen based on which one matches the closest */
if (stddiff < meddiff && stddiff < vgadiff)
{
- v->screen->configure(htotal, vtotal, visarea, stdperiod);
+ vd->screen->configure(htotal, vtotal, visarea, stdperiod);
osd_printf_debug("Standard resolution, %f Hz\n", ATTOSECONDS_TO_HZ(stdperiod));
}
else if (meddiff < vgadiff)
{
- v->screen->configure(htotal, vtotal, visarea, medperiod);
+ vd->screen->configure(htotal, vtotal, visarea, medperiod);
osd_printf_debug("Medium resolution, %f Hz\n", ATTOSECONDS_TO_HZ(medperiod));
}
else
{
- v->screen->configure(htotal, vtotal, visarea, vgaperiod);
+ vd->screen->configure(htotal, vtotal, visarea, vgaperiod);
osd_printf_debug("VGA resolution, %f Hz\n", ATTOSECONDS_TO_HZ(vgaperiod));
}
/* configure the new framebuffer info */
- v->fbi.width = hvis;
- v->fbi.height = vvis;
- v->fbi.xoffs = hbp;
- v->fbi.yoffs = vbp;
- v->fbi.vsyncscan = (v->reg[vSync].u >> 16) & 0xfff;
+ vd->fbi.width = hvis;
+ vd->fbi.height = vvis;
+ vd->fbi.xoffs = hbp;
+ vd->fbi.yoffs = vbp;
+ vd->fbi.vsyncscan = (vd->reg[vSync].u >> 16) & 0xfff;
/* recompute the time of VBLANK */
- adjust_vblank_timer(v);
+ adjust_vblank_timer(vd);
/* if changing dimensions, update video memory layout */
if (regnum == videoDimensions)
- recompute_video_memory(v);
+ recompute_video_memory(vd);
}
}
break;
/* fbiInit0 can only be written if initEnable says we can -- Voodoo/Voodoo2 only */
case fbiInit0:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(vd->pci.init_enable))
{
- v->reg[fbiInit0].u = data;
+ vd->reg[fbiInit0].u = data;
if (FBIINIT0_GRAPHICS_RESET(data))
- soft_reset(v);
+ soft_reset(vd);
if (FBIINIT0_FIFO_RESET(data))
- fifo_reset(&v->pci.fifo);
- recompute_video_memory(v);
+ fifo_reset(&vd->pci.fifo);
+ recompute_video_memory(vd);
}
break;
/* fbiInit5-7 are Voodoo 2-only; ignore them on anything else */
case fbiInit5:
case fbiInit6:
- if (v->type < TYPE_VOODOO_2)
+ if (vd->vd_type < TYPE_VOODOO_2)
break;
/* else fall through... */
@@ -2691,94 +2629,94 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case fbiInit1:
case fbiInit2:
case fbiInit4:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(vd->pci.init_enable))
{
- v->reg[regnum].u = data;
- recompute_video_memory(v);
- v->fbi.video_changed = TRUE;
+ vd->reg[regnum].u = data;
+ recompute_video_memory(vd);
+ vd->fbi.video_changed = TRUE;
}
break;
case fbiInit3:
- poly_wait(v->poly, v->regnames[regnum]);
- if (v->type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (vd->vd_type <= TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(vd->pci.init_enable))
{
- v->reg[regnum].u = data;
- v->alt_regmap = FBIINIT3_TRI_REGISTER_REMAP(data);
- v->fbi.yorigin = FBIINIT3_YORIGIN_SUBTRACT(v->reg[fbiInit3].u);
- recompute_video_memory(v);
+ vd->reg[regnum].u = data;
+ vd->alt_regmap = FBIINIT3_TRI_REGISTER_REMAP(data);
+ vd->fbi.yorigin = FBIINIT3_YORIGIN_SUBTRACT(vd->reg[fbiInit3].u);
+ recompute_video_memory(vd);
}
break;
case fbiInit7:
/* case swapPending: -- Banshee */
- if (v->type == TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(vd->pci.init_enable))
{
- poly_wait(v->poly, v->regnames[regnum]);
- v->reg[regnum].u = data;
- v->fbi.cmdfifo[0].enable = FBIINIT7_CMDFIFO_ENABLE(data);
- v->fbi.cmdfifo[0].count_holes = !FBIINIT7_DISABLE_CMDFIFO_HOLES(data);
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ vd->reg[regnum].u = data;
+ vd->fbi.cmdfifo[0].enable = FBIINIT7_CMDFIFO_ENABLE(data);
+ vd->fbi.cmdfifo[0].count_holes = !FBIINIT7_DISABLE_CMDFIFO_HOLES(data);
}
- else if (v->type >= TYPE_VOODOO_BANSHEE)
- v->fbi.swaps_pending++;
+ else if (vd->vd_type >= TYPE_VOODOO_BANSHEE)
+ vd->fbi.swaps_pending++;
break;
/* cmdFifo -- Voodoo2 only */
case cmdFifoBaseAddr:
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
{
- poly_wait(v->poly, v->regnames[regnum]);
- v->reg[regnum].u = data;
- v->fbi.cmdfifo[0].base = (data & 0x3ff) << 12;
- v->fbi.cmdfifo[0].end = (((data >> 16) & 0x3ff) + 1) << 12;
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ vd->reg[regnum].u = data;
+ vd->fbi.cmdfifo[0].base = (data & 0x3ff) << 12;
+ vd->fbi.cmdfifo[0].end = (((data >> 16) & 0x3ff) + 1) << 12;
}
break;
case cmdFifoBump:
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
fatalerror("cmdFifoBump\n");
break;
case cmdFifoRdPtr:
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
- v->fbi.cmdfifo[0].rdptr = data;
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
+ vd->fbi.cmdfifo[0].rdptr = data;
break;
case cmdFifoAMin:
/* case colBufferAddr: -- Banshee */
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
- v->fbi.cmdfifo[0].amin = data;
- else if (v->type >= TYPE_VOODOO_BANSHEE && (chips & 1))
- v->fbi.rgboffs[1] = data & v->fbi.mask & ~0x0f;
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
+ vd->fbi.cmdfifo[0].amin = data;
+ else if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (chips & 1))
+ vd->fbi.rgboffs[1] = data & vd->fbi.mask & ~0x0f;
break;
case cmdFifoAMax:
/* case colBufferStride: -- Banshee */
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
- v->fbi.cmdfifo[0].amax = data;
- else if (v->type >= TYPE_VOODOO_BANSHEE && (chips & 1))
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
+ vd->fbi.cmdfifo[0].amax = data;
+ else if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (chips & 1))
{
if (data & 0x8000)
- v->fbi.rowpixels = (data & 0x7f) << 6;
+ vd->fbi.rowpixels = (data & 0x7f) << 6;
else
- v->fbi.rowpixels = (data & 0x3fff) >> 1;
+ vd->fbi.rowpixels = (data & 0x3fff) >> 1;
}
break;
case cmdFifoDepth:
/* case auxBufferAddr: -- Banshee */
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
- v->fbi.cmdfifo[0].depth = data;
- else if (v->type >= TYPE_VOODOO_BANSHEE && (chips & 1))
- v->fbi.auxoffs = data & v->fbi.mask & ~0x0f;
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
+ vd->fbi.cmdfifo[0].depth = data;
+ else if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (chips & 1))
+ vd->fbi.auxoffs = data & vd->fbi.mask & ~0x0f;
break;
case cmdFifoHoles:
/* case auxBufferStride: -- Banshee */
- if (v->type == TYPE_VOODOO_2 && (chips & 1))
- v->fbi.cmdfifo[0].holes = data;
- else if (v->type >= TYPE_VOODOO_BANSHEE && (chips & 1))
+ if (vd->vd_type == TYPE_VOODOO_2 && (chips & 1))
+ vd->fbi.cmdfifo[0].holes = data;
+ else if (vd->vd_type >= TYPE_VOODOO_BANSHEE && (chips & 1))
{
int rowpixels;
@@ -2786,7 +2724,7 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
rowpixels = (data & 0x7f) << 6;
else
rowpixels = (data & 0x3fff) >> 1;
- if (v->fbi.rowpixels != rowpixels)
+ if (vd->fbi.rowpixels != rowpixels)
fatalerror("aux buffer stride differs from color buffer stride\n");
}
break;
@@ -2804,9 +2742,9 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case nccTable+9:
case nccTable+10:
case nccTable+11:
- poly_wait(v->poly, v->regnames[regnum]);
- if (chips & 2) ncc_table_write(&v->tmu[0].ncc[0], regnum - nccTable, data);
- if (chips & 4) ncc_table_write(&v->tmu[1].ncc[0], regnum - nccTable, data);
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (chips & 2) ncc_table_write(&vd->tmu[0].ncc[0], regnum - nccTable, data);
+ if (chips & 4) ncc_table_write(&vd->tmu[1].ncc[0], regnum - nccTable, data);
break;
case nccTable+12:
@@ -2821,9 +2759,9 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case nccTable+21:
case nccTable+22:
case nccTable+23:
- poly_wait(v->poly, v->regnames[regnum]);
- if (chips & 2) ncc_table_write(&v->tmu[0].ncc[1], regnum - (nccTable+12), data);
- if (chips & 4) ncc_table_write(&v->tmu[1].ncc[1], regnum - (nccTable+12), data);
+ poly_wait(vd->poly, vd->regnames[regnum]);
+ if (chips & 2) ncc_table_write(&vd->tmu[0].ncc[1], regnum - (nccTable+12), data);
+ if (chips & 4) ncc_table_write(&vd->tmu[1].ncc[1], regnum - (nccTable+12), data);
break;
/* fogTable entries are processed and expanded immediately */
@@ -2859,14 +2797,14 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case fogTable+29:
case fogTable+30:
case fogTable+31:
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
if (chips & 1)
{
int base = 2 * (regnum - fogTable);
- v->fbi.fogdelta[base + 0] = (data >> 0) & 0xff;
- v->fbi.fogblend[base + 0] = (data >> 8) & 0xff;
- v->fbi.fogdelta[base + 1] = (data >> 16) & 0xff;
- v->fbi.fogblend[base + 1] = (data >> 24) & 0xff;
+ vd->fbi.fogdelta[base + 0] = (data >> 0) & 0xff;
+ vd->fbi.fogblend[base + 0] = (data >> 8) & 0xff;
+ vd->fbi.fogdelta[base + 1] = (data >> 16) & 0xff;
+ vd->fbi.fogblend[base + 1] = (data >> 24) & 0xff;
}
break;
@@ -2878,22 +2816,22 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case texBaseAddr_1:
case texBaseAddr_2:
case texBaseAddr_3_8:
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
if (chips & 2)
{
- v->tmu[0].reg[regnum].u = data;
- v->tmu[0].regdirty = TRUE;
+ vd->tmu[0].reg[regnum].u = data;
+ vd->tmu[0].regdirty = TRUE;
}
if (chips & 4)
{
- v->tmu[1].reg[regnum].u = data;
- v->tmu[1].regdirty = TRUE;
+ vd->tmu[1].reg[regnum].u = data;
+ vd->tmu[1].regdirty = TRUE;
}
break;
case trexInit1:
/* send tmu config data to the frame buffer */
- v->send_config = (TREXINIT_SEND_TMU_CONFIG(data) > 0);
+ vd->send_config = (TREXINIT_SEND_TMU_CONFIG(data) > 0);
goto default_case;
/* these registers are referenced in the renderer; we must wait for pending work before changing */
@@ -2907,25 +2845,25 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data)
case color0:
case clipLowYHighY:
case clipLeftRight:
- poly_wait(v->poly, v->regnames[regnum]);
+ poly_wait(vd->poly, vd->regnames[regnum]);
/* fall through to default implementation */
/* by default, just feed the data to the chips */
default:
default_case:
- if (chips & 1) v->reg[0x000 + regnum].u = data;
- if (chips & 2) v->reg[0x100 + regnum].u = data;
- if (chips & 4) v->reg[0x200 + regnum].u = data;
- if (chips & 8) v->reg[0x300 + regnum].u = data;
+ if (chips & 1) vd->reg[0x000 + regnum].u = data;
+ if (chips & 2) vd->reg[0x100 + regnum].u = data;
+ if (chips & 4) vd->reg[0x200 + regnum].u = data;
+ if (chips & 8) vd->reg[0x300 + regnum].u = data;
break;
}
if (LOG_REGISTERS)
{
if (regnum < fvertexAx || regnum > fdWdY)
- v->device->logerror("VOODOO.%d.REG:%s(%d) write = %08X\n", v->index, (regnum < 0x384/4) ? v->regnames[regnum] : "oob", chips, origdata);
+ vd->device->logerror("VOODOO.%d.REG:%s(%d) write = %08X\n", vd->index, (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, origdata);
else
- v->device->logerror("VOODOO.%d.REG:%s(%d) write = %f\n", v->index, (regnum < 0x384/4) ? v->regnames[regnum] : "oob", chips, (double) u2f(origdata));
+ vd->device->logerror("VOODOO.%d.REG:%s(%d) write = %f\n", vd->index, (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, (double) u2f(origdata));
}
return cycles;
@@ -2938,25 +2876,25 @@ default_case:
* Voodoo LFB writes
*
*************************************/
-static INT32 lfb_direct_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
-{
+INT32 voodoo_device::lfb_direct_w(voodoo_device *vd, offs_t offset, UINT32 data, UINT32 mem_mask)
+{
UINT16 *dest;
UINT32 destmax;
int x, y;
UINT32 bufoffs;
/* statistics */
- v->stats.lfb_writes++;
+ vd->stats.lfb_writes++;
/* byte swizzling */
- if (LFBMODE_BYTE_SWIZZLE_WRITES(v->reg[lfbMode].u))
+ if (LFBMODE_BYTE_SWIZZLE_WRITES(vd->reg[lfbMode].u))
{
data = FLIPENDIAN_INT32(data);
mem_mask = FLIPENDIAN_INT32(mem_mask);
}
/* word swapping */
- if (LFBMODE_WORD_SWAP_WRITES(v->reg[lfbMode].u))
+ if (LFBMODE_WORD_SWAP_WRITES(vd->reg[lfbMode].u))
{
data = (data << 16) | (data >> 16);
mem_mask = (mem_mask << 16) | (mem_mask >> 16);
@@ -2966,25 +2904,26 @@ static INT32 lfb_direct_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 me
// For direct lfb access just write the data
/* compute X,Y */
offset <<= 1;
- x = offset & ((1 << v->fbi.lfb_stride) - 1);
- y = (offset >> v->fbi.lfb_stride);
- dest = (UINT16 *)(v->fbi.ram + v->fbi.lfb_base*4);
- destmax = (v->fbi.mask + 1 - v->fbi.lfb_base*4) / 2;
- bufoffs = y * v->fbi.rowpixels + x;
+ x = offset & ((1 << vd->fbi.lfb_stride) - 1);
+ y = (offset >> vd->fbi.lfb_stride);
+ dest = (UINT16 *)(vd->fbi.ram + vd->fbi.lfb_base*4);
+ destmax = (vd->fbi.mask + 1 - vd->fbi.lfb_base*4) / 2;
+ bufoffs = y * vd->fbi.rowpixels + x;
if (bufoffs >= destmax) {
- v->device->logerror("lfb_direct_w: Buffer offset out of bounds x=%i y=%i offset=%08X bufoffs=%08X data=%08X\n", x, y, offset, (UINT32) bufoffs, data);
+ vd->device->logerror("lfb_direct_w: Buffer offset out of bounds x=%i y=%i offset=%08X bufoffs=%08X data=%08X\n", x, y, offset, (UINT32) bufoffs, data);
return 0;
}
if (ACCESSING_BITS_0_15)
dest[bufoffs + 0] = data&0xffff;
if (ACCESSING_BITS_16_31)
dest[bufoffs + 1] = data>>16;
- if (LOG_LFB) v->device->logerror("VOODOO.%d.LFB:write direct (%d,%d) = %08X & %08X\n", v->index, x, y, data, mem_mask);
+ if (LOG_LFB) vd->device->logerror("VOODOO.%d.LFB:write direct (%d,%d) = %08X & %08X\n", vd->index, x, y, data, mem_mask);
return 0;
}
-static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
+INT32 voodoo_device::lfb_w(voodoo_device* vd, offs_t offset, UINT32 data, UINT32 mem_mask)
{
+
UINT16 *dest, *depth;
UINT32 destmax, depthmax;
int sr[2], sg[2], sb[2], sa[2], sw[2];
@@ -2992,28 +2931,28 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
int pix, destbuf;
/* statistics */
- v->stats.lfb_writes++;
+ vd->stats.lfb_writes++;
/* byte swizzling */
- if (LFBMODE_BYTE_SWIZZLE_WRITES(v->reg[lfbMode].u))
+ if (LFBMODE_BYTE_SWIZZLE_WRITES(vd->reg[lfbMode].u))
{
data = FLIPENDIAN_INT32(data);
mem_mask = FLIPENDIAN_INT32(mem_mask);
}
/* word swapping */
- if (LFBMODE_WORD_SWAP_WRITES(v->reg[lfbMode].u))
+ if (LFBMODE_WORD_SWAP_WRITES(vd->reg[lfbMode].u))
{
data = (data << 16) | (data >> 16);
mem_mask = (mem_mask << 16) | (mem_mask >> 16);
}
/* extract default depth and alpha values */
- sw[0] = sw[1] = v->reg[zaColor].u & 0xffff;
- sa[0] = sa[1] = v->reg[zaColor].u >> 24;
+ sw[0] = sw[1] = vd->reg[zaColor].u & 0xffff;
+ sa[0] = sa[1] = vd->reg[zaColor].u >> 24;
/* first extract A,R,G,B from the data */
- switch (LFBMODE_WRITE_FORMAT(v->reg[lfbMode].u) + 16 * LFBMODE_RGBA_LANES(v->reg[lfbMode].u))
+ switch (LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u) + 16 * LFBMODE_RGBA_LANES(vd->reg[lfbMode].u))
{
case 16*0 + 0: /* ARGB, 16-bit RGB 5-6-5 */
case 16*2 + 0: /* RGBA, 16-bit RGB 5-6-5 */
@@ -3180,13 +3119,13 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
break;
default: /* reserved */
- v->device->logerror("lfb_w: Unknown format\n");
+ vd->device->logerror("lfb_w: Unknown format\n");
return 0;
}
/* compute X,Y */
- x = offset & ((1 << v->fbi.lfb_stride) - 1);
- y = (offset >> v->fbi.lfb_stride) & 0x3ff;
+ x = offset & ((1 << vd->fbi.lfb_stride) - 1);
+ y = (offset >> vd->fbi.lfb_stride) & 0x3ff;
/* adjust the mask based on which half of the data is written */
if (!ACCESSING_BITS_0_15)
@@ -3195,47 +3134,47 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
mask &= ~(0xf0 + LFB_DEPTH_PRESENT_MSW);
/* select the target buffer */
- destbuf = (v->type >= TYPE_VOODOO_BANSHEE) ? 1 : LFBMODE_WRITE_BUFFER_SELECT(v->reg[lfbMode].u);
+ destbuf = (vd->vd_type >= TYPE_VOODOO_BANSHEE) ? 1 : LFBMODE_WRITE_BUFFER_SELECT(vd->reg[lfbMode].u);
switch (destbuf)
{
case 0: /* front buffer */
- dest = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
- destmax = (v->fbi.mask + 1 - v->fbi.rgboffs[v->fbi.frontbuf]) / 2;
- v->fbi.video_changed = TRUE;
+ dest = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.frontbuf]);
+ destmax = (vd->fbi.mask + 1 - vd->fbi.rgboffs[vd->fbi.frontbuf]) / 2;
+ vd->fbi.video_changed = TRUE;
break;
case 1: /* back buffer */
- dest = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.backbuf]);
- destmax = (v->fbi.mask + 1 - v->fbi.rgboffs[v->fbi.backbuf]) / 2;
+ dest = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.backbuf]);
+ destmax = (vd->fbi.mask + 1 - vd->fbi.rgboffs[vd->fbi.backbuf]) / 2;
break;
default: /* reserved */
return 0;
}
- depth = (UINT16 *)(v->fbi.ram + v->fbi.auxoffs);
- depthmax = (v->fbi.mask + 1 - v->fbi.auxoffs) / 2;
+ depth = (UINT16 *)(vd->fbi.ram + vd->fbi.auxoffs);
+ depthmax = (vd->fbi.mask + 1 - vd->fbi.auxoffs) / 2;
/* simple case: no pipeline */
- if (!LFBMODE_ENABLE_PIXEL_PIPELINE(v->reg[lfbMode].u))
+ if (!LFBMODE_ENABLE_PIXEL_PIPELINE(vd->reg[lfbMode].u))
{
DECLARE_DITHER_POINTERS_NO_DITHER_VAR;
UINT32 bufoffs;
- if (LOG_LFB) v->device->logerror("VOODOO.%d.LFB:write raw mode %X (%d,%d) = %08X & %08X\n", v->index, LFBMODE_WRITE_FORMAT(v->reg[lfbMode].u), x, y, data, mem_mask);
+ if (LOG_LFB) vd->device->logerror("VOODOO.%d.LFB:write raw mode %X (%d,%d) = %08X & %08X\n", vd->index, LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask);
/* determine the screen Y */
scry = y;
- if (LFBMODE_Y_ORIGIN(v->reg[lfbMode].u))
- scry = (v->fbi.yorigin - y) & 0x3ff;
+ if (LFBMODE_Y_ORIGIN(vd->reg[lfbMode].u))
+ scry = (vd->fbi.yorigin - y) & 0x3ff;
/* advance pointers to the proper row */
- bufoffs = scry * v->fbi.rowpixels + x;
+ bufoffs = scry * vd->fbi.rowpixels + x;
/* compute dithering */
- COMPUTE_DITHER_POINTERS_NO_DITHER_VAR(v->reg[fbzMode].u, y);
+ COMPUTE_DITHER_POINTERS_NO_DITHER_VAR(vd->reg[fbzMode].u, y);
/* wait for any outstanding work to finish */
- poly_wait(v->poly, "LFB Write");
+ poly_wait(vd->poly, "LFB Write");
/* loop over up to two pixels */
for (pix = 0; mask; pix++)
@@ -3247,7 +3186,7 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
if ((mask & LFB_RGB_PRESENT) && bufoffs < destmax)
{
/* apply dithering and write to the screen */
- APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
+ APPLY_DITHER(vd->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
dest[bufoffs] = (sr[pix] << 11) | (sg[pix] << 5) | sb[pix];
}
@@ -3255,16 +3194,16 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
if (depth && bufoffs < depthmax)
{
/* write to the alpha buffer */
- if ((mask & LFB_ALPHA_PRESENT) && FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u))
+ if ((mask & LFB_ALPHA_PRESENT) && FBZMODE_ENABLE_ALPHA_PLANES(vd->reg[fbzMode].u))
depth[bufoffs] = sa[pix];
/* write to the depth buffer */
- if ((mask & (LFB_DEPTH_PRESENT | LFB_DEPTH_PRESENT_MSW)) && !FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u))
+ if ((mask & (LFB_DEPTH_PRESENT | LFB_DEPTH_PRESENT_MSW)) && !FBZMODE_ENABLE_ALPHA_PLANES(vd->reg[fbzMode].u))
depth[bufoffs] = sw[pix];
}
/* track pixel writes to the frame buffer regardless of mask */
- v->reg[fbiPixelsOut].u++;
+ vd->reg[fbiPixelsOut].u++;
}
/* advance our pointers */
@@ -3279,20 +3218,20 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
{
DECLARE_DITHER_POINTERS;
- if (LOG_LFB) v->device->logerror("VOODOO.%d.LFB:write pipelined mode %X (%d,%d) = %08X & %08X\n", v->index, LFBMODE_WRITE_FORMAT(v->reg[lfbMode].u), x, y, data, mem_mask);
+ if (LOG_LFB) vd->device->logerror("VOODOO.%d.LFB:write pipelined mode %X (%d,%d) = %08X & %08X\n", vd->index, LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask);
/* determine the screen Y */
scry = y;
- if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
- scry = (v->fbi.yorigin - y) & 0x3ff;
+ if (FBZMODE_Y_ORIGIN(vd->reg[fbzMode].u))
+ scry = (vd->fbi.yorigin - y) & 0x3ff;
/* advance pointers to the proper row */
- dest += scry * v->fbi.rowpixels;
+ dest += scry * vd->fbi.rowpixels;
if (depth)
- depth += scry * v->fbi.rowpixels;
+ depth += scry * vd->fbi.rowpixels;
/* compute dithering */
- COMPUTE_DITHER_POINTERS(v->reg[fbzMode].u, y);
+ COMPUTE_DITHER_POINTERS(vd->reg[fbzMode].u, y);
/* loop over up to two pixels */
for (pix = 0; mask; pix++)
@@ -3300,10 +3239,10 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
/* make sure we care about this pixel */
if (mask & 0x0f)
{
- stats_block *stats = &v->fbi.lfb_stats;
+ stats_block *stats = &vd->fbi.lfb_stats;
INT64 iterw;
- if (LFBMODE_WRITE_W_SELECT(v->reg[lfbMode].u)) {
- iterw = (UINT32) v->reg[zaColor].u << 16;
+ if (LFBMODE_WRITE_W_SELECT(vd->reg[lfbMode].u)) {
+ iterw = (UINT32) vd->reg[zaColor].u << 16;
} else {
// The most significant fractional bits of 16.32 W are set to z
iterw = (UINT32) sw[pix] << 16;
@@ -3311,12 +3250,12 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
INT32 iterz = sw[pix] << 12;
/* apply clipping */
- if (FBZMODE_ENABLE_CLIPPING(v->reg[fbzMode].u))
+ if (FBZMODE_ENABLE_CLIPPING(vd->reg[fbzMode].u))
{
- if (x < ((v->reg[clipLeftRight].u >> 16) & 0x3ff) ||
- x >= (v->reg[clipLeftRight].u & 0x3ff) ||
- scry < ((v->reg[clipLowYHighY].u >> 16) & 0x3ff) ||
- scry >= (v->reg[clipLowYHighY].u & 0x3ff))
+ if (x < ((vd->reg[clipLeftRight].u >> 16) & 0x3ff) ||
+ x >= (vd->reg[clipLeftRight].u & 0x3ff) ||
+ scry < ((vd->reg[clipLowYHighY].u >> 16) & 0x3ff) ||
+ scry >= (vd->reg[clipLowYHighY].u & 0x3ff))
{
stats->pixels_in++;
stats->clip_fail++;
@@ -3329,7 +3268,7 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
/* pixel pipeline part 1 handles depth testing and stippling */
- //PIXEL_PIPELINE_BEGIN(v, stats, x, y, v->reg[fbzColorPath].u, v->reg[fbzMode].u, iterz, iterw);
+ //PIXEL_PIPELINE_BEGIN(v, stats, x, y, vd->reg[fbzColorPath].u, vd->reg[fbzMode].u, iterz, iterw);
// Start PIXEL_PIPE_BEGIN copy
//#define PIXEL_PIPELINE_BEGIN(VV, STATS, XX, YY, FBZCOLORPATH, FBZMODE, ITERZ, ITERW)
INT32 fogdepth, biasdepth;
@@ -3341,15 +3280,15 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
/* note that for perf reasons, we assume the caller has done clipping */
/* handle stippling */
- if (FBZMODE_ENABLE_STIPPLE(v->reg[fbzMode].u))
+ if (FBZMODE_ENABLE_STIPPLE(vd->reg[fbzMode].u))
{
/* rotate mode */
- if (FBZMODE_STIPPLE_PATTERN(v->reg[fbzMode].u) == 0)
+ if (FBZMODE_STIPPLE_PATTERN(vd->reg[fbzMode].u) == 0)
{
- v->reg[stipple].u = (v->reg[stipple].u << 1) | (v->reg[stipple].u >> 31);
- if ((v->reg[stipple].u & 0x80000000) == 0)
+ vd->reg[stipple].u = (vd->reg[stipple].u << 1) | (vd->reg[stipple].u >> 31);
+ if ((vd->reg[stipple].u & 0x80000000) == 0)
{
- v->stats.total_stippled++;
+ vd->stats.total_stippled++;
goto skipdrawdepth;
}
}
@@ -3358,9 +3297,9 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
else
{
int stipple_index = ((y & 3) << 3) | (~x & 7);
- if (((v->reg[stipple].u >> stipple_index) & 1) == 0)
+ if (((vd->reg[stipple].u >> stipple_index) & 1) == 0)
{
- v->stats.total_stippled++;
+ vd->stats.total_stippled++;
goto nextpixel;
}
}
@@ -3372,29 +3311,29 @@ static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask)
/* Perform depth testing */
- if (!depthTest((UINT16) v->reg[zaColor].u, stats, depth[x], v->reg[fbzMode].u, biasdepth))
+ if (!depthTest((UINT16) vd->reg[zaColor].u, stats, depth[x], vd->reg[fbzMode].u, biasdepth))
goto nextpixel;
/* use the RGBA we stashed above */
color.set(sa[pix], sr[pix], sg[pix], sb[pix]);
/* handle chroma key */
- if (!chromaKeyTest(v, stats, v->reg[fbzMode].u, color))
+ if (!chromaKeyTest(vd, stats, vd->reg[fbzMode].u, color))
goto nextpixel;
/* handle alpha mask */
- if (!alphaMaskTest(stats, v->reg[fbzMode].u, color.get_a()))
+ if (!alphaMaskTest(stats, vd->reg[fbzMode].u, color.get_a()))
goto nextpixel;
/* handle alpha test */
- if (!alphaTest(v, stats, v->reg[alphaMode].u, color.get_a()))
+ if (!alphaTest(vd, stats, vd->reg[alphaMode].u, color.get_a()))
goto nextpixel;
/* wait for any outstanding work to finish */
- poly_wait(v->poly, "LFB Write");
+ poly_wait(vd->poly, "LFB Write");
/* pixel pipeline part 2 handles color combine, fog, alpha, and final output */
- PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth,
- v->reg[fbzMode].u, v->reg[fbzColorPath].u, v->reg[alphaMode].u, v->reg[fogMode].u,
+ PIXEL_PIPELINE_END(vd, stats, dither, dither4, dither_lookup, x, dest, depth,
+ vd->reg[fbzMode].u, vd->reg[fbzColorPath].u, vd->reg[alphaMode].u, vd->reg[fogMode].u,
iterz, iterw, iterargb) {};
nextpixel:
/* advance our pointers */
@@ -3414,24 +3353,24 @@ nextpixel:
*
*************************************/
-static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
+INT32 voodoo_device::texture_w(voodoo_device *vd, offs_t offset, UINT32 data)
{
int tmunum = (offset >> 19) & 0x03;
tmu_state *t;
/* statistics */
- v->stats.tex_writes++;
+ vd->stats.tex_writes++;
/* point to the right TMU */
- if (!(v->chipmask & (2 << tmunum)))
+ if (!(vd->chipmask & (2 << tmunum)))
return 0;
- t = &v->tmu[tmunum];
+ t = &vd->tmu[tmunum];
if (TEXLOD_TDIRECT_WRITE(t->reg[tLOD].u))
fatalerror("Texture direct write!\n");
/* wait for any outstanding work to finish */
- poly_wait(v->poly, "Texture write");
+ poly_wait(vd->poly, "Texture write");
/* update texture info if dirty */
if (t->regdirty)
@@ -3451,13 +3390,13 @@ static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
UINT8 *dest;
/* extract info */
- if (v->type <= TYPE_VOODOO_2)
+ if (vd->vd_type <= TYPE_VOODOO_2)
{
lod = (offset >> 15) & 0x0f;
tt = (offset >> 7) & 0xff;
/* old code has a bit about how this is broken in gauntleg unless we always look at TMU0 */
- if (TEXMODE_SEQ_8_DOWNLD(v->tmu[0].reg/*t->reg*/[textureMode].u))
+ if (TEXMODE_SEQ_8_DOWNLD(vd->tmu[0].reg/*t->reg*/[textureMode].u))
ts = (offset << 2) & 0xfc;
else
ts = (offset << 1) & 0xfc;
@@ -3470,13 +3409,13 @@ static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
tbaseaddr = t->lodoffset[lod];
tbaseaddr += tt * ((t->wmask >> lod) + 1) + ts;
- if (LOG_TEXTURE_RAM) v->device->logerror("Texture 8-bit w: lod=%d s=%d t=%d data=%08X\n", lod, ts, tt, data);
+ if (LOG_TEXTURE_RAM) vd->device->logerror("Texture 8-bit w: lod=%d s=%d t=%d data=%08X\n", lod, ts, tt, data);
}
else
{
tbaseaddr = t->lodoffset[0] + offset*4;
- if (LOG_TEXTURE_RAM) v->device->logerror("Texture 8-bit w: offset=%X data=%08X\n", offset*4, data);
+ if (LOG_TEXTURE_RAM) vd->device->logerror("Texture 8-bit w: offset=%X data=%08X\n", offset*4, data);
}
/* write the four bytes in little-endian order */
@@ -3496,7 +3435,7 @@ static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
UINT16 *dest;
/* extract info */
- if (v->type <= TYPE_VOODOO_2)
+ if (vd->vd_type <= TYPE_VOODOO_2)
{
lod = (offset >> 15) & 0x0f;
tt = (offset >> 7) & 0xff;
@@ -3510,13 +3449,13 @@ static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
tbaseaddr = t->lodoffset[lod];
tbaseaddr += 2 * (tt * ((t->wmask >> lod) + 1) + ts);
- if (LOG_TEXTURE_RAM) v->device->logerror("Texture 16-bit w: lod=%d s=%d t=%d data=%08X\n", lod, ts, tt, data);
+ if (LOG_TEXTURE_RAM) vd->device->logerror("Texture 16-bit w: lod=%d s=%d t=%d data=%08X\n", lod, ts, tt, data);
}
else
{
tbaseaddr = t->lodoffset[0] + offset*4;
- if (LOG_TEXTURE_RAM) v->device->logerror("Texture 16-bit w: offset=%X data=%08X\n", offset*4, data);
+ if (LOG_TEXTURE_RAM) vd->device->logerror("Texture 16-bit w: offset=%X data=%08X\n", offset*4, data);
}
/* write the two words in little-endian order */
@@ -3538,7 +3477,7 @@ static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data)
*
*************************************/
-static void flush_fifos(voodoo_state *v, attotime current_time)
+void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time)
{
static UINT8 in_flush;
@@ -3547,14 +3486,14 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
return;
in_flush = TRUE;
- if (!v->pci.op_pending) fatalerror("flush_fifos called with no pending operation\n");
+ if (!vd->pci.op_pending) fatalerror("flush_fifos called with no pending operation\n");
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:flush_fifos start -- pending=%d.%08X%08X cur=%d.%08X%08X\n", v->index,
- v->pci.op_end_time.seconds(), (UINT32)(v->pci.op_end_time.attoseconds() >> 32), (UINT32)v->pci.op_end_time.attoseconds(),
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:flush_fifos start -- pending=%d.%08X%08X cur=%d.%08X%08X\n", vd->index,
+ vd->pci.op_end_time.seconds(), (UINT32)(vd->pci.op_end_time.attoseconds() >> 32), (UINT32)vd->pci.op_end_time.attoseconds(),
current_time.seconds(), (UINT32)(current_time.attoseconds() >> 32), (UINT32)current_time.attoseconds());
/* loop while we still have cycles to burn */
- while (v->pci.op_end_time <= current_time)
+ while (vd->pci.op_end_time <= current_time)
{
INT32 extra_cycles = 0;
INT32 cycles;
@@ -3567,27 +3506,27 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
UINT32 data;
/* we might be in CMDFIFO mode */
- if (v->fbi.cmdfifo[0].enable)
+ if (vd->fbi.cmdfifo[0].enable)
{
/* if we don't have anything to execute, we're done for now */
- cycles = cmdfifo_execute_if_ready(v, &v->fbi.cmdfifo[0]);
+ cycles = cmdfifo_execute_if_ready(vd, &vd->fbi.cmdfifo[0]);
if (cycles == -1)
{
- v->pci.op_pending = FALSE;
+ vd->pci.op_pending = FALSE;
in_flush = FALSE;
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", v->index);
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", vd->index);
return;
}
}
- else if (v->fbi.cmdfifo[1].enable)
+ else if (vd->fbi.cmdfifo[1].enable)
{
/* if we don't have anything to execute, we're done for now */
- cycles = cmdfifo_execute_if_ready(v, &v->fbi.cmdfifo[1]);
+ cycles = cmdfifo_execute_if_ready(vd, &vd->fbi.cmdfifo[1]);
if (cycles == -1)
{
- v->pci.op_pending = FALSE;
+ vd->pci.op_pending = FALSE;
in_flush = FALSE;
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", v->index);
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", vd->index);
return;
}
}
@@ -3596,15 +3535,15 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
else
{
/* choose which FIFO to read from */
- if (!fifo_empty(&v->fbi.fifo))
- fifo = &v->fbi.fifo;
- else if (!fifo_empty(&v->pci.fifo))
- fifo = &v->pci.fifo;
+ if (!fifo_empty(&vd->fbi.fifo))
+ fifo = &vd->fbi.fifo;
+ else if (!fifo_empty(&vd->pci.fifo))
+ fifo = &vd->pci.fifo;
else
{
- v->pci.op_pending = FALSE;
+ vd->pci.op_pending = FALSE;
in_flush = FALSE;
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- FIFOs empty\n", v->index);
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- FIFOs empty\n", vd->index);
return;
}
@@ -3614,9 +3553,9 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
/* target the appropriate location */
if ((address & (0xc00000/4)) == 0)
- cycles = register_w(v, address, data);
+ cycles = register_w(vd, address, data);
else if (address & (0x800000/4))
- cycles = texture_w(v, address, data);
+ cycles = texture_w(vd, address, data);
else
{
UINT32 mem_mask = 0xffffffff;
@@ -3628,7 +3567,7 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
mem_mask &= 0xffff0000;
address &= 0xffffff;
- cycles = lfb_w(v, address, data, mem_mask);
+ cycles = lfb_w(vd, address, data, mem_mask);
}
}
@@ -3645,15 +3584,15 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
cycles += extra_cycles;
/* account for those cycles */
- v->pci.op_end_time += attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle);
+ vd->pci.op_end_time += attotime(0, (attoseconds_t)cycles * vd->attoseconds_per_cycle);
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:update -- pending=%d.%08X%08X cur=%d.%08X%08X\n", v->index,
- v->pci.op_end_time.seconds(), (UINT32)(v->pci.op_end_time.attoseconds() >> 32), (UINT32)v->pci.op_end_time.attoseconds(),
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:update -- pending=%d.%08X%08X cur=%d.%08X%08X\n", vd->index,
+ vd->pci.op_end_time.seconds(), (UINT32)(vd->pci.op_end_time.attoseconds() >> 32), (UINT32)vd->pci.op_end_time.attoseconds(),
current_time.seconds(), (UINT32)(current_time.attoseconds() >> 32), (UINT32)current_time.attoseconds());
}
- if (LOG_FIFO_VERBOSE) v->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- pending command complete at %d.%08X%08X\n", v->index,
- v->pci.op_end_time.seconds(), (UINT32)(v->pci.op_end_time.attoseconds() >> 32), (UINT32)v->pci.op_end_time.attoseconds());
+ if (LOG_FIFO_VERBOSE) vd->device->logerror("VOODOO.%d.FIFO:flush_fifos end -- pending command complete at %d.%08X%08X\n", vd->index,
+ vd->pci.op_end_time.seconds(), (UINT32)(vd->pci.op_end_time.attoseconds() >> 32), (UINT32)vd->pci.op_end_time.attoseconds());
in_flush = FALSE;
}
@@ -3669,18 +3608,17 @@ static void flush_fifos(voodoo_state *v, attotime current_time)
WRITE32_MEMBER( voodoo_device::voodoo_w )
{
- voodoo_state *v = get_safe_token(this);
int stall = FALSE;
g_profiler.start(PROFILER_USER1);
/* should not be getting accesses while stalled */
- if (v->pci.stall_state != NOT_STALLED)
+ if (pci.stall_state != NOT_STALLED)
logerror("voodoo_w while stalled!\n");
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
/* special handling for registers */
if ((offset & 0xc00000/4) == 0)
@@ -3688,10 +3626,10 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
UINT8 access;
/* some special stuff for Voodoo 2 */
- if (v->type >= TYPE_VOODOO_2)
+ if (vd_type >= TYPE_VOODOO_2)
{
/* we might be in CMDFIFO mode */
- if (FBIINIT7_CMDFIFO_ENABLE(v->reg[fbiInit7].u))
+ if (FBIINIT7_CMDFIFO_ENABLE(reg[fbiInit7].u))
{
/* if bit 21 is set, we're writing to the FIFO */
if (offset & 0x200000/4)
@@ -3699,20 +3637,20 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
/* check for byte swizzling (bit 18) */
if (offset & 0x40000/4)
data = FLIPENDIAN_INT32(data);
- cmdfifo_w(v, &v->fbi.cmdfifo[0], offset & 0xffff, data);
+ cmdfifo_w(this, &fbi.cmdfifo[0], offset & 0xffff, data);
g_profiler.stop();
return;
}
/* we're a register access; but only certain ones are allowed */
- access = v->regaccess[offset & 0xff];
+ access = regaccess[offset & 0xff];
if (!(access & REGISTER_WRITETHRU))
{
/* track swap buffers regardless */
if ((offset & 0xff) == swapbufferCMD)
- v->fbi.swaps_pending++;
+ fbi.swaps_pending++;
- logerror("Ignoring write to %s in CMDFIFO mode\n", v->regnames[offset & 0xff]);
+ logerror("Ignoring write to %s in CMDFIFO mode\n", regnames[offset & 0xff]);
g_profiler.stop();
return;
}
@@ -3725,7 +3663,7 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
/* check the access behavior; note that the table works even if the */
/* alternate mapping is used */
- access = v->regaccess[offset & 0xff];
+ access = regaccess[offset & 0xff];
/* ignore if writes aren't allowed */
if (!(access & REGISTER_WRITE))
@@ -3740,31 +3678,31 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
/* track swap buffers */
if ((offset & 0xff) == swapbufferCMD)
- v->fbi.swaps_pending++;
+ fbi.swaps_pending++;
}
/* if we don't have anything pending, or if FIFOs are disabled, just execute */
- if (!v->pci.op_pending || !INITEN_ENABLE_PCI_FIFO(v->pci.init_enable))
+ if (!pci.op_pending || !INITEN_ENABLE_PCI_FIFO(pci.init_enable))
{
int cycles;
/* target the appropriate location */
if ((offset & (0xc00000/4)) == 0)
- cycles = register_w(v, offset, data);
+ cycles = register_w(this, offset, data);
else if (offset & (0x800000/4))
- cycles = texture_w(v, offset, data);
+ cycles = texture_w(this, offset, data);
else
- cycles = lfb_w(v, offset, data, mem_mask);
+ cycles = lfb_w(this, offset, data, mem_mask);
/* if we ended up with cycles, mark the operation pending */
if (cycles)
{
- v->pci.op_pending = TRUE;
- v->pci.op_end_time = machine().time() + attotime(0, (attoseconds_t)cycles * v->attoseconds_per_cycle);
+ pci.op_pending = TRUE;
+ pci.op_end_time = machine().time() + attotime(0, (attoseconds_t)cycles * attoseconds_per_cycle);
- if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index,
+ if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", index,
machine().time().seconds(), (UINT32)(machine().time().attoseconds() >> 32), (UINT32)machine().time().attoseconds(),
- v->pci.op_end_time.seconds(), (UINT32)(v->pci.op_end_time.attoseconds() >> 32), (UINT32)v->pci.op_end_time.attoseconds());
+ pci.op_end_time.seconds(), (UINT32)(pci.op_end_time.attoseconds() >> 32), (UINT32)pci.op_end_time.attoseconds());
}
g_profiler.stop();
return;
@@ -3780,56 +3718,56 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
}
/* if there's room in the PCI FIFO, add there */
- if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w adding to PCI FIFO @ %08X=%08X\n", v->index, offset, data);
- if (!fifo_full(&v->pci.fifo))
+ if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w adding to PCI FIFO @ %08X=%08X\n", this, offset, data);
+ if (!fifo_full(&pci.fifo))
{
- fifo_add(&v->pci.fifo, offset);
- fifo_add(&v->pci.fifo, data);
+ fifo_add(&pci.fifo, offset);
+ fifo_add(&pci.fifo, data);
}
else
fatalerror("PCI FIFO full\n");
/* handle flushing to the memory FIFO */
- if (FBIINIT0_ENABLE_MEMORY_FIFO(v->reg[fbiInit0].u) &&
- fifo_space(&v->pci.fifo) <= 2 * FBIINIT4_MEMORY_FIFO_LWM(v->reg[fbiInit4].u))
+ if (FBIINIT0_ENABLE_MEMORY_FIFO(reg[fbiInit0].u) &&
+ fifo_space(&pci.fifo) <= 2 * FBIINIT4_MEMORY_FIFO_LWM(reg[fbiInit4].u))
{
UINT8 valid[4];
/* determine which types of data can go to the memory FIFO */
valid[0] = TRUE;
- valid[1] = FBIINIT0_LFB_TO_MEMORY_FIFO(v->reg[fbiInit0].u);
- valid[2] = valid[3] = FBIINIT0_TEXMEM_TO_MEMORY_FIFO(v->reg[fbiInit0].u);
+ valid[1] = FBIINIT0_LFB_TO_MEMORY_FIFO(reg[fbiInit0].u);
+ valid[2] = valid[3] = FBIINIT0_TEXMEM_TO_MEMORY_FIFO(reg[fbiInit0].u);
/* flush everything we can */
- if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w moving PCI FIFO to memory FIFO\n", v->index);
- while (!fifo_empty(&v->pci.fifo) && valid[(fifo_peek(&v->pci.fifo) >> 22) & 3])
+ if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w moving PCI FIFO to memory FIFO\n", index);
+ while (!fifo_empty(&pci.fifo) && valid[(fifo_peek(&pci.fifo) >> 22) & 3])
{
- fifo_add(&v->fbi.fifo, fifo_remove(&v->pci.fifo));
- fifo_add(&v->fbi.fifo, fifo_remove(&v->pci.fifo));
+ fifo_add(&fbi.fifo, fifo_remove(&pci.fifo));
+ fifo_add(&fbi.fifo, fifo_remove(&pci.fifo));
}
/* if we're above the HWM as a result, stall */
- if (FBIINIT0_STALL_PCIE_FOR_HWM(v->reg[fbiInit0].u) &&
- fifo_items(&v->fbi.fifo) >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(v->reg[fbiInit0].u))
+ if (FBIINIT0_STALL_PCIE_FOR_HWM(reg[fbiInit0].u) &&
+ fifo_items(&fbi.fifo) >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(reg[fbiInit0].u))
{
- if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", v->index);
- stall_cpu(v, STALLED_UNTIL_FIFO_LWM, machine().time());
+ if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", index);
+ stall_cpu(this, STALLED_UNTIL_FIFO_LWM, machine().time());
}
}
/* if we're at the LWM for the PCI FIFO, stall */
- if (FBIINIT0_STALL_PCIE_FOR_HWM(v->reg[fbiInit0].u) &&
- fifo_space(&v->pci.fifo) <= 2 * FBIINIT0_PCI_FIFO_LWM(v->reg[fbiInit0].u))
+ if (FBIINIT0_STALL_PCIE_FOR_HWM(reg[fbiInit0].u) &&
+ fifo_space(&pci.fifo) <= 2 * FBIINIT0_PCI_FIFO_LWM(reg[fbiInit0].u))
{
- if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", v->index);
- stall_cpu(v, STALLED_UNTIL_FIFO_LWM, machine().time());
+ if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", index);
+ stall_cpu(this, STALLED_UNTIL_FIFO_LWM, machine().time());
}
/* if we weren't ready, and this is a non-FIFO access, stall until the FIFOs are clear */
if (stall)
{
- if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n", v->index);
- stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, machine().time());
+ if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n", index);
+ stall_cpu(this, STALLED_UNTIL_FIFO_EMPTY, machine().time());
}
g_profiler.stop();
@@ -3843,70 +3781,71 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
*
*************************************/
-static UINT32 register_r(voodoo_state *v, offs_t offset)
+static UINT32 register_r(voodoo_device *vd, offs_t offset)
{
+
int regnum = offset & 0xff;
UINT32 result;
/* statistics */
- v->stats.reg_reads++;
+ vd->stats.reg_reads++;
/* first make sure this register is readable */
- if (!(v->regaccess[regnum] & REGISTER_READ))
+ if (!(vd->regaccess[regnum] & REGISTER_READ))
{
- v->device->logerror("VOODOO.%d.ERROR:Invalid attempt to read %s\n", v->index, regnum < 225 ? v->regnames[regnum] : "unknown register");
+ vd->device->logerror("VOODOO.%d.ERROR:Invalid attempt to read %s\n", vd->index, regnum < 225 ? vd->regnames[regnum] : "unknown register");
return 0xffffffff;
}
/* default result is the FBI register value */
- result = v->reg[regnum].u;
+ result = vd->reg[regnum].u;
/* some registers are dynamic; compute them */
switch (regnum)
{
- case status:
+ case vdstatus:
/* start with a blank slate */
result = 0;
/* bits 5:0 are the PCI FIFO free space */
- if (fifo_empty(&v->pci.fifo))
+ if (fifo_empty(&vd->pci.fifo))
result |= 0x3f << 0;
else
{
- int temp = fifo_space(&v->pci.fifo)/2;
+ int temp = fifo_space(&vd->pci.fifo)/2;
if (temp > 0x3f)
temp = 0x3f;
result |= temp << 0;
}
/* bit 6 is the vertical retrace */
- result |= v->fbi.vblank << 6;
+ result |= vd->fbi.vblank << 6;
/* bit 7 is FBI graphics engine busy */
- if (v->pci.op_pending)
+ if (vd->pci.op_pending)
result |= 1 << 7;
/* bit 8 is TREX busy */
- if (v->pci.op_pending)
+ if (vd->pci.op_pending)
result |= 1 << 8;
/* bit 9 is overall busy */
- if (v->pci.op_pending)
+ if (vd->pci.op_pending)
result |= 1 << 9;
/* Banshee is different starting here */
- if (v->type < TYPE_VOODOO_BANSHEE)
+ if (vd->vd_type < TYPE_VOODOO_BANSHEE)
{
/* bits 11:10 specifies which buffer is visible */
- result |= v->fbi.frontbuf << 10;
+ result |= vd->fbi.frontbuf << 10;
/* bits 27:12 indicate memory FIFO freespace */
- if (!FBIINIT0_ENABLE_MEMORY_FIFO(v->reg[fbiInit0].u) || fifo_empty(&v->fbi.fifo))
+ if (!FBIINIT0_ENABLE_MEMORY_FIFO(vd->reg[fbiInit0].u) || fifo_empty(&vd->fbi.fifo))
result |= 0xffff << 12;
else
{
- int temp = fifo_space(&v->fbi.fifo)/2;
+ int temp = fifo_space(&vd->fbi.fifo)/2;
if (temp > 0xffff)
temp = 0xffff;
result |= temp << 12;
@@ -3917,38 +3856,38 @@ static UINT32 register_r(voodoo_state *v, offs_t offset)
/* bit 10 is 2D busy */
/* bit 11 is cmd FIFO 0 busy */
- if (v->fbi.cmdfifo[0].enable && v->fbi.cmdfifo[0].depth > 0)
+ if (vd->fbi.cmdfifo[0].enable && vd->fbi.cmdfifo[0].depth > 0)
result |= 1 << 11;
/* bit 12 is cmd FIFO 1 busy */
- if (v->fbi.cmdfifo[1].enable && v->fbi.cmdfifo[1].depth > 0)
+ if (vd->fbi.cmdfifo[1].enable && vd->fbi.cmdfifo[1].depth > 0)
result |= 1 << 12;
}
/* bits 30:28 are the number of pending swaps */
- if (v->fbi.swaps_pending > 7)
+ if (vd->fbi.swaps_pending > 7)
result |= 7 << 28;
else
- result |= v->fbi.swaps_pending << 28;
+ result |= vd->fbi.swaps_pending << 28;
/* bit 31 is not used */
/* eat some cycles since people like polling here */
- if (EAT_CYCLES) v->cpu->execute().eat_cycles(1000);
+ if (EAT_CYCLES) vd->cpu->execute().eat_cycles(1000);
break;
/* bit 2 of the initEnable register maps this to dacRead */
case fbiInit2:
- if (INITEN_REMAP_INIT_TO_DAC(v->pci.init_enable))
- result = v->dac.read_result;
+ if (INITEN_REMAP_INIT_TO_DAC(vd->pci.init_enable))
+ result = vd->dac.read_result;
break;
/* return the current scanline for now */
case vRetrace:
/* eat some cycles since people like polling here */
- if (EAT_CYCLES) v->cpu->execute().eat_cycles(10);
- result = v->screen->vpos();
+ if (EAT_CYCLES) vd->cpu->execute().eat_cycles(10);
+ result = vd->screen->vpos();
break;
/* reserved area in the TMU read by the Vegas startup sequence */
@@ -3959,26 +3898,26 @@ static UINT32 register_r(voodoo_state *v, offs_t offset)
/* cmdFifo -- Voodoo2 only */
case cmdFifoRdPtr:
- result = v->fbi.cmdfifo[0].rdptr;
+ result = vd->fbi.cmdfifo[0].rdptr;
/* eat some cycles since people like polling here */
- if (EAT_CYCLES) v->cpu->execute().eat_cycles(1000);
+ if (EAT_CYCLES) vd->cpu->execute().eat_cycles(1000);
break;
case cmdFifoAMin:
- result = v->fbi.cmdfifo[0].amin;
+ result = vd->fbi.cmdfifo[0].amin;
break;
case cmdFifoAMax:
- result = v->fbi.cmdfifo[0].amax;
+ result = vd->fbi.cmdfifo[0].amax;
break;
case cmdFifoDepth:
- result = v->fbi.cmdfifo[0].depth;
+ result = vd->fbi.cmdfifo[0].depth;
break;
case cmdFifoHoles:
- result = v->fbi.cmdfifo[0].holes;
+ result = vd->fbi.cmdfifo[0].holes;
break;
/* all counters are 24-bit only */
@@ -3987,9 +3926,9 @@ static UINT32 register_r(voodoo_state *v, offs_t offset)
case fbiZfuncFail:
case fbiAfuncFail:
case fbiPixelsOut:
- update_statistics(v, TRUE);
+ update_statistics(vd, TRUE);
case fbiTrianglesOut:
- result = v->reg[regnum].u & 0xffffff;
+ result = vd->reg[regnum].u & 0xffffff;
break;
}
@@ -3998,19 +3937,19 @@ static UINT32 register_r(voodoo_state *v, offs_t offset)
int logit = TRUE;
/* don't log multiple identical status reads from the same address */
- if (regnum == status)
+ if (regnum == vdstatus)
{
- offs_t pc = v->cpu->safe_pc();
- if (pc == v->last_status_pc && result == v->last_status_value)
+ offs_t pc = vd->cpu->safe_pc();
+ if (pc == vd->last_status_pc && result == vd->last_status_value)
logit = FALSE;
- v->last_status_pc = pc;
- v->last_status_value = result;
+ vd->last_status_pc = pc;
+ vd->last_status_value = result;
}
if (regnum == cmdFifoRdPtr)
logit = FALSE;
if (logit)
- v->device->logerror("VOODOO.%d.REG:%s read = %08X\n", v->index, v->regnames[regnum], result);
+ vd->device->logerror("VOODOO.%d.REG:%s read = %08X\n", vd->index, vd->regnames[regnum], result);
}
return result;
@@ -4024,7 +3963,7 @@ static UINT32 register_r(voodoo_state *v, offs_t offset)
*
*************************************/
-static UINT32 lfb_r(voodoo_state *v, offs_t offset, bool lfb_3d)
+static UINT32 lfb_r(voodoo_device *vd, offs_t offset, bool lfb_3d)
{
UINT16 *buffer;
UINT32 bufmax;
@@ -4033,34 +3972,34 @@ static UINT32 lfb_r(voodoo_state *v, offs_t offset, bool lfb_3d)
int x, y, scry, destbuf;
/* statistics */
- v->stats.lfb_reads++;
+ vd->stats.lfb_reads++;
/* compute X,Y */
offset <<= 1;
- x = offset & ((1 << v->fbi.lfb_stride) - 1);
- y = (offset >> v->fbi.lfb_stride);
+ x = offset & ((1 << vd->fbi.lfb_stride) - 1);
+ y = (offset >> vd->fbi.lfb_stride);
/* select the target buffer */
if (lfb_3d) {
y &= 0x3ff;
- destbuf = (v->type >= TYPE_VOODOO_BANSHEE) ? 1 : LFBMODE_READ_BUFFER_SELECT(v->reg[lfbMode].u);
+ destbuf = (vd->vd_type >= TYPE_VOODOO_BANSHEE) ? 1 : LFBMODE_READ_BUFFER_SELECT(vd->reg[lfbMode].u);
switch (destbuf)
{
case 0: /* front buffer */
- buffer = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
- bufmax = (v->fbi.mask + 1 - v->fbi.rgboffs[v->fbi.frontbuf]) / 2;
+ buffer = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.frontbuf]);
+ bufmax = (vd->fbi.mask + 1 - vd->fbi.rgboffs[vd->fbi.frontbuf]) / 2;
break;
case 1: /* back buffer */
- buffer = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.backbuf]);
- bufmax = (v->fbi.mask + 1 - v->fbi.rgboffs[v->fbi.backbuf]) / 2;
+ buffer = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.backbuf]);
+ bufmax = (vd->fbi.mask + 1 - vd->fbi.rgboffs[vd->fbi.backbuf]) / 2;
break;
case 2: /* aux buffer */
- if (v->fbi.auxoffs == ~0)
+ if (vd->fbi.auxoffs == ~0)
return 0xffffffff;
- buffer = (UINT16 *)(v->fbi.ram + v->fbi.auxoffs);
- bufmax = (v->fbi.mask + 1 - v->fbi.auxoffs) / 2;
+ buffer = (UINT16 *)(vd->fbi.ram + vd->fbi.auxoffs);
+ bufmax = (vd->fbi.mask + 1 - vd->fbi.auxoffs) / 2;
break;
default: /* reserved */
@@ -4069,37 +4008,37 @@ static UINT32 lfb_r(voodoo_state *v, offs_t offset, bool lfb_3d)
/* determine the screen Y */
scry = y;
- if (LFBMODE_Y_ORIGIN(v->reg[lfbMode].u))
- scry = (v->fbi.yorigin - y) & 0x3ff;
+ if (LFBMODE_Y_ORIGIN(vd->reg[lfbMode].u))
+ scry = (vd->fbi.yorigin - y) & 0x3ff;
} else {
// Direct lfb access
- buffer = (UINT16 *)(v->fbi.ram + v->fbi.lfb_base*4);
- bufmax = (v->fbi.mask + 1 - v->fbi.lfb_base*4) / 2;
+ buffer = (UINT16 *)(vd->fbi.ram + vd->fbi.lfb_base*4);
+ bufmax = (vd->fbi.mask + 1 - vd->fbi.lfb_base*4) / 2;
scry = y;
}
/* advance pointers to the proper row */
- bufoffs = scry * v->fbi.rowpixels + x;
+ bufoffs = scry * vd->fbi.rowpixels + x;
if (bufoffs >= bufmax) {
- v->device->logerror("LFB_R: Buffer offset out of bounds x=%i y=%i lfb_3d=%i offset=%08X bufoffs=%08X\n", x, y, lfb_3d, offset, (UINT32) bufoffs);
+ vd->device->logerror("LFB_R: Buffer offset out of bounds x=%i y=%i lfb_3d=%i offset=%08X bufoffs=%08X\n", x, y, lfb_3d, offset, (UINT32) bufoffs);
return 0xffffffff;
}
/* wait for any outstanding work to finish */
- poly_wait(v->poly, "LFB read");
+ poly_wait(vd->poly, "LFB read");
/* compute the data */
data = buffer[bufoffs + 0] | (buffer[bufoffs + 1] << 16);
/* word swapping */
- if (LFBMODE_WORD_SWAP_READS(v->reg[lfbMode].u))
+ if (LFBMODE_WORD_SWAP_READS(vd->reg[lfbMode].u))
data = (data << 16) | (data >> 16);
/* byte swizzling */
- if (LFBMODE_BYTE_SWIZZLE_READS(v->reg[lfbMode].u))
+ if (LFBMODE_BYTE_SWIZZLE_READS(vd->reg[lfbMode].u))
data = FLIPENDIAN_INT32(data);
- if (LOG_LFB) v->device->logerror("VOODOO.%d.LFB:read (%d,%d) = %08X\n", v->index, x, y, data);
+ if (LOG_LFB) vd->device->logerror("VOODOO.%d.LFB:read (%d,%d) = %08X\n", vd->index, x, y, data);
return data;
}
@@ -4114,17 +4053,16 @@ static UINT32 lfb_r(voodoo_state *v, offs_t offset, bool lfb_3d)
READ32_MEMBER( voodoo_device::voodoo_r )
{
- voodoo_state *v = get_safe_token(this);
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
/* target the appropriate location */
if (!(offset & (0xc00000/4)))
- return register_r(v, offset);
+ return register_r(this, offset);
else if (!(offset & (0x800000/4)))
- return lfb_r(v, offset, true);
+ return lfb_r(this, offset, true);
return 0xffffffff;
}
@@ -4140,7 +4078,6 @@ READ32_MEMBER( voodoo_device::voodoo_r )
READ32_MEMBER( voodoo_banshee_device::banshee_agp_r )
{
- voodoo_state *v = get_safe_token(this);
UINT32 result;
offset &= 0x1ff/4;
@@ -4149,64 +4086,63 @@ READ32_MEMBER( voodoo_banshee_device::banshee_agp_r )
switch (offset)
{
case cmdRdPtrL0:
- result = v->fbi.cmdfifo[0].rdptr;
+ result = fbi.cmdfifo[0].rdptr;
break;
case cmdAMin0:
- result = v->fbi.cmdfifo[0].amin;
+ result = fbi.cmdfifo[0].amin;
break;
case cmdAMax0:
- result = v->fbi.cmdfifo[0].amax;
+ result = fbi.cmdfifo[0].amax;
break;
case cmdFifoDepth0:
- result = v->fbi.cmdfifo[0].depth;
+ result = fbi.cmdfifo[0].depth;
break;
case cmdHoleCnt0:
- result = v->fbi.cmdfifo[0].holes;
+ result = fbi.cmdfifo[0].holes;
break;
case cmdRdPtrL1:
- result = v->fbi.cmdfifo[1].rdptr;
+ result = fbi.cmdfifo[1].rdptr;
break;
case cmdAMin1:
- result = v->fbi.cmdfifo[1].amin;
+ result = fbi.cmdfifo[1].amin;
break;
case cmdAMax1:
- result = v->fbi.cmdfifo[1].amax;
+ result = fbi.cmdfifo[1].amax;
break;
case cmdFifoDepth1:
- result = v->fbi.cmdfifo[1].depth;
+ result = fbi.cmdfifo[1].depth;
break;
case cmdHoleCnt1:
- result = v->fbi.cmdfifo[1].holes;
+ result = fbi.cmdfifo[1].holes;
break;
default:
- result = v->banshee.agp[offset];
+ result = banshee.agp[offset];
break;
}
if (LOG_REGISTERS)
- logerror("%s:banshee_r(AGP:%s)\n", v->device->machine().describe_context(), banshee_agp_reg_name[offset]);
+ logerror("%s:banshee_r(AGP:%s)\n", device->machine().describe_context(), banshee_agp_reg_name[offset]);
return result;
}
READ32_MEMBER( voodoo_banshee_device::banshee_r )
{
- voodoo_state *v = get_safe_token(this);
UINT32 result = 0xffffffff;
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
if (offset < 0x80000/4)
result = banshee_io_r(space, offset, mem_mask);
@@ -4215,7 +4151,7 @@ READ32_MEMBER( voodoo_banshee_device::banshee_r )
else if (offset < 0x200000/4)
logerror("%s:banshee_r(2D:%X)\n", machine().describe_context(), (offset*4) & 0xfffff);
else if (offset < 0x600000/4)
- result = register_r(v, offset & 0x1fffff/4);
+ result = register_r(this, offset & 0x1fffff/4);
else if (offset < 0x800000/4)
logerror("%s:banshee_r(TEX0:%X)\n", machine().describe_context(), (offset*4) & 0x1fffff);
else if (offset < 0xa00000/4)
@@ -4226,7 +4162,7 @@ READ32_MEMBER( voodoo_banshee_device::banshee_r )
logerror("%s:banshee_r(YUV:%X)\n", machine().describe_context(), (offset*4) & 0x3fffff);
else if (offset < 0x2000000/4)
{
- result = lfb_r(v, offset & 0xffffff/4, true);
+ result = lfb_r(this, offset & 0xffffff/4, true);
} else {
logerror("%s:banshee_r(%X) Access out of bounds\n", machine().describe_context(), offset*4);
}
@@ -4236,27 +4172,26 @@ READ32_MEMBER( voodoo_banshee_device::banshee_r )
READ32_MEMBER( voodoo_banshee_device::banshee_fb_r )
{
- voodoo_state *v = get_safe_token(this);
UINT32 result = 0xffffffff;
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
- if (offset < v->fbi.lfb_base)
+ if (offset < fbi.lfb_base)
{
#if LOG_LFB
logerror("%s:banshee_fb_r(%X)\n", machine().describe_context(), offset*4);
#endif
- if (offset*4 <= v->fbi.mask)
- result = ((UINT32 *)v->fbi.ram)[offset];
+ if (offset*4 <= fbi.mask)
+ result = ((UINT32 *)fbi.ram)[offset];
else
logerror("%s:banshee_fb_r(%X) Access out of bounds\n", machine().describe_context(), offset*4);
}
else {
if (LOG_LFB)
- logerror("%s:banshee_fb_r(%X) to lfb_r: %08X lfb_base=%08X\n", machine().describe_context(), offset*4, offset - v->fbi.lfb_base, v->fbi.lfb_base);
- result = lfb_r(v, offset - v->fbi.lfb_base, false);
+ logerror("%s:banshee_fb_r(%X) to lfb_r: %08X lfb_base=%08X\n", machine().describe_context(), offset*4, offset - fbi.lfb_base, fbi.lfb_base);
+ result = lfb_r(this, offset - fbi.lfb_base, false);
}
return result;
}
@@ -4264,7 +4199,6 @@ READ32_MEMBER( voodoo_banshee_device::banshee_fb_r )
READ8_MEMBER( voodoo_banshee_device::banshee_vga_r )
{
- voodoo_state *v = get_safe_token(this);
UINT8 result = 0xff;
offset &= 0x1f;
@@ -4274,10 +4208,10 @@ READ8_MEMBER( voodoo_banshee_device::banshee_vga_r )
{
/* attribute access */
case 0x3c0:
- if (v->banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(v->banshee.att))
- result = v->banshee.att[v->banshee.vga[0x3c1 & 0x1f]];
+ if (banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(banshee.att))
+ result = banshee.att[banshee.vga[0x3c1 & 0x1f]];
if (LOG_REGISTERS)
- logerror("%s:banshee_att_r(%X)\n", machine().describe_context(), v->banshee.vga[0x3c1 & 0x1f]);
+ logerror("%s:banshee_att_r(%X)\n", machine().describe_context(), banshee.vga[0x3c1 & 0x1f]);
break;
/* Input status 0 */
@@ -4295,41 +4229,41 @@ READ8_MEMBER( voodoo_banshee_device::banshee_vga_r )
/* Sequencer access */
case 0x3c5:
- if (v->banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(v->banshee.seq))
- result = v->banshee.seq[v->banshee.vga[0x3c4 & 0x1f]];
+ if (banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(banshee.seq))
+ result = banshee.seq[banshee.vga[0x3c4 & 0x1f]];
if (LOG_REGISTERS)
- logerror("%s:banshee_seq_r(%X)\n", machine().describe_context(), v->banshee.vga[0x3c4 & 0x1f]);
+ logerror("%s:banshee_seq_r(%X)\n", machine().describe_context(), banshee.vga[0x3c4 & 0x1f]);
break;
/* Feature control */
case 0x3ca:
- result = v->banshee.vga[0x3da & 0x1f];
- v->banshee.attff = 0;
+ result = banshee.vga[0x3da & 0x1f];
+ banshee.attff = 0;
if (LOG_REGISTERS)
logerror("%s:banshee_vga_r(%X)\n", machine().describe_context(), 0x300+offset);
break;
/* Miscellaneous output */
case 0x3cc:
- result = v->banshee.vga[0x3c2 & 0x1f];
+ result = banshee.vga[0x3c2 & 0x1f];
if (LOG_REGISTERS)
logerror("%s:banshee_vga_r(%X)\n", machine().describe_context(), 0x300+offset);
break;
/* Graphics controller access */
case 0x3cf:
- if (v->banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(v->banshee.gc))
- result = v->banshee.gc[v->banshee.vga[0x3ce & 0x1f]];
+ if (banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(banshee.gc))
+ result = banshee.gc[banshee.vga[0x3ce & 0x1f]];
if (LOG_REGISTERS)
- logerror("%s:banshee_gc_r(%X)\n", machine().describe_context(), v->banshee.vga[0x3ce & 0x1f]);
+ logerror("%s:banshee_gc_r(%X)\n", machine().describe_context(), banshee.vga[0x3ce & 0x1f]);
break;
/* CRTC access */
case 0x3d5:
- if (v->banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(v->banshee.crtc))
- result = v->banshee.crtc[v->banshee.vga[0x3d4 & 0x1f]];
+ if (banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(banshee.crtc))
+ result = banshee.crtc[banshee.vga[0x3d4 & 0x1f]];
if (LOG_REGISTERS)
- logerror("%s:banshee_crtc_r(%X)\n", machine().describe_context(), v->banshee.vga[0x3d4 & 0x1f]);
+ logerror("%s:banshee_crtc_r(%X)\n", machine().describe_context(), banshee.vga[0x3d4 & 0x1f]);
break;
/* Input status 1 */
@@ -4349,7 +4283,7 @@ READ8_MEMBER( voodoo_banshee_device::banshee_vga_r )
break;
default:
- result = v->banshee.vga[offset];
+ result = banshee.vga[offset];
if (LOG_REGISTERS)
logerror("%s:banshee_vga_r(%X)\n", machine().describe_context(), 0x300+offset);
break;
@@ -4360,7 +4294,6 @@ READ8_MEMBER( voodoo_banshee_device::banshee_vga_r )
READ32_MEMBER( voodoo_banshee_device::banshee_io_r )
{
- voodoo_state *v = get_safe_token(this);
UINT32 result;
offset &= 0xff/4;
@@ -4369,13 +4302,13 @@ READ32_MEMBER( voodoo_banshee_device::banshee_io_r )
switch (offset)
{
case io_status:
- result = register_r(v, 0);
+ result = register_r(this, 0);
break;
case io_dacData:
- result = v->fbi.clut[v->banshee.io[io_dacAddr] & 0x1ff] = v->banshee.io[offset];
+ result = fbi.clut[banshee.io[io_dacAddr] & 0x1ff] = banshee.io[offset];
if (LOG_REGISTERS)
- logerror("%s:banshee_dac_r(%X)\n", machine().describe_context(), v->banshee.io[io_dacAddr] & 0x1ff);
+ logerror("%s:banshee_dac_r(%X)\n", machine().describe_context(), banshee.io[io_dacAddr] & 0x1ff);
break;
case io_vgab0: case io_vgab4: case io_vgab8: case io_vgabc:
@@ -4393,7 +4326,7 @@ READ32_MEMBER( voodoo_banshee_device::banshee_io_r )
break;
default:
- result = v->banshee.io[offset];
+ result = banshee.io[offset];
if (LOG_REGISTERS)
logerror("%s:banshee_io_r(%s)\n", machine().describe_context(), banshee_io_reg_name[offset]);
break;
@@ -4409,9 +4342,9 @@ READ32_MEMBER( voodoo_banshee_device::banshee_rom_r )
return 0xffffffff;
}
-static void blit_2d(voodoo_state *v, UINT32 data)
+static void blit_2d(voodoo_device *vd, UINT32 data)
{
- switch (v->banshee.blt_cmd)
+ switch (vd->banshee.blt_cmd)
{
case 0: // NOP - wait for idle
{
@@ -4434,46 +4367,46 @@ static void blit_2d(voodoo_state *v, UINT32 data)
case 3: // Host-to-screen blit
{
- UINT32 addr = v->banshee.blt_dst_base;
+ UINT32 addr = vd->banshee.blt_dst_base;
- addr += (v->banshee.blt_dst_y * v->banshee.blt_dst_stride) + (v->banshee.blt_dst_x * v->banshee.blt_dst_bpp);
+ addr += (vd->banshee.blt_dst_y * vd->banshee.blt_dst_stride) + (vd->banshee.blt_dst_x * vd->banshee.blt_dst_bpp);
#if LOG_BANSHEE_2D
- logerror(" blit_2d:host_to_screen: %08x -> %08x, %d, %d\n", data, addr, v->banshee.blt_dst_x, v->banshee.blt_dst_y);
+ logerror(" blit_2d:host_to_screen: %08x -> %08x, %d, %d\n", data, addr, vd->banshee.blt_dst_x, vd->banshee.blt_dst_y);
#endif
- switch (v->banshee.blt_dst_bpp)
+ switch (vd->banshee.blt_dst_bpp)
{
case 1:
- v->fbi.ram[addr+0] = data & 0xff;
- v->fbi.ram[addr+1] = (data >> 8) & 0xff;
- v->fbi.ram[addr+2] = (data >> 16) & 0xff;
- v->fbi.ram[addr+3] = (data >> 24) & 0xff;
- v->banshee.blt_dst_x += 4;
+ vd->fbi.ram[addr+0] = data & 0xff;
+ vd->fbi.ram[addr+1] = (data >> 8) & 0xff;
+ vd->fbi.ram[addr+2] = (data >> 16) & 0xff;
+ vd->fbi.ram[addr+3] = (data >> 24) & 0xff;
+ vd->banshee.blt_dst_x += 4;
break;
case 2:
- v->fbi.ram[addr+1] = data & 0xff;
- v->fbi.ram[addr+0] = (data >> 8) & 0xff;
- v->fbi.ram[addr+3] = (data >> 16) & 0xff;
- v->fbi.ram[addr+2] = (data >> 24) & 0xff;
- v->banshee.blt_dst_x += 2;
+ vd->fbi.ram[addr+1] = data & 0xff;
+ vd->fbi.ram[addr+0] = (data >> 8) & 0xff;
+ vd->fbi.ram[addr+3] = (data >> 16) & 0xff;
+ vd->fbi.ram[addr+2] = (data >> 24) & 0xff;
+ vd->banshee.blt_dst_x += 2;
break;
case 3:
- v->banshee.blt_dst_x += 1;
+ vd->banshee.blt_dst_x += 1;
break;
case 4:
- v->fbi.ram[addr+3] = data & 0xff;
- v->fbi.ram[addr+2] = (data >> 8) & 0xff;
- v->fbi.ram[addr+1] = (data >> 16) & 0xff;
- v->fbi.ram[addr+0] = (data >> 24) & 0xff;
- v->banshee.blt_dst_x += 1;
+ vd->fbi.ram[addr+3] = data & 0xff;
+ vd->fbi.ram[addr+2] = (data >> 8) & 0xff;
+ vd->fbi.ram[addr+1] = (data >> 16) & 0xff;
+ vd->fbi.ram[addr+0] = (data >> 24) & 0xff;
+ vd->banshee.blt_dst_x += 1;
break;
}
- if (v->banshee.blt_dst_x >= v->banshee.blt_dst_width)
+ if (vd->banshee.blt_dst_x >= vd->banshee.blt_dst_width)
{
- v->banshee.blt_dst_x = 0;
- v->banshee.blt_dst_y++;
+ vd->banshee.blt_dst_x = 0;
+ vd->banshee.blt_dst_y++;
}
break;
}
@@ -4500,12 +4433,12 @@ static void blit_2d(voodoo_state *v, UINT32 data)
default:
{
- fatalerror("blit_2d: unknown command %d\n", v->banshee.blt_cmd);
+ fatalerror("blit_2d: unknown command %d\n", vd->banshee.blt_cmd);
}
}
}
-static INT32 banshee_2d_w(voodoo_state *v, offs_t offset, UINT32 data)
+INT32 voodoo_device::banshee_2d_w(voodoo_device *vd, offs_t offset, UINT32 data)
{
switch (offset)
{
@@ -4514,152 +4447,152 @@ static INT32 banshee_2d_w(voodoo_state *v, offs_t offset, UINT32 data)
logerror(" 2D:command: cmd %d, ROP0 %02X\n", data & 0xf, data >> 24);
#endif
- v->banshee.blt_src_x = v->banshee.blt_regs[banshee2D_srcXY] & 0xfff;
- v->banshee.blt_src_y = (v->banshee.blt_regs[banshee2D_srcXY] >> 16) & 0xfff;
- v->banshee.blt_src_base = v->banshee.blt_regs[banshee2D_srcBaseAddr] & 0xffffff;
- v->banshee.blt_src_stride = v->banshee.blt_regs[banshee2D_srcFormat] & 0x3fff;
- v->banshee.blt_src_width = v->banshee.blt_regs[banshee2D_srcSize] & 0xfff;
- v->banshee.blt_src_height = (v->banshee.blt_regs[banshee2D_srcSize] >> 16) & 0xfff;
+ vd->banshee.blt_src_x = vd->banshee.blt_regs[banshee2D_srcXY] & 0xfff;
+ vd->banshee.blt_src_y = (vd->banshee.blt_regs[banshee2D_srcXY] >> 16) & 0xfff;
+ vd->banshee.blt_src_base = vd->banshee.blt_regs[banshee2D_srcBaseAddr] & 0xffffff;
+ vd->banshee.blt_src_stride = vd->banshee.blt_regs[banshee2D_srcFormat] & 0x3fff;
+ vd->banshee.blt_src_width = vd->banshee.blt_regs[banshee2D_srcSize] & 0xfff;
+ vd->banshee.blt_src_height = (vd->banshee.blt_regs[banshee2D_srcSize] >> 16) & 0xfff;
- switch ((v->banshee.blt_regs[banshee2D_srcFormat] >> 16) & 0xf)
+ switch ((vd->banshee.blt_regs[banshee2D_srcFormat] >> 16) & 0xf)
{
- case 1: v->banshee.blt_src_bpp = 1; break;
- case 3: v->banshee.blt_src_bpp = 2; break;
- case 4: v->banshee.blt_src_bpp = 3; break;
- case 5: v->banshee.blt_src_bpp = 4; break;
- case 8: v->banshee.blt_src_bpp = 2; break;
- case 9: v->banshee.blt_src_bpp = 2; break;
- default: v->banshee.blt_src_bpp = 1; break;
+ case 1: vd->banshee.blt_src_bpp = 1; break;
+ case 3: vd->banshee.blt_src_bpp = 2; break;
+ case 4: vd->banshee.blt_src_bpp = 3; break;
+ case 5: vd->banshee.blt_src_bpp = 4; break;
+ case 8: vd->banshee.blt_src_bpp = 2; break;
+ case 9: vd->banshee.blt_src_bpp = 2; break;
+ default: vd->banshee.blt_src_bpp = 1; break;
}
- v->banshee.blt_dst_x = v->banshee.blt_regs[banshee2D_dstXY] & 0xfff;
- v->banshee.blt_dst_y = (v->banshee.blt_regs[banshee2D_dstXY] >> 16) & 0xfff;
- v->banshee.blt_dst_base = v->banshee.blt_regs[banshee2D_dstBaseAddr] & 0xffffff;
- v->banshee.blt_dst_stride = v->banshee.blt_regs[banshee2D_dstFormat] & 0x3fff;
- v->banshee.blt_dst_width = v->banshee.blt_regs[banshee2D_dstSize] & 0xfff;
- v->banshee.blt_dst_height = (v->banshee.blt_regs[banshee2D_dstSize] >> 16) & 0xfff;
+ vd->banshee.blt_dst_x = vd->banshee.blt_regs[banshee2D_dstXY] & 0xfff;
+ vd->banshee.blt_dst_y = (vd->banshee.blt_regs[banshee2D_dstXY] >> 16) & 0xfff;
+ vd->banshee.blt_dst_base = vd->banshee.blt_regs[banshee2D_dstBaseAddr] & 0xffffff;
+ vd->banshee.blt_dst_stride = vd->banshee.blt_regs[banshee2D_dstFormat] & 0x3fff;
+ vd->banshee.blt_dst_width = vd->banshee.blt_regs[banshee2D_dstSize] & 0xfff;
+ vd->banshee.blt_dst_height = (vd->banshee.blt_regs[banshee2D_dstSize] >> 16) & 0xfff;
- switch ((v->banshee.blt_regs[banshee2D_dstFormat] >> 16) & 0x7)
+ switch ((vd->banshee.blt_regs[banshee2D_dstFormat] >> 16) & 0x7)
{
- case 1: v->banshee.blt_dst_bpp = 1; break;
- case 3: v->banshee.blt_dst_bpp = 2; break;
- case 4: v->banshee.blt_dst_bpp = 3; break;
- case 5: v->banshee.blt_dst_bpp = 4; break;
- default: v->banshee.blt_dst_bpp = 1; break;
+ case 1: vd->banshee.blt_dst_bpp = 1; break;
+ case 3: vd->banshee.blt_dst_bpp = 2; break;
+ case 4: vd->banshee.blt_dst_bpp = 3; break;
+ case 5: vd->banshee.blt_dst_bpp = 4; break;
+ default: vd->banshee.blt_dst_bpp = 1; break;
}
- v->banshee.blt_cmd = data & 0xf;
+ vd->banshee.blt_cmd = data & 0xf;
break;
case banshee2D_colorBack:
#if LOG_BANSHEE_2D
logerror(" 2D:colorBack: %08X\n", data);
#endif
- v->banshee.blt_regs[banshee2D_colorBack] = data;
+ vd->banshee.blt_regs[banshee2D_colorBack] = data;
break;
case banshee2D_colorFore:
#if LOG_BANSHEE_2D
logerror(" 2D:colorFore: %08X\n", data);
#endif
- v->banshee.blt_regs[banshee2D_colorFore] = data;
+ vd->banshee.blt_regs[banshee2D_colorFore] = data;
break;
case banshee2D_srcBaseAddr:
#if LOG_BANSHEE_2D
logerror(" 2D:srcBaseAddr: %08X, %s\n", data & 0xffffff, data & 0x80000000 ? "tiled" : "non-tiled");
#endif
- v->banshee.blt_regs[banshee2D_srcBaseAddr] = data;
+ vd->banshee.blt_regs[banshee2D_srcBaseAddr] = data;
break;
case banshee2D_dstBaseAddr:
#if LOG_BANSHEE_2D
logerror(" 2D:dstBaseAddr: %08X, %s\n", data & 0xffffff, data & 0x80000000 ? "tiled" : "non-tiled");
#endif
- v->banshee.blt_regs[banshee2D_dstBaseAddr] = data;
+ vd->banshee.blt_regs[banshee2D_dstBaseAddr] = data;
break;
case banshee2D_srcSize:
#if LOG_BANSHEE_2D
logerror(" 2D:srcSize: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_srcSize] = data;
+ vd->banshee.blt_regs[banshee2D_srcSize] = data;
break;
case banshee2D_dstSize:
#if LOG_BANSHEE_2D
logerror(" 2D:dstSize: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_dstSize] = data;
+ vd->banshee.blt_regs[banshee2D_dstSize] = data;
break;
case banshee2D_srcXY:
#if LOG_BANSHEE_2D
logerror(" 2D:srcXY: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_srcXY] = data;
+ vd->banshee.blt_regs[banshee2D_srcXY] = data;
break;
case banshee2D_dstXY:
#if LOG_BANSHEE_2D
logerror(" 2D:dstXY: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_dstXY] = data;
+ vd->banshee.blt_regs[banshee2D_dstXY] = data;
break;
case banshee2D_srcFormat:
#if LOG_BANSHEE_2D
logerror(" 2D:srcFormat: str %d, fmt %d, packing %d\n", data & 0x3fff, (data >> 16) & 0xf, (data >> 22) & 0x3);
#endif
- v->banshee.blt_regs[banshee2D_srcFormat] = data;
+ vd->banshee.blt_regs[banshee2D_srcFormat] = data;
break;
case banshee2D_dstFormat:
#if LOG_BANSHEE_2D
logerror(" 2D:dstFormat: str %d, fmt %d\n", data & 0x3fff, (data >> 16) & 0xf);
#endif
- v->banshee.blt_regs[banshee2D_dstFormat] = data;
+ vd->banshee.blt_regs[banshee2D_dstFormat] = data;
break;
case banshee2D_clip0Min:
#if LOG_BANSHEE_2D
logerror(" 2D:clip0Min: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_clip0Min] = data;
+ vd->banshee.blt_regs[banshee2D_clip0Min] = data;
break;
case banshee2D_clip0Max:
#if LOG_BANSHEE_2D
logerror(" 2D:clip0Max: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_clip0Max] = data;
+ vd->banshee.blt_regs[banshee2D_clip0Max] = data;
break;
case banshee2D_clip1Min:
#if LOG_BANSHEE_2D
logerror(" 2D:clip1Min: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_clip1Min] = data;
+ vd->banshee.blt_regs[banshee2D_clip1Min] = data;
break;
case banshee2D_clip1Max:
#if LOG_BANSHEE_2D
logerror(" 2D:clip1Max: %d, %d\n", data & 0xfff, (data >> 16) & 0xfff);
#endif
- v->banshee.blt_regs[banshee2D_clip1Max] = data;
+ vd->banshee.blt_regs[banshee2D_clip1Max] = data;
break;
case banshee2D_rop:
#if LOG_BANSHEE_2D
logerror(" 2D:rop: %d, %d, %d\n", data & 0xff, (data >> 8) & 0xff, (data >> 16) & 0xff);
#endif
- v->banshee.blt_regs[banshee2D_rop] = data;
+ vd->banshee.blt_regs[banshee2D_rop] = data;
break;
default:
if (offset >= 0x20 && offset < 0x40)
{
- blit_2d(v, data);
+ blit_2d(vd, data);
}
else if (offset >= 0x40 && offset < 0x80)
{
@@ -4677,86 +4610,85 @@ static INT32 banshee_2d_w(voodoo_state *v, offs_t offset, UINT32 data)
WRITE32_MEMBER( voodoo_banshee_device::banshee_agp_w )
{
- voodoo_state *v = get_safe_token(this);
offset &= 0x1ff/4;
/* switch off the offset */
switch (offset)
{
case cmdBaseAddr0:
- COMBINE_DATA(&v->banshee.agp[offset]);
- v->fbi.cmdfifo[0].base = (data & 0xffffff) << 12;
- v->fbi.cmdfifo[0].end = v->fbi.cmdfifo[0].base + (((v->banshee.agp[cmdBaseSize0] & 0xff) + 1) << 12);
+ COMBINE_DATA(&banshee.agp[offset]);
+ fbi.cmdfifo[0].base = (data & 0xffffff) << 12;
+ fbi.cmdfifo[0].end = fbi.cmdfifo[0].base + (((banshee.agp[cmdBaseSize0] & 0xff) + 1) << 12);
break;
case cmdBaseSize0:
- COMBINE_DATA(&v->banshee.agp[offset]);
- v->fbi.cmdfifo[0].end = v->fbi.cmdfifo[0].base + (((v->banshee.agp[cmdBaseSize0] & 0xff) + 1) << 12);
- v->fbi.cmdfifo[0].enable = (data >> 8) & 1;
- v->fbi.cmdfifo[0].count_holes = (~data >> 10) & 1;
+ COMBINE_DATA(&banshee.agp[offset]);
+ fbi.cmdfifo[0].end = fbi.cmdfifo[0].base + (((banshee.agp[cmdBaseSize0] & 0xff) + 1) << 12);
+ fbi.cmdfifo[0].enable = (data >> 8) & 1;
+ fbi.cmdfifo[0].count_holes = (~data >> 10) & 1;
break;
case cmdBump0:
fatalerror("cmdBump0\n");
case cmdRdPtrL0:
- v->fbi.cmdfifo[0].rdptr = data;
+ fbi.cmdfifo[0].rdptr = data;
break;
case cmdAMin0:
- v->fbi.cmdfifo[0].amin = data;
+ fbi.cmdfifo[0].amin = data;
break;
case cmdAMax0:
- v->fbi.cmdfifo[0].amax = data;
+ fbi.cmdfifo[0].amax = data;
break;
case cmdFifoDepth0:
- v->fbi.cmdfifo[0].depth = data;
+ fbi.cmdfifo[0].depth = data;
break;
case cmdHoleCnt0:
- v->fbi.cmdfifo[0].holes = data;
+ fbi.cmdfifo[0].holes = data;
break;
case cmdBaseAddr1:
- COMBINE_DATA(&v->banshee.agp[offset]);
- v->fbi.cmdfifo[1].base = (data & 0xffffff) << 12;
- v->fbi.cmdfifo[1].end = v->fbi.cmdfifo[1].base + (((v->banshee.agp[cmdBaseSize1] & 0xff) + 1) << 12);
+ COMBINE_DATA(&banshee.agp[offset]);
+ fbi.cmdfifo[1].base = (data & 0xffffff) << 12;
+ fbi.cmdfifo[1].end = fbi.cmdfifo[1].base + (((banshee.agp[cmdBaseSize1] & 0xff) + 1) << 12);
break;
case cmdBaseSize1:
- COMBINE_DATA(&v->banshee.agp[offset]);
- v->fbi.cmdfifo[1].end = v->fbi.cmdfifo[1].base + (((v->banshee.agp[cmdBaseSize1] & 0xff) + 1) << 12);
- v->fbi.cmdfifo[1].enable = (data >> 8) & 1;
- v->fbi.cmdfifo[1].count_holes = (~data >> 10) & 1;
+ COMBINE_DATA(&banshee.agp[offset]);
+ fbi.cmdfifo[1].end = fbi.cmdfifo[1].base + (((banshee.agp[cmdBaseSize1] & 0xff) + 1) << 12);
+ fbi.cmdfifo[1].enable = (data >> 8) & 1;
+ fbi.cmdfifo[1].count_holes = (~data >> 10) & 1;
break;
case cmdBump1:
fatalerror("cmdBump1\n");
case cmdRdPtrL1:
- v->fbi.cmdfifo[1].rdptr = data;
+ fbi.cmdfifo[1].rdptr = data;
break;
case cmdAMin1:
- v->fbi.cmdfifo[1].amin = data;
+ fbi.cmdfifo[1].amin = data;
break;
case cmdAMax1:
- v->fbi.cmdfifo[1].amax = data;
+ fbi.cmdfifo[1].amax = data;
break;
case cmdFifoDepth1:
- v->fbi.cmdfifo[1].depth = data;
+ fbi.cmdfifo[1].depth = data;
break;
case cmdHoleCnt1:
- v->fbi.cmdfifo[1].holes = data;
+ fbi.cmdfifo[1].holes = data;
break;
default:
- COMBINE_DATA(&v->banshee.agp[offset]);
+ COMBINE_DATA(&banshee.agp[offset]);
break;
}
@@ -4767,11 +4699,10 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_agp_w )
WRITE32_MEMBER( voodoo_banshee_device::banshee_w )
{
- voodoo_state *v = get_safe_token(this);
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
if (offset < 0x80000/4)
banshee_io_w(space, offset, data, mem_mask);
@@ -4780,7 +4711,7 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_w )
else if (offset < 0x200000/4)
logerror("%s:banshee_w(2D:%X) = %08X & %08X\n", machine().describe_context(), (offset*4) & 0xfffff, data, mem_mask);
else if (offset < 0x600000/4)
- register_w(v, offset & 0x1fffff/4, data);
+ register_w(this, offset & 0x1fffff/4, data);
else if (offset < 0x800000/4)
logerror("%s:banshee_w(TEX0:%X) = %08X & %08X\n", machine().describe_context(), (offset*4) & 0x1fffff, data, mem_mask);
else if (offset < 0xa00000/4)
@@ -4791,7 +4722,7 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_w )
logerror("%s:banshee_w(YUV:%X) = %08X & %08X\n", machine().describe_context(), (offset*4) & 0x3fffff, data, mem_mask);
else if (offset < 0x2000000/4)
{
- lfb_w(v, offset & 0xffffff/4, data, mem_mask);
+ lfb_w(this, offset & 0xffffff/4, data, mem_mask);
} else {
logerror("%s:banshee_w Address out of range %08X = %08X & %08X\n", machine().describe_context(), (offset*4), data, mem_mask);
}
@@ -4800,23 +4731,22 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_w )
WRITE32_MEMBER( voodoo_banshee_device::banshee_fb_w )
{
- voodoo_state *v = get_safe_token(this);
UINT32 addr = offset*4;
/* if we have something pending, flush the FIFOs up to the current time */
- if (v->pci.op_pending)
- flush_fifos(v, machine().time());
+ if (pci.op_pending)
+ flush_fifos(this, machine().time());
- if (offset < v->fbi.lfb_base)
+ if (offset < fbi.lfb_base)
{
- if (v->fbi.cmdfifo[0].enable && addr >= v->fbi.cmdfifo[0].base && addr < v->fbi.cmdfifo[0].end)
- cmdfifo_w(v, &v->fbi.cmdfifo[0], (addr - v->fbi.cmdfifo[0].base) / 4, data);
- else if (v->fbi.cmdfifo[1].enable && addr >= v->fbi.cmdfifo[1].base && addr < v->fbi.cmdfifo[1].end)
- cmdfifo_w(v, &v->fbi.cmdfifo[1], (addr - v->fbi.cmdfifo[1].base) / 4, data);
+ if (fbi.cmdfifo[0].enable && addr >= fbi.cmdfifo[0].base && addr < fbi.cmdfifo[0].end)
+ cmdfifo_w(this, &fbi.cmdfifo[0], (addr - fbi.cmdfifo[0].base) / 4, data);
+ else if (fbi.cmdfifo[1].enable && addr >= fbi.cmdfifo[1].base && addr < fbi.cmdfifo[1].end)
+ cmdfifo_w(this, &fbi.cmdfifo[1], (addr - fbi.cmdfifo[1].base) / 4, data);
else
{
- if (offset*4 <= v->fbi.mask)
- COMBINE_DATA(&((UINT32 *)v->fbi.ram)[offset]);
+ if (offset*4 <= fbi.mask)
+ COMBINE_DATA(&((UINT32 *)fbi.ram)[offset]);
else
logerror("%s:banshee_fb_w Out of bounds (%X) = %08X & %08X\n", machine().describe_context(), offset*4, data, mem_mask);
#if LOG_LFB
@@ -4825,13 +4755,12 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_fb_w )
}
}
else
- lfb_direct_w(v, offset - v->fbi.lfb_base, data, mem_mask);
+ lfb_direct_w(this, offset - fbi.lfb_base, data, mem_mask);
}
WRITE8_MEMBER( voodoo_banshee_device::banshee_vga_w )
{
- voodoo_state *v = get_safe_token(this);
offset &= 0x1f;
/* switch off the offset */
@@ -4840,48 +4769,48 @@ WRITE8_MEMBER( voodoo_banshee_device::banshee_vga_w )
/* attribute access */
case 0x3c0:
case 0x3c1:
- if (v->banshee.attff == 0)
+ if (banshee.attff == 0)
{
- v->banshee.vga[0x3c1 & 0x1f] = data;
+ banshee.vga[0x3c1 & 0x1f] = data;
if (LOG_REGISTERS)
logerror("%s:banshee_vga_w(%X) = %02X\n", machine().describe_context(), 0x3c0+offset, data);
}
else
{
- if (v->banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(v->banshee.att))
- v->banshee.att[v->banshee.vga[0x3c1 & 0x1f]] = data;
+ if (banshee.vga[0x3c1 & 0x1f] < ARRAY_LENGTH(banshee.att))
+ banshee.att[banshee.vga[0x3c1 & 0x1f]] = data;
if (LOG_REGISTERS)
- logerror("%s:banshee_att_w(%X) = %02X\n", machine().describe_context(), v->banshee.vga[0x3c1 & 0x1f], data);
+ logerror("%s:banshee_att_w(%X) = %02X\n", machine().describe_context(), banshee.vga[0x3c1 & 0x1f], data);
}
- v->banshee.attff ^= 1;
+ banshee.attff ^= 1;
break;
/* Sequencer access */
case 0x3c5:
- if (v->banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(v->banshee.seq))
- v->banshee.seq[v->banshee.vga[0x3c4 & 0x1f]] = data;
+ if (banshee.vga[0x3c4 & 0x1f] < ARRAY_LENGTH(banshee.seq))
+ banshee.seq[banshee.vga[0x3c4 & 0x1f]] = data;
if (LOG_REGISTERS)
- logerror("%s:banshee_seq_w(%X) = %02X\n", machine().describe_context(), v->banshee.vga[0x3c4 & 0x1f], data);
+ logerror("%s:banshee_seq_w(%X) = %02X\n", machine().describe_context(), banshee.vga[0x3c4 & 0x1f], data);
break;
/* Graphics controller access */
case 0x3cf:
- if (v->banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(v->banshee.gc))
- v->banshee.gc[v->banshee.vga[0x3ce & 0x1f]] = data;
+ if (banshee.vga[0x3ce & 0x1f] < ARRAY_LENGTH(banshee.gc))
+ banshee.gc[banshee.vga[0x3ce & 0x1f]] = data;
if (LOG_REGISTERS)
- logerror("%s:banshee_gc_w(%X) = %02X\n", machine().describe_context(), v->banshee.vga[0x3ce & 0x1f], data);
+ logerror("%s:banshee_gc_w(%X) = %02X\n", machine().describe_context(), banshee.vga[0x3ce & 0x1f], data);
break;
/* CRTC access */
case 0x3d5:
- if (v->banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(v->banshee.crtc))
- v->banshee.crtc[v->banshee.vga[0x3d4 & 0x1f]] = data;
+ if (banshee.vga[0x3d4 & 0x1f] < ARRAY_LENGTH(banshee.crtc))
+ banshee.crtc[banshee.vga[0x3d4 & 0x1f]] = data;
if (LOG_REGISTERS)
- logerror("%s:banshee_crtc_w(%X) = %02X\n", machine().describe_context(), v->banshee.vga[0x3d4 & 0x1f], data);
+ logerror("%s:banshee_crtc_w(%X) = %02X\n", machine().describe_context(), banshee.vga[0x3d4 & 0x1f], data);
break;
default:
- v->banshee.vga[offset] = data;
+ banshee.vga[offset] = data;
if (LOG_REGISTERS)
logerror("%s:banshee_vga_w(%X) = %02X\n", machine().describe_context(), 0x3c0+offset, data);
break;
@@ -4891,73 +4820,72 @@ WRITE8_MEMBER( voodoo_banshee_device::banshee_vga_w )
WRITE32_MEMBER( voodoo_banshee_device::banshee_io_w )
{
- voodoo_state *v = get_safe_token(this);
UINT32 old;
offset &= 0xff/4;
- old = v->banshee.io[offset];
+ old = banshee.io[offset];
/* switch off the offset */
switch (offset)
{
case io_vidProcCfg:
- COMBINE_DATA(&v->banshee.io[offset]);
- if ((v->banshee.io[offset] ^ old) & 0x2800)
- v->fbi.clut_dirty = TRUE;
+ COMBINE_DATA(&banshee.io[offset]);
+ if ((banshee.io[offset] ^ old) & 0x2800)
+ fbi.clut_dirty = TRUE;
if (LOG_REGISTERS)
logerror("%s:banshee_io_w(%s) = %08X & %08X\n", machine().describe_context(), banshee_io_reg_name[offset], data, mem_mask);
break;
case io_dacData:
- COMBINE_DATA(&v->banshee.io[offset]);
- if (v->banshee.io[offset] != v->fbi.clut[v->banshee.io[io_dacAddr] & 0x1ff])
+ COMBINE_DATA(&banshee.io[offset]);
+ if (banshee.io[offset] != fbi.clut[banshee.io[io_dacAddr] & 0x1ff])
{
- v->fbi.clut[v->banshee.io[io_dacAddr] & 0x1ff] = v->banshee.io[offset];
- v->fbi.clut_dirty = TRUE;
+ fbi.clut[banshee.io[io_dacAddr] & 0x1ff] = banshee.io[offset];
+ fbi.clut_dirty = TRUE;
}
if (LOG_REGISTERS)
- logerror("%s:banshee_dac_w(%X) = %08X & %08X\n", machine().describe_context(), v->banshee.io[io_dacAddr] & 0x1ff, data, mem_mask);
+ logerror("%s:banshee_dac_w(%X) = %08X & %08X\n", machine().describe_context(), banshee.io[io_dacAddr] & 0x1ff, data, mem_mask);
break;
case io_miscInit0:
- COMBINE_DATA(&v->banshee.io[offset]);
- v->fbi.yorigin = (data >> 18) & 0xfff;
+ COMBINE_DATA(&banshee.io[offset]);
+ fbi.yorigin = (data >> 18) & 0xfff;
if (LOG_REGISTERS)
logerror("%s:banshee_io_w(%s) = %08X & %08X\n", machine().describe_context(), banshee_io_reg_name[offset], data, mem_mask);
break;
case io_vidScreenSize:
if (data & 0xfff)
- v->fbi.width = data & 0xfff;
+ fbi.width = data & 0xfff;
if (data & 0xfff000)
- v->fbi.height = (data >> 12) & 0xfff;
+ fbi.height = (data >> 12) & 0xfff;
/* fall through */
case io_vidOverlayDudx:
case io_vidOverlayDvdy:
{
/* warning: this is a hack for now! We should really compute the screen size */
/* from the CRTC registers */
- COMBINE_DATA(&v->banshee.io[offset]);
+ COMBINE_DATA(&banshee.io[offset]);
- int width = v->fbi.width;
- int height = v->fbi.height;
+ int width = fbi.width;
+ int height = fbi.height;
- if (v->banshee.io[io_vidOverlayDudx] != 0)
- width = (v->fbi.width * v->banshee.io[io_vidOverlayDudx]) / 1048576;
- if (v->banshee.io[io_vidOverlayDvdy] != 0)
- height = (v->fbi.height * v->banshee.io[io_vidOverlayDvdy]) / 1048576;
+ if (banshee.io[io_vidOverlayDudx] != 0)
+ width = (fbi.width * banshee.io[io_vidOverlayDudx]) / 1048576;
+ if (banshee.io[io_vidOverlayDvdy] != 0)
+ height = (fbi.height * banshee.io[io_vidOverlayDvdy]) / 1048576;
- v->screen->set_visible_area(0, width - 1, 0, height - 1);
+ screen->set_visible_area(0, width - 1, 0, height - 1);
- adjust_vblank_timer(v);
+ adjust_vblank_timer(this);
if (LOG_REGISTERS)
logerror("%s:banshee_io_w(%s) = %08X & %08X\n", machine().describe_context(), banshee_io_reg_name[offset], data, mem_mask);
break;
}
case io_lfbMemoryConfig:
- v->fbi.lfb_base = (data & 0x1fff) << (12-2);
- v->fbi.lfb_stride = ((data >> 13) & 7) + 9;
+ fbi.lfb_base = (data & 0x1fff) << (12-2);
+ fbi.lfb_stride = ((data >> 13) & 7) + 9;
if (LOG_REGISTERS)
logerror("%s:banshee_io_w(%s) = %08X & %08X\n", machine().describe_context(), banshee_io_reg_name[offset], data, mem_mask);
break;
@@ -4976,7 +4904,7 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_io_w )
break;
default:
- COMBINE_DATA(&v->banshee.io[offset]);
+ COMBINE_DATA(&banshee.io[offset]);
if (LOG_REGISTERS)
logerror("%s:banshee_io_w(%s) = %08X & %08X\n", machine().describe_context(), banshee_io_reg_name[offset], data, mem_mask);
break;
@@ -4995,7 +4923,6 @@ WRITE32_MEMBER( voodoo_banshee_device::banshee_io_w )
void voodoo_device::common_start_voodoo(UINT8 type)
{
- voodoo_state *v = get_safe_token(this);
const raster_info *info;
void *fbmem, *tmumem[2];
UINT32 tmumem0, tmumem1;
@@ -5007,17 +4934,17 @@ void voodoo_device::common_start_voodoo(UINT8 type)
assert(m_fbmem > 0);
/* store a pointer back to the device */
- v->device = this;
- v->type = type;
+ device = this;
+ vd_type = type;
/* copy config data */
- v->freq = clock();
- v->device->m_vblank.resolve();
- v->device->m_stall.resolve();
+ freq = clock();
+ device->m_vblank.resolve();
+ device->m_stall.resolve();
/* create a multiprocessor work queue */
- v->poly = poly_alloc(machine(), 64, sizeof(poly_extra_data), 0);
- v->thread_stats = auto_alloc_array(machine(), stats_block, WORK_MAX_THREADS);
+ poly = poly_alloc(machine(), 64, sizeof(poly_extra_data), 0);
+ 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 */
@@ -5048,38 +4975,38 @@ void voodoo_device::common_start_voodoo(UINT8 type)
}
}
- v->tmu_config = 0x11; // revision 1
+ tmu_config = 0x11; // revision 1
/* configure type-specific values */
- switch (v->type)
+ switch (vd_type)
{
case TYPE_VOODOO_1:
- v->regaccess = voodoo_register_access;
- v->regnames = voodoo_reg_name;
- v->alt_regmap = 0;
- v->fbi.lfb_stride = 10;
+ regaccess = voodoo_register_access;
+ regnames = voodoo_reg_name;
+ alt_regmap = 0;
+ fbi.lfb_stride = 10;
break;
case TYPE_VOODOO_2:
- v->regaccess = voodoo2_register_access;
- v->regnames = voodoo_reg_name;
- v->alt_regmap = 0;
- v->fbi.lfb_stride = 10;
- v->tmu_config |= 0x800;
+ regaccess = voodoo2_register_access;
+ regnames = voodoo_reg_name;
+ alt_regmap = 0;
+ fbi.lfb_stride = 10;
+ tmu_config |= 0x800;
break;
case TYPE_VOODOO_BANSHEE:
- v->regaccess = banshee_register_access;
- v->regnames = banshee_reg_name;
- v->alt_regmap = 1;
- v->fbi.lfb_stride = 11;
+ regaccess = banshee_register_access;
+ regnames = banshee_reg_name;
+ alt_regmap = 1;
+ fbi.lfb_stride = 11;
break;
case TYPE_VOODOO_3:
- v->regaccess = banshee_register_access;
- v->regnames = banshee_reg_name;
- v->alt_regmap = 1;
- v->fbi.lfb_stride = 11;
+ regaccess = banshee_register_access;
+ regnames = banshee_reg_name;
+ alt_regmap = 1;
+ fbi.lfb_stride = 11;
break;
default:
@@ -5088,41 +5015,41 @@ void voodoo_device::common_start_voodoo(UINT8 type)
/* set the type, and initialize the chip mask */
device_iterator iter(machine().root_device());
- v->index = 0;
+ index = 0;
for (device_t *scan = iter.first(); scan != nullptr; scan = iter.next())
if (scan->type() == this->type())
{
if (scan == this)
break;
- v->index++;
+ index++;
}
- v->screen = downcast<screen_device *>(machine().device(m_screen));
- assert_always(v->screen != nullptr, "Unable to find screen attached to voodoo");
- v->cpu = machine().device(m_cputag);
- assert_always(v->cpu != nullptr, "Unable to find CPU attached to voodoo");
+ screen = downcast<screen_device *>(machine().device(m_screen));
+ assert_always(screen != nullptr, "Unable to find screen attached to voodoo");
+ cpu = machine().device(m_cputag);
+ assert_always(cpu != nullptr, "Unable to find CPU attached to voodoo");
if (m_tmumem1 != 0)
- v->tmu_config |= 0xc0; // two TMUs
+ tmu_config |= 0xc0; // two TMUs
- v->chipmask = 0x01;
- v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq;
- v->trigger = 51324 + v->index;
+ chipmask = 0x01;
+ attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / freq;
+ trigger = 51324 + index;
/* build the rasterizer table */
for (info = predef_raster_table; info->callback; info++)
- add_rasterizer(v, info);
+ add_rasterizer(this, info);
/* set up the PCI FIFO */
- v->pci.fifo.base = v->pci.fifo_mem;
- 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 = machine().scheduler().timer_alloc(FUNC(stall_cpu_callback), v);
-
+ pci.fifo.base = pci.fifo_mem;
+ pci.fifo.size = 64*2;
+ pci.fifo.in = pci.fifo.out = 0;
+ pci.stall_state = NOT_STALLED;
+ pci.continue_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(voodoo_device::stall_cpu_callback),this), nullptr);
+
/* allocate memory */
tmumem0 = m_tmumem0;
tmumem1 = m_tmumem1;
- if (v->type <= TYPE_VOODOO_2)
+ if (vd_type <= TYPE_VOODOO_2)
{
/* separate FB/TMU memory */
fbmem = auto_alloc_array(machine(), UINT8, m_fbmem << 20);
@@ -5134,47 +5061,47 @@ void voodoo_device::common_start_voodoo(UINT8 type)
/* shared memory */
tmumem[0] = tmumem[1] = fbmem = auto_alloc_array(machine(), UINT8, m_fbmem << 20);
tmumem0 = m_fbmem;
- if (v->type == TYPE_VOODOO_3)
+ if (vd_type == TYPE_VOODOO_3)
tmumem1 = m_fbmem;
}
/* set up frame buffer */
- init_fbi(v, &v->fbi, fbmem, m_fbmem << 20);
+ init_fbi(this, &fbi, fbmem, m_fbmem << 20);
/* build shared TMU tables */
- init_tmu_shared(&v->tmushare);
+ init_tmu_shared(&tmushare);
/* set up the TMUs */
- init_tmu(v, &v->tmu[0], &v->reg[0x100], tmumem[0], tmumem0 << 20);
- v->chipmask |= 0x02;
+ init_tmu(this, &tmu[0], &reg[0x100], tmumem[0], tmumem0 << 20);
+ chipmask |= 0x02;
if (tmumem1 != 0)
{
- init_tmu(v, &v->tmu[1], &v->reg[0x200], tmumem[1], tmumem1 << 20);
- v->chipmask |= 0x04;
- v->tmu_config |= 0x40;
+ init_tmu(this, &tmu[1], &reg[0x200], tmumem[1], tmumem1 << 20);
+ chipmask |= 0x04;
+ tmu_config |= 0x40;
}
/* initialize some registers */
- memset(v->reg, 0, sizeof(v->reg));
- v->pci.init_enable = 0;
- v->reg[fbiInit0].u = (1 << 4) | (0x10 << 6);
- v->reg[fbiInit1].u = (1 << 1) | (1 << 8) | (1 << 12) | (2 << 20);
- v->reg[fbiInit2].u = (1 << 6) | (0x100 << 23);
- v->reg[fbiInit3].u = (2 << 13) | (0xf << 17);
- v->reg[fbiInit4].u = (1 << 0);
+ memset(reg, 0, sizeof(reg));
+ pci.init_enable = 0;
+ reg[fbiInit0].u = (1 << 4) | (0x10 << 6);
+ reg[fbiInit1].u = (1 << 1) | (1 << 8) | (1 << 12) | (2 << 20);
+ reg[fbiInit2].u = (1 << 6) | (0x100 << 23);
+ reg[fbiInit3].u = (2 << 13) | (0xf << 17);
+ reg[fbiInit4].u = (1 << 0);
/* initialize banshee registers */
- memset(v->banshee.io, 0, sizeof(v->banshee.io));
- v->banshee.io[io_pciInit0] = 0x01800040;
- v->banshee.io[io_sipMonitor] = 0x40000000;
- v->banshee.io[io_lfbMemoryConfig] = 0x000a2200;
- v->banshee.io[io_dramInit0] = 0x00579d29;
- v->banshee.io[io_dramInit0] |= 0x08000000; // Konami Viper expects 16MBit SGRAMs
- v->banshee.io[io_dramInit1] = 0x00f02200;
- v->banshee.io[io_tmuGbeInit] = 0x00000bfb;
+ memset(banshee.io, 0, sizeof(banshee.io));
+ banshee.io[io_pciInit0] = 0x01800040;
+ banshee.io[io_sipMonitor] = 0x40000000;
+ banshee.io[io_lfbMemoryConfig] = 0x000a2200;
+ banshee.io[io_dramInit0] = 0x00579d29;
+ banshee.io[io_dramInit0] |= 0x08000000; // Konami Viper expects 16MBit SGRAMs
+ banshee.io[io_dramInit1] = 0x00f02200;
+ banshee.io[io_tmuGbeInit] = 0x00000bfb;
/* do a soft reset to reset everything else */
- soft_reset(v);
+ soft_reset(this);
/* register for save states */
init_save_state(this);
@@ -5191,12 +5118,12 @@ void voodoo_device::common_start_voodoo(UINT8 type)
command
-------------------------------------------------*/
-static INT32 fastfill(voodoo_state *v)
+INT32 voodoo_device::fastfill(voodoo_device *vd)
{
- int sx = (v->reg[clipLeftRight].u >> 16) & 0x3ff;
- int ex = (v->reg[clipLeftRight].u >> 0) & 0x3ff;
- int sy = (v->reg[clipLowYHighY].u >> 16) & 0x3ff;
- int ey = (v->reg[clipLowYHighY].u >> 0) & 0x3ff;
+ int sx = (vd->reg[clipLeftRight].u >> 16) & 0x3ff;
+ int ex = (vd->reg[clipLeftRight].u >> 0) & 0x3ff;
+ int sy = (vd->reg[clipLowYHighY].u >> 16) & 0x3ff;
+ int ey = (vd->reg[clipLowYHighY].u >> 0) & 0x3ff;
poly_extent extents[64];
UINT16 dithermatrix[16];
UINT16 *drawbuf = nullptr;
@@ -5204,22 +5131,22 @@ static INT32 fastfill(voodoo_state *v)
int extnum, x, y;
/* if we're not clearing either, take no time */
- if (!FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u) && !FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u))
+ if (!FBZMODE_RGB_BUFFER_MASK(vd->reg[fbzMode].u) && !FBZMODE_AUX_BUFFER_MASK(vd->reg[fbzMode].u))
return 0;
/* are we clearing the RGB buffer? */
- if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u))
+ if (FBZMODE_RGB_BUFFER_MASK(vd->reg[fbzMode].u))
{
/* determine the draw buffer */
- int destbuf = (v->type >= TYPE_VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(v->reg[fbzMode].u);
+ int destbuf = (vd->vd_type >= TYPE_VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(vd->reg[fbzMode].u);
switch (destbuf)
{
case 0: /* front buffer */
- drawbuf = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
+ drawbuf = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.frontbuf]);
break;
case 1: /* back buffer */
- drawbuf = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.backbuf]);
+ drawbuf = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.backbuf]);
break;
default: /* reserved */
@@ -5230,14 +5157,14 @@ static INT32 fastfill(voodoo_state *v)
for (y = 0; y < 4; y++)
{
DECLARE_DITHER_POINTERS_NO_DITHER_VAR;
- COMPUTE_DITHER_POINTERS_NO_DITHER_VAR(v->reg[fbzMode].u, y);
+ COMPUTE_DITHER_POINTERS_NO_DITHER_VAR(vd->reg[fbzMode].u, y);
for (x = 0; x < 4; x++)
{
- int r = v->reg[color1].rgb.r;
- int g = v->reg[color1].rgb.g;
- int b = v->reg[color1].rgb.b;
+ int r = vd->reg[color1].rgb.r;
+ int g = vd->reg[color1].rgb.g;
+ int b = vd->reg[color1].rgb.b;
- APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, r, g, b);
+ APPLY_DITHER(vd->reg[fbzMode].u, x, dither_lookup, r, g, b);
dithermatrix[y*4 + x] = (r << 11) | (g << 5) | b;
}
}
@@ -5252,13 +5179,13 @@ static INT32 fastfill(voodoo_state *v)
/* iterate over blocks of extents */
for (y = sy; y < ey; y += ARRAY_LENGTH(extents))
{
- poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(v->poly);
+ poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(vd->poly);
int count = MIN(ey - y, ARRAY_LENGTH(extents));
- extra->state = v;
+ extra->device= vd;
memcpy(extra->dither, dithermatrix, sizeof(extra->dither));
- pixels += poly_render_triangle_custom(v->poly, drawbuf, global_cliprect, raster_fastfill, y, count, extents);
+ pixels += poly_render_triangle_custom(vd->poly, drawbuf, global_cliprect, raster_fastfill, y, count, extents);
}
/* 2 pixels per clock */
@@ -5271,23 +5198,23 @@ static INT32 fastfill(voodoo_state *v)
command
-------------------------------------------------*/
-static INT32 swapbuffer(voodoo_state *v, UINT32 data)
+INT32 voodoo_device::swapbuffer(voodoo_device* vd, UINT32 data)
{
/* set the don't swap value for Voodoo 2 */
- v->fbi.vblank_swap_pending = TRUE;
- v->fbi.vblank_swap = (data >> 1) & 0xff;
- v->fbi.vblank_dont_swap = (data >> 9) & 1;
+ vd->fbi.vblank_swap_pending = TRUE;
+ vd->fbi.vblank_swap = (data >> 1) & 0xff;
+ vd->fbi.vblank_dont_swap = (data >> 9) & 1;
/* if we're not syncing to the retrace, process the command immediately */
if (!(data & 1))
{
- swap_buffers(v);
+ swap_buffers(vd);
return 0;
}
/* determine how many cycles to wait; we deliberately overshoot here because */
/* the final count gets updated on the VBLANK */
- return (v->fbi.vblank_swap + 1) * v->freq / 30;
+ return (vd->fbi.vblank_swap + 1) * vd->freq / 30;
}
@@ -5296,7 +5223,7 @@ static INT32 swapbuffer(voodoo_state *v, UINT32 data)
command
-------------------------------------------------*/
-static INT32 triangle(voodoo_state *v)
+INT32 voodoo_device::triangle(voodoo_device *vd)
{
int texcount;
UINT16 *drawbuf;
@@ -5307,58 +5234,58 @@ static INT32 triangle(voodoo_state *v)
/* determine the number of TMUs involved */
texcount = 0;
- if (!FBIINIT3_DISABLE_TMUS(v->reg[fbiInit3].u) && FBZCP_TEXTURE_ENABLE(v->reg[fbzColorPath].u))
+ if (!FBIINIT3_DISABLE_TMUS(vd->reg[fbiInit3].u) && FBZCP_TEXTURE_ENABLE(vd->reg[fbzColorPath].u))
{
texcount = 1;
- if (v->chipmask & 0x04)
+ if (vd->chipmask & 0x04)
texcount = 2;
}
/* perform subpixel adjustments */
- if (FBZCP_CCA_SUBPIXEL_ADJUST(v->reg[fbzColorPath].u))
+ if (FBZCP_CCA_SUBPIXEL_ADJUST(vd->reg[fbzColorPath].u))
{
- INT32 dx = 8 - (v->fbi.ax & 15);
- INT32 dy = 8 - (v->fbi.ay & 15);
+ INT32 dx = 8 - (vd->fbi.ax & 15);
+ INT32 dy = 8 - (vd->fbi.ay & 15);
/* adjust iterated R,G,B,A and W/Z */
- v->fbi.startr += (dy * v->fbi.drdy + dx * v->fbi.drdx) >> 4;
- v->fbi.startg += (dy * v->fbi.dgdy + dx * v->fbi.dgdx) >> 4;
- v->fbi.startb += (dy * v->fbi.dbdy + dx * v->fbi.dbdx) >> 4;
- v->fbi.starta += (dy * v->fbi.dady + dx * v->fbi.dadx) >> 4;
- v->fbi.startw += (dy * v->fbi.dwdy + dx * v->fbi.dwdx) >> 4;
- v->fbi.startz += mul_32x32_shift(dy, v->fbi.dzdy, 4) + mul_32x32_shift(dx, v->fbi.dzdx, 4);
+ vd->fbi.startr += (dy * vd->fbi.drdy + dx * vd->fbi.drdx) >> 4;
+ vd->fbi.startg += (dy * vd->fbi.dgdy + dx * vd->fbi.dgdx) >> 4;
+ vd->fbi.startb += (dy * vd->fbi.dbdy + dx * vd->fbi.dbdx) >> 4;
+ vd->fbi.starta += (dy * vd->fbi.dady + dx * vd->fbi.dadx) >> 4;
+ vd->fbi.startw += (dy * vd->fbi.dwdy + dx * vd->fbi.dwdx) >> 4;
+ vd->fbi.startz += mul_32x32_shift(dy, vd->fbi.dzdy, 4) + mul_32x32_shift(dx, vd->fbi.dzdx, 4);
/* adjust iterated W/S/T for TMU 0 */
if (texcount >= 1)
{
- v->tmu[0].startw += (dy * v->tmu[0].dwdy + dx * v->tmu[0].dwdx) >> 4;
- v->tmu[0].starts += (dy * v->tmu[0].dsdy + dx * v->tmu[0].dsdx) >> 4;
- v->tmu[0].startt += (dy * v->tmu[0].dtdy + dx * v->tmu[0].dtdx) >> 4;
+ vd->tmu[0].startw += (dy * vd->tmu[0].dwdy + dx * vd->tmu[0].dwdx) >> 4;
+ vd->tmu[0].starts += (dy * vd->tmu[0].dsdy + dx * vd->tmu[0].dsdx) >> 4;
+ vd->tmu[0].startt += (dy * vd->tmu[0].dtdy + dx * vd->tmu[0].dtdx) >> 4;
/* adjust iterated W/S/T for TMU 1 */
if (texcount >= 2)
{
- v->tmu[1].startw += (dy * v->tmu[1].dwdy + dx * v->tmu[1].dwdx) >> 4;
- v->tmu[1].starts += (dy * v->tmu[1].dsdy + dx * v->tmu[1].dsdx) >> 4;
- v->tmu[1].startt += (dy * v->tmu[1].dtdy + dx * v->tmu[1].dtdx) >> 4;
+ vd->tmu[1].startw += (dy * vd->tmu[1].dwdy + dx * vd->tmu[1].dwdx) >> 4;
+ vd->tmu[1].starts += (dy * vd->tmu[1].dsdy + dx * vd->tmu[1].dsdx) >> 4;
+ vd->tmu[1].startt += (dy * vd->tmu[1].dtdy + dx * vd->tmu[1].dtdx) >> 4;
}
}
}
/* wait for any outstanding work to finish */
-// poly_wait(v->poly, "triangle");
+// poly_wait(vd->poly, "triangle");
/* determine the draw buffer */
- destbuf = (v->type >= TYPE_VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(v->reg[fbzMode].u);
+ destbuf = (vd->vd_type >= TYPE_VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(vd->reg[fbzMode].u);
switch (destbuf)
{
case 0: /* front buffer */
- drawbuf = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
- v->fbi.video_changed = TRUE;
+ drawbuf = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.frontbuf]);
+ vd->fbi.video_changed = TRUE;
break;
case 1: /* back buffer */
- drawbuf = (UINT16 *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.backbuf]);
+ drawbuf = (UINT16 *)(vd->fbi.ram + vd->fbi.rgboffs[vd->fbi.backbuf]);
break;
default: /* reserved */
@@ -5366,18 +5293,18 @@ static INT32 triangle(voodoo_state *v)
}
/* find a rasterizer that matches our current state */
- pixels = triangle_create_work_item(v, drawbuf, texcount);
+ pixels = triangle_create_work_item(vd, drawbuf, texcount);
/* update stats */
- v->reg[fbiTrianglesOut].u++;
+ vd->reg[fbiTrianglesOut].u++;
/* update stats */
- v->stats.total_triangles++;
+ vd->stats.total_triangles++;
g_profiler.stop();
/* 1 pixel per clock, plus some setup time */
- if (LOG_REGISTERS) v->device->logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + pixels);
+ if (LOG_REGISTERS) vd->device->logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + pixels);
return TRIANGLE_SETUP_CLOCKS + pixels;
}
@@ -5387,28 +5314,28 @@ static INT32 triangle(voodoo_state *v)
command
-------------------------------------------------*/
-static INT32 begin_triangle(voodoo_state *v)
+INT32 voodoo_device::begin_triangle(voodoo_device *vd)
{
- setup_vertex *sv = &v->fbi.svert[2];
+ setup_vertex *sv = &vd->fbi.svert[2];
/* extract all the data from registers */
- sv->x = v->reg[sVx].f;
- sv->y = v->reg[sVy].f;
- sv->wb = v->reg[sWb].f;
- sv->w0 = v->reg[sWtmu0].f;
- sv->s0 = v->reg[sS_W0].f;
- sv->t0 = v->reg[sT_W0].f;
- sv->w1 = v->reg[sWtmu1].f;
- sv->s1 = v->reg[sS_Wtmu1].f;
- sv->t1 = v->reg[sT_Wtmu1].f;
- sv->a = v->reg[sAlpha].f;
- sv->r = v->reg[sRed].f;
- sv->g = v->reg[sGreen].f;
- sv->b = v->reg[sBlue].f;
+ sv->x = vd->reg[sVx].f;
+ sv->y = vd->reg[sVy].f;
+ sv->wb = vd->reg[sWb].f;
+ sv->w0 = vd->reg[sWtmu0].f;
+ sv->s0 = vd->reg[sS_W0].f;
+ sv->t0 = vd->reg[sT_W0].f;
+ sv->w1 = vd->reg[sWtmu1].f;
+ sv->s1 = vd->reg[sS_Wtmu1].f;
+ sv->t1 = vd->reg[sT_Wtmu1].f;
+ sv->a = vd->reg[sAlpha].f;
+ sv->r = vd->reg[sRed].f;
+ sv->g = vd->reg[sGreen].f;
+ sv->b = vd->reg[sBlue].f;
/* spread it across all three verts and reset the count */
- v->fbi.svert[0] = v->fbi.svert[1] = v->fbi.svert[2];
- v->fbi.sverts = 1;
+ vd->fbi.svert[0] = vd->fbi.svert[1] = vd->fbi.svert[2];
+ vd->fbi.sverts = 1;
return 0;
}
@@ -5419,36 +5346,36 @@ static INT32 begin_triangle(voodoo_state *v)
command
-------------------------------------------------*/
-static INT32 draw_triangle(voodoo_state *v)
+INT32 voodoo_device::draw_triangle(voodoo_device *vd)
{
- setup_vertex *sv = &v->fbi.svert[2];
+ setup_vertex *sv = &vd->fbi.svert[2];
int cycles = 0;
/* for strip mode, shuffle vertex 1 down to 0 */
- if (!(v->reg[sSetupMode].u & (1 << 16)))
- v->fbi.svert[0] = v->fbi.svert[1];
+ if (!(vd->reg[sSetupMode].u & (1 << 16)))
+ vd->fbi.svert[0] = vd->fbi.svert[1];
/* copy 2 down to 1 regardless */
- v->fbi.svert[1] = v->fbi.svert[2];
+ vd->fbi.svert[1] = vd->fbi.svert[2];
/* extract all the data from registers */
- sv->x = v->reg[sVx].f;
- sv->y = v->reg[sVy].f;
- sv->wb = v->reg[sWb].f;
- sv->w0 = v->reg[sWtmu0].f;
- sv->s0 = v->reg[sS_W0].f;
- sv->t0 = v->reg[sT_W0].f;
- sv->w1 = v->reg[sWtmu1].f;
- sv->s1 = v->reg[sS_Wtmu1].f;
- sv->t1 = v->reg[sT_Wtmu1].f;
- sv->a = v->reg[sAlpha].f;
- sv->r = v->reg[sRed].f;
- sv->g = v->reg[sGreen].f;
- sv->b = v->reg[sBlue].f;
+ sv->x = vd->reg[sVx].f;
+ sv->y = vd->reg[sVy].f;
+ sv->wb = vd->reg[sWb].f;
+ sv->w0 = vd->reg[sWtmu0].f;
+ sv->s0 = vd->reg[sS_W0].f;
+ sv->t0 = vd->reg[sT_W0].f;
+ sv->w1 = vd->reg[sWtmu1].f;
+ sv->s1 = vd->reg[sS_Wtmu1].f;
+ sv->t1 = vd->reg[sT_Wtmu1].f;
+ sv->a = vd->reg[sAlpha].f;
+ sv->r = vd->reg[sRed].f;
+ sv->g = vd->reg[sGreen].f;
+ sv->b = vd->reg[sBlue].f;
/* if we have enough verts, go ahead and draw */
- if (++v->fbi.sverts >= 3)
- cycles = setup_and_draw_triangle(v);
+ if (++vd->fbi.sverts >= 3)
+ cycles = setup_and_draw_triangle(vd);
return cycles;
}
@@ -5464,32 +5391,32 @@ static INT32 draw_triangle(voodoo_state *v)
parameters and render the triangle
-------------------------------------------------*/
-static INT32 setup_and_draw_triangle(voodoo_state *v)
+INT32 voodoo_device::setup_and_draw_triangle(voodoo_device *vd)
{
float dx1, dy1, dx2, dy2;
float divisor, tdiv;
/* grab the X/Ys at least */
- v->fbi.ax = (INT16)(v->fbi.svert[0].x * 16.0f);
- v->fbi.ay = (INT16)(v->fbi.svert[0].y * 16.0f);
- v->fbi.bx = (INT16)(v->fbi.svert[1].x * 16.0f);
- v->fbi.by = (INT16)(v->fbi.svert[1].y * 16.0f);
- v->fbi.cx = (INT16)(v->fbi.svert[2].x * 16.0f);
- v->fbi.cy = (INT16)(v->fbi.svert[2].y * 16.0f);
+ vd->fbi.ax = (INT16)(vd->fbi.svert[0].x * 16.0f);
+ vd->fbi.ay = (INT16)(vd->fbi.svert[0].y * 16.0f);
+ vd->fbi.bx = (INT16)(vd->fbi.svert[1].x * 16.0f);
+ vd->fbi.by = (INT16)(vd->fbi.svert[1].y * 16.0f);
+ vd->fbi.cx = (INT16)(vd->fbi.svert[2].x * 16.0f);
+ vd->fbi.cy = (INT16)(vd->fbi.svert[2].y * 16.0f);
/* compute the divisor */
- divisor = 1.0f / ((v->fbi.svert[0].x - v->fbi.svert[1].x) * (v->fbi.svert[0].y - v->fbi.svert[2].y) -
- (v->fbi.svert[0].x - v->fbi.svert[2].x) * (v->fbi.svert[0].y - v->fbi.svert[1].y));
+ divisor = 1.0f / ((vd->fbi.svert[0].x - vd->fbi.svert[1].x) * (vd->fbi.svert[0].y - vd->fbi.svert[2].y) -
+ (vd->fbi.svert[0].x - vd->fbi.svert[2].x) * (vd->fbi.svert[0].y - vd->fbi.svert[1].y));
/* backface culling */
- if (v->reg[sSetupMode].u & 0x20000)
+ if (vd->reg[sSetupMode].u & 0x20000)
{
- int culling_sign = (v->reg[sSetupMode].u >> 18) & 1;
+ int culling_sign = (vd->reg[sSetupMode].u >> 18) & 1;
int divisor_sign = (divisor < 0);
/* if doing strips and ping pong is enabled, apply the ping pong */
- if ((v->reg[sSetupMode].u & 0x90000) == 0x00000)
- culling_sign ^= (v->fbi.sverts - 3) & 1;
+ if ((vd->reg[sSetupMode].u & 0x90000) == 0x00000)
+ culling_sign ^= (vd->fbi.sverts - 3) & 1;
/* if our sign matches the culling sign, we're done for */
if (divisor_sign == culling_sign)
@@ -5497,92 +5424,92 @@ static INT32 setup_and_draw_triangle(voodoo_state *v)
}
/* compute the dx/dy values */
- dx1 = v->fbi.svert[0].y - v->fbi.svert[2].y;
- dx2 = v->fbi.svert[0].y - v->fbi.svert[1].y;
- dy1 = v->fbi.svert[0].x - v->fbi.svert[1].x;
- dy2 = v->fbi.svert[0].x - v->fbi.svert[2].x;
+ dx1 = vd->fbi.svert[0].y - vd->fbi.svert[2].y;
+ dx2 = vd->fbi.svert[0].y - vd->fbi.svert[1].y;
+ dy1 = vd->fbi.svert[0].x - vd->fbi.svert[1].x;
+ dy2 = vd->fbi.svert[0].x - vd->fbi.svert[2].x;
/* set up R,G,B */
tdiv = divisor * 4096.0f;
- if (v->reg[sSetupMode].u & (1 << 0))
+ if (vd->reg[sSetupMode].u & (1 << 0))
{
- v->fbi.startr = (INT32)(v->fbi.svert[0].r * 4096.0f);
- v->fbi.drdx = (INT32)(((v->fbi.svert[0].r - v->fbi.svert[1].r) * dx1 - (v->fbi.svert[0].r - v->fbi.svert[2].r) * dx2) * tdiv);
- v->fbi.drdy = (INT32)(((v->fbi.svert[0].r - v->fbi.svert[2].r) * dy1 - (v->fbi.svert[0].r - v->fbi.svert[1].r) * dy2) * tdiv);
- v->fbi.startg = (INT32)(v->fbi.svert[0].g * 4096.0f);
- v->fbi.dgdx = (INT32)(((v->fbi.svert[0].g - v->fbi.svert[1].g) * dx1 - (v->fbi.svert[0].g - v->fbi.svert[2].g) * dx2) * tdiv);
- v->fbi.dgdy = (INT32)(((v->fbi.svert[0].g - v->fbi.svert[2].g) * dy1 - (v->fbi.svert[0].g - v->fbi.svert[1].g) * dy2) * tdiv);
- v->fbi.startb = (INT32)(v->fbi.svert[0].b * 4096.0f);
- v->fbi.dbdx = (INT32)(((v->fbi.svert[0].b - v->fbi.svert[1].b) * dx1 - (v->fbi.svert[0].b - v->fbi.svert[2].b) * dx2) * tdiv);
- v->fbi.dbdy = (INT32)(((v->fbi.svert[0].b - v->fbi.svert[2].b) * dy1 - (v->fbi.svert[0].b - v->fbi.svert[1].b) * dy2) * tdiv);
+ vd->fbi.startr = (INT32)(vd->fbi.svert[0].r * 4096.0f);
+ vd->fbi.drdx = (INT32)(((vd->fbi.svert[0].r - vd->fbi.svert[1].r) * dx1 - (vd->fbi.svert[0].r - vd->fbi.svert[2].r) * dx2) * tdiv);
+ vd->fbi.drdy = (INT32)(((vd->fbi.svert[0].r - vd->fbi.svert[2].r) * dy1 - (vd->fbi.svert[0].r - vd->fbi.svert[1].r) * dy2) * tdiv);
+ vd->fbi.startg = (INT32)(vd->fbi.svert[0].g * 4096.0f);
+ vd->fbi.dgdx = (INT32)(((vd->fbi.svert[0].g - vd->fbi.svert[1].g) * dx1 - (vd->fbi.svert[0].g - vd->fbi.svert[2].g) * dx2) * tdiv);
+ vd->fbi.dgdy = (INT32)(((vd->fbi.svert[0].g - vd->fbi.svert[2].g) * dy1 - (vd->fbi.svert[0].g - vd->fbi.svert[1].g) * dy2) * tdiv);
+ vd->fbi.startb = (INT32)(vd->fbi.svert[0].b * 4096.0f);
+ vd->fbi.dbdx = (INT32)(((vd->fbi.svert[0].b - vd->fbi.svert[1].b) * dx1 - (vd->fbi.svert[0].b - vd->fbi.svert[2].b) * dx2) * tdiv);
+ vd->fbi.dbdy = (INT32)(((vd->fbi.svert[0].b - vd->fbi.svert[2].b) * dy1 - (vd->fbi.svert[0].b - vd->fbi.svert[1].b) * dy2) * tdiv);
}
/* set up alpha */
- if (v->reg[sSetupMode].u & (1 << 1))
+ if (vd->reg[sSetupMode].u & (1 << 1))
{
- v->fbi.starta = (INT32)(v->fbi.svert[0].a * 4096.0f);
- v->fbi.dadx = (INT32)(((v->fbi.svert[0].a - v->fbi.svert[1].a) * dx1 - (v->fbi.svert[0].a - v->fbi.svert[2].a) * dx2) * tdiv);
- v->fbi.dady = (INT32)(((v->fbi.svert[0].a - v->fbi.svert[2].a) * dy1 - (v->fbi.svert[0].a - v->fbi.svert[1].a) * dy2) * tdiv);
+ vd->fbi.starta = (INT32)(vd->fbi.svert[0].a * 4096.0f);
+ vd->fbi.dadx = (INT32)(((vd->fbi.svert[0].a - vd->fbi.svert[1].a) * dx1 - (vd->fbi.svert[0].a - vd->fbi.svert[2].a) * dx2) * tdiv);
+ vd->fbi.dady = (INT32)(((vd->fbi.svert[0].a - vd->fbi.svert[2].a) * dy1 - (vd->fbi.svert[0].a - vd->fbi.svert[1].a) * dy2) * tdiv);
}
/* set up Z */
- if (v->reg[sSetupMode].u & (1 << 2))
+ if (vd->reg[sSetupMode].u & (1 << 2))
{
- v->fbi.startz = (INT32)(v->fbi.svert[0].z * 4096.0f);
- v->fbi.dzdx = (INT32)(((v->fbi.svert[0].z - v->fbi.svert[1].z) * dx1 - (v->fbi.svert[0].z - v->fbi.svert[2].z) * dx2) * tdiv);
- v->fbi.dzdy = (INT32)(((v->fbi.svert[0].z - v->fbi.svert[2].z) * dy1 - (v->fbi.svert[0].z - v->fbi.svert[1].z) * dy2) * tdiv);
+ vd->fbi.startz = (INT32)(vd->fbi.svert[0].z * 4096.0f);
+ vd->fbi.dzdx = (INT32)(((vd->fbi.svert[0].z - vd->fbi.svert[1].z) * dx1 - (vd->fbi.svert[0].z - vd->fbi.svert[2].z) * dx2) * tdiv);
+ vd->fbi.dzdy = (INT32)(((vd->fbi.svert[0].z - vd->fbi.svert[2].z) * dy1 - (vd->fbi.svert[0].z - vd->fbi.svert[1].z) * dy2) * tdiv);
}
/* set up Wb */
tdiv = divisor * 65536.0f * 65536.0f;
- if (v->reg[sSetupMode].u & (1 << 3))
+ if (vd->reg[sSetupMode].u & (1 << 3))
{
- v->fbi.startw = v->tmu[0].startw = v->tmu[1].startw = (INT64)(v->fbi.svert[0].wb * 65536.0f * 65536.0f);
- v->fbi.dwdx = v->tmu[0].dwdx = v->tmu[1].dwdx = ((v->fbi.svert[0].wb - v->fbi.svert[1].wb) * dx1 - (v->fbi.svert[0].wb - v->fbi.svert[2].wb) * dx2) * tdiv;
- v->fbi.dwdy = v->tmu[0].dwdy = v->tmu[1].dwdy = ((v->fbi.svert[0].wb - v->fbi.svert[2].wb) * dy1 - (v->fbi.svert[0].wb - v->fbi.svert[1].wb) * dy2) * tdiv;
+ vd->fbi.startw = vd->tmu[0].startw = vd->tmu[1].startw = (INT64)(vd->fbi.svert[0].wb * 65536.0f * 65536.0f);
+ vd->fbi.dwdx = vd->tmu[0].dwdx = vd->tmu[1].dwdx = ((vd->fbi.svert[0].wb - vd->fbi.svert[1].wb) * dx1 - (vd->fbi.svert[0].wb - vd->fbi.svert[2].wb) * dx2) * tdiv;
+ vd->fbi.dwdy = vd->tmu[0].dwdy = vd->tmu[1].dwdy = ((vd->fbi.svert[0].wb - vd->fbi.svert[2].wb) * dy1 - (vd->fbi.svert[0].wb - vd->fbi.svert[1].wb) * dy2) * tdiv;
}
/* set up W0 */
- if (v->reg[sSetupMode].u & (1 << 4))
+ if (vd->reg[sSetupMode].u & (1 << 4))
{
- v->tmu[0].startw = v->tmu[1].startw = (INT64)(v->fbi.svert[0].w0 * 65536.0f * 65536.0f);
- v->tmu[0].dwdx = v->tmu[1].dwdx = ((v->fbi.svert[0].w0 - v->fbi.svert[1].w0) * dx1 - (v->fbi.svert[0].w0 - v->fbi.svert[2].w0) * dx2) * tdiv;
- v->tmu[0].dwdy = v->tmu[1].dwdy = ((v->fbi.svert[0].w0 - v->fbi.svert[2].w0) * dy1 - (v->fbi.svert[0].w0 - v->fbi.svert[1].w0) * dy2) * tdiv;
+ vd->tmu[0].startw = vd->tmu[1].startw = (INT64)(vd->fbi.svert[0].w0 * 65536.0f * 65536.0f);
+ vd->tmu[0].dwdx = vd->tmu[1].dwdx = ((vd->fbi.svert[0].w0 - vd->fbi.svert[1].w0) * dx1 - (vd->fbi.svert[0].w0 - vd->fbi.svert[2].w0) * dx2) * tdiv;
+ vd->tmu[0].dwdy = vd->tmu[1].dwdy = ((vd->fbi.svert[0].w0 - vd->fbi.svert[2].w0) * dy1 - (vd->fbi.svert[0].w0 - vd->fbi.svert[1].w0) * dy2) * tdiv;
}
/* set up S0,T0 */
- if (v->reg[sSetupMode].u & (1 << 5))
+ if (vd->reg[sSetupMode].u & (1 << 5))
{
- v->tmu[0].starts = v->tmu[1].starts = (INT64)(v->fbi.svert[0].s0 * 65536.0f * 65536.0f);
- v->tmu[0].dsdx = v->tmu[1].dsdx = ((v->fbi.svert[0].s0 - v->fbi.svert[1].s0) * dx1 - (v->fbi.svert[0].s0 - v->fbi.svert[2].s0) * dx2) * tdiv;
- v->tmu[0].dsdy = v->tmu[1].dsdy = ((v->fbi.svert[0].s0 - v->fbi.svert[2].s0) * dy1 - (v->fbi.svert[0].s0 - v->fbi.svert[1].s0) * dy2) * tdiv;
- v->tmu[0].startt = v->tmu[1].startt = (INT64)(v->fbi.svert[0].t0 * 65536.0f * 65536.0f);
- v->tmu[0].dtdx = v->tmu[1].dtdx = ((v->fbi.svert[0].t0 - v->fbi.svert[1].t0) * dx1 - (v->fbi.svert[0].t0 - v->fbi.svert[2].t0) * dx2) * tdiv;
- v->tmu[0].dtdy = v->tmu[1].dtdy = ((v->fbi.svert[0].t0 - v->fbi.svert[2].t0) * dy1 - (v->fbi.svert[0].t0 - v->fbi.svert[1].t0) * dy2) * tdiv;
+ vd->tmu[0].starts = vd->tmu[1].starts = (INT64)(vd->fbi.svert[0].s0 * 65536.0f * 65536.0f);
+ vd->tmu[0].dsdx = vd->tmu[1].dsdx = ((vd->fbi.svert[0].s0 - vd->fbi.svert[1].s0) * dx1 - (vd->fbi.svert[0].s0 - vd->fbi.svert[2].s0) * dx2) * tdiv;
+ vd->tmu[0].dsdy = vd->tmu[1].dsdy = ((vd->fbi.svert[0].s0 - vd->fbi.svert[2].s0) * dy1 - (vd->fbi.svert[0].s0 - vd->fbi.svert[1].s0) * dy2) * tdiv;
+ vd->tmu[0].startt = vd->tmu[1].startt = (INT64)(vd->fbi.svert[0].t0 * 65536.0f * 65536.0f);
+ vd->tmu[0].dtdx = vd->tmu[1].dtdx = ((vd->fbi.svert[0].t0 - vd->fbi.svert[1].t0) * dx1 - (vd->fbi.svert[0].t0 - vd->fbi.svert[2].t0) * dx2) * tdiv;
+ vd->tmu[0].dtdy = vd->tmu[1].dtdy = ((vd->fbi.svert[0].t0 - vd->fbi.svert[2].t0) * dy1 - (vd->fbi.svert[0].t0 - vd->fbi.svert[1].t0) * dy2) * tdiv;
}
/* set up W1 */
- if (v->reg[sSetupMode].u & (1 << 6))
+ if (vd->reg[sSetupMode].u & (1 << 6))
{
- v->tmu[1].startw = (INT64)(v->fbi.svert[0].w1 * 65536.0f * 65536.0f);
- v->tmu[1].dwdx = ((v->fbi.svert[0].w1 - v->fbi.svert[1].w1) * dx1 - (v->fbi.svert[0].w1 - v->fbi.svert[2].w1) * dx2) * tdiv;
- v->tmu[1].dwdy = ((v->fbi.svert[0].w1 - v->fbi.svert[2].w1) * dy1 - (v->fbi.svert[0].w1 - v->fbi.svert[1].w1) * dy2) * tdiv;
+ vd->tmu[1].startw = (INT64)(vd->fbi.svert[0].w1 * 65536.0f * 65536.0f);
+ vd->tmu[1].dwdx = ((vd->fbi.svert[0].w1 - vd->fbi.svert[1].w1) * dx1 - (vd->fbi.svert[0].w1 - vd->fbi.svert[2].w1) * dx2) * tdiv;
+ vd->tmu[1].dwdy = ((vd->fbi.svert[0].w1 - vd->fbi.svert[2].w1) * dy1 - (vd->fbi.svert[0].w1 - vd->fbi.svert[1].w1) * dy2) * tdiv;
}
/* set up S1,T1 */
- if (v->reg[sSetupMode].u & (1 << 7))
+ if (vd->reg[sSetupMode].u & (1 << 7))
{
- v->tmu[1].starts = (INT64)(v->fbi.svert[0].s1 * 65536.0f * 65536.0f);
- v->tmu[1].dsdx = ((v->fbi.svert[0].s1 - v->fbi.svert[1].s1) * dx1 - (v->fbi.svert[0].s1 - v->fbi.svert[2].s1) * dx2) * tdiv;
- v->tmu[1].dsdy = ((v->fbi.svert[0].s1 - v->fbi.svert[2].s1) * dy1 - (v->fbi.svert[0].s1 - v->fbi.svert[1].s1) * dy2) * tdiv;
- v->tmu[1].startt = (INT64)(v->fbi.svert[0].t1 * 65536.0f * 65536.0f);
- v->tmu[1].dtdx = ((v->fbi.svert[0].t1 - v->fbi.svert[1].t1) * dx1 - (v->fbi.svert[0].t1 - v->fbi.svert[2].t1) * dx2) * tdiv;
- v->tmu[1].dtdy = ((v->fbi.svert[0].t1 - v->fbi.svert[2].t1) * dy1 - (v->fbi.svert[0].t1 - v->fbi.svert[1].t1) * dy2) * tdiv;
+ vd->tmu[1].starts = (INT64)(vd->fbi.svert[0].s1 * 65536.0f * 65536.0f);
+ vd->tmu[1].dsdx = ((vd->fbi.svert[0].s1 - vd->fbi.svert[1].s1) * dx1 - (vd->fbi.svert[0].s1 - vd->fbi.svert[2].s1) * dx2) * tdiv;
+ vd->tmu[1].dsdy = ((vd->fbi.svert[0].s1 - vd->fbi.svert[2].s1) * dy1 - (vd->fbi.svert[0].s1 - vd->fbi.svert[1].s1) * dy2) * tdiv;
+ vd->tmu[1].startt = (INT64)(vd->fbi.svert[0].t1 * 65536.0f * 65536.0f);
+ vd->tmu[1].dtdx = ((vd->fbi.svert[0].t1 - vd->fbi.svert[1].t1) * dx1 - (vd->fbi.svert[0].t1 - vd->fbi.svert[2].t1) * dx2) * tdiv;
+ vd->tmu[1].dtdy = ((vd->fbi.svert[0].t1 - vd->fbi.svert[2].t1) * dy1 - (vd->fbi.svert[0].t1 - vd->fbi.svert[1].t1) * dy2) * tdiv;
}
/* draw the triangle */
- v->fbi.cheating_allowed = 1;
- return triangle(v);
+ vd->fbi.cheating_allowed = 1;
+ return triangle(vd);
}
@@ -5591,81 +5518,82 @@ static INT32 setup_and_draw_triangle(voodoo_state *v)
setup and create the work item
-------------------------------------------------*/
-static INT32 triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int texcount)
+INT32 voodoo_device::triangle_create_work_item(voodoo_device* vd, UINT16 *drawbuf, int texcount)
{
- poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(v->poly);
- raster_info *info = find_rasterizer(v, texcount);
+ poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(vd->poly);
+
+ raster_info *info = find_rasterizer(vd, texcount);
poly_vertex vert[3];
/* fill in the vertex data */
- vert[0].x = (float)v->fbi.ax * (1.0f / 16.0f);
- vert[0].y = (float)v->fbi.ay * (1.0f / 16.0f);
- vert[1].x = (float)v->fbi.bx * (1.0f / 16.0f);
- vert[1].y = (float)v->fbi.by * (1.0f / 16.0f);
- vert[2].x = (float)v->fbi.cx * (1.0f / 16.0f);
- vert[2].y = (float)v->fbi.cy * (1.0f / 16.0f);
+ vert[0].x = (float)vd->fbi.ax * (1.0f / 16.0f);
+ vert[0].y = (float)vd->fbi.ay * (1.0f / 16.0f);
+ vert[1].x = (float)vd->fbi.bx * (1.0f / 16.0f);
+ vert[1].y = (float)vd->fbi.by * (1.0f / 16.0f);
+ vert[2].x = (float)vd->fbi.cx * (1.0f / 16.0f);
+ vert[2].y = (float)vd->fbi.cy * (1.0f / 16.0f);
/* fill in the extra data */
- extra->state = v;
+ extra->device = vd;
extra->info = info;
/* fill in triangle parameters */
- extra->ax = v->fbi.ax;
- extra->ay = v->fbi.ay;
- extra->startr = v->fbi.startr;
- extra->startg = v->fbi.startg;
- extra->startb = v->fbi.startb;
- extra->starta = v->fbi.starta;
- extra->startz = v->fbi.startz;
- extra->startw = v->fbi.startw;
- extra->drdx = v->fbi.drdx;
- extra->dgdx = v->fbi.dgdx;
- extra->dbdx = v->fbi.dbdx;
- extra->dadx = v->fbi.dadx;
- extra->dzdx = v->fbi.dzdx;
- extra->dwdx = v->fbi.dwdx;
- extra->drdy = v->fbi.drdy;
- extra->dgdy = v->fbi.dgdy;
- extra->dbdy = v->fbi.dbdy;
- extra->dady = v->fbi.dady;
- extra->dzdy = v->fbi.dzdy;
- extra->dwdy = v->fbi.dwdy;
+ extra->ax = vd->fbi.ax;
+ extra->ay = vd->fbi.ay;
+ extra->startr = vd->fbi.startr;
+ extra->startg = vd->fbi.startg;
+ extra->startb = vd->fbi.startb;
+ extra->starta = vd->fbi.starta;
+ extra->startz = vd->fbi.startz;
+ extra->startw = vd->fbi.startw;
+ extra->drdx = vd->fbi.drdx;
+ extra->dgdx = vd->fbi.dgdx;
+ extra->dbdx = vd->fbi.dbdx;
+ extra->dadx = vd->fbi.dadx;
+ extra->dzdx = vd->fbi.dzdx;
+ extra->dwdx = vd->fbi.dwdx;
+ extra->drdy = vd->fbi.drdy;
+ extra->dgdy = vd->fbi.dgdy;
+ extra->dbdy = vd->fbi.dbdy;
+ extra->dady = vd->fbi.dady;
+ extra->dzdy = vd->fbi.dzdy;
+ extra->dwdy = vd->fbi.dwdy;
/* fill in texture 0 parameters */
if (texcount > 0)
{
- extra->starts0 = v->tmu[0].starts;
- extra->startt0 = v->tmu[0].startt;
- extra->startw0 = v->tmu[0].startw;
- extra->ds0dx = v->tmu[0].dsdx;
- extra->dt0dx = v->tmu[0].dtdx;
- extra->dw0dx = v->tmu[0].dwdx;
- extra->ds0dy = v->tmu[0].dsdy;
- extra->dt0dy = v->tmu[0].dtdy;
- extra->dw0dy = v->tmu[0].dwdy;
- extra->lodbase0 = prepare_tmu(&v->tmu[0]);
- v->stats.texture_mode[TEXMODE_FORMAT(v->tmu[0].reg[textureMode].u)]++;
+ extra->starts0 = vd->tmu[0].starts;
+ extra->startt0 = vd->tmu[0].startt;
+ extra->startw0 = vd->tmu[0].startw;
+ extra->ds0dx = vd->tmu[0].dsdx;
+ extra->dt0dx = vd->tmu[0].dtdx;
+ extra->dw0dx = vd->tmu[0].dwdx;
+ extra->ds0dy = vd->tmu[0].dsdy;
+ extra->dt0dy = vd->tmu[0].dtdy;
+ extra->dw0dy = vd->tmu[0].dwdy;
+ extra->lodbase0 = prepare_tmu(&vd->tmu[0]);
+ vd->stats.texture_mode[TEXMODE_FORMAT(vd->tmu[0].reg[textureMode].u)]++;
/* fill in texture 1 parameters */
if (texcount > 1)
{
- extra->starts1 = v->tmu[1].starts;
- extra->startt1 = v->tmu[1].startt;
- extra->startw1 = v->tmu[1].startw;
- extra->ds1dx = v->tmu[1].dsdx;
- extra->dt1dx = v->tmu[1].dtdx;
- extra->dw1dx = v->tmu[1].dwdx;
- extra->ds1dy = v->tmu[1].dsdy;
- extra->dt1dy = v->tmu[1].dtdy;
- extra->dw1dy = v->tmu[1].dwdy;
- extra->lodbase1 = prepare_tmu(&v->tmu[1]);
- v->stats.texture_mode[TEXMODE_FORMAT(v->tmu[1].reg[textureMode].u)]++;
+ extra->starts1 = vd->tmu[1].starts;
+ extra->startt1 = vd->tmu[1].startt;
+ extra->startw1 = vd->tmu[1].startw;
+ extra->ds1dx = vd->tmu[1].dsdx;
+ extra->dt1dx = vd->tmu[1].dtdx;
+ extra->dw1dx = vd->tmu[1].dwdx;
+ extra->ds1dy = vd->tmu[1].dsdy;
+ extra->dt1dy = vd->tmu[1].dtdy;
+ extra->dw1dy = vd->tmu[1].dwdy;
+ extra->lodbase1 = prepare_tmu(&vd->tmu[1]);
+ vd->stats.texture_mode[TEXMODE_FORMAT(vd->tmu[1].reg[textureMode].u)]++;
}
}
/* farm the rasterization out to other threads */
info->polys++;
- return poly_render_triangle(v->poly, drawbuf, global_cliprect, info->callback, 0, &vert[0], &vert[1], &vert[2]);
+ return poly_render_triangle(vd->poly, drawbuf, global_cliprect, info->callback, 0, &vert[0], &vert[1], &vert[2]);
}
@@ -5679,12 +5607,12 @@ static INT32 triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int tex
hash table
-------------------------------------------------*/
-static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo)
+raster_info *voodoo_device::add_rasterizer(voodoo_device *vd, const raster_info *cinfo)
{
- raster_info *info = &v->rasterizer[v->next_rasterizer++];
+ raster_info *info = &vd->rasterizer[vd->next_rasterizer++];
int hash = compute_raster_hash(cinfo);
- assert_always(v->next_rasterizer <= MAX_RASTERIZERS, "Out of space for new rasterizers!");
+ assert_always(vd->next_rasterizer <= MAX_RASTERIZERS, "Out of space for new rasterizers!");
/* make a copy of the info */
*info = *cinfo;
@@ -5695,8 +5623,8 @@ static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo)
info->hash = hash;
/* hook us into the hash table */
- info->next = v->raster_hash[hash];
- v->raster_hash[hash] = info;
+ info->next = vd->raster_hash[hash];
+ vd->raster_hash[hash] = info;
if (LOG_RASTERIZERS)
printf("Adding rasterizer @ %p : cp=%08X am=%08X %08X fbzM=%08X tm0=%08X tm1=%08X (hash=%d)\n",
@@ -5714,25 +5642,25 @@ static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo)
it, creating a new one if necessary
-------------------------------------------------*/
-static raster_info *find_rasterizer(voodoo_state *v, int texcount)
+raster_info *voodoo_device::find_rasterizer(voodoo_device *vd, int texcount)
{
raster_info *info, *prev = nullptr;
raster_info curinfo;
int hash;
/* build an info struct with all the parameters */
- curinfo.eff_color_path = normalize_color_path(v->reg[fbzColorPath].u);
- curinfo.eff_alpha_mode = normalize_alpha_mode(v->reg[alphaMode].u);
- curinfo.eff_fog_mode = normalize_fog_mode(v->reg[fogMode].u);
- curinfo.eff_fbz_mode = normalize_fbz_mode(v->reg[fbzMode].u);
- curinfo.eff_tex_mode_0 = (texcount >= 1) ? normalize_tex_mode(v->tmu[0].reg[textureMode].u) : 0xffffffff;
- curinfo.eff_tex_mode_1 = (texcount >= 2) ? normalize_tex_mode(v->tmu[1].reg[textureMode].u) : 0xffffffff;
+ curinfo.eff_color_path = normalize_color_path(vd->reg[fbzColorPath].u);
+ curinfo.eff_alpha_mode = normalize_alpha_mode(vd->reg[alphaMode].u);
+ curinfo.eff_fog_mode = normalize_fog_mode(vd->reg[fogMode].u);
+ curinfo.eff_fbz_mode = normalize_fbz_mode(vd->reg[fbzMode].u);
+ curinfo.eff_tex_mode_0 = (texcount >= 1) ? normalize_tex_mode(vd->tmu[0].reg[textureMode].u) : 0xffffffff;
+ curinfo.eff_tex_mode_1 = (texcount >= 2) ? normalize_tex_mode(vd->tmu[1].reg[textureMode].u) : 0xffffffff;
/* compute the hash */
hash = compute_raster_hash(&curinfo);
/* find the appropriate hash entry */
- for (info = v->raster_hash[hash]; info; prev = info, info = info->next)
+ for (info = vd->raster_hash[hash]; info; prev = info, info = info->next)
if (info->eff_color_path == curinfo.eff_color_path &&
info->eff_alpha_mode == curinfo.eff_alpha_mode &&
info->eff_fog_mode == curinfo.eff_fog_mode &&
@@ -5744,8 +5672,8 @@ static raster_info *find_rasterizer(voodoo_state *v, int texcount)
if (prev)
{
prev->next = info->next;
- info->next = v->raster_hash[hash];
- v->raster_hash[hash] = info;
+ info->next = vd->raster_hash[hash];
+ vd->raster_hash[hash] = info;
}
/* return the result */
@@ -5761,7 +5689,7 @@ static raster_info *find_rasterizer(voodoo_state *v, int texcount)
curinfo.next = nullptr;
curinfo.hash = hash;
- return add_rasterizer(v, &curinfo);
+ return add_rasterizer(vd, &curinfo);
}
@@ -5770,7 +5698,7 @@ static raster_info *find_rasterizer(voodoo_state *v, int texcount)
the current rasterizer usage patterns
-------------------------------------------------*/
-static void dump_rasterizer_stats(voodoo_state *v)
+void voodoo_device::dump_rasterizer_stats(voodoo_device *vd)
{
static UINT8 display_index;
raster_info *cur, *best;
@@ -5786,7 +5714,7 @@ static void dump_rasterizer_stats(voodoo_state *v)
/* find the highest entry */
for (hash = 0; hash < RASTER_HASH_SIZE; hash++)
- for (cur = v->raster_hash[hash]; cur; cur = cur->next)
+ for (cur = vd->raster_hash[hash]; cur; cur = cur->next)
if (cur->display != display_index && (best == nullptr || cur->hits > best->hits))
best = cur;
@@ -5822,12 +5750,10 @@ voodoo_device::voodoo_device(const machine_config &mconfig, device_type type, co
m_vblank(*this),
m_stall(*this)
{
- m_token = global_alloc_clear<voodoo_state>();
}
voodoo_device::~voodoo_device()
{
- global_free(m_token);
}
//-------------------------------------------------
@@ -5846,8 +5772,7 @@ void voodoo_device::device_config_complete()
void voodoo_device::device_reset()
{
- voodoo_state *v = get_safe_token(this);
- soft_reset(v);
+ soft_reset(this);
}
//-------------------------------------------------
@@ -5856,11 +5781,9 @@ void voodoo_device::device_reset()
void voodoo_device::device_stop()
{
- voodoo_state *v = get_safe_token(this);
-
/* release the work queue, ensuring all work is finished */
- if (v->poly != nullptr)
- poly_free(v->poly);
+ if (poly != nullptr)
+ poly_free(poly);
}
@@ -5947,26 +5870,26 @@ void voodoo_3_device::device_start()
implementation of the 'fastfill' command
-------------------------------------------------*/
-static void raster_fastfill(void *destbase, INT32 y, const poly_extent *extent, const void *extradata, int threadid)
+void voodoo_device::raster_fastfill(void *destbase, INT32 y, const poly_extent *extent, const void *extradata, int threadid)
{
const poly_extra_data *extra = (const poly_extra_data *)extradata;
- voodoo_state *v = extra->state;
- stats_block *stats = &v->thread_stats[threadid];
+ voodoo_device* vd = extra->device;
+ stats_block *stats = &vd->thread_stats[threadid];
INT32 startx = extent->startx;
INT32 stopx = extent->stopx;
int scry, x;
/* determine the screen Y */
scry = y;
- if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
- scry = (v->fbi.yorigin - y) & 0x3ff;
+ if (FBZMODE_Y_ORIGIN(vd->reg[fbzMode].u))
+ scry = (vd->fbi.yorigin - y) & 0x3ff;
/* fill this RGB row */
- if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u))
+ if (FBZMODE_RGB_BUFFER_MASK(vd->reg[fbzMode].u))
{
const UINT16 *ditherow = &extra->dither[(y & 3) * 4];
UINT64 expanded = *(UINT64 *)ditherow;
- UINT16 *dest = (UINT16 *)destbase + scry * v->fbi.rowpixels;
+ UINT16 *dest = (UINT16 *)destbase + scry * vd->fbi.rowpixels;
for (x = startx; x < stopx && (x & 3) != 0; x++)
dest[x] = ditherow[x & 3];
@@ -5978,11 +5901,11 @@ static void raster_fastfill(void *destbase, INT32 y, const poly_extent *extent,
}
/* fill this dest buffer row */
- if (FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u) && v->fbi.auxoffs != ~0)
+ if (FBZMODE_AUX_BUFFER_MASK(vd->reg[fbzMode].u) && vd->fbi.auxoffs != ~0)
{
- UINT16 color = v->reg[zaColor].u;
+ UINT16 color = vd->reg[zaColor].u;
UINT64 expanded = ((UINT64)color << 48) | ((UINT64)color << 32) | (color << 16) | color;
- UINT16 *dest = (UINT16 *)(v->fbi.ram + v->fbi.auxoffs) + scry * v->fbi.rowpixels;
+ UINT16 *dest = (UINT16 *)(vd->fbi.ram + vd->fbi.auxoffs) + scry * vd->fbi.rowpixels;
for (x = startx; x < stopx && (x & 3) != 0; x++)
dest[x] = color;
@@ -5998,21 +5921,21 @@ static void raster_fastfill(void *destbase, INT32 y, const poly_extent *extent,
generic_0tmu - generic rasterizer for 0 TMUs
-------------------------------------------------*/
-RASTERIZER(generic_0tmu, 0, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
- v->reg[fogMode].u, 0, 0)
+RASTERIZER(generic_0tmu, 0, vd->reg[fbzColorPath].u, vd->reg[fbzMode].u, vd->reg[alphaMode].u,
+ vd->reg[fogMode].u, 0, 0)
/*-------------------------------------------------
generic_1tmu - generic rasterizer for 1 TMU
-------------------------------------------------*/
-RASTERIZER(generic_1tmu, 1, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
- v->reg[fogMode].u, v->tmu[0].reg[textureMode].u, 0)
+RASTERIZER(generic_1tmu, 1, vd->reg[fbzColorPath].u, vd->reg[fbzMode].u, vd->reg[alphaMode].u,
+ vd->reg[fogMode].u, vd->tmu[0].reg[textureMode].u, 0)
/*-------------------------------------------------
generic_2tmu - generic rasterizer for 2 TMUs
-------------------------------------------------*/
-RASTERIZER(generic_2tmu, 2, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
- v->reg[fogMode].u, v->tmu[0].reg[textureMode].u, v->tmu[1].reg[textureMode].u)
+RASTERIZER(generic_2tmu, 2, vd->reg[fbzColorPath].u, vd->reg[fbzMode].u, vd->reg[alphaMode].u,
+ vd->reg[fogMode].u, vd->tmu[0].reg[textureMode].u, vd->tmu[1].reg[textureMode].u)