summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/distate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/distate.cpp')
-rw-r--r--src/emu/distate.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/emu/distate.cpp b/src/emu/distate.cpp
index 06e3d1947af..76ede23dfe2 100644
--- a/src/emu/distate.cpp
+++ b/src/emu/distate.cpp
@@ -65,8 +65,6 @@ device_state_entry::device_state_entry(int index, const char *symbol, u8 size, u
// override well-known symbols
if (index == STATE_GENPCBASE)
m_symbol.assign("CURPC");
- else if (index == STATE_GENSP)
- m_symbol.assign("CURSP");
else if (index == STATE_GENFLAGS)
m_symbol.assign("CURFLAGS");
}
@@ -103,7 +101,7 @@ device_state_entry &device_state_entry::formatstr(const char *_format)
// set the DSF_CUSTOM_STRING flag by formatting with a nullptr string
m_flags &= ~DSF_CUSTOM_STRING;
- format(nullptr);
+ format(nullptr, 0);
return *this;
}
@@ -128,10 +126,8 @@ void device_state_entry::format_from_mask()
// make up a format based on the mask
if (m_datamask == 0)
- throw emu_fatalerror("%s state entry requires a nonzero mask\n", m_symbol.c_str());
- int width = 0;
- for (u64 tempmask = m_datamask; tempmask != 0; tempmask >>= 4)
- width++;
+ throw emu_fatalerror("%s state entry requires a nonzero mask\n", m_symbol);
+ int width = (63 - count_leading_zeros_64(m_datamask)) / 4 + 1;
m_format = string_format("%%0%dX", width);
}
@@ -203,12 +199,10 @@ double device_state_entry::entry_dvalue() const
// pieces of indexed state as a string
//-------------------------------------------------
-std::string device_state_entry::format(const char *string, bool maxout) const
+std::string device_state_entry::format(const char *string, u64 result, bool maxout) const
{
- std::string dest;
- u64 result = entry_value() & m_datamask;
-
// parse the format
+ std::string dest;
bool leadzero = false;
bool percent = false;
bool explicitsign = false;
@@ -331,18 +325,18 @@ std::string device_state_entry::format(const char *string, bool maxout) const
width--;
}
// fall through to unsigned case
-
+ [[fallthrough]];
// u outputs as unsigned decimal
case 'u':
if (width == 0)
throw emu_fatalerror("Width required for %%u formats\n");
hitnonzero = false;
- while (leadzero && width > ARRAY_LENGTH(k_decimal_divisor))
+ while (leadzero && width > std::size(k_decimal_divisor))
{
dest.append(" ");
width--;
}
- for (int digitnum = ARRAY_LENGTH(k_decimal_divisor) - 1; digitnum >= 0; digitnum--)
+ for (int digitnum = std::size(k_decimal_divisor) - 1; digitnum >= 0; digitnum--)
{
int digit = (result >= k_decimal_divisor[digitnum]) ? (result / k_decimal_divisor[digitnum]) % 10 : 0;
if (digit != 0)
@@ -402,7 +396,7 @@ std::string device_state_entry::to_string() const
custom = string_format("%-12G", entry_dvalue());
// ask the entry to format itself
- return format(custom.c_str());
+ return format(custom.c_str(), value());
}
@@ -414,7 +408,7 @@ std::string device_state_entry::to_string() const
int device_state_entry::max_length() const
{
// ask the entry to format itself maximally
- return format("", true).length();
+ return format("", 0, true).length();
}
@@ -491,9 +485,6 @@ device_state_interface::device_state_interface(const machine_config &mconfig, de
: device_interface(device, "state")
{
memset(m_fast_state, 0, sizeof(m_fast_state));
-
- // configure the fast accessor
- device.interfaces().m_state = this;
}