Add some APU debugging capabilities.

This commit is contained in:
Brandon Wright 2018-05-16 17:46:28 -05:00
parent 30a924fa48
commit dfff94200c
8 changed files with 50 additions and 17 deletions

View File

@ -62,7 +62,17 @@ void SMP::op_step() {
#if defined(PSEUDO_CYCLE)
if(opcode_cycle == 0)
{
#ifdef DEBUGGER
if (Settings.TraceSMP)
{
disassemble_opcode(tmp, regs.pc);
S9xTraceMessage (tmp);
}
#endif
opcode_number = op_readpc();
}
switch(opcode_number) {
#include "core/oppseudo_misc.cpp"

View File

@ -288,7 +288,7 @@ void SMP::disassemble_opcode(char *output, uint16 addr) {
strcat(s, t);
sprintf(t, "A:%.2x X:%.2x Y:%.2x SP:01%.2x YA:%.4x ",
regs.a, regs.x, regs.y, regs.sp, (uint16)regs.ya);
regs.B.a, regs.x, regs.B.y, regs.sp, (uint16)regs.ya);
strcat(s, t);
sprintf(t, "%c%c%c%c%c%c%c%c",
@ -301,4 +301,9 @@ void SMP::disassemble_opcode(char *output, uint16 addr) {
regs.p.z ? 'Z' : 'z',
regs.p.c ? 'C' : 'c');
strcat(s, t);
sprintf(t, " %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x",
apuram[0xf4], apuram[0xf5], apuram[0xf6], apuram[0xf7],
cpu.port_read(0), cpu.port_read(1), cpu.port_read(2), cpu.port_read(3));
strcat(s, t);
}

View File

@ -1,16 +1,22 @@
#define CYCLE_ACCURATE
#define PSEUDO_CYCLE
#ifdef DEBUGGER
#include "../../../snes9x.h"
#include "../../../debug.h"
char tmp[1024];
#endif
#include <snes/snes.hpp>
#define SMP_CPP
namespace SNES {
// TODO: reactivate once APU debugger works again
#if 0 // DEBUGGER
#include "debugger/debugger.cpp"
#ifdef DEBUGGER
// #include "debugger/debugger.cpp"
#include "debugger/disassembler.cpp"
SMPDebugger smp;
SMP smp;
#else
SMP smp;
#endif

View File

@ -122,6 +122,11 @@ public:
inline uint8 op_lsr (uint8 x);
inline uint8 op_rol (uint8 x);
inline uint8 op_ror (uint8 x);
#ifdef DEBUGGER
void disassemble_opcode(char *output, uint16 addr);
inline uint8 disassemble_read(uint16 addr);
inline uint16 relb(int8 offset, int op_len);
#endif
};
// TODO: reactivate once APU debugger works again

View File

@ -198,6 +198,8 @@
#include "debug.h"
#endif
#include "../apu/apu.h"
struct SOpcodes
{
void (*S9xOpcode) (void);
@ -289,6 +291,8 @@ static inline void S9xCheckInterrupts (void)
{
bool8 thisIRQ = PPU.HTimerEnabled | PPU.VTimerEnabled;
S9xAPUExecute();
if (CPU.IRQLine & thisIRQ)
CPU.IRQTransition = TRUE;

View File

@ -202,6 +202,8 @@
#include "debug.h"
#include "missing.h"
#include "apu/bapu/snes/snes.hpp"
extern SDMA DMA[8];
extern FILE *apu_trace;
FILE *trace = NULL, *trace2 = NULL;
@ -259,7 +261,7 @@ static const char *HelpMessage[] =
// "ai - Shou APU vectors",
// "a - Show APU status",
// "x - Show Sound DSP status",
// "A - Toggle APU instruction tracing to aputrace.log",
"A - Toggle APU instruction tracing to trace.log",
// "B - Toggle sound DSP register tracing to aputrace.log",
// "C - Dump sound sample addresses",
// "ad [Address] - Dump APU RAM from PC or [Address]",
@ -1581,8 +1583,11 @@ static void debug_process_command (char *Line)
}
// TODO: reactivate once APU debugger works again
/*if (*Line == 'A')
spc_core->debug_toggle_trace();*/
if (*Line == 'A')
{
Settings.TraceSMP = !Settings.TraceSMP;
printf("SMP tracing %s\n", Settings.TraceSMP ? "enabled" : "disabled");
}
/*
if (*Line == 'B')
@ -1643,20 +1648,16 @@ static void debug_process_command (char *Line)
}
*Line = 0;
}
}*/
if (*Line == 'a')
{
printf("APU in-ports : %02X %02X %02X %02X\n", IAPU.RAM[0xF4], IAPU.RAM[0xF5], IAPU.RAM[0xF6], IAPU.RAM[0xF7]);
printf("APU out-ports: %02X %02X %02X %02X\n", APU.OutPorts[0], APU.OutPorts[1], APU.OutPorts[2], APU.OutPorts[3]);
printf("ROM/RAM switch: %s\n", (IAPU.RAM[0xf1] & 0x80) ? "ROM" : "RAM");
for (int i = 0; i < 3; i++)
if (APU.TimerEnabled[i])
printf("Timer%d enabled, Value: 0x%03X, 4-bit: 0x%02X, Target: 0x%03X\n",
i, APU.Timer[i], IAPU.RAM[0xfd + i], APU.TimerTarget[i]);
printf("S-CPU-side ports S-CPU writes these, S-SMP reads: %02X %02X %02X %02X\n", SNES::cpu.port_read(0), SNES::cpu.port_read(1), SNES::cpu.port_read(2), SNES::cpu.port_read(3));
printf("S-SMP-side ports S-SMP writes these, S-CPU reads: %02X %02X %02X %02X\n", SNES::smp.port_read(0), SNES::smp.port_read(1), SNES::smp.port_read(2), SNES::smp.port_read(3));
}
/*
if (*Line == 'P')
{
Settings.TraceDSP = !Settings.TraceDSP;

View File

@ -516,6 +516,7 @@ void S9xLoadConfigFiles (char **argv, int argc)
ENSURE_TRACE_OPEN(trace,"trace.log","wb")
CPU.Flags |= TRACE_FLAG;
}
Settings.TraceSMP = FALSE;
#endif
S9xParsePortConfig(conf, 1);

View File

@ -365,6 +365,7 @@ struct SSettings
bool8 TraceUnknownRegisters;
bool8 TraceDSP;
bool8 TraceHCEvent;
bool8 TraceSMP;
bool8 SuperFX;
uint8 DSP;