Commit graph

195 commits

Author SHA1 Message Date
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 333d619858 Update tool_bundle.py to parse correctly under Python3
mmontag reports that tool_bundle.py cannot be parsed under Python 3.
Fortunately, the errors are all straightforward, so non-OS X systems can
see the errors when the file is imported.  Normally, the file is only
imported when building for darwin, so non-OS X systems do not see the
problem.

- Add parentheses to print() calls.  This is not consistent with the
  rest of the Rebirth output scheme, but is simple to do.
- Adjust the syntax for raising exceptions.

Reported-by: mmontag <https://github.com/dxx-rebirth/dxx-rebirth/issues/503#issuecomment-619463994>
2020-04-26 17:26:23 +00:00
Kp b396445efa Require support for std::index_sequence, std::make_index_sequence
The minimum supported compiler versions now provide a depth-efficient
implementation of std::make_index_sequence, which removes the last
reason to carry a private implementation.  In the case of clang, it
appears to have a special compiler intrinsic used to implement its
std::make_index_sequence.

Switch to the compiler-provided version for both gcc and clang.
2020-04-26 17:26:23 +00:00
ziplantil b38f99d7ce modify SConstruct to handle target platform; fix track finish detect code 2019-10-27 14:53:48 +02:00
ziplantil 24fc28c8bd indent fixes, improve comments, other code fixes 2019-10-27 03:11:15 +03:00
ziplantil e664d93ea4 add hack for MCI or CD driver bug (?) 2019-10-27 02:48:20 +03:00
ziplantil 2c5ab8e739 initial version of this, trying to catch MCI events 2019-10-27 02:47:45 +03:00
daivuk 74ef8b02e6 Added axis buttons
Each axis can act as two buttons in both ways.
For example, a player might map slide left and slide right to J1 -A1 and J1 +A1 as button presses instead of the slide L/R axis.

This is mostly to fix XBox 360 Controller Left and Right triggers. But it can work on every axis if the player wishes to bind them.
2019-09-01 13:11:14 -04:00
Kp 6d0cd8513e Recompute automap subcanvas on window size change
The subcanvas is positioned based on the dimensions of the containing
window, so it must be repositioned if the outer window is resized.

Reported-by: vLKp <https://github.com/dxx-rebirth/dxx-rebirth/issues/394>
Fixes: f491059ed7 ("Enable building with SDL2")
2019-08-18 20:37:29 +00:00
Kp 10de0975f4 Fix gcc-9 build of joy.cpp
gcc-9 fails to constrain `i`, then warns that very large `i` would
be truncated.  Add `cf_assert` and `xrange` to inform gcc that `i` is
constrained.
2019-05-06 00:36:16 +00:00
Kp 2243cd7f58 Use xrange for loops with zero start and constant numerical end
s/for\s*(\s*\(\w\+\)\s\+\(\w\+\)\s*=\s*0\+u\?\s*;\s*\2\s*\(!=\|<\)\s*\([0-9]\+\)u\?\s*;\s*\(++\s*\2\|\2\s*++\s*\))/range_for (const \1 \2, xrange(\4u))/
2019-05-04 18:27:36 +00:00
Kp 3cc644eb52 Fix gcc-7 build of joy.cpp
gcc-7 needs an additional cf_assert to inform it that e.idx is
constrained.  Without this, it assumes e.idx could have any positive
value, then issues a fatal warning when INT_MAX does not fit in the
provided buffer.

    common/arch/sdl/joy.cpp: In function 'void dcx::joy_init()':
    common/arch/sdl/joy.cpp:281:6: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 4 [-Werror=format-truncation=]
    common/arch/sdl/joy.cpp:281:6: note: directive argument in the range [1, 2147483647]
    common/arch/sdl/joy.cpp:333:13: note: 'snprintf' output between 6 and 24 bytes into a destination of size 8
