Converted Pocket Gal to use the common deco video routines [David Haywood]

This commit is contained in:
Angelo Salese 2011-03-28 16:53:26 +00:00
parent da5fb6dd0d
commit 82a14bf9fd
5 changed files with 60 additions and 53 deletions

View File

@ -18,6 +18,7 @@
#include "sound/3812intf.h"
#include "sound/msm5205.h"
#include "includes/pcktgal.h"
#include "video/decbac06.h"
/***************************************************************************/
@ -72,11 +73,12 @@ static READ8_DEVICE_HANDLER( pcktgal_adpcm_reset_r )
static ADDRESS_MAP_START( pcktgal_map, AS_PROGRAM, 8 )
AM_RANGE(0x0000, 0x07ff) AM_RAM
AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(pcktgal_videoram_w) AM_BASE_MEMBER(pcktgal_state, videoram)
AM_RANGE(0x0800, 0x0fff) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_data_8bit_r, deco_bac06_pf_data_8bit_w)
AM_RANGE(0x1000, 0x11ff) AM_RAM AM_BASE_SIZE_MEMBER(pcktgal_state, spriteram, spriteram_size)
AM_RANGE(0x1800, 0x1800) AM_READ_PORT("P1")
AM_RANGE(0x1801, 0x1801) AM_WRITE(pcktgal_flipscreen_w)
/* 1800 - 0x181f are unused BAC-06 registers, see video/dec0.c */
AM_RANGE(0x1800, 0x1807) AM_DEVWRITE("tilegen1", deco_bac06_pf_control0_8bit_w)
AM_RANGE(0x1810, 0x181f) AM_DEVREADWRITE("tilegen1", deco_bac06_pf_control1_8bit_r, deco_bac06_pf_control1_8bit_w)
AM_RANGE(0x1a00, 0x1a00) AM_READ_PORT("P2") AM_WRITE(pcktgal_sound_w)
AM_RANGE(0x1c00, 0x1c00) AM_READ_PORT("DSW") AM_WRITE(pcktgal_bank_w)
AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1")
@ -240,7 +242,9 @@ static MACHINE_CONFIG_START( pcktgal, pcktgal_state )
MCFG_PALETTE_LENGTH(512)
MCFG_PALETTE_INIT(pcktgal)
MCFG_VIDEO_START(pcktgal)
MCFG_DEVICE_ADD("tilegen1", deco_bac06_, 0)
deco_bac06_device_config::set_gfx_region_wide(device, 0,0,0);
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
@ -259,6 +263,8 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( bootleg, pcktgal )
MCFG_GFXDECODE(bootleg)
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_UPDATE(pcktgalb)
MACHINE_CONFIG_END
/***************************************************************************/

View File

@ -4,10 +4,8 @@ public:
pcktgal_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *videoram;
int msm5205next;
int toggle;
tilemap_t *bg_tilemap;
UINT8 *spriteram;
size_t spriteram_size;
};
@ -15,9 +13,7 @@ public:
/*----------- defined in video/pcktgal.c -----------*/
WRITE8_HANDLER( pcktgal_videoram_w );
WRITE8_HANDLER( pcktgal_flipscreen_w );
PALETTE_INIT( pcktgal );
VIDEO_START( pcktgal );
SCREEN_UPDATE( pcktgal );
SCREEN_UPDATE( pcktgalb );

View File

