More Debugger related work.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-05-15 13:32:34 +01:00
parent c36cbe5a31
commit 9d4f293a3c
7 changed files with 74 additions and 23 deletions

View file

@ -81,7 +81,6 @@ set(SOURCE_FILES
linux/network/tfe2.cpp
linux/network/slirp2.cpp
linux/duplicates/AppleWin.cpp
linux/duplicates/Debugger_Display.cpp
linux/duplicates/Debugger_Win32.cpp
linux/duplicates/Joystick.cpp

View file

@ -366,3 +366,8 @@ namespace na2
}
}
void SingleStep(bool /* bReinit */)
{
}

View file

@ -142,3 +142,8 @@ BYTE* QtFrame::GetResource(WORD id, LPCSTR lpType, DWORD expectedSize)
return reinterpret_cast<BYTE *>(myResource.data());
}
void SingleStep(bool /* bReinit */)
{
}

View file

@ -18,7 +18,6 @@
#include "Utilities.h"
#include "Memory.h"
#include "Debugger/Debug.h"
#include "Debugger/DebugDefs.h"
#include "Tfe/tfe.h"
@ -854,20 +853,15 @@ namespace sa2
const ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_ScrollY;
if (ImGui::BeginTable("Console", 1, flags))
{
for (int i = 0; i < CONSOLE_HEIGHT; ++i)
for (int i = g_nConsoleDisplayTotal; i >= CONSOLE_FIRST_LINE; --i)
{
const conchar_t * src = g_aConsoleDisplay[CONSOLE_HEIGHT - i - 1];
const conchar_t * src = g_aConsoleDisplay[i];
char line[CONSOLE_WIDTH + 1];
COLORREF currentColor = ConsoleColor_GetColor(src[0]);
line[0] = ConsoleChar_GetChar(src[0]);
size_t length = 1;
if (!line[0])
{
continue;
}
size_t length = 0;
ImGui::TableNextRow();
ImGui::TableNextColumn();
COLORREF currentColor = DebuggerGetColor( FG_CONSOLE_OUTPUT );
const auto textAndReset = [&line, &length, & currentColor] () {
line[length] = 0;
@ -876,7 +870,7 @@ namespace sa2
ImGui::TextColored(color, "%s", line);
};
for (size_t j = length; j < CONSOLE_WIDTH; ++j)
for (size_t j = 0; j < CONSOLE_WIDTH; ++j)
{
const conchar_t g = src[j];
if (ConsoleColor_IsColorOrMouse(g))
@ -888,10 +882,26 @@ namespace sa2
currentColor = ConsoleColor_GetColor(g);
}
line[length] = ConsoleChar_GetChar(g);
if (line[length])
{
++length;
}
else
{
break;
}
}
textAndReset();
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextUnformatted(g_aConsoleInput);
if (myScrollConsole)
{
ImGui::SetScrollHereY(1.0f);
myScrollConsole = false;
}
ImGui::EndTable();
}
}
@ -900,7 +910,8 @@ namespace sa2
{
if (ImGui::Begin("Debugger", &myShowDebugger))
{
if (ImGui::BeginTabBar("Settings"))
ImGui::BeginChild("Console", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()));
if (ImGui::BeginTabBar("Tabs"))
{
if (ImGui::BeginTabItem("CPU"))
{
@ -931,6 +942,10 @@ namespace sa2
{
frame->ChangeMode(MODE_PAUSED);
}
if ((ImGui::SameLine(), ImGui::Button("Debug")))
{
frame->ChangeMode(MODE_DEBUG);
}
ImGui::SameLine();
ImGui::Text("%016llu - %04X", g_nCumulativeCycles, regs.pc);
@ -961,9 +976,20 @@ namespace sa2
}
ImGui::EndTabBar();
}
ImGui::EndChild();
if (ImGui::InputText("Prompt", myInputBuffer, IM_ARRAYSIZE(myInputBuffer), ImGuiInputTextFlags_EnterReturnsTrue))
{
for (const char *ch = myInputBuffer; *ch; ++ch)
{
DebuggerInputConsoleChar(*ch);
}
DebuggerProcessKey(VK_RETURN);
myScrollConsole = true;
myInputBuffer[0] = 0;
ImGui::SetKeyboardFocusHere(-1);
}
}
ImGui::End();
}
}

View file

@ -2,6 +2,8 @@
#include "frontends/sdl/imgui/gles.h"
#include "frontends/sdl/sdirectsound.h"
#include "Debugger/Debug.h"
#include "Debugger/Debugger_Console.h"
namespace sa2
{
@ -24,6 +26,9 @@ namespace sa2
bool mySyncCPU = true;
bool myShowAbout = false;
bool myScrollConsole = true;
char myInputBuffer[CONSOLE_WIDTH] = "";
int myStepCycles = 0;
int mySpeakerVolume;
int myMockingboardVolume;

View file

@ -17,6 +17,7 @@
#include "Mockingboard.h"
#include "MouseInterface.h"
#include "Log.h"
#include "Debugger/Debug.h"
#include "linux/paddle.h"
#include "linux/keyboard.h"
@ -532,12 +533,20 @@ namespace sa2
{
// when running in adaptive speed
// the value msNextFrame is only a hint for when the next frame will arrive
if (g_nAppMode == MODE_RUNNING)
switch (g_nAppMode)
{
case MODE_RUNNING:
{
const size_t cyclesToExecute = mySpeed.getCyclesTillNext(msNextFrame * 1000);
Execute(cyclesToExecute);
break;
}
// else do nothing, it is either paused, debugged or stepped
case MODE_STEPPING:
{
DebugContinueStepping();
break;
}
};
}
void SDLFrame::ChangeMode(const AppMode_e mode)
@ -572,3 +581,8 @@ namespace sa2
}
}
void SingleStep(bool /* bReinit */)
{
dynamic_cast<sa2::SDLFrame &>(GetFrame()).Execute(0);
}

View file

@ -1,3 +0,0 @@
void SingleStep(bool /* bReinit */)
{
}