distate: don't try to read unused value() during formatstr

This commit is contained in:
hap 2023-01-02 01:08:01 +01:00
parent 2bfe2358fb
commit 47a484001c
4 changed files with 15 additions and 18 deletions

View file

@ -341,7 +341,7 @@ void tms99xx_device::state_import(const device_state_entry &entry)
break;
default:
// Workspace registers
if (index <= TMS9900_R15 && started())
if (index <= TMS9900_R15)
write_workspace_register_debug(index-TMS9900_R0, (uint16_t)m_state_any);
break;
}
@ -373,7 +373,7 @@ void tms99xx_device::state_export(const device_state_entry &entry)
default:
// Workspace registers
if (index <= TMS9900_R15)
m_state_any = started() ? read_workspace_register_debug(index-TMS9900_R0) : 0;
m_state_any = read_workspace_register_debug(index-TMS9900_R0);
break;
}
}

View file

@ -339,7 +339,7 @@ void tms9995_device::state_import(const device_state_entry &entry)
break;
default:
// Workspace registers
if (index <= TMS9995_R15 && started())
if (index <= TMS9995_R15)
write_workspace_register_debug(index-TMS9995_R0, (uint16_t)m_state_any);
break;
}
@ -371,7 +371,7 @@ void tms9995_device::state_export(const device_state_entry &entry)
default:
// Workspace registers
if (index <= TMS9995_R15)
m_state_any = started() ? read_workspace_register_debug(index-TMS9995_R0) : 0;
m_state_any = read_workspace_register_debug(index-TMS9995_R0);
break;
}
}

View file

@ -101,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;
}
@ -201,12 +201,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 = value();
// parse the format
std::string dest;
bool leadzero = false;
bool percent = false;
bool explicitsign = false;
@ -400,7 +398,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());
}
@ -412,7 +410,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("", value(), true).length();
}

View file

@ -104,7 +104,7 @@ protected:
private:
// helpers
void format_from_mask();
std::string format(const char *string, bool maxout = false) const;
std::string format(const char *string, u64 result, bool maxout = false) const;
// statics
static const u64 k_decimal_divisor[20]; // divisors for outputting decimal values
@ -362,8 +362,7 @@ protected:
// state
std::vector<std::unique_ptr<device_state_entry>> m_state_list; // head of state list
device_state_entry * m_fast_state[FAST_STATE_MAX + 1 - FAST_STATE_MIN];
// fast access to common entries
device_state_entry *m_fast_state[FAST_STATE_MAX + 1 - FAST_STATE_MIN]; // fast access to common entries
};
// iterator