mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-01 09:45:25 +00:00
Merging
This commit is contained in:
@@ -0,0 +1,488 @@
|
||||
// //! @brief Convert a basic CPU to a debugging CPU.
|
||||
|
||||
// Created by Melefo on 19/02/2020.
|
||||
//
|
||||
|
||||
#include "APUDebug.hpp"
|
||||
#include "../Utility/Utility.hpp"
|
||||
|
||||
using namespace ComSquare::APU;
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
APUDebug::APUDebug(APU &apu, SNES &snes) :
|
||||
APU(apu),
|
||||
QMainWindow(),
|
||||
_ui(),
|
||||
_snes(snes)
|
||||
{
|
||||
this->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
this->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
|
||||
this->_ui.setupUi(this);
|
||||
this->show();
|
||||
this->_updatePanel();
|
||||
}
|
||||
|
||||
void APUDebug::_updatePanel()
|
||||
{
|
||||
this->_ui.port0hexaLineEdit->setText(Utility::to_hex(this->_registers.port0).c_str());
|
||||
this->_ui.port0LineEdit->setText(Utility::to_binary(this->_registers.port0).c_str());
|
||||
|
||||
this->_ui.port1hexaLineEdit->setText(Utility::to_hex(this->_registers.port1).c_str());
|
||||
this->_ui.port1LineEdit->setText(Utility::to_binary(this->_registers.port1).c_str());
|
||||
|
||||
this->_ui.port2hexaLineEdit->setText(Utility::to_hex(this->_registers.port1).c_str());
|
||||
this->_ui.port2LineEdit->setText(Utility::to_binary(this->_registers.port1).c_str());
|
||||
|
||||
this->_ui.port3hexaLineEdit->setText(Utility::to_hex(this->_registers.port1).c_str());
|
||||
this->_ui.port3LineEdit->setText(Utility::to_binary(this->_registers.port1).c_str());
|
||||
|
||||
this->_ui.controlhexaLineEdit->setText(Utility::to_hex(this->_registers.ctrlreg).c_str());
|
||||
this->_ui.controlLineEdit->setText(Utility::to_binary(this->_registers.ctrlreg).c_str());
|
||||
|
||||
this->_ui.dSPRegAddresshexaLineEdit->setText(Utility::to_hex(this->_registers.dspregAddr).c_str());
|
||||
this->_ui.dSPRegAddressLineEdit->setText(Utility::to_binary(this->_registers.dspregAddr).c_str());
|
||||
|
||||
this->_ui.dSPRegDatahexaLineEdit->setText(Utility::to_hex(this->_registers.dspregData).c_str());
|
||||
this->_ui.dSPRegDataLineEdit->setText(Utility::to_binary(this->_registers.dspregData).c_str());
|
||||
|
||||
this->_ui.timer0hexaLineEdit->setText(Utility::to_hex(this->_registers.timer0).c_str());
|
||||
this->_ui.timer0LineEdit->setText(Utility::to_binary(this->_registers.timer0).c_str());
|
||||
|
||||
this->_ui.timer1hexaLineEdit->setText(Utility::to_hex(this->_registers.timer1).c_str());
|
||||
this->_ui.timer1LineEdit->setText(Utility::to_binary(this->_registers.timer1).c_str());
|
||||
|
||||
this->_ui.timer2hexaLineEdit->setText(Utility::to_hex(this->_registers.timer2).c_str());
|
||||
this->_ui.timer2LineEdit->setText(Utility::to_binary(this->_registers.timer2).c_str());
|
||||
|
||||
this->_ui.counter0hexaLineEdit->setText(Utility::to_hex(this->_registers.counter0).c_str());
|
||||
this->_ui.counter0LineEdit->setText(Utility::to_binary(this->_registers.counter0).c_str());
|
||||
|
||||
this->_ui.counter1hexaLineEdit->setText(Utility::to_hex(this->_registers.counter1).c_str());
|
||||
this->_ui.counter1LineEdit->setText(Utility::to_binary(this->_registers.counter1).c_str());
|
||||
|
||||
this->_ui.counter2hexaLineEdit->setText(Utility::to_hex(this->_registers.counter2).c_str());
|
||||
this->_ui.counter2LineEdit->setText(Utility::to_binary(this->_registers.counter2).c_str());
|
||||
|
||||
this->_ui.regMemhexaLineEdit->setText(Utility::to_hex(this->_registers.regmem1).c_str());
|
||||
this->_ui.regMemLineEdit->setText(Utility::to_binary(this->_registers.regmem1).c_str());
|
||||
|
||||
this->_ui.regMemhexaLineEdit_2->setText(Utility::to_hex(this->_registers.regmem2).c_str());
|
||||
this->_ui.regMemLineEdit_2->setText(Utility::to_binary(this->_registers.regmem2).c_str());
|
||||
|
||||
this->_ui.unknownhexaLineEdit->setText(Utility::to_hex(this->_registers.unknown).c_str());
|
||||
this->_ui.unknownLineEdit->setText(Utility::to_binary(this->_registers.unknown).c_str());
|
||||
|
||||
this->_ui.stackPointerLineEdit->setText(Utility::to_hex(this->_internalRegisters.sp).c_str());
|
||||
this->_ui.xIndexLineEdit->setText(Utility::to_hex(this->_internalRegisters.x).c_str());
|
||||
this->_ui.yIndexLineEdit->setText(Utility::to_hex(this->_internalRegisters.y).c_str());
|
||||
this->_ui.accumlatorLineEdit->setText(Utility::to_hex(this->_internalRegisters.a).c_str());
|
||||
this->_ui.programCounterLineEdit->setText(Utility::to_hex(this->_internalRegisters.pc).c_str());
|
||||
this->_ui.programStatusWordLineEdit->setText(this->_getPSWString().c_str());
|
||||
|
||||
this->_ui.mvolLprogressBar->setValue(this->_dsp->getRegisters().mvolL);
|
||||
this->_ui.mvolRprogressBar->setValue(this->_dsp->getRegisters().mvolR);
|
||||
this->_ui.evolLprogressBar->setValue(this->_dsp->getRegisters().evolL);
|
||||
this->_ui.evolRprogressBar->setValue(this->_dsp->getRegisters().evolR);
|
||||
this->_ui.echoprogressBar->setValue(this->_dsp->getRegisters().efb);
|
||||
this->_ui.flagslineEdit->setText(Utility::to_binary(this->_dsp->getRegisters().flg).c_str());
|
||||
this->_ui.sourceDirectoryLineEdit->setText(Utility::to_hex(this->_dsp->getRegisters().dir).c_str());
|
||||
this->_ui.echoBufferOffsetLineEdit->setText(Utility::to_hex(this->_dsp->getRegisters().esa).c_str());
|
||||
this->_ui.echoDelayLineEdit->setText(Utility::to_hex(this->_dsp->getRegisters().edl).c_str());
|
||||
|
||||
this->_ui.VolumeLprogressBar->setValue(this->_dsp->getChannels()[0].volL);
|
||||
this->_ui.VolumeRprogressBar->setValue(this->_dsp->getChannels()[0].volR);
|
||||
this->_ui.WaveHeightprogressBar->setValue(this->_dsp->getChannels()[0].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar->setValue(this->_dsp->getChannels()[0].coeff);
|
||||
this->_ui.PitchlineEdit->setText(Utility::to_hex(this->_dsp->getChannels()[0].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit->setText(Utility::to_hex(this->_dsp->getChannels()[0].srcn).c_str());
|
||||
this->_ui.GainlineEdit->setText(Utility::to_hex(this->_dsp->getChannels()[0].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit->setText(Utility::to_hex(this->_dsp->getChannels()[0].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit->setText(Utility::to_hex(this->_dsp->getChannels()[0].envx).c_str());
|
||||
this->_ui.KeyOncheckBox->setChecked(this->_dsp->getChannels()[0].kon);
|
||||
this->_ui.KeyOffcheckBox->setChecked(this->_dsp->getChannels()[0].kof);
|
||||
this->_ui.NoisecheckBox->setChecked(this->_dsp->getChannels()[0].non);
|
||||
this->_ui.EchocheckBox->setChecked(this->_dsp->getChannels()[0].eon);
|
||||
this->_ui.SampleEndcheckBox->setChecked(this->_dsp->getChannels()[0].endx);
|
||||
this->_ui.PitchModulationcheckBox->setChecked(this->_dsp->getChannels()[0].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_2->setValue(this->_dsp->getChannels()[1].volL);
|
||||
this->_ui.VolumeRprogressBar_2->setValue(this->_dsp->getChannels()[1].volR);
|
||||
this->_ui.WaveHeightprogressBar_2->setValue(this->_dsp->getChannels()[1].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_2->setValue(this->_dsp->getChannels()[1].coeff);
|
||||
this->_ui.PitchlineEdit_2->setText(Utility::to_hex(this->_dsp->getChannels()[1].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_2->setText(Utility::to_hex(this->_dsp->getChannels()[1].srcn).c_str());
|
||||
this->_ui.GainlineEdit_2->setText(Utility::to_hex(this->_dsp->getChannels()[1].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_2->setText(Utility::to_hex(this->_dsp->getChannels()[1].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_2->setText(Utility::to_hex(this->_dsp->getChannels()[1].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_2->setChecked(this->_dsp->getChannels()[1].kon);
|
||||
this->_ui.KeyOffcheckBox_2->setChecked(this->_dsp->getChannels()[1].kof);
|
||||
this->_ui.NoisecheckBox_2->setChecked(this->_dsp->getChannels()[1].non);
|
||||
this->_ui.EchocheckBox_2->setChecked(this->_dsp->getChannels()[1].eon);
|
||||
this->_ui.SampleEndcheckBox_2->setChecked(this->_dsp->getChannels()[1].endx);
|
||||
this->_ui.PitchModulationcheckBox_2->setChecked(this->_dsp->getChannels()[1].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_3->setValue(this->_dsp->getChannels()[2].volL);
|
||||
this->_ui.VolumeRprogressBar_3->setValue(this->_dsp->getChannels()[2].volR);
|
||||
this->_ui.WaveHeightprogressBar_3->setValue(this->_dsp->getChannels()[2].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_3->setValue(this->_dsp->getChannels()[2].coeff);
|
||||
this->_ui.PitchlineEdit_3->setText(Utility::to_hex(this->_dsp->getChannels()[2].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_3->setText(Utility::to_hex(this->_dsp->getChannels()[2].srcn).c_str());
|
||||
this->_ui.GainlineEdit_3->setText(Utility::to_hex(this->_dsp->getChannels()[2].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_3->setText(Utility::to_hex(this->_dsp->getChannels()[2].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_3->setText(Utility::to_hex(this->_dsp->getChannels()[2].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_3->setChecked(this->_dsp->getChannels()[2].kon);
|
||||
this->_ui.KeyOffcheckBox_3->setChecked(this->_dsp->getChannels()[2].kof);
|
||||
this->_ui.NoisecheckBox_3->setChecked(this->_dsp->getChannels()[2].non);
|
||||
this->_ui.EchocheckBox_3->setChecked(this->_dsp->getChannels()[2].eon);
|
||||
this->_ui.SampleEndcheckBox_3->setChecked(this->_dsp->getChannels()[2].endx);
|
||||
this->_ui.PitchModulationcheckBox_3->setChecked(this->_dsp->getChannels()[2].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_4->setValue(this->_dsp->getChannels()[3].volL);
|
||||
this->_ui.VolumeRprogressBar_4->setValue(this->_dsp->getChannels()[3].volR);
|
||||
this->_ui.WaveHeightprogressBar_4->setValue(this->_dsp->getChannels()[3].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_4->setValue(this->_dsp->getChannels()[3].coeff);
|
||||
this->_ui.PitchlineEdit_4->setText(Utility::to_hex(this->_dsp->getChannels()[3].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_4->setText(Utility::to_hex(this->_dsp->getChannels()[3].srcn).c_str());
|
||||
this->_ui.GainlineEdit_4->setText(Utility::to_hex(this->_dsp->getChannels()[3].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_4->setText(Utility::to_hex(this->_dsp->getChannels()[3].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_4->setText(Utility::to_hex(this->_dsp->getChannels()[3].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_4->setChecked(this->_dsp->getChannels()[3].kon);
|
||||
this->_ui.KeyOffcheckBox_4->setChecked(this->_dsp->getChannels()[3].kof);
|
||||
this->_ui.NoisecheckBox_4->setChecked(this->_dsp->getChannels()[3].non);
|
||||
this->_ui.EchocheckBox_4->setChecked(this->_dsp->getChannels()[3].eon);
|
||||
this->_ui.SampleEndcheckBox_4->setChecked(this->_dsp->getChannels()[3].endx);
|
||||
this->_ui.PitchModulationcheckBox_4->setChecked(this->_dsp->getChannels()[3].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_5->setValue(this->_dsp->getChannels()[4].volL);
|
||||
this->_ui.VolumeRprogressBar_5->setValue(this->_dsp->getChannels()[4].volR);
|
||||
this->_ui.WaveHeightprogressBar_5->setValue(this->_dsp->getChannels()[4].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_5->setValue(this->_dsp->getChannels()[4].coeff);
|
||||
this->_ui.PitchlineEdit_5->setText(Utility::to_hex(this->_dsp->getChannels()[4].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_5->setText(Utility::to_hex(this->_dsp->getChannels()[4].srcn).c_str());
|
||||
this->_ui.GainlineEdit_5->setText(Utility::to_hex(this->_dsp->getChannels()[4].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_5->setText(Utility::to_hex(this->_dsp->getChannels()[4].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_5->setText(Utility::to_hex(this->_dsp->getChannels()[4].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_5->setChecked(this->_dsp->getChannels()[4].kon);
|
||||
this->_ui.KeyOffcheckBox_5->setChecked(this->_dsp->getChannels()[4].kof);
|
||||
this->_ui.NoisecheckBox_5->setChecked(this->_dsp->getChannels()[4].non);
|
||||
this->_ui.EchocheckBox_5->setChecked(this->_dsp->getChannels()[4].eon);
|
||||
this->_ui.SampleEndcheckBox_5->setChecked(this->_dsp->getChannels()[4].endx);
|
||||
this->_ui.PitchModulationcheckBox_5->setChecked(this->_dsp->getChannels()[4].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_6->setValue(this->_dsp->getChannels()[5].volL);
|
||||
this->_ui.VolumeRprogressBar_6->setValue(this->_dsp->getChannels()[5].volR);
|
||||
this->_ui.WaveHeightprogressBar_6->setValue(this->_dsp->getChannels()[5].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_6->setValue(this->_dsp->getChannels()[5].coeff);
|
||||
this->_ui.PitchlineEdit_6->setText(Utility::to_hex(this->_dsp->getChannels()[5].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_6->setText(Utility::to_hex(this->_dsp->getChannels()[5].srcn).c_str());
|
||||
this->_ui.GainlineEdit_6->setText(Utility::to_hex(this->_dsp->getChannels()[5].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_6->setText(Utility::to_hex(this->_dsp->getChannels()[5].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_6->setText(Utility::to_hex(this->_dsp->getChannels()[5].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_6->setChecked(this->_dsp->getChannels()[5].kon);
|
||||
this->_ui.KeyOffcheckBox_6->setChecked(this->_dsp->getChannels()[5].kof);
|
||||
this->_ui.NoisecheckBox_6->setChecked(this->_dsp->getChannels()[5].non);
|
||||
this->_ui.EchocheckBox_6->setChecked(this->_dsp->getChannels()[5].eon);
|
||||
this->_ui.SampleEndcheckBox_6->setChecked(this->_dsp->getChannels()[5].endx);
|
||||
this->_ui.PitchModulationcheckBox_6->setChecked(this->_dsp->getChannels()[5].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_7->setValue(this->_dsp->getChannels()[6].volL);
|
||||
this->_ui.VolumeRprogressBar_7->setValue(this->_dsp->getChannels()[6].volR);
|
||||
this->_ui.WaveHeightprogressBar_7->setValue(this->_dsp->getChannels()[6].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_7->setValue(this->_dsp->getChannels()[6].coeff);
|
||||
this->_ui.PitchlineEdit_7->setText(Utility::to_hex(this->_dsp->getChannels()[6].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_7->setText(Utility::to_hex(this->_dsp->getChannels()[6].srcn).c_str());
|
||||
this->_ui.GainlineEdit_7->setText(Utility::to_hex(this->_dsp->getChannels()[6].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_7->setText(Utility::to_hex(this->_dsp->getChannels()[6].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_7->setText(Utility::to_hex(this->_dsp->getChannels()[6].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_7->setChecked(this->_dsp->getChannels()[6].kon);
|
||||
this->_ui.KeyOffcheckBox_7->setChecked(this->_dsp->getChannels()[6].kof);
|
||||
this->_ui.NoisecheckBox_7->setChecked(this->_dsp->getChannels()[6].non);
|
||||
this->_ui.EchocheckBox_7->setChecked(this->_dsp->getChannels()[6].eon);
|
||||
this->_ui.SampleEndcheckBox_7->setChecked(this->_dsp->getChannels()[6].endx);
|
||||
this->_ui.PitchModulationcheckBox_7->setChecked(this->_dsp->getChannels()[6].pmon);
|
||||
|
||||
this->_ui.VolumeLprogressBar_8->setValue(this->_dsp->getChannels()[7].volL);
|
||||
this->_ui.VolumeRprogressBar_8->setValue(this->_dsp->getChannels()[7].volR);
|
||||
this->_ui.WaveHeightprogressBar_8->setValue(this->_dsp->getChannels()[7].outx);
|
||||
this->_ui.EchoFIRCoeffprogressBar_8->setValue(this->_dsp->getChannels()[7].coeff);
|
||||
this->_ui.PitchlineEdit_8->setText(Utility::to_hex(this->_dsp->getChannels()[7].pitch).c_str());
|
||||
this->_ui.sourceNumberLineEdit_8->setText(Utility::to_hex(this->_dsp->getChannels()[7].srcn).c_str());
|
||||
this->_ui.GainlineEdit_8->setText(Utility::to_hex(this->_dsp->getChannels()[7].gain).c_str());
|
||||
this->_ui.EnvelopelineEdit_8->setText(Utility::to_hex(this->_dsp->getChannels()[7].envelope).c_str());
|
||||
this->_ui.EnvelopeValueLineEdit_8->setText(Utility::to_hex(this->_dsp->getChannels()[7].envx).c_str());
|
||||
this->_ui.KeyOncheckBox_8->setChecked(this->_dsp->getChannels()[7].kon);
|
||||
this->_ui.KeyOffcheckBox_8->setChecked(this->_dsp->getChannels()[7].kof);
|
||||
this->_ui.NoisecheckBox_8->setChecked(this->_dsp->getChannels()[7].non);
|
||||
this->_ui.EchocheckBox_8->setChecked(this->_dsp->getChannels()[7].eon);
|
||||
this->_ui.SampleEndcheckBox_8->setChecked(this->_dsp->getChannels()[7].endx);
|
||||
this->_ui.PitchModulationcheckBox_8->setChecked(this->_dsp->getChannels()[7].pmon);
|
||||
}
|
||||
|
||||
std::string APUDebug::_getPSWString()
|
||||
{
|
||||
std::string str;
|
||||
str += this->_internalRegisters.n ? 'n' : '-';
|
||||
str += this->_internalRegisters.v ? 'v' : '-';
|
||||
str += this->_internalRegisters.p ? 'p' : '-';
|
||||
str += this->_internalRegisters.b ? 'b' : '-';
|
||||
str += this->_internalRegisters.h ? 'h' : '-';
|
||||
str += this->_internalRegisters.i ? 'i' : '-';
|
||||
str += this->_internalRegisters.z ? 'z' : '-';
|
||||
str += this->_internalRegisters.c ? 'c' : '-';
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string APUDebug::_getInstructionString()
|
||||
{
|
||||
uint8_t opcode = this->_internalRead(this->_internalRegisters.pc);
|
||||
|
||||
switch (opcode) {
|
||||
case 0x00:
|
||||
return "NOP";
|
||||
case 0x10:
|
||||
return "BPL";
|
||||
case 0x20:
|
||||
return "CLRP";
|
||||
case 0x30:
|
||||
return "BMI";
|
||||
case 0x40:
|
||||
return "SETP";
|
||||
case 0x50:
|
||||
return "BVC";
|
||||
case 0x60:
|
||||
return "CLRC";
|
||||
case 0x70:
|
||||
return "BVS";
|
||||
case 0x80:
|
||||
return "SETC";
|
||||
case 0x90:
|
||||
return "BCC";
|
||||
case 0xA0:
|
||||
return "EI";
|
||||
case 0xB0:
|
||||
return "BCS";
|
||||
case 0xC0:
|
||||
return "DI";
|
||||
case 0xD0:
|
||||
return "BNE";
|
||||
case 0xE0:
|
||||
return "CLRV";
|
||||
case 0xF0:
|
||||
return "BEQ";
|
||||
case 0x01:
|
||||
case 0x11:
|
||||
case 0x21:
|
||||
case 0x31:
|
||||
case 0x41:
|
||||
case 0x51:
|
||||
case 0x61:
|
||||
case 0x71:
|
||||
case 0x81:
|
||||
case 0x91:
|
||||
case 0xA1:
|
||||
case 0xB1:
|
||||
case 0xC1:
|
||||
case 0xD1:
|
||||
case 0xE1:
|
||||
case 0xF1:
|
||||
return "TCALL";
|
||||
case 0x02:
|
||||
case 0x22:
|
||||
case 0x42:
|
||||
case 0x62:
|
||||
case 0x82:
|
||||
case 0xA2:
|
||||
case 0xC2:
|
||||
case 0xE2:
|
||||
return "SET1";
|
||||
case 0x12:
|
||||
case 0x32:
|
||||
case 0x52:
|
||||
case 0x72:
|
||||
case 0x92:
|
||||
case 0xB2:
|
||||
case 0xD2:
|
||||
case 0xF2:
|
||||
return "CLR1";
|
||||
case 0x03:
|
||||
case 0x13:
|
||||
case 0x23:
|
||||
case 0x33:
|
||||
case 0x43:
|
||||
case 0x53:
|
||||
case 0x63:
|
||||
case 0x73:
|
||||
case 0x83:
|
||||
case 0x93:
|
||||
case 0xA3:
|
||||
case 0xB3:
|
||||
case 0xC3:
|
||||
case 0xD3:
|
||||
case 0xE3:
|
||||
case 0xF3:
|
||||
return "BBC";
|
||||
case 0x04 ... 0x09:
|
||||
case 0x14 ... 0x19:
|
||||
return "OR";
|
||||
case 0x24 ... 0x29:
|
||||
case 0x34 ... 0x39:
|
||||
return "AND";
|
||||
case 0x44 ... 0x49:
|
||||
case 0x54 ... 0x59:
|
||||
return "EOR";
|
||||
case 0x64 ... 0x69:
|
||||
case 0x74 ... 0x79:
|
||||
case 0xC8:
|
||||
case 0xAD:
|
||||
case 0x1E:
|
||||
case 0x3E:
|
||||
case 0x5E:
|
||||
case 0x7E:
|
||||
return "CMP";
|
||||
case 0x84 ... 0x89:
|
||||
case 0x94 ... 0x99:
|
||||
return "ADC";
|
||||
case 0xA4 ... 0xA9:
|
||||
case 0xB4 ... 0xB9:
|
||||
return "SBC";
|
||||
case 0xC4 ... 0xC7:
|
||||
case 0xCB ... 0xCD:
|
||||
case 0xD4 ... 0xD9:
|
||||
case 0xE4 ... 0xE9:
|
||||
case 0xEB ... 0xEC:
|
||||
case 0xF4 ... 0xFB:
|
||||
case 0xDB:
|
||||
case 0xC9:
|
||||
case 0x5D:
|
||||
case 0x7D:
|
||||
case 0x8D:
|
||||
case 0x9D:
|
||||
case 0xBD:
|
||||
case 0xDD:
|
||||
case 0xFD:
|
||||
case 0x8F:
|
||||
case 0xAF:
|
||||
case 0xBF:
|
||||
return "MOV";
|
||||
case 0x0A:
|
||||
case 0x2A:
|
||||
return "OR1";
|
||||
case 0x1A:
|
||||
return "DECW";
|
||||
case 0x3A:
|
||||
return "INCW";
|
||||
case 0x4A:
|
||||
case 0x6A:
|
||||
return "AND1";
|
||||
case 0x5A:
|
||||
return "CMPW";
|
||||
case 0x7A:
|
||||
return "ADDW";
|
||||
case 0x8A:
|
||||
return "EOR1";
|
||||
case 0x9A:
|
||||
return "SUBW";
|
||||
case 0xAA:
|
||||
case 0xCA:
|
||||
return "MOV1";
|
||||
case 0xBA:
|
||||
case 0xDA:
|
||||
return "MOVW";
|
||||
case 0xEA:
|
||||
return "NOT1";
|
||||
case 0x0B ... 0x0C:
|
||||
case 0x1B ... 0x1C:
|
||||
return "ASL";
|
||||
case 0x2B ... 0x2C:
|
||||
case 0x3B ... 0x3C:
|
||||
return "ROL";
|
||||
case 0x4B ... 0x4C:
|
||||
case 0x5B ... 0x5C:
|
||||
return "LSR";
|
||||
case 0x6B ... 0x6C:
|
||||
case 0x7B ... 0x7C:
|
||||
return "ROR";
|
||||
case 0x8B ... 0x8C:
|
||||
case 0x9B ... 0x9C:
|
||||
case 0xDC:
|
||||
case 0x1D:
|
||||
return "DEC";
|
||||
case 0xAB ... 0xAC:
|
||||
case 0xBB ... 0xBC:
|
||||
case 0xFC:
|
||||
case 0x3D:
|
||||
return "INC";
|
||||
case 0x0D:
|
||||
case 0x2D:
|
||||
case 0x4D:
|
||||
case 0x6D:
|
||||
return "PUSH";
|
||||
case 0xED:
|
||||
return "NOTC";
|
||||
case 0x0E:
|
||||
return "TSET1";
|
||||
case 0x2E:
|
||||
case 0xDE:
|
||||
return "CBNE";
|
||||
case 0x4E:
|
||||
return "TCLR1";
|
||||
case 0x6E:
|
||||
case 0xFE:
|
||||
return "DBNZ";
|
||||
case 0x8E:
|
||||
case 0xAE:
|
||||
case 0xCE:
|
||||
case 0xEE:
|
||||
return "POP";
|
||||
case 0x9E:
|
||||
return "DIV";
|
||||
case 0xBE:
|
||||
return "DAS";
|
||||
case 0x0F:
|
||||
return "BRK";
|
||||
case 0x1F:
|
||||
case 0x5F:
|
||||
return "JMP";
|
||||
case 0x2F:
|
||||
return "BRA";
|
||||
case 0x3F:
|
||||
return "CALL";
|
||||
case 0x4F:
|
||||
return "PCALL";
|
||||
case 0x6F:
|
||||
return "RET";
|
||||
case 0x7F:
|
||||
return "RETI";
|
||||
case 0x9F:
|
||||
return "XCN";
|
||||
case 0xCF:
|
||||
return "MUL";
|
||||
case 0xDF:
|
||||
return "DAA";
|
||||
case 0xEF:
|
||||
return "SLEEP";
|
||||
case 0xFF:
|
||||
return "STOP";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
int APUDebug::_executeInstruction()
|
||||
{
|
||||
this->_ui.logger->append(APUDebug::_getInstructionString().c_str());
|
||||
this->_updatePanel();
|
||||
return APU::_executeInstruction();
|
||||
}
|
||||
|
||||
void APUDebug::update(unsigned cycles)
|
||||
{
|
||||
if (!this->isVisible()) {
|
||||
this->_snes.disableAPUDebugging();
|
||||
return;
|
||||
}
|
||||
return APU::update(cycles);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by Melefo on 19/02/2020.
|
||||
//
|
||||
|
||||
#ifndef COMSQUARE_APUDEBUG_HPP
|
||||
#define COMSQUARE_APUDEBUG_HPP
|
||||
|
||||
#include "../APU/APU.hpp"
|
||||
#include "../SNES.hpp"
|
||||
#include "../../ui/ui_apuView.h"
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
class APUDebug : public APU::APU, public QMainWindow {
|
||||
private:
|
||||
//! @brief A widget that contain the whole UI.
|
||||
Ui::APUView _ui;
|
||||
|
||||
//! @brief A reference to the snes (to disable the debugger).
|
||||
SNES &_snes;
|
||||
|
||||
//! @brief Update the debugger panel values
|
||||
void _updatePanel();
|
||||
|
||||
//! @brief Convert CPU APU flags to a string.
|
||||
std::string _getPSWString();
|
||||
|
||||
//! @brief Replace original _executeInstruction to write to the logger.
|
||||
int _executeInstruction() override;
|
||||
|
||||
//! @brief return the mnemonic of the current instruction done.
|
||||
std::string _getInstructionString();
|
||||
public:
|
||||
//! @brief Convert a basic APU to a debugging APU.
|
||||
explicit APUDebug(ComSquare::APU::APU &apu, SNES &snes);
|
||||
APUDebug(const APUDebug &) = delete;
|
||||
APUDebug &operator=(const APUDebug &) = delete;
|
||||
~APUDebug() override = default;
|
||||
|
||||
//! @brief Override the apu's update to disable debugging.
|
||||
void update(unsigned cycles) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //COMSQUARE_APUDEBUG_HPP
|
||||
@@ -4,9 +4,13 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include "MemoryViewer.hpp"
|
||||
#include "../SNES.hpp"
|
||||
#include "../Utility/Utility.hpp"
|
||||
#include "../Memory/MemoryShadow.hpp"
|
||||
#include "../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
MemoryViewerModel::MemoryViewerModel(std::shared_ptr<Ram> memory, QObject *parent) :
|
||||
QAbstractTableModel(parent),
|
||||
@@ -58,12 +62,12 @@ void MemoryViewerModel::setMemory(std::shared_ptr<Ram> memory)
|
||||
emit this->layoutChanged();
|
||||
}
|
||||
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
MemoryViewer::MemoryViewer(ComSquare::SNES &snes) :
|
||||
MemoryViewer::MemoryViewer(ComSquare::SNES &snes, Memory::MemoryBus &bus) :
|
||||
QMainWindow(),
|
||||
_snes(snes),
|
||||
_bus(bus),
|
||||
_ui(),
|
||||
_model(snes.wram)
|
||||
{
|
||||
@@ -77,6 +81,8 @@ namespace ComSquare::Debugger
|
||||
this->_ui.tabs->addTab("&SRam");
|
||||
this->_ui.tabs->addTab("&Rom");
|
||||
// this->_ui.tabs->addTab("&VRam");
|
||||
QMainWindow::connect(this->_ui.actionGoto, &QAction::triggered, this, &MemoryViewer::gotoAddr);
|
||||
QMainWindow::connect(this->_ui.actionGoto_Absolute, &QAction::triggered, this, &MemoryViewer::gotoAbsoluteAddr);
|
||||
QObject::connect(this->_ui.tabs, &QTabBar::currentChanged, this, &MemoryViewer::changeRam);
|
||||
this->show();
|
||||
}
|
||||
@@ -99,4 +105,61 @@ namespace ComSquare::Debugger
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryViewer::gotoAddr()
|
||||
{
|
||||
this->_internalGoto(false);
|
||||
}
|
||||
|
||||
void MemoryViewer::gotoAbsoluteAddr()
|
||||
{
|
||||
this->_internalGoto(true);
|
||||
}
|
||||
|
||||
void MemoryViewer::_internalGoto(bool isAbsolute)
|
||||
{
|
||||
QDialog dialog(this);
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
Ui::GotoDialog dialogUI;
|
||||
dialogUI.setupUi(&dialog);
|
||||
QFont font = dialogUI.spinBox->font();
|
||||
font.setCapitalization(QFont::AllUppercase);
|
||||
dialogUI.spinBox->setFont(font);
|
||||
dialogUI.spinBox->selectAll();
|
||||
dialogUI.checkBox->setChecked(isAbsolute);
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, nullptr, 16);
|
||||
if (dialogUI.checkBox->isChecked()) {
|
||||
try {
|
||||
value = this->switchToAddrTab(value);
|
||||
} catch (InvalidAddress &) {}
|
||||
}
|
||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
|
||||
this->_ui.tableView->scrollTo(index);
|
||||
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
|
||||
{
|
||||
std::shared_ptr<Memory::IMemory> accessor = this->_bus.getAccessor(addr);
|
||||
if (!accessor)
|
||||
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||
Memory::IMemory *ptr;
|
||||
if (accessor->isMirror())
|
||||
ptr = accessor->getMirrored().get();
|
||||
else
|
||||
ptr = accessor.get();
|
||||
|
||||
if (ptr == this->_snes.wram.get())
|
||||
this->_ui.tabs->setCurrentIndex(0);
|
||||
else if (ptr == this->_snes.sram.get())
|
||||
this->_ui.tabs->setCurrentIndex(1);
|
||||
else if (ptr == this->_snes.cartridge.get())
|
||||
this->_ui.tabs->setCurrentIndex(2);
|
||||
else
|
||||
throw InvalidAddress("Memory viewer switch to address", addr);
|
||||
return addr - accessor->getStart();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include "../../ui/ui_ramView.h"
|
||||
#include "../../ui/ui_gotoDialog.h"
|
||||
#include "../Ram/Ram.hpp"
|
||||
#include "../Memory/MemoryBus.hpp"
|
||||
#include <memory>
|
||||
|
||||
using ComSquare::Ram::Ram;
|
||||
|
||||
@@ -50,15 +53,27 @@ namespace ComSquare
|
||||
private:
|
||||
//! @brief SNES containing all rams to view.
|
||||
SNES &_snes;
|
||||
//! @brief The memory bus used to get the view for a given address.
|
||||
Memory::MemoryBus &_bus;
|
||||
//! @brief The layout of the viewer.
|
||||
Ui::RamView _ui;
|
||||
//! @brief The Ram visualizer model for QT.
|
||||
MemoryViewerModel _model;
|
||||
//! @brief Helper function to create the goto dialog.
|
||||
void _internalGoto(bool isAbsolute);
|
||||
public:
|
||||
//! @brief Select the memory tab corresponding to a 24 bit address (map the address via the bus).
|
||||
//! @return The address converted to the new tab's locale space.
|
||||
unsigned switchToAddrTab(uint24_t addr);
|
||||
|
||||
//! @brief Callback called when a memory tab is selected.
|
||||
void changeRam(int id);
|
||||
//! @brief Create a popup asking you where you want to jump to.
|
||||
void gotoAddr();
|
||||
//! @brief Create a popup asking you where you want to jump to with the absolute mode selected.
|
||||
void gotoAbsoluteAddr();
|
||||
|
||||
explicit MemoryViewer(SNES &snes);
|
||||
explicit MemoryViewer(SNES &snes, Memory::MemoryBus &bus);
|
||||
MemoryViewer(const MemoryViewer &) = delete;
|
||||
MemoryViewer &operator=(const MemoryViewer &) = delete;
|
||||
~MemoryViewer() override = default;
|
||||
|
||||
Reference in New Issue
Block a user