Skip to content

Commit

Permalink
Better Monitor in FLTK
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 24, 2023
1 parent ac7f816 commit 1330a94
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Emulator/Platform/TNewt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
using namespace TNewt;

TEmulator* TNewt::mEmulator = nullptr; ///< Reference back to the Emulator
TMemory* TNewt::mMemory = nullptr; ///< Reference back to emulated memeory
TMemory* TNewt::mMemory = nullptr; ///< Reference back to emulated memory
TARMProcessor* TNewt::mCPU = nullptr; ///< Reference back to the emulated CPU

/**
Expand Down
46 changes: 37 additions & 9 deletions Monitor/TFLMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,12 @@ TFLMonitor::Show()
mwWindow = new TFLMonitorWindow(mx, my, mw, mh, "Einstein Monitor");
// ---- terminal window for all text output
mwTerminal = new Fl_Terminal(0, 0, mwWindow->w(), mwWindow->h() - 2 * ch);
mwTerminal->box(FL_FLAT_BOX);
mwTerminal->box(FL_DOWN_BOX);
// mwTerminal->init_tabstops(8); // default is 8
// mwTerminal->append("\033[3g\033[8G\033H"); // layout does not match well
// mwTerminal->hide_cursor();
mwTerminal->color(FL_LIGHT3);
mwTerminal->textcolor(FL_FOREGROUND_COLOR);
// mwTerminal->color(FL_LIGHT3);
// mwTerminal->textcolor(FL_FOREGROUND_COLOR);
// mwTerminal->cursor_color(FL_BACKGROUND_COLOR);
mwTerminal->ansi(true);
// mwTerminal->stay_at_bottom(true);
Expand All @@ -452,27 +454,48 @@ TFLMonitor::Show()
// --- the stop button stops the emulation
mwPause = new Fl_Button(xp, mwToolbar->y(), 3 * cw, 2 * ch, "@||");
xp += 3 * cw;
mwPause->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("stop"); }, this);
mwPause->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("stop");
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwPause);
// --- continue running the app
mwRun = new Fl_Button(xp, mwToolbar->y(), 3 * cw, 2 * ch, "@|>");
xp += 3 * cw;
mwRun->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("run"); }, this);
mwRun->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("run");
Fl::wait(0.1);
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwRun);
// --- step over
mwStepOver = new Fl_Button(xp, mwToolbar->y(), 3 * cw, 2 * ch, "@3redo");
xp += 3 * cw;
mwStepOver->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("trace"); }, this);
mwStepOver->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("trace");
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwStepOver);
// --- step into
mwStep = new Fl_Button(xp, mwToolbar->y(), 3 * cw, 2 * ch, "@2->|");
xp += 3 * cw;
mwStep->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("step"); }, this);
mwStep->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("step");
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwStep);
// --- leave
mwLeave = new Fl_Button(xp, mwToolbar->y(), 3 * cw, 2 * ch, "@8->|");
xp += 3 * cw;
mwLeave->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("mr"); }, this);
mwLeave->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("mr");
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwLeave);
// --- enter your commands here
mwInput = new Fl_Input(xp, mwToolbar->y(), mwWindow->w() - xp - 3 * cw, 2 * ch);
Expand All @@ -484,13 +507,18 @@ TFLMonitor::Show()
mwInput->callback([](Fl_Widget* w, void* m) {
Fl_Input* in = (Fl_Input*) w;
((TMonitor*) m)->ExecuteCommand(in->value());
((TFLMonitor*) m)->DrawScreen();
in->value("");
Fl::focus(in);
},
this);
// --- help
mwHelp = new Fl_Button(mwWindow->w() - 3 * cw, mwToolbar->y(), 3 * cw, 2 * ch, "?");
mwHelp->callback([](Fl_Widget*, void* m) { ((TMonitor*) m)->ExecuteCommand("help"); }, this);
mwHelp->callback([](Fl_Widget*, void* m) {
((TMonitor*) m)->ExecuteCommand("help");
((TFLMonitor*) m)->DrawScreen();
},
this);
set_attributes(mwHelp);
mwHelp->labelcolor(FL_BLACK);
// --- set resizing properties
Expand Down
1 change: 1 addition & 0 deletions Monitor/TMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ TMonitor::TMonitor(
mMonitorStartupScriptPath(strdup(inMonitorStartupScriptPath))
{
mMemory = inEmulator->GetMemory();
UDisasm::setMemory(mMemory);
mROMImageDir = strdup(mMonitorStartupScriptPath);
#if TARGET_OS_WIN32
char* pathEnd = strrchr(mROMImageDir, '\\');
Expand Down
3 changes: 2 additions & 1 deletion Monitor/TMonitorCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

TMonitorCore::TMonitorCore(TSymbolList* inSymbolList) :
mMemory(0L),
mSymbolList(inSymbolList)
mSymbolList(inSymbolList),
mDisasm(nullptr)
{
}

Expand Down
2 changes: 2 additions & 0 deletions Monitor/TMonitorCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TMemory;
class TARMProcessor;
class TInterruptManager;
class TSymbolList;
class UDisasm;

// Logging types for PrintLine()

Expand Down Expand Up @@ -84,6 +85,7 @@ class TMonitorCore
/// \name Variables
TMemory* mMemory; ///< Memory.
TSymbolList* mSymbolList; ///< List of symbols.
UDisasm* mDisasm; ///< Disassembler
};

#endif
Expand Down
21 changes: 21 additions & 0 deletions Monitor/UDisasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

// Einstein
#include "TSymbolList.h"
#include "Emulator/TMemory.h"

// ANSI C & POSIX
#include <stdio.h>
Expand All @@ -72,6 +73,7 @@
#endif

TSymbolList* UDisasm::pSymbolList = 0L;
TMemory* UDisasm::pMemory = 0L;

/*
* General instruction format
Expand Down Expand Up @@ -783,6 +785,19 @@ disasm_interface_t::di_printaddr(unsigned int inAddress)
{
di_printf("%08X =", inAddress);
di_printf("%s+%X", theSymbol, theOffset);
if (UDisasm::pMemory)
{
KUInt32 ptr = 0;
if (UDisasm::pMemory->ReadAligned(inAddress, ptr) == false)
{
char sym[512];
bool found = mSymbolList->GetSymbolByAddress(ptr, sym);
if (found)
{
di_printf(" [%s]", sym);
}
}
}
}
} else
{
Expand Down Expand Up @@ -1002,6 +1017,12 @@ UDisasm::setSymbolList(TSymbolList* aSymbolList)
pSymbolList = aSymbolList;
}

void
UDisasm::setMemory(TMemory* inMemory)
{
pMemory = inMemory;
}

// ====================================== //
// Crazee Edeee, his prices are INSANE!!! //
// ====================================== //
8 changes: 8 additions & 0 deletions Monitor/UDisasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <K/Defines/KDefinitions.h>

class TSymbolList;
class TMemory;

///
/// Class for a disassembler.
Expand Down Expand Up @@ -54,6 +55,13 @@ class UDisasm
///
static void setSymbolList(TSymbolList*);

///
/// make memory access possible
///
static void setMemory(TMemory*);

static TMemory* pMemory;

private:
static TSymbolList* pSymbolList;
};
Expand Down

0 comments on commit 1330a94

Please sign in to comment.