summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/fd1094.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
committer AJR <ajrhacker@users.noreply.github.com>2016-04-07 18:59:38 -0400
commitc0f366c61374775f8f8b7661e84705b568134dea (patch)
tree626e95fa31e6e8480983abbe305c0415ded783d2 /src/mame/machine/fd1094.cpp
parent5933d47ed740fd08c2f66f37fdca4f95e08df3d4 (diff)
Devfind revision phase 1, cleaning out some legacy stuff
- Eliminate the cached device_t::m_region pointer and its region() getter method. Devices that need to bind to a region with the same tag should use optional/required_memory_region or optional/required_region_ptr with DEVICE_SELF as the subtag; this improves error checking. (DEVICE_SELF has been moved to device.h for greater visibility in the source.) - Allow required/optional_region_ptr to specify a specific length which must match that of the region found. - Implement finder_base::finder_tag() getter for diagnostic purposes. - Perform some (not very efficient) validity checks on memory region finders instead of allowing them to automatically pass. - Privatize device_memory_interface::m_addrspace.
Diffstat (limited to 'src/mame/machine/fd1094.cpp')
-rw-r--r--src/mame/machine/fd1094.cpp36
1 files changed, 9 insertions, 27 deletions
diff --git a/src/mame/machine/fd1094.cpp b/src/mame/machine/fd1094.cpp
index 9dc3009cd31..7616adcd0b9 100644
--- a/src/mame/machine/fd1094.cpp
+++ b/src/mame/machine/fd1094.cpp
@@ -558,9 +558,8 @@ fd1094_device::fd1094_device(const machine_config &mconfig, const char *tag, dev
m_state(0x00),
m_irqmode(false),
m_cache(*this),
- m_srcbase(nullptr),
- m_srcbytes(0),
- m_key(nullptr)
+ m_srcbase(*this, DEVICE_SELF),
+ m_key(*this, "key")
{
// override the name after the m68000 initializes
m_name.assign("FD1094");
@@ -634,35 +633,18 @@ void fd1094_device::change_state(int newstate)
void fd1094_device::device_start()
{
- // find the key
- m_key = memregion("key")->base();
- if (m_key == nullptr)
- throw emu_fatalerror("FD1094 key region not found!");
-
- // get a pointer to the ROM region
- if (region() != nullptr)
- {
- m_srcbase = reinterpret_cast<UINT16 *>(region()->base());
- m_srcbytes = region()->bytes();
- }
-
// if no ROM region, see if there's a memory share with our name
- else
+ if (!m_srcbase.found())
{
- memory_share *share = owner()->memshare(tag());
+ memory_share *share = memshare(DEVICE_SELF);
if (share != nullptr)
- {
- m_srcbase = reinterpret_cast<UINT16 *>(share->ptr());
- m_srcbytes = share->bytes();
- }
+ m_srcbase.set_target(reinterpret_cast<UINT16 *>(share->ptr()), share->bytes() / 2);
+ else
+ throw emu_fatalerror("FD1094 found no data to decrypt!");
}
- // if we got nothing, error
- if (m_srcbase == nullptr)
- throw emu_fatalerror("FD1094 found no data to decrypt!");
-
// determine length and configure our cache
- m_cache.configure(0x000000, m_srcbytes, 0x000000);
+ m_cache.configure(0x000000, m_srcbase.bytes(), 0x000000);
change_state(STATE_RESET);
// start the base device
@@ -907,7 +889,7 @@ UINT16 fd1094_device::decrypt_one(offs_t address, UINT16 val, const UINT8 *main_
void fd1094_device::decrypt(offs_t baseaddr, UINT32 size, const UINT16 *srcptr, UINT16 *opcodesptr, UINT8 state)
{
for (offs_t offset = 0; offset < size; offset += 2)
- opcodesptr[offset / 2] = decrypt_one((baseaddr + offset) / 2, srcptr[offset / 2], m_key, state, (baseaddr + offset) < 8);
+ opcodesptr[offset / 2] = decrypt_one((baseaddr + offset) / 2, srcptr[offset / 2], &m_key[0], state, (baseaddr + offset) < 8);
}