DSP debugger: Fix prpage

This commit is contained in:
wheremyfoodat 2025-07-08 18:10:57 +03:00
parent 69bbb13d5d
commit 518b279139
7 changed files with 30 additions and 9 deletions

View file

@ -64,7 +64,8 @@ namespace Audio {
Samples& getSamples() { return sampleBuffer; }
virtual void setAudioEnabled(bool enable) { audioEnabled = enable; }
virtual u32 getPC() { return 0; }
virtual Type getType() = 0;
virtual void* getRegisters() { return nullptr; }
};
std::unique_ptr<DSPCore> makeDSPCore(EmulatorConfig& config, Memory& mem, Scheduler& scheduler, DSPService& dspService);

View file

@ -213,6 +213,7 @@ namespace Audio {
void runAudioFrame(u64 eventTimestamp) override;
u8* getDspMemory() override { return dspRam.rawMemory.data(); }
DSPCore::Type getType() override { return DSPCore::Type::HLE; }
u16 recvData(u32 regId) override;
bool recvDataIsReady(u32 regId) override { return true; } // Treat data as always ready

View file

@ -30,6 +30,7 @@ namespace Audio {
void runAudioFrame(u64 eventTimestamp) override;
u8* getDspMemory() override { return dspRam.data(); }
DSPCore::Type getType() override { return DSPCore::Type::Null; }
u16 recvData(u32 regId) override;
bool recvDataIsReady(u32 regId) override { return true; } // Treat data as always ready

View file

@ -90,7 +90,8 @@ namespace Audio {
void setAudioEnabled(bool enable) override;
u8* getDspMemory() override { return teakra.GetDspMemory().data(); }
u32 getPC() override;
void* getRegisters() override;
DSPCore::Type getType() override { return DSPCore::Type::Teakra; }
u16 recvData(u32 regId) override { return teakra.RecvData(regId); }
bool recvDataIsReady(u32 regId) override { return teakra.RecvDataIsReady(regId); }

View file

@ -31,6 +31,9 @@ class DSPDebugger : public QWidget {
void disable();
private:
// Get the full PC value of the DSP, including the current progrma page value
u32 getPC();
// Update the state of the disassembler. Qt events should always call update, not updateDisasm/updateRegister
// As update properly handles thread safety
void update();

View file

@ -8,10 +8,6 @@
#include "audio/dsp_binary.hpp"
#include "services/dsp.hpp"
#undef Assert
#undef UNREACHABLE
#include "teakra/impl/register.h"
using namespace Audio;
TeakraDSP::TeakraDSP(Memory& mem, Scheduler& scheduler, DSPService& dspService, EmulatorConfig& config)
@ -322,4 +318,4 @@ void TeakraDSP::unloadComponent() {
running = false;
}
u32 TeakraDSP::getPC() { return teakra.GetRegisterState().pc; }
void* TeakraDSP::getRegisters() { return &teakra.GetRegisterState(); }

View file

@ -12,8 +12,13 @@
#include <span>
#include <utility>
#include "audio/dsp_core.hpp"
#include "teakra/disassembler.h"
#undef Assert
#undef UNREACHABLE
#include "teakra/impl/register.h"
// TODO: Make this actually thread-safe by having it only work when paused
static int getLinesInViewport(QListWidget* listWidget) {
auto viewportHeight = listWidget->viewport()->height();
@ -167,7 +172,7 @@ void DSPDebugger::updateDisasm() {
};
auto& mem = emu->getMemory();
u32 pc = DSP->getPC();
u32 pc = getPC();
std::string disassembly;
@ -192,8 +197,21 @@ void DSPDebugger::updateDisasm() {
disasmListWidget->setCurrentRow(currentRow);
}
// This is only supported on the Teakra core, as other cores don't actually have a register contexts
u32 DSPDebugger::getPC() {
auto DSP = emu->getDSP();
auto dspType = DSP->getType();
if (dspType == Audio::DSPCore::Type::Teakra) {
auto regs = (Teakra::RegisterState*)DSP->getRegisters();
return regs->pc | (u32(regs->prpage) << 18);
} else {
return 0;
}
}
void DSPDebugger::scrollToPC() {
u32 pc = emu->getDSP()->getPC();
u32 pc = getPC();
verticalScrollBar->setValue(pc);
}