diff options
Diffstat (limited to 'src/emu/output.h')
-rw-r--r-- | src/emu/output.h | 150 |
1 files changed, 78 insertions, 72 deletions
diff --git a/src/emu/output.h b/src/emu/output.h index d4a442f6636..77798c1eaf1 100644 --- a/src/emu/output.h +++ b/src/emu/output.h @@ -23,77 +23,83 @@ typedef void (*output_notifier_func)(const char *outname, INT32 value, void *param); +// ======================> output_manager - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -/* core initialization */ -void output_init(running_machine &machine); - -/* set the value for a given output */ -void output_set_value(const char *outname, INT32 value); - -/* set an indexed value for an output (concatenates basename + index) */ -void output_set_indexed_value(const char *basename, int index, int value); - -/* return the current value for a given output */ -INT32 output_get_value(const char *outname); - -/* return the current value for a given indexed output */ -INT32 output_get_indexed_value(const char *outname, int index); - -/* set a notifier on a particular output, or globally if NULL */ -void output_set_notifier(const char *outname, output_notifier_func callback, void *param); - -/* set a notifier on a particular output, or globally if NULL */ -void output_notify_all(output_notifier_func callback, void *param); - -/* map a name to a unique ID */ -UINT32 output_name_to_id(const char *outname); - -/* map a unique ID back to a name */ -const char *output_id_to_name(UINT32 id); - -/* set the status of an LED */ -void set_led_status(running_machine &machine, int num, int value); - - -/*************************************************************************** - INLINES -***************************************************************************/ - -static inline void output_set_led_value(int index, int value) -{ - output_set_indexed_value("led", index, value ? 1 : 0); -} - -static inline void output_set_lamp_value(int index, int value) +class output_manager { - output_set_indexed_value("lamp", index, value); -} - -static inline void output_set_digit_value(int index, int value) -{ - output_set_indexed_value("digit", index, value); -} - - -static inline INT32 output_get_led_value(int index) -{ - return output_get_indexed_value("led", index); -} - -static inline INT32 output_get_lamp_value(int index) -{ - return output_get_indexed_value("lamp", index); -} - -static inline INT32 output_get_digit_value(int index) -{ - return output_get_indexed_value("digit", index); -} - - -#endif /* __OUTPUT_H__ */ + class output_notify + { + public: + output_notify(output_notifier_func callback, void *param) + : m_notifier(callback), + m_param(param) { } + + output_notifier_func m_notifier; // callback to call + void * m_param; // parameter to pass the callback + }; + + + class output_item + { + public: + std::string name; // string name of the item + UINT32 hash; // hash for this item name + UINT32 id; // unique ID for this item + INT32 value; // current value + std::vector<output_notify> notifylist; // list of notifier callbacks + }; + +public: + // construction/destruction + output_manager(running_machine &machine); + + // getters + running_machine &machine() const { return m_machine; } + + // set the value for a given output + void set_value(const char *outname, INT32 value); + + // set an indexed value for an output (concatenates basename + index) + void set_indexed_value(const char *basename, int index, int value); + + // return the current value for a given output + INT32 get_value(const char *outname); + + // return the current value for a given indexed output + INT32 get_indexed_value(const char *outname, int index); + + // set a notifier on a particular output, or globally if NULL + void set_notifier(const char *outname, output_notifier_func callback, void *param); + + // set a notifier on a particular output, or globally if NULL + void notify_all(output_notifier_func callback, void *param); + + // map a name to a unique ID + UINT32 name_to_id(const char *outname); + + // map a unique ID back to a name + const char *id_to_name(UINT32 id); + + + // helpers + void set_led_value(int index, int value) { set_indexed_value("led", index, value ? 1 : 0); } + void set_lamp_value(int index, int value) { set_indexed_value("lamp", index, value); } + void set_digit_value(int index, int value) { set_indexed_value("digit", index, value); } + INT32 get_led_value(int index) { return get_indexed_value("led", index); } + INT32 get_lamp_value(int index) { return get_indexed_value("lamp", index); } + INT32 get_digit_value(int index) { return get_indexed_value("digit", index); } + + void pause(); + void resume(); +private: + output_item *find_item(const char *string); + output_item *create_new_item(const char *outname, INT32 value); + + // internal state + running_machine & m_machine; // reference to our machine + std::unordered_map<std::string,output_item> m_itemtable; + std::vector<output_notify> m_global_notifylist; + UINT32 m_uniqueid; +}; + +#endif // __OUTPUT_H__ |