From 38306e6b274b690d5e803d3426a864ff3f5cb8f2 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Wed, 7 Feb 2018 18:20:33 +0100 Subject: m6502: Fixed paged variants tracing and breakpoints [O. Galibert] --- src/devices/cpu/m6502/m6502.cpp | 17 ++++++++++++++--- src/devices/cpu/m6502/m6502.h | 2 ++ src/devices/cpu/m6502/m6509.cpp | 11 +++-------- src/devices/cpu/m6502/m6509.h | 4 +--- src/devices/cpu/m6502/m65ce02.cpp | 4 ---- src/devices/cpu/m6502/m65ce02.h | 1 - src/devices/cpu/m6502/xavix.cpp | 20 +++++--------------- src/devices/cpu/m6502/xavix.h | 2 +- 8 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp index e63e622ffe7..63d12c5b336 100644 --- a/src/devices/cpu/m6502/m6502.cpp +++ b/src/devices/cpu/m6502/m6502.cpp @@ -50,8 +50,10 @@ void m6502_device::init() sync_w.resolve_safe(); - state_add(STATE_GENPC, "GENPC", NPC).noshow(); - state_add(STATE_GENPCBASE, "CURPC", PPC).noshow(); + XPC = 0; + + state_add(STATE_GENPC, "GENPC", XPC).callexport().noshow(); + state_add(STATE_GENPCBASE, "CURPC", XPC).callexport().noshow(); state_add(STATE_GENSP, "GENSP", SP).noshow(); state_add(STATE_GENFLAGS, "GENFLAGS", P).callimport().formatstr("%6s").noshow(); state_add(M6502_PC, "PC", NPC).callimport(); @@ -373,6 +375,11 @@ uint8_t m6502_device::do_asr(uint8_t v) return v; } +offs_t m6502_device::pc_to_external(u16 pc) +{ + return pc; +} + void m6502_device::execute_run() { if(inst_substate) @@ -383,7 +390,7 @@ void m6502_device::execute_run() PPC = NPC; inst_state = IR | inst_state_base; if(machine().debug_flags & DEBUG_FLAG_ENABLED) - debugger_instruction_hook(this, NPC); + debugger_instruction_hook(this, pc_to_external(NPC)); } do_exec_full(); } @@ -437,6 +444,10 @@ void m6502_device::state_import(const device_state_entry &entry) void m6502_device::state_export(const device_state_entry &entry) { + switch(entry.index()) { + case STATE_GENPC: XPC = pc_to_external(PPC); break; + case STATE_GENPCBASE: XPC = pc_to_external(NPC); break; + } } void m6502_device::state_string_export(const device_state_entry &entry, std::string &str) const diff --git a/src/devices/cpu/m6502/m6502.h b/src/devices/cpu/m6502/m6502.h index 96dfc1f9be3..ab44415ca5a 100644 --- a/src/devices/cpu/m6502/m6502.h +++ b/src/devices/cpu/m6502/m6502.h @@ -140,6 +140,8 @@ protected: void prefetch_noirq(); void set_nz(uint8_t v); + u32 XPC; + virtual offs_t pc_to_external(u16 pc); // For paged PCs virtual void do_exec_full(); virtual void do_exec_partial(); diff --git a/src/devices/cpu/m6502/m6509.cpp b/src/devices/cpu/m6502/m6509.cpp index 5fdf1114f96..a954df176cc 100644 --- a/src/devices/cpu/m6502/m6509.cpp +++ b/src/devices/cpu/m6502/m6509.cpp @@ -15,7 +15,7 @@ DEFINE_DEVICE_TYPE(M6509, m6509_device, "m6509", "M6509") m6509_device::m6509_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - m6502_device(mconfig, M6509, tag, owner, clock), XPC(0), bank_i(0), bank_y(0) + m6502_device(mconfig, M6509, tag, owner, clock), bank_i(0), bank_y(0) { program_config.m_addr_width = 20; program_config.m_logaddr_width = 20; @@ -45,14 +45,9 @@ void m6509_device::device_reset() bank_y = 0x0f; } -void m6509_device::state_export(const device_state_entry &entry) +offs_t m6509_device::pc_to_external(u16 pc) { - switch(entry.index()) { - case STATE_GENPC: - case STATE_GENPCBASE: - XPC = adr_in_bank_i(NPC); - break; - } + return adr_in_bank_i(pc); } util::disasm_interface *m6509_device::create_disassembler() diff --git a/src/devices/cpu/m6502/m6509.h b/src/devices/cpu/m6502/m6509.h index c8fa2ba937e..3945c4fcdac 100644 --- a/src/devices/cpu/m6502/m6509.h +++ b/src/devices/cpu/m6502/m6509.h @@ -46,9 +46,7 @@ protected: virtual void device_start() override; virtual void device_reset() override; - virtual void state_export(const device_state_entry &entry) override; - - uint32_t XPC; + virtual offs_t pc_to_external(u16 pc) override; uint8_t bank_i, bank_y; diff --git a/src/devices/cpu/m6502/m65ce02.cpp b/src/devices/cpu/m6502/m65ce02.cpp index ff5c66b160c..9e497a3f4d3 100644 --- a/src/devices/cpu/m6502/m65ce02.cpp +++ b/src/devices/cpu/m6502/m65ce02.cpp @@ -72,10 +72,6 @@ void m65ce02_device::state_import(const device_state_entry &entry) } } -void m65ce02_device::state_export(const device_state_entry &entry) -{ -} - void m65ce02_device::state_string_export(const device_state_entry &entry, std::string &str) const { switch(entry.index()) { diff --git a/src/devices/cpu/m6502/m65ce02.h b/src/devices/cpu/m6502/m65ce02.h index e3c7a440ca8..dbefeb0f019 100644 --- a/src/devices/cpu/m6502/m65ce02.h +++ b/src/devices/cpu/m6502/m65ce02.h @@ -33,7 +33,6 @@ protected: virtual void device_start() override; virtual void device_reset() override; virtual void state_import(const device_state_entry &entry) override; - virtual void state_export(const device_state_entry &entry) override; virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; inline void dec_SP_ce() { if(P & F_E) SP = set_l(SP, SP-1); else SP--; } diff --git a/src/devices/cpu/m6502/xavix.cpp b/src/devices/cpu/m6502/xavix.cpp index 1766a30aeba..55a5212c069 100644 --- a/src/devices/cpu/m6502/xavix.cpp +++ b/src/devices/cpu/m6502/xavix.cpp @@ -32,6 +32,11 @@ util::disasm_interface *xavix_device::create_disassembler() } +offs_t xavix_device::pc_to_external(u16 pc) +{ + return adr_with_bank(pc); +} + void xavix_device::device_start() { if(direct_disabled) @@ -43,26 +48,11 @@ void xavix_device::device_start() m_vector_callback.bind_relative_to(*owner()); init(); - - state_add(STATE_GENPC, "GENPC", XPC).callexport().noshow(); - state_add(STATE_GENPCBASE, "CURPC", XPC).callexport().noshow(); } -void xavix_device::state_export(const device_state_entry &entry) -{ - switch(entry.index()) { - case STATE_GENPC: - case STATE_GENPCBASE: - XPC = adr_with_bank(NPC); - break; - } -} - - void xavix_device::device_reset() { m_farbank = 0; - XPC = 0; m6502_device::device_reset(); } diff --git a/src/devices/cpu/m6502/xavix.h b/src/devices/cpu/m6502/xavix.h index 4e0a76424a2..821ee42bf45 100644 --- a/src/devices/cpu/m6502/xavix.h +++ b/src/devices/cpu/m6502/xavix.h @@ -70,7 +70,7 @@ protected: virtual void device_start() override; virtual void device_reset() override; - virtual void state_export(const device_state_entry &entry) override; + virtual offs_t pc_to_external(u16 pc) override; private: xavix_interrupt_vector_delegate m_vector_callback; -- cgit v1.2.3