Skip to content

Allow the debugger to change register values #247

@neuromancer

Description

@neuromancer

I'm working on the reimplementation of some CPC games for ScummVM and I needed some debugging to change registers during the execution. Caprice32 allows to see the registers in the developer's tool and the fields are editable, but changing them will not do anything, so I did a quick patch:

diff --git a/src/gui/includes/cap_register.h b/src/gui/includes/cap_register.h
index d1fbd13..09973ff 100644
--- a/src/gui/includes/cap_register.h
+++ b/src/gui/includes/cap_register.h
@@ -35,6 +35,10 @@ public:
        //! Set the value of the register
        //! \param c The value to assign to the control
        void SetValue(const unsigned int c);
+       unsigned int GetValue() const {
+               std::string x = m_pHexValue->GetWindowText();
+               return stoi(x, nullptr, 16);
+       }
 
 protected:
 
diff --git a/src/gui/src/CapriceDevTools.cpp b/src/gui/src/CapriceDevTools.cpp
index e8487cb..5f6e01a 100644
--- a/src/gui/src/CapriceDevTools.cpp
+++ b/src/gui/src/CapriceDevTools.cpp
@@ -854,6 +854,7 @@ void CapriceDevTools::ResumeExecution()
 {
   CPC.paused = false;
   m_pButtonPause->SetWindowText("Pause");
+  z80.AF.b.h = m_pZ80RegA->GetValue();
 }
 
 void CapriceDevTools::LoadSymbols(const std::string& filename)

If you think this approach looks good, I can complete this code and create a small PR. Otherwise, this is a small feature request to make the debugger more useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions