diff --git a/CMakeLists.txt b/CMakeLists.txt index 904a817..a2a5618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,8 +177,8 @@ if (UNIX) target_link_libraries(${DEBUGGER_TARGET} xcb xcb-randr boost_regex) endif (UNIX) -target_link_libraries(${RUNTIME_TARGET} SDL2main SDL2 SDL2_image) -target_link_libraries(${DEBUGGER_TARGET} SDL2main SDL2 SDL2_image) +target_link_libraries(${RUNTIME_TARGET} SDL3 SDL3_image) +target_link_libraries(${DEBUGGER_TARGET} SDL3 SDL3_image) target_link_libraries(${RUNTIME_TARGET} ostd ogfx) target_link_libraries(${DEBUGGER_TARGET} ostd ogfx) diff --git a/build b/build index 6c19d8b..c675610 100755 --- a/build +++ b/build @@ -72,5 +72,23 @@ else ./ddb config/testMachine.dvm --verbose-load backtrack_changes cd .. + elif [[ "$1" == "gdb" ]]; then + printf "\n\033[0;32mDebugging Test Application...\n\n\033[0m" + cd bin + ./reload_env.sh + gdb -batch \ + -ex 'set pagination off' \ + -ex 'set print pretty on' \ + -ex 'set logging file gdb-last.log' \ + -ex 'set logging overwrite on' \ + -ex 'set logging on' \ + -ex 'handle SIGPIPE nostop noprint pass' \ + -ex run \ + -ex 'bt full' \ + -ex 'info locals' \ + -ex 'info args' \ + -ex quit \ + --args ./dvm config/testMachine.dvm + cd .. fi fi diff --git a/extra/dragon/disk1.dr b/extra/dragon/disk1.dr index c49dec6..3bbe04a 100644 Binary files a/extra/dragon/disk1.dr and b/extra/dragon/disk1.dr differ diff --git a/extra/dss/sdk/bios_api.dss b/extra/dss/sdk/bios_api.dss index b073ae5..6847cdf 100644 --- a/extra/dss/sdk/bios_api.dss +++ b/extra/dss/sdk/bios_api.dss @@ -1,5 +1,5 @@ ## -- -## -- This file is automatically generated by the DragonAssembler (version 0.4.1645) +## -- This file is automatically generated by the DragonAssembler (version 0.4.1646) ## -- Please do not modify this file in any way. ## -- diff --git a/src/debugger/Debugger.cpp b/src/debugger/Debugger.cpp index 43d62e8..ddddfef 100644 --- a/src/debugger/Debugger.cpp +++ b/src/debugger/Debugger.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace dragon { @@ -15,12 +16,12 @@ namespace dragon { validate(); enableSignals(); - connectSignal(ostd::tBuiltinSignals::WindowClosed); + connectSignal(ostd::BuiltinSignals::WindowClosed); } - void Debugger::tCloseEventListener::handleSignal(ostd::tSignal& signal) + void Debugger::tCloseEventListener::handleSignal(ostd::Signal& signal) { - m_mainWindowClosed = signal.ID == ostd::tBuiltinSignals::WindowClosed; + m_mainWindowClosed = signal.ID == ostd::BuiltinSignals::WindowClosed; } @@ -365,11 +366,11 @@ namespace dragon // ostd::String currCode = " ("; // currCode.add(minfo.currentInstructionOpCode).add(") "); // for (int32_t i = 0; i < minfo.currentInstructionFootprintSize; i++) - // currCode.add(ostd::String::getHexStr(minfo.currentInstructionFootprint[i], false, 1)).add(" "); + // currCode.add(ostd::String::getHexStr(minfo.currentInstructionFootprint[i], false, 1)).add(" "); // tmp.add(currCode); // tmp.addPadding(item_len, ' ', ostd::String::ePaddingBehavior::AllowOddExtraLeft); // // if (currCode != prevCode) - // // tmpStyle = "[@@style foreground:Black,background:BrightRed]"; + // // tmpStyle = "[@@style foreground:Black,background:BrightRed]"; // // else // tmpStyle = "[@@style foreground:Blue]"; // tmpStyle.add(tmp).add("[@@/]"); @@ -1418,7 +1419,7 @@ namespace dragon output().fg(ostd::ConsoleColors::Yellow).p("Press to enter in step-execution mode...").reset().nl(); while (!userQuit) { - ostd::SignalHandler::refresh(); + ostd::SignalHandler::handleDelegateSignals(); if (closeEventListener.hasHappened()) userQuit = true; data().command.clr(); diff --git a/src/debugger/Debugger.hpp b/src/debugger/Debugger.hpp index 8332b6b..b28192b 100644 --- a/src/debugger/Debugger.hpp +++ b/src/debugger/Debugger.hpp @@ -42,7 +42,7 @@ namespace dragon struct tCloseEventListener : public ostd::BaseObject { void init(void); - void handleSignal(ostd::tSignal& signal); + void handleSignal(ostd::Signal& signal); inline bool hasHappened(void) const { return m_mainWindowClosed; } private: diff --git a/src/debugger/DebuggerNew.cpp b/src/debugger/DebuggerNew.cpp index 4d3c292..f6616c0 100644 --- a/src/debugger/DebuggerNew.cpp +++ b/src/debugger/DebuggerNew.cpp @@ -1,13 +1,14 @@ #include "DebuggerNew.hpp" #include #include -#include -#include +#include +#include #include #include #include #include #include +#include #include "DisassemblyLoader.hpp" #include "../runtime/DragonRuntime.hpp" @@ -15,20 +16,20 @@ namespace ogfx { namespace gui { - Button::EventListener::EventListener(Button& _parent) : parent(_parent) + CustomButton::EventListener::EventListener(CustomButton& _parent) : parent(_parent) { - connectSignal(ostd::tBuiltinSignals::KeyPressed); - connectSignal(ostd::tBuiltinSignals::KeyReleased); - connectSignal(ostd::tBuiltinSignals::MouseMoved); - connectSignal(ostd::tBuiltinSignals::MousePressed); - connectSignal(ostd::tBuiltinSignals::MouseReleased); - connectSignal(ostd::tBuiltinSignals::OnGuiEvent); - connectSignal(ostd::tBuiltinSignals::WindowResized); + connectSignal(ostd::BuiltinSignals::KeyPressed); + connectSignal(ostd::BuiltinSignals::KeyReleased); + connectSignal(ostd::BuiltinSignals::MouseMoved); + connectSignal(ostd::BuiltinSignals::MousePressed); + connectSignal(ostd::BuiltinSignals::MouseReleased); + connectSignal(ostd::BuiltinSignals::OnGuiEvent); + connectSignal(ostd::BuiltinSignals::WindowResized); } - void Button::EventListener::handleSignal(ostd::tSignal& signal) + void CustomButton::EventListener::handleSignal(ostd::Signal& signal) { - if (signal.ID == ostd::tBuiltinSignals::KeyPressed) + if (signal.ID == ostd::BuiltinSignals::KeyPressed) { if (m_lastEvent != eEventType::KeyPressed) { @@ -51,7 +52,7 @@ namespace ogfx { } } - else if (signal.ID == ostd::tBuiltinSignals::MouseMoved) + else if (signal.ID == ostd::BuiltinSignals::MouseMoved) { auto& data = (ogfx::MouseEventData&)signal.userData; if (parent.contains((float)data.position_x, (float)data.position_y)) @@ -59,7 +60,7 @@ namespace ogfx else parent.m_mouseInside = false; } - else if (signal.ID == ostd::tBuiltinSignals::MousePressed) + else if (signal.ID == ostd::BuiltinSignals::MousePressed) { auto& data = (ogfx::MouseEventData&)signal.userData; if (data.button == ogfx::MouseEventData::eButton::Left && parent.m_gfx != nullptr && parent.m_mouseInside) @@ -70,7 +71,7 @@ namespace ogfx parent.m_pressed = true; } } - else if (signal.ID == ostd::tBuiltinSignals::MouseReleased) + else if (signal.ID == ostd::BuiltinSignals::MouseReleased) { auto& data = (ogfx::MouseEventData&)signal.userData; if (data.button == ogfx::MouseEventData::eButton::Left && parent.m_gfx != nullptr) @@ -78,7 +79,7 @@ namespace ogfx if (parent.m_pressed) { ActionEventData aed(parent, parent.getName(), eActionEventType::Pressed, ostd::BaseObject::InvalidRef()); - ostd::SignalHandler::emitSignal(Button::actionEventSignalID, ostd::tSignalPriority::RealTime, aed); + ostd::SignalHandler::emitSignal(CustomButton::actionEventSignalID, ostd::Signal::Priority::RealTime, aed); } parent.m_pressed = false; } @@ -90,7 +91,7 @@ namespace ogfx - Button& Button::create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name) + CustomButton& CustomButton::create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name) { setPosition(position); setSize(size); @@ -100,7 +101,7 @@ namespace ogfx return *this; } - void Button::render(ogfx::BasicRenderer2D& gfx) + void CustomButton::render(ogfx::BasicRenderer2D& gfx) { m_gfx = &gfx; ostd::Color backgroundColor = m_theme.backgroundColor; @@ -121,34 +122,34 @@ namespace ogfx gfx.outlinedRect(*this, backgroundColor, borderColor, 2); if (m_text.len() > 0) { - ostd::IPoint strSize = gfx.getStringSize(m_text, m_theme.fontSize); + ostd::IPoint strSize = gfx.getStringDimensions(m_text, m_theme.fontSize); ostd::Vec2 txtPos = getPosition() + ostd::Vec2 { (getw() / 2.0f) - (strSize.x / 2.0f), (geth() / 2.0f) - (strSize.y / 2.0f) }; gfx.drawString(m_text, txtPos, textColor, m_theme.fontSize); } onRender(gfx); } - void Button::update(void) + void CustomButton::update(void) { onUpdate(); } - void Button::fixedUpdate(void) + void CustomButton::fixedUpdate(void) { onFixedUpdate(); } - void Button::setText(const ostd::String& text) + void CustomButton::setText(const ostd::String& text) { m_text = text; } - void Button::appendText(const ostd::String& text) + void CustomButton::appendText(const ostd::String& text) { m_text.add(text); } - void Button::setTheme(Theme theme) + void CustomButton::setTheme(Theme theme) { m_theme = theme; } @@ -256,7 +257,7 @@ namespace dragon while (dragon::data::ErrorHandler::hasError()) { auto err = dragon::data::ErrorHandler::popError(); - out.nl().fg(ostd::ConsoleColors::Red).p("Error ").p(ostd::String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl(); + out().nl().fg(ostd::ConsoleColors::Red).p("Error ").p(ostd::String::getHexStr(err.code, true, 8).cpp_str()).p(": ").p(err.text.cpp_str()).nl(); } debugger.args.step_exec = true; } @@ -265,8 +266,8 @@ namespace dragon { if (argc < 2) { - out.fg(ostd::ConsoleColors::Red).p("Error: too few arguments.").nl(); - out.fg(ostd::ConsoleColors::Red).p("Use the --help option for more info.").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Error: too few arguments.").nl(); + out().fg(ostd::ConsoleColors::Red).p("Use the --help option for more info.").reset().nl(); return DragonRuntime::RETURN_VAL_TOO_FEW_ARGUMENTS; } else @@ -345,8 +346,8 @@ namespace dragon // while ((key = kbc.getPressedKey()) != ostd::eKeys::Enter) // { - // if (key == ostd::eKeys::Escape) - // return InputCommandQuit; + // if (key == ostd::eKeys::Escape) + // return InputCommandQuit; // } // return kbc.getInputString(); @@ -357,14 +358,14 @@ namespace dragon { int32_t rValue = 0; bool userQuit = false; - output().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl(); + out().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl(); if (!data().args.step_exec) - output().fg(ostd::ConsoleColors::Yellow).p("Press to enter in step-execution mode...").reset().nl(); + out().fg(ostd::ConsoleColors::Yellow).p("Press to enter in step-execution mode...").reset().nl(); while (!userQuit) { - ostd::SignalHandler::refresh(); + ostd::SignalHandler::handleDelegateSignals(); // if (closeEventListener.hasHappened()) - // userQuit = true; + // userQuit = true; data().command.clr(); if (!userQuit && data().args.step_exec) rValue = step_execution(userQuit, true); @@ -372,7 +373,7 @@ namespace dragon rValue = normal_runtime(userQuit); data().currentAddress = DragonRuntime::cpu.readRegister(data::Registers::IP); } - output().nl().fg(ostd::ConsoleColors::Yellow).p("Execution terminated.").nl().nl().reset(); + out().nl().fg(ostd::ConsoleColors::Yellow).p("Execution terminated.").nl().nl().reset(); return rValue; } @@ -383,7 +384,7 @@ namespace dragon // Display::printStep(); processErrors(); if (DragonRuntime::cpu.isInDebugBreakPoint()) - output().fg(ostd::ConsoleColors::Red).p("Reached Debug Break Point.").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Reached Debug Break Point.").reset().nl(); // Display::printPrompt(); data().command = getCommandInput(); data().command.trim().toLower(); @@ -391,7 +392,7 @@ namespace dragon { if (data().command == "q" || data().command == "quit" || data().command == InputCommandQuit) { - output().nl(); + out().nl(); outUserQuit = true; data().command = ""; } @@ -399,8 +400,8 @@ namespace dragon { data().args.step_exec = false; data().command = ""; - output().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl(); - output().fg(ostd::ConsoleColors::Yellow).p("Press to enter in step-execution mode...").reset().nl(); + out().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl(); + out().fg(ostd::ConsoleColors::Yellow).p("Press to enter in step-execution mode...").reset().nl(); } else if (data().command.startsWith("p ") || data().command.startsWith("print ")) { @@ -442,18 +443,18 @@ namespace dragon rgx.fg("\\(|\\)|-", "darkgray"); rgx.fg("\\*", "red"); rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(? command.").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Unknown symbol for command.").reset().nl(); else { ostd::String tmp = ""; @@ -474,32 +475,32 @@ namespace dragon rgx.fg("\\(|\\)|-", "darkgray"); rgx.fg("\\*", "red"); rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(? command.").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Invalid value for command.").reset().nl(); } // Display::printPrompt(); data().command = getCommandInput(); @@ -518,25 +519,25 @@ namespace dragon { addr = findSymbol(debugger.labels, data().command); if (addr == 0x0000 || addr == 0xFFFF) - output().fg(ostd::ConsoleColors::Red).p("Invalid symbol: ").p(data().command).reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Invalid symbol: ").p(data().command).reset().nl(); else valid = true; } else { - output().fg(ostd::ConsoleColors::Red).p("Invalid value for command.").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("Invalid value for command.").reset().nl(); } if (valid) { if (isBreakPoint(addr)) { removeBreakPoint(addr); - output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl(); + out().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl(); } else { addBreakPoint(addr); - output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl(); + out().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::String::getHexStr(addr, true, 2)).reset().nl(); } } // Display::printPrompt(); @@ -670,17 +671,16 @@ namespace dragon void DebuggerNew::onInitialize(void) { enableSignals(); - connectSignal(ostd::tBuiltinSignals::KeyReleased); + connectSignal(ostd::BuiltinSignals::KeyReleased); connectSignal(ogfx::gui::RawTextInput::actionEventSignalID); - connectSignal(ogfx::gui::Button::actionEventSignalID); - enableMouseDragEvent(false); + connectSignal(ogfx::gui::CustomButton::actionEventSignalID); // DisassemblyLoader::loadDirectory("disassembly"); // m_codeTable = DisassemblyLoader::getCodeTable(); // m_codeRandomIndex = ostd::Random::geti32(0, m_codeTable.size() - m_consoleSize.y - 1); m_gfx.init(*this); - m_gfx.setFont("res/Courier Prime.ttf"); + m_gfx.openFont("res/Courier Prime.ttf"); float w = m_consolePosition.x - 12; float h = 40.0f; @@ -697,21 +697,21 @@ namespace dragon m_wout.setFontSize(22); m_wout.setConsoleMaxCharacters(m_consoleSize); m_wout.setConsolePosition(m_consolePosition); - m_wout.setWrapMode(ogfx::WindowBaseOutputHandler::eWrapMode::TripleDots); + m_wout.setWrapMode(ogfx::GraphicsWindowOutputHandler::eWrapMode::TripleDots); m_wout.setDefaultForegroundColor({ 180, 180, 180, 255 }); std::cout << STR_BOOL(ostd::Memory::loadByteStreamFromFile("./bios.bin", m_test)) << "\n"; - } + } - void DebuggerNew::handleSignal(ostd::tSignal& signal) + void DebuggerNew::handleSignal(ostd::Signal& signal) { - if (signal.ID == ostd::tBuiltinSignals::KeyReleased) + if (signal.ID == ostd::BuiltinSignals::KeyReleased) { auto& evtData = (ogfx::KeyEventData&)signal.userData; if (evtData.keyCode == SDLK_ESCAPE) close(); // else if (evtData.keyCode == SDLK_SPACE) - // m_codeRandomIndex = ostd::Random::geti32(0, m_codeTable.size() - m_consoleSize.y - 1); + // m_codeRandomIndex = ostd::Random::geti32(0, m_codeTable.size() - m_consoleSize.y - 1); } else if (signal.ID == ogfx::gui::RawTextInput::actionEventSignalID) { @@ -720,23 +720,23 @@ namespace dragon return; if (data.eventType == ogfx::gui::RawTextInput::eActionEventType::Enter) { - out.fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl(); + out().fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl(); data.sender.setText(""); } else if (data.eventType == ogfx::gui::RawTextInput::eActionEventType::Tab) { - out.fg(ostd::ConsoleColors::Red).p("TAB").reset().nl(); + out().fg(ostd::ConsoleColors::Red).p("TAB").reset().nl(); data.sender.appendText("TAB"); } } - else if (signal.ID == ogfx::gui::Button::actionEventSignalID) + else if (signal.ID == ogfx::gui::CustomButton::actionEventSignalID) { - auto& data = (ogfx::gui::Button::ActionEventData&)signal.userData; + auto& data = (ogfx::gui::CustomButton::ActionEventData&)signal.userData; if (data.senderName != "TestBTN") return; - if (data.eventType == ogfx::gui::Button::eActionEventType::Pressed) + if (data.eventType == ogfx::gui::CustomButton::eActionEventType::Pressed) { - out.fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl(); + out().fg(ostd::ConsoleColors::Green).p(data.sender.getText()).reset().nl(); } } } diff --git a/src/debugger/DebuggerNew.hpp b/src/debugger/DebuggerNew.hpp index bf7087c..c6f6158 100644 --- a/src/debugger/DebuggerNew.hpp +++ b/src/debugger/DebuggerNew.hpp @@ -4,10 +4,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "../assembler/Assembler.hpp" @@ -15,19 +15,19 @@ namespace ogfx { namespace gui { - class Button : public ostd::Rectangle + class CustomButton : public ostd::Rectangle { public: class EventListener : public ostd::BaseObject { public: enum class eEventType { None = 0, MousePressed, KeyPressed, KeyReleased }; public: - EventListener(Button& _parent); - virtual void handleSignal(ostd::tSignal& signal) override; - inline virtual void onSignalHandled(ostd::tSignal& signal) { } - inline Button& getParent(void) { return parent; } + EventListener(CustomButton& _parent); + virtual void handleSignal(ostd::Signal& signal) override; + inline virtual void onSignalHandled(ostd::Signal& signal) { } + inline CustomButton& getParent(void) { return parent; } private: - Button& parent; + CustomButton& parent; eEventType m_lastEvent { eEventType::None }; }; public: class Theme @@ -50,61 +50,61 @@ namespace ogfx public: struct tDefaultThemes { inline static const Theme DebugTheme { - { 220, 220, 255 }, //Text Color - { 10, 20, 120 }, //Border Color - { 0, 0, 22 }, //Background Color + { 220, 220, 255 }, //Text Color + { 10, 20, 120 }, //Border Color + { 0, 0, 22 }, //Background Color - { 220, 220, 255 }, //Text Color Hover - { 10, 20, 120 }, //Border Color Hover - { 0, 0, 22 }, //Background Color Hover + { 220, 220, 255 }, //Text Color Hover + { 10, 20, 120 }, //Border Color Hover + { 0, 0, 22 }, //Background Color Hover - { 220, 220, 255 }, //Text Color Pressed - { 10, 20, 120 }, //Border Color Pressed - { 0, 0, 22 }, //Background Color Pressed + { 220, 220, 255 }, //Text Color Pressed + { 10, 20, 120 }, //Border Color Pressed + { 0, 0, 22 }, //Background Color Pressed - 20 //Font Size + 20 //Font Size }; inline static const Theme DefaultTheme { - { 120, 120, 180 }, //Text Color - { 10, 20, 120 }, //Border Color - { 0, 2, 10 }, //Background Color + { 120, 120, 180 }, //Text Color + { 10, 20, 120 }, //Border Color + { 0, 2, 10 }, //Background Color - { 120, 120, 210 }, //Text Color Hover - { 10, 20, 180 }, //Border Color Hover - { 0, 2, 50 }, //Background Color Hover + { 120, 120, 210 }, //Text Color Hover + { 10, 20, 180 }, //Border Color Hover + { 0, 2, 50 }, //Background Color Hover - { 120, 120, 120 }, //Text Color Pressed - { 10, 20, 60 }, //Border Color Pressed - { 0, 2, 0 }, //Background Color Pressed + { 120, 120, 120 }, //Text Color Pressed + { 10, 20, 60 }, //Border Color Pressed + { 0, 2, 0 }, //Background Color Pressed - 20 //Font Size + 20 //Font Size }; }; public: enum eActionEventType { None = 0, Pressed }; public: class ActionEventData : public ostd::BaseObject { public: - inline ActionEventData(Button& _sender, const ostd::String& _senderName, eActionEventType _eventType, ostd::BaseObject& _userData) : + inline ActionEventData(CustomButton& _sender, const ostd::String& _senderName, eActionEventType _eventType, ostd::BaseObject& _userData) : sender(_sender), senderName(_senderName), eventType(_eventType), userData(_userData) { - setTypeName("ogfx::gui::Button::ActionEventData"); + setTypeName("ogfx::gui::CustomButton::ActionEventData"); validate(); } public: - Button& sender; + CustomButton& sender; ostd::String senderName { "" }; eActionEventType eventType { eActionEventType::None }; ostd::BaseObject& userData { ostd::BaseObject::InvalidRef() }; }; public: - inline Button(void) { create({ 0.0f, 0.0f }, { 200.0f, 30.0f }, "UnnamedButton"); } - inline Button(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name) { create(position, size, name); } - Button& create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name); + inline CustomButton(void) { create({ 0.0f, 0.0f }, { 200.0f, 30.0f }, "UnnamedButton"); } + inline CustomButton(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name) { create(position, size, name); } + CustomButton& create(const ostd::Vec2& position, const ostd::Vec2& size, const ostd::String& name); virtual void render(ogfx::BasicRenderer2D& gfx); virtual void update(void); @@ -149,7 +149,7 @@ namespace dragon { typedef std::vector DisassemblyList; - class DebuggerNew : public ogfx::WindowBase + class DebuggerNew : public ogfx::GraphicsWindow { public: struct tCommandLineArgs { @@ -197,7 +197,6 @@ namespace dragon int32_t initRuntime(void); ostd::String getCommandInput(void); inline tDebuggerData& data(void) { return debugger; } - inline ostd::ConsoleOutputHandler& output(void) { return out; } int32_t executeRuntime(void); int32_t step_execution(bool& outUserQuit, bool exec_first_step = true); int32_t normal_runtime(bool& outUserQuit); @@ -210,7 +209,7 @@ namespace dragon //General inline DebuggerNew(void) : m_sigHandler(m_textInput, *this), m_btnSigHandler(m_testBtn) { } void onInitialize(void) override; - void handleSignal(ostd::tSignal& signal) override; + void handleSignal(ostd::Signal& signal) override; void onRender(void) override; void onFixedUpdate(double frameTime_s) override; void onUpdate(void) override; @@ -222,10 +221,10 @@ namespace dragon ogfx::gui::RawTextInputEventListener m_sigHandler; ogfx::gui::RawTextInputNumberCharacterFilter m_numCharFilter; - ogfx::gui::Button m_testBtn; - ogfx::gui::Button::EventListener m_btnSigHandler; + ogfx::gui::CustomButton m_testBtn; + ogfx::gui::CustomButton::EventListener m_btnSigHandler; - ogfx::WindowBaseOutputHandler m_wout; + ogfx::GraphicsWindowOutputHandler m_wout; ostd::IPoint m_consoleSize { 300, 50 }; ostd::Vec2 m_consolePosition { 650, 8 }; // std::vector m_codeTable; diff --git a/src/debugger/debugger_main.cpp b/src/debugger/debugger_main.cpp index 38479d7..33c6221 100644 --- a/src/debugger/debugger_main.cpp +++ b/src/debugger/debugger_main.cpp @@ -6,8 +6,6 @@ int main(int argc, char** argv) { - ostd::SignalHandler::init(); - //Loading commandline arguments int32_t rValue = dragon::Debugger::loadArguments(argc, argv); if (rValue == dragon::DragonRuntime::RETURN_VAL_CLOSE_DEBUGGER) @@ -38,18 +36,18 @@ int main(int argc, char** argv) // //Loading commandline arguments // int32_t rValue = debuggerInstance.loadArguments(argc, argv); // if (rValue == dragon::DragonRuntime::RETURN_VAL_CLOSE_DEBUGGER) - // return 0; + // return 0; // if (rValue != 0) return rValue; // //Initializing the runtime // rValue = debuggerInstance.initRuntime(); // if (rValue == dragon::DragonRuntime::RETURN_VAL_CLOSE_DEBUGGER) - // return 0; + // return 0; // if (rValue != 0) return rValue; // while (debuggerInstance.isRunning()) // { - // debuggerInstance.update(); + // debuggerInstance.update(); // } return 0; diff --git a/src/hardware/VirtualCPU.cpp b/src/hardware/VirtualCPU.cpp index 676ecff..7f25830 100644 --- a/src/hardware/VirtualCPU.cpp +++ b/src/hardware/VirtualCPU.cpp @@ -180,7 +180,7 @@ namespace dragon interruptData.addr = intValue; interruptData.inst_addr = 0x0000; interruptData.interrupts_disabled = !readFlag(data::Flags::InterruptsEnabled); - ostd::SignalHandler::emitSignal(DragonRuntime::SignalListener::Signal_HardwareInterruptOccurred, ostd::tSignalPriority::RealTime, interruptData); + ostd::SignalHandler::emitSignal(DragonRuntime::SignalListener::Signal_HardwareInterruptOccurred, ostd::Signal::Priority::RealTime, interruptData); } } diff --git a/src/hardware/VirtualCPU.hpp b/src/hardware/VirtualCPU.hpp index 980aaf6..744332b 100644 --- a/src/hardware/VirtualCPU.hpp +++ b/src/hardware/VirtualCPU.hpp @@ -80,7 +80,7 @@ namespace dragon std::vector m_debug_stackFrameStrings; - ostd::Timer m_profilerTimer; + ostd::Counter m_profilerTimer; friend class dragon::DragonRuntime; friend class dragon::Debugger::Display; diff --git a/src/hardware/VirtualDisplay.cpp b/src/hardware/VirtualDisplay.cpp index dbde97f..92672a3 100644 --- a/src/hardware/VirtualDisplay.cpp +++ b/src/hardware/VirtualDisplay.cpp @@ -1,5 +1,5 @@ #include "VirtualDisplay.hpp" -#include +#include #include "../runtime/DragonRuntime.hpp" #include "../tools/GlobalData.hpp" diff --git a/src/hardware/VirtualDisplay.hpp b/src/hardware/VirtualDisplay.hpp index 63419d2..5623410 100644 --- a/src/hardware/VirtualDisplay.hpp +++ b/src/hardware/VirtualDisplay.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include "../hardware/VirtualIODevices.hpp" namespace dragon @@ -9,7 +9,7 @@ namespace dragon namespace data { class IBiosVideoPalette; } namespace hw { - class VirtualDisplay : public ogfx::WindowBase + class VirtualDisplay : public ogfx::GraphicsWindow { public: struct tRegisters { diff --git a/src/hardware/VirtualIODevices.cpp b/src/hardware/VirtualIODevices.cpp index df0212c..884d20c 100644 --- a/src/hardware/VirtualIODevices.cpp +++ b/src/hardware/VirtualIODevices.cpp @@ -5,13 +5,13 @@ #include "VirtualCPU.hpp" #include "../runtime/DragonRuntime.hpp" -#include +#include #include //TODO: Fix all access functions (reads and writes) ensuring the address is not out of bounds. -// Right now the check is done, but just to push an error if out of bounds; the address -// gets still used even in that case, which is really dumb and will probably crash the -// runtime most of the time. +// Right now the check is done, but just to push an error if out of bounds; the address +// gets still used even in that case, which is really dumb and will probably crash the +// runtime most of the time. namespace dragon { @@ -118,9 +118,9 @@ namespace dragon m_data.push_back(0x00); enableSignals(); validate(); - connectSignal(ostd::tBuiltinSignals::KeyPressed); - connectSignal(ostd::tBuiltinSignals::KeyReleased); - connectSignal(ostd::tBuiltinSignals::TextEntered); + connectSignal(ostd::BuiltinSignals::KeyPressed); + connectSignal(ostd::BuiltinSignals::KeyReleased); + connectSignal(ostd::BuiltinSignals::TextEntered); } int8_t VirtualKeyboard::read8(uint16_t addr) @@ -167,11 +167,11 @@ namespace dragon return &m_data; } - void VirtualKeyboard::handleSignal(ostd::tSignal& signal) + void VirtualKeyboard::handleSignal(ostd::Signal& signal) { auto& cpu = DragonRuntime::cpu; const auto& state = SDL_GetKeyboardState(nullptr); - if (signal.ID == ostd::tBuiltinSignals::KeyPressed || signal.ID == ostd::tBuiltinSignals::KeyReleased) + if (signal.ID == ostd::BuiltinSignals::KeyPressed || signal.ID == ostd::BuiltinSignals::KeyReleased) { ogfx::KeyEventData& ked = (ogfx::KeyEventData&)signal.userData; m_modifiersBitFiels = __construct_modifiers_bitfield(); @@ -182,12 +182,12 @@ namespace dragon else if (ked.eventType == ogfx::KeyEventData::eKeyEvent::Pressed) cpu.handleInterrupt(data::InterruptCodes::KeyReleased, true); } - else if (signal.ID == ostd::tBuiltinSignals::TextEntered) + else if (signal.ID == ostd::BuiltinSignals::TextEntered) { ogfx::KeyEventData& ked = (ogfx::KeyEventData&)signal.userData; m_modifiersBitFiels = __construct_modifiers_bitfield(); __write16(tRegisters::Modifiers, (int16_t)m_modifiersBitFiels.value); - __write16(tRegisters::KeyCode, (int16_t)ked.text); + __write16(tRegisters::KeyCode, (int16_t)ked.text[0]); cpu.handleInterrupt(data::InterruptCodes::TextEntered, true); } } @@ -196,17 +196,17 @@ namespace dragon { ostd::BitField_16 bitfield; auto mod_state = SDL_GetModState(); - ostd::Bits::val(bitfield, tModifierBits::LeftShift, (mod_state & KMOD_LSHIFT)); - ostd::Bits::val(bitfield, tModifierBits::LeftControl, (mod_state & KMOD_LCTRL)); - ostd::Bits::val(bitfield, tModifierBits::LeftAlt, (mod_state & KMOD_LALT)); - ostd::Bits::val(bitfield, tModifierBits::LeftSuper, (mod_state & KMOD_LGUI)); - ostd::Bits::val(bitfield, tModifierBits::RightShift, (mod_state & KMOD_RSHIFT)); - ostd::Bits::val(bitfield, tModifierBits::RightControl, (mod_state & KMOD_RCTRL)); - ostd::Bits::val(bitfield, tModifierBits::RightAlt, (mod_state & KMOD_RALT)); - ostd::Bits::val(bitfield, tModifierBits::RightSuper, (mod_state & KMOD_RGUI)); - ostd::Bits::val(bitfield, tModifierBits::CapsLock, (mod_state & KMOD_CAPS)); - ostd::Bits::val(bitfield, tModifierBits::NumLock, (mod_state & KMOD_NUM)); - ostd::Bits::val(bitfield, tModifierBits::ScrolLLock, (mod_state & KMOD_SCROLL)); + ostd::Bits::val(bitfield, tModifierBits::LeftShift, (mod_state & SDL_KMOD_LSHIFT)); + ostd::Bits::val(bitfield, tModifierBits::LeftControl, (mod_state & SDL_KMOD_LCTRL)); + ostd::Bits::val(bitfield, tModifierBits::LeftAlt, (mod_state & SDL_KMOD_LALT)); + ostd::Bits::val(bitfield, tModifierBits::LeftSuper, (mod_state & SDL_KMOD_LGUI)); + ostd::Bits::val(bitfield, tModifierBits::RightShift, (mod_state & SDL_KMOD_RSHIFT)); + ostd::Bits::val(bitfield, tModifierBits::RightControl, (mod_state & SDL_KMOD_RCTRL)); + ostd::Bits::val(bitfield, tModifierBits::RightAlt, (mod_state & SDL_KMOD_RALT)); + ostd::Bits::val(bitfield, tModifierBits::RightSuper, (mod_state & SDL_KMOD_RGUI)); + ostd::Bits::val(bitfield, tModifierBits::CapsLock, (mod_state & SDL_KMOD_CAPS)); + ostd::Bits::val(bitfield, tModifierBits::NumLock, (mod_state & SDL_KMOD_NUM)); + ostd::Bits::val(bitfield, tModifierBits::ScrolLLock, (mod_state & SDL_KMOD_SCROLL)); return bitfield; } @@ -283,12 +283,12 @@ namespace dragon case SDLK_TAB: return (int16_t)eKeys::Tab; case SDLK_SPACE: return (int16_t)eKeys::Spacebar; case SDLK_EXCLAIM: return (int16_t)eKeys::ExclamationMark; - case SDLK_QUOTEDBL: return (int16_t)eKeys::DoubleQuote; + case SDLK_DBLAPOSTROPHE: return (int16_t)eKeys::DoubleQuote; case SDLK_HASH: return (int16_t)eKeys::Hash; case SDLK_PERCENT: return (int16_t)eKeys::Percent; case SDLK_DOLLAR: return (int16_t)eKeys::DollarSign; case SDLK_AMPERSAND: return (int16_t)eKeys::Ampersand; - case SDLK_QUOTE: return (int16_t)eKeys::SingleQuote; + case SDLK_APOSTROPHE: return (int16_t)eKeys::SingleQuote; case SDLK_LEFTPAREN: return (int16_t)eKeys::LeftParenthesis; case SDLK_RIGHTPAREN: return (int16_t)eKeys::RightParenthesis; case SDLK_ASTERISK: return (int16_t)eKeys::Asterisk; @@ -319,33 +319,33 @@ namespace dragon case SDLK_RIGHTBRACKET: return (int16_t)eKeys::RightBracket; case SDLK_CARET: return (int16_t)eKeys::Caret; case SDLK_UNDERSCORE: return (int16_t)eKeys::Underscore; - case SDLK_BACKQUOTE: return (int16_t)eKeys::BackQuote; - case SDLK_a: return (int16_t)eKeys::LowerCase_a; - case SDLK_b: return (int16_t)eKeys::LowerCase_b; - case SDLK_c: return (int16_t)eKeys::LowerCase_c; - case SDLK_d: return (int16_t)eKeys::LowerCase_d; - case SDLK_e: return (int16_t)eKeys::LowerCase_e; - case SDLK_f: return (int16_t)eKeys::LowerCase_f; - case SDLK_g: return (int16_t)eKeys::LowerCase_g; - case SDLK_h: return (int16_t)eKeys::LowerCase_h; - case SDLK_i: return (int16_t)eKeys::LowerCase_i; - case SDLK_j: return (int16_t)eKeys::LowerCase_j; - case SDLK_k: return (int16_t)eKeys::LowerCase_k; - case SDLK_l: return (int16_t)eKeys::LowerCase_l; - case SDLK_m: return (int16_t)eKeys::LowerCase_m; - case SDLK_n: return (int16_t)eKeys::LowerCase_n; - case SDLK_o: return (int16_t)eKeys::LowerCase_o; - case SDLK_p: return (int16_t)eKeys::LowerCase_p; - case SDLK_q: return (int16_t)eKeys::LowerCase_q; - case SDLK_r: return (int16_t)eKeys::LowerCase_r; - case SDLK_s: return (int16_t)eKeys::LowerCase_s; - case SDLK_t: return (int16_t)eKeys::LowerCase_t; - case SDLK_u: return (int16_t)eKeys::LowerCase_u; - case SDLK_v: return (int16_t)eKeys::LowerCase_v; - case SDLK_w: return (int16_t)eKeys::LowerCase_w; - case SDLK_x: return (int16_t)eKeys::LowerCase_x; - case SDLK_y: return (int16_t)eKeys::LowerCase_y; - case SDLK_z: return (int16_t)eKeys::LowerCase_z; + case SDLK_GRAVE: return (int16_t)eKeys::BackQuote; + case SDLK_A: return (int16_t)eKeys::LowerCase_a; + case SDLK_B: return (int16_t)eKeys::LowerCase_b; + case SDLK_C: return (int16_t)eKeys::LowerCase_c; + case SDLK_D: return (int16_t)eKeys::LowerCase_d; + case SDLK_E: return (int16_t)eKeys::LowerCase_e; + case SDLK_F: return (int16_t)eKeys::LowerCase_f; + case SDLK_G: return (int16_t)eKeys::LowerCase_g; + case SDLK_H: return (int16_t)eKeys::LowerCase_h; + case SDLK_I: return (int16_t)eKeys::LowerCase_i; + case SDLK_J: return (int16_t)eKeys::LowerCase_j; + case SDLK_K: return (int16_t)eKeys::LowerCase_k; + case SDLK_L: return (int16_t)eKeys::LowerCase_l; + case SDLK_M: return (int16_t)eKeys::LowerCase_m; + case SDLK_N: return (int16_t)eKeys::LowerCase_n; + case SDLK_O: return (int16_t)eKeys::LowerCase_o; + case SDLK_P: return (int16_t)eKeys::LowerCase_p; + case SDLK_Q: return (int16_t)eKeys::LowerCase_q; + case SDLK_R: return (int16_t)eKeys::LowerCase_r; + case SDLK_S: return (int16_t)eKeys::LowerCase_s; + case SDLK_T: return (int16_t)eKeys::LowerCase_t; + case SDLK_U: return (int16_t)eKeys::LowerCase_u; + case SDLK_V: return (int16_t)eKeys::LowerCase_v; + case SDLK_W: return (int16_t)eKeys::LowerCase_w; + case SDLK_X: return (int16_t)eKeys::LowerCase_x; + case SDLK_Y: return (int16_t)eKeys::LowerCase_y; + case SDLK_Z: return (int16_t)eKeys::LowerCase_z; default: return (int16_t)eKeys::UpperCase_A; } return (int16_t)eKeys::UpperCase_A; @@ -911,7 +911,7 @@ namespace dragon int8_t b1 = read8(addr); int8_t b2 = read8(addr + 1); return ((b1 << 8) & 0xFF00U) - | (b2 & 0x00FFU); + | (b2 & 0x00FFU); } int8_t CMOS::write8(uint16_t addr, int8_t value) diff --git a/src/hardware/VirtualIODevices.hpp b/src/hardware/VirtualIODevices.hpp index 0962fae..a323217 100644 --- a/src/hardware/VirtualIODevices.hpp +++ b/src/hardware/VirtualIODevices.hpp @@ -233,7 +233,7 @@ namespace dragon ostd::ByteStream* getByteStream(void) override; - void handleSignal(ostd::tSignal& signal) override; + void handleSignal(ostd::Signal& signal) override; private: ostd::BitField_16 __construct_modifiers_bitfield(void); diff --git a/src/runtime/DragonRuntime.cpp b/src/runtime/DragonRuntime.cpp index e6e21d7..56bc912 100644 --- a/src/runtime/DragonRuntime.cpp +++ b/src/runtime/DragonRuntime.cpp @@ -1,5 +1,5 @@ #include "DragonRuntime.hpp" -#include +#include #include #include @@ -13,7 +13,7 @@ namespace dragon connectSignal(Signal_HardwareInterruptOccurred); } - void DragonRuntime::SignalListener::handleSignal(ostd::tSignal& signal) + void DragonRuntime::SignalListener::handleSignal(ostd::Signal& signal) { if (signal.ID == Signal_HardwareInterruptOccurred) { @@ -135,7 +135,6 @@ namespace dragon bool trackCallStack, bool debugModeEnabled) { - ostd::SignalHandler::init(); s_signalListener.init(); vKeyboard.init(); if (verbose) @@ -358,21 +357,21 @@ namespace dragon uint64_t avg_count = 0; uint64_t _time = 0; double avg_tot = 0; - ostd::Timer clock_timer; + ostd::Counter clock_timer; bool running = true; bool fixed_clock = machine_config.fixed_clock; - ostd::Timer _timer; + ostd::Counter _timer; while (running || vDiskInterface.isBusy()) { clock_timer.startCount(ostd::eTimeUnits::Microseconds); - ostd::SignalHandler::refresh(); + ostd::SignalHandler::handleDelegateSignals(); uint16_t addr = cpu.readRegister(dragon::data::Registers::IP); uint16_t spAddr = cpu.readRegister(dragon::data::Registers::SP); uint8_t screenRedrawRate = vCMOS.read8(data::CMOSRegisters::ScreenRedrawRate); // _timer.start(true, "Profiling", ostd::eTimeUnits::Microseconds, &out); running = cpu.execute() && vDisplay.isRunning(); // _timer.end(true); - vDisplay.update(); + vDisplay.mainLoop(); vDiskInterface.cycleStep(); if (dragon::data::ErrorHandler::hasError()) { @@ -407,7 +406,7 @@ namespace dragon __track_call_stack(&s_machineInfo); bool running = cpu.execute() && vDisplay.isRunning(); uint8_t screenRedrawRate = vCMOS.read8(data::CMOSRegisters::ScreenRedrawRate); - vDisplay.update(); + vDisplay.mainLoop(); if (s_enableScreenRedrawDelay && s_stepAcc2 == (1000.0 / screenRedrawRate)) { vDisplay.redrawScreen(); @@ -502,7 +501,7 @@ namespace dragon else { //if (int_op_code >= data::OpCodes::Ext01 && int_op_code <= data::OpCodes::Ext16) - // minfo.currentInstructionAddress = minfo.previousInstructionAddress; + // minfo.currentInstructionAddress = minfo.previousInstructionAddress; //else minfo.currentInstructionAddress = instAddr; minfo.currentInstructionFootprintSize = instSize; diff --git a/src/runtime/DragonRuntime.hpp b/src/runtime/DragonRuntime.hpp index 0501e8a..90266aa 100644 --- a/src/runtime/DragonRuntime.hpp +++ b/src/runtime/DragonRuntime.hpp @@ -20,7 +20,7 @@ namespace dragon public: inline SignalListener(void) { } void init(void); - void handleSignal(ostd::tSignal& signal) override; + void handleSignal(ostd::Signal& signal) override; public: inline static const int32_t Signal_HardwareInterruptOccurred = ostd::SignalHandler::newCustomSignal(8129); diff --git a/src/tools/Tools.cpp b/src/tools/Tools.cpp index cae23a9..39f2e22 100644 --- a/src/tools/Tools.cpp +++ b/src/tools/Tools.cpp @@ -5,7 +5,7 @@ #include #include "../hardware/VirtualHardDrive.hpp" #include "GlobalData.hpp" -#include "debugger/DisassemblyLoader.hpp" +#include "../debugger/DisassemblyLoader.hpp" #include #include