1
0
Fork 0
Commit graph

685 commits

Author SHA1 Message Date
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
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
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
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
8d5bc9537a Prevent a crash in Windows AMD drivers
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.
2020-03-27 00:54:11 +01:00
Patryk Obara
bf1c7eef18 Fix effc++ warnings in control.h 2020-03-27 00:54:11 +01:00
Patryk Obara
0b173eec08 Cleanup and document GFX_StartUpdate function
Usage of this function depends on the state of global sdl struct; and
it's very easy to make a mistake - documentation should lower this risk.

Change the type of output parameter 'pitch' and assure type safety with
internal SDL types via static asserts.
2020-03-27 00:54:11 +01:00
Patryk Obara
08934b2972 Remove dead code remains of WinDIB usage
This used to have meaning for Windows 9x support via SDL 1.2; the issue
described in README was never mentioned in the context of SDL2.

Add missing include to video header while we're at it.
2020-03-27 00:54:11 +01:00
krcroft
a1a3e0203d Only initialize the mapper once during startup 2020-03-21 23:41:06 +01:00
Patryk Obara
a956f14de1 Inject newlines before displaying DOS prompt
In an earlier change, I removed appending newline outside of batch mode
in DOS shell code - that made DOSBox behave less like MS-DOS and more
like modern shells, that do not try to compensate for buggy
applications.

However, we should recognize that DOSBox (unlike e.g. FreeDOS) is designed
to run legacy applications, which might make assumptions about DOS
implementation. Some examples:

- PC Player Benchmark assumes, that help commands are displayed exactly
  at 80x25 terminal and formats the output to fill the whole screen
  (scrolling past DOS4GW messages).
- Quake and other ID games print shareware information on exit, but do
  it via a direct memory dump (not interrupts to print DOS text), and
  follow up with setting cursor exactly at line 22 (which is partly
  written already), expecting shell to inject newline.
- PCC Compiler prints status message on exit without newline, depending
  on MS-DOS shell behaviour.
- TEXTUTIL set of external commands do not print nothing to standard
  output, and are designed to clear the screen, therefore writing a
  newline after .COM commands would be a mistake.

Therefore we want to inject this newline, but not in every case.

New implementation reuses a static variable used by Program base class
(for purpose of translating UNIX newlines to DOS newlines) for detection
if it's appropriate to inject an additional newline or not.

Injecting the newline happens in function displaying the DOS prompt (so
we don't need to write additonal logic for separately handling batch
mode). When starting a non-COM, non-internal command the static variable
is set to the state indicating that next DOS prompt should inject the
newline.

Fixes: #208
2020-03-12 20:54:33 +01:00
Anton Shepelev
d1be65b105 Add output type texturepp for pixel-perfect scaling
The new output type `texturepp' was added, which implements
pixel-perfect scaling using SDL's hardware-accelerated texture output.
In pixel-pefect mode, each original pixel is displayed as a rectangle m
by n pixels, so that m:n yields a reasonably good approximation of the
pixel aspect ratio (PAR) of the emulated graphical mode while using as
much screen space as possible. The balance between the precision of
aspect ratio and the utilisation of screen space is specified as the
`parweight' parameter to pp_getscale() and is currently hard-coded in
sdlmain.cpp.

This implementation emulatates pixel-perfect mode as a special case of
nearest-neighbor interpolation when the horisontal and vertical scaling
factors are integers.
2020-03-09 20:12:36 +01:00
Joshua Fern
f2029d71d8 Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
krcroft
46044b6387 Use static assert feedback instead of convoluted template failure messages 2020-03-06 19:21:44 +01:00
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