From 0dc00ab33f8009ef48db5f9cbd907f126129ddaf Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 23 Jun 2008 01:28:05 +0000 Subject: [PATCH] Converted voodoo into a proper device. Updated drivers accordingly. --- src/emu/machine/idectrl.h | 4 +- src/emu/video/vooddefs.h | 463 +++++++++++------------ src/emu/video/voodoo.c | 743 +++++++++++++++++-------------------- src/emu/video/voodoo.h | 124 +++++-- src/mame/drivers/gticlub.c | 50 +-- src/mame/drivers/hornet.c | 114 +++--- src/mame/drivers/nwk-tr.c | 18 +- src/mame/drivers/seattle.c | 84 ++--- src/mame/drivers/vegas.c | 126 +++---- src/mame/drivers/viper.c | 26 +- src/mame/machine/konppc.c | 33 +- src/mame/machine/konppc.h | 12 +- 12 files changed, 881 insertions(+), 916 deletions(-) diff --git a/src/emu/machine/idectrl.h b/src/emu/machine/idectrl.h index 9c6c20f2545..09d5566ac4c 100644 --- a/src/emu/machine/idectrl.h +++ b/src/emu/machine/idectrl.h @@ -31,7 +31,7 @@ struct _ide_config /*************************************************************************** - TIMER DEVICE CONFIGURATION MACROS + DEVICE CONFIGURATION MACROS ***************************************************************************/ #define MDRV_IDE_CONTROLLER_ADD(_tag, _disknum, _callback) \ @@ -68,7 +68,7 @@ READ16_DEVICE_HANDLER( ide_controller16_r ); WRITE16_DEVICE_HANDLER( ide_controller16_w ); -/* ----- timer device interface ----- */ +/* ----- device interface ----- */ /* device get info callback */ #define IDE_CONTROLLER DEVICE_GET_INFO_NAME(ide_controller) diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index d424d9dedf1..78370393e68 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -1340,9 +1340,9 @@ typedef struct _rgba rgba; struct _rgba { #ifdef LSB_FIRST - UINT8 b, g, r, a; + UINT8 b, g, r, a; #else - UINT8 a, r, g, b; + UINT8 a, r, g, b; #endif }; @@ -1350,10 +1350,10 @@ struct _rgba typedef union _voodoo_reg voodoo_reg; union _voodoo_reg { - INT32 i; - UINT32 u; - float f; - rgba rgb; + INT32 i; + UINT32 u; + float f; + rgba rgb; }; @@ -1363,26 +1363,26 @@ typedef voodoo_reg rgb_union; typedef struct _voodoo_stats voodoo_stats; struct _voodoo_stats { - UINT8 lastkey; /* last key state */ - UINT8 display; /* display stats? */ - INT32 swaps; /* total swaps */ - INT32 stalls; /* total stalls */ - INT32 total_triangles; /* total triangles */ - INT32 total_pixels_in; /* total pixels in */ - INT32 total_pixels_out; /* total pixels out */ - INT32 total_chroma_fail; /* total chroma fail */ - INT32 total_zfunc_fail; /* total z func fail */ - INT32 total_afunc_fail; /* total a func fail */ - INT32 total_clipped; /* total clipped */ - INT32 total_stippled; /* total stippled */ - INT32 lfb_writes; /* LFB writes */ - INT32 lfb_reads; /* LFB reads */ - INT32 reg_writes; /* register writes */ - INT32 reg_reads; /* register reads */ - INT32 tex_writes; /* texture writes */ - INT32 texture_mode[16]; /* 16 different texture modes */ - UINT8 render_override; /* render override */ - char buffer[1024]; /* string */ + UINT8 lastkey; /* last key state */ + UINT8 display; /* display stats? */ + INT32 swaps; /* total swaps */ + INT32 stalls; /* total stalls */ + INT32 total_triangles; /* total triangles */ + INT32 total_pixels_in; /* total pixels in */ + INT32 total_pixels_out; /* total pixels out */ + INT32 total_chroma_fail; /* total chroma fail */ + INT32 total_zfunc_fail; /* total z func fail */ + INT32 total_afunc_fail; /* total a func fail */ + INT32 total_clipped; /* total clipped */ + INT32 total_stippled; /* total stippled */ + INT32 lfb_writes; /* LFB writes */ + INT32 lfb_reads; /* LFB reads */ + INT32 reg_writes; /* register writes */ + INT32 reg_reads; /* register reads */ + INT32 tex_writes; /* texture writes */ + INT32 texture_mode[16]; /* 16 different texture modes */ + UINT8 render_override; /* render override */ + char buffer[1024]; /* string */ }; @@ -1390,319 +1390,320 @@ struct _voodoo_stats typedef struct _stats_block stats_block; struct _stats_block { - INT32 pixels_in; /* pixels in statistic */ - INT32 pixels_out; /* pixels out statistic */ - INT32 chroma_fail; /* chroma test fail statistic */ - INT32 zfunc_fail; /* z function test fail statistic */ - INT32 afunc_fail; /* alpha function test fail statistic */ - INT32 clip_fail; /* clipping fail statistic */ - INT32 stipple_count; /* stipple statistic */ - INT32 filler[64/4 - 7]; /* pad this structure to 64 bytes */ + INT32 pixels_in; /* pixels in statistic */ + INT32 pixels_out; /* pixels out statistic */ + INT32 chroma_fail; /* chroma test fail statistic */ + INT32 zfunc_fail; /* z function test fail statistic */ + INT32 afunc_fail; /* alpha function test fail statistic */ + INT32 clip_fail; /* clipping fail statistic */ + INT32 stipple_count; /* stipple statistic */ + INT32 filler[64/4 - 7]; /* pad this structure to 64 bytes */ }; typedef struct _fifo_state fifo_state; struct _fifo_state { - UINT32 * base; /* base of the FIFO */ - INT32 size; /* size of the FIFO */ - INT32 in; /* input pointer */ - INT32 out; /* output pointer */ + UINT32 * base; /* base of the FIFO */ + INT32 size; /* size of the FIFO */ + INT32 in; /* input pointer */ + INT32 out; /* output pointer */ }; typedef struct _cmdfifo_info cmdfifo_info; struct _cmdfifo_info { - UINT8 enable; /* enabled? */ - UINT8 count_holes; /* count holes? */ - UINT32 base; /* base address in framebuffer RAM */ - UINT32 end; /* end address in framebuffer RAM */ - UINT32 rdptr; /* current read pointer */ - UINT32 amin; /* minimum address */ - UINT32 amax; /* maximum address */ - UINT32 depth; /* current depth */ - UINT32 holes; /* number of holes */ + UINT8 enable; /* enabled? */ + UINT8 count_holes; /* count holes? */ + UINT32 base; /* base address in framebuffer RAM */ + UINT32 end; /* end address in framebuffer RAM */ + UINT32 rdptr; /* current read pointer */ + UINT32 amin; /* minimum address */ + UINT32 amax; /* maximum address */ + UINT32 depth; /* current depth */ + UINT32 holes; /* number of holes */ }; typedef struct _pci_state pci_state; struct _pci_state { - fifo_state fifo; /* PCI FIFO */ - UINT32 init_enable; /* initEnable value */ - UINT8 stall_state; /* state of the system if we're stalled */ - void (*stall_callback)(running_machine *, int); /* callback for stalling/unstalling */ - UINT8 op_pending; /* true if an operation is pending */ - attotime op_end_time; /* time when the pending operation ends */ - emu_timer *continue_timer; /* timer to use to continue processing */ - UINT32 fifo_mem[64*2]; /* memory backing the PCI FIFO */ + fifo_state fifo; /* PCI FIFO */ + UINT32 init_enable; /* initEnable value */ + UINT8 stall_state; /* state of the system if we're stalled */ + voodoo_stall_func stall_callback; /* callback for stalling/unstalling */ + UINT8 op_pending; /* true if an operation is pending */ + attotime op_end_time; /* time when the pending operation ends */ + emu_timer * continue_timer; /* timer to use to continue processing */ + UINT32 fifo_mem[64*2]; /* memory backing the PCI FIFO */ }; typedef struct _ncc_table ncc_table; struct _ncc_table { - UINT8 dirty; /* is the texel lookup dirty? */ - voodoo_reg *reg; /* pointer to our registers */ - INT32 ir[4], ig[4], ib[4]; /* I values for R,G,B */ - INT32 qr[4], qg[4], qb[4]; /* Q values for R,G,B */ - INT32 y[16]; /* Y values */ - rgb_t * palette; /* pointer to associated RGB palette */ - rgb_t * palettea; /* pointer to associated ARGB palette */ - rgb_t texel[256]; /* texel lookup */ + UINT8 dirty; /* is the texel lookup dirty? */ + voodoo_reg * reg; /* pointer to our registers */ + INT32 ir[4], ig[4], ib[4]; /* I values for R,G,B */ + INT32 qr[4], qg[4], qb[4]; /* Q values for R,G,B */ + INT32 y[16]; /* Y values */ + rgb_t * palette; /* pointer to associated RGB palette */ + rgb_t * palettea; /* pointer to associated ARGB palette */ + rgb_t texel[256]; /* texel lookup */ }; typedef struct _tmu_state tmu_state; struct _tmu_state { - UINT8 * ram; /* pointer to our RAM */ - UINT32 mask; /* mask to apply to pointers */ - voodoo_reg *reg; /* pointer to our register base */ - UINT32 regdirty; /* true if the LOD/mode/base registers have changed */ + UINT8 * ram; /* pointer to our RAM */ + UINT32 mask; /* mask to apply to pointers */ + voodoo_reg * reg; /* pointer to our register base */ + UINT32 regdirty; /* true if the LOD/mode/base registers have changed */ - UINT32 texaddr_mask; /* mask for texture address */ - UINT8 texaddr_shift; /* shift for texture address */ + UINT32 texaddr_mask; /* mask for texture address */ + UINT8 texaddr_shift; /* shift for texture address */ - INT64 starts, startt; /* starting S,T (14.18) */ - INT64 startw; /* starting W (2.30) */ - INT64 dsdx, dtdx; /* delta S,T per X */ - INT64 dwdx; /* delta W per X */ - INT64 dsdy, dtdy; /* delta S,T per Y */ - INT64 dwdy; /* delta W per Y */ + INT64 starts, startt; /* starting S,T (14.18) */ + INT64 startw; /* starting W (2.30) */ + INT64 dsdx, dtdx; /* delta S,T per X */ + INT64 dwdx; /* delta W per X */ + INT64 dsdy, dtdy; /* delta S,T per Y */ + INT64 dwdy; /* delta W per Y */ - INT32 lodmin, lodmax; /* min, max LOD values */ - INT32 lodbias; /* LOD bias */ - UINT32 lodmask; /* mask of available LODs */ - UINT32 lodoffset[9]; /* offset of texture base for each LOD */ - INT32 detailmax; /* detail clamp */ - INT32 detailbias; /* detail bias */ - UINT8 detailscale; /* detail scale */ + INT32 lodmin, lodmax; /* min, max LOD values */ + INT32 lodbias; /* LOD bias */ + UINT32 lodmask; /* mask of available LODs */ + UINT32 lodoffset[9]; /* offset of texture base for each LOD */ + INT32 detailmax; /* detail clamp */ + INT32 detailbias; /* detail bias */ + UINT8 detailscale; /* detail scale */ - UINT32 wmask; /* mask for the current texture width */ - UINT32 hmask; /* mask for the current texture height */ + UINT32 wmask; /* mask for the current texture width */ + UINT32 hmask; /* mask for the current texture height */ - UINT32 bilinear_mask; /* mask for bilinear resolution (0xf0 for V1, 0xff for V2) */ + UINT32 bilinear_mask; /* mask for bilinear resolution (0xf0 for V1, 0xff for V2) */ - ncc_table ncc[2]; /* two NCC tables */ + ncc_table ncc[2]; /* two NCC tables */ - rgb_t * lookup; /* currently selected lookup */ - rgb_t * texel[16]; /* texel lookups for each format */ + rgb_t * lookup; /* currently selected lookup */ + rgb_t * texel[16]; /* texel lookups for each format */ - rgb_t palette[256]; /* palette lookup table */ - rgb_t palettea[256]; /* palette+alpha lookup table */ + rgb_t palette[256]; /* palette lookup table */ + rgb_t palettea[256]; /* palette+alpha lookup table */ }; typedef struct _tmu_shared_state tmu_shared_state; struct _tmu_shared_state { - rgb_t rgb332[256]; /* RGB 3-3-2 lookup table */ - rgb_t alpha8[256]; /* alpha 8-bit lookup table */ - rgb_t int8[256]; /* intensity 8-bit lookup table */ - rgb_t ai44[256]; /* alpha, intensity 4-4 lookup table */ + rgb_t rgb332[256]; /* RGB 3-3-2 lookup table */ + rgb_t alpha8[256]; /* alpha 8-bit lookup table */ + rgb_t int8[256]; /* intensity 8-bit lookup table */ + rgb_t ai44[256]; /* alpha, intensity 4-4 lookup table */ - rgb_t rgb565[65536]; /* RGB 5-6-5 lookup table */ - rgb_t argb1555[65536]; /* ARGB 1-5-5-5 lookup table */ - rgb_t argb4444[65536]; /* ARGB 4-4-4-4 lookup table */ + rgb_t rgb565[65536]; /* RGB 5-6-5 lookup table */ + rgb_t argb1555[65536]; /* ARGB 1-5-5-5 lookup table */ + rgb_t argb4444[65536]; /* ARGB 4-4-4-4 lookup table */ }; typedef struct _setup_vertex setup_vertex; struct _setup_vertex { - float x, y; /* X, Y coordinates */ - float a, r, g, b; /* A, R, G, B values */ - float z, wb; /* Z and broadcast W values */ - float w0, s0, t0; /* W, S, T for TMU 0 */ - float w1, s1, t1; /* W, S, T for TMU 1 */ + float x, y; /* X, Y coordinates */ + float a, r, g, b; /* A, R, G, B values */ + float z, wb; /* Z and broadcast W values */ + float w0, s0, t0; /* W, S, T for TMU 0 */ + float w1, s1, t1; /* W, S, T for TMU 1 */ }; typedef struct _fbi_state fbi_state; struct _fbi_state { - void * ram; /* pointer to frame buffer RAM */ - UINT32 mask; /* mask to apply to pointers */ - UINT16 * rgb[3]; /* pointer to 3 RGB buffers */ - UINT16 * aux; /* pointer to 1 aux buffer */ - UINT32 rgbmax[3]; /* maximum valid offset in each RGB buffer */ - UINT32 auxmax; /* maximum valid offset in the aux buffer */ + void * ram; /* pointer to frame buffer RAM */ + UINT32 mask; /* mask to apply to pointers */ + UINT16 * rgb[3]; /* pointer to 3 RGB buffers */ + UINT16 * aux; /* pointer to 1 aux buffer */ + UINT32 rgbmax[3]; /* maximum valid offset in each RGB buffer */ + UINT32 auxmax; /* maximum valid offset in the aux buffer */ - UINT8 frontbuf; /* front buffer index */ - UINT8 backbuf; /* back buffer index */ - UINT8 swaps_pending; /* number of pending swaps */ - UINT8 video_changed; /* did the frontbuffer video change? */ + UINT8 frontbuf; /* front buffer index */ + UINT8 backbuf; /* back buffer index */ + UINT8 swaps_pending; /* number of pending swaps */ + UINT8 video_changed; /* did the frontbuffer video change? */ - UINT32 yorigin; /* Y origin subtract value */ - UINT32 lfb_base; /* base of LFB in memory */ - UINT8 lfb_stride; /* stride of LFB accesses in bits */ + UINT32 yorigin; /* Y origin subtract value */ + UINT32 lfb_base; /* base of LFB in memory */ + UINT8 lfb_stride; /* stride of LFB accesses in bits */ - UINT32 width; /* width of current frame buffer */ - UINT32 height; /* height of current frame buffer */ - UINT32 xoffs; /* horizontal offset (back porch) */ - UINT32 yoffs; /* vertical offset (back porch) */ - UINT32 vsyncscan; /* vertical sync scanline */ - UINT32 rowpixels; /* pixels per row */ - UINT32 tile_width; /* width of video tiles */ - UINT32 tile_height; /* height of video tiles */ - UINT32 x_tiles; /* number of tiles in the X direction */ + UINT32 width; /* width of current frame buffer */ + UINT32 height; /* height of current frame buffer */ + UINT32 xoffs; /* horizontal offset (back porch) */ + UINT32 yoffs; /* vertical offset (back porch) */ + UINT32 vsyncscan; /* vertical sync scanline */ + UINT32 rowpixels; /* pixels per row */ + UINT32 tile_width; /* width of video tiles */ + UINT32 tile_height; /* height of video tiles */ + UINT32 x_tiles; /* number of tiles in the X direction */ - emu_timer * vblank_timer; /* VBLANK timer */ - UINT8 vblank; /* VBLANK state */ - UINT8 vblank_count; /* number of VBLANKs since last swap */ - UINT8 vblank_swap_pending; /* a swap is pending, waiting for a vblank */ - UINT8 vblank_swap; /* swap when we hit this count */ - UINT8 vblank_dont_swap; /* don't actually swap when we hit this point */ - void (*vblank_client)(running_machine *, int); /* client callback */ + emu_timer * vblank_timer; /* VBLANK timer */ + UINT8 vblank; /* VBLANK state */ + UINT8 vblank_count; /* number of VBLANKs since last swap */ + UINT8 vblank_swap_pending; /* a swap is pending, waiting for a vblank */ + UINT8 vblank_swap; /* swap when we hit this count */ + UINT8 vblank_dont_swap; /* don't actually swap when we hit this point */ + voodoo_vblank_func vblank_client; /* client callback */ /* triangle setup info */ - UINT8 cheating_allowed; /* allow cheating? */ - INT32 sign; /* triangle sign */ - INT16 ax, ay; /* vertex A x,y (12.4) */ - INT16 bx, by; /* vertex B x,y (12.4) */ - INT16 cx, cy; /* vertex C x,y (12.4) */ - INT32 startr, startg, startb, starta; /* starting R,G,B,A (12.12) */ - INT32 startz; /* starting Z (20.12) */ - INT64 startw; /* starting W (16.32) */ - INT32 drdx, dgdx, dbdx, dadx; /* delta R,G,B,A per X */ - INT32 dzdx; /* delta Z per X */ - INT64 dwdx; /* delta W per X */ - INT32 drdy, dgdy, dbdy, dady; /* delta R,G,B,A per Y */ - INT32 dzdy; /* delta Z per Y */ - INT64 dwdy; /* delta W per Y */ + UINT8 cheating_allowed; /* allow cheating? */ + INT32 sign; /* triangle sign */ + INT16 ax, ay; /* vertex A x,y (12.4) */ + INT16 bx, by; /* vertex B x,y (12.4) */ + INT16 cx, cy; /* vertex C x,y (12.4) */ + INT32 startr, startg, startb, starta; /* starting R,G,B,A (12.12) */ + INT32 startz; /* starting Z (20.12) */ + INT64 startw; /* starting W (16.32) */ + INT32 drdx, dgdx, dbdx, dadx; /* delta R,G,B,A per X */ + INT32 dzdx; /* delta Z per X */ + INT64 dwdx; /* delta W per X */ + INT32 drdy, dgdy, dbdy, dady; /* delta R,G,B,A per Y */ + INT32 dzdy; /* delta Z per Y */ + INT64 dwdy; /* delta W per Y */ - stats_block lfb_stats; /* LFB-access statistics */ + stats_block lfb_stats; /* LFB-access statistics */ - UINT8 sverts; /* number of vertices ready */ - setup_vertex svert[3]; /* 3 setup vertices */ + UINT8 sverts; /* number of vertices ready */ + setup_vertex svert[3]; /* 3 setup vertices */ - fifo_state fifo; /* framebuffer memory fifo */ - cmdfifo_info cmdfifo[2]; /* command FIFOs */ + fifo_state fifo; /* framebuffer memory fifo */ + cmdfifo_info cmdfifo[2]; /* command FIFOs */ - UINT8 fogblend[64]; /* 64-entry fog table */ - UINT8 fogdelta[64]; /* 64-entry fog table */ - UINT8 fogdelta_mask; /* mask for for delta (0xff for V1, 0xfc for V2) */ + UINT8 fogblend[64]; /* 64-entry fog table */ + UINT8 fogdelta[64]; /* 64-entry fog table */ + UINT8 fogdelta_mask; /* mask for for delta (0xff for V1, 0xfc for V2) */ - rgb_t pen[65536]; /* mapping from pixels to pens */ - rgb_t clut[512]; /* clut gamma data */ - UINT8 clut_dirty; /* do we need to recompute? */ + rgb_t pen[65536]; /* mapping from pixels to pens */ + rgb_t clut[512]; /* clut gamma data */ + UINT8 clut_dirty; /* do we need to recompute? */ }; typedef struct _dac_state dac_state; struct _dac_state { - UINT8 reg[8]; /* 8 registers */ - UINT8 read_result; /* pending read result */ + UINT8 reg[8]; /* 8 registers */ + UINT8 read_result; /* pending read result */ }; typedef struct _raster_info raster_info; struct _raster_info { - struct _raster_info *next; /* pointer to next entry with the same hash */ - poly_draw_scanline_func callback; /* callback pointer */ - UINT8 is_generic; /* TRUE if this is one of the generic rasterizers */ - UINT8 display; /* display index */ - UINT32 hits; /* how many hits (pixels) we've used this for */ - UINT32 polys; /* how many polys we've used this for */ - UINT32 eff_color_path; /* effective fbzColorPath value */ - UINT32 eff_alpha_mode; /* effective alphaMode value */ - UINT32 eff_fog_mode; /* effective fogMode value */ - UINT32 eff_fbz_mode; /* effective fbzMode value */ - UINT32 eff_tex_mode_0; /* effective textureMode value for TMU #0 */ - UINT32 eff_tex_mode_1; /* effective textureMode value for TMU #1 */ + struct _raster_info *next; /* pointer to next entry with the same hash */ + poly_draw_scanline_func callback; /* callback pointer */ + UINT8 is_generic; /* TRUE if this is one of the generic rasterizers */ + UINT8 display; /* display index */ + UINT32 hits; /* how many hits (pixels) we've used this for */ + UINT32 polys; /* how many polys we've used this for */ + UINT32 eff_color_path; /* effective fbzColorPath value */ + UINT32 eff_alpha_mode; /* effective alphaMode value */ + UINT32 eff_fog_mode; /* effective fogMode value */ + UINT32 eff_fbz_mode; /* effective fbzMode value */ + UINT32 eff_tex_mode_0; /* effective textureMode value for TMU #0 */ + UINT32 eff_tex_mode_1; /* effective textureMode value for TMU #1 */ }; struct _poly_extra_data { - voodoo_state *state; /* pointer back to the voodoo state */ - raster_info *info; /* pointer to rasterizer information */ + voodoo_state * state; /* pointer back to the voodoo state */ + raster_info * info; /* pointer to rasterizer information */ - INT16 ax, ay; /* vertex A x,y (12.4) */ - INT32 startr, startg, startb, starta; /* starting R,G,B,A (12.12) */ - INT32 startz; /* starting Z (20.12) */ - INT64 startw; /* starting W (16.32) */ - INT32 drdx, dgdx, dbdx, dadx; /* delta R,G,B,A per X */ - INT32 dzdx; /* delta Z per X */ - INT64 dwdx; /* delta W per X */ - INT32 drdy, dgdy, dbdy, dady; /* delta R,G,B,A per Y */ - INT32 dzdy; /* delta Z per Y */ - INT64 dwdy; /* delta W per Y */ + INT16 ax, ay; /* vertex A x,y (12.4) */ + INT32 startr, startg, startb, starta; /* starting R,G,B,A (12.12) */ + INT32 startz; /* starting Z (20.12) */ + INT64 startw; /* starting W (16.32) */ + INT32 drdx, dgdx, dbdx, dadx; /* delta R,G,B,A per X */ + INT32 dzdx; /* delta Z per X */ + INT64 dwdx; /* delta W per X */ + INT32 drdy, dgdy, dbdy, dady; /* delta R,G,B,A per Y */ + INT32 dzdy; /* delta Z per Y */ + INT64 dwdy; /* delta W per Y */ - INT64 starts0, startt0; /* starting S,T (14.18) */ - INT64 startw0; /* starting W (2.30) */ - INT64 ds0dx, dt0dx; /* delta S,T per X */ - INT64 dw0dx; /* delta W per X */ - INT64 ds0dy, dt0dy; /* delta S,T per Y */ - INT64 dw0dy; /* delta W per Y */ - INT32 lodbase0; /* used during rasterization */ + INT64 starts0, startt0; /* starting S,T (14.18) */ + INT64 startw0; /* starting W (2.30) */ + INT64 ds0dx, dt0dx; /* delta S,T per X */ + INT64 dw0dx; /* delta W per X */ + INT64 ds0dy, dt0dy; /* delta S,T per Y */ + INT64 dw0dy; /* delta W per Y */ + INT32 lodbase0; /* used during rasterization */ - INT64 starts1, startt1; /* starting S,T (14.18) */ - INT64 startw1; /* starting W (2.30) */ - INT64 ds1dx, dt1dx; /* delta S,T per X */ - INT64 dw1dx; /* delta W per X */ - INT64 ds1dy, dt1dy; /* delta S,T per Y */ - INT64 dw1dy; /* delta W per Y */ - INT32 lodbase1; /* used during rasterization */ + INT64 starts1, startt1; /* starting S,T (14.18) */ + INT64 startw1; /* starting W (2.30) */ + INT64 ds1dx, dt1dx; /* delta S,T per X */ + INT64 dw1dx; /* delta W per X */ + INT64 ds1dy, dt1dy; /* delta S,T per Y */ + INT64 dw1dy; /* delta W per Y */ + INT32 lodbase1; /* used during rasterization */ - UINT16 dither[16]; /* dither matrix, for fastfill */ + UINT16 dither[16]; /* dither matrix, for fastfill */ }; typedef struct _banshee_info banshee_info; struct _banshee_info { - UINT32 io[0x40]; /* I/O registers */ - UINT32 agp[0x80]; /* AGP registers */ - UINT8 vga[0x20]; /* VGA registers */ - UINT8 crtc[0x27]; /* VGA CRTC registers */ - UINT8 seq[0x05]; /* VGA sequencer registers */ - UINT8 gc[0x05]; /* VGA graphics controller registers */ - UINT8 att[0x15]; /* VGA attribute registers */ - UINT8 attff; /* VGA attribute flip-flop */ + UINT32 io[0x40]; /* I/O registers */ + UINT32 agp[0x80]; /* AGP registers */ + UINT8 vga[0x20]; /* VGA registers */ + UINT8 crtc[0x27]; /* VGA CRTC registers */ + UINT8 seq[0x05]; /* VGA sequencer registers */ + UINT8 gc[0x05]; /* VGA graphics controller registers */ + UINT8 att[0x15]; /* VGA attribute registers */ + UINT8 attff; /* VGA attribute flip-flop */ }; /* typedef struct _voodoo_state voodoo_state; -- declared above */ struct _voodoo_state { - UINT8 index; /* index of board */ - const device_config *screen; /* the screen we are acting on */ - UINT8 type; /* type of system */ - UINT8 chipmask; /* mask for which chips are available */ - UINT32 freq; /* operating frequency */ - attoseconds_t attoseconds_per_cycle;/* attoseconds per cycle */ - UINT32 extra_cycles; /* extra cycles not yet accounted for */ - int trigger; /* trigger used for stalling */ + UINT8 index; /* index of board */ + const device_config *device; /* pointer to our containing device */ + const device_config *screen; /* the screen we are acting on */ + UINT8 type; /* type of system */ + UINT8 chipmask; /* mask for which chips are available */ + UINT32 freq; /* operating frequency */ + attoseconds_t attoseconds_per_cycle; /* attoseconds per cycle */ + UINT32 extra_cycles; /* extra cycles not yet accounted for */ + int trigger; /* trigger used for stalling */ - voodoo_reg reg[0x400]; /* raw registers */ - const UINT8 *regaccess; /* register access array */ - const char *const *regnames; /* register names array */ - UINT8 alt_regmap; /* enable alternate register map? */ + voodoo_reg reg[0x400]; /* raw registers */ + const UINT8 * regaccess; /* register access array */ + const char *const * regnames; /* register names array */ + UINT8 alt_regmap; /* enable alternate register map? */ - pci_state pci; /* PCI state */ - dac_state dac; /* DAC state */ + pci_state pci; /* PCI state */ + dac_state dac; /* DAC state */ - fbi_state fbi; /* FBI states */ - tmu_state tmu[MAX_TMU]; /* TMU states */ - tmu_shared_state tmushare; /* TMU shared state */ - banshee_info banshee; /* Banshee state */ + fbi_state fbi; /* FBI states */ + tmu_state tmu[MAX_TMU]; /* TMU states */ + tmu_shared_state tmushare; /* TMU shared state */ + banshee_info banshee; /* Banshee state */ - poly_manager *poly; /* polygon manager */ - stats_block *thread_stats; /* per-thread statistics */ + poly_manager * poly; /* polygon manager */ + stats_block * thread_stats; /* per-thread statistics */ - voodoo_stats stats; /* internal statistics */ + voodoo_stats stats; /* internal statistics */ - offs_t last_status_pc; /* PC of last status read (for logging) */ - UINT32 last_status_value; /* value of last status read (for logging) */ + offs_t last_status_pc; /* PC of last status read (for logging) */ + UINT32 last_status_value; /* value of last status read (for logging) */ - int next_rasterizer; /* next rasterizer index */ - raster_info rasterizer[MAX_RASTERIZERS]; /* array of rasterizers */ - raster_info *raster_hash[RASTER_HASH_SIZE]; /* hash table of rasterizers */ + int next_rasterizer; /* next rasterizer index */ + raster_info rasterizer[MAX_RASTERIZERS]; /* array of rasterizers */ + raster_info * raster_hash[RASTER_HASH_SIZE]; /* hash table of rasterizers */ }; diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index a55e6ad22de..9cd2ec08822 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -175,8 +175,6 @@ bits(7:4) and bit(24)), X, and Y: * *************************************/ -static voodoo_state *voodoo[MAX_VOODOO]; - /* fast dither lookup */ static UINT8 dither4_lookup[256*16*2]; static UINT8 dither2_lookup[256*16*2]; @@ -194,25 +192,16 @@ UINT32 voodoo_reciplog[(2 << RECIPLOG_LOOKUP_BITS) + 2]; 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, int type, voodoo_reg *reg, void *memory, int tmem); +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 check_stalled_cpu(running_machine *machine, voodoo_state *v, attotime current_time); +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(running_machine *machine, voodoo_state *v, int state, attotime current_time); +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_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask, int forcefront); static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data); -static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); -static UINT32 voodoo_r(voodoo_state *v, offs_t offset); -static void banshee_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); -static UINT32 banshee_r(voodoo_state *v, offs_t offset, UINT32 mem_mask); -static void banshee_fb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); -static UINT32 banshee_fb_r(voodoo_state *v, offs_t offset, UINT32 mem_mask); -static void banshee_io_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); -static UINT32 banshee_io_r(voodoo_state *v, offs_t offset, UINT32 mem_mask); -static UINT32 banshee_rom_r(voodoo_state *v, offs_t offset, UINT32 mem_mask); /* command handlers */ static INT32 fastfill(voodoo_state *v); @@ -272,188 +261,22 @@ static const raster_info predef_raster_table[] = -/************************************* - * - * Main create routine - * - *************************************/ +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ -void voodoo_start(int which, const device_config *screen, int type, int fbmem_in_mb, int tmem0_in_mb, int tmem1_in_mb) +/*------------------------------------------------- + get_safe_token - makes sure that the passed + in device is, in fact, an IDE controller +-------------------------------------------------*/ + +INLINE voodoo_state *get_safe_token(const device_config *device) { - const raster_info *info; - void *fbmem, *tmumem[2]; - voodoo_state *v; - int val; + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == VOODOO_GRAPHICS); - /* validate */ - assert((which >= 0) && (which < MAX_VOODOO)); - assert(screen != NULL); - assert((type >= 0) && (type < MAX_VOODOO_TYPES)); - assert(fbmem_in_mb >= 0); - assert(tmem0_in_mb >= 0); - assert(tmem1_in_mb >= 0); - - /* allocate memory */ - v = auto_malloc(sizeof(*v)); - memset(v, 0, sizeof(*v)); - voodoo[which] = v; - - /* create a multiprocessor work queue */ - v->poly = poly_alloc(64, sizeof(poly_extra_data), 0); - v->thread_stats = auto_malloc(sizeof(v->thread_stats[0]) * WORK_MAX_THREADS); - - /* create a table of precomputed 1/n and log2(n) values */ - /* n ranges from 1.0000 to 2.0000 */ - for (val = 0; val <= (1 << RECIPLOG_LOOKUP_BITS); val++) - { - UINT32 value = (1 << RECIPLOG_LOOKUP_BITS) + val; - voodoo_reciplog[val*2 + 0] = (1 << (RECIPLOG_LOOKUP_PREC + RECIPLOG_LOOKUP_BITS)) / value; - voodoo_reciplog[val*2 + 1] = (UINT32)(LOGB2((double)value / (double)(1 << RECIPLOG_LOOKUP_BITS)) * (double)(1 << RECIPLOG_LOOKUP_PREC)); - } - - /* create dithering tables */ - for (val = 0; val < 256*16*2; val++) - { - int g = (val >> 0) & 1; - int x = (val >> 1) & 3; - int color = (val >> 3) & 0xff; - int y = (val >> 11) & 3; - - if (!g) - { - dither4_lookup[val] = DITHER_RB(color, dither_matrix_4x4[y * 4 + x]) >> 3; - dither2_lookup[val] = DITHER_RB(color, dither_matrix_2x2[y * 4 + x]) >> 3; - } - else - { - dither4_lookup[val] = DITHER_G(color, dither_matrix_4x4[y * 4 + x]) >> 2; - dither2_lookup[val] = DITHER_G(color, dither_matrix_2x2[y * 4 + x]) >> 2; - } - } - - /* configure type-specific values */ - switch (type) - { - case VOODOO_1: - v->freq = 50000000; - v->regaccess = voodoo_register_access; - v->regnames = voodoo_reg_name; - v->alt_regmap = 0; - v->fbi.lfb_stride = 10; - break; - - case VOODOO_2: - v->freq = 90000000; - v->regaccess = voodoo2_register_access; - v->regnames = voodoo_reg_name; - v->alt_regmap = 0; - v->fbi.lfb_stride = 10; - break; - - case VOODOO_BANSHEE: - v->freq = 90000000; - v->regaccess = banshee_register_access; - v->regnames = banshee_reg_name; - v->alt_regmap = 1; - v->fbi.lfb_stride = 11; - break; - - case VOODOO_3: - v->freq = 132000000; - v->regaccess = banshee_register_access; - v->regnames = banshee_reg_name; - v->alt_regmap = 1; - v->fbi.lfb_stride = 11; - break; - - default: - fatalerror("Unsupported voodoo card in voodoo_start!"); - break; - } - - /* set the type, and initialize the chip mask */ - v->index = which; - v->screen = screen; - v->type = type; - v->chipmask = 0x01; - v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq; - v->trigger = 51324 + which; - - /* build the rasterizer table */ - for (info = predef_raster_table; info->callback; info++) - add_rasterizer(v, 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 = timer_alloc(stall_cpu_callback, v); - - /* allocate memory */ - if (type <= VOODOO_2) - { - /* separate FB/TMU memory */ - fbmem = auto_malloc(fbmem_in_mb << 20); - tmumem[0] = auto_malloc(tmem0_in_mb << 20); - tmumem[1] = tmem1_in_mb ? auto_malloc(tmem1_in_mb << 20) : NULL; - } - else - { - /* shared memory */ - tmumem[0] = tmumem[1] = fbmem = auto_malloc(fbmem_in_mb << 20); - } - - /* set up frame buffer */ - init_fbi(v, &v->fbi, fbmem, fbmem_in_mb << 20); - - /* build shared TMU tables */ - init_tmu_shared(&v->tmushare); - - /* set up the TMUs */ - init_tmu(v, &v->tmu[0], type, &v->reg[0x100], tmumem[0], tmem0_in_mb << 20); - v->chipmask |= 0x02; - if (tmem1_in_mb) - { - init_tmu(v, &v->tmu[1], type, &v->reg[0x200], tmumem[1], tmem1_in_mb << 20); - v->chipmask |= 0x04; - } - - /* 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); - - /* 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_dramInit1] = 0x00f02200; - v->banshee.io[io_tmuGbeInit] = 0x00000bfb; - - /* do a soft reset to reset everything else */ - soft_reset(v); -} - - - -/************************************* - * - * Video exit - * - *************************************/ - -void voodoo_exit(int which) -{ - /* release the work queue, ensuring all work is finished */ - if (voodoo[which] != NULL && voodoo[which]->poly != NULL) - poly_free(voodoo[which]->poly); + return (voodoo_state *)device->token; } @@ -464,9 +287,9 @@ void voodoo_exit(int which) * *************************************/ -int voodoo_update(int which, bitmap_t *bitmap, const rectangle *cliprect) +int voodoo_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) { - voodoo_state *v = voodoo[which]; + voodoo_state *v = get_safe_token(device); int changed = v->fbi.video_changed; int drawbuf = v->fbi.frontbuf; int statskey; @@ -600,178 +423,26 @@ int voodoo_update(int which, bitmap_t *bitmap, const rectangle *cliprect) * *************************************/ -void voodoo_reset(int which) +int voodoo_get_type(const device_config *device) { - soft_reset(voodoo[which]); + voodoo_state *v = get_safe_token(device); + return v->type; } -int voodoo_get_type(int which) +int voodoo_is_stalled(const device_config *device) { - return voodoo[which]->type; + voodoo_state *v = get_safe_token(device); + return (v->pci.stall_state != NOT_STALLED); } -int voodoo_is_stalled(int which) +void voodoo_set_init_enable(const device_config *device, UINT32 newval) { - return (voodoo[which]->pci.stall_state != NOT_STALLED); -} - - -void voodoo_set_init_enable(int which, UINT32 newval) -{ - voodoo[which]->pci.init_enable = newval; + voodoo_state *v = get_safe_token(device); + v->pci.init_enable = newval; if (LOG_REGISTERS) - logerror("VOODOO.%d.REG:initEnable write = %08X\n", which, newval); -} - - -void voodoo_set_vblank_callback(int which, void (*vblank)(running_machine *, int)) -{ - voodoo[which]->fbi.vblank_client = vblank; -} - - -void voodoo_set_stall_callback(int which, void (*stall)(running_machine *, int)) -{ - voodoo[which]->pci.stall_callback = stall; -} - - - -/************************************* - * - * Specific write handlers - * - *************************************/ - -WRITE32_HANDLER( voodoo_0_w ) -{ - voodoo_w(machine, voodoo[0], offset, data, mem_mask); -} - - -WRITE32_HANDLER( voodoo_1_w ) -{ - voodoo_w(machine, voodoo[1], offset, data, mem_mask); -} - - - -/************************************* - * - * Specific read handlers - * - *************************************/ - -READ32_HANDLER( voodoo_0_r ) -{ - return voodoo_r(voodoo[0], offset); -} - - -READ32_HANDLER( voodoo_1_r ) -{ - return voodoo_r(voodoo[1], offset); -} - - - -/************************************* - * - * Specific Banshee write handlers - * - *************************************/ - -WRITE32_HANDLER( banshee_0_w ) -{ - banshee_w(voodoo[0], offset, data, mem_mask); -} - - -WRITE32_HANDLER( banshee_fb_0_w ) -{ - banshee_fb_w(voodoo[0], offset, data, mem_mask); -} - - -WRITE32_HANDLER( banshee_io_0_w ) -{ - banshee_io_w(voodoo[0], offset, data, mem_mask); -} - - -WRITE32_HANDLER( banshee_1_w ) -{ - banshee_w(voodoo[1], offset, data, mem_mask); -} - - -WRITE32_HANDLER( banshee_fb_1_w ) -{ - banshee_fb_w(voodoo[1], offset, data, mem_mask); -} - - -WRITE32_HANDLER( banshee_io_1_w ) -{ - banshee_io_w(voodoo[1], offset, data, mem_mask); -} - - - - -/************************************* - * - * Specific Banshee read handlers - * - *************************************/ - -READ32_HANDLER( banshee_0_r ) -{ - return banshee_r(voodoo[0], offset, mem_mask); -} - - -READ32_HANDLER( banshee_fb_0_r ) -{ - return banshee_fb_r(voodoo[0], offset, mem_mask); -} - - -READ32_HANDLER( banshee_io_0_r ) -{ - return banshee_io_r(voodoo[0], offset, mem_mask); -} - - -READ32_HANDLER( banshee_rom_0_r ) -{ - return banshee_rom_r(voodoo[0], offset, mem_mask); -} - - -READ32_HANDLER( banshee_1_r ) -{ - return banshee_r(voodoo[1], offset, mem_mask); -} - - -READ32_HANDLER( banshee_fb_1_r ) -{ - return banshee_fb_r(voodoo[1], offset, mem_mask); -} - - -READ32_HANDLER( banshee_io_1_r ) -{ - return banshee_io_r(voodoo[1], offset, mem_mask); -} - - -READ32_HANDLER( banshee_rom_1_r ) -{ - return banshee_rom_r(voodoo[1], offset, mem_mask); + logerror("VOODOO.%d.REG:initEnable write = %08X\n", v->index, newval); } @@ -868,14 +539,14 @@ static void init_tmu_shared(tmu_shared_state *s) } -static void init_tmu(voodoo_state *v, tmu_state *t, int type, voodoo_reg *reg, void *memory, int tmem) +static void init_tmu(voodoo_state *v, tmu_state *t, voodoo_reg *reg, void *memory, int tmem) { /* allocate texture RAM */ t->ram = memory; t->mask = tmem - 1; t->reg = reg; t->regdirty = TRUE; - t->bilinear_mask = (type >= VOODOO_2) ? 0xff : 0xf0; + t->bilinear_mask = (v->type >= VOODOO_2) ? 0xff : 0xf0; /* mark the NCC tables dirty and configure their registers */ t->ncc[0].dirty = t->ncc[1].dirty = TRUE; @@ -889,7 +560,7 @@ static void init_tmu(voodoo_state *v, tmu_state *t, int type, voodoo_reg *reg, v t->texel[3] = v->tmushare.int8; t->texel[4] = v->tmushare.ai44; t->texel[5] = t->palette; - t->texel[6] = (type >= VOODOO_2) ? t->palettea : NULL; + t->texel[6] = (v->type >= VOODOO_2) ? t->palettea : NULL; t->texel[7] = NULL; t->texel[8] = v->tmushare.rgb332; t->texel[9] = t->ncc[0].texel; @@ -903,11 +574,11 @@ static void init_tmu(voodoo_state *v, tmu_state *t, int type, voodoo_reg *reg, v /* attach the palette to NCC table 0 */ t->ncc[0].palette = t->palette; - if (type >= VOODOO_2) + if (v->type >= VOODOO_2) t->ncc[0].palettea = t->palettea; /* set up texture address calculations */ - if (type <= VOODOO_2) + if (v->type <= VOODOO_2) { t->texaddr_mask = 0x0fffff; t->texaddr_shift = 3; @@ -1027,7 +698,7 @@ static void swap_buffers(voodoo_state *v) /* we may be able to unstall now */ if (v->pci.stall_state != NOT_STALLED) - check_stalled_cpu(v->screen->machine, v, timer_get_time()); + check_stalled_cpu(v, timer_get_time()); /* periodically log rasterizer info */ v->stats.swaps++; @@ -1108,8 +779,8 @@ static TIMER_CALLBACK( vblank_off_callback ) /* set internal state and call the client */ v->fbi.vblank = FALSE; - if (v->fbi.vblank_client) - (*v->fbi.vblank_client)(machine, FALSE); + if (v->fbi.vblank_client != NULL) + (*v->fbi.vblank_client)(v->device, FALSE); /* go to the end of the next frame */ adjust_vblank_timer(v); @@ -1148,8 +819,8 @@ static TIMER_CALLBACK( vblank_callback ) /* set internal state and call the client */ v->fbi.vblank = TRUE; - if (v->fbi.vblank_client) - (*v->fbi.vblank_client)(machine, TRUE); + if (v->fbi.vblank_client != NULL) + (*v->fbi.vblank_client)(v->device, TRUE); } @@ -2149,11 +1820,11 @@ static void cmdfifo_w(voodoo_state *v, cmdfifo_info *f, offs_t offset, UINT32 da static TIMER_CALLBACK( stall_cpu_callback ) { - check_stalled_cpu(machine, ptr, timer_get_time()); + check_stalled_cpu(ptr, timer_get_time()); } -static void check_stalled_cpu(running_machine *machine, voodoo_state *v, attotime current_time) +static void check_stalled_cpu(voodoo_state *v, attotime current_time) { int resume = FALSE; @@ -2194,9 +1865,9 @@ static void check_stalled_cpu(running_machine *machine, voodoo_state *v, attotim /* either call the callback, or trigger the trigger */ if (v->pci.stall_callback) - (*v->pci.stall_callback)(machine, FALSE); + (*v->pci.stall_callback)(v->device, FALSE); else - cpu_trigger(machine, v->trigger); + cpu_trigger(v->device->machine, v->trigger); } /* if not, set a timer for the next one */ @@ -2207,7 +1878,7 @@ static void check_stalled_cpu(running_machine *machine, voodoo_state *v, attotim } -static void stall_cpu(running_machine *machine, voodoo_state *v, int state, attotime current_time) +static void stall_cpu(voodoo_state *v, int state, attotime current_time) { /* sanity check */ if (!v->pci.op_pending) fatalerror("FIFOs not empty, no op pending!"); @@ -2218,7 +1889,7 @@ static void stall_cpu(running_machine *machine, voodoo_state *v, int state, atto /* either call the callback, or spin the CPU */ if (v->pci.stall_callback) - (*v->pci.stall_callback)(machine, TRUE); + (*v->pci.stall_callback)(v->device, TRUE); else cpu_spinuntil_trigger(v->trigger); @@ -3583,8 +3254,9 @@ static void flush_fifos(voodoo_state *v, attotime current_time) * *************************************/ -static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) +WRITE32_DEVICE_HANDLER( voodoo_w ) { + voodoo_state *v = get_safe_token(device); int stall = FALSE; profiler_mark(PROFILER_USER1); @@ -3728,7 +3400,7 @@ static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, U fifo_items(&v->fbi.fifo) >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(v->reg[fbiInit0].u)) { if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", v->index); - stall_cpu(machine, v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); + stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); } } @@ -3737,14 +3409,14 @@ static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, U fifo_space(&v->pci.fifo) <= 2 * FBIINIT0_PCI_FIFO_LWM(v->reg[fbiInit0].u)) { if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", v->index); - stall_cpu(machine, v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); + stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_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(machine, v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time()); + stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time()); } profiler_mark(PROFILER_END); @@ -4016,8 +3688,10 @@ static UINT32 lfb_r(voodoo_state *v, offs_t offset, int forcefront) * *************************************/ -static UINT32 voodoo_r(voodoo_state *v, offs_t offset) +READ32_DEVICE_HANDLER( voodoo_r ) { + voodoo_state *v = get_safe_token(device); + /* if we have something pending, flush the FIFOs up to the current time */ if (v->pci.op_pending) flush_fifos(v, timer_get_time()); @@ -4040,8 +3714,9 @@ static UINT32 voodoo_r(voodoo_state *v, offs_t offset) * *************************************/ -static UINT32 banshee_agp_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) +static READ32_DEVICE_HANDLER( banshee_agp_r ) { + voodoo_state *v = get_safe_token(device); UINT32 result; offset &= 0x1ff/4; @@ -4100,8 +3775,9 @@ static UINT32 banshee_agp_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) } -static UINT32 banshee_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) +READ32_DEVICE_HANDLER( banshee_r ) { + voodoo_state *v = get_safe_token(device); UINT32 result = 0xffffffff; /* if we have something pending, flush the FIFOs up to the current time */ @@ -4109,9 +3785,9 @@ static UINT32 banshee_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) flush_fifos(v, timer_get_time()); if (offset < 0x80000/4) - result = banshee_io_r(v, offset, mem_mask); + result = banshee_io_r(device, offset, mem_mask); else if (offset < 0x100000/4) - result = banshee_agp_r(v, offset, mem_mask); + result = banshee_agp_r(device, offset, mem_mask); else if (offset < 0x200000/4) logerror("%08X:banshee_r(2D:%X)\n", activecpu_get_pc(), (offset*4) & 0xfffff); else if (offset < 0x600000/4) @@ -4133,8 +3809,9 @@ static UINT32 banshee_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) } -static UINT32 banshee_fb_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) +READ32_DEVICE_HANDLER( banshee_fb_r ) { + voodoo_state *v = get_safe_token(device); UINT32 result = 0xffffffff; /* if we have something pending, flush the FIFOs up to the current time */ @@ -4153,8 +3830,9 @@ static UINT32 banshee_fb_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) } -static UINT8 banshee_vga_r(voodoo_state *v, offs_t offset) +static READ8_DEVICE_HANDLER( banshee_vga_r ) { + voodoo_state *v = get_safe_token(device); UINT8 result = 0xff; offset &= 0x1f; @@ -4248,8 +3926,9 @@ static UINT8 banshee_vga_r(voodoo_state *v, offs_t offset) } -static UINT32 banshee_io_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) +READ32_DEVICE_HANDLER( banshee_io_r ) { + voodoo_state *v = get_safe_token(device); UINT32 result; offset &= 0xff/4; @@ -4272,13 +3951,13 @@ static UINT32 banshee_io_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) case io_vgad0: case io_vgad4: case io_vgad8: case io_vgadc: result = 0; if (ACCESSING_BITS_0_7) - result |= banshee_vga_r(v, offset*4+0) << 0; + result |= banshee_vga_r(device, offset*4+0) << 0; if (ACCESSING_BITS_8_15) - result |= banshee_vga_r(v, offset*4+1) << 8; + result |= banshee_vga_r(device, offset*4+1) << 8; if (ACCESSING_BITS_16_23) - result |= banshee_vga_r(v, offset*4+2) << 16; + result |= banshee_vga_r(device, offset*4+2) << 16; if (ACCESSING_BITS_24_31) - result |= banshee_vga_r(v, offset*4+3) << 24; + result |= banshee_vga_r(device, offset*4+3) << 24; break; default: @@ -4292,7 +3971,7 @@ static UINT32 banshee_io_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) } -static UINT32 banshee_rom_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) +READ32_DEVICE_HANDLER( banshee_rom_r ) { logerror("%08X:banshee_rom_r(%X)\n", activecpu_get_pc(), offset*4); return 0xffffffff; @@ -4300,8 +3979,9 @@ static UINT32 banshee_rom_r(voodoo_state *v, offs_t offset, UINT32 mem_mask) -static void banshee_agp_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) +static WRITE32_DEVICE_HANDLER( banshee_agp_w ) { + voodoo_state *v = get_safe_token(device); offset &= 0x1ff/4; /* switch off the offset */ @@ -4391,16 +4071,18 @@ static void banshee_agp_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 me } -static void banshee_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) +WRITE32_DEVICE_HANDLER( banshee_w ) { + voodoo_state *v = get_safe_token(device); + /* if we have something pending, flush the FIFOs up to the current time */ if (v->pci.op_pending) flush_fifos(v, timer_get_time()); if (offset < 0x80000/4) - banshee_io_w(v, offset, data, mem_mask); + banshee_io_w(device, offset, data, mem_mask); else if (offset < 0x100000/4) - banshee_agp_w(v, offset, data, mem_mask); + banshee_agp_w(device, offset, data, mem_mask); else if (offset < 0x200000/4) logerror("%08X:banshee_w(2D:%X) = %08X & %08X\n", activecpu_get_pc(), (offset*4) & 0xfffff, data, mem_mask); else if (offset < 0x600000/4) @@ -4421,8 +4103,9 @@ static void banshee_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_ma } -static void banshee_fb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) +WRITE32_DEVICE_HANDLER( banshee_fb_w ) { + voodoo_state *v = get_safe_token(device); UINT32 addr = offset*4; /* if we have something pending, flush the FIFOs up to the current time */ @@ -4447,8 +4130,9 @@ static void banshee_fb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem } -static void banshee_vga_w(voodoo_state *v, offs_t offset, UINT8 data) +static WRITE8_DEVICE_HANDLER( banshee_vga_w ) { + voodoo_state *v = get_safe_token(device); offset &= 0x1f; /* switch off the offset */ @@ -4506,8 +4190,9 @@ static void banshee_vga_w(voodoo_state *v, offs_t offset, UINT8 data) } -static void banshee_io_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) +WRITE32_DEVICE_HANDLER( banshee_io_w ) { + voodoo_state *v = get_safe_token(device); UINT32 old; offset &= 0xff/4; @@ -4567,13 +4252,13 @@ static void banshee_io_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem case io_vgac0: case io_vgac4: case io_vgac8: case io_vgacc: case io_vgad0: case io_vgad4: case io_vgad8: case io_vgadc: if (ACCESSING_BITS_0_7) - banshee_vga_w(v, offset*4+0, data >> 0); + banshee_vga_w(device, offset*4+0, data >> 0); if (ACCESSING_BITS_8_15) - banshee_vga_w(v, offset*4+1, data >> 8); + banshee_vga_w(device, offset*4+1, data >> 8); if (ACCESSING_BITS_16_23) - banshee_vga_w(v, offset*4+2, data >> 16); + banshee_vga_w(device, offset*4+2, data >> 16); if (ACCESSING_BITS_24_31) - banshee_vga_w(v, offset*4+3, data >> 24); + banshee_vga_w(device, offset*4+3, data >> 24); break; default: @@ -4586,6 +4271,262 @@ static void banshee_io_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem +/*************************************************************************** + DEVICE INTERFACE +***************************************************************************/ + +/*------------------------------------------------- + device start callback +-------------------------------------------------*/ + +static DEVICE_START( voodoo ) +{ + const voodoo_config *config = device->inline_config; + voodoo_state *v = get_safe_token(device); + const raster_info *info; + void *fbmem, *tmumem[2]; + char unique_tag[50]; + UINT32 tmumem0; + int val; + + /* validate some basic stuff */ + assert(device->static_config == NULL); + assert(device->inline_config != NULL); + assert(device->machine != NULL); + assert(device->machine->config != NULL); + + /* validate configuration */ + assert(config->screen != NULL); + assert(config->type >= VOODOO_1 && config->type < MAX_VOODOO_TYPES); + assert(config->fbmem > 0); + assert(config->type >= VOODOO_BANSHEE || config->tmumem0 > 0); + + /* store a pointer back to the device */ + v->device = device; + + /* copy config data */ + v->freq = config->clock; + v->fbi.vblank_client = config->vblank; + v->pci.stall_callback = config->stall; + + /* create a multiprocessor work queue */ + v->poly = poly_alloc(64, sizeof(poly_extra_data), 0); + v->thread_stats = auto_malloc(sizeof(v->thread_stats[0]) * WORK_MAX_THREADS); + + /* create a table of precomputed 1/n and log2(n) values */ + /* n ranges from 1.0000 to 2.0000 */ + for (val = 0; val <= (1 << RECIPLOG_LOOKUP_BITS); val++) + { + UINT32 value = (1 << RECIPLOG_LOOKUP_BITS) + val; + voodoo_reciplog[val*2 + 0] = (1 << (RECIPLOG_LOOKUP_PREC + RECIPLOG_LOOKUP_BITS)) / value; + voodoo_reciplog[val*2 + 1] = (UINT32)(LOGB2((double)value / (double)(1 << RECIPLOG_LOOKUP_BITS)) * (double)(1 << RECIPLOG_LOOKUP_PREC)); + } + + /* create dithering tables */ + for (val = 0; val < 256*16*2; val++) + { + int g = (val >> 0) & 1; + int x = (val >> 1) & 3; + int color = (val >> 3) & 0xff; + int y = (val >> 11) & 3; + + if (!g) + { + dither4_lookup[val] = DITHER_RB(color, dither_matrix_4x4[y * 4 + x]) >> 3; + dither2_lookup[val] = DITHER_RB(color, dither_matrix_2x2[y * 4 + x]) >> 3; + } + else + { + dither4_lookup[val] = DITHER_G(color, dither_matrix_4x4[y * 4 + x]) >> 2; + dither2_lookup[val] = DITHER_G(color, dither_matrix_2x2[y * 4 + x]) >> 2; + } + } + + /* configure type-specific values */ + switch (config->type) + { + case VOODOO_1: + v->regaccess = voodoo_register_access; + v->regnames = voodoo_reg_name; + v->alt_regmap = 0; + v->fbi.lfb_stride = 10; + break; + + case VOODOO_2: + v->regaccess = voodoo2_register_access; + v->regnames = voodoo_reg_name; + v->alt_regmap = 0; + v->fbi.lfb_stride = 10; + break; + + case VOODOO_BANSHEE: + v->regaccess = banshee_register_access; + v->regnames = banshee_reg_name; + v->alt_regmap = 1; + v->fbi.lfb_stride = 11; + break; + + case VOODOO_3: + v->regaccess = banshee_register_access; + v->regnames = banshee_reg_name; + v->alt_regmap = 1; + v->fbi.lfb_stride = 11; + break; + + default: + fatalerror("Unsupported voodoo card in voodoo_start!"); + break; + } + + /* set the type, and initialize the chip mask */ + v->index = device_list_index(device->machine->config->devicelist, device->type, device->tag); + v->screen = device_list_find_by_tag(device->machine->config->devicelist, VIDEO_SCREEN, config->screen); + assert_always(v->screen != NULL, "Unable to find screen attached to voodoo"); + v->type = config->type; + v->chipmask = 0x01; + v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq; + v->trigger = 51324 + v->index; + + /* build the rasterizer table */ + for (info = predef_raster_table; info->callback; info++) + add_rasterizer(v, 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 = timer_alloc(stall_cpu_callback, v); + + /* allocate memory */ + tmumem0 = config->tmumem0; + if (config->type <= VOODOO_2) + { + /* separate FB/TMU memory */ + fbmem = auto_malloc(config->fbmem << 20); + tmumem[0] = auto_malloc(config->tmumem0 << 20); + tmumem[1] = (config->tmumem1 != 0) ? auto_malloc(config->tmumem1 << 20) : NULL; + } + else + { + /* shared memory */ + tmumem[0] = tmumem[1] = fbmem = auto_malloc(config->fbmem << 20); + tmumem0 = config->fbmem; + } + + /* set up frame buffer */ + init_fbi(v, &v->fbi, fbmem, config->fbmem << 20); + + /* build shared TMU tables */ + init_tmu_shared(&v->tmushare); + + /* set up the TMUs */ + init_tmu(v, &v->tmu[0], &v->reg[0x100], tmumem[0], tmumem0 << 20); + v->chipmask |= 0x02; + if (config->tmumem1 != 0) + { + init_tmu(v, &v->tmu[1], &v->reg[0x200], tmumem[1], config->tmumem1 << 20); + v->chipmask |= 0x04; + } + + /* 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); + + /* 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_dramInit1] = 0x00f02200; + v->banshee.io[io_tmuGbeInit] = 0x00000bfb; + + /* do a soft reset to reset everything else */ + soft_reset(v); + + /* create the name for save states */ + assert(strlen(device->tag) < 30); + state_save_combine_module_and_tag(unique_tag, "voodoo", device->tag); + + /* register states */ +// state_save_register_item(unique_tag, 0, ide->adapter_control); +} + + +/*------------------------------------------------- + device exit callback +-------------------------------------------------*/ + +static DEVICE_STOP( voodoo ) +{ + voodoo_state *v = get_safe_token(device); + + /* release the work queue, ensuring all work is finished */ + if (v->poly != NULL) + poly_free(v->poly); +} + + +/*------------------------------------------------- + device reset callback +-------------------------------------------------*/ + +static DEVICE_RESET( voodoo ) +{ + voodoo_state *v = get_safe_token(device); + soft_reset(v); +} + + +/*------------------------------------------------- + device set info callback +-------------------------------------------------*/ + +static DEVICE_SET_INFO( voodoo ) +{ + switch (state) + { + /* no parameters to set */ + } +} + + +/*------------------------------------------------- + device get info callback +-------------------------------------------------*/ + +DEVICE_GET_INFO( voodoo ) +{ + switch (state) + { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(voodoo_state); break; + case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(voodoo_config); break; + case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; + + /* --- the following bits of info are returned as pointers to data or functions --- */ + case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(voodoo); break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(voodoo); break; + case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(voodoo); break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(voodoo);break; + + /* --- the following bits of info are returned as NULL-terminated strings --- */ + case DEVINFO_STR_NAME: info->s = "3dfx Voodoo"; break; + case DEVINFO_STR_FAMILY: info->s = "3dfx Voodoo Graphics"; break; + case DEVINFO_STR_VERSION: info->s = "1.0"; break; + case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; + case DEVINFO_STR_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break; + } +} + + + /*************************************************************************** COMMAND HANDLERS ***************************************************************************/ diff --git a/src/emu/video/voodoo.h b/src/emu/video/voodoo.h index 45c2a8b83ae..4bcde1a2289 100644 --- a/src/emu/video/voodoo.h +++ b/src/emu/video/voodoo.h @@ -6,7 +6,10 @@ **************************************************************************/ -#define MAX_VOODOO 2 + +/*************************************************************************** + CONSTANTS +***************************************************************************/ /* enumeration specifying which model of Voodoo we are emulating */ enum @@ -18,34 +21,99 @@ enum MAX_VOODOO_TYPES }; -void voodoo_start(int which, const device_config *screen, int type, int fbmem_in_mb, int tmem0_in_mb, int tmem1_in_mb); -int voodoo_update(int which, bitmap_t *bitmap, const rectangle *cliprect); -void voodoo_reset(int which); -void voodoo_exit(int which); -int voodoo_get_type(int which); -int voodoo_is_stalled(int which); -void voodoo_set_init_enable(int which, UINT32 newval); -void voodoo_set_vblank_callback(int which, void (*vblank)(running_machine *, int)); -void voodoo_set_stall_callback(int which, void (*stall)(running_machine *, int)); -READ32_HANDLER( voodoo_0_r ); -WRITE32_HANDLER( voodoo_0_w ); +#define STD_VOODOO_1_CLOCK 50000000 +#define STD_VOODOO_2_CLOCK 90000000 +#define STD_VOODOO_BANSHEE_CLOCK 90000000 +#define STD_VOODOO_3_CLOCK 132000000 -READ32_HANDLER( voodoo_1_r ); -WRITE32_HANDLER( voodoo_1_w ); -READ32_HANDLER( banshee_0_r ); -WRITE32_HANDLER( banshee_0_w ); -READ32_HANDLER( banshee_fb_0_r ); -WRITE32_HANDLER( banshee_fb_0_w ); -READ32_HANDLER( banshee_io_0_r ); -WRITE32_HANDLER( banshee_io_0_w ); -READ32_HANDLER( banshee_rom_0_r ); +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ -READ32_HANDLER( banshee_1_r ); -WRITE32_HANDLER( banshee_1_w ); -READ32_HANDLER( banshee_fb_1_r ); -WRITE32_HANDLER( banshee_fb_1_w ); -READ32_HANDLER( banshee_io_1_r ); -WRITE32_HANDLER( banshee_io_1_w ); -READ32_HANDLER( banshee_rom_1_r ); +typedef void (*voodoo_vblank_func)(const device_config *device, int state); +typedef void (*voodoo_stall_func)(const device_config *device, int state); + + +typedef struct _voodoo_config voodoo_config; +struct _voodoo_config +{ + int type; + UINT32 clock; + UINT8 fbmem; + UINT8 tmumem0; + UINT8 tmumem1; + const char * screen; + voodoo_vblank_func vblank; + voodoo_stall_func stall; +}; + + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MDRV_3DFX_VOODOO_ADD(_tag, _type, _clock, _fbmem, _screen) \ + MDRV_DEVICE_ADD(_tag, VOODOO_GRAPHICS) \ + MDRV_DEVICE_CONFIG_DATA32(voodoo_config, type, _type) \ + MDRV_DEVICE_CONFIG_DATA32(voodoo_config, clock, _clock) \ + MDRV_DEVICE_CONFIG_DATA32(voodoo_config, fbmem, _fbmem) \ + MDRV_DEVICE_CONFIG_DATAPTR(voodoo_config, screen, _screen) + +#define MDRV_3DFX_VOODOO_1_ADD(_tag, _clock, _fbmem, _screen) \ + MDRV_3DFX_VOODOO_ADD(_tag, VOODOO_1, _clock, _fbmem, _screen) + +#define MDRV_3DFX_VOODOO_2_ADD(_tag, _clock, _fbmem, _screen) \ + MDRV_3DFX_VOODOO_ADD(_tag, VOODOO_2, _clock, _fbmem, _screen) + +#define MDRV_3DFX_VOODOO_BANSHEE_ADD(_tag, _clock, _fbmem, _screen) \ + MDRV_3DFX_VOODOO_ADD(_tag, VOODOO_BANSHEE, _clock, _fbmem, _screen) + +#define MDRV_3DFX_VOODOO_3_ADD(_tag, _clock, _fbmem, _screen) \ + MDRV_3DFX_VOODOO_ADD(_tag, VOODOO_3, _clock, _fbmem, _screen) + +#define MDRV_3DFX_VOODOO_TMU_MEMORY(_tmu, _tmumem) \ + MDRV_DEVICE_CONFIG_DATA32(voodoo_config, tmumem##_tmu, _tmumem) + +#define MDRV_3DFX_VOODOO_VBLANK(_vblank) \ + MDRV_DEVICE_CONFIG_DATAPTR(voodoo_config, vblank, _vblank) + +#define MDRV_3DFX_VOODOO_STALL(_stall) \ + MDRV_DEVICE_CONFIG_DATAPTR(voodoo_config, stall, _stall) + +#define MDRV_3DFX_VOODOO_MODIFY(_tag) \ + MDRV_DEVICE_MODIFY(_tag, VOODOO_GRAPHICS) + +#define MDRV_3DFX_VOODOO_REMOVE(_tag) \ + MDRV_DEVICE_REMOVE(_tag, VOODOO_GRAPHICS) + + + +/*************************************************************************** + FUNCTION PROTOTYPES +***************************************************************************/ + +int voodoo_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect); +int voodoo_get_type(const device_config *device); +int voodoo_is_stalled(const device_config *device); +void voodoo_set_init_enable(const device_config *device, UINT32 newval); + +READ32_DEVICE_HANDLER( voodoo_r ); +WRITE32_DEVICE_HANDLER( voodoo_w ); + +READ32_DEVICE_HANDLER( banshee_r ); +WRITE32_DEVICE_HANDLER( banshee_w ); +READ32_DEVICE_HANDLER( banshee_fb_r ); +WRITE32_DEVICE_HANDLER( banshee_fb_w ); +READ32_DEVICE_HANDLER( banshee_io_r ); +WRITE32_DEVICE_HANDLER( banshee_io_w ); +READ32_DEVICE_HANDLER( banshee_rom_r ); + + +/* ----- device interface ----- */ + +/* device get info callback */ +#define VOODOO_GRAPHICS DEVICE_GET_INFO_NAME(voodoo) +DEVICE_GET_INFO( voodoo ); diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c index 8c9adbc0eae..24860a56b6d 100644 --- a/src/mame/drivers/gticlub.c +++ b/src/mame/drivers/gticlub.c @@ -71,27 +71,18 @@ static WRITE32_HANDLER( paletteram32_w ) palette_set_color_rgb(machine, offset, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0)); } -static void voodoo_vblank_0(running_machine *machine, int param) +static void voodoo_vblank_0(const device_config *device, int param) { - cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); + cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); } -static void voodoo_vblank_1(running_machine *machine, int param) +static void voodoo_vblank_1(const device_config *device, int param) { - cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); + cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); } static VIDEO_START( hangplt ) { - const device_config *left_screen = device_list_find_by_tag(machine->config->devicelist, VIDEO_SCREEN, "left"); - const device_config *right_screen = device_list_find_by_tag(machine->config->devicelist, VIDEO_SCREEN, "right"); - - voodoo_start(0, left_screen, VOODOO_1, 2, 4, 4); - voodoo_start(1, right_screen, VOODOO_1, 2, 4, 4); - - voodoo_set_vblank_callback(0, voodoo_vblank_0); - voodoo_set_vblank_callback(1, voodoo_vblank_1); - K001604_vh_start(machine, 0); K001604_vh_start(machine, 1); } @@ -99,26 +90,27 @@ static VIDEO_START( hangplt ) static VIDEO_UPDATE( hangplt ) { - const device_config *left_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left"); - const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right"); - fillbitmap(bitmap, screen->machine->pens[0], cliprect); - if (screen == left_screen) + if (strcmp(screen->tag, "left") == 0) { + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo0"); + K001604_tile_update(screen->machine, 0); // K001604_draw_back_layer(bitmap, cliprect); - voodoo_update(0, bitmap, cliprect); + voodoo_update(voodoo, bitmap, cliprect); K001604_draw_front_layer(0, bitmap, cliprect); } - else if (screen == right_screen) + else if (strcmp(screen->tag, "right") == 0) { + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo1"); + K001604_tile_update(screen->machine, 1); // K001604_draw_back_layer(bitmap, cliprect); - voodoo_update(1, bitmap, cliprect); + voodoo_update(voodoo, bitmap, cliprect); K001604_draw_front_layer(1, bitmap, cliprect); } @@ -487,9 +479,9 @@ static ADDRESS_MAP_START( hangplt_sharc0_map, ADDRESS_SPACE_DATA, 32 ) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_0_shared_sharc_r, cgboard_0_shared_sharc_w) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram0_r, dsp_dataram0_w) AM_RANGE(0x1400000, 0x14fffff) AM_RAM - AM_RANGE(0x2400000, 0x27fffff) AM_READWRITE(nwk_voodoo_0_r, voodoo_0_w) + AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo0", nwk_voodoo_0_r, voodoo_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_0_comm_sharc_r, cgboard_0_comm_sharc_w) - AM_RANGE(0x3401000, 0x34fffff) AM_WRITE(nwk_fifo_0_w) + AM_RANGE(0x3401000, 0x34fffff) AM_DEVWRITE(VOODOO_GRAPHICS, "voodoo0", nwk_fifo_0_w) AM_RANGE(0x3500000, 0x3507fff) AM_READWRITE(K033906_0_r, K033906_0_w) AM_RANGE(0x3600000, 0x37fffff) AM_ROMBANK(5) ADDRESS_MAP_END @@ -498,9 +490,9 @@ static ADDRESS_MAP_START( hangplt_sharc1_map, ADDRESS_SPACE_DATA, 32 ) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_1_shared_sharc_r, cgboard_1_shared_sharc_w) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram1_r, dsp_dataram1_w) AM_RANGE(0x1400000, 0x14fffff) AM_RAM - AM_RANGE(0x2400000, 0x27fffff) AM_READWRITE(nwk_voodoo_1_r, voodoo_1_w) + AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo1", nwk_voodoo_1_r, voodoo_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_1_comm_sharc_r, cgboard_1_comm_sharc_w) - AM_RANGE(0x3401000, 0x34fffff) AM_WRITE(nwk_fifo_1_w) + AM_RANGE(0x3401000, 0x34fffff) AM_DEVWRITE(VOODOO_GRAPHICS, "voodoo1", nwk_fifo_1_w) AM_RANGE(0x3500000, 0x3507fff) AM_READWRITE(K033906_1_r, K033906_1_w) AM_RANGE(0x3600000, 0x37fffff) AM_ROMBANK(6) ADDRESS_MAP_END @@ -779,6 +771,16 @@ static MACHINE_DRIVER_START( hangplt ) MDRV_MACHINE_START(gticlub) MDRV_MACHINE_RESET(hangplt) + MDRV_3DFX_VOODOO_1_ADD("voodoo0", STD_VOODOO_1_CLOCK, 2, "left") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 2) + MDRV_3DFX_VOODOO_TMU_MEMORY(1, 2) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_0) + + MDRV_3DFX_VOODOO_1_ADD("voodoo1", STD_VOODOO_1_CLOCK, 2, "right") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 2) + MDRV_3DFX_VOODOO_TMU_MEMORY(1, 2) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_1) + /* video hardware */ MDRV_PALETTE_LENGTH(65536) diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c index 0907bf9e34a..fc19d58ae3b 100644 --- a/src/mame/drivers/hornet.c +++ b/src/mame/drivers/hornet.c @@ -579,64 +579,23 @@ static WRITE32_HANDLER(K037122_reg_w) COMBINE_DATA( K037122_reg[chip] + offset ); } -static int voodoo_version = 0; - -static void voodoo_vblank_0(running_machine *machine, int param) +static void voodoo_vblank_0(const device_config *device, int param) { - cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); + cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); } -static void voodoo_vblank_1(running_machine *machine, int param) +static void voodoo_vblank_1(const device_config *device, int param) { - cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); -} - -static void hornet_exit(running_machine *machine) -{ - voodoo_exit(0); -} - -static void hornet_2board_exit(running_machine *machine) -{ - voodoo_exit(0); - voodoo_exit(1); + cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); } static VIDEO_START( hornet ) { - add_exit_callback(machine, hornet_exit); - - if (voodoo_version == 0) - voodoo_start(0, machine->primary_screen, VOODOO_1, 2, 4, 0); - else - voodoo_start(0, machine->primary_screen, VOODOO_2, 2, 4, 0); - - voodoo_set_vblank_callback(0, voodoo_vblank_0); - K037122_vh_start(machine, 0); } static VIDEO_START( hornet_2board ) { - const device_config *left_screen = device_list_find_by_tag(machine->config->devicelist, VIDEO_SCREEN, "left"); - const device_config *right_screen = device_list_find_by_tag(machine->config->devicelist, VIDEO_SCREEN, "right"); - - add_exit_callback(machine, hornet_2board_exit); - - if (voodoo_version == 0) - { - voodoo_start(0, left_screen, VOODOO_1, 2, 4, 0); - voodoo_start(1, right_screen, VOODOO_1, 2, 4, 0); - } - else - { - voodoo_start(0, left_screen, VOODOO_2, 2, 4, 0); - voodoo_start(1, right_screen, VOODOO_2, 2, 4, 0); - } - - voodoo_set_vblank_callback(0, voodoo_vblank_0); - voodoo_set_vblank_callback(1, voodoo_vblank_1); - K037122_vh_start(machine, 0); K037122_vh_start(machine, 1); } @@ -644,7 +603,9 @@ static VIDEO_START( hornet_2board ) static VIDEO_UPDATE( hornet ) { - voodoo_update(0, bitmap, cliprect); + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo0"); + + voodoo_update(voodoo, bitmap, cliprect); K037122_tile_update(screen->machine, 0); K037122_tile_draw(screen->machine, 0, bitmap, cliprect); @@ -656,20 +617,19 @@ static VIDEO_UPDATE( hornet ) static VIDEO_UPDATE( hornet_2board ) { - const device_config *left_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left"); - const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right"); - - if (screen == left_screen) + if (strcmp(screen->tag, "left") == 0) { - voodoo_update(0, bitmap, cliprect); + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo0"); + voodoo_update(voodoo, bitmap, cliprect); /* TODO: tilemaps per screen */ K037122_tile_update(screen->machine, 0); K037122_tile_draw(screen->machine, 0, bitmap, cliprect); } - else if (screen == right_screen) + else if (strcmp(screen->tag, "right") == 0) { - voodoo_update(1, bitmap, cliprect); + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo1"); + voodoo_update(voodoo, bitmap, cliprect); /* TODO: tilemaps per screen */ K037122_tile_update(screen->machine, 1); @@ -818,7 +778,7 @@ static ADDRESS_MAP_START( sharc0_map, ADDRESS_SPACE_DATA, 32 ) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_0_shared_sharc_r, cgboard_0_shared_sharc_w) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram0_r, dsp_dataram0_w) AM_RANGE(0x1400000, 0x14fffff) AM_RAM - AM_RANGE(0x2400000, 0x27fffff) AM_READWRITE(voodoo_0_r, voodoo_0_w) + AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo0", voodoo_r, voodoo_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_0_comm_sharc_r, cgboard_0_comm_sharc_w) AM_RANGE(0x3500000, 0x35000ff) AM_READWRITE(K033906_0_r, K033906_0_w) AM_RANGE(0x3600000, 0x37fffff) AM_ROMBANK(5) @@ -828,7 +788,7 @@ static ADDRESS_MAP_START( sharc1_map, ADDRESS_SPACE_DATA, 32 ) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_1_shared_sharc_r, cgboard_1_shared_sharc_w) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram1_r, dsp_dataram1_w) AM_RANGE(0x1400000, 0x14fffff) AM_RAM - AM_RANGE(0x2400000, 0x27fffff) AM_READWRITE(voodoo_1_r, voodoo_1_w) + AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo1", voodoo_r, voodoo_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_1_comm_sharc_r, cgboard_1_comm_sharc_w) AM_RANGE(0x3500000, 0x35000ff) AM_READWRITE(K033906_1_r, K033906_1_w) AM_RANGE(0x3600000, 0x37fffff) AM_ROMBANK(6) @@ -1003,6 +963,10 @@ static MACHINE_DRIVER_START( hornet ) MDRV_NVRAM_HANDLER( timekeeper_0 ) + MDRV_3DFX_VOODOO_1_ADD("voodoo0", STD_VOODOO_1_CLOCK, 2, "main") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_0) + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -1051,6 +1015,15 @@ static MACHINE_DRIVER_START( hornet_2board ) MDRV_VIDEO_START(hornet_2board) MDRV_VIDEO_UPDATE(hornet_2board) + MDRV_3DFX_VOODOO_REMOVE("voodoo0") + MDRV_3DFX_VOODOO_1_ADD("voodoo0", STD_VOODOO_1_CLOCK, 2, "left") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_0) + + MDRV_3DFX_VOODOO_1_ADD("voodoo1", STD_VOODOO_1_CLOCK, 2, "right") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_1) + /* video hardware */ MDRV_PALETTE_LENGTH(65536) @@ -1069,6 +1042,20 @@ static MACHINE_DRIVER_START( hornet_2board ) MDRV_SCREEN_VISIBLE_AREA(0, 511, 0, 383) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( hornet_2board_v2 ) + MDRV_IMPORT_FROM(hornet_2board) + + MDRV_3DFX_VOODOO_REMOVE("voodoo0") + MDRV_3DFX_VOODOO_2_ADD("voodoo0", STD_VOODOO_2_CLOCK, 2, "left") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_0) + + MDRV_3DFX_VOODOO_REMOVE("voodoo1") + MDRV_3DFX_VOODOO_2_ADD("voodoo1", STD_VOODOO_2_CLOCK, 2, "right") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_1) +MACHINE_DRIVER_END + /*****************************************************************************/ @@ -1274,7 +1261,6 @@ static DRIVER_INIT(gradius4) backup_ram[0x0e] = 0x02; // checksum backup_ram[0x0f] = 0xd7; // checksum - voodoo_version = 0; init_hornet(machine); } @@ -1308,7 +1294,6 @@ static DRIVER_INIT(nbapbp) backup_ram[0x0e] = (checksum >> 8) & 0xff; // checksum backup_ram[0x0f] = (checksum >> 0) & 0xff; // checksum - voodoo_version = 0; init_hornet(machine); } @@ -1342,7 +1327,6 @@ static DRIVER_INIT(terabrst) backup_ram[0x0e] = (checksum >> 8) & 0xff; // checksum backup_ram[0x0f] = (checksum >> 0) & 0xff; // checksum - voodoo_version = 0; init_hornet_2board(machine); } @@ -1376,7 +1360,6 @@ static DRIVER_INIT(sscope) backup_ram[0x0e] = (checksum >> 8) & 0xff; // checksum backup_ram[0x0f] = (checksum >> 0) & 0xff; // checksum - voodoo_version = 0; init_hornet_2board(machine); } @@ -1438,7 +1421,6 @@ static DRIVER_INIT(sscope2) backup_ram[0x1f4e] = (checksum >> 8) & 0xff; // checksum backup_ram[0x1f4f] = (checksum >> 0) & 0xff; // checksum - voodoo_version = 1; init_hornet_2board(machine); } @@ -1579,9 +1561,9 @@ ROM_END /*************************************************************************/ -GAME( 1998, gradius4, 0, hornet, hornet, gradius4, ROT0, "Konami", "Gradius 4: Fukkatsu", GAME_IMPERFECT_SOUND ) -GAME( 1998, nbapbp, 0, hornet, hornet, nbapbp, ROT0, "Konami", "NBA Play By Play", GAME_IMPERFECT_SOUND ) -GAMEL( 1998, terabrst, 0, hornet_2board, hornet, terabrst, ROT0, "Konami", "Teraburst", GAME_IMPERFECT_SOUND, layout_dualhsxs ) -GAMEL( 2000, sscope, 0, hornet_2board, sscope, sscope, ROT0, "Konami", "Silent Scope (ver UAB)", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) -GAMEL( 2000, sscopea, sscope, hornet_2board, sscope, sscope, ROT0, "Konami", "Silent Scope (ver UAA)", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) -GAMEL( 2000, sscope2, 0, hornet_2board, sscope, sscope2, ROT0, "Konami", "Silent Scope 2", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) +GAME( 1998, gradius4, 0, hornet, hornet, gradius4, ROT0, "Konami", "Gradius 4: Fukkatsu", GAME_IMPERFECT_SOUND ) +GAME( 1998, nbapbp, 0, hornet, hornet, nbapbp, ROT0, "Konami", "NBA Play By Play", GAME_IMPERFECT_SOUND ) +GAMEL( 1998, terabrst, 0, hornet_2board, hornet, terabrst, ROT0, "Konami", "Teraburst", GAME_IMPERFECT_SOUND, layout_dualhsxs ) +GAMEL( 2000, sscope, 0, hornet_2board, sscope, sscope, ROT0, "Konami", "Silent Scope (ver UAB)", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) +GAMEL( 2000, sscopea, sscope, hornet_2board, sscope, sscope, ROT0, "Konami", "Silent Scope (ver UAA)", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) +GAMEL( 2000, sscope2, 0, hornet_2board_v2, sscope, sscope2, ROT0, "Konami", "Silent Scope 2", GAME_IMPERFECT_SOUND|GAME_NOT_WORKING, layout_dualhsxs ) diff --git a/src/mame/drivers/nwk-tr.c b/src/mame/drivers/nwk-tr.c index a01bf3f9ce1..e8f377502ea 100644 --- a/src/mame/drivers/nwk-tr.c +++ b/src/mame/drivers/nwk-tr.c @@ -521,25 +521,24 @@ READ32_HANDLER(K001604_reg_r) -static void voodoo_vblank_0(running_machine *machine, int param) +static void voodoo_vblank_0(const device_config *device, int param) { - cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); + cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); } static VIDEO_START( nwktr ) { - voodoo_start(0, machine->primary_screen, VOODOO_1, 2, 2, 2); - voodoo_set_vblank_callback(0, voodoo_vblank_0); - K001604_vh_start(machine, 0); } static VIDEO_UPDATE( nwktr ) { + const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo"); + fillbitmap(bitmap, screen->machine->pens[0], cliprect); - voodoo_update(0, bitmap, cliprect); + voodoo_update(voodoo, bitmap, cliprect); K001604_tile_update(screen->machine, 0); K001604_draw_front_layer(0, bitmap, cliprect); @@ -817,7 +816,7 @@ static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 ) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_0_shared_sharc_r, cgboard_0_shared_sharc_w) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram_r, dsp_dataram_w) AM_RANGE(0x1400000, 0x14fffff) AM_RAM - AM_RANGE(0x2400000, 0x27fffff) AM_READWRITE(nwk_voodoo_0_r, nwk_voodoo_0_w) + AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo", nwk_voodoo_0_r, nwk_voodoo_0_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_0_comm_sharc_r, cgboard_0_comm_sharc_w) AM_RANGE(0x3500000, 0x35000ff) AM_READWRITE(K033906_0_r, K033906_0_w) AM_RANGE(0x3600000, 0x37fffff) AM_ROMBANK(5) @@ -923,6 +922,11 @@ static MACHINE_DRIVER_START( nwktr ) MDRV_MACHINE_RESET(nwktr) MDRV_NVRAM_HANDLER( timekeeper_0 ) + MDRV_3DFX_VOODOO_1_ADD("voodoo", STD_VOODOO_1_CLOCK, 2, "main") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 2) + MDRV_3DFX_VOODOO_TMU_MEMORY(1, 2) + MDRV_3DFX_VOODOO_VBLANK(voodoo_vblank_0) + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_REFRESH_RATE(60) diff --git a/src/mame/drivers/seattle.c b/src/mame/drivers/seattle.c index e4e0b9f779f..a1b681186c4 100644 --- a/src/mame/drivers/seattle.c +++ b/src/mame/drivers/seattle.c @@ -430,6 +430,7 @@ static UINT32 *rombase; static struct galileo_data galileo; static struct widget_data widget; +static const device_config *voodoo_device; static UINT8 voodoo_stalled; static UINT8 cpu_stalled_on_voodoo; static UINT32 cpu_stalled_offset; @@ -469,7 +470,7 @@ static void update_vblank_irq(running_machine *machine); static void galileo_reset(void); static TIMER_CALLBACK( galileo_timer_callback ); static void galileo_perform_dma(running_machine *machine, int which); -static void voodoo_stall(running_machine *machine, int stall); +static void voodoo_stall(const device_config *device, int stall); static void widget_reset(running_machine *machine); static void update_widget_irq(running_machine *machine); @@ -481,37 +482,9 @@ static void update_widget_irq(running_machine *machine); * *************************************/ -static void seattle_exit(running_machine *machine) -{ - voodoo_exit(0); -} - - -static VIDEO_START( seattle ) -{ - add_exit_callback(machine, seattle_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_1, 2, 4, 0); - - voodoo_set_vblank_callback(0, vblank_assert); - voodoo_set_stall_callback(0, voodoo_stall); -} - - -static VIDEO_START( flagstaff ) -{ - add_exit_callback(machine, seattle_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_1, 2, 4, 4); - - voodoo_set_vblank_callback(0, vblank_assert); - voodoo_set_stall_callback(0, voodoo_stall); -} - - static VIDEO_UPDATE( seattle ) { - return voodoo_update(0, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; + return voodoo_update(voodoo_device, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; } @@ -522,8 +495,16 @@ static VIDEO_UPDATE( seattle ) * *************************************/ -static MACHINE_RESET( seattle ) +static MACHINE_START( seattle ) { + voodoo_device = device_list_find_by_tag(machine->config->devicelist, VOODOO_GRAPHICS, "voodoo"); + + /* allocate timers for the galileo */ + galileo.timer[0].timer = timer_alloc(galileo_timer_callback, NULL); + galileo.timer[1].timer = timer_alloc(galileo_timer_callback, NULL); + galileo.timer[2].timer = timer_alloc(galileo_timer_callback, NULL); + galileo.timer[3].timer = timer_alloc(galileo_timer_callback, NULL); + /* set the fastest DRC options, but strict verification */ cpunum_set_info_int(0, CPUINFO_INT_MIPS3_DRC_OPTIONS, MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY); @@ -539,12 +520,11 @@ static MACHINE_RESET( seattle ) cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_END, 0x1fc7ffff); cpunum_set_info_ptr(0, CPUINFO_PTR_MIPS3_FASTRAM_BASE, rombase); cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_READONLY, 1); +} - /* allocate timers for the galileo */ - galileo.timer[0].timer = timer_alloc(galileo_timer_callback, NULL); - galileo.timer[1].timer = timer_alloc(galileo_timer_callback, NULL); - galileo.timer[2].timer = timer_alloc(galileo_timer_callback, NULL); - galileo.timer[3].timer = timer_alloc(galileo_timer_callback, NULL); + +static MACHINE_RESET( seattle ) +{ galileo.dma_active = -1; vblank_irq_num = 0; @@ -565,8 +545,6 @@ static MACHINE_RESET( seattle ) /* reset the other devices */ galileo_reset(); - devtag_reset(machine, IDE_CONTROLLER, "ide"); - voodoo_reset(0); if (board_config == SEATTLE_WIDGET_CONFIG) widget_reset(machine); if (board_config == FLAGSTAFF_CONFIG) @@ -829,7 +807,7 @@ static void pci_3dfx_w(UINT8 reg, UINT8 type, UINT32 data) break; case 0x10: /* initEnable register */ - voodoo_set_init_enable(0, data); + voodoo_set_init_enable(voodoo_device, data); break; } if (LOG_PCI) @@ -1017,7 +995,7 @@ static void galileo_perform_dma(running_machine *machine, int which) } /* write the data and advance */ - voodoo_0_w(machine, (dstaddr & 0xffffff) / 4, program_read_dword(srcaddr), 0xffffffff); + voodoo_w(voodoo_device, (dstaddr & 0xffffff) / 4, program_read_dword(srcaddr), 0xffffffff); srcaddr += srcinc; dstaddr += dstinc; bytesleft -= 4; @@ -1294,12 +1272,12 @@ static WRITE32_HANDLER( galileo_w ) * *************************************/ -static WRITE32_HANDLER( seattle_voodoo_w ) +static WRITE32_DEVICE_HANDLER( seattle_voodoo_w ) { /* if we're not stalled, just write and get out */ if (!voodoo_stalled) { - voodoo_0_w(machine, offset, data, mem_mask); + voodoo_w(device, offset, data, mem_mask); return; } @@ -1319,7 +1297,7 @@ static WRITE32_HANDLER( seattle_voodoo_w ) } -static void voodoo_stall(running_machine *machine, int stall) +static void voodoo_stall(const device_config *device, int stall) { /* set the new state */ voodoo_stalled = stall; @@ -1355,7 +1333,7 @@ static void voodoo_stall(running_machine *machine, int stall) /* resume execution */ cpuintrf_push_context(0); - galileo_perform_dma(machine, which); + galileo_perform_dma(device->machine, which); cpuintrf_pop_context(); break; } @@ -1365,12 +1343,12 @@ static void voodoo_stall(running_machine *machine, int stall) { /* if the CPU had a pending write, do it now */ if (cpu_stalled_on_voodoo) - voodoo_0_w(machine, cpu_stalled_offset, cpu_stalled_data, cpu_stalled_mem_mask); + voodoo_w(device, cpu_stalled_offset, cpu_stalled_data, cpu_stalled_mem_mask); cpu_stalled_on_voodoo = FALSE; /* resume CPU execution */ if (LOG_DMA) logerror("Resuming CPU on voodoo\n"); - cpu_trigger(machine, 45678); + cpu_trigger(device->machine, 45678); } } } @@ -1720,7 +1698,7 @@ PCI Mem = 08000000-09FFFFFF static ADDRESS_MAP_START( seattle_map, ADDRESS_SPACE_PROGRAM, 32 ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE(&rambase) // wg3dh only has 4MB; sfrush, blitz99 8MB - AM_RANGE(0x08000000, 0x08ffffff) AM_READWRITE(voodoo_0_r, seattle_voodoo_w) + AM_RANGE(0x08000000, 0x08ffffff) AM_DEVREADWRITE(VOODOO_GRAPHICS, "voodoo", voodoo_r, seattle_voodoo_w) AM_RANGE(0x0a000000, 0x0a0003ff) AM_DEVREADWRITE(IDE_CONTROLLER, "ide", ide_controller32_r, ide_controller32_w) AM_RANGE(0x0a00040c, 0x0a00040f) AM_NOP // IDE-related, but annoying AM_RANGE(0x0a000f00, 0x0a000f07) AM_DEVREADWRITE(IDE_CONTROLLER, "ide", ide_bus_master32_r, ide_bus_master32_w) @@ -2455,11 +2433,17 @@ static MACHINE_DRIVER_START( seattle_common ) MDRV_CPU_CONFIG(config) MDRV_CPU_PROGRAM_MAP(seattle_map,0) + MDRV_MACHINE_START(seattle) MDRV_MACHINE_RESET(seattle) MDRV_NVRAM_HANDLER(generic_1fill) MDRV_IDE_CONTROLLER_ADD("ide", 0, ide_interrupt) + MDRV_3DFX_VOODOO_1_ADD("voodoo", STD_VOODOO_1_CLOCK, 2, "main") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_VBLANK(vblank_assert) + MDRV_3DFX_VOODOO_STALL(voodoo_stall) + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_REFRESH_RATE(57) @@ -2467,7 +2451,6 @@ static MACHINE_DRIVER_START( seattle_common ) MDRV_SCREEN_SIZE(640, 480) MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479) - MDRV_VIDEO_START(seattle) MDRV_VIDEO_UPDATE(seattle) /* sound hardware */ @@ -2498,7 +2481,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( flagstaff ) MDRV_IMPORT_FROM(seattle_common) MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*4) - MDRV_VIDEO_START(flagstaff) + + MDRV_3DFX_VOODOO_MODIFY("voodoo") + MDRV_3DFX_VOODOO_TMU_MEMORY(1, 4) + MDRV_IMPORT_FROM(cage_seattle) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vegas.c b/src/mame/drivers/vegas.c index 59176026086..548ff3a15d6 100644 --- a/src/mame/drivers/vegas.c +++ b/src/mame/drivers/vegas.c @@ -475,7 +475,7 @@ static UINT8 cmos_unlocked; static UINT32 *timekeeper_nvram; static size_t timekeeper_nvram_size; -static UINT8 voodoo_type; +static const device_config *voodoo_device; static UINT8 dcs_idma_cs; static int dynamic_count; @@ -501,7 +501,6 @@ static struct dynamic_address * *************************************/ -static void vblank_assert(running_machine *machine, int state); static TIMER_CALLBACK( nile_timer_callback ); static void ide_interrupt(const device_config *device, int state); static void remap_dynamic_addresses(running_machine *machine); @@ -514,42 +513,9 @@ static void remap_dynamic_addresses(running_machine *machine); * *************************************/ -static void vegas_exit(running_machine *machine) -{ - voodoo_exit(0); -} - - -static VIDEO_START( vegas_voodoo2 ) -{ - add_exit_callback(machine, vegas_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_2, 2, 4, 4); - voodoo_set_vblank_callback(0, vblank_assert); -} - - -static VIDEO_START( vegas_voodoo_banshee ) -{ - add_exit_callback(machine, vegas_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_BANSHEE, 16, 16, 0); - voodoo_set_vblank_callback(0, vblank_assert); -} - - -static VIDEO_START( vegas_voodoo3 ) -{ - add_exit_callback(machine, vegas_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_3, 16, 16, 16); - voodoo_set_vblank_callback(0, vblank_assert); -} - - static VIDEO_UPDATE( vegas ) { - return voodoo_update(0, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; + return voodoo_update(voodoo_device, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; } @@ -560,8 +526,24 @@ static VIDEO_UPDATE( vegas ) * *************************************/ -static MACHINE_RESET( vegas ) +static MACHINE_START( vegas ) { + voodoo_device = device_list_find_by_tag(machine->config->devicelist, VOODOO_GRAPHICS, "voodoo"); + + /* allocate timers for the NILE */ + timer[0] = timer_alloc(NULL, NULL); + timer[1] = timer_alloc(NULL, NULL); + timer[2] = timer_alloc(nile_timer_callback, NULL); + timer[3] = timer_alloc(nile_timer_callback, NULL); + + /* identify our sound board */ + if (mame_find_cpu_index(machine, "dsio") != -1) + dcs_idma_cs = 6; + else if (mame_find_cpu_index(machine, "denver") != -1) + dcs_idma_cs = 7; + else + dcs_idma_cs = 0; + /* set the fastest DRC options, but strict verification */ cpunum_set_info_int(0, CPUINFO_INT_MIPS3_DRC_OPTIONS, MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY + MIPS3DRC_FLUSH_PC); @@ -577,13 +559,11 @@ static MACHINE_RESET( vegas ) cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_END, 0x1fc7ffff); cpunum_set_info_ptr(0, CPUINFO_PTR_MIPS3_FASTRAM_BASE, rombase); cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_READONLY, 1); +} - /* allocate timers for the NILE */ - timer[0] = timer_alloc(NULL, NULL); - timer[1] = timer_alloc(NULL, NULL); - timer[2] = timer_alloc(nile_timer_callback, NULL); - timer[3] = timer_alloc(nile_timer_callback, NULL); +static MACHINE_RESET( vegas ) +{ /* reset dynamic addressing */ memset(nile_regs, 0, 0x1000); memset(pci_ide_regs, 0, sizeof(pci_ide_regs)); @@ -597,23 +577,12 @@ static MACHINE_RESET( vegas ) } /* reset subsystems */ - devtag_reset(machine, IDE_CONTROLLER, "ide"); - voodoo_reset(0); smc91c94_reset(machine); /* initialize IRQ states */ ide_irq_state = 0; nile_irq_state = 0; sio_irq_state = 0; - - /* find out what type of voodoo we have */ - voodoo_type = voodoo_get_type(0); - if (mame_find_cpu_index(machine, "dsio") != -1) - dcs_idma_cs = 6; - else if (mame_find_cpu_index(machine, "denver") != -1) - dcs_idma_cs = 7; - else - dcs_idma_cs = 0; } @@ -806,6 +775,7 @@ static WRITE32_HANDLER( pci_ide_w ) static READ32_HANDLER( pci_3dfx_r ) { + int voodoo_type = voodoo_get_type(voodoo_device); UINT32 result = pci_3dfx_regs[offset]; switch (offset) @@ -838,6 +808,8 @@ static READ32_HANDLER( pci_3dfx_r ) static WRITE32_HANDLER( pci_3dfx_w ) { + int voodoo_type = voodoo_get_type(voodoo_device); + pci_3dfx_regs[offset] = data; switch (offset) @@ -875,7 +847,7 @@ static WRITE32_HANDLER( pci_3dfx_w ) break; case 0x10: /* initEnable register */ - voodoo_set_init_enable(0, data); + voodoo_set_init_enable(voodoo_device, data); break; } @@ -1569,6 +1541,7 @@ INLINE void _add_dynamic_device_address(const device_config *device, offs_t star static void remap_dynamic_addresses(running_machine *machine) { const device_config *ide = device_list_find_by_tag(machine->config->devicelist, IDE_CONTROLLER, "ide"); + int voodoo_type = voodoo_get_type(voodoo_device); offs_t base; int addr; @@ -1667,24 +1640,24 @@ static void remap_dynamic_addresses(running_machine *machine) if (base >= ramsize && base < 0x20000000) { if (voodoo_type == VOODOO_2) - add_dynamic_address(base + 0x000000, base + 0xffffff, voodoo_0_r, voodoo_0_w); + add_dynamic_device_address(voodoo_device, base + 0x000000, base + 0xffffff, voodoo_r, voodoo_w); else - add_dynamic_address(base + 0x000000, base + 0x1ffffff, banshee_0_r, banshee_0_w); + add_dynamic_device_address(voodoo_device, base + 0x000000, base + 0x1ffffff, banshee_r, banshee_w); } if (voodoo_type >= VOODOO_BANSHEE) { base = pci_3dfx_regs[0x05] & 0xfffffff0; if (base >= ramsize && base < 0x20000000) - add_dynamic_address(base + 0x0000000, base + 0x1ffffff, banshee_fb_0_r, banshee_fb_0_w); + add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x1ffffff, banshee_fb_r, banshee_fb_w); base = pci_3dfx_regs[0x06] & 0xfffffff0; if (base >= ramsize && base < 0x20000000) - add_dynamic_address(base + 0x0000000, base + 0x00000ff, banshee_io_0_r, banshee_io_0_w); + add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x00000ff, banshee_io_r, banshee_io_w); base = pci_3dfx_regs[0x0c] & 0xffff0000; if (base >= ramsize && base < 0x20000000) - add_dynamic_address(base + 0x0000000, base + 0x000ffff, banshee_rom_0_r, NULL); + add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x000ffff, banshee_rom_r, NULL); } } @@ -2231,11 +2204,17 @@ static MACHINE_DRIVER_START( vegascore ) MDRV_CPU_CONFIG(config) MDRV_CPU_PROGRAM_MAP(vegas_map_8mb,0) + MDRV_MACHINE_START(vegas) MDRV_MACHINE_RESET(vegas) MDRV_NVRAM_HANDLER(timekeeper_save) MDRV_IDE_CONTROLLER_ADD("ide", 0, ide_interrupt) + MDRV_3DFX_VOODOO_2_ADD("voodoo", STD_VOODOO_2_CLOCK, 2, "main") + MDRV_3DFX_VOODOO_TMU_MEMORY(0, 4) + MDRV_3DFX_VOODOO_TMU_MEMORY(1, 4) + MDRV_3DFX_VOODOO_VBLANK(vblank_assert) + /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) MDRV_SCREEN_REFRESH_RATE(57) @@ -2243,7 +2222,6 @@ static MACHINE_DRIVER_START( vegascore ) MDRV_SCREEN_SIZE(640, 480) MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479) - MDRV_VIDEO_START(vegas_voodoo2) MDRV_VIDEO_UPDATE(vegas) MACHINE_DRIVER_END @@ -2256,41 +2234,54 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( vegas250 ) MDRV_IMPORT_FROM(vegascore) - MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*2.5) MDRV_IMPORT_FROM(dcs2_audio_2104) + + MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*2.5) MACHINE_DRIVER_END static MACHINE_DRIVER_START( vegas32m ) MDRV_IMPORT_FROM(vegascore) + MDRV_IMPORT_FROM(dcs2_audio_dsio) + MDRV_CPU_MODIFY("main") MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0) - MDRV_IMPORT_FROM(dcs2_audio_dsio) MACHINE_DRIVER_END static MACHINE_DRIVER_START( vegasban ) MDRV_IMPORT_FROM(vegascore) + MDRV_IMPORT_FROM(dcs2_audio_2104) + MDRV_CPU_MODIFY("main") MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0) - MDRV_IMPORT_FROM(dcs2_audio_2104) - MDRV_VIDEO_START(vegas_voodoo_banshee) + + MDRV_3DFX_VOODOO_REMOVE("voodoo") + MDRV_3DFX_VOODOO_BANSHEE_ADD("voodoo", STD_VOODOO_BANSHEE_CLOCK, 16, "main") + MDRV_3DFX_VOODOO_VBLANK(vblank_assert) MACHINE_DRIVER_END static MACHINE_DRIVER_START( vegasv3 ) MDRV_IMPORT_FROM(vegas32m) MDRV_CPU_REPLACE("main", RM7000LE, SYSTEM_CLOCK*2.5) - MDRV_VIDEO_START(vegas_voodoo3) + + MDRV_3DFX_VOODOO_REMOVE("voodoo") + MDRV_3DFX_VOODOO_3_ADD("voodoo", STD_VOODOO_3_CLOCK, 16, "main") + MDRV_3DFX_VOODOO_VBLANK(vblank_assert) MACHINE_DRIVER_END static MACHINE_DRIVER_START( denver ) MDRV_IMPORT_FROM(vegascore) + MDRV_IMPORT_FROM(dcs2_audio_denver) + MDRV_CPU_REPLACE("main", RM7000LE, SYSTEM_CLOCK*2.5) MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0) - MDRV_VIDEO_START(vegas_voodoo3) - MDRV_IMPORT_FROM(dcs2_audio_denver) + + MDRV_3DFX_VOODOO_REMOVE("voodoo") + MDRV_3DFX_VOODOO_3_ADD("voodoo", STD_VOODOO_3_CLOCK, 16, "main") + MDRV_3DFX_VOODOO_VBLANK(vblank_assert) MACHINE_DRIVER_END @@ -2582,7 +2573,6 @@ static DRIVER_INIT( cartfury ) - /************************************* * * Game drivers diff --git a/src/mame/drivers/viper.c b/src/mame/drivers/viper.c index 99d82c41266..f5fb5df039c 100644 --- a/src/mame/drivers/viper.c +++ b/src/mame/drivers/viper.c @@ -39,21 +39,10 @@ static UINT8 backup_ram[0x2000]; -static void viper_exit(running_machine *machine) -{ - voodoo_exit(0); -} - -static VIDEO_START(viper) -{ - add_exit_callback(machine, viper_exit); - - voodoo_start(0, machine->primary_screen, VOODOO_3, 16, 16, 16); -} - static VIDEO_UPDATE(viper) { - return voodoo_update(0, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; + const device_config *device = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo"); + return voodoo_update(device, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; } @@ -527,6 +516,7 @@ static void voodoo3_pci_w(int function, int reg, UINT32 data, UINT32 mem_mask) } } +#if 0 static READ64_HANDLER(voodoo3_io_r) { return read64be_with_32le_handler(banshee_io_0_r, machine, offset, mem_mask); @@ -556,7 +546,7 @@ static WRITE64_HANDLER(voodoo3_lfb_w) // printf("voodoo3_lfb_w: %08X%08X, %08X at %08X\n", (UINT32)(data >> 32), (UINT32)(data), offset, activecpu_get_pc()); write64be_with_32le_handler(banshee_fb_0_w, machine, offset, data, mem_mask); } - +#endif static READ64_HANDLER(m48t58_r) @@ -592,9 +582,9 @@ static WRITE64_HANDLER(m48t58_w) static ADDRESS_MAP_START(viper_map, ADDRESS_SPACE_PROGRAM, 64) AM_RANGE(0x00000000, 0x00ffffff) AM_MIRROR(0x1000000) AM_RAM AM_RANGE(0x80000000, 0x800fffff) AM_READWRITE(epic_64be_r, epic_64be_w) - AM_RANGE(0x82000000, 0x83ffffff) AM_READWRITE(voodoo3_r, voodoo3_w) - AM_RANGE(0x84000000, 0x85ffffff) AM_READWRITE(voodoo3_lfb_r, voodoo3_lfb_w) - AM_RANGE(0xfe800000, 0xfe8000ff) AM_READWRITE(voodoo3_io_r, voodoo3_io_w) + AM_RANGE(0x82000000, 0x83ffffff) AM_DEVREADWRITE32(VOODOO_GRAPHICS, "voodoo", banshee_r, banshee_w, U64(0xffffffffffffffff)) + AM_RANGE(0x84000000, 0x85ffffff) AM_DEVREADWRITE32(VOODOO_GRAPHICS, "voodoo", banshee_fb_r, banshee_fb_w, U64(0xffffffffffffffff)) + AM_RANGE(0xfe800000, 0xfe8000ff) AM_DEVREADWRITE32(VOODOO_GRAPHICS, "voodoo", banshee_io_r, banshee_io_w, U64(0xffffffffffffffff)) AM_RANGE(0xfec00000, 0xfedfffff) AM_READWRITE(pci_config_addr_r, pci_config_addr_w) AM_RANGE(0xfee00000, 0xfeefffff) AM_READWRITE(pci_config_data_r, pci_config_data_w) AM_RANGE(0xff300000, 0xff300fff) AM_DEVREADWRITE(IDE_CONTROLLER, "ide", ata_r, ata_w) @@ -643,6 +633,7 @@ static MACHINE_DRIVER_START(viper) MDRV_NVRAM_HANDLER(timekeeper_0) MDRV_IDE_CONTROLLER_ADD("ide", 0, ide_interrupt) + MDRV_3DFX_VOODOO_3_ADD("voodoo", STD_VOODOO_3_CLOCK, 16, "main") /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) @@ -653,7 +644,6 @@ static MACHINE_DRIVER_START(viper) MDRV_PALETTE_LENGTH(65536) - MDRV_VIDEO_START(viper) MDRV_VIDEO_UPDATE(viper) /* sound hardware */ diff --git a/src/mame/machine/konppc.c b/src/mame/machine/konppc.c index 1463687c90b..abc1030c14a 100644 --- a/src/mame/machine/konppc.c +++ b/src/mame/machine/konppc.c @@ -435,7 +435,7 @@ static UINT32 K033906_r(int chip, int reg) return 0; } -static void K033906_w(int chip, int reg, UINT32 data) +static void K033906_w(running_machine *machine, int chip, int reg, UINT32 data) { switch(reg) { @@ -466,7 +466,8 @@ static void K033906_w(int chip, int reg, UINT32 data) case 0x10: // initEnable { - voodoo_set_init_enable(chip, data); + const device_config *device = device_list_find_by_index(machine->config->devicelist, VOODOO_GRAPHICS, chip); + voodoo_set_init_enable(device, data); break; } @@ -505,7 +506,7 @@ WRITE32_HANDLER(K033906_0_w) { if (pci_bridge_enable[0]) { - K033906_w(0, offset, data); + K033906_w(machine, 0, offset, data); } else { @@ -536,7 +537,7 @@ WRITE32_HANDLER(K033906_1_w) { if (pci_bridge_enable[1]) { - K033906_w(1, offset, data); + K033906_w(machine, 1, offset, data); } else { @@ -546,7 +547,7 @@ WRITE32_HANDLER(K033906_1_w) /*****************************************************************************/ -WRITE32_HANDLER(nwk_fifo_0_w) +WRITE32_DEVICE_HANDLER(nwk_fifo_0_w) { if (nwk_device_sel[0] & 0x01) { @@ -559,11 +560,11 @@ WRITE32_HANDLER(nwk_fifo_0_w) } else { - voodoo_0_w(machine, offset ^ 0x80000, data, mem_mask); + voodoo_w(device, offset ^ 0x80000, data, mem_mask); } } -WRITE32_HANDLER(nwk_fifo_1_w) +WRITE32_DEVICE_HANDLER(nwk_fifo_1_w) { if (nwk_device_sel[1] & 0x01) { @@ -576,11 +577,11 @@ WRITE32_HANDLER(nwk_fifo_1_w) } else { - voodoo_1_w(machine, offset ^ 0x80000, data, mem_mask); + voodoo_w(device, offset ^ 0x80000, data, mem_mask); } } -READ32_HANDLER(nwk_voodoo_0_r) +READ32_DEVICE_HANDLER(nwk_voodoo_0_r) { if ((nwk_device_sel[0] == 0x4) && offset >= 0x100000 && offset < 0x200000) { @@ -588,11 +589,11 @@ READ32_HANDLER(nwk_voodoo_0_r) } else { - return voodoo_0_r(machine, offset, mem_mask); + return voodoo_r(device, offset, mem_mask); } } -READ32_HANDLER(nwk_voodoo_1_r) +READ32_DEVICE_HANDLER(nwk_voodoo_1_r) { if ((nwk_device_sel[1] == 0x4) && offset >= 0x100000 && offset < 0x200000) { @@ -600,11 +601,11 @@ READ32_HANDLER(nwk_voodoo_1_r) } else { - return voodoo_1_r(machine, offset, mem_mask); + return voodoo_r(device, offset, mem_mask); } } -WRITE32_HANDLER(nwk_voodoo_0_w) +WRITE32_DEVICE_HANDLER(nwk_voodoo_0_w) { if (nwk_device_sel[0] & 0x01) { @@ -617,11 +618,11 @@ WRITE32_HANDLER(nwk_voodoo_0_w) } else { - voodoo_0_w(machine, offset, data, mem_mask); + voodoo_w(device, offset, data, mem_mask); } } -WRITE32_HANDLER(nwk_voodoo_1_w) +WRITE32_DEVICE_HANDLER(nwk_voodoo_1_w) { if (nwk_device_sel[1] & 0x01) { @@ -634,7 +635,7 @@ WRITE32_HANDLER(nwk_voodoo_1_w) } else { - voodoo_1_w(machine, offset, data, mem_mask); + voodoo_w(device, offset, data, mem_mask); } } diff --git a/src/mame/machine/konppc.h b/src/mame/machine/konppc.h index f27c461a9f5..2b9f6d8535c 100644 --- a/src/mame/machine/konppc.h +++ b/src/mame/machine/konppc.h @@ -32,12 +32,12 @@ WRITE32_HANDLER(K033906_0_w); READ32_HANDLER(K033906_1_r); WRITE32_HANDLER(K033906_1_w); -WRITE32_HANDLER(nwk_fifo_0_w); -WRITE32_HANDLER(nwk_fifo_1_w); -READ32_HANDLER(nwk_voodoo_0_r); -READ32_HANDLER(nwk_voodoo_1_r); -WRITE32_HANDLER(nwk_voodoo_0_w); -WRITE32_HANDLER(nwk_voodoo_1_w); +WRITE32_DEVICE_HANDLER(nwk_fifo_0_w); +WRITE32_DEVICE_HANDLER(nwk_fifo_1_w); +READ32_DEVICE_HANDLER(nwk_voodoo_0_r); +READ32_DEVICE_HANDLER(nwk_voodoo_1_r); +WRITE32_DEVICE_HANDLER(nwk_voodoo_0_w); +WRITE32_DEVICE_HANDLER(nwk_voodoo_1_w); void draw_7segment_led(bitmap_t *bitmap, int x, int y, UINT8 value);