started moving common deco MXC06 sprite controller code to it's own device files, reducing code duplication [David Haywood]

This commit is contained in:
Angelo Salese 2011-03-28 21:41:32 +00:00
parent f3916bed57
commit 01c56fd81f
8 changed files with 257 additions and 206 deletions

2
.gitattributes vendored
View File

@ -3848,6 +3848,8 @@ src/mame/video/dec0.c svneol=native#text/plain
src/mame/video/dec8.c svneol=native#text/plain src/mame/video/dec8.c svneol=native#text/plain
src/mame/video/decbac06.c svneol=native#text/plain src/mame/video/decbac06.c svneol=native#text/plain
src/mame/video/decbac06.h svneol=native#text/plain src/mame/video/decbac06.h svneol=native#text/plain
src/mame/video/decmxc06.c svneol=native#text/plain
src/mame/video/decmxc06.h svneol=native#text/plain
src/mame/video/deco16ic.c svneol=native#text/plain src/mame/video/deco16ic.c svneol=native#text/plain
src/mame/video/deco16ic.h svneol=native#text/plain src/mame/video/deco16ic.h svneol=native#text/plain
src/mame/video/deco32.c svneol=native#text/plain src/mame/video/deco32.c svneol=native#text/plain

View File

@ -162,7 +162,7 @@ Notes:
#include "sound/okim6295.h" #include "sound/okim6295.h"
#include "sound/msm5205.h" #include "sound/msm5205.h"
#include "video/decbac06.h" #include "video/decbac06.h"
#include "video/decmxc06.h"
/******************************************************************************/ /******************************************************************************/
@ -1309,6 +1309,9 @@ static MACHINE_CONFIG_START( dec0_base, dec0_state )
MCFG_DEVICE_ADD("tilegen3", deco_bac06_, 0) MCFG_DEVICE_ADD("tilegen3", deco_bac06_, 0)
deco_bac06_device_config::set_gfx_region_wide(device, 0,2,0); deco_bac06_device_config::set_gfx_region_wide(device, 0,2,0);
MCFG_DEVICE_ADD("spritegen", deco_mxc06_, 0)
deco_mxc06_device_config::set_gfx_region(device, 3);
MCFG_VIDEO_START(dec0) MCFG_VIDEO_START(dec0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
@ -1330,6 +1333,25 @@ static MACHINE_CONFIG_DERIVED( dec0_base_sound, dec0_base )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( dec0_base_sound_alt, dec0_base )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz/8) /* verified on pcb */
MCFG_SOUND_ROUTE(0, "mono", 0.90)
MCFG_SOUND_ROUTE(1, "mono", 0.90)
MCFG_SOUND_ROUTE(2, "mono", 0.90)
MCFG_SOUND_ROUTE(3, "mono", 0.35)
MCFG_SOUND_ADD("ym2", YM3812, XTAL_12MHz/4) /* verified on pcb */
MCFG_SOUND_CONFIG(ym3812b_interface)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
MCFG_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( automat, dec0_base ) static MACHINE_CONFIG_DERIVED( automat, dec0_base )
@ -1512,7 +1534,7 @@ static MACHINE_RESET( slyspy )
slyspy_set_protection_map(machine, 0); slyspy_set_protection_map(machine, 0);
} }
static MACHINE_CONFIG_DERIVED( slyspy, dec0_base_sound ) static MACHINE_CONFIG_DERIVED( slyspy, dec0_base_sound_alt )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */
@ -1538,7 +1560,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( secretab, dec0_base_sound ) static MACHINE_CONFIG_DERIVED( secretab, dec0_base_sound_alt )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */
@ -1562,7 +1584,7 @@ static MACHINE_CONFIG_DERIVED( secretab, dec0_base_sound )
MCFG_VIDEO_START(dec0_nodma) MCFG_VIDEO_START(dec0_nodma)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( midres, dec0_base_sound ) static MACHINE_CONFIG_DERIVED( midres, dec0_base_sound_alt )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */

View File

