1
0
Fork 0
Commit graph

5026 commits

Author SHA1 Message Date
krcroft
cc80c19193 Add copyright header 2020-04-04 04:10:06 +02:00
krcroft
11643631f5 Apply clang-format rules 2020-04-04 04:10:06 +02:00
krcroft
ce369221e7 Update allowed warnings limits 2020-04-04 04:10:06 +02:00
krcroft
a8a0e5fa91 Cleanup PVS warning about uninitialized members 2020-04-04 04:10:06 +02:00
krcroft
f1d197ec5f Cleanup PVS warning unecessary code 2020-04-04 04:10:06 +02:00
krcroft
233cf5089b Cleanup PVS warning regarding combersome empty checks 2020-04-04 04:10:06 +02:00
krcroft
dad002203c Cleanup PVS warning regarding unecessary copy 2020-04-04 04:10:06 +02:00
krcroft
73e22747e7 Use references when catching polymorphic exceptions 2020-04-04 04:10:06 +02:00
krcroft
3aa27e0491 Mark a function const 2020-04-04 04:10:06 +02:00
krcroft
3df2734b52 Clarify choice of wrap-width 2020-04-04 04:10:06 +02:00
krcroft
9e086a882e Use WriteOut_NoParsing where possible 2020-04-04 04:10:06 +02:00
krcroft
75dd033cb0 Validate string to double using std::isfinite 2020-04-04 04:10:06 +02:00
krcroft
239396fec8 Add AUTOTYPE to DOSBox's programs
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."
2020-04-04 04:10:06 +02:00
Patryk Obara
ee7107470e
Update README sections
Change repo description to reflect relation with upstream.
Update information for developers, and provide few tiny clarifications.
2020-04-02 07:24:43 +02:00
krcroft
e8ac2d60f3 Ensure seeks and reads are within bounds of the track length
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.
2020-04-02 06:20:23 +02:00
Patryk Obara
68a1291bc6 Update clang-format rules to 9.0
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.
2020-04-02 03:30:17 +02:00
Patrick McMorris
48c7add817 Organize files in VS solution
Mirror project structure on the file system.
2020-04-01 13:06:45 +02:00
krcroft
78ae277d28 Expand use and support for LTO and FDO builds
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.
2020-04-01 08:03:39 +02:00
Patryk Obara
0759165f45 Implement script for re-formatting recent commits
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.
2020-04-01 07:38:05 +02:00
Patryk Obara
e4d3188c7a Add clang-format rules
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.
2020-04-01 07:38:05 +02:00
Patryk Obara
71f892d7ea Cleanup workflow files 2020-03-31 11:11:26 +02:00
Patryk Obara
abb6e12044 Move PVS Studio static analysis to a separate file
This job depends on credentials stored in GitHub secrets, therefore
fails for pull requests created by new contributors out of their forked
repos.
2020-03-31 11:11:20 +02:00
krcroft
619742f70f Improve comment about EXPOSED event 2020-03-30 21:48:02 +02:00
krcroft
c2b3015839 Eliminate redundant use void arguments 2020-03-30 21:48:02 +02:00
krcroft
b4e6e40c95 Assess the mouse capture state when gaining window focus
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).
2020-03-30 21:48:02 +02:00
Patrick McMorris
82a3a46550 Enable parallel builds in VS for all configs 2020-03-30 19:31:03 +02:00
Patryk Obara
de7289221b Update maintainers list in workflow 2020-03-29 23:05:27 +02:00
Patryk Obara
d4b2f2167a Update allowed warnings limits 2020-03-28 05:41:04 +01:00
Patryk Obara
1d704d49a5 Fix few trivial warnings in macOS code
Prevents "unused-variable" warnings and one "sometimes-uninitialized"
warning.
2020-03-28 05:41:04 +01:00
Patryk Obara
f959484192 Make block_fnum unsigned in fmopl
This value is stored as 32-bit unsigned value elsewhere throughout this
file and is being compared against 32-bit unsigned in this function.
2020-03-28 05:41:04 +01:00
Patryk Obara
5983e820c4 Bring back C++11 foreach loop in fmopl
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.
2020-03-28 05:41:04 +01:00
Patryk Obara
06805b28fb Change bpp to unsigned int around render code
Max value of bpp is 32, so there's really no reason to tie this variable
to architecture size.  This change prevents few -Wformat warnings.
2020-03-28 05:41:04 +01:00
krcroft
241f6d1c41 Update allowed warning count 2020-03-28 03:04:25 +01:00
krcroft
c6f45effab Update PVS Studio to version 7.06.37052.34 2020-03-28 03:04:25 +01:00
krcroft
b71788dba6 Make a second harder attempt to seek if needed 2020-03-27 15:01:26 +01:00
Patryk Obara
dbc77a6f1c Prevent empty property names 2020-03-27 00:54:11 +01:00
Patryk Obara
4811193998 Initialize all members of Property class 2020-03-27 00:54:11 +01:00
Patryk Obara
dbfca7353e Cleanup MIDI/ALSA-related logs
We want logs to adhere to a common format.
2020-03-27 00:54:11 +01:00
Patryk Obara
9d2b7ea578 Adjust help strings for sdl options 2020-03-27 00:54:11 +01:00
Patryk Obara
193f2ed564 Declare sdl.vsync as deprecated/disabled
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.
2020-03-27 00:54:11 +01:00
Patryk Obara
04d2e9f3f1 Allow config properties to be deprecated
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.
2020-03-27 00:54:11 +01:00
Patryk Obara
779131d396 Skip splash screen if resolution is not large enough
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).
2020-03-27 00:54:11 +01:00
Patryk Obara
5ac2567adc Rename gimp_image to splash_image 2020-03-27 00:54:11 +01:00
Patryk Obara
6f238c0d1a Fix splash screen for surface output
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.
2020-03-27 00:54:11 +01:00
Patryk Obara
00ffbd0977 Remove dead code remains of "lazy_fullscreen" feature 2020-03-27 00:54:11 +01:00
Patryk Obara
1f62338610 Fix indirect memory leak of icon surface 2020-03-27 00:54:11 +01:00
Patryk Obara
d34378b621 Define SDL rgb-masks for creating surfaces 2020-03-27 00:54:11 +01:00
Patryk Obara
a5b65b3c8e Initialize default window size before GUI_StartUp 2020-03-27 00:54:11 +01:00
Patryk Obara
acb020147d Move "extern C" to ppscale header 2020-03-27 00:54:11 +01:00
Patryk Obara
facabcee2a Handle surface as the last option during update
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.
2020-03-27 00:54:11 +01:00