From 7870e6d5392172714738da99ced2c6b9db1f935e Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 26 Jun 2016 13:03:08 -0400 Subject: [PATCH] Delegatize dasm overrides (nw) --- src/emu/didisasm.cpp | 19 +++++++++++++++---- src/emu/didisasm.h | 11 +++++++---- src/mame/drivers/palm.cpp | 2 +- src/mame/includes/coco.h | 2 +- src/mame/includes/mac.h | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/emu/didisasm.cpp b/src/emu/didisasm.cpp index ef3882cba8b..875b2bfef5e 100644 --- a/src/emu/didisasm.cpp +++ b/src/emu/didisasm.cpp @@ -21,7 +21,6 @@ device_disasm_interface::device_disasm_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "disasm") - , m_dasm_override(nullptr) { } @@ -35,12 +34,24 @@ device_disasm_interface::~device_disasm_interface() } +//------------------------------------------------- +// interface_pre_start - work to be done prior to +// actually starting a device +//------------------------------------------------- + +void device_disasm_interface::interface_pre_start() +{ + // bind delegate + m_dasm_override.bind_relative_to(*device().owner()); +} + + //------------------------------------------------- // static_set_dasm_override - configuration // helper to override disassemble function //------------------------------------------------- -void device_disasm_interface::static_set_dasm_override(device_t &device, dasm_override_func dasm_override) +void device_disasm_interface::static_set_dasm_override(device_t &device, dasm_override_delegate dasm_override) { device_disasm_interface *dasm; if (!device.interface(dasm)) @@ -58,8 +69,8 @@ offs_t device_disasm_interface::disassemble(char *buffer, offs_t pc, const UINT8 offs_t result = 0; // check for disassembler override - if (m_dasm_override != nullptr) - result = (*m_dasm_override)(device(), buffer, pc, oprom, opram, options); + if (!m_dasm_override.isnull()) + result = m_dasm_override(device(), buffer, pc, oprom, opram, options); if (result == 0) result = disasm_disassemble(buffer, pc, oprom, opram, options); diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h index 7e1bedceeac..f91438a071c 100644 --- a/src/emu/didisasm.h +++ b/src/emu/didisasm.h @@ -45,7 +45,7 @@ const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain t //************************************************************************** #define MCFG_DEVICE_DISASSEMBLE_OVERRIDE(_class, _func) \ - device_disasm_interface::static_set_dasm_override(*device, &_class::_func); + device_disasm_interface::static_set_dasm_override(*device, dasm_override_delegate(&_class::_func, #_class "::" #_func, nullptr, (_class *)nullptr)); @@ -53,13 +53,13 @@ const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain t // TYPE DEFINITIONS //************************************************************************** +typedef device_delegate dasm_override_delegate; // ======================> device_disasm_interface // class representing interface-specific live disasm class device_disasm_interface : public device_interface { - typedef offs_t (*dasm_override_func)(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); public: // construction/destruction @@ -71,7 +71,7 @@ public: UINT32 max_opcode_bytes() const { return disasm_max_opcode_bytes(); } // static inline configuration helpers - static void static_set_dasm_override(device_t &device, dasm_override_func dasm_override); + static void static_set_dasm_override(device_t &device, dasm_override_delegate dasm_override); // interface for disassembly offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options = 0); @@ -82,8 +82,11 @@ protected: virtual UINT32 disasm_max_opcode_bytes() const = 0; virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) = 0; + // interface-level overrides + virtual void interface_pre_start(); + private: - dasm_override_func m_dasm_override; // pointer to provided override function + dasm_override_delegate m_dasm_override; // provided override function }; // iterator diff --git a/src/mame/drivers/palm.cpp b/src/mame/drivers/palm.cpp index 5f0e74dc5f8..f60d74674d2 100644 --- a/src/mame/drivers/palm.cpp +++ b/src/mame/drivers/palm.cpp @@ -64,7 +64,7 @@ public: required_ioport m_io_penb; required_ioport m_io_portd; - static offs_t palm_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); + offs_t palm_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); }; diff --git a/src/mame/includes/coco.h b/src/mame/includes/coco.h index 95e9eb51eef..642c05c3d93 100644 --- a/src/mame/includes/coco.h +++ b/src/mame/includes/coco.h @@ -142,7 +142,7 @@ public: DECLARE_WRITE_LINE_MEMBER( cart_w ) { cart_w((bool) state); } // disassembly override - static offs_t dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); + offs_t dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); protected: // device-level overrides diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h index 99df423e901..f68432b1088 100644 --- a/src/mame/includes/mac.h +++ b/src/mame/includes/mac.h @@ -557,7 +557,7 @@ public: void mac_driver_init(model_t model); void mac_install_memory(offs_t memory_begin, offs_t memory_end, offs_t memory_size, void *memory_data, int is_rom, const char *bank); - static offs_t mac_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); + offs_t mac_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); }; #endif /* MAC_H_ */