@ -20,6 +20,7 @@
#include "sound/okim6295.h" #include "sound/okim6295.h"
#include "includes/madmotor.h" #include "includes/madmotor.h"
#include "video/decbac06.h" #include "video/decbac06.h"
#include "video/decmxc06.h"
/******************************************************************************/ /******************************************************************************/
@ -281,6 +282,10 @@ static MACHINE_CONFIG_START( madmotor, madmotor_state )
MCFG_DEVICE_ADD("tilegen3", deco_bac06_, 0) MCFG_DEVICE_ADD("tilegen3", deco_bac06_, 0)
deco_bac06_device_config::set_gfx_region_wide(device, 0,2,1); deco_bac06_device_config::set_gfx_region_wide(device, 0,2,1);
MCFG_DEVICE_ADD("spritegen", deco_mxc06_, 0)
deco_mxc06_device_config::set_gfx_region(device, 3);
MCFG_VIDEO_START(madmotor) MCFG_VIDEO_START(madmotor)
/* sound hardware */ /* sound hardware */

View File

@ -612,6 +612,7 @@ $(MAMEOBJ)/dataeast.a: \
$(VIDEO)/deco16ic.o \ $(VIDEO)/deco16ic.o \
$(VIDEO)/decocomn.o \ $(VIDEO)/decocomn.o \
$(VIDEO)/decospr.o \ $(VIDEO)/decospr.o \
$(VIDEO)/decmxc06.o \
$(MAMEOBJ)/dooyong.a: \ $(MAMEOBJ)/dooyong.a: \
$(DRIVERS)/dooyong.o $(VIDEO)/dooyong.o \ $(DRIVERS)/dooyong.o $(VIDEO)/dooyong.o \

View File

