Converted Kaneko Pandora sprite chip to be a MAME device and updated drivers accordingly.

This commit is contained in:
Fabio Priuli 2009-12-10 09:28:17 +00:00
parent 907c61c43e
commit c0488dbe0d
12 changed files with 345 additions and 154 deletions

View File

@ -299,12 +299,13 @@ static WRITE8_HANDLER( master_bankswitch_w )
static WRITE8_HANDLER( slave_bankswitch_w )
{
const device_config *pandora = devtag_get_device(space->machine, "pandora");
airbustr_bankswitch(space->machine, "slave", "bank2", data);
flip_screen_set(space->machine, data & 0x10);
// used at the end of levels, after defeating the boss, to leave trails
pandora_set_clear_bitmap(data&0x20);
pandora_set_clear_bitmap(pandora, data&0x20);
}
static WRITE8_HANDLER( sound_bankswitch_w )
@ -370,7 +371,7 @@ static WRITE8_HANDLER( airbustr_coin_counter_w )
static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xcfff) AM_READWRITE(pandora_spriteram_r, pandora_spriteram_w)
AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("pandora", pandora_spriteram_r, pandora_spriteram_w)
AM_RANGE(0xd000, 0xdfff) AM_RAM
AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE(&devram) // shared with protection device
AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("share1")
@ -609,6 +610,13 @@ static MACHINE_RESET( airbustr )
/* Machine Driver */
static const kaneko_pandora_interface airbustr_pandora_config =
{
"screen", /* screen tag */
1, /* gfx_region */
0, 0 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( airbustr )
// basic machine hardware
MDRV_CPU_ADD("master", Z80, 6000000) // ???
@ -633,7 +641,6 @@ static MACHINE_DRIVER_START( airbustr )
MDRV_WATCHDOG_TIME_INIT(SEC(3)) /* a guess, and certainly wrong */
// video hardware
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
@ -643,6 +650,8 @@ static MACHINE_DRIVER_START( airbustr )
MDRV_GFXDECODE(airbustr)
MDRV_PALETTE_LENGTH(768)
MDRV_KANEKO_PANDORA_ADD("pandora", airbustr_pandora_config)
MDRV_VIDEO_START(airbustr)
MDRV_VIDEO_UPDATE(airbustr)
MDRV_VIDEO_EOF(airbustr)

View File

@ -743,7 +743,7 @@ static WRITE8_HANDLER( cpu2_bankswitch_w )
static ADDRESS_MAP_START( cpu0_am, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xafff) AM_ROMBANK("bank4")
AM_RANGE(0xb000, 0xbfff) AM_READWRITE( pandora_spriteram_r, pandora_spriteram_w )
AM_RANGE(0xb000, 0xbfff) AM_DEVREADWRITE("pandora", pandora_spriteram_r, pandora_spriteram_w)
AM_RANGE(0xc000, 0xdfff) AM_ROMBANK("bank1")
AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1")
AM_RANGE(0xf000, 0xf7ff) AM_RAM
@ -907,6 +907,13 @@ static INTERRUPT_GEN( djboy_interrupt )
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, addr);
}
static const kaneko_pandora_interface djboy_pandora_config =
{
"screen", /* screen tag */
0, /* gfx_region */
0, 0 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( djboy )
MDRV_CPU_ADD("maincpu", Z80,6000000)
MDRV_CPU_PROGRAM_MAP(cpu0_am)
@ -935,6 +942,8 @@ static MACHINE_DRIVER_START( djboy )
MDRV_GFXDECODE(djboy)
MDRV_PALETTE_LENGTH(0x200)
MDRV_KANEKO_PANDORA_ADD("pandora", djboy_pandora_config)
MDRV_VIDEO_START(djboy)
MDRV_VIDEO_UPDATE(djboy)
MDRV_VIDEO_EOF(djboy)

View File

@ -137,7 +137,8 @@ VIDEO_UPDATE( comad );
static VIDEO_EOF( galpanic )
{
pandora_eof(machine);
const device_config *pandora = devtag_get_device(machine, "pandora");
pandora_eof(pandora);
}
static INTERRUPT_GEN( galpanic_interrupt )
@ -162,6 +163,8 @@ static INTERRUPT_GEN( galhustl_interrupt )
static WRITE16_HANDLER( galpanic_6295_bankswitch_w )
{
const device_config *pandora = devtag_get_device(space->machine, "pandora");
if (ACCESSING_BITS_8_15)
{
UINT8 *rom = memory_region(space->machine, "oki");
@ -169,7 +172,7 @@ static WRITE16_HANDLER( galpanic_6295_bankswitch_w )
memcpy(&rom[0x30000],&rom[0x40000 + ((data >> 8) & 0x0f) * 0x10000],0x10000);
// used before title screen
pandora_set_clear_bitmap((data & 0x8000)>>15);
pandora_set_clear_bitmap(pandora, (data & 0x8000)>>15);
}
}
@ -186,9 +189,11 @@ static WRITE16_HANDLER( galpania_6295_bankswitch_w )
#ifdef UNUSED_FUNCTION
static WRITE16_HANDLER( galpania_misc_w )
{
const device_config *pandora = devtag_get_device(machine, "pandora");
if (ACCESSING_BITS_0_7)
{
pandora_set_clear_bitmap( data & 0x0004 );
pandora_set_clear_bitmap(pandora, data & 0x0004);
}
// other bits unknown !
@ -223,7 +228,7 @@ static ADDRESS_MAP_START( galpanic_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x500000, 0x51ffff) AM_RAM AM_BASE(&galpanic_fgvideoram) AM_SIZE(&galpanic_fgvideoram_size)
AM_RANGE(0x520000, 0x53ffff) AM_RAM_WRITE(galpanic_bgvideoram_w) AM_BASE(&galpanic_bgvideoram) /* + work RAM */
AM_RANGE(0x600000, 0x6007ff) AM_RAM_WRITE(galpanic_paletteram_w) AM_BASE_GENERIC(paletteram) /* 1024 colors, but only 512 seem to be used */
AM_RANGE(0x700000, 0x701fff) AM_READWRITE(pandora_spriteram_LSB_r, pandora_spriteram_LSB_w)
AM_RANGE(0x700000, 0x701fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r, pandora_spriteram_LSB_w)
AM_RANGE(0x702000, 0x704fff) AM_RAM
AM_RANGE(0x800000, 0x800001) AM_READ_PORT("DSW1_P1")
AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2_P2")
@ -868,6 +873,13 @@ static GFXDECODE_START( galpanic )
GFXDECODE_END
static const kaneko_pandora_interface galpanic_pandora_config =
{
"screen", /* screen tag */
0, /* gfx_region */
0, -16 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( galpanic )
@ -887,6 +899,8 @@ static MACHINE_DRIVER_START( galpanic )
MDRV_GFXDECODE(galpanic)
MDRV_PALETTE_LENGTH(1024 + 32768)
MDRV_KANEKO_PANDORA_ADD("pandora", galpanic_pandora_config)
MDRV_PALETTE_INIT(galpanic)
MDRV_VIDEO_START(galpanic)
MDRV_VIDEO_UPDATE(galpanic)
@ -917,6 +931,8 @@ static MACHINE_DRIVER_START( comad )
MDRV_CPU_REPLACE("maincpu", M68000, 10000000)
MDRV_CPU_PROGRAM_MAP(comad_map)
MDRV_DEVICE_REMOVE("pandora")
/* video hardware */
MDRV_VIDEO_UPDATE(comad)
MDRV_VIDEO_EOF(0)

View File

@ -286,7 +286,6 @@ static TILE_GET_INFO( get_bg_tile_info )
static VIDEO_START(hvyunit)
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
pandora_start(machine,0,0,0);
}
#define SX_POS 152
@ -294,7 +293,7 @@ static VIDEO_START(hvyunit)
static VIDEO_UPDATE(hvyunit)
{
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
tilemap_set_scrollx( bg_tilemap,0, ((port0_data&0x40)<<2)+ hu_scrollx + SX_POS); //TODO
tilemap_set_scrolly( bg_tilemap,0, ((port0_data&0x80)<<1)+ hu_scrolly + SY_POS); // TODO
@ -302,13 +301,14 @@ static VIDEO_UPDATE(hvyunit)
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
pandora_update(screen->machine,bitmap,cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}
static VIDEO_EOF(hvyunit)
{
pandora_eof(machine);
const device_config *pandora = devtag_get_device(machine, "pandora");
pandora_eof(pandora);
}
static WRITE8_HANDLER( trigger_nmi_on_sound_cpu2 )
@ -349,7 +349,7 @@ static WRITE8_HANDLER( hu_colorram_w )
static ADDRESS_MAP_START( master_memory, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xcfff) AM_READWRITE( pandora_spriteram_r, pandora_spriteram_w )
AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("pandora", pandora_spriteram_r, pandora_spriteram_w)
AM_RANGE(0xd000, 0xdfff) AM_RAM
AM_RANGE(0xe000, 0xefff) AM_RAM AM_SHARE("share1")
AM_RANGE(0xf000, 0xffff) AM_RAM
@ -630,6 +630,13 @@ static INTERRUPT_GEN( hvyunit_interrupt )
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, addr);
}
static const kaneko_pandora_interface hvyunit_pandora_config =
{
"screen", /* screen tag */
0, /* gfx_region */
0, 0 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( hvyunit )
@ -661,6 +668,8 @@ static MACHINE_DRIVER_START( hvyunit )
MDRV_GFXDECODE(hvyunit)
MDRV_PALETTE_LENGTH(0x800)
MDRV_KANEKO_PANDORA_ADD("pandora", hvyunit_pandora_config)
MDRV_VIDEO_START(hvyunit)
MDRV_VIDEO_UPDATE(hvyunit)
MDRV_VIDEO_EOF(hvyunit)

View File

@ -122,9 +122,10 @@ static INTERRUPT_GEN( sandscrp_interrupt )
static VIDEO_EOF( sandscrp )
{
const device_config *pandora = devtag_get_device(machine, "pandora");
sprite_irq = 1;
update_irq_state(machine);
pandora_eof(machine);
pandora_eof(pandora);
}
/* Reads the cause of the interrupt */
@ -213,7 +214,7 @@ static ADDRESS_MAP_START( sandscrp, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x401000, 0x401fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0) //
AM_RANGE(0x402000, 0x402fff) AM_RAM AM_BASE(&kaneko16_vscroll_1) //
AM_RANGE(0x403000, 0x403fff) AM_RAM AM_BASE(&kaneko16_vscroll_0) //
AM_RANGE(0x500000, 0x501fff) AM_READWRITE(pandora_spriteram_LSB_r, pandora_spriteram_LSB_w ) // sprites
AM_RANGE(0x500000, 0x501fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r, pandora_spriteram_LSB_w ) // sprites
AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram) // Palette
AM_RANGE(0xa00000, 0xa00001) AM_WRITE(sandscrp_coin_counter_w) // Coin Counters (Lockout unused)
AM_RANGE(0xb00000, 0xb00001) AM_READ_PORT("P1")
@ -431,6 +432,13 @@ static const ym2203_interface ym2203_intf_sandscrp =
};
static const kaneko_pandora_interface sandscrp_pandora_config =
{
"screen", /* screen tag */
0, /* gfx_region */
0, 0 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( sandscrp )
/* basic machine hardware */
@ -457,6 +465,8 @@ static MACHINE_DRIVER_START( sandscrp )
MDRV_GFXDECODE(sandscrp)
MDRV_PALETTE_LENGTH(2048)
MDRV_KANEKO_PANDORA_ADD("pandora", sandscrp_pandora_config)
MDRV_VIDEO_START(sandscrp_1xVIEW2)
MDRV_VIDEO_EOF(sandscrp)
MDRV_VIDEO_UPDATE(sandscrp)

View File

@ -82,21 +82,19 @@ static WRITE16_HANDLER( snowbros_flipscreen_w )
static VIDEO_UPDATE( snowbros )
{
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
/* This clears & redraws the entire screen each pass */
bitmap_fill(bitmap,cliprect,0xf0);
pandora_update(screen->machine,bitmap,cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}
static VIDEO_START( snowbros )
{
pandora_start(machine,0,0,0);
}
static VIDEO_EOF( snowbros )
{
pandora_eof(machine);
const device_config *pandora = devtag_get_device(machine, "pandora");
pandora_eof(pandora);
}
@ -185,7 +183,7 @@ static ADDRESS_MAP_START( snowbros_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x500002, 0x500003) AM_READ_PORT("DSW2")
AM_RANGE(0x500004, 0x500005) AM_READ_PORT("SYSTEM")
AM_RANGE(0x600000, 0x6001ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x700000, 0x701fff) AM_READWRITE(pandora_spriteram_LSB_r,pandora_spriteram_LSB_w)
AM_RANGE(0x700000, 0x701fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r, pandora_spriteram_LSB_w)
AM_RANGE(0x800000, 0x800001) AM_WRITE(snowbros_irq4_ack_w) /* IRQ 4 acknowledge */
AM_RANGE(0x900000, 0x900001) AM_WRITE(snowbros_irq3_ack_w) /* IRQ 3 acknowledge */
AM_RANGE(0xa00000, 0xa00001) AM_WRITE(snowbros_irq2_ack_w) /* IRQ 2 acknowledge */
@ -366,7 +364,7 @@ static ADDRESS_MAP_START( hyperpac_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x500004, 0x500005) AM_READ_PORT("SYSTEM")
AM_RANGE(0x600000, 0x6001ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x700000, 0x701fff) AM_READWRITE(pandora_spriteram_LSB_r,pandora_spriteram_LSB_w)
AM_RANGE(0x700000, 0x701fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r,pandora_spriteram_LSB_w)
AM_RANGE(0x800000, 0x800001) AM_WRITE(snowbros_irq4_ack_w) /* IRQ 4 acknowledge */
AM_RANGE(0x900000, 0x900001) AM_WRITE(snowbros_irq3_ack_w) /* IRQ 3 acknowledge */
AM_RANGE(0xa00000, 0xa00001) AM_WRITE(snowbros_irq2_ack_w) /* IRQ 2 acknowledge */
@ -517,7 +515,7 @@ static ADDRESS_MAP_START( finalttr_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x500004, 0x500005) AM_READ_PORT("SYSTEM")
AM_RANGE(0x600000, 0x6001ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x700000, 0x701fff) AM_READWRITE(pandora_spriteram_LSB_r,pandora_spriteram_LSB_w)
AM_RANGE(0x700000, 0x701fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r, pandora_spriteram_LSB_w)
AM_RANGE(0x800000, 0x800001) AM_WRITE(snowbros_irq4_ack_w) /* IRQ 4 acknowledge */
AM_RANGE(0x900000, 0x900001) AM_WRITE(snowbros_irq3_ack_w) /* IRQ 3 acknowledge */
AM_RANGE(0xa00000, 0xa00001) AM_WRITE(snowbros_irq2_ack_w) /* IRQ 2 acknowledge */
@ -1514,6 +1512,13 @@ static MACHINE_RESET (finalttr)
hyperpac_ram[0x2000/2 + i] = PROTDATA[i];
}
static const kaneko_pandora_interface snowbros_pandora_config =
{
"screen", /* screen tag */
0, /* gfx_region */
0, 0 /* x_offs, y_offs */
};
static MACHINE_DRIVER_START( snowbros )
/* basic machine hardware */
@ -1536,10 +1541,11 @@ static MACHINE_DRIVER_START( snowbros )
MDRV_GFXDECODE(snowbros)
MDRV_PALETTE_LENGTH(256)
MDRV_VIDEO_START(snowbros)
MDRV_VIDEO_UPDATE(snowbros)
MDRV_VIDEO_EOF(snowbros)
MDRV_KANEKO_PANDORA_ADD("pandora", snowbros_pandora_config)
/* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1555,6 +1561,8 @@ static MACHINE_DRIVER_START( wintbob )
MDRV_CPU_REPLACE("maincpu", M68000, 10000000) /* 10mhz - Confirmed */
MDRV_CPU_PROGRAM_MAP(wintbob_map)
MDRV_DEVICE_REMOVE("pandora")
/* video hardware */
MDRV_GFXDECODE(wb)
MDRV_VIDEO_UPDATE(wintbob)

View File

@ -121,7 +121,6 @@ VIDEO_START( airbustr )
sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state_save_register_global_bitmap(machine, sprites_bitmap);
tilemap_set_transparent_pen(fg_tilemap, 0);
pandora_start(machine,1,0,0);
tilemap_set_scrolldx(bg_tilemap, 0x094, 0x06a);
tilemap_set_scrolldy(bg_tilemap, 0x100, 0x1ff);
@ -132,18 +131,20 @@ VIDEO_START( airbustr )
VIDEO_UPDATE( airbustr )
{
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
// copy the sprite bitmap to the screen
pandora_update(screen->machine, bitmap, cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}
VIDEO_EOF( airbustr )
{
const device_config *pandora = devtag_get_device(machine, "pandora");
// update the sprite bitmap
pandora_eof(machine);
pandora_eof(pandora);
}

View File

@ -45,7 +45,6 @@ WRITE8_HANDLER( djboy_videoram_w )
VIDEO_START( djboy )
{
background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,16,16,64,32);
pandora_start(machine,0,0,0);
}
WRITE8_HANDLER( djboy_paletteram_w )
@ -67,17 +66,19 @@ VIDEO_UPDATE( djboy )
* ---x---- flipscreen?
* ----xxxx ROM bank
*/
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
int scroll;
scroll = djboy_scrollx | ((djboy_videoreg&0xc0)<<2);
tilemap_set_scrollx( background, 0, scroll-0x391 );
scroll = djboy_scrolly | ((djboy_videoreg&0x20)<<3);
tilemap_set_scrolly( background, 0, scroll );
tilemap_draw( bitmap, cliprect,background,0,0 );
pandora_update(screen->machine,bitmap,cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}
VIDEO_EOF( djboy )
{
pandora_eof(machine);
const device_config *pandora = devtag_get_device(machine, "pandora");
pandora_eof(pandora);
}

View File

@ -10,8 +10,6 @@ VIDEO_START( galpanic )
{
machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
pandora_start(machine,0,0, -16);
}
PALETTE_INIT( galpanic )
@ -103,12 +101,14 @@ static void draw_fgbitmap(bitmap_t *bitmap, const rectangle *cliprect)
VIDEO_UPDATE( galpanic )
{
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
/* copy the temporary bitmap to the screen */
copybitmap(bitmap,screen->machine->generic.tmpbitmap,0,0,0,0,cliprect);
draw_fgbitmap(bitmap, cliprect);
pandora_update(screen->machine,bitmap,cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}

View File

@ -1,4 +1,6 @@
/* kan_pand.c Kaneko Pandora Sprite Chip
/***********************************************************************
Kaneko Pandora Sprite Chip
GFX processor - PX79C480FP-3 (KANEKO, Pandora-Chip)
This emulates the Kaneko Pandora Sprite Chip
@ -13,7 +15,7 @@
Air Buster
DJ Boy
Heavy Unit
Sand Scorpian
Sand Scorpion
Gals Panic (1st release)
The SemiCom games are also using this because
@ -32,48 +34,81 @@
hookups.
to use this in a driver you must hook functions to
VIDEO_START (allocates ram used by chip)
VIDEO_UPDATE (copies framebuffer to screen)
and
VIDEO_EOF (renders the sprites to the framebuffer)
also, you have to add the correspondent device in MACHINE_DRIVER
spriteram should be accessed only with the
pandora_spriteram_r / pandora_spriteram_w or
pandora_spriteram_LSB_r / pandora_spriteram_LSB_w
handlers, depending on the CPU being used with it.
*/
***********************************************************************/
#include "driver.h"
#include "kan_pand.h"
#include "video/kan_pand.h"
static UINT8* pandora_spriteram;
static UINT8 pandora_region;
static bitmap_t *pandora_sprites_bitmap; /* bitmap to render sprites to, Pandora seems to be frame'buffered' */
static int pandora_clear_bitmap;
static int pandora_xoffset, pandora_yoffset;
void pandora_set_clear_bitmap(int clear)
typedef struct _kaneko_pandora_state kaneko_pandora_state;
struct _kaneko_pandora_state
{
pandora_clear_bitmap = clear;
const device_config *screen;
UINT8 * spriteram;
bitmap_t *sprites_bitmap; /* bitmap to render sprites to, Pandora seems to be frame'buffered' */
int clear_bitmap;
UINT8 region;
int xoffset, yoffset;
};
/*****************************************************************************
INLINE FUNCTIONS
*****************************************************************************/
INLINE kaneko_pandora_state *get_safe_token( const device_config *device )
{
assert(device != NULL);
assert(device->token != NULL);
assert(device->type == KANEKO_PANDORA);
return (kaneko_pandora_state *)device->token;
}
void pandora_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
INLINE const kaneko_pandora_interface *get_interface( const device_config *device )
{
if (!pandora_sprites_bitmap)
assert(device != NULL);
assert((device->type == KANEKO_PANDORA));
return (const kaneko_pandora_interface *) device->static_config;
}
/*****************************************************************************
IMPLEMENTATION
*****************************************************************************/
void pandora_set_clear_bitmap( const device_config *device, int clear )
{
kaneko_pandora_state *pandora = get_safe_token(device);
pandora->clear_bitmap = clear;
}
void pandora_update( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect )
{
kaneko_pandora_state *pandora = get_safe_token(device);
if (!pandora->sprites_bitmap)
{
printf("ERROR: pandora_update with no pandora_sprites_bitmap\n");
return;
}
copybitmap_trans(bitmap,pandora_sprites_bitmap,0,0,0,0,cliprect,0);
copybitmap_trans(bitmap, pandora->sprites_bitmap, 0, 0, 0, 0, cliprect, 0);
}
static void pandora_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void pandora_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect )
{
int sx=0, sy=0, x=0, y=0, offs;
kaneko_pandora_state *pandora = get_safe_token(device);
int sx = 0, sy = 0, x = 0, y = 0, offs;
/*
@ -95,18 +130,20 @@ static void pandora_draw(running_machine *machine, bitmap_t *bitmap, const recta
* 7 | .x...... | Flip Sprite X-Axis
*/
for (offs = 0;offs < 0x1000;offs += 8)
for (offs = 0; offs < 0x1000; offs += 8)
{
int dx = pandora_spriteram[offs+4];
int dy = pandora_spriteram[offs+5];
int tilecolour = pandora_spriteram[offs+3];
int attr = pandora_spriteram[offs+7];
int dx = pandora->spriteram[offs + 4];
int dy = pandora->spriteram[offs + 5];
int tilecolour = pandora->spriteram[offs + 3];
int attr = pandora->spriteram[offs + 7];
int flipx = attr & 0x80;
int flipy = (attr & 0x40) << 1;
int tile = ((attr & 0x3f) << 8) + (pandora_spriteram[offs+6] & 0xff);
int tile = ((attr & 0x3f) << 8) + (pandora->spriteram[offs + 6] & 0xff);
if (tilecolour & 1) dx |= 0x100;
if (tilecolour & 2) dy |= 0x100;
if (tilecolour & 1)
dx |= 0x100;
if (tilecolour & 2)
dy |= 0x100;
if (tilecolour & 4)
{
@ -119,7 +156,7 @@ static void pandora_draw(running_machine *machine, bitmap_t *bitmap, const recta
y = dy;
}
if (flip_screen_get(machine))
if (flip_screen_get(device->machine))
{
sx = 240 - x;
sy = 240 - y;
@ -133,16 +170,18 @@ static void pandora_draw(running_machine *machine, bitmap_t *bitmap, const recta
}
/* global offset */
sx+=pandora_xoffset;
sy+=pandora_yoffset;
sx += pandora->xoffset;
sy += pandora->yoffset;
sx &=0x1ff;
sy &=0x1ff;
sx &= 0x1ff;
sy &= 0x1ff;
if (sx&0x100) sx-=0x200;
if (sy&0x100) sy-=0x200;
if (sx & 0x100)
sx -= 0x200;
if (sy & 0x100)
sy -= 0x200;
drawgfx_transpen(bitmap,cliprect,machine->gfx[pandora_region],
drawgfx_transpen(bitmap,cliprect,device->machine->gfx[pandora->region],
tile,
(tilecolour & 0xf0) >> 4,
flipx, flipy,
@ -150,100 +189,140 @@ static void pandora_draw(running_machine *machine, bitmap_t *bitmap, const recta
}
}
void pandora_eof(running_machine *machine)
void pandora_eof( const device_config *device )
{
assert(pandora_spriteram != NULL);
kaneko_pandora_state *pandora = get_safe_token(device);
assert(pandora->spriteram != NULL);
// the games can disable the clearing of the sprite bitmap, to leave sprite trails
if (pandora_clear_bitmap) bitmap_fill(pandora_sprites_bitmap,video_screen_get_visible_area(machine->primary_screen),0);
if (pandora->clear_bitmap)
bitmap_fill(pandora->sprites_bitmap, video_screen_get_visible_area(pandora->screen), 0);
pandora_draw(machine, pandora_sprites_bitmap, video_screen_get_visible_area(machine->primary_screen));
pandora_draw(device, pandora->sprites_bitmap, video_screen_get_visible_area(pandora->screen));
}
void pandora_start(running_machine *machine, UINT8 region, int x, int y)
/*****************************************************************************
DEVICE HANDLERS
*****************************************************************************/
WRITE8_DEVICE_HANDLER ( pandora_spriteram_w )
{
pandora_region = region;
pandora_xoffset = x;
pandora_yoffset = y;
pandora_spriteram = auto_alloc_array(machine, UINT8, 0x1000);
memset(pandora_spriteram,0x00, 0x1000);
kaneko_pandora_state *pandora = get_safe_token(device);
pandora_sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
pandora_clear_bitmap = 1;
state_save_register_global(machine, pandora_clear_bitmap);
state_save_register_global_pointer(machine, pandora_spriteram, 0x1000);
state_save_register_global_bitmap(machine, pandora_sprites_bitmap);
}
WRITE8_HANDLER ( pandora_spriteram_w )
{
// it's either hooked up oddly on this, or on the 16-bit games
// either way, we swap the address lines so that the spriteram is in the same format
offset = BITSWAP16(offset, 15,14,13,12, 11, 7,6,5,4,3,2,1,0, 10,9,8 );
if (!pandora_spriteram)
if (!pandora->spriteram)
{
printf("ERROR: pandora_spriteram_w with no pandora_spriteram\n");
printf("ERROR: pandora->spriteram_w with no pandora_spriteram\n");
return;
}
if (offset>=0x1000)
if (offset >= 0x1000)
{
logerror("pandora_spriteram_w write past spriteram, offset %04x %02x\n",offset,data);
logerror("pandora->spriteram_w write past spriteram, offset %04x %02x\n", offset, data);
return;
}
pandora_spriteram[offset] = data;
pandora->spriteram[offset] = data;
}
READ8_HANDLER( pandora_spriteram_r )
READ8_DEVICE_HANDLER( pandora_spriteram_r )
{
kaneko_pandora_state *pandora = get_safe_token(device);
// it's either hooked up oddly on this, or ont the 16-bit games
// either way, we swap the address lines so that the spriteram is in the same format
offset = BITSWAP16(offset, 15,14,13,12, 11, 7,6,5,4,3,2,1,0, 10,9,8 );
if (!pandora_spriteram)
if (!pandora->spriteram)
{
printf("ERROR: pandora_spriteram_r with no pandora_spriteram\n");
printf("ERROR: pandora->spriteram_r with no pandora_spriteram\n");
return 0x00;
}
if (offset>=0x1000)
if (offset >= 0x1000)
{
logerror("pandora_spriteram_r read past spriteram, offset %04x\n",offset );
logerror("pandora->spriteram_r read past spriteram, offset %04x\n", offset);
return 0x00;
}
return pandora_spriteram[offset];
return pandora->spriteram[offset];
}
/* I don't know if this MSB/LSB mirroring is correct, or if there is twice as much ram, with half of it unused */
WRITE16_HANDLER( pandora_spriteram_LSB_w )
WRITE16_DEVICE_HANDLER( pandora_spriteram_LSB_w )
{
if (!pandora_spriteram)
kaneko_pandora_state *pandora = get_safe_token(device);
if (!pandora->spriteram)
{
printf("ERROR: pandora_spriteram_LSB_w with no pandora_spriteram\n");
printf("ERROR: pandora->spriteram_LSB_w with no pandora_spriteram\n");
return;
}
if (ACCESSING_BITS_8_15)
{
pandora_spriteram[offset] = (data>>8)&0xff;
pandora->spriteram[offset] = (data >> 8) & 0xff;
}
if (ACCESSING_BITS_0_7)
{
pandora_spriteram[offset] = data&0xff;
pandora->spriteram[offset] = data & 0xff;
}
}
READ16_HANDLER( pandora_spriteram_LSB_r )
READ16_DEVICE_HANDLER( pandora_spriteram_LSB_r )
{
if (!pandora_spriteram)
kaneko_pandora_state *pandora = get_safe_token(device);
if (!pandora->spriteram)
{
printf("ERROR: pandora_spriteram_LSB_r with no pandora_spriteram\n");
return 0x0000;
}
return pandora_spriteram[offset]|(pandora_spriteram[offset]<<8);
return pandora->spriteram[offset] | (pandora->spriteram[offset] << 8);
}
/*****************************************************************************
DEVICE INTERFACE
*****************************************************************************/
static DEVICE_START( kaneko_pandora )
{
kaneko_pandora_state *pandora = get_safe_token(device);
const kaneko_pandora_interface *intf = get_interface(device);
pandora->screen = devtag_get_device(device->machine, intf->screen);
pandora->region = intf->gfx_region;
pandora->xoffset = intf->x;
pandora->yoffset = intf->y;
pandora->spriteram = auto_alloc_array(device->machine, UINT8, 0x1000);
pandora->sprites_bitmap = video_screen_auto_bitmap_alloc(pandora->screen);
state_save_register_device_item(device, 0, pandora->clear_bitmap);
state_save_register_device_item_pointer(device, 0, pandora->spriteram, 0x1000);
state_save_register_device_item_bitmap(device, 0, pandora->sprites_bitmap);
}
static DEVICE_RESET( kaneko_pandora )
{
kaneko_pandora_state *pandora = get_safe_token(device);
memset(pandora->spriteram, 0x00, 0x1000);
pandora->clear_bitmap = 1;
}
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
#define DEVTEMPLATE_ID( p, s ) p##kaneko_pandora##s
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
#define DEVTEMPLATE_NAME "Kaneko Pandora - PX79C480FP-3"
#define DEVTEMPLATE_FAMILY "Kaneko Video Chips"
#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO
#include "devtempl.h"

View File

@ -1,11 +1,60 @@
/* kan_pand.h */
/*************************************************************************
void pandora_start(running_machine *machine, UINT8 region, int x, int y);
void pandora_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect);
void pandora_eof(running_machine *machine);
void pandora_set_clear_bitmap(int clear);
kan_pand.h
Implementation of Kaneko Pandora sprite chip
**************************************************************************/
#ifndef __KAN_PAND_H__
#define __KAN_PAND_H__
#include "devcb.h"
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
typedef struct _kaneko_pandora_interface kaneko_pandora_interface;
struct _kaneko_pandora_interface
{
const char *screen;
UINT8 gfx_region;
int x;
int y;
};
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
DEVICE_GET_INFO( kaneko_pandora );
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define KANEKO_PANDORA DEVICE_GET_INFO_NAME( kaneko_pandora )
#define MDRV_KANEKO_PANDORA_ADD(_tag, _interface) \
MDRV_DEVICE_ADD(_tag, KANEKO_PANDORA, 0) \
MDRV_DEVICE_CONFIG(_interface)
/***************************************************************************
DEVICE I/O FUNCTIONS
***************************************************************************/
void pandora_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
void pandora_eof(const device_config *device);
void pandora_set_clear_bitmap(const device_config *device, int clear);
WRITE8_DEVICE_HANDLER ( pandora_spriteram_w );
READ8_DEVICE_HANDLER( pandora_spriteram_r );
WRITE16_DEVICE_HANDLER( pandora_spriteram_LSB_w );
READ16_DEVICE_HANDLER( pandora_spriteram_LSB_r );
#endif /* __KAN_PAND_H__ */
WRITE8_HANDLER ( pandora_spriteram_w );
READ8_HANDLER( pandora_spriteram_r );
WRITE16_HANDLER( pandora_spriteram_LSB_w );
READ16_HANDLER( pandora_spriteram_LSB_r );

View File

@ -235,7 +235,6 @@ VIDEO_START( kaneko16_2xVIEW2 )
VIDEO_START( sandscrp_1xVIEW2 )
{
VIDEO_START_CALL(kaneko16_1xVIEW2);
pandora_start(machine,0,0,0);
tilemap_set_scrolldy( kaneko16_tmap_0, 0, 256 - 1 );
tilemap_set_scrolldy( kaneko16_tmap_1, 0, 256 - 1 );
@ -1122,6 +1121,7 @@ VIDEO_UPDATE( galsnew )
VIDEO_UPDATE( sandscrp )
{
const device_config *pandora = devtag_get_device(screen->machine, "pandora");
kaneko16_fill_bitmap(screen->machine,bitmap,cliprect);
// if the display is disabled, do nothing?
@ -1130,7 +1130,7 @@ VIDEO_UPDATE( sandscrp )
VIDEO_UPDATE_CALL(common);
// copy sprite bitmap to screen
pandora_update(screen->machine,bitmap,cliprect);
pandora_update(pandora, bitmap, cliprect);
return 0;
}