From 38c4b762f03769155fb8f8d2ce7c9dd47ece5f46 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 24 Jun 2016 22:34:13 -0400 Subject: [PATCH 1/3] Move disasm overrides into interface, reducing driver-debugger dependencies (nw) --- src/emu/debug/debugcpu.cpp | 15 +++++---------- src/emu/debug/debugcpu.h | 6 ------ src/emu/devcpu.h | 2 ++ src/emu/didisasm.cpp | 33 +++++++++++++++++++++++++++++++++ src/emu/didisasm.h | 19 ++++++++++++++++++- src/mame/drivers/coco12.cpp | 1 + src/mame/drivers/coco3.cpp | 1 + src/mame/drivers/mac.cpp | 23 +++++++++++++++++++++++ src/mame/drivers/palm.cpp | 10 +++------- src/mame/drivers/palm_dbg.hxx | 2 +- src/mame/includes/coco.h | 7 ++++--- src/mame/includes/dgn_beta.h | 2 ++ src/mame/includes/mac.h | 1 + src/mame/machine/coco.cpp | 7 ------- src/mame/machine/dgn_beta.cpp | 10 +--------- src/mame/machine/mac.cpp | 10 +--------- 16 files changed, 96 insertions(+), 53 deletions(-) diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 021d745d0ec..9dcb1ee68f5 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1631,7 +1631,6 @@ device_debug::device_debug(device_t &device) , m_flags(0) , m_symtable(&device, device.machine().debugger().cpu().get_global_symtable()) , m_instrhook(nullptr) - , m_dasm_override(nullptr) , m_stepaddr(0) , m_stepsleft(0) , m_stopaddr(0) @@ -1984,20 +1983,16 @@ void device_debug::set_instruction_hook(debug_instruction_hook_func hook) offs_t device_debug::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) const { - offs_t result = 0; - - // check for disassembler override - if (m_dasm_override != nullptr) - result = (*m_dasm_override)(m_device, buffer, pc, oprom, opram, 0); + if (m_disasm == nullptr) + return 0; // if we have a disassembler, run it - if (result == 0 && m_disasm != nullptr) - result = m_disasm->disassemble(buffer, pc, oprom, opram, 0); + offs_t result = m_disasm->disassemble(buffer, pc, oprom, opram, 0); // make sure we get good results - assert((result & DASMFLAG_LENGTHMASK) != 0 || m_disasm == nullptr); + assert((result & DASMFLAG_LENGTHMASK) != 0); #ifdef MAME_DEBUG - if (m_memory != nullptr && m_disasm != nullptr) + if (m_memory != nullptr) { address_space &space = m_memory->space(AS_PROGRAM); int bytes = space.address_to_byte(result & DASMFLAG_LENGTHMASK); diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 757fc57649a..3a0453b72cc 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -46,8 +46,6 @@ struct xml_data_node; class device_debug { - typedef offs_t (*dasm_override_func)(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); - public: // breakpoint class class breakpoint @@ -186,7 +184,6 @@ public: // hooks into our operations void set_instruction_hook(debug_instruction_hook_func hook); - void set_dasm_override(dasm_override_func dasm_override) { m_dasm_override = dasm_override; } // disassembly offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) const; @@ -316,9 +313,6 @@ private: symbol_table m_symtable; // symbol table for expression evaluation debug_instruction_hook_func m_instrhook; // per-instruction callback hook - // disassembly - dasm_override_func m_dasm_override; // pointer to provided override function - // stepping information offs_t m_stepaddr; // step target address for DEBUG_FLAG_STEPPING_OVER int m_stepsleft; // number of steps left until done diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index 1ee234c3d12..d2f4a1f1394 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -41,6 +41,8 @@ #define MCFG_CPU_PERIODIC_INT_REMOVE MCFG_DEVICE_PERIODIC_INT_REMOVE #define MCFG_CPU_IRQ_ACKNOWLEDGE_REMOVE MCFG_DEVICE_IRQ_ACKNOWLEDGE_REMOVE +#define MCFG_CPU_DISASSEMBLE_OVERRIDE MCFG_DEVICE_DISASSEMBLE_OVERRIDE + // recompilation parameters #define MCFG_CPU_FORCE_NO_DRC() \ cpu_device::static_set_force_no_drc(*device, true); diff --git a/src/emu/didisasm.cpp b/src/emu/didisasm.cpp index 9abca9e3f96..ef3882cba8b 100644 --- a/src/emu/didisasm.cpp +++ b/src/emu/didisasm.cpp @@ -21,6 +21,7 @@ device_disasm_interface::device_disasm_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "disasm") + , m_dasm_override(nullptr) { } @@ -32,3 +33,35 @@ device_disasm_interface::device_disasm_interface(const machine_config &mconfig, device_disasm_interface::~device_disasm_interface() { } + + +//------------------------------------------------- +// 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) +{ + device_disasm_interface *dasm; + if (!device.interface(dasm)) + throw emu_fatalerror("MCFG_DEVICE_DISASSEMBLE_OVERRIDE called on device '%s' with no disasm interface", device.tag()); + dasm->m_dasm_override = dasm_override; +} + + +//------------------------------------------------- +// disassemble - interface for disassembly +//------------------------------------------------- + +offs_t device_disasm_interface::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) +{ + offs_t result = 0; + + // check for disassembler override + if (m_dasm_override != nullptr) + result = (*m_dasm_override)(device(), buffer, pc, oprom, opram, options); + if (result == 0) + result = disasm_disassemble(buffer, pc, oprom, opram, options); + + return result; +} diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h index 58cc00a7b11..7e1bedceeac 100644 --- a/src/emu/didisasm.h +++ b/src/emu/didisasm.h @@ -40,6 +40,15 @@ const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain t +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_DEVICE_DISASSEMBLE_OVERRIDE(_class, _func) \ + device_disasm_interface::static_set_dasm_override(*device, &_class::_func); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -50,6 +59,8 @@ const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain t // 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 device_disasm_interface(const machine_config &mconfig, device_t &device); @@ -59,14 +70,20 @@ public: UINT32 min_opcode_bytes() const { return disasm_min_opcode_bytes(); } 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); + // interface for disassembly - offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options = 0) { return disasm_disassemble(buffer, pc, oprom, opram, options); } + offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options = 0); protected: // required operation overrides virtual UINT32 disasm_min_opcode_bytes() const = 0; 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; + +private: + dasm_override_func m_dasm_override; // pointer to provided override function }; // iterator diff --git a/src/mame/drivers/coco12.cpp b/src/mame/drivers/coco12.cpp index b6c60660e53..bae50cb4dbd 100644 --- a/src/mame/drivers/coco12.cpp +++ b/src/mame/drivers/coco12.cpp @@ -294,6 +294,7 @@ static MACHINE_CONFIG_START( coco, coco12_state ) // basic machine hardware MCFG_CPU_ADD(MAINCPU_TAG, M6809E, XTAL_3_579545MHz) MCFG_CPU_PROGRAM_MAP(coco_mem) + MCFG_CPU_DISASSEMBLE_OVERRIDE(coco_state, dasm_override) // devices MCFG_DEVICE_ADD(PIA0_TAG, PIA6821, 0) diff --git a/src/mame/drivers/coco3.cpp b/src/mame/drivers/coco3.cpp index 83a23fe7fa9..cefb1940070 100644 --- a/src/mame/drivers/coco3.cpp +++ b/src/mame/drivers/coco3.cpp @@ -245,6 +245,7 @@ static MACHINE_CONFIG_START( coco3, coco3_state ) // basic machine hardware MCFG_CPU_ADD(MAINCPU_TAG, M6809E, XTAL_3_579545MHz) MCFG_CPU_PROGRAM_MAP(coco3_mem) + MCFG_CPU_DISASSEMBLE_OVERRIDE(coco_state, dasm_override) // devices MCFG_DEVICE_ADD(PIA0_TAG, PIA6821, 0) diff --git a/src/mame/drivers/mac.cpp b/src/mame/drivers/mac.cpp index 395c53057b8..616f357e53c 100644 --- a/src/mame/drivers/mac.cpp +++ b/src/mame/drivers/mac.cpp @@ -893,6 +893,7 @@ static MACHINE_CONFIG_START( mac512ke, mac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, C7M) /* 7.8336 MHz */ MCFG_CPU_PROGRAM_MAP(mac512ke_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_QUANTUM_TIME(attotime::from_hz(60)) /* video hardware */ @@ -1023,6 +1024,7 @@ static MACHINE_CONFIG_START( macprtb, mac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, C15M) MCFG_CPU_PROGRAM_MAP(macprtb_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_QUANTUM_TIME(attotime::from_hz(60)) /* video hardware */ @@ -1084,6 +1086,7 @@ static MACHINE_CONFIG_START( macii, mac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68020PMMU, C15M) MCFG_CPU_PROGRAM_MAP(macii_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_PALETTE_ADD("palette", 256) @@ -1153,6 +1156,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( maciihmu, macii ) MCFG_CPU_REPLACE("maincpu", M68020HMMU, C15M) MCFG_CPU_PROGRAM_MAP(macii_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MACHINE_CONFIG_END static MACHINE_CONFIG_START( maciifx, mac_state ) @@ -1160,6 +1164,7 @@ static MACHINE_CONFIG_START( maciifx, mac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68030, 40000000) MCFG_CPU_PROGRAM_MAP(maciifx_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") @@ -1221,6 +1226,7 @@ static MACHINE_CONFIG_DERIVED( maclc, macii ) MCFG_CPU_REPLACE("maincpu", M68020HMMU, C15M) MCFG_CPU_PROGRAM_MAP(maclc_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_PALETTE_MODIFY("palette") MCFG_PALETTE_ENTRIES(256) @@ -1277,6 +1283,7 @@ static MACHINE_CONFIG_DERIVED( maclc2, maclc ) MCFG_CPU_REPLACE("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(maclc_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") @@ -1301,6 +1308,7 @@ static MACHINE_CONFIG_DERIVED( maclc3, maclc ) MCFG_CPU_REPLACE("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(maclc3_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_VIDEO_START_OVERRIDE(mac_state,macsonora) MCFG_VIDEO_RESET_OVERRIDE(mac_state,macsonora) @@ -1341,6 +1349,7 @@ static MACHINE_CONFIG_DERIVED( maciivx, maclc ) MCFG_CPU_REPLACE("maincpu", M68030, C32M) MCFG_CPU_PROGRAM_MAP(maclc3_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_VIDEO_START_OVERRIDE(mac_state,macv8) MCFG_VIDEO_RESET_OVERRIDE(mac_state,macrbv) @@ -1376,6 +1385,7 @@ static MACHINE_CONFIG_DERIVED( maciivi, maclc ) MCFG_CPU_REPLACE("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(maclc3_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_VIDEO_START_OVERRIDE(mac_state,macv8) MCFG_VIDEO_RESET_OVERRIDE(mac_state,macrbv) @@ -1410,6 +1420,7 @@ static MACHINE_CONFIG_DERIVED( maciix, macii ) MCFG_CPU_REPLACE("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(macii_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("2M") @@ -1426,6 +1437,7 @@ static MACHINE_CONFIG_START( macse30, mac_state ) MCFG_CPU_ADD("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(macse30_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) /* video hardware */ MCFG_SCREEN_ADD(MAC_SCREEN_NAME, RASTER) @@ -1503,6 +1515,7 @@ static MACHINE_CONFIG_START( macpb140, mac_state ) MCFG_CPU_ADD("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(macpb140_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) /* video hardware */ MCFG_SCREEN_ADD(MAC_SCREEN_NAME, RASTER) @@ -1568,6 +1581,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( macpb145, macpb140 ) MCFG_CPU_REPLACE("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(macpb140_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") @@ -1578,6 +1592,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( macpb170, macpb140 ) MCFG_CPU_REPLACE("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(macpb140_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") @@ -1588,6 +1603,7 @@ static MACHINE_CONFIG_START( macpb160, mac_state ) MCFG_CPU_ADD("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(macpb160_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) /* video hardware */ MCFG_SCREEN_ADD(MAC_SCREEN_NAME, RASTER) @@ -1652,6 +1668,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( macpb180, macpb160 ) MCFG_CPU_REPLACE("maincpu", M68030, 33000000) MCFG_CPU_PROGRAM_MAP(macpb160_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") @@ -1661,6 +1678,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( macpb180c, macpb160 ) MCFG_CPU_REPLACE("maincpu", M68030, 33000000) MCFG_CPU_PROGRAM_MAP(macpb165c_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_SCREEN_MODIFY(MAC_SCREEN_NAME) MCFG_SCREEN_SIZE(800, 525) @@ -1676,6 +1694,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( macpd210, macpb160 ) MCFG_CPU_REPLACE("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(macpd210_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_RAM_MODIFY(RAM_TAG) MCFG_RAM_DEFAULT_SIZE("4M") @@ -1686,6 +1705,7 @@ static MACHINE_CONFIG_DERIVED( macclas2, maclc ) MCFG_CPU_REPLACE("maincpu", M68030, C15M) MCFG_CPU_PROGRAM_MAP(maclc_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_VIDEO_START_OVERRIDE(mac_state,macv8) MCFG_VIDEO_RESET_OVERRIDE(mac_state,maceagle) @@ -1715,6 +1735,7 @@ static MACHINE_CONFIG_DERIVED( maciici, macii ) MCFG_CPU_REPLACE("maincpu", M68030, 25000000) MCFG_CPU_PROGRAM_MAP(maciici_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_PALETTE_MODIFY("palette") MCFG_PALETTE_ENTRIES(256) @@ -1745,6 +1766,7 @@ static MACHINE_CONFIG_DERIVED( maciisi, macii ) MCFG_CPU_REPLACE("maincpu", M68030, 20000000) MCFG_CPU_PROGRAM_MAP(maciici_map) MCFG_CPU_VBLANK_INT_DRIVER(MAC_SCREEN_NAME, mac_state, mac_rbv_vbl) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_PALETTE_MODIFY("palette") MCFG_PALETTE_ENTRIES(256) @@ -1855,6 +1877,7 @@ static MACHINE_CONFIG_START( macqd700, mac_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68040, 25000000) MCFG_CPU_PROGRAM_MAP(quadra700_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(mac_state, mac_dasm_override) MCFG_SCREEN_ADD(MAC_SCREEN_NAME, RASTER) MCFG_SCREEN_REFRESH_RATE(75.08) diff --git a/src/mame/drivers/palm.cpp b/src/mame/drivers/palm.cpp index f00bf63e44d..5f0e74dc5f8 100644 --- a/src/mame/drivers/palm.cpp +++ b/src/mame/drivers/palm.cpp @@ -16,8 +16,6 @@ #include "machine/mc68328.h" #include "machine/ram.h" #include "sound/dac.h" -#include "debugger.h" -#include "debug/debugcpu.h" #include "rendlay.h" #define MC68328_TAG "dragonball" @@ -65,9 +63,9 @@ public: required_ioport m_io_peny; 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); + static offs_t palm_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); +}; /*************************************************************************** @@ -141,9 +139,6 @@ void palm_state::machine_start() save_item(NAME(m_port_f_latch)); save_item(NAME(m_spim_data)); - - if (m_maincpu->debug()) - m_maincpu->debug()->set_dasm_override(palm_dasm_override); } void palm_state::machine_reset() @@ -192,6 +187,7 @@ static MACHINE_CONFIG_START( palm, palm_state ) /* basic machine hardware */ MCFG_CPU_ADD( "maincpu", M68000, 32768*506 ) /* 16.580608 MHz */ MCFG_CPU_PROGRAM_MAP( palm_map) + MCFG_CPU_DISASSEMBLE_OVERRIDE(palm_state, palm_dasm_override) MCFG_QUANTUM_TIME( attotime::from_hz(60) ) diff --git a/src/mame/drivers/palm_dbg.hxx b/src/mame/drivers/palm_dbg.hxx index 8c89146b955..c964d96b291 100644 --- a/src/mame/drivers/palm_dbg.hxx +++ b/src/mame/drivers/palm_dbg.hxx @@ -1162,7 +1162,7 @@ static const char *lookup_trap(UINT16 opcode) return nullptr; } -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_state::palm_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) { UINT16 opcode; unsigned result = 0; diff --git a/src/mame/includes/coco.h b/src/mame/includes/coco.h index f083911afbc..95e9eb51eef 100644 --- a/src/mame/includes/coco.h +++ b/src/mame/includes/coco.h @@ -140,6 +140,10 @@ public: DECLARE_READ8_MEMBER( floating_bus_read ) { return floating_bus_read(); } 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); + protected: // device-level overrides virtual void device_start() override; @@ -228,9 +232,6 @@ private: // floating bus UINT8 floating_bus_read(void); - // disassembly override - static offs_t dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); - // input ports ioport_port *m_keyboard[7]; ioport_port *m_joystick_type_control; diff --git a/src/mame/includes/dgn_beta.h b/src/mame/includes/dgn_beta.h index c58b821f5c0..ea49068a512 100644 --- a/src/mame/includes/dgn_beta.h +++ b/src/mame/includes/dgn_beta.h @@ -221,6 +221,8 @@ public: required_device m_floppy3; required_device m_palette; + offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); + private: void execute_beta_key_dump(int ref, int params, const char *param[]); void execute_beta_dat_log(int ref, int params, const char *param[]); diff --git a/src/mame/includes/mac.h b/src/mame/includes/mac.h index c8d2e16d05b..99df423e901 100644 --- a/src/mame/includes/mac.h +++ b/src/mame/includes/mac.h @@ -557,6 +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); }; #endif /* MAC_H_ */ diff --git a/src/mame/machine/coco.cpp b/src/mame/machine/coco.cpp index ba88b004762..71686d9d757 100644 --- a/src/mame/machine/coco.cpp +++ b/src/mame/machine/coco.cpp @@ -59,7 +59,6 @@ DAC and bitbanger values written should be reflected in the read. #include "includes/coco.h" #include "cpu/m6809/m6809.h" -#include "debug/debugcpu.h" @@ -160,12 +159,6 @@ void coco_state::device_start() save_item(NAME(m_dclg_timer)); save_item(NAME(m_vhd_select)); - /* set up disassembly override */ - if (m_maincpu->debug()) - { - m_maincpu->debug()->set_dasm_override(dasm_override); - } - // miscellaneous m_in_floating_bus_read = false; } diff --git a/src/mame/machine/dgn_beta.cpp b/src/mame/machine/dgn_beta.cpp index b3689e67b3d..44ce021c4d2 100644 --- a/src/mame/machine/dgn_beta.cpp +++ b/src/mame/machine/dgn_beta.cpp @@ -69,7 +69,6 @@ #include "imagedev/flopdrv.h" #include "debugger.h" -#include "debug/debugcpu.h" #include "debug/debugcon.h" #include "machine/ram.h" @@ -87,9 +86,6 @@ #define LOG_INTS(x) do { if (VERBOSE) logerror x; } while (0) -/* Debugging commands and handlers. */ -static offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); - //static int DMA_NMI; /* DMA cpu has received an NMI */ #define INVALID_KEYROW -1 /* no ketrow selected */ @@ -939,10 +935,6 @@ void dgn_beta_state::machine_start() { logerror("MACHINE_START( dgnbeta )\n"); - if (machine().device(MAINCPU_TAG)->debug()) { - machine().device(MAINCPU_TAG)->debug()->set_dasm_override(dgnbeta_dasm_override); - } - /* setup debug commands */ if (machine().debug_flags & DEBUG_FLAG_ENABLED) { @@ -1109,7 +1101,7 @@ static const char *const os9syscalls[] = }; -static offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) +offs_t dgn_beta_state::dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) { unsigned call; unsigned result = 0; diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp index 02b223fc423..51260a749b4 100644 --- a/src/mame/machine/mac.cpp +++ b/src/mame/machine/mac.cpp @@ -94,8 +94,6 @@ #include "includes/mac.h" #include "machine/applefdc.h" #include "machine/sonydriv.h" -#include "debug/debugcpu.h" -#include "debugger.h" #define AUDIO_IS_CLASSIC (m_model <= MODEL_MAC_CLASSIC) #define MAC_HAS_VIA2 ((m_model >= MODEL_MAC_II) && (m_model != MODEL_MAC_IIFX)) @@ -118,8 +116,6 @@ #define LOG_MEMORY 0 #endif -static offs_t mac_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); - // returns non-zero if this Mac has ADB int mac_state::has_adb() { @@ -1986,10 +1982,6 @@ void mac_state::machine_reset() } m_scsi_interrupt = 0; - if ((m_maincpu->debug()) && (m_model < MODEL_MAC_POWERMAC_6100)) - { - m_maincpu->debug()->set_dasm_override(mac_dasm_override); - } m_drive_select = 0; m_scsiirq_enable = 0; @@ -3185,7 +3177,7 @@ const char *lookup_trap(UINT16 opcode) -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_state::mac_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) { UINT16 opcode; unsigned result = 0; From 7870e6d5392172714738da99ced2c6b9db1f935e Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 26 Jun 2016 13:03:08 -0400 Subject: [PATCH 2/3] 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_ */ From c88953784c4e9a315a3ca976e06b7d353477198d Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 26 Jun 2016 13:08:45 -0400 Subject: [PATCH 3/3] Override method (nw) --- src/emu/didisasm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h index f91438a071c..474cc2b5079 100644 --- a/src/emu/didisasm.h +++ b/src/emu/didisasm.h @@ -83,7 +83,7 @@ protected: 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(); + virtual void interface_pre_start() override; private: dasm_override_delegate m_dasm_override; // provided override function