Define new macro ALLOW_SAVE_TYPE which can be used to declare enums as

valid save types on a case-by-case basis.

Updated the cosmac CPU core to do this for its mode and state enums,
which were previously failing.
This commit is contained in:
Aaron Giles 2011-02-10 07:25:44 +00:00
parent dd574a314a
commit c7ff741eb9
3 changed files with 30 additions and 18 deletions

View File

@ -22,6 +22,11 @@
*/
// permit our enums to be saved
ALLOW_SAVE_TYPE(cosmac_device::cosmac_mode);
ALLOW_SAVE_TYPE(cosmac_device::cosmac_state);
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************

View File

@ -348,17 +348,16 @@ protected:
devcb_resolved_write_line m_out_tpb_func;
// control modes
enum _cosmac_mode
enum cosmac_mode
{
COSMAC_MODE_LOAD = 0,
COSMAC_MODE_RESET,
COSMAC_MODE_PAUSE,
COSMAC_MODE_RUN
};
typedef enum _cosmac_mode cosmac_mode;
// execution states
enum _cosmac_state
enum cosmac_state
{
COSMAC_STATE_0_FETCH = 0,
COSMAC_STATE_1_RESET,
@ -368,7 +367,6 @@ protected:
COSMAC_STATE_2_DMA_OUT,
COSMAC_STATE_3_INT
};
typedef enum _cosmac_state cosmac_state;
// internal state
UINT8 m_op; // current opcode
@ -411,5 +409,4 @@ protected:
};
#endif /* __COSMAC_H__ */

View File

@ -67,10 +67,12 @@ enum state_save_error
// MACROS
//**************************************************************************
// macros to declare presave/postload functions with the appropriate parameters
#define STATE_PRESAVE(name) void name(running_machine *machine, void *param)
#define STATE_POSTLOAD(name) void name(running_machine *machine, void *param)
// templates to assume the 'param' of a presave/postload function is a class pointer
template<class T, void (T::*func)()>
void state_presave_stub(running_machine *machine, void *param)
{
@ -86,6 +88,13 @@ void state_postload_stub(running_machine *machine, void *param)
}
// use this to declare a given type is a simple, non-pointer type that can be
// saved; in general, this is intended only to be used for specific enum types
// defined by your device
#define ALLOW_SAVE_TYPE(TYPE) template<> struct state_manager::type_checker<TYPE> { static const bool is_atom = true; static const bool is_pointer = false; }
// register items with explicit tags
#define state_save_register_item(_mach, _mod, _tag, _index, _val) \
(_mach)->state().save_item(_mod, _tag, _index, _val, #_val)
@ -254,19 +263,20 @@ private:
// template specializations to enumerate the fundamental atomic types you are allowed to save
template<> struct state_manager::type_checker<bool> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<INT8> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<UINT8> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<INT16> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<UINT16> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<INT32> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<UINT32> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<INT64> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<UINT64> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<PAIR> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<PAIR64> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<float> { static const bool is_atom = true; static const bool is_pointer = false; };
template<> struct state_manager::type_checker<double> { static const bool is_atom = true; static const bool is_pointer = false; };
ALLOW_SAVE_TYPE(bool);
ALLOW_SAVE_TYPE(INT8);
ALLOW_SAVE_TYPE(UINT8);
ALLOW_SAVE_TYPE(INT16);
ALLOW_SAVE_TYPE(UINT16);
ALLOW_SAVE_TYPE(INT32);
ALLOW_SAVE_TYPE(UINT32);
ALLOW_SAVE_TYPE(INT64);
ALLOW_SAVE_TYPE(UINT64);
ALLOW_SAVE_TYPE(PAIR);
ALLOW_SAVE_TYPE(PAIR64);
ALLOW_SAVE_TYPE(float);
ALLOW_SAVE_TYPE(double);
ALLOW_SAVE_TYPE(endianness_t);