From 12b7d3674f006d1916cc3df49938dd9b61b78e2c Mon Sep 17 00:00:00 2001 From: Oxore Date: Sat, 25 May 2024 14:18:24 +0300 Subject: Make it render regularly while idling --- emulator.cpp | 12 ++++++++---- graphics.cpp | 9 +++++++++ graphics.hpp | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/emulator.cpp b/emulator.cpp index 0fb50dd..7dab3af 100644 --- a/emulator.cpp +++ b/emulator.cpp @@ -532,8 +532,10 @@ static int emulator(M68KDebuggingControl& m68k_debug, Graphics& graphics, CharDe } else { struct pollfd fds[1] = { {/*.fd = */socket_fd, /*.events = */POLLIN, /*.revents = */0}}; - const int timeout_msecs = 30; - poll(fds, 1, timeout_msecs); + const int timeout_msecs = 200; + if (0 == poll(fds, 1, timeout_msecs)) { + graphics.ReRender(); + } } continue; } @@ -578,8 +580,10 @@ static int emulator(M68KDebuggingControl& m68k_debug, Graphics& graphics, CharDe } else if (err == EWOULDBLOCK) { struct pollfd fds[1] = { {/*.fd = */conn_fd, /*.events = */POLLIN, /*.revents = */0}}; - const int timeout_msecs = 30; - poll(fds, 1, timeout_msecs); + const int timeout_msecs = 200; + if (0 == poll(fds, 1, timeout_msecs)) { + graphics.ReRender(); + } } } close(conn_fd); diff --git a/graphics.cpp b/graphics.cpp index d193b50..1473f65 100644 --- a/graphics.cpp +++ b/graphics.cpp @@ -96,3 +96,12 @@ void Graphics::Render(const VDP& vdp) (void) buffer; #endif } + +void Graphics::ReRender() +{ +#if HAS_GRAPHICS == 1 + SDL_RenderClear(_renderer); + SDL_RenderCopy(_renderer, _render_texture, NULL, NULL); + SDL_RenderPresent(_renderer); +#endif +} diff --git a/graphics.hpp b/graphics.hpp index a88cd61..98ad848 100644 --- a/graphics.hpp +++ b/graphics.hpp @@ -15,6 +15,7 @@ public: ~Graphics(); bool IsOk() const { return _initialized_ok; } void Render(const VDP&); + void ReRender(); private: bool _initialized_ok{}; -- cgit v1.2.3