@ -2,55 +2,12 @@
Dec0 Video emulation - Bryan McPhail, mish@tendril.co.uk Dec0 Video emulation - Bryan McPhail, mish@tendril.co.uk
********************************************************************* *********************************************************************/
Each game uses the MXC-06 chip to produce sprites.
Sprite data: The unknown bits seem to be unused.
Byte 0:
Bit 0 : Y co-ord hi bit
Bit 1,2 : Sprite width (1x, 2x, 4x, 8x) - NOT YET EMULATED (todo)
Bit 3,4 : Sprite height (1x, 2x, 4x, 8x)
Bit 5 - X flip
Bit 6 - Y flip
Bit 7 - Only display Sprite if set
Byte 1: Y-coords
Byte 2:
Bit 0,1,2,3: Hi bits of sprite number
Bit 4,5,6,7: (Probably unused MSB's of sprite)
Byte 3: Low bits of sprite number
Byte 4:
Bit 0 : X co-ords hi bit
Bit 1,2: ??
Bit 3: Sprite flash (sprite is displayed every other frame)
Bit 4,5,6,7: - Colour
Byte 5: X-coords
**********************************************************************
Palette data
0x000 - character palettes (Sprites on Midnight R)
0x200 - sprite palettes (Characters on Midnight R)
0x400 - tiles 1
0x600 - tiles 2
Bad Dudes, Robocop, Heavy Barrel, Hippodrome - 24 bit rgb
Sly Spy, Midnight Resistance - 12 bit rgb
Todo:
Implement multi-width sprites (used by Birdtry).
Implement sprite/tilemap orthogonality (not strictly needed as no
games make deliberate use of it).
***************************************************************************/
#include "emu.h" #include "emu.h"
#include "includes/dec0.h" #include "includes/dec0.h"
#include "video/decbac06.h" #include "video/decbac06.h"
#include "video/decmxc06.h"
/******************************************************************************/ /******************************************************************************/
@ -87,87 +44,20 @@ WRITE16_HANDLER( dec0_paletteram_b_w )
/******************************************************************************/ /******************************************************************************/
static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectangle *cliprect,int pri_mask,int pri_val)
{
dec0_state *state = machine->driver_data<dec0_state>();
UINT16 *spriteram = state->buffered_spriteram;
int offs;
for (offs = 0;offs < 0x400;offs += 4)
{
int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
y = spriteram[offs];
if ((y&0x8000) == 0) continue;
x = spriteram[offs+2];
colour = x >> 12;
if ((colour & pri_mask) != pri_val) continue;
flash=x&0x800;
if (flash && (machine->primary_screen->frame_number() & 1)) continue;
fx = y & 0x2000;
fy = y & 0x4000;
multi = (1 << ((y & 0x1800) >> 11)) - 1; /* 1x, 2x, 4x, 8x height */
/* multi = 0 1 3 7 */
sprite = spriteram[offs+1] & 0x0fff;
x = x & 0x01ff;
y = y & 0x01ff;
if (x >= 256) x -= 512;
if (y >= 256) y -= 512;
x = 240 - x;
y = 240 - y;
if (x>256) continue; /* Speedup */
sprite &= ~multi;
if (fy)
inc = -1;
else
{
sprite += multi;
inc = 1;
}
if (flip_screen_get(machine)) {
y=240-y;
x=240-x;
if (fx) fx=0; else fx=1;
if (fy) fy=0; else fy=1;
mult=16;
}
else mult=-16;
while (multi >= 0)
{
drawgfx_transpen(bitmap,cliprect,machine->gfx[3],
sprite - multi * inc,
colour,
fx,fy,
x,y + mult * multi,0);
multi--;
}
}
}
/******************************************************************************/
SCREEN_UPDATE( hbarrel ) SCREEN_UPDATE( hbarrel )
{ {
dec0_state *state = screen->machine->driver_data<dec0_state>();
flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state()); flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state());
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
draw_sprites(screen->machine,bitmap,cliprect,0x08,0x08); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, 0x08, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
/* HB always keeps pf2 on top of pf3, no need explicitly support priority register */ /* HB always keeps pf2 on top of pf3, no need explicitly support priority register */
draw_sprites(screen->machine,bitmap,cliprect,0x08,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;
} }
@ -188,7 +78,7 @@ SCREEN_UPDATE( baddudes )
if (state->pri & 2) if (state->pri & 2)
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
if (state->pri & 4) if (state->pri & 4)
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */
@ -201,7 +91,7 @@ SCREEN_UPDATE( baddudes )
if (state->pri & 2) if (state->pri & 2)
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
if (state->pri & 4) if (state->pri & 4)
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */ screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0,0x08,0x08,0x08,0x08); // upper 8 pens of upper 8 priority marked tiles /* Foreground pens only */
@ -234,7 +124,7 @@ SCREEN_UPDATE( robocop )
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
} }
@ -243,15 +133,15 @@ SCREEN_UPDATE( robocop )
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
} }
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans ^ 0x08); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans^0x08, 0x0f);
else else
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;
@ -261,13 +151,15 @@ SCREEN_UPDATE( robocop )
SCREEN_UPDATE( birdtry ) SCREEN_UPDATE( birdtry )
{ {
dec0_state *state = screen->machine->driver_data<dec0_state>();
flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state()); flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state());
/* This game doesn't have the extra playfield chip on the game board, but /* This game doesn't have the extra playfield chip on the game board, but
the palette does show through. */ the palette does show through. */
bitmap_fill(bitmap,cliprect,screen->machine->pens[768]); bitmap_fill(bitmap,cliprect,screen->machine->pens[768]);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;
} }
@ -290,7 +182,7 @@ SCREEN_UPDATE( hippodrm )
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
} }
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;
} }
@ -305,7 +197,7 @@ SCREEN_UPDATE( slyspy )
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
/* Redraw top 8 pens of top 8 palettes over sprites */ /* Redraw top 8 pens of top 8 palettes over sprites */
if (state->pri&0x80) if (state->pri&0x80)
@ -333,7 +225,7 @@ SCREEN_UPDATE( midres )
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
} }
@ -342,15 +234,15 @@ SCREEN_UPDATE( midres )
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
} }
if (state->pri & 0x02) if (state->pri & 0x02)
draw_sprites(screen->machine,bitmap,cliprect,0x08,trans ^ 0x08); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x08, trans ^ 0x08, 0x0f);
else else
draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->buffered_spriteram, 0x00, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;

