diff --git a/src/emu/cpu/psx/psx.c b/src/emu/cpu/psx/psx.c index 505e1f9a27c..c0d425586ba 100644 --- a/src/emu/cpu/psx/psx.c +++ b/src/emu/cpu/psx/psx.c @@ -2050,14 +2050,7 @@ void psxcpu_device::state_string_export( const device_state_entry &entry, astrin offs_t psxcpu_device::disasm_disassemble( char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options ) { - DasmPSXCPU_state state; - - state.pc = m_pc; - state.delayr = m_delayr; - state.delayv = m_delayv; - memcpy( state.r, m_r, sizeof( state.r ) ); - - return DasmPSXCPU( &state, buffer, pc, opram ); + return DasmPSXCPU( this, buffer, pc, opram ); } diff --git a/src/emu/cpu/psx/psx.h b/src/emu/cpu/psx/psx.h index dec0887fb29..65863869dbc 100644 --- a/src/emu/cpu/psx/psx.h +++ b/src/emu/cpu/psx/psx.h @@ -133,9 +133,19 @@ enum // TYPE DEFINITIONS //************************************************************************** +class psxcpu_state +{ +public: + virtual UINT32 pc(); + virtual UINT32 delayr(); + virtual UINT32 delayv(); + virtual UINT32 r(int i); +}; + // ======================> psxcpu_device -class psxcpu_device : public cpu_device +class psxcpu_device : public cpu_device, + psxcpu_state { public: // construction/destruction @@ -333,6 +343,13 @@ protected: devcb2_write8 m_cd_write_handler; required_device m_ram; memory_region *m_rom; + +private: + // disassembler interface + virtual UINT32 pc() { return m_pc; } + virtual UINT32 delayr() { return m_delayr; } + virtual UINT32 delayv() { return m_delayv; } + virtual UINT32 r(int i) { return m_r[ i ]; } }; class cxd8530aq_device : public psxcpu_device @@ -504,16 +521,6 @@ extern const device_type CXD8606CQ; #define CF_TLBP ( 8 ) #define CF_RFE ( 16 ) - - -struct DasmPSXCPU_state -{ - UINT32 pc; - int delayr; - UINT32 delayv; - UINT32 r[ 32 ]; -}; - -extern unsigned DasmPSXCPU( DasmPSXCPU_state *state, char *buffer, UINT32 pc, const UINT8 *opram ); +extern unsigned DasmPSXCPU( psxcpu_state *state, char *buffer, UINT32 pc, const UINT8 *opram ); #endif /* __PSXCPU_H__ */ diff --git a/src/emu/cpu/psx/psxdasm.c b/src/emu/cpu/psx/psxdasm.c index 269ff7d19d7..ae7f3c46296 100644 --- a/src/emu/cpu/psx/psxdasm.c +++ b/src/emu/cpu/psx/psxdasm.c @@ -122,37 +122,37 @@ static const char *const s_gtelm[] = " lm=s16", " lm=u15" }; -static char *effective_address( DasmPSXCPU_state *state, UINT32 pc, UINT32 op ) +static char *effective_address( psxcpu_state *state, UINT32 pc, UINT32 op ) { static char s_address[ 20 ]; - if( state != NULL && state->pc == pc ) + if( state != NULL && state->pc() == pc ) { sprintf( s_address, "%s(%s) ; 0x%08x", make_signed_hex_str_16( INS_IMMEDIATE( op ) ), s_cpugenreg[ INS_RS( op ) ], - (UINT32)( state->r[ INS_RS( op ) ] + (INT16)INS_IMMEDIATE( op ) ) ); + (UINT32)( state->r( INS_RS( op ) ) + (INT16)INS_IMMEDIATE( op ) ) ); return s_address; } sprintf( s_address, "%s(%s)", make_signed_hex_str_16( INS_IMMEDIATE( op ) ), s_cpugenreg[ INS_RS( op ) ] ); return s_address; } -static UINT32 relative_address( DasmPSXCPU_state *state, UINT32 pc, UINT32 op ) +static UINT32 relative_address( psxcpu_state *state, UINT32 pc, UINT32 op ) { UINT32 nextpc = pc + 4; - if( state != NULL && state->pc == pc && state->delayr == PSXCPU_DELAYR_PC ) + if( state != NULL && state->pc() == pc && state->delayr() == PSXCPU_DELAYR_PC ) { - nextpc = state->delayv; + nextpc = state->delayv(); } return nextpc + ( PSXCPU_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ); } -static UINT32 jump_address( DasmPSXCPU_state *state, UINT32 pc, UINT32 op ) +static UINT32 jump_address( psxcpu_state *state, UINT32 pc, UINT32 op ) { UINT32 nextpc = pc + 4; - if( state != NULL && state->pc == pc && state->delayr == PSXCPU_DELAYR_PC ) + if( state != NULL && state->pc() == pc && state->delayr() == PSXCPU_DELAYR_PC ) { - nextpc = state->delayv; + nextpc = state->delayv(); } return ( nextpc & 0xf0000000 ) + ( INS_TARGET( op ) << 2 ); } @@ -183,7 +183,7 @@ static char *upper_address( UINT32 op, const UINT8 *opram ) return s_address; } -unsigned DasmPSXCPU( DasmPSXCPU_state *state, char *buffer, UINT32 pc, const UINT8 *opram ) +unsigned DasmPSXCPU( psxcpu_state *state, char *buffer, UINT32 pc, const UINT8 *opram ) { UINT32 op; const UINT8 *oldopram; @@ -676,7 +676,5 @@ unsigned DasmPSXCPU( DasmPSXCPU_state *state, char *buffer, UINT32 pc, const UIN CPU_DISASSEMBLE( psxcpu_generic ) { - DasmPSXCPU_state state = {0}; - state.pc = pc; - return DasmPSXCPU( &state, buffer, pc, opram ); + return DasmPSXCPU( NULL, buffer, pc, opram ); }