2019-04-28 00:53:40 +00:00
Kp 645daa2304 Format joystick indices as unsigned values 2019-04-13 18:00:07 +00:00
Kp 4e1bbc0759 Improve Windows exception strings 2019-02-02 18:36:39 +00:00
Kp 8425e75e62 Factor out RAII_Windows_DynamicSharedObject::Load common logic 2018-12-13 02:31:39 +00:00
Kp a76487405c Make ADL MIDI runtime configurable
Add configuration file entries for number of chips, bank index, and
whether to use ADL MIDI.  Currently, there is no GUI for this.
Interested users must enable it via direct configuration file editing.
A menu interface will come later.
2018-10-18 02:18:56 +00:00
Kp 1be414217c Add build time flag to choose whether to enable ADL MIDI support
Since ADL MIDI is not packaged on some distributions, default the option
to off.
2018-10-15 00:51:53 +00:00
JP Cimalando ccb91d7362 allow libADLMIDI to be loaded dynamically 2018-10-08 05:02:02 +02:00
JP Cimalando 00a57d5a28 fix how the adlmidi music is looped 2018-10-05 14:23:43 +02:00
JP Cimalando ba8c8ac5a7 apply a few changes as suggested by @vLKp 2018-10-05 14:20:13 +02:00
JP Cimalando cabe06e895 WIP ADLMIDI 2018-10-04 12:06:27 +02:00
Kp 12b57e84e6 Switch most in-tree http:// links to https://
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it.  These domains were converted:

* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
2018-09-02 00:57:29 +00:00
Kp ec1cf005b6 Enable -Wformat-truncation
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible.  Use it to avoid generating range checks for
situations that never happen.  If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
2018-08-26 18:10:36 +00:00
Kp 25ab07bcc5 SDL2: set relative mouse mode when grabbing the mouse
Reported-by: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/397>
2018-07-29 21:17:09 +00:00
Kp c65020bf04 Fix gcc-8 build of common/arch/sdl/key.cpp
gcc-7 allows `constexpr auto X = std::initializer_list<unsigned>{A1, A2,
...};`.  gcc-8 rejects it:

```
common/arch/sdl/key.cpp:583:105: error: 'const std::initializer_list<const SDL_Scancode>{((const SDL_Scancode*)(&<anonymous>)), 3}' is not a constant expression
  constexpr auto sticky_keys = {SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_NUMLOCKCLEAR};
```

Switch to a macro and a fully anonymous list, which is accepted by both
versions.

Fixes: f491059ed7 ("Enable building with SDL2")
2018-07-29 16:13:15 +00:00
Kp f491059ed7 Enable building with SDL2
This commit enables Rebirth to build with SDL2, but the result is not
perfect.

- SDL2 removed some sticky key support.  Rebirth may behave differently
  now in this area.
- SDL2 removed some key-repeat related support.  Rebirth may behave
  differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
  the desktop instead of by changing the desktop resolution.  Rebirth
  uses this, and it mostly works.
  - Resizing while in the automap does not notify the automap code, so
    the view is wrong until the player switches out of automap mode and
    back in.
