mirror of
https://github.com/holub/mame
synced 2025-05-28 16:43:04 +03:00
Converted darkhors to eeprom device. Also trimmed obvious overdump of
EEPROM data. Updated EEPROM device to initialize EEPROM at NVRAM load time rather than init time, giving DEVICE_INIT handlers a chance to muck with the data first.
This commit is contained in:
parent
be3aa6f941
commit
aee2295323
@ -358,15 +358,61 @@ static DEVICE_NVRAM( eeprom )
|
||||
mame_fwrite(file, eestate->data, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
|
||||
else if (file != NULL)
|
||||
mame_fread(file, eestate->data, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
|
||||
else
|
||||
{
|
||||
const eeprom_config *config = (const eeprom_config *)device->inline_config;
|
||||
UINT16 default_value = 0xffff;
|
||||
int offs;
|
||||
|
||||
/* initialize to the default value */
|
||||
if (config->default_value != 0)
|
||||
default_value = config->default_value;
|
||||
for (offs = 0; offs < (1 << eestate->intf->address_bits); offs++)
|
||||
if (eestate->intf->data_bits == 8)
|
||||
eestate->data[offs] = (UINT8)default_value;
|
||||
else
|
||||
{
|
||||
eestate->data[offs * 2 + 0] = default_value >> 8;
|
||||
eestate->data[offs * 2 + 1] = default_value & 0xff;
|
||||
}
|
||||
|
||||
/* handle hard-coded data from the driver */
|
||||
if (config->default_data != NULL)
|
||||
memcpy(eestate->data, config->default_data, config->default_data_size);
|
||||
|
||||
/* populate from a memory region if present */
|
||||
if (device->region != NULL)
|
||||
{
|
||||
UINT32 eeprom_length = (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8;
|
||||
UINT32 region_flags = memory_region_flags(device->machine, device->tag);
|
||||
|
||||
if (device->regionbytes != eeprom_length)
|
||||
fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", device->tag, eeprom_length);
|
||||
if (eestate->intf->data_bits == 8 && (region_flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT)
|
||||
fatalerror("eeprom region '%s' needs to be an 8-bit region", device->tag);
|
||||
if (eestate->intf->data_bits == 16 && ((region_flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (region_flags & ROMREGION_ENDIANMASK) != ROMREGION_BE))
|
||||
fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", device->tag, region_flags);
|
||||
|
||||
if (eestate->intf->data_bits == 8)
|
||||
memcpy(eestate->data, device->region, eeprom_length);
|
||||
else
|
||||
{
|
||||
int offs;
|
||||
for (offs = 0; offs < eeprom_length; offs += 2)
|
||||
{
|
||||
UINT16 data = *(UINT16 *)&device->region[offs];
|
||||
eestate->data[offs + 0] = data >> 8;
|
||||
eestate->data[offs + 1] = data & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static DEVICE_START(eeprom)
|
||||
{
|
||||
eeprom_state *eestate = get_safe_token(device);
|
||||
const eeprom_config *config;
|
||||
UINT16 default_value;
|
||||
UINT8 *region_base;
|
||||
int offs;
|
||||
|
||||
/* validate some basic stuff */
|
||||
assert(device != NULL);
|
||||
@ -380,51 +426,6 @@ static DEVICE_START(eeprom)
|
||||
|
||||
if ((1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8 > MEMORY_SIZE)
|
||||
fatalerror("EEPROM larger than eepromdev.c allows");
|
||||
|
||||
/* initialize to the default value */
|
||||
default_value = 0xffff;
|
||||
if (config->default_value != 0)
|
||||
default_value = config->default_value;
|
||||
for (offs = 0; offs < (1 << eestate->intf->address_bits); offs++)
|
||||
if (eestate->intf->data_bits == 8)
|
||||
eestate->data[offs] = (UINT8)default_value;
|
||||
else
|
||||
{
|
||||
eestate->data[offs * 2 + 0] = default_value >> 8;
|
||||
eestate->data[offs * 2 + 1] = default_value & 0xff;
|
||||
}
|
||||
|
||||
/* handle hard-coded data from the driver */
|
||||
if (config->default_data != NULL)
|
||||
eepromdev_set_data(device, config->default_data, config->default_data_size);
|
||||
|
||||
/* populate from a memory region if present */
|
||||
region_base = memory_region(device->machine, device->tag);
|
||||
if (region_base != NULL)
|
||||
{
|
||||
UINT32 region_length = memory_region_length(device->machine, device->tag);
|
||||
UINT32 region_flags = memory_region_flags(device->machine, device->tag);
|
||||
|
||||
if (region_length != (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8)
|
||||
fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", device->tag, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
|
||||
if (eestate->intf->data_bits == 8 && (region_flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT)
|
||||
fatalerror("eeprom region '%s' needs to be an 8-bit region", device->tag);
|
||||
if (eestate->intf->data_bits == 16 && ((region_flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (region_flags & ROMREGION_ENDIANMASK) != ROMREGION_BE))
|
||||
fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", device->tag, region_flags);
|
||||
|
||||
if (eestate->intf->data_bits == 8)
|
||||
memcpy(eestate->data, region_base, region_length);
|
||||
else
|
||||
{
|
||||
int offs;
|
||||
for (offs = 0; offs < region_length; offs += 2)
|
||||
{
|
||||
UINT16 data = *(UINT16 *)®ion_base[offs];
|
||||
eestate->data[offs + 0] = data >> 8;
|
||||
eestate->data[offs + 1] = data & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eestate->serial_count = 0;
|
||||
eestate->latch = 0;
|
||||
|
@ -57,7 +57,7 @@ To do:
|
||||
#include "driver.h"
|
||||
#include "cpu/m68000/m68000.h"
|
||||
#include "deprecat.h"
|
||||
#include "machine/eeprom.h"
|
||||
#include "machine/eepromdev.h"
|
||||
#include "sound/okim6295.h"
|
||||
#include "sound/st0016.h"
|
||||
#include "includes/st0016.h"
|
||||
@ -217,38 +217,21 @@ static const eeprom_interface eeprom_intf =
|
||||
// "*10010xxxx" // erase all 1 00 10xxxx
|
||||
};
|
||||
|
||||
static NVRAM_HANDLER( darkhors )
|
||||
{
|
||||
if (read_or_write)
|
||||
eeprom_save(file);
|
||||
else
|
||||
{
|
||||
eeprom_init(machine, &eeprom_intf);
|
||||
|
||||
if (file) eeprom_load(file);
|
||||
else
|
||||
{
|
||||
// Set the EEPROM to Factory Defaults
|
||||
eeprom_set_data(memory_region(machine, "user1"),(1<<7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER( darkhors_eeprom_w )
|
||||
static WRITE32_DEVICE_HANDLER( darkhors_eeprom_w )
|
||||
{
|
||||
if (data & ~0xff000000)
|
||||
logerror("CPU #0 PC: %06X - Unknown EEPROM bit written %08X\n",cpu_get_pc(space->cpu),data);
|
||||
logerror("%s: Unknown EEPROM bit written %08X\n",cpuexec_describe_context(device->machine),data);
|
||||
|
||||
if ( ACCESSING_BITS_24_31 )
|
||||
{
|
||||
// latch the bit
|
||||
eeprom_write_bit(data & 0x04000000);
|
||||
eepromdev_write_bit(device, data & 0x04000000);
|
||||
|
||||
// reset line asserted: reset.
|
||||
eeprom_set_cs_line((data & 0x01000000) ? CLEAR_LINE : ASSERT_LINE );
|
||||
eepromdev_set_cs_line(device, (data & 0x01000000) ? CLEAR_LINE : ASSERT_LINE );
|
||||
|
||||
// clock line asserted: write latch or select next bit to read
|
||||
eeprom_set_clock_line((data & 0x02000000) ? ASSERT_LINE : CLEAR_LINE );
|
||||
eepromdev_set_clock_line(device, (data & 0x02000000) ? ASSERT_LINE : CLEAR_LINE );
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +285,7 @@ static ADDRESS_MAP_START( darkhors_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0x000000, 0x0fffff) AM_ROM
|
||||
AM_RANGE(0x400000, 0x41ffff) AM_RAM
|
||||
|
||||
AM_RANGE(0x490040, 0x490043) AM_WRITE(darkhors_eeprom_w)
|
||||
AM_RANGE(0x490040, 0x490043) AM_DEVWRITE("eeprom", darkhors_eeprom_w)
|
||||
AM_RANGE(0x4e0080, 0x4e0083) AM_READ_PORT("4e0080") AM_WRITE(darkhors_unk1_w)
|
||||
|
||||
AM_RANGE(0x580000, 0x580003) AM_READ_PORT("580000")
|
||||
@ -339,7 +322,7 @@ static ADDRESS_MAP_START( jclub2_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0x000000, 0x1fffff) AM_ROM
|
||||
AM_RANGE(0x400000, 0x41ffff) AM_RAM
|
||||
|
||||
AM_RANGE(0x490040, 0x490043) AM_WRITE(darkhors_eeprom_w)
|
||||
AM_RANGE(0x490040, 0x490043) AM_DEVWRITE("eeprom", darkhors_eeprom_w)
|
||||
AM_RANGE(0x4e0080, 0x4e0083) AM_READ_PORT("4e0080") AM_WRITE(darkhors_unk1_w)
|
||||
|
||||
AM_RANGE(0x580000, 0x580003) AM_READ_PORT("580000")
|
||||
@ -414,7 +397,7 @@ static INPUT_PORTS_START( darkhors )
|
||||
PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1) // test
|
||||
PORT_BIT( 0x00200000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // door 1
|
||||
PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // door 2
|
||||
PORT_BIT( 0x00800000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
|
||||
PORT_BIT( 0x00800000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
|
||||
PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_START1 ) // start
|
||||
PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Payout") PORT_CODE(KEYCODE_LCONTROL) // payout
|
||||
PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Cancel") PORT_CODE(KEYCODE_LALT) // cancel
|
||||
@ -643,7 +626,7 @@ static MACHINE_DRIVER_START( darkhors )
|
||||
MDRV_CPU_PROGRAM_MAP(darkhors_map)
|
||||
MDRV_CPU_VBLANK_INT_HACK(darkhors,3)
|
||||
|
||||
MDRV_NVRAM_HANDLER(darkhors)
|
||||
MDRV_EEPROM_ADD("eeprom", eeprom_intf)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_SCREEN_ADD("screen", RASTER)
|
||||
@ -694,7 +677,7 @@ static MACHINE_DRIVER_START( jclub2 )
|
||||
MDRV_CPU_PROGRAM_MAP(jclub2_map)
|
||||
MDRV_CPU_VBLANK_INT_HACK(darkhors,3)
|
||||
|
||||
MDRV_NVRAM_HANDLER(darkhors)
|
||||
MDRV_EEPROM_ADD("eeprom", eeprom_intf)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_SCREEN_ADD("screen", RASTER)
|
||||
@ -755,7 +738,7 @@ static MACHINE_DRIVER_START( jclub2o )
|
||||
MDRV_CPU_PROGRAM_MAP(jclub2o_map)
|
||||
//MDRV_CPU_VBLANK_INT_HACK(darkhors,3)
|
||||
|
||||
MDRV_NVRAM_HANDLER(darkhors)
|
||||
MDRV_EEPROM_ADD("eeprom", eeprom_intf)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_SCREEN_ADD("screen", RASTER)
|
||||
@ -807,8 +790,8 @@ ROM_START( darkhors )
|
||||
ROM_REGION( 0x80000, "oki", 0 ) // Samples
|
||||
ROM_LOAD( "snd", 0x00000, 0x80000, CRC(7aeb12d3) SHA1(3e81725fc206baa7559da87552a0cd73b7616155) )
|
||||
|
||||
ROM_REGION( 0x80000, "user1", ROMREGION_BE ) // EEPROM
|
||||
ROM_LOAD( "eeprom", 0x00000, 0x80000, CRC(45314fdb) SHA1(c4bd5508e5b51a6e0356c049f1ccf2b5d94caee9) )
|
||||
ROM_REGION( 0x80, "eeprom", 0 ) // EEPROM
|
||||
ROM_LOAD( "eeprom", 0x0000, 0x0080, CRC(1f434f66) SHA1(e1bee11d83fb72aed9c312bdc794d8b9a6645534) )
|
||||
ROM_END
|
||||
|
||||
/*
|
||||
@ -876,8 +859,6 @@ ROM_START( jclub2 )
|
||||
// data distribution would indicate this is a sound rom
|
||||
ROM_LOAD( "m88-02.u6", 0x00000, 0x100000, CRC(0dd3436a) SHA1(809d3b7a26d36f71da04036fd8ab5d0c5089392a) )
|
||||
|
||||
ROM_REGION( 0x80000, "user1", ROMREGION_ERASEFF | ROMREGION_BE ) // EEPROM
|
||||
|
||||
ROM_REGION( 0x80000, "misc", ROMREGION_ERASEFF )
|
||||
ROM_LOAD( "gal16v8b-m88-03.bin", 0x000, 0x117, CRC(6d9c882e) SHA1(84cb95ab540290c2f8b740668360e9c643a67dcf) )
|
||||
ROM_LOAD( "gal16v8b-m88-04.bin", 0x000, 0x117, CRC(5e79f292) SHA1(5e44c234e2b15d486a1af71fee986892aa245b4d) )
|
||||
@ -928,8 +909,6 @@ ROM_START( jclub2o )
|
||||
ROM_REGION( 0x90000, "st0016", 0 ) // z80 core (used for sound?)
|
||||
ROM_LOAD( "sx006-04.u87", 0x10000, 0x80000, CRC(a87adedd) SHA1(1cd5af2d03738fff2230b46241659179467c828c) )
|
||||
ROM_COPY( "st0016", 0x10000, 0x00000, 0x08000 )
|
||||
|
||||
ROM_REGION( 0x80000, "user1", ROMREGION_ERASEFF | ROMREGION_BE ) // EEPROM
|
||||
ROM_END
|
||||
|
||||
/***************************************************************************
|
||||
@ -943,7 +922,7 @@ ROM_END
|
||||
static DRIVER_INIT( darkhors )
|
||||
{
|
||||
UINT32 *rom = (UINT32 *) memory_region(machine, "maincpu");
|
||||
UINT8 *eeprom = (UINT8 *) memory_region(machine, "user1");
|
||||
UINT8 *eeprom = (UINT8 *) memory_region(machine, "eeprom");
|
||||
int i;
|
||||
|
||||
#if 1
|
||||
@ -955,8 +934,9 @@ static DRIVER_INIT( darkhors )
|
||||
rom[0x04600/4] = 0x4e714eb9;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < (1<<7); i++)
|
||||
eeprom[i] = eeprom[i*2];
|
||||
if (eeprom != NULL)
|
||||
for (i = 0; i < (1<<7); i++)
|
||||
eeprom[i] = eeprom[i*2];
|
||||
}
|
||||
|
||||
GAME( 199?, jclub2, 0, jclub2, darkhors, 0, ROT0, "Seta", "Jockey Club II (newer hardware)", GAME_NOT_WORKING | GAME_NO_SOUND )
|
||||
|
Loading…
Reference in New Issue
Block a user