From 440550a02d28f1951597a2d467da85f68359dcb4 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Wed, 3 Jul 2013 13:20:04 +0000 Subject: [PATCH] * Tracer: only output "from $XXXX" when the subroutine was called by JSR (fixes possible errors in those cases when the subroutine was called using stack magic) --- trunk/src/drivers/win/tracer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/trunk/src/drivers/win/tracer.cpp b/trunk/src/drivers/win/tracer.cpp index 4b1b7f1a..f5d284fe 100644 --- a/trunk/src/drivers/win/tracer.cpp +++ b/trunk/src/drivers/win/tracer.cpp @@ -411,9 +411,13 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size) { // add the beginning address of the subroutine that we exit from unsigned int caller_addr = GetMem(((X.S) + 1)|0x0100) + (GetMem(((X.S) + 2)|0x0100) << 8) - 0x2; - unsigned int call_addr = GetMem(caller_addr + 1) + (GetMem(caller_addr + 2) << 8); - sprintf(str_decoration, " (from $%04X)", call_addr); - strcat(a, str_decoration); + if (GetMem(caller_addr) == 0x20) + { + // this was a JSR instruction - take the subroutine address from it + unsigned int call_addr = GetMem(caller_addr + 1) + (GetMem(caller_addr + 2) << 8); + sprintf(str_decoration, " (from $%04X)", call_addr); + strcat(a, str_decoration); + } } break; }