Make memory shares follow the same pattern as memory

regions and memory banks, accessible only via the device.
This commit is contained in:
Aaron Giles 2012-04-20 19:57:41 +00:00
parent 95fcb3ceec
commit 5594694605
15 changed files with 38 additions and 40 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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<adsp21xx_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<adsp21xx_device>("dcs2");

View File

@ -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 */

View File

@ -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 =

View File

@ -64,7 +64,7 @@ WRITE8_MEMBER(actfancr_state::actfancr_sound_w)
WRITE8_MEMBER(actfancr_state::actfancr_buffer_spriteram_w)
{
UINT8 *src = reinterpret_cast<UINT8 *>(machine().memory().shared("spriteram")->ptr());
UINT8 *src = reinterpret_cast<UINT8 *>(memshare("spriteram")->ptr());
// copy to a 16-bit region for our sprite draw code too
for (int i=0;i<0x800/2;i++)
{

View File

@ -111,7 +111,7 @@ static MACHINE_START( segac2 )
static MACHINE_RESET( segac2 )
{
segac2_state *state = machine.driver_data<segac2_state>();
megadrive_ram = reinterpret_cast<UINT16 *>(machine.memory().shared("nvram")->ptr());
megadrive_ram = reinterpret_cast<UINT16 *>(state->memshare("nvram")->ptr());
/* set up interrupts and such */
MACHINE_RESET_CALL(megadriv);

View File

@ -320,7 +320,7 @@ MACHINE_START( leland )
{
leland_state *state = machine.driver_data<leland_state>();
/* allocate extra stuff */
state->m_battery_ram = reinterpret_cast<UINT8 *>(machine.memory().shared("battery")->ptr());
state->m_battery_ram = reinterpret_cast<UINT8 *>(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<leland_state>();
/* set the odd data banks */
state->m_battery_ram = reinterpret_cast<UINT8 *>(machine.memory().shared("battery")->ptr());
state->m_battery_ram = reinterpret_cast<UINT8 *>(state->memshare("battery")->ptr());
state->m_extra_tram = auto_alloc_array(machine, UINT8, ATAXX_EXTRA_TRAM_SIZE);
/* start scanline interrupts going */

View File

@ -28,7 +28,7 @@ void psx_driver_init( running_machine &machine )
{
psx_state *p_psx = machine.driver_data<psx_state>();
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();
}

View File

@ -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();

View File

@ -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<UINT16 *>(machine.memory().shared("spriteram")->ptr());
UINT16 *spriteram16 = reinterpret_cast<UINT16 *>(machine.root_device().memshare("spriteram")->ptr());
int offs,fx,fy,x,y,color,sprite;
int dx,dy,ax,ay;