Put the state list in a simple_list<>.

This commit is contained in:
Aaron Giles 2010-09-07 04:51:51 +00:00
parent 2dbd6f67f8
commit 7e98d6e583
3 changed files with 8 additions and 10 deletions

View File

@ -263,7 +263,7 @@ void legacy_cpu_device::device_start()
m_inited = true; m_inited = true;
// fetch information about the CPU states // fetch information about the CPU states
if (m_state_list == NULL) if (m_state_list.count() == 0)
{ {
m_using_legacy_state = true; m_using_legacy_state = true;
for (int index = 0; index < MAX_REGS; index++) for (int index = 0; index < MAX_REGS; index++)

View File

@ -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_state_interface::device_state_interface(running_machine &machine, const device_config &config, device_t &device)
: device_interface(machine, config, device), : device_interface(machine, config, device),
m_machine(machine), m_machine(machine),
m_state_config(dynamic_cast<const device_config_state_interface &>(config)), m_state_config(dynamic_cast<const device_config_state_interface &>(config))
m_state_list(NULL)
{ {
memset(m_fast_state, 0, sizeof(m_fast_state)); 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)); device_state_entry *entry = auto_alloc(&m_machine, device_state_entry(index, symbol, data, size));
// append to the end of the list // append to the end of the list
device_state_entry **tailptr; m_state_list.append(*entry);
for (tailptr = &m_state_list; *tailptr != NULL; tailptr = &(*tailptr)->m_next) ;
*tailptr = entry;
// set the fast entry if applicable // set the fast entry if applicable
if (index >= k_fast_state_min && index <= k_fast_state_max) 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]; return m_fast_state[index - k_fast_state_min];
// otherwise, scan the first // 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) if (entry->m_index == index)
return entry; 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() void device_state_interface::interface_post_start()
{ {
// make sure we got something during startup // 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()); throw emu_fatalerror("No state registered for device '%s' that supports it!", m_device.tag());
} }

View File

@ -73,6 +73,7 @@ enum
class device_state_entry class device_state_entry
{ {
friend class device_state_interface; friend class device_state_interface;
friend class simple_list<device_state_entry>;
private: private:
// construction/destruction // construction/destruction
@ -161,7 +162,7 @@ public:
// configuration access // configuration access
const device_config_state_interface &state_config() const { return m_state_config; } 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 // state getters
UINT64 state(int index); UINT64 state(int index);
@ -205,7 +206,7 @@ protected:
// state // state
running_machine & m_machine; // reference to owning machine running_machine & m_machine; // reference to owning machine
const device_config_state_interface & m_state_config; // reference to configuration data 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]; device_state_entry * m_fast_state[k_fast_state_max + 1 - k_fast_state_min];
// fast access to common entries // fast access to common entries
}; };