mirror of
https://github.com/holub/mame
synced 2025-10-07 09:25:34 +03:00
Converted Stadium Hero driver to use the common Deco video functions [David Haywood]
This commit is contained in:
parent
b40cf676fc
commit
58f70e9184
@ -4,6 +4,8 @@
|
||||
|
||||
Emulation by Bryan McPhail, mish@tendril.co.uk
|
||||
|
||||
Are the colours correct on the scoreboard screen? they look strange
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
@ -13,6 +15,7 @@
|
||||
#include "sound/3812intf.h"
|
||||
#include "sound/okim6295.h"
|
||||
#include "includes/stadhero.h"
|
||||
#include "video/decbac06.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -56,9 +59,9 @@ static WRITE16_HANDLER( stadhero_control_w )
|
||||
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16 )
|
||||
AM_RANGE(0x000000, 0x01ffff) AM_ROM
|
||||
AM_RANGE(0x200000, 0x2007ff) AM_RAM_WRITE(stadhero_pf1_data_w) AM_BASE_MEMBER(stadhero_state, pf1_data)
|
||||
AM_RANGE(0x240000, 0x240007) AM_RAM AM_BASE_MEMBER(stadhero_state, pf2_control_0)
|
||||
AM_RANGE(0x240010, 0x240017) AM_WRITEONLY AM_BASE_MEMBER(stadhero_state, pf2_control_1)
|
||||
AM_RANGE(0x260000, 0x261fff) AM_READWRITE(stadhero_pf2_data_r, stadhero_pf2_data_w)
|
||||
AM_RANGE(0x240000, 0x240007) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_0_w) /* text layer */
|
||||
AM_RANGE(0x240010, 0x240017) AM_DEVWRITE("tilegen1", deco_bac06_pf_control_1_w)
|
||||
AM_RANGE(0x260000, 0x261fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_r, deco_bac06_pf_data_w)
|
||||
AM_RANGE(0x30c000, 0x30c00b) AM_READWRITE(stadhero_control_r, stadhero_control_w)
|
||||
AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
|
||||
AM_RANGE(0xff8000, 0xffbfff) AM_RAM /* Main ram */
|
||||
@ -230,6 +233,9 @@ static MACHINE_CONFIG_START( stadhero, stadhero_state )
|
||||
MCFG_GFXDECODE(stadhero)
|
||||
MCFG_PALETTE_LENGTH(1024)
|
||||
|
||||
MCFG_DEVICE_ADD("tilegen1", deco_bac06_, 0)
|
||||
deco_bac06_device_config::set_gfx_region_wide(device, 1,1,2);
|
||||
|
||||
MCFG_VIDEO_START(stadhero)
|
||||
|
||||
/* sound hardware */
|
||||
|
@ -5,11 +5,7 @@ public:
|
||||
: driver_device(machine, config) { }
|
||||
|
||||
UINT16 *pf1_data;
|
||||
UINT16 *pf2_control_0;
|
||||
UINT16 *pf2_control_1;
|
||||
UINT16 *pf2_data;
|
||||
tilemap_t *pf1_tilemap;
|
||||
tilemap_t *pf2_tilemap;
|
||||
int flipscreen;
|
||||
UINT16 *spriteram;
|
||||
};
|
||||
@ -21,5 +17,3 @@ VIDEO_START( stadhero );
|
||||
SCREEN_UPDATE( stadhero );
|
||||
|
||||
WRITE16_HANDLER( stadhero_pf1_data_w );
|
||||
READ16_HANDLER( stadhero_pf2_data_r );
|
||||
WRITE16_HANDLER( stadhero_pf2_data_w );
|
||||
|
@ -95,17 +95,17 @@ deco_bac06_device::deco_bac06_device(running_machine &_machine, const deco_bac06
|
||||
|
||||
static TILEMAP_MAPPER( tile_shape0_scan )
|
||||
{
|
||||
return (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x70) << 4);
|
||||
return (col & 0xf) + ((row & 0xf) << 4) + ((col & 0x1f0) << 4);
|
||||
}
|
||||
|
||||
static TILEMAP_MAPPER( tile_shape1_scan )
|
||||
{
|
||||
return (col & 0xf) + ((row & 0x1f) << 4) + ((col & 0x30) << 5);
|
||||
return (col & 0xf) + ((row & 0x1f) << 4) + ((col & 0xf0) << 5);
|
||||
}
|
||||
|
||||
static TILEMAP_MAPPER( tile_shape2_scan )
|
||||
{
|
||||
return (col & 0xf) + ((row & 0x3f) << 4) + ((col & 0x10) << 6);
|
||||
return (col & 0xf) + ((row & 0x3f) << 4) + ((col & 0x70) << 6);
|
||||
}
|
||||
|
||||
static TILEMAP_MAPPER( tile_shape0_8x8_scan )
|
||||
@ -129,7 +129,9 @@ static TILEMAP_MAPPER( tile_shape2_8x8_scan )
|
||||
|
||||
static TILE_GET_INFO_DEVICE( get_pf8x8_tile_info )
|
||||
{
|
||||
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
if (dev->m_rambank&1) tile_index+=0x1000;
|
||||
int tile=dev->pf_data[tile_index];
|
||||
int colourpri=(tile>>12);
|
||||
SET_TILE_INFO_DEVICE(dev->tile_region,tile&0xfff,0,0);
|
||||
@ -139,6 +141,7 @@ static TILE_GET_INFO_DEVICE( get_pf8x8_tile_info )
|
||||
static TILE_GET_INFO_DEVICE( get_pf16x16_tile_info )
|
||||
{
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
if (dev->m_rambank&1) tile_index+=0x1000;
|
||||
int tile=dev->pf_data[tile_index];
|
||||
int colourpri=(tile>>12);
|
||||
SET_TILE_INFO_DEVICE(dev->tile_region,tile&0xfff,0,0);
|
||||
@ -156,7 +159,13 @@ void deco_bac06_device::create_tilemaps(int region8x8, int region16x16)
|
||||
|
||||
tile_region = region16x16;
|
||||
|
||||
if (m_wide)
|
||||
if (m_wide==2)
|
||||
{
|
||||
pf16x16_tilemap[0] = tilemap_create_device(this, get_pf16x16_tile_info, tile_shape0_scan, 16, 16, 256, 16);
|
||||
pf16x16_tilemap[1] = tilemap_create_device(this, get_pf16x16_tile_info, tile_shape1_scan, 16, 16, 128, 32);
|
||||
pf16x16_tilemap[2] = tilemap_create_device(this, get_pf16x16_tile_info, tile_shape2_scan, 16, 16, 64, 64);
|
||||
}
|
||||
else if (m_wide==1)
|
||||
{
|
||||
pf16x16_tilemap[0] = tilemap_create_device(this, get_pf16x16_tile_info, tile_shape0_scan, 16, 16, 128, 16);
|
||||
pf16x16_tilemap[1] = tilemap_create_device(this, get_pf16x16_tile_info, tile_shape1_scan, 16, 16, 64, 32);
|
||||
@ -172,12 +181,16 @@ void deco_bac06_device::create_tilemaps(int region8x8, int region16x16)
|
||||
|
||||
void deco_bac06_device::device_start()
|
||||
{
|
||||
pf_data = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2); // 0x2000 is the maximum needed, some games / chip setups map less and mirror
|
||||
pf_data = auto_alloc_array_clear(this->machine, UINT16, 0x4000 / 2); // 0x2000 is the maximum needed, some games / chip setups map less and mirror - stadium hero banks this to 0x4000?!
|
||||
pf_rowscroll = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2);
|
||||
pf_colscroll = auto_alloc_array_clear(this->machine, UINT16, 0x2000 / 2);
|
||||
|
||||
create_tilemaps(m_gfxregion8x8, m_gfxregion16x16);
|
||||
m_gfxcolmask = 0x0f;
|
||||
|
||||
m_bppmult = 0x10;
|
||||
m_bppmask = 0x0f;
|
||||
m_rambank = 0;
|
||||
}
|
||||
|
||||
void deco_bac06_device::device_reset()
|
||||
@ -258,13 +271,13 @@ void deco_bac06_device::custom_tilemap_draw(running_machine *machine,
|
||||
colpri = *BITMAP_ADDR8(flags_bitmap, (src_y + column_offset)&height_mask, src_x&width_mask)&0xf;
|
||||
|
||||
src_x++;
|
||||
if ((flags&TILEMAP_DRAW_OPAQUE) || (p&0xf))
|
||||
if ((flags&TILEMAP_DRAW_OPAQUE) || (p&m_bppmask))
|
||||
{
|
||||
|
||||
|
||||
if ((p&penmask)==pencondition)
|
||||
if((colpri&colprimask)==colpricondition)
|
||||
*BITMAP_ADDR16(bitmap, y, x) = p+(colpri&m_gfxcolmask)*0x10;
|
||||
*BITMAP_ADDR16(bitmap, y, x) = p+(colpri&m_gfxcolmask)*m_bppmult;
|
||||
}
|
||||
}
|
||||
src_y++;
|
||||
@ -309,12 +322,33 @@ WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_0_w )
|
||||
{
|
||||
offset &= 3;
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
|
||||
COMBINE_DATA(&dev->pf_control_0[offset]);
|
||||
|
||||
if (offset==2)
|
||||
{
|
||||
int newbank = dev->pf_control_0[offset]&1;
|
||||
if ((newbank&1) != (dev->m_rambank&1))
|
||||
{
|
||||
// I don't know WHY Stadium Hero uses this as a bank but the RAM test expects it..
|
||||
// I'm curious as to if anything else sets it tho
|
||||
if (strcmp(dev->machine->gamedrv->name,"stadhero"))
|
||||
printf("tilemap ram bank change to %d\n", newbank&1);
|
||||
|
||||
dev->m_rambank = newbank&1;
|
||||
tilemap_mark_all_tiles_dirty(dev->pf8x8_tilemap[0]);
|
||||
tilemap_mark_all_tiles_dirty(dev->pf8x8_tilemap[1]);
|
||||
tilemap_mark_all_tiles_dirty(dev->pf8x8_tilemap[2]);
|
||||
tilemap_mark_all_tiles_dirty(dev->pf16x16_tilemap[0]);
|
||||
tilemap_mark_all_tiles_dirty(dev->pf16x16_tilemap[1]);
|
||||
tilemap_mark_all_tiles_dirty(dev->pf16x16_tilemap[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
READ16_DEVICE_HANDLER( deco_bac06_pf_control_1_r )
|
||||
{
|
||||
offset &= 3;
|
||||
offset &= 7;
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
return dev->pf_control_1[offset];
|
||||
}
|
||||
@ -328,7 +362,10 @@ WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_1_w )
|
||||
|
||||
WRITE16_DEVICE_HANDLER( deco_bac06_pf_data_w )
|
||||
{
|
||||
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
if (dev->m_rambank&1) offset+=0x1000;
|
||||
|
||||
COMBINE_DATA(&dev->pf_data[offset]);
|
||||
tilemap_mark_tile_dirty(dev->pf8x8_tilemap[0],offset);
|
||||
tilemap_mark_tile_dirty(dev->pf8x8_tilemap[1],offset);
|
||||
@ -341,6 +378,8 @@ WRITE16_DEVICE_HANDLER( deco_bac06_pf_data_w )
|
||||
READ16_DEVICE_HANDLER( deco_bac06_pf_data_r )
|
||||
{
|
||||
deco_bac06_device *dev = (deco_bac06_device*)device;
|
||||
if (dev->m_rambank&1) offset+=0x1000;
|
||||
|
||||
return dev->pf_data[offset];
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,9 @@ public:
|
||||
void deco_bac06_pf_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags,UINT16 penmask, UINT16 pencondition,UINT16 colprimask, UINT16 colpricondition);
|
||||
UINT8 get_flip_state(void) { return pf_control_0[0]&0x80; };
|
||||
void set_colmask(int data) { m_gfxcolmask = data; }
|
||||
|
||||
void set_bppmultmask( int mult, int mask ) { m_bppmult = mult; m_bppmask = mask; } // stadium hero has 3bpp tiles
|
||||
UINT8 m_gfxcolmask;
|
||||
int m_rambank; // external connection?
|
||||
|
||||
protected:
|
||||
virtual void device_start();
|
||||
@ -49,6 +50,9 @@ protected:
|
||||
UINT8 m_gfxregion16x16;
|
||||
int m_wide;
|
||||
|
||||
UINT8 m_bppmult;
|
||||
UINT8 m_bppmask;
|
||||
|
||||
void custom_tilemap_draw(running_machine *machine,
|
||||
bitmap_t *bitmap,
|
||||
const rectangle *cliprect,
|
||||
|
@ -5,13 +5,14 @@
|
||||
*********************************************************************
|
||||
|
||||
MXC-06 chip to produce sprites, see dec0.c
|
||||
BAC-06 chip for background?
|
||||
BAC-06 chip for background
|
||||
??? for text layer
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "includes/stadhero.h"
|
||||
|
||||
#include "video/decbac06.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -84,12 +85,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
|
||||
SCREEN_UPDATE( stadhero )
|
||||
{
|
||||
stadhero_state *state = screen->machine->driver_data<stadhero_state>();
|
||||
state->flipscreen=state->pf2_control_0[0]&0x80;
|
||||
tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
|
||||
tilemap_set_scrollx( state->pf2_tilemap,0, state->pf2_control_1[0] );
|
||||
tilemap_set_scrolly( state->pf2_tilemap,0, state->pf2_control_1[1] );
|
||||
// tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
|
||||
|
||||
tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0);
|
||||
screen->machine->device<deco_bac06_device>("tilegen1")->set_bppmultmask(0x8, 0x7);
|
||||
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
|
||||
|
||||
//pf2 draw
|
||||
draw_sprites(screen->machine, bitmap,cliprect,0x00,0x00);
|
||||
tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0);
|
||||
return 0;
|
||||
@ -104,44 +105,9 @@ WRITE16_HANDLER( stadhero_pf1_data_w )
|
||||
tilemap_mark_tile_dirty(state->pf1_tilemap,offset);
|
||||
}
|
||||
|
||||
READ16_HANDLER( stadhero_pf2_data_r )
|
||||
{
|
||||
stadhero_state *state = space->machine->driver_data<stadhero_state>();
|
||||
return state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset];
|
||||
}
|
||||
|
||||
WRITE16_HANDLER( stadhero_pf2_data_w )
|
||||
{
|
||||
stadhero_state *state = space->machine->driver_data<stadhero_state>();
|
||||
COMBINE_DATA(&state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset]);
|
||||
tilemap_mark_tile_dirty(state->pf2_tilemap,offset);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static TILEMAP_MAPPER( stadhero_scan )
|
||||
{
|
||||
/* logical (col,row) -> memory offset */
|
||||
return (col & 0xf) + ((row & 0xf) << 4) + ((row & 0x30) << 4) + ((col & 0x30) << 6);
|
||||
}
|
||||
|
||||
static TILE_GET_INFO( get_pf2_tile_info )
|
||||
{
|
||||
stadhero_state *state = machine->driver_data<stadhero_state>();
|
||||
int tile,color;
|
||||
|
||||
tile=state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | tile_index];
|
||||
color=tile >> 12;
|
||||
tile=tile&0xfff;
|
||||
|
||||
SET_TILE_INFO(
|
||||
1,
|
||||
tile,
|
||||
color,
|
||||
0);
|
||||
}
|
||||
|
||||
static TILE_GET_INFO( get_pf1_tile_info )
|
||||
{
|
||||
stadhero_state *state = machine->driver_data<stadhero_state>();
|
||||
@ -160,10 +126,6 @@ VIDEO_START( stadhero )
|
||||
{
|
||||
stadhero_state *state = machine->driver_data<stadhero_state>();
|
||||
state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows, 8, 8,32,32);
|
||||
state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,stadhero_scan, 16,16,64,64);
|
||||
|
||||
state->pf2_data = auto_alloc_array(machine, UINT16, 0x2000);
|
||||
|
||||
tilemap_set_transparent_pen(state->pf1_tilemap,0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user