mirror of
https://github.com/holub/mame
synced 2025-05-21 21:29:15 +03:00
Added casting operators to the region_info class so you can assign
a region to a generic type pointer and have it automatically convert. Also added a bytes() method which is safe if the region is NULL (useful for saying machine->region("foo")->bytes() and not crashing if foo doesn't exist). Changed the region field in the device_config to be a region_info *, and removed the regionbytes field. Updated all users of these fields to use the new casting operators and bytes() methods instead. Added subdevice and subregion methods to the device_config class, so you can easily query for devices and regions that are device-specific. The device prefix ("devicename:") is automatically prepended.
This commit is contained in:
parent
51fd1fa822
commit
d35a800134
@ -81,6 +81,40 @@ INLINE int device_matches_type(const device_config *device, device_type type)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
subregion - return a pointer to the region
|
||||
info for a given region
|
||||
-------------------------------------------------*/
|
||||
|
||||
const region_info *device_config::subregion(const char *_tag) const
|
||||
{
|
||||
// safety first
|
||||
if (this == NULL)
|
||||
return NULL;
|
||||
|
||||
// build a fully-qualified name
|
||||
astring tempstring(tag, ":", _tag);
|
||||
return machine->region(tempstring);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
subdevice - return a pointer to the given
|
||||
device that is owned by us
|
||||
-------------------------------------------------*/
|
||||
|
||||
const device_config *device_config::subdevice(const char *_tag) const
|
||||
{
|
||||
// safety first
|
||||
if (this == NULL)
|
||||
return NULL;
|
||||
|
||||
// build a fully-qualified name
|
||||
astring tempstring(tag, ":", _tag);
|
||||
return machine->device(tempstring);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION
|
||||
@ -116,12 +150,50 @@ void device_list_deinit(device_list *devlist)
|
||||
end of a device list
|
||||
-------------------------------------------------*/
|
||||
|
||||
device_config::device_config(const device_config *_owner, device_type _type, const char *_tag, UINT32 _clock)
|
||||
: next(NULL),
|
||||
owner(const_cast<device_config *>(_owner)),
|
||||
typenext(NULL),
|
||||
classnext(NULL),
|
||||
tag(_tag),
|
||||
type(_type),
|
||||
devclass(static_cast<device_class>(devtype_get_info_int(_type, DEVINFO_INT_CLASS))),
|
||||
clock(_clock),
|
||||
static_config(NULL),
|
||||
inline_config(NULL),
|
||||
machine(NULL),
|
||||
started(DEVICE_STOPPED),
|
||||
token(NULL),
|
||||
tokenbytes(NULL),
|
||||
execute(NULL),
|
||||
region(NULL)
|
||||
{
|
||||
memset(address_map, 0, sizeof(address_map));
|
||||
memset(addrspace, 0, sizeof(addrspace));
|
||||
|
||||
if ((clock & 0xff000000) == 0xff000000)
|
||||
{
|
||||
assert(owner != NULL);
|
||||
clock = owner->clock * ((clock >> 12) & 0xfff) / ((clock >> 0) & 0xfff);
|
||||
}
|
||||
|
||||
/* populate device configuration */
|
||||
UINT32 configlen = (UINT32)devtype_get_info_int(_type, DEVINFO_INT_INLINE_CONFIG_BYTES);
|
||||
inline_config = (configlen == 0) ? NULL : global_alloc_array_clear(UINT8, configlen);
|
||||
}
|
||||
|
||||
|
||||
device_config::~device_config()
|
||||
{
|
||||
global_free(inline_config);
|
||||
}
|
||||
|
||||
|
||||
device_config *device_list_add(device_list *devlist, const device_config *owner, device_type type, const char *tag, UINT32 clock)
|
||||
{
|
||||
device_config **devptr, **tempdevptr;
|
||||
device_config *device, *tempdevice;
|
||||
tagmap_error tmerr;
|
||||
UINT32 configlen;
|
||||
|
||||
assert(devlist != NULL);
|
||||
assert(type != NULL);
|
||||
@ -131,7 +203,7 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
|
||||
for (devptr = &devlist->head; *devptr != NULL; devptr = &(*devptr)->next) ;
|
||||
|
||||
/* allocate a new device */
|
||||
device = global_alloc(device_config);
|
||||
device = global_alloc(device_config(owner, type, tag, clock));
|
||||
|
||||
/* add to the map */
|
||||
tmerr = devlist->map.add_unique_hash(tag, device, FALSE);
|
||||
@ -145,41 +217,6 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
|
||||
fatalerror("Two devices have tags which hash to the same value: '%s' and '%s'\n", tag, match->tag.cstr());
|
||||
}
|
||||
|
||||
/* populate device relationships */
|
||||
device->next = NULL;
|
||||
device->owner = (device_config *)owner;
|
||||
device->typenext = NULL;
|
||||
device->classnext = NULL;
|
||||
|
||||
/* populate device properties */
|
||||
device->type = type;
|
||||
device->devclass = (device_class)(INT32)devtype_get_info_int(type, DEVINFO_INT_CLASS);
|
||||
|
||||
/* populate device configuration */
|
||||
device->clock = clock;
|
||||
memset((void *)device->address_map, 0, sizeof(device->address_map));
|
||||
if ((device->clock & 0xff000000) == 0xff000000)
|
||||
{
|
||||
assert(device->owner != NULL);
|
||||
device->clock = device->owner->clock * ((device->clock >> 12) & 0xfff) / ((device->clock >> 0) & 0xfff);
|
||||
}
|
||||
device->static_config = NULL;
|
||||
configlen = (UINT32)devtype_get_info_int(type, DEVINFO_INT_INLINE_CONFIG_BYTES);
|
||||
device->inline_config = (configlen == 0) ? NULL : global_alloc_array_clear(UINT8, configlen);
|
||||
|
||||
/* ensure live fields are all cleared */
|
||||
device->machine = NULL;
|
||||
device->started = DEVICE_STOPPED;
|
||||
device->token = NULL;
|
||||
device->tokenbytes = 0;
|
||||
device->region = NULL;
|
||||
device->regionbytes = 0;
|
||||
memset((void *)device->addrspace, 0, sizeof(device->addrspace));
|
||||
device->execute = NULL;
|
||||
|
||||
/* append the tag */
|
||||
device->tag.cpy(tag);
|
||||
|
||||
/* fetch function pointers to the core functions */
|
||||
|
||||
/* before adding us to the global list, add us to the end of the type list */
|
||||
@ -238,8 +275,6 @@ void device_list_remove(device_list *devlist, const char *tag)
|
||||
devlist->map.remove(device->tag);
|
||||
|
||||
/* free the device object */
|
||||
if (device->inline_config != NULL)
|
||||
global_free(device->inline_config);
|
||||
global_free(device);
|
||||
}
|
||||
|
||||
@ -633,8 +668,7 @@ void device_list_start(running_machine *machine)
|
||||
device->token = auto_alloc_array_clear(machine, UINT8, device->tokenbytes);
|
||||
|
||||
/* fill in the remaining runtime fields */
|
||||
device->region = memory_region(machine, device->tag);
|
||||
device->regionbytes = memory_region_length(machine, device->tag);
|
||||
device->region = machine->region(device->tag);
|
||||
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
|
||||
device->addrspace[spacenum] = device->space(spacenum);
|
||||
device->execute = (device_execute_func)device_get_info_fct(device, DEVINFO_FCT_EXECUTE);
|
||||
@ -718,7 +752,6 @@ static void device_list_stop(running_machine *machine)
|
||||
device->tokenbytes = 0;
|
||||
device->machine = NULL;
|
||||
device->region = NULL;
|
||||
device->regionbytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,11 +305,24 @@ enum device_space
|
||||
AS_IO = 2
|
||||
};
|
||||
|
||||
class region_info;
|
||||
|
||||
class device_config
|
||||
{
|
||||
DISABLE_COPYING(device_config);
|
||||
|
||||
public: // private eventually
|
||||
const address_space * addrspace[ADDRESS_SPACES]; /* auto-discovered address spaces */
|
||||
|
||||
public:
|
||||
device_config(const device_config *owner, device_type type, const char *tag, UINT32 clock);
|
||||
~device_config();
|
||||
|
||||
inline const address_space *space(int index = 0) const;
|
||||
inline const address_space *space(device_space index) const;
|
||||
|
||||
const region_info *subregion(const char *tag) const;
|
||||
const device_config *subdevice(const char *tag) const;
|
||||
|
||||
/* device relationships (always valid) */
|
||||
device_config * next; /* next device (of any type/class) */
|
||||
@ -335,10 +348,8 @@ public:
|
||||
UINT8 started; /* TRUE if the start function has succeeded */
|
||||
void * token; /* token if device is live */
|
||||
UINT32 tokenbytes; /* size of the token data allocated */
|
||||
UINT8 * region; /* pointer to region with the device's tag, or NULL */
|
||||
UINT32 regionbytes; /* size of the region, in bytes */
|
||||
const address_space * addrspace[ADDRESS_SPACES]; /* auto-discovered address spaces */
|
||||
device_execute_func execute; /* quick pointer to execute callback */
|
||||
const region_info * region; /* our device-local region */
|
||||
};
|
||||
|
||||
|
||||
|
@ -78,9 +78,13 @@ class running_machine;
|
||||
union generic_ptr
|
||||
{
|
||||
void * v;
|
||||
INT8 * i8;
|
||||
UINT8 * u8;
|
||||
INT16 * i16;
|
||||
UINT16 * u16;
|
||||
INT32 * i32;
|
||||
UINT32 * u32;
|
||||
INT64 * i64;
|
||||
UINT64 * u64;
|
||||
};
|
||||
|
||||
|
@ -143,7 +143,7 @@ static DEVICE_START(at28c16)
|
||||
c->oe_12v = 0;
|
||||
c->last_write = -1;
|
||||
c->write_timer = timer_alloc(device->machine, write_finished, c );
|
||||
c->default_data = device->region;
|
||||
c->default_data = *device->region;
|
||||
|
||||
config = (const at28c16_config *)device->inline_config;
|
||||
if (config->id != NULL)
|
||||
|
@ -360,20 +360,18 @@ static DEVICE_NVRAM( eeprom )
|
||||
/* populate from a memory region if present */
|
||||
if (device->region != NULL)
|
||||
{
|
||||
UINT32 region_flags = memory_region_flags(device->machine, device->tag.cstr());
|
||||
|
||||
if (device->regionbytes != eeprom_bytes)
|
||||
if (device->region->length != eeprom_bytes)
|
||||
fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", device->tag.cstr(), eeprom_bytes);
|
||||
if (eestate->intf->data_bits == 8 && (region_flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT)
|
||||
if (eestate->intf->data_bits == 8 && (device->region->flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT)
|
||||
fatalerror("eeprom region '%s' needs to be an 8-bit region", device->tag.cstr());
|
||||
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.cstr(), region_flags);
|
||||
if (eestate->intf->data_bits == 16 && ((device->region->flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (device->region->flags & ROMREGION_ENDIANMASK) != ROMREGION_BE))
|
||||
fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", device->tag.cstr(), device->region->flags);
|
||||
|
||||
for (offs = 0; offs < eeprom_length; offs++)
|
||||
if (eestate->intf->data_bits == 8)
|
||||
memory_write_byte(device->space(), offs, device->region[offs]);
|
||||
memory_write_byte(device->space(), offs, device->region->base.u8[offs]);
|
||||
else
|
||||
memory_write_word(device->space(), offs * 2, ((UINT16 *)device->region)[offs]);
|
||||
memory_write_word(device->space(), offs * 2, device->region->base.u16[offs]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,8 @@ static void pr8210_init(laserdisc_state *ld)
|
||||
player->slowtrg = curtime;
|
||||
|
||||
/* find our CPU */
|
||||
player->cpu = ld->device->machine->device(device_build_tag(tempstring, ld->device, "pr8210"));
|
||||
player->cpu = ld->device->subdevice("pr8210");
|
||||
assert(player->cpu != NULL);
|
||||
|
||||
/* we don't have the Simutrek player overrides */
|
||||
player->simutrek.cpu = NULL;
|
||||
|
@ -310,11 +310,8 @@ static DEVICE_START(timekeeper)
|
||||
c->century = make_bcd( systime.local_time.year / 100 );
|
||||
c->data = auto_alloc_array( device->machine, UINT8, c->size );
|
||||
|
||||
c->default_data = device->region;
|
||||
if (c->default_data != NULL)
|
||||
{
|
||||
assert( device->regionbytes == c->size );
|
||||
}
|
||||
c->default_data = *device->region;
|
||||
assert( device->region->bytes() == c->size );
|
||||
|
||||
state_save_register_device_item( device, 0, c->control );
|
||||
state_save_register_device_item( device, 0, c->seconds );
|
||||
|
@ -748,9 +748,9 @@ region_info::region_info(running_machine *_machine, const char *_name, UINT32 _l
|
||||
next(NULL),
|
||||
name(_name),
|
||||
length(_length),
|
||||
flags(_flags),
|
||||
base(auto_alloc_array(_machine, UINT8, _length))
|
||||
flags(_flags)
|
||||
{
|
||||
base.u8 = auto_alloc_array(_machine, UINT8, _length);
|
||||
}
|
||||
|
||||
|
||||
@ -760,7 +760,7 @@ region_info::region_info(running_machine *_machine, const char *_name, UINT32 _l
|
||||
|
||||
region_info::~region_info()
|
||||
{
|
||||
auto_free(machine, base);
|
||||
auto_free(machine, base.v);
|
||||
}
|
||||
|
||||
|
||||
@ -793,7 +793,7 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
|
||||
|
||||
/* hook us into the list */
|
||||
*infoptr = info;
|
||||
return reinterpret_cast<UINT8 *>(info->base);
|
||||
return info->base.u8;
|
||||
}
|
||||
|
||||
|
||||
@ -850,7 +850,7 @@ region_info *memory_region_info(running_machine *machine, const char *name)
|
||||
UINT8 *memory_region(running_machine *machine, const char *name)
|
||||
{
|
||||
const region_info *region = machine->region(name);
|
||||
return (region != NULL) ? reinterpret_cast<UINT8 *>(region->base) : NULL;
|
||||
return (region != NULL) ? region->base.u8 : NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -885,6 +885,8 @@ UINT32 memory_region_flags(running_machine *machine, const char *name)
|
||||
|
||||
const char *memory_region_next(running_machine *machine, const char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return (machine->mame_data->regionlist != NULL) ? machine->mame_data->regionlist->name : NULL;
|
||||
const region_info *region = machine->region(name);
|
||||
return (region != NULL && region->next != NULL) ? region->next->name.cstr() : NULL;
|
||||
}
|
||||
|
@ -160,17 +160,29 @@ class region_info
|
||||
{
|
||||
DISABLE_COPYING(region_info);
|
||||
|
||||
running_machine *machine;
|
||||
running_machine * machine;
|
||||
|
||||
public:
|
||||
region_info(running_machine *machine, const char *_name, UINT32 _length, UINT32 _flags);
|
||||
~region_info();
|
||||
|
||||
region_info * next;
|
||||
astring name;
|
||||
UINT32 length;
|
||||
UINT32 flags;
|
||||
UINT8 * base;
|
||||
operator void *() const { return (this != NULL) ? base.v : NULL; }
|
||||
operator INT8 *() const { return (this != NULL) ? base.i8 : NULL; }
|
||||
operator UINT8 *() const { return (this != NULL) ? base.u8 : NULL; }
|
||||
operator INT16 *() const { return (this != NULL) ? base.i16 : NULL; }
|
||||
operator UINT16 *() const { return (this != NULL) ? base.u16 : NULL; }
|
||||
operator INT32 *() const { return (this != NULL) ? base.i32 : NULL; }
|
||||
operator UINT32 *() const { return (this != NULL) ? base.u32 : NULL; }
|
||||
operator INT64 *() const { return (this != NULL) ? base.i64 : NULL; }
|
||||
operator UINT64 *() const { return (this != NULL) ? base.u64 : NULL; }
|
||||
|
||||
UINT32 bytes() const { return (this != NULL) ? length : 0; }
|
||||
|
||||
region_info * next;
|
||||
astring name;
|
||||
generic_ptr base;
|
||||
UINT32 length;
|
||||
UINT32 flags;
|
||||
};
|
||||
|
||||
|
||||
|
@ -161,8 +161,8 @@ static DEVICE_START( ym2608 )
|
||||
/* stream system initialize */
|
||||
info->stream = stream_create(device,0,2,rate,info,ym2608_stream_update);
|
||||
/* setup adpcm buffers */
|
||||
pcmbufa = device->region;
|
||||
pcmsizea = device->regionbytes;
|
||||
pcmbufa = *device->region;
|
||||
pcmsizea = device->region->bytes();
|
||||
|
||||
/* initialize YM2608 */
|
||||
info->chip = ym2608_init(info,device,device->clock,rate,
|
||||
|
@ -165,8 +165,8 @@ static DEVICE_START( ym2610 )
|
||||
/* stream system initialize */
|
||||
info->stream = stream_create(device,0,2,rate,info,(type == SOUND_YM2610) ? ym2610_stream_update : ym2610b_stream_update);
|
||||
/* setup adpcm buffers */
|
||||
pcmbufa = device->region;
|
||||
pcmsizea = device->regionbytes;
|
||||
pcmbufa = *device->region;
|
||||
pcmsizea = device->region->bytes();
|
||||
name.printf("%s.deltat", device->tag.cstr());
|
||||
pcmbufb = (void *)(memory_region(device->machine, name));
|
||||
pcmsizeb = memory_region_length(device->machine, name);
|
||||
|
@ -130,7 +130,7 @@ static DEVICE_START( y8950 )
|
||||
assert_always(info->chip != NULL, "Error creating Y8950 chip");
|
||||
|
||||
/* ADPCM ROM data */
|
||||
y8950_set_delta_t_memory(info->chip, device->region, device->regionbytes);
|
||||
y8950_set_delta_t_memory(info->chip, *device->region, device->region->bytes());
|
||||
|
||||
info->stream = stream_create(device,0,1,rate,info,y8950_stream_update);
|
||||
|
||||
|
@ -533,11 +533,11 @@ static void AICA_Init(const device_config *device, aica_state *AICA, const aica_
|
||||
{
|
||||
AICA->Master = intf->master;
|
||||
|
||||
AICA->AICARAM = device->region;
|
||||
AICA->AICARAM = *device->region;
|
||||
if (AICA->AICARAM)
|
||||
{
|
||||
AICA->AICARAM += intf->roffset;
|
||||
AICA->AICARAM_LENGTH = device->regionbytes;
|
||||
AICA->AICARAM_LENGTH = device->region->bytes();
|
||||
AICA->RAM_MASK = AICA->AICARAM_LENGTH-1;
|
||||
AICA->RAM_MASK16 = AICA->RAM_MASK & 0x7ffffe;
|
||||
AICA->DSP.AICARAM = (UINT16 *)AICA->AICARAM;
|
||||
|
@ -124,8 +124,8 @@ static DEVICE_START( bsmt2000 )
|
||||
chip->clock = device->clock;
|
||||
|
||||
/* initialize the regions */
|
||||
chip->region_base = (INT8 *)device->region;
|
||||
chip->total_banks = device->regionbytes / 0x10000;
|
||||
chip->region_base = *device->region;
|
||||
chip->total_banks = device->region->bytes() / 0x10000;
|
||||
|
||||
/* register chip-wide data for save states */
|
||||
state_save_register_device_item(device, 0, chip->last_register);
|
||||
|
@ -475,7 +475,7 @@ static DEVICE_START( c140 )
|
||||
|
||||
info->stream = stream_create(device,0,2,info->sample_rate,info,update_stereo);
|
||||
|
||||
info->pRom=device->region;
|
||||
info->pRom=*device->region;
|
||||
|
||||
/* make decompress pcm table */ //2000.06.26 CAB
|
||||
{
|
||||
|
@ -543,8 +543,8 @@ static DEVICE_START( c352 )
|
||||
{
|
||||
c352_state *info = get_safe_token(device);
|
||||
|
||||
info->c352_rom_samples = device->region;
|
||||
info->c352_rom_length = device->regionbytes;
|
||||
info->c352_rom_samples = *device->region;
|
||||
info->c352_rom_length = device->region->bytes();
|
||||
|
||||
info->sample_rate_base = device->clock / 192;
|
||||
|
||||
|
@ -227,7 +227,7 @@ static DEVICE_START( es8712 )
|
||||
chip->repeat = 0;
|
||||
|
||||
chip->bank_offset = 0;
|
||||
chip->region_base = device->region;
|
||||
chip->region_base = *device->region;
|
||||
|
||||
/* generate the name and create the stream */
|
||||
chip->stream = stream_create(device, 0, 1, device->clock, chip, es8712_update);
|
||||
|
@ -268,7 +268,7 @@ static DEVICE_START( gaelco )
|
||||
info->stream = stream_create(device, 0, 2, 8000, info, gaelco_update);
|
||||
info->snd_data = (UINT8 *)memory_region(device->machine, intf->gfxregion);
|
||||
if (info->snd_data == NULL)
|
||||
info->snd_data = device->region;
|
||||
info->snd_data = *device->region;
|
||||
|
||||
/* init volume table */
|
||||
for (vol = 0; vol < VOLUME_LEVELS; vol++){
|
||||
|
@ -477,7 +477,7 @@ static DEVICE_START( ics2115 )
|
||||
|
||||
chip->device = device;
|
||||
chip->intf = (const ics2115_interface *)device->static_config;
|
||||
chip->rom = device->region;
|
||||
chip->rom = *device->region;
|
||||
chip->timer[0].timer = timer_alloc(device->machine, timer_cb_0, chip);
|
||||
chip->timer[1].timer = timer_alloc(device->machine, timer_cb_1, chip);
|
||||
chip->ulaw = auto_alloc_array(device->machine, INT16, 256);
|
||||
|
@ -242,8 +242,8 @@ static DEVICE_START( iremga20 )
|
||||
int i;
|
||||
|
||||
/* Initialize our chip structure */
|
||||
chip->rom = device->region;
|
||||
chip->rom_size = device->regionbytes;
|
||||
chip->rom = *device->region;
|
||||
chip->rom_size = device->region->bytes();
|
||||
|
||||
iremga20_reset(chip);
|
||||
|
||||
|
@ -176,7 +176,7 @@ static DEVICE_START( k005289 )
|
||||
/* build the mixer table */
|
||||
make_mixer_table(device->machine, info, 2);
|
||||
|
||||
info->sound_prom = device->region;
|
||||
info->sound_prom = *device->region;
|
||||
|
||||
/* reset all the voices */
|
||||
voice[0].frequency = 0;
|
||||
|
@ -311,9 +311,9 @@ static DEVICE_START( k007232 )
|
||||
|
||||
/* Set up the chips */
|
||||
|
||||
info->pcmbuf[0] = device->region;
|
||||
info->pcmbuf[1] = device->region;
|
||||
info->pcmlimit = device->regionbytes;
|
||||
info->pcmbuf[0] = *device->region;
|
||||
info->pcmbuf[1] = *device->region;
|
||||
info->pcmlimit = device->region->bytes();
|
||||
|
||||
info->clock = device->clock;
|
||||
|
||||
|
@ -218,13 +218,11 @@ static DEVICE_START( k053260 )
|
||||
ic->intf = (device->static_config != NULL) ? (const k053260_interface *)device->static_config : &defintrf;
|
||||
|
||||
ic->mode = 0;
|
||||
ic->rom = device->region;
|
||||
ic->rom_size = device->regionbytes;
|
||||
if (ic->intf->rgnoverride != NULL)
|
||||
{
|
||||
ic->rom = memory_region(device->machine, ic->intf->rgnoverride);
|
||||
ic->rom_size = memory_region_length(device->machine, ic->intf->rgnoverride);
|
||||
}
|
||||
|
||||
const region_info *region = (ic->intf->rgnoverride != NULL) ? device->machine->region(ic->intf->rgnoverride) : device->region;
|
||||
|
||||
ic->rom = *region;
|
||||
ic->rom_size = region->bytes();
|
||||
|
||||
DEVICE_RESET_CALL(k053260);
|
||||
|
||||
|
@ -459,13 +459,9 @@ static void k054539_init_chip(const device_config *device, k054539_state *info)
|
||||
info->cur_ptr = 0;
|
||||
memset(info->ram, 0, 0x4000*2+device->clock/50*2);
|
||||
|
||||
info->rom = device->region;
|
||||
info->rom_size = device->regionbytes;
|
||||
if (info->intf->rgnoverride != NULL)
|
||||
{
|
||||
info->rom = memory_region(device->machine, info->intf->rgnoverride);
|
||||
info->rom_size = memory_region_length(device->machine, info->intf->rgnoverride);
|
||||
}
|
||||
const region_info *region = (info->intf->rgnoverride != NULL) ? device->machine->region(info->intf->rgnoverride) : device->region;
|
||||
info->rom = *region;
|
||||
info->rom_size = region->bytes();
|
||||
info->rom_mask = 0xffffffffU;
|
||||
for(i=0; i<32; i++)
|
||||
if((1U<<i) >= info->rom_size) {
|
||||
|
@ -502,7 +502,7 @@ static DEVICE_START( multipcm )
|
||||
MultiPCM *ptChip = get_safe_token(device);
|
||||
int i;
|
||||
|
||||
ptChip->ROM=(INT8 *)device->region;
|
||||
ptChip->ROM=*device->region;
|
||||
ptChip->Rate=(float) device->clock / MULTIPCM_CLOCKDIV;
|
||||
|
||||
ptChip->stream = stream_create(device, 0, 2, ptChip->Rate, ptChip, MultiPCM_update);
|
||||
|
@ -115,7 +115,7 @@ static DEVICE_START( namco_63701x )
|
||||
{
|
||||
namco_63701x *chip = get_safe_token(device);
|
||||
|
||||
chip->rom = device->region;
|
||||
chip->rom = *device->region;
|
||||
|
||||
chip->stream = stream_create(device, 0, 2, device->clock/1000, chip, namco_63701x_update);
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ static DEVICE_START( namco )
|
||||
logerror("Namco: freq fractional bits = %d: internal freq = %d, output freq = %d\n", chip->f_fracbits, chip->namco_clock, chip->sample_rate);
|
||||
|
||||
/* build the waveform table */
|
||||
build_decoded_waveform(device->machine, chip, device->region);
|
||||
build_decoded_waveform(device->machine, chip, *device->region);
|
||||
|
||||
/* get stream channels */
|
||||
if (intf->stereo)
|
||||
|
@ -229,7 +229,7 @@ static DEVICE_START( nile )
|
||||
{
|
||||
nile_state *info = get_safe_token(device);
|
||||
|
||||
info->sound_ram = device->region;
|
||||
info->sound_ram = *device->region;
|
||||
|
||||
info->stream = stream_create(device, 0, 2, 44100, info, nile_update);
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void okim6295_set_bank_base(const device_config *device, int base)
|
||||
if (info->bank_installed)
|
||||
{
|
||||
info->bank_offs = base;
|
||||
memory_set_bankptr(device->machine, device->tag, device->region + base);
|
||||
memory_set_bankptr(device->machine, device->tag, device->region->base.u8 + base);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ static DEVICE_START( okim6376 )
|
||||
compute_tables();
|
||||
|
||||
info->command = -1;
|
||||
info->region_base = device->region;
|
||||
info->region_base = *device->region;
|
||||
info->master_clock = device->clock;
|
||||
|
||||
/* generate the name and create the stream */
|
||||
|
@ -107,8 +107,8 @@ static DEVICE_START( qsound )
|
||||
qsound_state *chip = get_safe_token(device);
|
||||
int i;
|
||||
|
||||
chip->sample_rom = (QSOUND_SRC_SAMPLE *)device->region;
|
||||
chip->sample_rom_length = device->regionbytes;
|
||||
chip->sample_rom = (QSOUND_SRC_SAMPLE *)*device->region;
|
||||
chip->sample_rom_length = device->region->bytes();
|
||||
|
||||
memset(chip->channel, 0, sizeof(chip->channel));
|
||||
|
||||
|
@ -244,8 +244,8 @@ static void rf5c400_init_chip(const device_config *device, rf5c400_state *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
info->rom = (INT16*)device->region;
|
||||
info->rom_length = device->regionbytes / 2;
|
||||
info->rom = *device->region;
|
||||
info->rom_length = device->region->bytes() / 2;
|
||||
|
||||
// init volume table
|
||||
{
|
||||
|
@ -581,7 +581,7 @@ static DEVICE_START( s14001a )
|
||||
chip->filtervals[i] = SILENCE;
|
||||
}
|
||||
|
||||
chip->SpeechRom = device->region;
|
||||
chip->SpeechRom = *device->region;
|
||||
|
||||
chip->stream = stream_create(device, 0, 1, device->clock ? device->clock : device->machine->sample_rate, chip, s14001a_pcm_update);
|
||||
}
|
||||
|
@ -537,10 +537,10 @@ static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scs
|
||||
SCSP->Master=0;
|
||||
}
|
||||
|
||||
SCSP->SCSPRAM = device->region;
|
||||
SCSP->SCSPRAM = *device->region;
|
||||
if (SCSP->SCSPRAM)
|
||||
{
|
||||
SCSP->SCSPRAM_LENGTH = device->regionbytes;
|
||||
SCSP->SCSPRAM_LENGTH = device->region->bytes();
|
||||
SCSP->DSP.SCSPRAM = (UINT16 *)SCSP->SCSPRAM;
|
||||
SCSP->DSP.SCSPRAM_LENGTH = SCSP->SCSPRAM_LENGTH/2;
|
||||
SCSP->SCSPRAM += intf->roffset;
|
||||
|
@ -92,7 +92,7 @@ static DEVICE_START( segapcm )
|
||||
int mask, rom_mask, len;
|
||||
segapcm_state *spcm = get_safe_token(device);
|
||||
|
||||
spcm->rom = (const UINT8 *)device->region;
|
||||
spcm->rom = *device->region;
|
||||
spcm->ram = auto_alloc_array(device->machine, UINT8, 0x800);
|
||||
|
||||
memset(spcm->ram, 0xff, 0x800);
|
||||
@ -102,7 +102,7 @@ static DEVICE_START( segapcm )
|
||||
if(!mask)
|
||||
mask = BANK_MASK7>>16;
|
||||
|
||||
len = device->regionbytes;
|
||||
len = device->region->bytes();
|
||||
for(rom_mask = 1; rom_mask < len; rom_mask *= 2);
|
||||
rom_mask--;
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ static DEVICE_START( sp0256 )
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Setup the ROM. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
sp->rom = device->region;
|
||||
sp->rom = *device->region;
|
||||
sp0256_bitrevbuff(sp->rom, 0, 0xffff);
|
||||
}
|
||||
|
||||
|
@ -943,7 +943,7 @@ static DEVICE_START( tms5110 )
|
||||
tms5110_state *tms = get_safe_token(device);
|
||||
|
||||
tms->intf = device->static_config ? (const tms5110_interface *)device->static_config : &dummy;
|
||||
tms->table = device->region;
|
||||
tms->table = *device->region;
|
||||
|
||||
tms->device = device;
|
||||
tms5110_set_variant(tms, TMS5110_IS_5110A);
|
||||
|
@ -656,7 +656,7 @@ static DEVICE_START( upd7759 )
|
||||
chip->state = STATE_IDLE;
|
||||
|
||||
/* compute the ROM base or allocate a timer */
|
||||
chip->rom = chip->rombase = device->region;
|
||||
chip->rom = chip->rombase = *device->region;
|
||||
if (chip->rom == NULL)
|
||||
chip->timer = timer_alloc(device->machine, upd7759_slave_update, chip);
|
||||
|
||||
|
@ -665,10 +665,10 @@ static DEVICE_START( vlm5030 )
|
||||
vlm5030_reset(chip);
|
||||
chip->phase = PH_IDLE;
|
||||
|
||||
chip->rom = device->region;
|
||||
chip->rom = *device->region;
|
||||
/* memory size */
|
||||
if( chip->intf->memory_size == 0)
|
||||
chip->address_mask = device->regionbytes-1;
|
||||
chip->address_mask = device->region->bytes()-1;
|
||||
else
|
||||
chip->address_mask = chip->intf->memory_size-1;
|
||||
|
||||
|
@ -206,7 +206,7 @@ static DEVICE_START( x1_010 )
|
||||
const x1_010_interface *intf = (const x1_010_interface *)device->static_config;
|
||||
x1_010_state *info = get_safe_token(device);
|
||||
|
||||
info->region = device->region;
|
||||
info->region = *device->region;
|
||||
info->base_clock = device->clock;
|
||||
info->rate = device->clock / 1024;
|
||||
info->address = intf->adr;
|
||||
|
@ -1779,7 +1779,7 @@ static DEVICE_START( ymf271 )
|
||||
|
||||
intf = (device->static_config != NULL) ? (const ymf271_interface *)device->static_config : &defintrf;
|
||||
|
||||
ymf271_init(device, chip, device->region, intf->irq_callback, &intf->ext_read, &intf->ext_write);
|
||||
ymf271_init(device, chip, *device->region, intf->irq_callback, &intf->ext_read, &intf->ext_write);
|
||||
chip->stream = stream_create(device, 0, 2, device->clock/384, chip, ymf271_update);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
|
@ -668,7 +668,7 @@ WRITE8_DEVICE_HANDLER( ymf278b_w )
|
||||
|
||||
static void ymf278b_init(const device_config *device, YMF278BChip *chip, void (*cb)(const device_config *, int))
|
||||
{
|
||||
chip->rom = device->region;
|
||||
chip->rom = *device->region;
|
||||
chip->irq_callback = cb;
|
||||
chip->timer_a = timer_alloc(device->machine, ymf278b_timer_a_tick, chip);
|
||||
chip->timer_b = timer_alloc(device->machine, ymf278b_timer_b_tick, chip);
|
||||
|
@ -650,7 +650,7 @@ static DEVICE_START( ymz280b )
|
||||
|
||||
/* initialize the rest of the structure */
|
||||
chip->master_clock = (double)device->clock / 384.0;
|
||||
chip->region_base = device->region;
|
||||
chip->region_base = *device->region;
|
||||
chip->irq_callback = intf->irq_callback;
|
||||
|
||||
/* create the stream */
|
||||
|
@ -3735,10 +3735,10 @@ static void init_ds3(running_machine *machine)
|
||||
|
||||
/* if we have a sound DSP, boot it */
|
||||
if (state->soundcpu != NULL && cpu_get_type(state->soundcpu) == CPU_ADSP2105)
|
||||
adsp2105_load_boot_data((UINT8 *)(state->soundcpu->region + 0x10000), (UINT32 *)state->soundcpu->region);
|
||||
adsp2105_load_boot_data(state->soundcpu->region->base.u8 + 0x10000, state->soundcpu->region->base.u32);
|
||||
|
||||
if (state->sounddsp != NULL && cpu_get_type(state->sounddsp) == CPU_ADSP2105)
|
||||
adsp2105_load_boot_data((UINT8 *)(state->sounddsp->region + 0x10000), (UINT32 *)state->sounddsp->region);
|
||||
adsp2105_load_boot_data(state->sounddsp->region->base.u8 + 0x10000, state->sounddsp->region->base.u32);
|
||||
|
||||
/*
|
||||
|
||||
|
@ -2105,7 +2105,7 @@ static UINT8 tape_get_status_bits(const device_config *device)
|
||||
|
||||
/* data block bytes are data */
|
||||
else if (tape->bytenum >= BYTE_DATA_0 && tape->bytenum <= BYTE_DATA_255)
|
||||
byteval = device->region[blocknum * 256 + (tape->bytenum - BYTE_DATA_0)];
|
||||
byteval = static_cast<UINT8 *>(*device->region)[blocknum * 256 + (tape->bytenum - BYTE_DATA_0)];
|
||||
|
||||
/* CRC MSB */
|
||||
else if (tape->bytenum == BYTE_CRC16_MSB)
|
||||
@ -2182,10 +2182,11 @@ static DEVICE_START( decocass_tape )
|
||||
tape->timer = timer_alloc(device->machine, tape_clock_callback, (void *)device);
|
||||
if (device->region == NULL)
|
||||
return;
|
||||
UINT8 *regionbase = *device->region;
|
||||
|
||||
/* scan for the first non-empty block in the image */
|
||||
for (offs = device->regionbytes - 1; offs >= 0; offs--)
|
||||
if (device->region[offs] != 0)
|
||||
for (offs = device->region->bytes() - 1; offs >= 0; offs--)
|
||||
if (regionbase[offs] != 0)
|
||||
break;
|
||||
numblocks = ((offs | 0xff) + 1) / 256;
|
||||
assert(numblocks < ARRAY_LENGTH(tape->crc16));
|
||||
@ -2201,7 +2202,7 @@ static DEVICE_START( decocass_tape )
|
||||
|
||||
/* first CRC the 256 bytes of data */
|
||||
for (offs = 256 * curblock; offs < 256 * curblock + 256; offs++)
|
||||
crc = tape_crc16_byte(crc, device->region[offs]);
|
||||
crc = tape_crc16_byte(crc, regionbase[offs]);
|
||||
|
||||
/* then find a pair of bytes that will bring the CRC to 0 (any better way than brute force?) */
|
||||
for (testval = 0; testval < 0x10000; testval++)
|
||||
|
@ -163,7 +163,7 @@ void segaic16_memory_mapper_config(running_machine *machine, const UINT8 *map_da
|
||||
void segaic16_memory_mapper_set_decrypted(running_machine *machine, UINT8 *decrypted)
|
||||
{
|
||||
struct memory_mapper_chip *chip = &memory_mapper;
|
||||
offs_t romsize = chip->cpu->regionbytes;
|
||||
offs_t romsize = chip->cpu->region->length;
|
||||
int rgnum;
|
||||
|
||||
/* loop over the regions */
|
||||
@ -346,7 +346,7 @@ static void update_memory_mapping(running_machine *machine, struct memory_mapper
|
||||
/* ROM areas need extra clamping */
|
||||
if (rgn->romoffset != ~0)
|
||||
{
|
||||
offs_t romsize = chip->cpu->regionbytes;
|
||||
offs_t romsize = chip->cpu->region->length;
|
||||
if (region_start >= romsize)
|
||||
read = NULL;
|
||||
else if (region_start + rgn->length > romsize)
|
||||
@ -382,7 +382,7 @@ static void update_memory_mapping(running_machine *machine, struct memory_mapper
|
||||
decrypted = (UINT8 *)fd1089_get_decrypted_base();
|
||||
}
|
||||
|
||||
memory_configure_bank(machine, readbank, 0, 1, (UINT8 *)chip->cpu->region + region_start, 0);
|
||||
memory_configure_bank(machine, readbank, 0, 1, chip->cpu->region->base.u8 + region_start, 0);
|
||||
if (decrypted)
|
||||
memory_configure_bank_decrypted(machine, readbank, 0, 1, decrypted + region_start, 0);
|
||||
|
||||
|
@ -557,8 +557,8 @@ VIDEO_UPDATE( atarisy1 )
|
||||
static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *molookup)
|
||||
{
|
||||
atarisy1_state *state = (atarisy1_state *)machine->driver_data;
|
||||
UINT8 *prom1 = &machine->region("proms")->base[0x000];
|
||||
UINT8 *prom2 = &machine->region("proms")->base[0x200];
|
||||
UINT8 *prom1 = &machine->region("proms")->base.u8[0x000];
|
||||
UINT8 *prom2 = &machine->region("proms")->base.u8[0x200];
|
||||
int obj, i;
|
||||
|
||||
/* reset the globals */
|
||||
@ -660,7 +660,7 @@ static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp)
|
||||
assert(gfx_index != MAX_GFX_ELEMENTS);
|
||||
|
||||
/* decode the graphics */
|
||||
srcdata = &tiles->base[0x80000 * (bank_index - 1)];
|
||||
srcdata = &tiles->base.u8[0x80000 * (bank_index - 1)];
|
||||
switch (bpp)
|
||||
{
|
||||
case 4:
|
||||
|
Loading…
Reference in New Issue
Block a user