- SDL2 changed how to enumerate available resolutions.  Since
  fitting the window to the desktop is generally more useful than
  fitting the desktop to the window, I chose to drop support for
  enumerating resolutions instead of porting to the new API.  Users can
  now enter an arbitrary window dimension and Rebirth will make an
  attempt to use it.
  - It might be useful to cap the window dimension at the desktop
    dimension, but that is not done yet.
  - Entering fullscreen mode through the Controls->Graphics submenu
    failed to notify the relevant subsystems, causing the rendered
    content not to rescale.  For now, compile out the option to toggle
    full screen through that menu.  Toggling through Alt+Enter works
    properly.

Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all.  The remaining issues can be
resolved in future work.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-28 23:22:58 +00:00
Kp fd0238cb6b Silence gcc-8 -Wcast-function-type in except.cpp
gcc-8 adds a new warning controlled by -Wcast-function-type, which is
implied on by Rebirth's default options.  This new warning rejects
attempts to reinterpret_cast between function pointer types.  While this
might provide some value when the function pointer was derived by taking
the address of a properly declared function provided elsewhere in the
same program, it is wrong when the function pointer is returned by an
external library call, such as GetProcAddress, which always returns a
placeholder type instead of the actual type of the target function.
Switch to using a union with type-punning, which achieves the same
effect as the cast, but does not count as a cast, and therefore does not
provoke the warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-07-15 04:43:55 +00:00
Kp 9ea09107d1 Delegate managing SDL_RWops to SDL_mixer when possible
SDL_mixer 2 offers the option to have the library free the SDL_RWops.
Add macros to use this feature when available.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-05 04:03:34 +00:00
Kp e63bbe8c52 Set d_event type at construction 2018-05-12 18:24:19 +00:00
Kp 80ee9f9249 Merge pull request #376 "Update SDLMain.m" to github/master
Reviewed-by: kreatordxx <https://github.com/dxx-rebirth/dxx-rebirth/pull/376#issuecomment-383352781>
2018-04-23 05:09:52 +00:00
derhass 38815ba10b change SYNC_GL_AUTO mode to disable GL sync if VSync is turned off
Users with disabled VSync might not expect any forced waiting on the GPU,
and the GL sync methods were intented to fix issues with VSync only,
so the new heuristic for SYNC_GL_AUTO is to enable GL sync only if
VSync is enabled, too.

Users can still request to use a specific GL sync method via the
-gl_syncmethod switch, independent of the VSync setting.

[Kp: folded `else { if () }` into `else if ()` to avoid moving
`ogl_have_ARB_sync` lines.  Original change visible at
<https://github.com/dxx-rebirth/dxx-rebirth/pull/381>.]
2018-04-23 04:57:48 +00:00
derhass 8e43a845b3 handle multiplayer network packets during SYNC_GL_FENCE_SLEEP wait loop
This mirrors the logic from calc_frame_time(). When VSync is enabled,
waiting for the previous frame to complete might induce long wait periods,
up to the complete frame time, so we should also handle multiplayer there.

For the other sync modes, the GL calls will simply block, so we can't do
anything about that (except going multithreaded, but that's a totally
different can of worms). Note that even without sync, the SwapBuffers()
call in gr_flip() may also block if VSync is on (and enough frames are
queued up), so the issue is not the GL sync code itself.

SYNC_GL_FENCE_SLEEP is now probably the nicest mode for multiplayer
with VSsync, as it is the only one which has the potential to continue
handling multiplayer packets during the wait for VBlank time.
2018-04-22 18:14:34 +02:00
C.W. Betts c4417aafb1 Update SDLMain.m:
10.9 changed how applications were launched, making the old method of detecting a Finder launch fail.
2018-04-16 16:19:36 -06:00
Kp d469bcbe24 Guard event_get_idle_seconds in #if DXX_USE_EDITOR
Only editor code accesses this variable.  Skip tracking it in non-EDITOR
builds.
2018-02-10 22:23:36 +00:00
Kp 01e1b28d71 Replace useless printf with puts 2017-12-05 05:29:55 +00:00
Kp d42fff397b Fix Windows exception log short stack
The Windows exception handler probes the stack to determine how much can
be safely dumped, up to a fixed maximum number of bytes.  A logic error
caused the probe function to start its stack probe lower than intended,
so the eventual dump code logs fewer pre-exception bytes than intended.
Fix that error so that the dump shows more pre-exception bytes.

Also, log the address of the ud2 instruction, so that the effective load
address of the module can be determined.  Without this, ASLR makes
reading the dumps needlessly difficult.
2017-11-18 04:45:50 +00:00
Kp 6b209c8713 Decorate OpenGL messages
Some Linux libraries print their own messages to stdout/stderr,
particularly in case of severe errors.  Decorate messages generated by
Rebirth to distinguish them from library generated messages.

For specific blacklisted renderers, add a message informing the user
that the blacklist matched and changed settings.
2017-08-26 19:47:51 +00:00
Kp 9421c31b5a Replace "compiler-type_traits.h" with <type_traits>
Delete stub "compiler-type_traits.h" header.  Redirect all uses to the
standard <type_traits> header.

git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
    BEGIN {
	    $i = 0;
    }
    if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
	    # First blank line or first user-include after a system-include.
	    # Print, then never again for this file.
	    print "#include <type_traits>\n";
	    $i = 2;
    } elsif ($i == 0) {
	    $i = 1 if (/^#include </);
    } elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
	    # Remove this line if found.
	    $_ = '';
    }
    # Reset state machine when moving to next file.
    $i = 0 if eof;
