1
0
Fork 0
Commit graph

669 commits

Author SHA1 Message Date
krcroft
08c6fc10c1 Add a signed integer ceiling divide function 2020-03-06 19:21:44 +01:00
krcroft
a757f41ead Add an integer division and ceiling helper function
Many parts of the code (especially audio) deal with discrete integer
(and always-positive) values that need to be scaled up or down by
some divisor. This functions provides a fast and an easy way to
divide and round up, while avoiding the CPU burden and excessive
wordiness associated with casting to and from floating point and
back to integer again.
2020-03-06 19:21:44 +01:00
krcroft
eef8c51419 Address code-review comments (squash-me) 2020-03-04 05:11:40 +01:00
krcroft
1d123367a5 Use MixerObject's singleton-pattern to manage the channel 2020-03-04 05:11:40 +01:00
krcroft
91cd907c4e Migrate some members of the Player class to smart pointers
1. Moves the mutex and mixer channel members to unique pointers
2. Moves the trackFile to a weak pointer
3. Move member initialization to the class definition

This class still retains a raw *cd member, however fixing this
ripples up to the array of [26] CD images, and across more
code that generically deals with mount points; so this work
remains to do.
2020-03-04 05:11:40 +01:00
Patryk Obara
c155400979 Use _fileno only with MSVC compiler
Function fileno is available in POSIX environment out of the box. On
non-POSIX platforms, it might be missing in some cases when compiling
with -std=c++11, as it's outside of strict ANSI compatibility.
2020-03-01 21:13:19 +01:00
Patryk Obara
5e41eaf150 Merge branch 'svn/trunk' r4333
Conflict resolutions required some algorithm adjustments.
2020-02-25 11:11:00 +01:00
Peter Veenstra
5d654fc5c5 Make value operator== const, add some limit checks in PrintConfigfile and related functions. Unify style a bit more.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4332
2020-02-24 20:00:55 +00:00
krcroft
6c0e1a4607 Switch write protected set to unordered_set 2020-02-24 12:08:01 +01:00
krcroft
b302b535c3 Add DEBUG messages for protected-file handling 2020-02-24 12:08:01 +01:00
krcroft
9603c961c0 Fix spacing and effc++ warnings
Apply code review recommendations
2020-02-24 12:07:53 +01:00
krcroft
c730e5d70a
Permit the use of protected game data files
Many DOS games open all their files in write-mode regardless if the
game actually intends to write to them or not.

This can result the files' metadata being updated (lossing the
original date-stamp) as well as putting the file at-risk of
corruption if the game crashes with the file open for writing.

Under the existing DOSBox implementation, if a user attempts to
write-protect their data files then DOSBox will quit with an error in
the above scenario.

This commit allows the use of write-protected files (similar to
running a game from CDROM) and indicates which files are being
actively protected against modification.

Typically the only files that need to be left writable are those that
the game actually changes, such as: save-game files, highscore
files, in-game settings, and so on.  If these are also protected,
then the game will quit/crash immediately after the protected message
is printed, and thus indicate which file require write-allowance.
2020-02-23 21:45:20 -08:00
Patryk Obara
c619445003 Avoid buffer underflow by copying all fields
This code made silent assumption that first fields in direntry are
exactly 14 bytes - this was fine, except would break as soon as anyone
would touch the struct (or e.g. if a compiler would lack support for
packed structures and inject some padding in there); rewrite the copy
code to follow the same pattern as other fields - now the code will be
fine even if someone will change fields in the direntry struct.

