SCP: video improvements#487
Closed
bscottm wants to merge 2 commits intoopen-simh:masterfrom
Closed
Conversation
- The main thread must be the event loop as noted in
SDL_RenderPresent()'s documentation; it is mere coincidence that SDL2
works in a thread other than the main thread. No asymmetry between
macOS, Linux and Windows. (BESM6 is still an exception.)
- Video/display-based simulators spawn the simulator in its own
thread, requesting an 8M stack when created (since SDL 2.0.9).
- main() defers SDL initialization via a condition variable until
signaled. This occurs when either the simulator thread exits or the
simulator asks for a display window.
- If the simulator's video frame is larger than the physical screen
dimensions, it is automatically rescaled. While this may "uglify" the
video, it's better than not being able to see the bottom of the
simulator's video and unable to resize or move the frame.
- "SHOW VERSION": Report the simulator thread's stack size if the API is
available. pthread-based implementations and Windows 8+ have an API to
report thread stack size (unavailable on Windows XP.)
- "SET VIDEO NATIVE": Support SDL native rendering support (vice the
SDL2 software renderer). For example, configure the PDP-11 VT "Moon
Lander" demo mode as follows:
set video native
boot vt
- Window expose/open latency: Windows Subsystem for Linux (WSL) has
highly variable window visibility times exceeding the code's original
2 second delay.
- New user event, EVENT_OPENCOMPLETE, signals to the caller via a
condition variable that initial window opening and exposure events
have been processed by the event loop.
- Asynchronous audio: The 330 Hz audio "beep" is completely
asynchronous. vid_beep() keeps track of consecutively requested beeps,
inserting a silence gap between them and continues to play out the
tone.
- PDP-11 VT demo mode: No awkward freeze when crashing into the Moon's
surface waiting for the beep to finish playing.
- vid_draw_onto/vid_draw_onto_window: New interface functions that allow
a simulator calback to execute in the SDL main and draw directly onto
the texture, cutting down on the amount of extra buffer copying incurred
by vid_draw and vid_draw_window.
SCP: Reduce scp.c compiler warnings
- Assignments in conditional expressions
- Hiding previously declared variables.
- Trim trailing spaces.
- Reduce/eliminate compiler warnings
- Variables that hide previous definitions (e.g., uptr)
- Assignments in conditional expressions (conditional expressions
should be... conditionals, i.e. "==".)
- Readability: use constants for conversions, make it easier to see the
time units.
- Use size_t for array indices.
- Windows: Prefer waitable timers over Sleep(). Sleep() is the fallback
if initializing a waitable timer fails (which it doesn't, but there's
no penalty for writing safe code.) A detailed discussion on Windows
timers can be found at http://www.windowstimestamp.com/description
Significantly reduces the occasional headache-inducing slow redraw
(flicker) on Windows (Imlac, primarily, but also afflicts PDP11 VT
sometimes.)
c7e37a2 to
a1e1544
Compare
Contributor
Author
|
Retracting temporarily -- strange refresh beat frequency on Linux X server. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-engineered sim_video support. Submitted as two commits so that it's easier to cherry-pick the second commit.
The first commit is the re-engineered video that removes the
SDL_main()asymmetry between macOS, Linux and Windows -- they all useSDL_main()if video is needed. Video is also automagically rescaled if it can't fit on the physical screen; SDL2 has been able to handle this for a long time. Audio is also asynchronous and won't stall the simulator while the tone plays out. There's a new "onto" API that allows the simulator to draw pixels directly into the SDL texture, reducing the amount of video frame buffering. Lastly, users can enable native hardware acceleration, for what it's worth; simulator video is not limited to the SDL software renderer.The second commit is sim_timer.c cleanups, notably using actual constants for various conversions, e.g.,
MSEC_PER_SEC_lfor millisecond to second (long) conversions. It also corrects the long-running issue on Windows whereSleep(1)can sleep for 1 + 15 + 5 milliseconds (requested delay + timer interrupt periodicity + wakeup latency) by using waitable timers.