summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-05-25 14:18:24 +0300
committerOxore <oxore@protonmail.com>2024-05-25 15:01:47 +0300
commit12b7d3674f006d1916cc3df49938dd9b61b78e2c (patch)
treeedd3da6f5a2b99740fdf98027020fad9e22d90d2
parente2c2cabaece87279a69b4e8e0c0929bbef178078 (diff)
Make it render regularly while idling
-rw-r--r--emulator.cpp12
-rw-r--r--graphics.cpp9
-rw-r--r--graphics.hpp1
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{};