Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the debugger to change register values #247

Open
neuromancer opened this issue Dec 14, 2024 · 1 comment
Open

Allow the debugger to change register values #247

neuromancer opened this issue Dec 14, 2024 · 1 comment

Comments

@neuromancer
Copy link

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.

@ColinPitrat
Copy link
Owner

Having the option to edit the registers is definitely a good idea and I was planning to support it (hence the editable field) but then forgot about it !

One concern I have is the risk of changing the values by mistake. An option could be to have a confirmation button. On the other hand, having to click an extra button can be a pain... This option is fine so far IMO.

More problematic is the fact that the value is displayed in 3 fields (hex, dec and char) but only one is read when resuming the execution. An easy fix is to have only the hex field editable and make the others read-only. Alternatively (I don't remember how hard it would be to do), updating one field would directly update the others.

Note to self: I double checked and changing ResumeExecution should be enough to cover all the cases (resume, step-in, step-over, ...).

So in a nutshell, please do proceed with a PR. If you can make the dec & char fields read-only or ensure updating one of the 3 fields update the other 2 it would be nice.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants