diff --git a/Emulator/Platform/TNewt.cpp b/Emulator/Platform/TNewt.cpp index d0edebb2..14b3e063 100644 --- a/Emulator/Platform/TNewt.cpp +++ b/Emulator/Platform/TNewt.cpp @@ -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 /** diff --git a/Monitor/TFLMonitor.cpp b/Monitor/TFLMonitor.cpp index a0867742..831db0ac 100644 --- a/Monitor/TFLMonitor.cpp +++ b/Monitor/TFLMonitor.cpp @@ -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); @@ -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); @@ -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 diff --git a/Monitor/TMonitor.cpp b/Monitor/TMonitor.cpp index 584a647c..096d5a44 100644 --- a/Monitor/TMonitor.cpp +++ b/Monitor/TMonitor.cpp @@ -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, '\\'); diff --git a/Monitor/TMonitorCore.cpp b/Monitor/TMonitorCore.cpp index 14376c68..7b068bba 100644 --- a/Monitor/TMonitorCore.cpp +++ b/Monitor/TMonitorCore.cpp @@ -46,7 +46,8 @@ TMonitorCore::TMonitorCore(TSymbolList* inSymbolList) : mMemory(0L), - mSymbolList(inSymbolList) + mSymbolList(inSymbolList), + mDisasm(nullptr) { } diff --git a/Monitor/TMonitorCore.h b/Monitor/TMonitorCore.h index c2ba7961..4571e00b 100644 --- a/Monitor/TMonitorCore.h +++ b/Monitor/TMonitorCore.h @@ -34,6 +34,7 @@ class TMemory; class TARMProcessor; class TInterruptManager; class TSymbolList; +class UDisasm; // Logging types for PrintLine() @@ -84,6 +85,7 @@ class TMonitorCore /// \name Variables TMemory* mMemory; ///< Memory. TSymbolList* mSymbolList; ///< List of symbols. + UDisasm* mDisasm; ///< Disassembler }; #endif diff --git a/Monitor/UDisasm.cpp b/Monitor/UDisasm.cpp index 2202f00f..541d4848 100644 --- a/Monitor/UDisasm.cpp +++ b/Monitor/UDisasm.cpp @@ -62,6 +62,7 @@ // Einstein #include "TSymbolList.h" +#include "Emulator/TMemory.h" // ANSI C & POSIX #include @@ -72,6 +73,7 @@ #endif TSymbolList* UDisasm::pSymbolList = 0L; +TMemory* UDisasm::pMemory = 0L; /* * General instruction format @@ -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 { @@ -1002,6 +1017,12 @@ UDisasm::setSymbolList(TSymbolList* aSymbolList) pSymbolList = aSymbolList; } +void +UDisasm::setMemory(TMemory* inMemory) +{ + pMemory = inMemory; +} + // ====================================== // // Crazee Edeee, his prices are INSANE!!! // // ====================================== // diff --git a/Monitor/UDisasm.h b/Monitor/UDisasm.h index 8f259745..98629919 100644 --- a/Monitor/UDisasm.h +++ b/Monitor/UDisasm.h @@ -27,6 +27,7 @@ #include class TSymbolList; +class TMemory; /// /// Class for a disassembler. @@ -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; };