EOF
2017-06-25 20:46:03 +00:00
Kp 32daf8e8c3 Handle unaligned stack during Win32 hexdump logging
The dump logger probes for the end of the stack, then rounds down to the
nearest paragraph boundary to simplify the logic in the hexdump routine.
The termination condition in the hexdump code assumed that there would
exist an integer N such that (`start` + (16 * N) == `end`).  Since `end`
is rounded to a multiple of 16, this held if and only if `start` is also
a multiple of 16.  In practice, this tended to happen, but it was not
guaranteed by the code.  If it ever failed to happen, then the hexdump
routine would not terminate and would instead perform an invalid read
beyond the edge of the stack.

Modify the hexdump routine to round `start` to a multiple of 16 so that
the termination condition works as intended.  This has the useful side
effect that hex dumps now always start paragraph aligned.  When the
stack was not paragraph aligned, this change will cause the hexdump to
show bytes below the stack pointer at the time of the fault.  However,
the stack requirements of the handler itself ensure that these bytes
will be valid.
2017-06-03 17:11:12 +00:00
Kp 9478d1e6a5 Add custom terminate handler on Windows 2017-04-22 21:23:56 +00:00
Kp 5d951e4453 Move ogl_sync fence into local scope for before_swap 2017-04-08 16:48:19 +00:00
Chris Taylor bde055a6a1 Fix 'declaration shadows a field of 'dcx::ogl_sync'' warning
Replace fence with fence_func in implementation of ogl_sync::sync_deleter::operator().
2017-01-13 12:30:09 +08:00
Kp 85338cba5e Fix memory corruption starting multiplayer game
Various points in the game code call `hide_menus()`, then later use
`show_menus()` to reverse the effect.  If the forcibly hidden window is
deleted before `show_menus()` is called, the attempt to show it would
write to freed memory.  Add a hook to forget those windows when they are
deleted, so that `show_menus()` does not try to make them visible later.
2016-11-19 18:09:26 +00:00
Kp 2dd4b574c7 Use virtual function to dispatch window events 2016-11-19 17:24:52 +00:00
Kp 61c11ec4d4 Use d_enumerate for SDL joystick loops 2016-11-19 17:24:52 +00:00
Kp 8c4668179e Merge refs/pull/264/head into master 2016-11-13 17:02:26 +00:00
Chris Taylor e597f159e9 In event_process, handle the case of a window deleted in drawing loop with no previous window correctly, preventing possible crash 2016-11-13 11:47:59 +08:00
Chris Taylor 709a2c3d2a Fixes freeze when starting new game or editor
Fixes freeze introduced by 9511f65 where event_process wouldn't go to the next window if it's hidden.
2016-11-07 09:32:06 +08:00
Kp 1cb04cb64b Merge branch derhass:patches/GLES_GL_extension_unification into master 2016-11-06 19:24:52 +00:00
Chris Taylor 143ed30fee Merging in unification/master, resolving conflict in similar/main/kmatrix.cpp 2016-11-06 14:20:18 +08:00