Fixes 2 PVS static analysis issues (buffer underflow on src and dst).
2020-02-23 01:13:11 +01:00
Patryk Obara
bdf67cdbcc Merge branch 'svn/trunk' r4330 2020-02-22 21:10:57 +01:00
Patryk Obara
28ebbd3bed Revert "Enhance capturing to handle unchanged screens (…)" r4329
This reverts commit fd11108206.
2020-02-22 20:59:59 +01:00
Peter Veenstra
57bf045cc8 some big endian improvents and drive_fat fixes. (jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4330
2020-02-22 12:06:40 +00:00
Patryk Obara
0e32c002ae Cleanup ifdef guards in serialport misc util 2020-02-19 19:25:47 +01:00
Peter Veenstra
fd11108206 Enhance capturing to handle unchanged screens more efficiently(jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4329
2020-02-17 16:20:07 +00:00
Patryk Obara
5bd3a4ac8d Merge branch 'svn/trunk' r4328 2020-02-15 21:27:20 +01:00
Peter Veenstra
2b00069ae9 remove unused variable
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4327
2020-02-15 17:21:22 +00:00
Patryk Obara
be6b446028 Merge branch 'svn/trunk' r4319 2020-02-12 08:39:40 +01:00
Peter Veenstra
4a565a75ed Add OpenGL shader support. (patch by ny00123 and refined by jmarsh). Add several builtin ones that mimic the scalers and some extra. Thanks jmarsh
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4319
2020-02-10 18:59:01 +00:00
Patryk Obara
77c4523723 Byteswap captured audio samples on PPC
Fixes: #161
2020-02-08 14:56:14 +01:00
Peter Veenstra
987a48600d Rewrite video capturing and fix some endian issues with all captures as well. Thanks jmarsh
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4314
2020-02-06 10:36:10 +00:00
Patryk Obara
2983de4db4 Use unsigned for numbers in shortened filenames
Bitu (aka uintptr_t) is not necessary for handling shortened files,
as we can represent max 10^7 shortened files anyway; unsigned is good
enough.

This allows use to use simple %u for conversion instead of PRIuPTR,
which caused a bug on AmigaOS on PPC.

Fixes: #162
2020-02-06 09:24:05 +01:00
Patryk Obara
4a6704367b Reorder includes for drive_cache
Class DOS_Drive_Cache is declared in dos_system.h, but this header was
indirectly included.  Remove faulty windows.h include (the correct one
exists in cross.h already).
2020-02-06 09:24:05 +01:00
krcroft
3446db1ee9 Expand mouse control methods
Replace the [sdl] `autolock = true/false` configuration setting with [sdl]
`capture_mouse = ...` with a two-value setting.

The first value defines how the mouse is controlled:
- onclick:       The mouse will be captured with a click inside the window.
- onstart:       The mouse is captured immediately on start (similar to real DOS).
- seamless:      The mouse will move seamlessly in and out of DOSBox and cannot be captured.
- nomouse:       The mouse is disabled and hidden without any input sent to the game.

The second value defines how middle-clicks are handled:
- middlegame:    Middle-clicks are sent to the game (not used to uncapture the mouse).
- middlerelease: Middle-click will uncapture the mouse when windowed (not sent to the game).

Middle-clicks are sent to the game when fullscreen or when seamless control is set.

The default setting of "onclick middlegame" reproduces DOSBox's existing behavior.
2020-02-02 00:43:24 +01:00
krcroft
93f9cd7e4e Fix audio-related static analysis issues 2020-01-29 17:13:25 +01:00
VileRancour
ffe3c5ab7f Add cga_mono machine
Emulates the user using a CGA card with a monochrome monitor.
Monochrome monitor options are: green, amber, white or paperwhite.
The color can be changed at runtime with F11.

Include paperwhite color by Basic <basic@vogons.org>
https://www.vogons.org/viewtopic.php?p=587382#p587382

Vogons thread: https://www.vogons.org/viewtopic.php?f=41&t=29101

Signed-off-by: Michael Zijlstra <mzijlstra@gmail.com>
Signed-off-by: Patryk Obara <dreamer.tan@gmail.com>

Imported-from: https://www.vogons.org/viewtopic.php?p=238045#p238045
2020-01-29 13:46:23 +01:00
krcroft
c7484ceaaa Improve compliance when printing drive labels 2020-01-22 09:40:00 +01:00
Patryk Obara
bc52faf4ed Fix MSVC stricmp-related warnings
MSVC replaced its own non-standard implementation of stricmp with
ISO-compliant _stricmp, and issues a security warnings when old name is
used.

This tiny redefine solves 129 warnings in Visual Studio 2019.
2020-01-11 20:52:55 +01:00
Patryk Obara
381dd8be87 Make setter for RO-medium flag a virtual method
This way we prevent pointless dynamic_cast; correct usage of
dynamic_cast requires a nullcheck, which was missing in this case
causing Coverity to complain.

Instead of changing cast, let's make this method a virtual one in base
class - this way we could reuse it in future for cases outside of CD-ROM
(e.g. write-protected floppies).
2020-01-11 20:52:55 +01:00
Patryk Obara
1953d0880b Redefine fileno for Windows
This redefine prevents fake deprecation warning on Windows (C4996) and
prevents a compilation problem when using old MinGW and Windows XP.
2020-01-11 17:50:28 +01:00
Patryk Obara
4d674102d0 Prevent unaligned memory access in adlib
This removes the last warnings in this area; in this case changing endianess
is not used for accessing emulated memory, just to flip few values to
low endian for storage.
2020-01-09 22:50:47 +01:00
Patryk Obara
c4dba16740 Move drives.h to common include dir
Judging by the usage, this header belongs in there instead of being
limited to dos module only.  This change makes it easier to reuse code
for new features related to drives mounting/unmounting.
2020-01-04 08:26:22 +01:00
Patryk Obara
2694aca2b2 Fix effc++ warnings in drives.cpp 2020-01-04 08:26:22 +01:00
Patryk Obara
0506aaf436 Stop silencing disabled C4786 MSVC warning
This is old, and disabled by default in new MSVC compilers.
It was purely infomational warning:

"object name was truncated to 'number' characters in the debug
information"

Regardless, even if we'll decide to silence it again for any reason,
then it should be configured in VS project and not using ifdefed
pragma in the code.
2019-12-29 20:04:39 +01:00
Patryk Obara
475e315943 Stop silencing 'throw' warnings in MSVC
Warning C4290 informs users, that MSVC ignores throw specification. This
is very good warning, because 'throw' specifications were faulty design
and got deprecated in C++11 and REMOVED from the language in C++20.

Throw specifications were replaced by much better 'noexcept' keyword,
which allows for compile-time checks, unlike 'throw', which might
silently inject exception 'std::unexpected'.
2019-12-29 20:04:39 +01:00
Patryk Obara
aff02450d1 Move GCC_ATTRIBUTE out of autoconf 2019-12-29 20:04:39 +01:00
Patryk Obara
3b157cd785 Add missing headers to autoconfig file
Also sort list of headers, so it's easier to assure no files are
missing.
2019-12-29 20:04:39 +01:00
Patryk Obara
ff2968df3f Move 'likely' macros to the compiler support header
This makes it easier to move away from autoconfig in the future.

Also, use '!!' C trick to prevent accidental incorrect usage of
these macros.
2019-12-29 20:04:39 +01:00
Patryk Obara
a7280cf1f7 Query SDL for available texture renderers
There's no point in hardcoding these values - they can be different to
every user (it depends on hardware, OS, SDL version, etc).

Also, future versions of SDL might introduce more renderers, so this way
the code is more future-proof.
2019-12-26 03:23:19 +01:00
Patryk Obara
cb82a60341 Surround WIN32_LEAN_AND_MEAN with ifndef
Otherwise it redefines macro definition in SDL_opengl.h.
2019-12-26 03:23:19 +01:00
Patryk Obara
3a68ba2b26 Indicate system includes for relevant SDL headers 2019-12-26 03:23:19 +01:00
Patryk Obara
0d108a7df5 Remove GFX_SetPalette
After move to SDL2, this function is no longer useful.
2019-12-26 03:23:19 +01:00
Patryk Obara
c81269eebe Remove extern global variable from bios_disk.h
This way interface of swapInDisks function is cleaner and we avoid a
warning when comparing (previously) signed swap position with an
unsigned array size or index.

Also, add some documentation to swapInDisks function.
2019-12-18 23:56:28 +01:00
Patryk Obara
5f282f6015 Use shared_ptr to prevent double free on imageDisk
Also, replacing unique_ptr with shared_ptr makes it unnecessary to move
a pointer when swapping boot disks; moving shared_ptr would lead to
inconsistent internal state.

Fixes: #94
2019-12-18 23:56:28 +01:00
Patryk Obara
5f9ac5eeab Remove code ifdefed for OS/2
Cleanup before replacing SDL1.2 with SDL2.

OS/2 support was introduced in DOSBox in March 2006.  OS/2 reached EOL
in December 2006.

As of 2019, OS/2 is being continued by proprietary 32-bit only ArcaOS,
although there is no official SDL2 support, despite pledges from SDL2
maintainers.
2019-12-09 16:27:11 +01:00
krcroft
ef2686ac02 Switch from std::vector to std::array 2019-12-09 09:11:16 +01:00
krcroft
78cc6be86d Make use of template variable, and reformat whitespace 2019-12-09 08:19:26 +01:00