1
0
Fork 0
Commit graph

49 commits

Author SHA1 Message Date
Patryk Obara
f49eb0904b Implement starts_with and ends_with functions
There are many options for implementing these functions; using C++14
std::equals is the simplest one, and allows for marking the function as
noexcept.
2020-05-11 01:18:21 +02:00
Patryk Obara
c890c7b05b Implement iround helper function 2020-04-14 06:28:08 +02:00
krcroft
73e22747e7 Use references when catching polymorphic exceptions 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
dbc77a6f1c Prevent empty property names 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
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
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
krcroft
b302b535c3 Add DEBUG messages for protected-file handling 2020-02-24 12:08:01 +01:00
Patryk Obara
0e32c002ae Cleanup ifdef guards in serialport misc util 2020-02-19 19:25:47 +01:00
krcroft
93f9cd7e4e Fix audio-related static analysis issues 2020-01-29 17:13:25 +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
krcroft
78cc6be86d Make use of template variable, and reformat whitespace 2019-12-09 08:19:26 +01:00
krcroft
c9198b2944 Fix unsafe memory operations and warnings in the fatDrive class
- Move imageDiskList from pointer to vector of unique_ptr
- Replace string operations with size-limited versions
- Initialize members
- Eliminate unecessary casts
- Eliminate memory-leak on pointer assignment
2019-12-09 08:19:26 +01:00
krcroft
8c6758c8d1 Memory overrun and C++11 updates
- Limit write length into buffer, and add comment about corner-case
- Use C++11's syntax to explicitly remove private copy and assignment operators
- Use C++11 container loop syntax to shorting a cleanup function
2019-12-07 19:08:47 +01:00
krcroft
cff6b05559 Improve memory safety in the DOS Drive Cache class
- Fix Bitu printf format type
- Check a pointer prior to dereferencing it
- Prevent writing one-beyond the last index
- Replace strcpy with with helper safe_strcpy, provided by @dreamer - thank you!
- Replace strcat with strncat
- Add constructor intializers for scalars and arrays
- Initialize and replace 0-value pointers with nullptr
- Pass in the buffer length when strncpy'ing into a function variable
2019-12-07 19:08:47 +01:00
krcroft
eaeb001b17 Play into subsequent track(s) if playback length exceeds the the current track
Issue reported by Dagar and Pr3tty F1y, and confirmed as a bug by ripsaw8080.
Thank you!

This fixes the GoG release of Betrayal at Krondor which (either due to CD mastering
issues or a faulty rip), requests playback of a given track at the tail end
of the prior track.

In debugging and performing this fix, many debug messages were improved as well
as making some small small code adjustments, such as using iterators to point to
individual tracks (track->attribute) instead of using the tracks array
(tracks[track -1].attribute).
2019-11-24 17:34:54 +01:00
Peter Veenstra
1fbaff47fc Update year and address of FSF
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4183
2019-01-25 14:09:58 +00:00
Peter Veenstra
5bb10db88b Time keeps on ticking
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4109
2018-05-29 12:58:58 +00:00
Peter Veenstra
54c993669a Strip spaces properly. Fixes bug #480
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4100
2018-05-06 19:34:22 +00:00
Peter Veenstra
6cf39c1fc6 Years update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4021
2017-05-30 11:35:08 +00:00
Peter Veenstra
0f4c92ca32 Year update.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3878
2015-01-06 14:40:32 +00:00
Peter Veenstra
2fea508f7f Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3812
2013-01-15 09:03:13 +00:00
Peter Veenstra
999f33de27 Update year. Remove CVS tags
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3700
2011-04-26 09:34:55 +00:00
Peter Veenstra
a78b2c4f8b Update year
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3548
2010-02-11 13:36:50 +00:00
Peter Veenstra
16d14b78e1 Some year and version numbers
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3410
2009-05-27 09:15:42 +00:00
Sjoerd van der Berg
88caf1dc71 Add compiler testing for always_inline attribute
Add compiler testing for fastcall attribute
Add the FASTCALL define to visual c
Remove some overkill inline routines
Make sure that all the inline routines in headers are static


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3355
2009-04-25 16:25:03 +00:00
Peter Veenstra
bd88bcea69 Add low- and uppercase for std::string.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3078
2008-01-13 11:28:41 +00:00
Peter Veenstra
fdd16dea1a Happy New Year\!
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2728
2007-01-08 19:45:42 +00:00
Peter Veenstra
132bbffb68 Add part of patch 1235377 of msharov and fix a few small bugs in the return values of the cpu cores
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2593
2006-04-11 19:02:33 +00:00
Peter Veenstra
df67775306 time passes on and on....
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2480
2006-02-09 11:47:57 +00:00
Peter Veenstra
c7c2ee5d5a Add patch 1239754 from Moe. This patches fixes a few crashes by checking the SDL_SetMode return value and it changes strncopy to a safe_strncopy which adds a 0 to each string copied
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2240
2005-07-19 19:45:33 +00:00
Peter Veenstra
224ef1a68b new include system + lot's of classes maintaining certain aspects of dosbox
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2140
2005-03-24 21:11:05 +00:00
Peter Veenstra
2094d8b985 Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2106
2005-02-10 10:21:12 +00:00
Peter Veenstra
4e69d3bf7a Made all string functions more aware of systems with reverse signed unsigned defaults
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2027
2004-10-17 14:54:41 +00:00
Peter Veenstra
ca409fd57c Typo in preamble
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1899
2004-08-04 09:12:57 +00:00
Sjoerd van der Berg
b3e0ba59e5 change const char * to char * for the trim functions
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1872
2004-07-05 12:00:26 +00:00
Sjoerd van der Berg
c7e25e08b7 Add some new function and clean up
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1793
2004-05-11 18:58:18 +00:00
Peter Veenstra
fcbd0fe854 Copyright to 2004
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1552
2004-01-10 14:03:36 +00:00
Peter Veenstra
87216faa9b Added patch 826821 from phearbear
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1382
2003-10-27 14:16:59 +00:00
Peter Veenstra
4ff5924eb1 changed upcase and lowercase code.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@582
2002-12-17 18:32:02 +00:00
Sjoerd van der Berg
dd95e35dd3 Removed wildcmp
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@341
2002-10-18 09:18:16 +00:00
Sjoerd van der Berg
42e5d0b779 First CVS upload.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@80
2002-07-27 13:08:48 +00:00