diff --git a/src/emu/device.c b/src/emu/device.c index ad29e267f35..faf57fbf7b4 100644 --- a/src/emu/device.c +++ b/src/emu/device.c @@ -201,7 +201,24 @@ memory_region *device_t::memregion(const char *_tag) const //------------------------------------------------- -// memregion - return a pointer to the memory +// memshare - return a pointer to the memory share +// info for a given share +//------------------------------------------------- + +memory_share *device_t::memshare(const char *_tag) const +{ + // safety first + if (this == NULL) + return NULL; + + // build a fully-qualified name and look it up + astring fullpath; + return machine().memory().shared(subtag(fullpath, _tag)); +} + + +//------------------------------------------------- +// membank - return a pointer to the memory // bank info for a given bank //------------------------------------------------- @@ -883,7 +900,7 @@ device_t::finder_base::~finder_base() void *device_t::finder_base::find_memory(UINT8 width, size_t &bytes, bool required) { // look up the share and return NULL if not found - memory_share *share = m_base.machine().memory().shared(m_base, m_tag); + memory_share *share = m_base.memshare(m_tag); if (share == NULL) return NULL; diff --git a/src/emu/device.h b/src/emu/device.h index e436cb4c1e8..84acfd14fb6 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -184,6 +184,7 @@ public: astring &subtag(astring &dest, const char *tag) const; astring &siblingtag(astring &dest, const char *tag) const { return (this != NULL && m_owner != NULL) ? m_owner->subtag(dest, tag) : dest.cpy(tag); } memory_region *memregion(const char *tag) const; + memory_share *memshare(const char *tag) const; memory_bank *membank(const char *tag) const; device_t *subdevice(const char *tag) const; device_t *siblingdevice(const char *tag) const; diff --git a/src/emu/machine/nvram.c b/src/emu/machine/nvram.c index fed1c07a192..4bacf3047d9 100644 --- a/src/emu/machine/nvram.c +++ b/src/emu/machine/nvram.c @@ -187,7 +187,7 @@ void nvram_device::determine_final_base() // find our shared pointer with the target RAM if (m_base == NULL) { - memory_share *share = machine().memory().shared(*owner(), tag()); + memory_share *share = owner()->memshare(tag()); if (share == NULL) throw emu_fatalerror("NVRAM device '%s' has no corresponding AM_SHARE region", tag()); m_base = share->ptr(); diff --git a/src/emu/memory.c b/src/emu/memory.c index 4157aa9fa7b..4d00811fe00 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -1560,23 +1560,6 @@ void memory_manager::initialize() } -//------------------------------------------------- -// shared - get a pointer to a shared memory -// region by tag -//------------------------------------------------- - -memory_share *memory_manager::shared(const char *tag) -{ - return shared(machine().root_device(), tag); -} - -memory_share *memory_manager::shared(device_t &device, const char *tag) -{ - astring fulltag; - return m_sharelist.find(device.subtag(fulltag, tag).cstr()); -} - - //------------------------------------------------- // dump - dump the internal memory tables to the // given file diff --git a/src/emu/memory.h b/src/emu/memory.h index b40f378bffc..23e19d37c9f 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -816,10 +816,6 @@ public: address_space *first_space() const { return m_spacelist.first(); } memory_region *first_region() const { return m_regionlist.first(); } - // get a pointer to a shared memory region by tag - memory_share *shared(const char *tag); - memory_share *shared(device_t &device, const char *tag); - // dump the internal memory tables to the given file void dump(FILE *file); @@ -835,6 +831,7 @@ private: memory_bank *first_bank() const { return m_banklist.first(); } memory_bank *bank(const char *tag) const { return m_bankmap.find(tag); } memory_region *region(const char *tag) { return m_regionlist.find(tag); } + memory_share *shared(const char *tag) { return m_sharelist.find(tag); } void bank_reattach(); // internal state diff --git a/src/emu/sound/spu.c b/src/emu/sound/spu.c index fd8fa159373..6deaf8d1fca 100644 --- a/src/emu/sound/spu.c +++ b/src/emu/sound/spu.c @@ -3090,14 +3090,14 @@ void spu_device::flush_cdda(const unsigned int sector) void spu_device::dma_read( UINT32 n_address, INT32 n_size ) { - UINT8 *psxram = (UINT8 *)machine().memory().shared("share1")->ptr(); + UINT8 *psxram = (UINT8 *)machine().root_device().memshare("share1")->ptr(); start_dma(psxram + n_address, false, n_size*4); } void spu_device::dma_write( UINT32 n_address, INT32 n_size ) { - UINT8 *psxram = (UINT8 *)machine().memory().shared("share1")->ptr(); + UINT8 *psxram = (UINT8 *)machine().root_device().memshare("share1")->ptr(); // printf("SPU DMA write from %x, size %x\n", n_address, n_size); diff --git a/src/mame/audio/dcs.c b/src/mame/audio/dcs.c index 0d2e15a0867..bd6326ba136 100644 --- a/src/mame/audio/dcs.c +++ b/src/mame/audio/dcs.c @@ -943,8 +943,8 @@ void dcs_init(running_machine &machine) memset(&dcs, 0, sizeof(dcs)); dcs.sram = NULL; - dcs.internal_program_ram = (UINT32 *)machine.memory().shared("dcsint")->ptr(); - dcs.external_program_ram = (UINT32 *)machine.memory().shared("dcsext")->ptr(); + dcs.internal_program_ram = (UINT32 *)machine.root_device().memshare("dcsint")->ptr(); + dcs.external_program_ram = (UINT32 *)machine.root_device().memshare("dcsext")->ptr(); /* find the DCS CPU and the sound ROMs */ dcs.cpu = machine.device("dcs"); @@ -982,8 +982,8 @@ void dcs2_init(running_machine &machine, int dram_in_mb, offs_t polling_offset) int soundbank_words; memset(&dcs, 0, sizeof(dcs)); - dcs.internal_program_ram = (UINT32 *)machine.memory().shared("dcsint")->ptr(); - dcs.external_program_ram = (UINT32 *)machine.memory().shared("dcsext")->ptr(); + dcs.internal_program_ram = (UINT32 *)machine.root_device().memshare("dcsint")->ptr(); + dcs.external_program_ram = (UINT32 *)machine.root_device().memshare("dcsext")->ptr(); /* find the DCS CPU and the sound ROMs */ dcs.cpu = machine.device("dcs2"); diff --git a/src/mame/audio/segasnd.c b/src/mame/audio/segasnd.c index 710363a1d15..563944a10ec 100644 --- a/src/mame/audio/segasnd.c +++ b/src/mame/audio/segasnd.c @@ -736,7 +736,7 @@ static DEVICE_START( usb_sound ) assert(usb->cpu != NULL); /* allocate RAM */ - usb->program_ram = (UINT8 *)machine.memory().shared("pgmram")->ptr(); + usb->program_ram = (UINT8 *)machine.root_device().memshare("pgmram")->ptr(); usb->work_ram = auto_alloc_array(machine, UINT8, 0x400); /* create a sound stream */ diff --git a/src/mame/audio/taito_en.c b/src/mame/audio/taito_en.c index 737e2818467..e40a96be858 100644 --- a/src/mame/audio/taito_en.c +++ b/src/mame/audio/taito_en.c @@ -305,7 +305,7 @@ SOUND_RESET( taito_f3_soundsystem_reset ) { /* Sound cpu program loads to 0xc00000 so we use a bank */ UINT16 *ROM = (UINT16 *)machine.root_device().memregion("audiocpu")->base(); - UINT16 *sound_ram = (UINT16 *)machine.memory().shared("share1")->ptr(); + UINT16 *sound_ram = (UINT16 *)machine.root_device().memshare("share1")->ptr(); machine.root_device().membank("bank1")->set_base(&ROM[0x80000]); machine.root_device().membank("bank2")->set_base(&ROM[0x90000]); machine.root_device().membank("bank3")->set_base(&ROM[0xa0000]); @@ -319,7 +319,7 @@ SOUND_RESET( taito_f3_soundsystem_reset ) machine.device("audiocpu")->reset(); //cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); - f3_shared_ram = (UINT32 *)machine.memory().shared("f3_shared")->ptr(); + f3_shared_ram = (UINT32 *)machine.root_device().memshare("f3_shared")->ptr(); } static const es5505_interface es5505_taito_f3_config = diff --git a/src/mame/drivers/actfancr.c b/src/mame/drivers/actfancr.c index 9ef7fa68196..9751a205fd3 100644 --- a/src/mame/drivers/actfancr.c +++ b/src/mame/drivers/actfancr.c @@ -64,7 +64,7 @@ WRITE8_MEMBER(actfancr_state::actfancr_sound_w) WRITE8_MEMBER(actfancr_state::actfancr_buffer_spriteram_w) { - UINT8 *src = reinterpret_cast(machine().memory().shared("spriteram")->ptr()); + UINT8 *src = reinterpret_cast(memshare("spriteram")->ptr()); // copy to a 16-bit region for our sprite draw code too for (int i=0;i<0x800/2;i++) { diff --git a/src/mame/drivers/segac2.c b/src/mame/drivers/segac2.c index 17c1f5308c1..ba9a31e3cac 100644 --- a/src/mame/drivers/segac2.c +++ b/src/mame/drivers/segac2.c @@ -111,7 +111,7 @@ static MACHINE_START( segac2 ) static MACHINE_RESET( segac2 ) { segac2_state *state = machine.driver_data(); - megadrive_ram = reinterpret_cast(machine.memory().shared("nvram")->ptr()); + megadrive_ram = reinterpret_cast(state->memshare("nvram")->ptr()); /* set up interrupts and such */ MACHINE_RESET_CALL(megadriv); diff --git a/src/mame/machine/leland.c b/src/mame/machine/leland.c index b29579d62f3..594f67126dd 100644 --- a/src/mame/machine/leland.c +++ b/src/mame/machine/leland.c @@ -320,7 +320,7 @@ MACHINE_START( leland ) { leland_state *state = machine.driver_data(); /* allocate extra stuff */ - state->m_battery_ram = reinterpret_cast(machine.memory().shared("battery")->ptr()); + state->m_battery_ram = reinterpret_cast(state->memshare("battery")->ptr()); /* start scanline interrupts going */ state->m_master_int_timer = machine.scheduler().timer_alloc(FUNC(leland_interrupt_callback)); @@ -370,7 +370,7 @@ MACHINE_START( ataxx ) { leland_state *state = machine.driver_data(); /* set the odd data banks */ - state->m_battery_ram = reinterpret_cast(machine.memory().shared("battery")->ptr()); + state->m_battery_ram = reinterpret_cast(state->memshare("battery")->ptr()); state->m_extra_tram = auto_alloc_array(machine, UINT8, ATAXX_EXTRA_TRAM_SIZE); /* start scanline interrupts going */ diff --git a/src/mame/machine/psx.c b/src/mame/machine/psx.c index 510f94260bb..402d35dcb49 100644 --- a/src/mame/machine/psx.c +++ b/src/mame/machine/psx.c @@ -28,7 +28,7 @@ void psx_driver_init( running_machine &machine ) { psx_state *p_psx = machine.driver_data(); - memory_share *share = machine.memory().shared("share1"); + memory_share *share = machine.root_device().memshare("share1"); p_psx->m_p_n_psxram = (UINT32 *)share->ptr(); p_psx->m_n_psxramsize = share->bytes(); } diff --git a/src/mame/machine/s24fd.c b/src/mame/machine/s24fd.c index 627ad8f9fd1..5fad6367414 100644 --- a/src/mame/machine/s24fd.c +++ b/src/mame/machine/s24fd.c @@ -156,7 +156,7 @@ void s24_fd1094_driver_init(running_machine &machine) { int i; - s24_fd1094_cpuregion = (UINT16*)machine.memory().shared("share2")->ptr(); + s24_fd1094_cpuregion = (UINT16*)machine.root_device().memshare("share2")->ptr(); s24_fd1094_cpuregionsize = 0x40000; s24_fd1094_key = machine.root_device().memregion("fd1094key")->base(); diff --git a/src/mame/video/sei_crtc.c b/src/mame/video/sei_crtc.c index 97b40afca23..1504981b1a1 100644 --- a/src/mame/video/sei_crtc.c +++ b/src/mame/video/sei_crtc.c @@ -208,7 +208,7 @@ static TILE_GET_INFO( seibucrtc_sc3_tile_info ) static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect,int pri) { - UINT16 *spriteram16 = reinterpret_cast(machine.memory().shared("spriteram")->ptr()); + UINT16 *spriteram16 = reinterpret_cast(machine.root_device().memshare("spriteram")->ptr()); int offs,fx,fy,x,y,color,sprite; int dx,dy,ax,ay;