diff --git a/imgui.ini b/imgui.ini new file mode 100644 index 0000000..67c9899 --- /dev/null +++ b/imgui.ini @@ -0,0 +1,13 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Debugger] +ViewportPos=1587,230 +ViewportId=0x289D2C3F +Size=400,600 +Collapsed=0 + +[Docking][Data] + diff --git a/src/Application.cpp b/src/Application.cpp index d6d5599..af1c3b3 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -140,5 +140,13 @@ bool Application::Update() debugger->Render(); window->End(); + std::chrono::microseconds frametime = std::chrono::duration_cast(std::chrono::steady_clock::now() - lastFrameTime); + lastFrameTime = std::chrono::steady_clock::now(); + + if (frametime < std::chrono::microseconds(1000000 / 60)) { + std::this_thread::sleep_for(std::chrono::microseconds(1000000 / 60) - frametime); + } + + return !window->ShouldClose(); } diff --git a/src/Application.hpp b/src/Application.hpp index 16ba5ff..02d4168 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -1,5 +1,7 @@ #pragma once +#include + class Bus; class Window; class Debugger; @@ -33,4 +35,6 @@ private: Bus* bus; Screen* screen; Debugger* debugger; + + std::chrono::steady_clock::time_point lastFrameTime; }; diff --git a/src/debugger/Debugger.cpp b/src/debugger/Debugger.cpp index 17b4386..f745ff0 100644 --- a/src/debugger/Debugger.cpp +++ b/src/debugger/Debugger.cpp @@ -161,6 +161,10 @@ void Debugger::Render() ImGui::InputScalar("Reset Vector", ImGuiDataType_U16, &resetVector, (const void*)0, (const void*)0, "%04X", ImGuiInputTextFlags_CharsHexadecimal); } + ImGui::Separator(); + + ImGui::Text("FPS: %f", ImGui::GetIO().Framerate); + for (DebugWindow* window : windows) { if (window->isOpen) window->OnRender(); diff --git a/src/gfx/Window.cpp b/src/gfx/Window.cpp index 795067d..7cd0707 100644 --- a/src/gfx/Window.cpp +++ b/src/gfx/Window.cpp @@ -11,6 +11,7 @@ Window::Window(uint16_t width, uint16_t height, const std::string& title) : handle(nullptr) { glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); + handle = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr); if (handle == nullptr) { @@ -20,6 +21,7 @@ Window::Window(uint16_t width, uint16_t height, const std::string& title) : } glfwMakeContextCurrent(handle); + glfwSwapInterval(1); Input::SetWindow(this); } diff --git a/src/gfx/imgui.ini b/src/gfx/imgui.ini new file mode 100644 index 0000000..8eea4ed --- /dev/null +++ b/src/gfx/imgui.ini @@ -0,0 +1,12 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Debugger] +Pos=217,104 +Size=400,325 +Collapsed=0 + +[Docking][Data] + diff --git a/src/imgui.ini b/src/imgui.ini new file mode 100644 index 0000000..c011a8d --- /dev/null +++ b/src/imgui.ini @@ -0,0 +1,30 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Debugger] +Pos=506,49 +Size=490,229 +Collapsed=0 + +[Window][Disassembler] +ViewportPos=1326,634 +ViewportId=0x85E8BACF +Size=400,400 +Collapsed=0 + +[Window][CPU Watch] +ViewportPos=915,545 +ViewportId=0x759989B3 +Size=400,400 +Collapsed=0 + +[Window][Palettes] +ViewportPos=1756,613 +ViewportId=0x550214C1 +Size=400,291 +Collapsed=0 + +[Docking][Data] +