Added save states to astrocorp.c. Also updated the driver to use EEPROM device.

Converted groundfx.c to use EEPROM device.

The latter was mainly a test for the eepromdev_bit_r PORT_CUSTOM introduced in svn7301. It seems to works perfectly fine.
This commit is contained in:
Fabio Priuli 2009-11-23 13:27:34 +00:00
parent 7b1aa92c4d
commit 0502582bfe
2 changed files with 104 additions and 86 deletions

View File

@ -13,9 +13,24 @@ OTHER: ASTRO 0001B, EEPROM
#include "driver.h" #include "driver.h"
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "machine/eeprom.h" #include "machine/eepromdev.h"
#include "sound/okim6295.h" #include "sound/okim6295.h"
typedef struct _astrocrp_state astrocrp_state;
struct _astrocrp_state
{
/* memory pointers */
UINT16 * spriteram16;
UINT16 * paletteram16;
/* video-related */
UINT16 screen_enable;
/* devices */
const device_config *eeprom;
};
/*************************************************************************** /***************************************************************************
Sprites Format Sprites Format
@ -34,22 +49,23 @@ OTHER: ASTRO 0001B, EEPROM
***************************************************************************/ ***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
{ {
UINT16 *source = spriteram16; astrocrp_state *state = (astrocrp_state *)machine->driver_data;
UINT16 *finish = spriteram16 + spriteram_size/2; UINT16 *source = state->spriteram16;
UINT16 *finish = state->spriteram16 + spriteram_size / 2;
for ( ; source < finish; source += 8/2 ) for ( ; source < finish; source += 8 / 2 )
{ {
int x,y; int x, y;
int sx = source[ 0x0/2 ]; int sx = source[ 0x0/2 ];
int code = source[ 0x2/2 ]; int code = source[ 0x2/2 ];
int sy = source[ 0x4/2 ]; int sy = source[ 0x4/2 ];
int attr = source[ 0x6/2 ]; int attr = source[ 0x6/2 ];
int dimx = (attr >> 8) & 0xff; int dimx = (attr >> 8) & 0xff;
int dimy = (attr >> 0) & 0xff; int dimy = (attr >> 0) & 0xff;
if (!dimx && !dimy) if (!dimx && !dimy)
return; return;
@ -73,17 +89,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
} }
} }
static UINT16 astrocorp_screen_enable;
static VIDEO_UPDATE(astrocorp) static VIDEO_UPDATE(astrocorp)
{ {
if (astrocorp_screen_enable & 1) astrocrp_state *state = (astrocrp_state *)screen->machine->driver_data;
if (state->screen_enable & 1)
{ {
bitmap_fill(bitmap,cliprect,screen->machine->pens[0xff]); bitmap_fill(bitmap,cliprect,screen->machine->pens[0xff]);
draw_sprites(screen->machine,bitmap,cliprect); draw_sprites(screen->machine, bitmap, cliprect);
} }
else else
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
return 0; return 0;
} }
@ -95,21 +111,25 @@ static VIDEO_UPDATE(astrocorp)
static READ16_HANDLER( astrocorp_eeprom_r ) static READ16_HANDLER( astrocorp_eeprom_r )
{ {
return 0xfff7 | (eeprom_read_bit() << 3); astrocrp_state *state = (astrocrp_state *)space->machine->driver_data;
return 0xfff7 | (eepromdev_read_bit(state->eeprom) << 3);
} }
static WRITE16_HANDLER( astrocorp_eeprom_w ) static WRITE16_HANDLER( astrocorp_eeprom_w )
{ {
astrocrp_state *state = (astrocrp_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
// latch the bit // latch the bit
eeprom_write_bit(data & 0x01); eepromdev_write_bit(state->eeprom, data & 0x01);
// reset line asserted: reset. // reset line asserted: reset.
eeprom_set_cs_line((data & 0x04) ? CLEAR_LINE : ASSERT_LINE ); eepromdev_set_cs_line(state->eeprom, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
// clock line asserted: write latch or select next bit to read // clock line asserted: write latch or select next bit to read
eeprom_set_clock_line((data & 0x02) ? ASSERT_LINE : CLEAR_LINE ); eepromdev_set_clock_line(state->eeprom, (data & 0x02) ? ASSERT_LINE : CLEAR_LINE);
} }
} }
@ -117,8 +137,8 @@ static WRITE16_DEVICE_HANDLER( astrocorp_sound_bank_w )
{ {
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
{ {
okim6295_set_bank_base(device, 0x40000 * ((data >> 8) & 1) ); okim6295_set_bank_base(device, 0x40000 * ((data >> 8) & 1));
// logerror("CPU #0 PC %06X: OKI bank %08X\n",cpu_get_pc(space->cpu),data); // logerror("CPU #0 PC %06X: OKI bank %08X\n", cpu_get_pc(space->cpu), data);
} }
} }
@ -128,7 +148,7 @@ static WRITE16_HANDLER( astrocorp_outputs_w )
{ {
coin_counter_w(0, (data & 0x0004)); // coin counter coin_counter_w(0, (data & 0x0004)); // coin counter
set_led_status(0, (data & 0x0008)); // you win set_led_status(0, (data & 0x0008)); // you win
if ( (data & 0x0010)) dispensed_tickets++; // coin out if ((data & 0x0010)) dispensed_tickets++; // coin out
set_led_status(1, (data & 0x0020)); // coin/hopper jam set_led_status(1, (data & 0x0020)); // coin/hopper jam
} }
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
@ -144,10 +164,11 @@ static WRITE16_HANDLER( astrocorp_outputs_w )
static WRITE16_HANDLER( astrocorp_enable_w ) static WRITE16_HANDLER( astrocorp_enable_w )
{ {
COMBINE_DATA( &astrocorp_screen_enable ); astrocrp_state *state = (astrocrp_state *)space->machine->driver_data;
COMBINE_DATA(&state->screen_enable);
// popmessage("%04X",data); // popmessage("%04X",data);
if (data & (~1)) if (data & (~1))
logerror("CPU #0 PC %06X: screen enable = %04X\n",cpu_get_pc(space->cpu),data); logerror("CPU #0 PC %06X: screen enable = %04X\n", cpu_get_pc(space->cpu), data);
} }
static READ16_HANDLER( astrocorp_unk_r ) static READ16_HANDLER( astrocorp_unk_r )
@ -158,42 +179,43 @@ static READ16_HANDLER( astrocorp_unk_r )
// 5-6-5 Palette: BBBBB-GGGGGG-RRRRR // 5-6-5 Palette: BBBBB-GGGGGG-RRRRR
static WRITE16_HANDLER( astrocorp_palette_w ) static WRITE16_HANDLER( astrocorp_palette_w )
{ {
COMBINE_DATA( &paletteram16[offset] ); astrocrp_state *state = (astrocrp_state *)space->machine->driver_data;
palette_set_color_rgb( space->machine, offset, COMBINE_DATA(&state->paletteram16[offset]);
pal5bit((paletteram16[offset] >> 0) & 0x1f), palette_set_color_rgb(space->machine, offset,
pal6bit((paletteram16[offset] >> 5) & 0x3f), pal5bit((state->paletteram16[offset] >> 0) & 0x1f),
pal5bit((paletteram16[offset] >> 11) & 0x1f) pal6bit((state->paletteram16[offset] >> 5) & 0x3f),
pal5bit((state->paletteram16[offset] >> 11) & 0x1f)
); );
} }
static ADDRESS_MAP_START( showhand_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( showhand_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE( 0x000000, 0x01ffff ) AM_ROM AM_RANGE( 0x000000, 0x01ffff ) AM_ROM
AM_RANGE( 0x050000, 0x050fff ) AM_RAM AM_BASE( &spriteram16 ) AM_SIZE( &spriteram_size ) AM_RANGE( 0x050000, 0x050fff ) AM_RAM AM_BASE_MEMBER(astrocrp_state, spriteram16) AM_SIZE(&spriteram_size)
AM_RANGE( 0x052000, 0x052001 ) AM_WRITENOP AM_RANGE( 0x052000, 0x052001 ) AM_WRITENOP
AM_RANGE( 0x054000, 0x054001 ) AM_READ_PORT( "INPUTS" ) AM_RANGE( 0x054000, 0x054001 ) AM_READ_PORT("INPUTS")
AM_RANGE( 0x058000, 0x058001 ) AM_WRITE( astrocorp_eeprom_w ) AM_RANGE( 0x058000, 0x058001 ) AM_WRITE(astrocorp_eeprom_w)
AM_RANGE( 0x05a000, 0x05a001 ) AM_WRITE( astrocorp_outputs_w ) AM_RANGE( 0x05a000, 0x05a001 ) AM_WRITE(astrocorp_outputs_w)
AM_RANGE( 0x05e000, 0x05e001 ) AM_READ( astrocorp_eeprom_r ) AM_RANGE( 0x05e000, 0x05e001 ) AM_READ(astrocorp_eeprom_r)
AM_RANGE( 0x060000, 0x0601ff ) AM_RAM_WRITE( astrocorp_palette_w ) AM_BASE( &paletteram16 ) AM_RANGE( 0x060000, 0x0601ff ) AM_RAM_WRITE(astrocorp_palette_w) AM_BASE_MEMBER(astrocrp_state, paletteram16)
AM_RANGE( 0x070000, 0x073fff ) AM_RAM AM_RANGE( 0x070000, 0x073fff ) AM_RAM
AM_RANGE( 0x080000, 0x080001 ) AM_DEVWRITE( "oki", astrocorp_sound_bank_w ) AM_RANGE( 0x080000, 0x080001 ) AM_DEVWRITE("oki", astrocorp_sound_bank_w)
AM_RANGE( 0x0a0000, 0x0a0001 ) AM_WRITE( astrocorp_enable_w ) AM_RANGE( 0x0a0000, 0x0a0001 ) AM_WRITE(astrocorp_enable_w)
AM_RANGE( 0x0d0000, 0x0d0001 ) AM_READ( astrocorp_unk_r ) AM_DEVWRITE8( "oki", okim6295_w, 0xff00 ) AM_RANGE( 0x0d0000, 0x0d0001 ) AM_READ(astrocorp_unk_r) AM_DEVWRITE8("oki", okim6295_w, 0xff00)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( showhanc_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( showhanc_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE( 0x000000, 0x01ffff ) AM_ROM AM_RANGE( 0x000000, 0x01ffff ) AM_ROM
AM_RANGE( 0x060000, 0x0601ff ) AM_RAM_WRITE( astrocorp_palette_w ) AM_BASE( &paletteram16 ) AM_RANGE( 0x060000, 0x0601ff ) AM_RAM_WRITE(astrocorp_palette_w) AM_BASE_MEMBER(astrocrp_state, paletteram16)
AM_RANGE( 0x070000, 0x070001 ) AM_DEVWRITE( "oki", astrocorp_sound_bank_w ) AM_RANGE( 0x070000, 0x070001 ) AM_DEVWRITE("oki", astrocorp_sound_bank_w)
AM_RANGE( 0x080000, 0x080fff ) AM_RAM AM_BASE( &spriteram16 ) AM_SIZE( &spriteram_size ) AM_RANGE( 0x080000, 0x080fff ) AM_RAM AM_BASE_MEMBER(astrocrp_state, spriteram16) AM_SIZE(&spriteram_size)
AM_RANGE( 0x082000, 0x082001 ) AM_WRITENOP AM_RANGE( 0x082000, 0x082001 ) AM_WRITENOP
AM_RANGE( 0x084000, 0x084001 ) AM_READ_PORT( "INPUTS" ) AM_RANGE( 0x084000, 0x084001 ) AM_READ_PORT("INPUTS")
AM_RANGE( 0x088000, 0x088001 ) AM_WRITE( astrocorp_eeprom_w ) AM_RANGE( 0x088000, 0x088001 ) AM_WRITE(astrocorp_eeprom_w)
AM_RANGE( 0x08a000, 0x08a001 ) AM_WRITE( astrocorp_outputs_w ) AM_RANGE( 0x08a000, 0x08a001 ) AM_WRITE(astrocorp_outputs_w)
AM_RANGE( 0x08e000, 0x08e001 ) AM_READ( astrocorp_eeprom_r ) AM_RANGE( 0x08e000, 0x08e001 ) AM_READ(astrocorp_eeprom_r)
AM_RANGE( 0x090000, 0x093fff ) AM_RAM AM_RANGE( 0x090000, 0x093fff ) AM_RAM
AM_RANGE( 0x0a0000, 0x0a0001 ) AM_WRITE( astrocorp_enable_w ) AM_RANGE( 0x0a0000, 0x0a0001 ) AM_WRITE(astrocorp_enable_w)
AM_RANGE( 0x0e0000, 0x0e0001 ) AM_READ( astrocorp_unk_r ) AM_DEVWRITE8( "oki", okim6295_w, 0xff00 ) AM_RANGE( 0x0e0000, 0x0e0001 ) AM_READ(astrocorp_unk_r) AM_DEVWRITE8("oki", okim6295_w, 0xff00)
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************************************************** /***************************************************************************
@ -264,32 +286,39 @@ GFXDECODE_END
Machine Drivers Machine Drivers
***************************************************************************/ ***************************************************************************/
static const UINT16 showhand_default_eeprom[] = {0x0001,0x0007,0x000a,0x0003,0x0000,0x0009,0x0003,0x0000,0x0002,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000}; static MACHINE_START( showhand )
static NVRAM_HANDLER( showhand )
{ {
if (read_or_write) astrocrp_state *state = (astrocrp_state *)machine->driver_data;
eeprom_save(file);
else
{
eeprom_init(machine, &eeprom_interface_93C46);
if (file) eeprom_load(file); state->eeprom = devtag_get_device(machine, "eeprom");
else
{ state_save_register_global(machine, state->screen_enable);
/* Set the EEPROM to Factory Defaults */
eeprom_set_data((UINT8*)showhand_default_eeprom,sizeof(showhand_default_eeprom));
}
}
} }
static MACHINE_RESET( showhand )
{
astrocrp_state *state = (astrocrp_state *)machine->driver_data;
state->screen_enable = 0;
}
static const UINT16 showhand_default_eeprom[0x0f] = {0x0001,0x0007,0x000a,0x0003,0x0000,0x0009,0x0003,0x0000,0x0002,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000};
static MACHINE_DRIVER_START( showhand ) static MACHINE_DRIVER_START( showhand )
/* driver data */
MDRV_DRIVER_DATA(astrocrp_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) MDRV_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
MDRV_CPU_PROGRAM_MAP(showhand_map) MDRV_CPU_PROGRAM_MAP(showhand_map)
MDRV_CPU_VBLANK_INT("screen", irq4_line_hold) MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
MDRV_NVRAM_HANDLER(showhand) MDRV_MACHINE_START(showhand)
MDRV_MACHINE_RESET(showhand)
MDRV_EEPROM_93C46_ADD("eeprom", sizeof(showhand_default_eeprom), showhand_default_eeprom)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
@ -444,5 +473,5 @@ static DRIVER_INIT( showhanc )
#endif #endif
} }
GAME( 1999?, showhand, 0, showhand, showhand, showhand, ROT0, "Astro Corp.", "Show Hand (Italy)", 0 ) GAME( 1999?, showhand, 0, showhand, showhand, showhand, ROT0, "Astro Corp.", "Show Hand (Italy)", GAME_SUPPORTS_SAVE )
GAME( 1999?, showhanc, showhand, showhanc, showhanc, showhanc, ROT0, "Astro Corp.", "Wang Pai Dui Jue", 0 ) GAME( 1999?, showhanc, showhand, showhanc, showhanc, showhanc, ROT0, "Astro Corp.", "Wang Pai Dui Jue", GAME_SUPPORTS_SAVE )

View File

@ -65,7 +65,7 @@
#include "driver.h" #include "driver.h"
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "video/taitoic.h" #include "video/taitoic.h"
#include "machine/eeprom.h" #include "machine/eepromdev.h"
#include "sound/es5506.h" #include "sound/es5506.h"
#include "includes/taito_f3.h" #include "includes/taito_f3.h"
#include "audio/taito_en.h" #include "audio/taito_en.h"
@ -138,19 +138,6 @@ static const eeprom_interface groundfx_eeprom_interface =
"0100110000", /* lock command */ "0100110000", /* lock command */
}; };
static NVRAM_HANDLER( groundfx )
{
if (read_or_write)
eeprom_save(file);
else {
eeprom_init(machine, &groundfx_eeprom_interface);
if (file)
eeprom_load(file);
else
eeprom_set_data(default_eeprom,128); /* Default the gun setup values */
}
}
/********************************************************** /**********************************************************
GAME INPUTS GAME INPUTS
@ -168,6 +155,7 @@ static CUSTOM_INPUT( coin_word_r )
static WRITE32_HANDLER( groundfx_input_w ) static WRITE32_HANDLER( groundfx_input_w )
{ {
const device_config *eeprom = devtag_get_device(space->machine, "eeprom");
switch (offset) switch (offset)
{ {
case 0x00: case 0x00:
@ -179,9 +167,9 @@ static WRITE32_HANDLER( groundfx_input_w )
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
eeprom_set_clock_line((data & 0x20) ? ASSERT_LINE : CLEAR_LINE); eepromdev_set_clock_line(eeprom, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
eeprom_write_bit(data & 0x40); eepromdev_write_bit(eeprom, data & 0x40);
eeprom_set_cs_line((data & 0x10) ? CLEAR_LINE : ASSERT_LINE); eepromdev_set_cs_line(eeprom, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
return; return;
} }
@ -283,7 +271,7 @@ static INPUT_PORTS_START( groundfx )
PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL) PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eepromdev_bit_r, "eeprom")
PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_BUTTON3 ) /* shift hi */ PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_BUTTON3 ) /* shift hi */
PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_BUTTON1 ) /* brake */ PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_BUTTON1 ) /* brake */
PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNUSED )
@ -389,7 +377,8 @@ static MACHINE_DRIVER_START( groundfx )
TAITO_F3_SOUND_SYSTEM_CPU(16000000) TAITO_F3_SOUND_SYSTEM_CPU(16000000)
MDRV_MACHINE_RESET(groundfx) MDRV_MACHINE_RESET(groundfx)
MDRV_NVRAM_HANDLER(groundfx) // MDRV_NVRAM_HANDLER(groundfx)
MDRV_EEPROM_ADD("eeprom", groundfx_eeprom_interface, 128, default_eeprom)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)