diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 84812e4cb02..9454db8c703 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -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(_owner)), + typenext(NULL), + classnext(NULL), + tag(_tag), + type(_type), + devclass(static_cast(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; } } diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index a02744ce8f2..2560542cb42 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -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 */ }; diff --git a/src/emu/emucore.h b/src/emu/emucore.h index 238c726d848..3de03bda6d6 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -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; }; diff --git a/src/emu/machine/at28c16.c b/src/emu/machine/at28c16.c index 52054f1426e..d304eeae395 100644 --- a/src/emu/machine/at28c16.c +++ b/src/emu/machine/at28c16.c @@ -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) diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c index a223226b618..e39bb075997 100644 --- a/src/emu/machine/eeprom.c +++ b/src/emu/machine/eeprom.c @@ -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]); } } } diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c index 3964b2ec40b..15f79542ebc 100644 --- a/src/emu/machine/ldpr8210.c +++ b/src/emu/machine/ldpr8210.c @@ -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; diff --git a/src/emu/machine/timekpr.c b/src/emu/machine/timekpr.c index 94f716931d7..e3f656c409d 100644 --- a/src/emu/machine/timekpr.c +++ b/src/emu/machine/timekpr.c @@ -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 ); diff --git a/src/emu/mame.c b/src/emu/mame.c index 2d2ed48a191..e4260cb05e7 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -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(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(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; } diff --git a/src/emu/mame.h b/src/emu/mame.h index ddea489cac1..238879e44cb 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -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; }; diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index a66ebc3d043..f802f09ae6a 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -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, diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index 19e425f0523..c7601ab9ec3 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -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); diff --git a/src/emu/sound/8950intf.c b/src/emu/sound/8950intf.c index fcf6968447c..2510d3e6cf4 100644 --- a/src/emu/sound/8950intf.c +++ b/src/emu/sound/8950intf.c @@ -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); diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index 1104c4f7839..c4152de929f 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -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; diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c index 5c60171e68e..585076008f4 100644 --- a/src/emu/sound/bsmt2000.c +++ b/src/emu/sound/bsmt2000.c @@ -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); diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c index 8b34e9bdda8..265ab534e7c 100644 --- a/src/emu/sound/c140.c +++ b/src/emu/sound/c140.c @@ -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 { diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c index 5645e8afaab..98870afce38 100644 --- a/src/emu/sound/c352.c +++ b/src/emu/sound/c352.c @@ -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; diff --git a/src/emu/sound/es8712.c b/src/emu/sound/es8712.c index 7508602cb6e..5fff26f4b18 100644 --- a/src/emu/sound/es8712.c +++ b/src/emu/sound/es8712.c @@ -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); diff --git a/src/emu/sound/gaelco.c b/src/emu/sound/gaelco.c index 09a358de25c..fb69ee27d15 100644 --- a/src/emu/sound/gaelco.c +++ b/src/emu/sound/gaelco.c @@ -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++){ diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index a24bd88981b..d32b17ceee6 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -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); diff --git a/src/emu/sound/iremga20.c b/src/emu/sound/iremga20.c index b536830ebbd..6202b2eb6c7 100644 --- a/src/emu/sound/iremga20.c +++ b/src/emu/sound/iremga20.c @@ -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); diff --git a/src/emu/sound/k005289.c b/src/emu/sound/k005289.c index 051eee5289a..33d39318195 100644 --- a/src/emu/sound/k005289.c +++ b/src/emu/sound/k005289.c @@ -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; diff --git a/src/emu/sound/k007232.c b/src/emu/sound/k007232.c index 2a199394c70..54c612da5f1 100644 --- a/src/emu/sound/k007232.c +++ b/src/emu/sound/k007232.c @@ -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; diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index 651dac7345f..5dc70ec7a39 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -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); diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index 2a2c7a635b6..e8e3865bc21 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -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<= info->rom_size) { diff --git a/src/emu/sound/multipcm.c b/src/emu/sound/multipcm.c index 294137ce4fc..cc346ba80ba 100644 --- a/src/emu/sound/multipcm.c +++ b/src/emu/sound/multipcm.c @@ -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); diff --git a/src/emu/sound/n63701x.c b/src/emu/sound/n63701x.c index 2c8eff2669b..fc7bda5f3e3 100644 --- a/src/emu/sound/n63701x.c +++ b/src/emu/sound/n63701x.c @@ -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); } diff --git a/src/emu/sound/namco.c b/src/emu/sound/namco.c index e6e2c0a55e6..4cdfadcea19 100644 --- a/src/emu/sound/namco.c +++ b/src/emu/sound/namco.c @@ -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) diff --git a/src/emu/sound/nile.c b/src/emu/sound/nile.c index 64d08ecb489..8d6912d94cb 100644 --- a/src/emu/sound/nile.c +++ b/src/emu/sound/nile.c @@ -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); } diff --git a/src/emu/sound/okim6295.c b/src/emu/sound/okim6295.c index 7b954f165a0..18ccb418d29 100644 --- a/src/emu/sound/okim6295.c +++ b/src/emu/sound/okim6295.c @@ -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); } } diff --git a/src/emu/sound/okim6376.c b/src/emu/sound/okim6376.c index 89368ca252c..a1e694384cf 100644 --- a/src/emu/sound/okim6376.c +++ b/src/emu/sound/okim6376.c @@ -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 */ diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c index 931019445d2..929ef314c54 100644 --- a/src/emu/sound/qsound.c +++ b/src/emu/sound/qsound.c @@ -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)); diff --git a/src/emu/sound/rf5c400.c b/src/emu/sound/rf5c400.c index cd847d7869f..c640fa52004 100644 --- a/src/emu/sound/rf5c400.c +++ b/src/emu/sound/rf5c400.c @@ -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 { diff --git a/src/emu/sound/s14001a.c b/src/emu/sound/s14001a.c index 63cf0f0c8e6..7cca2cdeee7 100644 --- a/src/emu/sound/s14001a.c +++ b/src/emu/sound/s14001a.c @@ -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); } diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 1f5acb492c5..25102d483ea 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -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; diff --git a/src/emu/sound/segapcm.c b/src/emu/sound/segapcm.c index 62900b6e756..86e5f4b75cb 100644 --- a/src/emu/sound/segapcm.c +++ b/src/emu/sound/segapcm.c @@ -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--; diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index 130b05990ef..b8be8e6815d 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -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); } diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index aaaebbcf023..401efed217e 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -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); diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index bc379a92028..c81d37bceba 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -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); diff --git a/src/emu/sound/vlm5030.c b/src/emu/sound/vlm5030.c index 720448e5da9..2e41f422e71 100644 --- a/src/emu/sound/vlm5030.c +++ b/src/emu/sound/vlm5030.c @@ -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; diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c index d14cf3e7857..830a0f29763 100644 --- a/src/emu/sound/x1_010.c +++ b/src/emu/sound/x1_010.c @@ -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; diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index 7f9d36b1903..be9bc60dab5 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -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++) diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 8180d2e01b5..0e5f72c9a70 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -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); diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 1e765c920c9..f7861215bb6 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -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 */ diff --git a/src/mame/drivers/harddriv.c b/src/mame/drivers/harddriv.c index b5b02dcf40b..1e01745d3d1 100644 --- a/src/mame/drivers/harddriv.c +++ b/src/mame/drivers/harddriv.c @@ -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); /* diff --git a/src/mame/machine/decocass.c b/src/mame/machine/decocass.c index f7f92dcaf63..9c75d4a6274 100644 --- a/src/mame/machine/decocass.c +++ b/src/mame/machine/decocass.c @@ -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(*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++) diff --git a/src/mame/machine/segaic16.c b/src/mame/machine/segaic16.c index e342568b8ab..4a938c7565e 100644 --- a/src/mame/machine/segaic16.c +++ b/src/mame/machine/segaic16.c @@ -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); diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c index a9d2ede14b5..1bd5a3d78da 100644 --- a/src/mame/video/atarisy1.c +++ b/src/mame/video/atarisy1.c @@ -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: