mirror of
https://github.com/holub/mame
synced 2025-05-23 22:20:01 +03:00
Put the state list in a simple_list<>.
This commit is contained in:
parent
2dbd6f67f8
commit
7e98d6e583
@ -263,7 +263,7 @@ void legacy_cpu_device::device_start()
|
||||
m_inited = true;
|
||||
|
||||
// fetch information about the CPU states
|
||||
if (m_state_list == NULL)
|
||||
if (m_state_list.count() == 0)
|
||||
{
|
||||
m_using_legacy_state = true;
|
||||
for (int index = 0; index < MAX_REGS; index++)
|
||||
|
@ -410,8 +410,7 @@ device_config_state_interface::~device_config_state_interface()
|
||||
device_state_interface::device_state_interface(running_machine &machine, const device_config &config, device_t &device)
|
||||
: device_interface(machine, config, device),
|
||||
m_machine(machine),
|
||||
m_state_config(dynamic_cast<const device_config_state_interface &>(config)),
|
||||
m_state_list(NULL)
|
||||
m_state_config(dynamic_cast<const device_config_state_interface &>(config))
|
||||
{
|
||||
memset(m_fast_state, 0, sizeof(m_fast_state));
|
||||
}
|
||||
@ -584,9 +583,7 @@ device_state_entry &device_state_interface::state_add(int index, const char *sym
|
||||
device_state_entry *entry = auto_alloc(&m_machine, device_state_entry(index, symbol, data, size));
|
||||
|
||||
// append to the end of the list
|
||||
device_state_entry **tailptr;
|
||||
for (tailptr = &m_state_list; *tailptr != NULL; tailptr = &(*tailptr)->m_next) ;
|
||||
*tailptr = entry;
|
||||
m_state_list.append(*entry);
|
||||
|
||||
// set the fast entry if applicable
|
||||
if (index >= k_fast_state_min && index <= k_fast_state_max)
|
||||
@ -608,7 +605,7 @@ const device_state_entry *device_state_interface::state_find_entry(int index)
|
||||
return m_fast_state[index - k_fast_state_min];
|
||||
|
||||
// otherwise, scan the first
|
||||
for (const device_state_entry *entry = m_state_list; entry != NULL; entry = entry->m_next)
|
||||
for (const device_state_entry *entry = m_state_list.first(); entry != NULL; entry = entry->m_next)
|
||||
if (entry->m_index == index)
|
||||
return entry;
|
||||
|
||||
@ -625,6 +622,6 @@ const device_state_entry *device_state_interface::state_find_entry(int index)
|
||||
void device_state_interface::interface_post_start()
|
||||
{
|
||||
// make sure we got something during startup
|
||||
if (m_state_list == NULL)
|
||||
if (m_state_list.count() == 0)
|
||||
throw emu_fatalerror("No state registered for device '%s' that supports it!", m_device.tag());
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ enum
|
||||
class device_state_entry
|
||||
{
|
||||
friend class device_state_interface;
|
||||
friend class simple_list<device_state_entry>;
|
||||
|
||||
private:
|
||||
// construction/destruction
|
||||
@ -161,7 +162,7 @@ public:
|
||||
|
||||
// configuration access
|
||||
const device_config_state_interface &state_config() const { return m_state_config; }
|
||||
const device_state_entry *state_first() const { return m_state_list; }
|
||||
const device_state_entry *state_first() const { return m_state_list.first(); }
|
||||
|
||||
// state getters
|
||||
UINT64 state(int index);
|
||||
@ -205,7 +206,7 @@ protected:
|
||||
// state
|
||||
running_machine & m_machine; // reference to owning machine
|
||||
const device_config_state_interface & m_state_config; // reference to configuration data
|
||||
device_state_entry * m_state_list; // head of state list
|
||||
simple_list<device_state_entry> m_state_list; // head of state list
|
||||
device_state_entry * m_fast_state[k_fast_state_max + 1 - k_fast_state_min];
|
||||
// fast access to common entries
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user