160
src/mame/video/decmxc06.c Normal file
View File

@ -0,0 +1,160 @@
/*
Deco MXC06 sprite generator:
used by:
madmotor.c
Notes (dec0.c)
Sprite data: The unknown bits seem to be unused.
Byte 0:
Bit 0 : Y co-ord hi bit
Bit 1,2 : Sprite width (1x, 2x, 4x, 8x)
Bit 3,4 : Sprite height (1x, 2x, 4x, 8x)
Bit 5 - X flip
Bit 6 - Y flip
Bit 7 - Only display Sprite if set
Byte 1: Y-coords
Byte 2:
Bit 0,1,2,3: Hi bits of sprite number
Bit 4,5,6,7: (Probably unused MSB's of sprite)
Byte 3: Low bits of sprite number
Byte 4:
Bit 0 : X co-ords hi bit
Bit 1,2: ??
Bit 3: Sprite flash (sprite is displayed every other frame)
Bit 4,5,6,7: - Colour
Byte 5: X-coords
todo:
Implement sprite/tilemap orthogonality (not strictly needed as no
games make deliberate use of it). (pdrawgfx, or rendering to bitmap for manual mixing)
fix multi-width support, used by birdie try
*/
#include "emu.h"
#include "decmxc06.h"
deco_mxc06_device_config::deco_mxc06_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, "decmxc06_device", tag, owner, clock)
{
m_gfxregion = 0;
}
device_config *deco_mxc06_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
{
return global_alloc(deco_mxc06_device_config(mconfig, tag, owner, clock));
}
device_t *deco_mxc06_device_config::alloc_device(running_machine &machine) const
{
return auto_alloc(&machine, deco_mxc06_device(machine, *this));
}
void deco_mxc06_device_config::set_gfx_region(device_config *device, int region)
{
deco_mxc06_device_config *dev = downcast<deco_mxc06_device_config *>(device);
dev->m_gfxregion = region;
}
deco_mxc06_device::deco_mxc06_device(running_machine &_machine, const deco_mxc06_device_config &config)
: device_t(_machine, config),
m_config(config),
m_gfxregion(m_config.m_gfxregion)
{
}
/* this implementation was originally from Mad Motor */
void deco_mxc06_device::draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT16* spriteram, int pri_mask, int pri_val, int col_mask )
{
int offs;
offs = 0;
while (offs < 0x800 / 2)
{
int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y;
sy = spriteram[offs];
sx = spriteram[offs + 2];
color = sx >> 12;
flash = sx & 0x800;
flipx = sy & 0x2000;
flipy = sy & 0x4000;
h = (1 << ((sy & 0x1800) >> 11)); /* 1x, 2x, 4x, 8x height */
w = (1 << ((sy & 0x0600) >> 9)); /* 1x, 2x, 4x, 8x width */
/* multi width used only on the title screen? */
code = spriteram[offs + 1] & 0x1fff;
sx = sx & 0x01ff;
sy = sy & 0x01ff;
if (sx >= 256) sx -= 512;
if (sy >= 256) sy -= 512;
sx = 240 - sx;
sy = 240 - sy;
code &= ~(h-1);
if (flipy)
incy = -1;
else
{
code += h-1;
incy = 1;
}
if (flip_screen_get(machine))
{
sy = 240 - sy;
sx = 240 - sx;
if (flipx) flipx = 0; else flipx = 1;
if (flipy) flipy = 0; else flipy = 1;
mult = 16;
}
else
mult = -16;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
if (spriteram[offs] & 0x8000)
{
if ((color & pri_mask) == pri_val && (!flash || (machine->primary_screen->frame_number() & 1)))
{
drawgfx_transpen(bitmap,cliprect,machine->gfx[m_gfxregion],
code - y * incy + h * x,
color & col_mask,
flipx,flipy,
sx + (mult * x),sy + (mult * y),0);
}
}
}
offs += 4;
if (offs >= 0x800 / 2 || spriteram[offs] & 0x8000) // seems the expected behaviour on the title screen - WRONG for birdie try
break;
}
}
}
void deco_mxc06_device::device_start()
{
}
void deco_mxc06_device::device_reset()
{
}

