diff options
author | 2010-09-10 18:36:53 +0000 | |
---|---|---|
committer | 2010-09-10 18:36:53 +0000 | |
commit | 7676f5ae3e71f3b2c312a4756296bd5bdc3754e8 (patch) | |
tree | 6cbc66eaf054b019733054b5c595b95e84d50d41 /src/emu/machine/nvram.c | |
parent | e0e567bf9c9813bebf205752b10208906685263a (diff) |
Regression fixes.
Diffstat (limited to 'src/emu/machine/nvram.c')
-rw-r--r-- | src/emu/machine/nvram.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/emu/machine/nvram.c b/src/emu/machine/nvram.c index 751c1c40c83..4ddacf04bc1 100644 --- a/src/emu/machine/nvram.c +++ b/src/emu/machine/nvram.c @@ -140,15 +140,6 @@ void nvram_device::device_start() // bind our handler if (!m_config.m_custom_handler.isnull()) m_custom_handler = nvram_init_delegate(m_config.m_custom_handler, *m_owner); - - // find our shared pointer with the target RAM - m_base = memory_get_shared(m_machine, tag(), m_length); - if (m_base == NULL) - throw emu_fatalerror("NVRAM device '%s' has no corresponding AM_SHARE region", tag()); - - // if we are region-backed for the default, find it now and make sure it's the right size - if (m_region != NULL && m_region->bytes() != m_length) - throw emu_fatalerror("NVRAM device '%s' has a default region, but it should be 0x%X bytes", tag(), m_length); } @@ -159,6 +150,9 @@ void nvram_device::device_start() void nvram_device::nvram_default() { + // make sure we have a valid base pointer + determine_final_base(); + // region always wins if (m_region != NULL) { @@ -204,6 +198,9 @@ void nvram_device::nvram_default() void nvram_device::nvram_read(mame_file &file) { + // make sure we have a valid base pointer + determine_final_base(); + mame_fread(&file, m_base, m_length); } @@ -217,3 +214,25 @@ void nvram_device::nvram_write(mame_file &file) { mame_fwrite(&file, m_base, m_length); } + + +//------------------------------------------------- +// determine_final_base - get the final base +// pointer by looking up the memory share, unless +// a pointer was provided to us +//------------------------------------------------- + +void nvram_device::determine_final_base() +{ + // find our shared pointer with the target RAM + if (m_base == NULL) + { + m_base = memory_get_shared(m_machine, tag(), m_length); + if (m_base == NULL) + throw emu_fatalerror("NVRAM device '%s' has no corresponding AM_SHARE region", tag()); + } + + // if we are region-backed for the default, find it now and make sure it's the right size + if (m_region != NULL && m_region->bytes() != m_length) + throw emu_fatalerror("NVRAM device '%s' has a default region, but it should be 0x%X bytes", tag(), m_length); +} |