AUTOTYPE performs scripted keyboard entry into the running
DOS program.
It can be used to reliably skip intros, answer Q&A style questions
that some games ask on startup, or conduct a simple demo.
It allows for delaying input by any number of fractional seconds,
as well defining the pacing between keystrokes. It uses the
comma character "," to insert additional delays similar to modern
phone numbers.
It uses key_* names as defined by the mapper to avoid using SDL
scancodes[1], which are unstable across platforms. This approach
also allows the triggering of custom key bindings the use has
defined.
[1] https://wiki.libsdl.org/SDL_GetScancodeName
"Warning: The returned name is by design not stable across
platforms, e.g. the name for SDL_SCANCODE_LGUI is "Left GUI" under
Linux but "Left Windows" under Microsoft Windows, and some
scancodes like SDL_SCANCODE_NONUSBACKSLASH don't have any name at
all. There are even scancodes that share names, e.g.
SDL_SCANCODE_RETURN and SDL_SCANCODE_RETURN2 (both called
"Return"). This function is therefore unsuitable for creating a
stable cross-platform two-way mapping between strings and
scancodes."
In the previous code, if the game attempted to seek beyond the track
length, or if a "seek & read" would add up to going beyond the
end-of-the-track, the code would pass those requests to the underlying
codecs to handle (and reject with a corresponding error code).
This PR moves those checks up into the CDROM CD-DA code, and will
short-circuit them. Illegal seeks won't be attempted, however the usual
negative return code will still be passed to the game just like before.
Likewise, reads beyond the end will be pruned so they will get as much
audio as possible, without asking the codec for extra.
Set AllowAllConstructorInitializersOnNextLine to false. This prevents
formatting problem when initializer list is long enough to be wrapped
once, but all initializers fitted into the next line.
Turn on AlignConsecutiveMacros option.
Adds LTO to the CI build for Linux, which bring it as close as possible
to the planned formal release, which will additionally use FDO.
Adds some helper scripts to work with FDO files.
Improves the build notes for how to create and use FDO files.
This script is intended to be used in two situations:
- When user can't configure clang-format in code editor or IDE
- Potentially to be used in CI in the future
Normal usecase is to run this script after commit, then review and
add formatted code, and amend the commit, e.g.:
git commit -m "Edit some C++ code"
./scripts/format-commit.sh
git add -p # select formatting changes you want to use
git commit --amend
Run:
./scripts/format-commit.sh --help
to learn about other options.
Rules are defined for all C/C++ code, except src/libs.
These rules are designed to emulate kernel coding convention with some
adaptations for C++11. Configuration file uses options available in
clang-format 8.0 (the newest version in 10.0) to provide compatibility
with older environments and operating systems. Some options are
commented out and marked with TODOs - those need to be investigated and
enabled/disabled during upgrade to clang-format 9.0.
DOSBox codebase is a mix of various styles with only few consistent
rules seen throughout the codebase, these clang-format rules preserve
some of existing conventions and conciously break with others.
Some unwritten upstream rules, that are now encoded in clang-format:
- Using tab for indentation.
- K&R-like indentation for control statements.
- Indentation rules for structs, classes, and non-anonymous enums.
- Case labels in switch statements are aligned the same way goto
statements would be (also K&R rule).
Some formatting aspects that were not followed consistently throughout
old DOSBox code, but are now encoded in clang-format:
- Space placing in control statements and function calls (makes the code
much more readable).
- Control statements (if-else, while) must be broken into multiple lines
(makes the code more readable, helps with debugging, reading compiler
logs and static analysis reports).
Some unwritten upstream rules, that are now changed by these rules:
- Placing opening function bracket in the same line as function
declaration (not in line with K&R). This rule makes it hard to make
constructor formatting consistent - old code dealt with it by not
formatting initializer lists at all. Unformatted initializer list can
result in lines hundreds of lines long and make it hard to add/remove
class fields while assuring correct initialization order.
In new clang-format rules K&R indentation is followed, allowing
initalizer lists to be formatted one initializer per line (which makes
it much easier to read and edit.
This fixes mouse visibility issues on the Raspberry Pi,
which uses an older customized version of SDL2. SDL2 on
the Pi fires different windows events in a different
order, making dealing with states challenging.
To handle this generically, we additionally assess the
mouse capture state after the Window has gained focus.
We also add a "has_focus" state tracking boolean to the
SDL object, which protects against general SDL mouse
trigger events from changing the mouse state before the
Window has "risen" and delivered us an EXPOSED or FOCUS
event. In the prior code rapidly clicking the mouse while
DOSBox was starting could freeze the mouse cursor in
place on the Pi.
We still also assess the mouse state on EXPOSE events,
which is fired after full - windowed modes are toggled.
The EXPOSE even occurs reliably on OSX, X11, Wayland, and
Windows after the window has settled (but is never fired
on the Pi).
Upstream replaced C++11 code with C++ "almost-equivalents", when merging
code from MAME project.
Reverting this fixes few warnings (comparison of signed and unsigned
integer in this case) and makes it slightly easier for the compiler
to unroll the nested loops.
vsync is an option introduced by SDL2 patch, but the testing indicates,
that it very rarely (if ever) works. We still want to support it, but
this might require serious implementation effort, so for the time being
we're removing broken option to prevent confusing the users.
This allows us to show a warning to the user if the .conf file includes
a property that is no longer supported, or a property that is completely
unknown. Actual handling of the property can still be implemented
(e.g. to use as a fallback for modern replacement), but doesn't need
to be.
It's the easiest way to prevent problems when user wants to play the
game using fullscreen while explicitly setting tiny resolution
for a specific game (e.g. 320x200).
All rendering backends except output=surface assume input buffer row
with the same length as output buffer row. Surface is "special" and in
fullscreen uses pitch equal to *screen* width instead. Padding the
output rows with black pixels is necessary for splash screen to show up
correctly.
SCREEN_SURFACE is no longer the default option, and it's usable only for
debugging purposes. Move it to the last position in switches, to make
texture and opengl a little bit faster.
Usually, when window is being created without SDL_WINDOW_OPENGL flag,
SDL2 internally re-creates it to support OpenGL during
SDL_CreateRenderer if needed.
This leads to crash in AMD OpenGL drivers (Windows only), which happens
for drivers: "opengl", "opengles", "opengles2".
When the window is created with correct flag from the get-go, the crash
does not happen.
On Linux, the code does not crash either way (at least not when using
Mesa and AMDGPU open source driver), so there's no point in propagating
the hack.
Also, remove a comment that is no longer relevant to the code below.
Lock/UnlockTexture is stable and works very well on Linux and with
OpenGL texture driver and on Linux and Windows, but it's usage caused
problems with content of updated texture when used with drivers:
'direct3d11' on Windows and 'metal' on macOS.
Also, Lock/Unlock turned out to be the root cause of deadlocks for
'opengl' driver on AmigaOS.
According to SDL2 documentation, using Lock/UnlockTexture is supposed to
be faster, but in DOSBox usecase we couldn't confirm significant
performance change - there are some community reports indicating, that
UpdateTexture might be actually faster (but we couldn't confirm it
either).
Discussion on this topic can be found on SDL forum:
https://forums.libsdl.org/viewtopic.php?t=9728
In our case, switch to UpdateTexture has no serious negative impact, but
makes the behaviour more robust across the board.
Make the user settings affect splash screen as well as emulator; this
way, when user wants to start in fullscreen, the splash screen will be
displayed in fullscreen - making the startup process more streamlined.
This fixes long-standing problem on SteamOS (or Steam in Big Picture
mode), when starting dosbox moves the user out of fullscreen to window
(to show tiny splash screen), and then back to fullscreen.
Simplify the code displaying the splash screen and extract it to a new
function. Using GFX_* functions avoids the problem of re-creating
the window from scratch after splash is shown, which solves a lot of
problems:
- application window is always visible on screen, it does not disappear
for a moment between closing splash and starting emulator.
- seriously reduces resolution trashing on start
- user will not experience loss of window focus due to splash screen
disappearing (this was happening e.g. on AmigaOS)