39
src/mame/video/decmxc06.h Normal file
View File

@ -0,0 +1,39 @@
/* MXC06 */
class deco_mxc06_device_config : public device_config
{
friend class deco_mxc06_device;
deco_mxc06_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
static void set_gfx_region(device_config *device, int region);
protected:
UINT8 m_gfxregion;
};
class deco_mxc06_device : public device_t
{
friend class deco_mxc06_device_config;
deco_mxc06_device(running_machine &_machine, const deco_mxc06_device_config &config);
public:
void set_gfxregion(int region) { m_gfxregion = region; };
void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT16* spriteram16, int pri_mask, int pri_val, int col_mask );
protected:
virtual void device_start();
virtual void device_reset();
const deco_mxc06_device_config &m_config;
UINT8 m_gfxregion;
private:
};
const device_type deco_mxc06_ = deco_mxc06_device_config::static_alloc_device_config;

View File

@ -9,6 +9,7 @@
#include "emu.h" #include "emu.h"
#include "includes/madmotor.h" #include "includes/madmotor.h"
#include "video/decbac06.h" #include "video/decbac06.h"
#include "video/decmxc06.h"
/******************************************************************************/ /******************************************************************************/
@ -18,90 +19,19 @@ VIDEO_START( madmotor )
/******************************************************************************/ /******************************************************************************/
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri_mask, int pri_val )
{
madmotor_state *state = machine->driver_data<madmotor_state>();
UINT16 *spriteram = state->spriteram;
int offs;
offs = 0;
while (offs < state->spriteram_size / 2)
{
int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y;
sy = spriteram[offs];
sx = spriteram[offs + 2];
color = sx >> 12;
flash = sx & 0x800;
flipx = sy & 0x2000;
flipy = sy & 0x4000;
h = (1 << ((sy & 0x1800) >> 11)); /* 1x, 2x, 4x, 8x height */
w = (1 << ((sy & 0x0600) >> 9)); /* 1x, 2x, 4x, 8x width */
/* multi width used only on the title screen? */
code = spriteram[offs + 1] & 0x1fff;
sx = sx & 0x01ff;
sy = sy & 0x01ff;
if (sx >= 256) sx -= 512;
if (sy >= 256) sy -= 512;
sx = 240 - sx;
sy = 240 - sy;
code &= ~(h-1);
if (flipy)
incy = -1;
else
{
code += h-1;
incy = 1;
}
if (state->flipscreen)
{
sy = 240 - sy;
sx = 240 - sx;
if (flipx) flipx = 0; else flipx = 1;
if (flipy) flipy = 0; else flipy = 1;
mult = 16;
}
else
mult = -16;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
if ((color & pri_mask) == pri_val &&
(!flash || (machine->primary_screen->frame_number() & 1)))
drawgfx_transpen(bitmap,cliprect,machine->gfx[3],
code - y * incy + h * x,
color,
flipx,flipy,
sx + mult * x,sy + mult * y,0);
}
offs += 4;
if (offs >= state->spriteram_size / 2 || spriteram[offs] & 0x8000) // seems the expected behaviour on the title screen
break;
}
}
}
/******************************************************************************/ /******************************************************************************/
SCREEN_UPDATE( madmotor ) SCREEN_UPDATE( madmotor )
{ {
madmotor_state *state = screen->machine->driver_data<madmotor_state>();
flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state()); flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state());
// tilemap_set_flip_all(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state() ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); // tilemap_set_flip_all(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state() ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen3")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen2")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
draw_sprites(screen->machine, bitmap, cliprect, 0x00, 0x00); screen->machine->device<deco_mxc06_device>("spritegen")->draw_sprites(screen->machine, bitmap, cliprect, state->spriteram, 0x00, 0x00, 0x0f);
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00);
return 0; return 0;
} }