@ -5,7 +5,14 @@
we could implement this as either an 8-bit or a 16-bit chip, for now
I'm using the 16-bit implementation from dec0.c
used by:
actfancr.c
dec0.c
dec8.c (oscar, cobracom, ghostb)
madmotor.c
stadhero.c
pcktgal.c
Notes (from dec0.c)
@ -218,12 +225,25 @@ void deco_bac06_device::custom_tilemap_draw(running_machine *machine,
const bitmap_t *flags_bitmap = tilemap_get_flagsmap(tilemap_ptr);
int x, y, p, colpri;
int column_offset=0, src_x=0, src_y=0;
UINT32 scrollx=control1[0];
UINT32 scrolly=control1[1];
UINT32 scrollx = 0;
UINT32 scrolly = 0;
if (control1)
{
scrollx = control1[0];
scrolly = control1[1];
}
int width_mask;
int height_mask;
int row_scroll_enabled = (rowscroll_ptr && (control0[0]&0x4));
int col_scroll_enabled = (colscroll_ptr && (control0[0]&0x8));
int row_scroll_enabled = 0;
int col_scroll_enabled = 0;
if (control0)
{
row_scroll_enabled = (rowscroll_ptr && (control0[0]&0x4));
col_scroll_enabled = (colscroll_ptr && (control0[0]&0x8));
}
if (!src_bitmap)
return;
@ -317,6 +337,17 @@ void deco_bac06_device::deco_bac06_pf_draw(running_machine *machine,bitmap_t *bi
}
// used for pocket gal bootleg, which doesn't set registers properly and simply expects a fixed size tilemap.
void deco_bac06_device::deco_bac06_pf_draw_bootleg(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags, int mode, int type)
{
tilemap_t* tm = 0;
if (!mode) tm = pf8x8_tilemap[type];
else tm = pf16x16_tilemap[type];
custom_tilemap_draw(machine,bitmap,cliprect,tm,pf_rowscroll,pf_colscroll,0,0,flags, 0, 0, 0, 0);
}
WRITE16_DEVICE_HANDLER( deco_bac06_pf_control_0_w )
{

View File

@ -35,6 +35,8 @@ public:
UINT16 pf_control_1[8];
void deco_bac06_pf_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags,UINT16 penmask, UINT16 pencondition,UINT16 colprimask, UINT16 colpricondition);
void deco_bac06_pf_draw_bootleg(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags, int mode, int type);
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
@ -84,9 +86,8 @@ READ16_DEVICE_HANDLER( deco_bac06_pf_colscroll_r );
/* 8-bit accessors */
/* for dec8.c */
/* for dec8.c, pcktgal.c */
READ8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_r );
WRITE8_DEVICE_HANDLER( deco_bac06_pf_control_8bit_w );
WRITE8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_w );
WRITE8_DEVICE_HANDLER( deco_bac06_pf_control0_8bit_w );
@ -96,7 +97,7 @@ WRITE8_DEVICE_HANDLER( deco_bac06_pf_control1_8bit_w );
READ8_DEVICE_HANDLER( deco_bac06_pf_rowscroll_8bit_r );
WRITE8_DEVICE_HANDLER( deco_bac06_pf_rowscroll_8bit_w );
/* for hippodrm (dec0.c) */
/* for hippodrm (dec0.c) and actfancr / triothep (H6280 based games)*/
WRITE8_DEVICE_HANDLER( deco_bac06_pf_control0_8bit_packed_w );
WRITE8_DEVICE_HANDLER( deco_bac06_pf_control1_8bit_swap_w );
READ8_DEVICE_HANDLER( deco_bac06_pf_data_8bit_swap_r );

View File

@ -1,6 +1,6 @@
#include "emu.h"
#include "includes/pcktgal.h"
#include "video/decbac06.h"
PALETTE_INIT( pcktgal )
{
@ -30,40 +30,6 @@ PALETTE_INIT( pcktgal )
}
}
WRITE8_HANDLER( pcktgal_videoram_w )
{
pcktgal_state *state = space->machine->driver_data<pcktgal_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
WRITE8_HANDLER( pcktgal_flipscreen_w )
{
if (flip_screen_get(space->machine) != (data & 0x80))
{
flip_screen_set(space->machine, data & 0x80);
tilemap_mark_all_tiles_dirty_all(space->machine);
}
}
static TILE_GET_INFO( get_bg_tile_info )
{
pcktgal_state *state = machine->driver_data<pcktgal_state>();
UINT8 *videoram = state->videoram;
int code = videoram[tile_index*2+1] + ((videoram[tile_index*2] & 0x0f) << 8);
int color = videoram[tile_index*2] >> 4;
SET_TILE_INFO(0, code, color, 0);
}
VIDEO_START( pcktgal )
{
pcktgal_state *state = machine->driver_data<pcktgal_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
pcktgal_state *state = machine->driver_data<pcktgal_state>();
@ -100,8 +66,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
SCREEN_UPDATE( pcktgal )
{
pcktgal_state *state = screen->machine->driver_data<pcktgal_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
// flip_screen_set(screen->machine, screen->machine->device<deco_bac06_device>("tilegen1")->get_flip_state());
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
SCREEN_UPDATE( pcktgalb )
{
// the bootleg doesn't properly set the tilemap registers, because it's on non-original hardware, which probably doesn't have the flexible tilemaps.
screen->machine->device<deco_bac06_device>("tilegen1")->deco_bac06_pf_draw_bootleg(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0, 2);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;}