Commit Graph

1901 Commits

Author SHA1 Message Date
Rafael Kitover 1fc0966384 minor code cleanup
Change one instance of a dummy local variable to a C++11 temporary via
CLASS{param}.
2017-09-23 15:29:35 -07:00
Rafael Kitover f069f0c02d default LTO to OFF on 64 bit MinGW
64 bit MinGW (e.g. msys2 64 bit) produces a binary that immediately
segfaults when built with LTO.

Make ENABLE_LTO default to OFF on 64 bit MinGW (32 bit will still
default to ON.)
2017-09-22 00:42:49 -07:00
ZachBacon 75ef0aa26d Added executable extension
* Allows the SDL binary to be installed if it's cross compiled from
within linux or macOS for windows for packaging purposes.
2017-09-22 02:46:20 -04:00
Rafael Kitover e9a86c541d fix deadlock in SoundSDL::deinit() #139 #130
On SoundSDL destructor and `reset()`, there was a deadlock with Linux
pthreads, it happened sometimes that the reader thread would call
`SDL_SemWait(data_available)` while `deinit()` would destroy the
semaphore and the `SDL_SemWait()` would end up waiting forever on a null
semaphore.

Change the sequencing of deinit() to prevent this from happening, set
`initialized = false` at the beginning of the sequence to prevent
subsequent entries into the reader callback, and add an SDL_Delay(100)
between the final `SDL_SemPost()` and `SDL_UnlockMutex()`s and the
`SDL_DestroySemaphore()` and `SDL_DestroyMutex()`s to allow a running
reader to complete with a valid mutex and semaphores before they are
destroyed and the thread is joined.

Resetting the sound system also sometimes triggers a memory corruption
bug, but that's a separate issue.
2017-09-21 15:39:30 -07:00
Rafael Kitover 3d792457b2 fix huge app icon in Win volume settings #149 #121
We were setting the app icon based on the 256x256 xpm icon in the xrc,
and this triggered a bug where the app-specific icon in Windows volume
settings was huge:

https://stackoverflow.com/questions/17949693/windows-volume-mixer-icon-size-is-too-large/46310786#46310786

Adapt the code from that SO question to use Windows-specific code to
load and scale the icon appropriately using a Vista+ API, and fall back
to the normal Wx icon loading mechanism on XP.

Also generate a nice new `vbam.ico` Windows icon file based on the
`.svg` using the app from:

https://iconverticons.com
2017-09-19 16:28:23 -07:00
Rafael Kitover de89bd0561 use num cpu cores to parallelize LTO link with gcc
Use the `cmake` `ProcessorCount` module to determine the number of CPU
threads, and set the `-flto` flag for gcc to `-flto=${num_cpus}` if the
number of CPU threads is detected and is greater than `1`.

clang does not support this.
2017-09-19 06:58:48 -07:00
Rafael Kitover 268c638456 improve win32 dependencies git submodule handling
Use `git submodule update --remote --recursive` instead of `git
submodule update --init --recursive` so that the latest version of the
repo is always installed.

Run the command from cmake instead of throwing an error if the submodule
is not checked out. Only throw an error if the checkout failed or the
source tree is not a git checkout.

Don't add the `mingw-xaudio` include directory if using MSVC.

Remove the submodule check from src/wx/CMakeLists.txt, having it in the
main CMakeLists.txt is enough.
2017-09-19 06:11:41 -07:00
Rafael Kitover d3351a7575 remove doctoc title from README.md TOC
Remove the "generated with doctoc" title from the README.md table of
contents.

Need to run `doctoc --notitle`.
2017-09-18 01:02:33 -07:00
Rafael Kitover 42fb76bfcf update README.md
Note that LTO now defaults to ON, and ENABLE_ASM does not turn on
ENABLE_ASM_CORE.

Trim the wxLogDebug() section.

Titlecase headings.

Generate a TOC with `doctoc`.
2017-09-18 00:58:47 -07:00
Rafael Kitover 7f1fec88af work around gcc lto wrappers bug with gcc 7.x
gcc lto wrapper commands such as `gcc-ar` will segfault with some
versions of gcc 7.x when called via an absolute path, see:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80717

Generalize the mechanism for compiling a small C program on the host
(currently used for bin2c for Wx resources) and use it to wrap the gcc
wrappers in a little executable that prepends their dirname to PATH and
runs them with `execvp()`.

Make LTO default to ON again, except on win32 with gcc < 7, because
those toolchains produce broken binaries with LTO enabled.

Also add `-ffat-lto-objects` to compiler flags for gcc when LTO is
enabled, this will increase the chances that the LTO build will succeed
even if there are issues with the binutils wrappers. Clang does not
support this.
2017-09-16 19:47:39 -07:00
Rafael Kitover b82cab14e2 rename CMakeScripts/ to cmake/
Most projects nowadays call the project specific cmake scripts directory
just `cmake/` and we will do so as well.
2017-09-13 20:30:33 -07:00
Rafael Kitover 02b3defcd0 restore wx 2.8 compat, improve string processing
Fix building with wx 2.8 by rewriting some more string related code.

Replace all calls to .c_str() with .mb_str().

Remove some of the .c_str()/.mb_str() calls where the target is already
wxString.

Move the split()/enum_idx() functions from opts.cpp into
str_split()/vec_find() in strutils.h/strutils.cpp for use in other
files.

Replace the C-style string parsing code in a couple of places in
wxvbam.cpp for processing possible command line options by splitting on
'='.

Also replace a couple of places that use pointer arithmetic in
widgets/joyedit.cpp and widgets/keyedit.cpp with wxString methods.
2017-09-13 05:32:44 -07:00
Rafael Kitover fa9afa4e18 cmake: wx and cross compiling fixes
When calling find_package(wxWidgets ...) allow the first call to fail
because the OpenGL library may not be found. A subsequent call without
listing the OpenGL library is done with REQUIRED.

And if the OpenGL library is not found, skip the OpenGL compile test.

When cross-compiling (e.g. with mxe or other mingw packages) skip the wx
ABI compatibility run tests.

When choosing which minhook lib to link to the wx ABI compat run test
program, check for 64 bit but fallback to 32 bit just in case.
2017-09-12 15:31:49 -07:00
Rafael Kitover 5691ac0c0e installdeps: fedora fixes, including m32
Fix some syntax errors and extraneous output in fedora_installdeps().

"Fix" the 32 bit deps installer to try to ignore file conflicts between
i686 and host rpms, by first using rpm --force to install the 32 bit
rpms and then overwriting them with the host ones using --force as well.
This is hackish and fragile, but there aren't any good alternatives
right now.
2017-09-12 13:47:56 -07:00
Rafael Kitover f5cb7b2b40 support Wx built with --enable-stl #134
When Wx is built with --enable-stl, wxString to wxChar*/char* implicit
conversions and vice-versa no longer work.

Change all wxChar* data members to wxString and change all pointer
arithmetic code (mostly in opts.cpp, cmdevents.cpp and
widgets/joyedit.cpp) to use wxString methods instead.

Also make mostly minor changes in various other files for all of this to
work.
2017-09-10 15:44:18 -07:00
Rafael Kitover 142dbc0aca cmake: use arch specific minhook trampoline libs
Use either the 32 bit or 64 bit MinHook trampoline static lib for the Wx
ABI tests, depending on the detected arch of the host/target.
2017-09-10 12:24:36 -07:00
Rafael Kitover de95c70547 fix Wx ABI check for Win32/MinGW
Fix error dialog boxes popping up when the Wx ABI compat tests are run
from cmake.

Wx 3.x is hardcoded to use MessageBox for wxLogFatalError(), even in a
console app, so use the minhook trampoline lib (added to dependencies)
to hook the Win32 API MessageBoxW and MessageBoxA (the second just in
case) so that no error dialogs pop up.

Details here:

https://www.codeproject.com/Articles/44326/MinHook-The-Minimalistic-x-x-API-Hooking-Libra
2017-09-10 11:00:24 -07:00
Rafael Kitover 42f6c446ea minor improvements for Wx compile tests
Include `wx/wxprec.h` (precompiled header first in test programs to
possibly make the tests slightly faster.

For the ABI compat check, set a variable for the test program instead of
listing it twice.
2017-09-08 08:59:19 -07:00
Rafael Kitover ceef480e70 improve wx GCC ABI check #142
Following some suggestions from @ArtiiP, first check if there are no
issues without an -fabi-version flag, and then instead of incrementing
from 0, decrement from 15 to find the highest working ABI version.

This is very slow if the needed ABI version is 2 for example, but not
much to do about that for the time being.
2017-09-04 12:28:24 -07:00
Rafael Kitover b1937fe9cb improve Wx GCC ABI check #142
Start checking the ABI version at -fabi-version=0, which is the default,
and if that succeeds don't set the flag at all.

This will allow the code to work properly if and when Wx removes the ABI
check alltogether.
2017-09-02 18:52:01 -07:00
Rafael Kitover 4b1c9b4e86 installdeps: minor refactoring/cleanup
Break command line argument processing and OS detection off into
functions called from `main()`.

Remove all references to cairo.

For fink, install the SFML package I made instead of turning off link.
2017-09-02 03:59:31 -07:00
Rafael Kitover 2ad204619b compile/run test to detect Wx ABI version #142
In 4e665ae I hardcoded -fabi-version=2 for g++ flags, and @ArtiiP
pointed out that this is wrong, because Wx may be compiled with other
ABI versions.

Add cmake check_cxx_source_runs() tests to determine the correct ABI
version flag to use with Wx.
2017-09-01 21:51:24 -07:00
Rafael Kitover 4e665ae088 use -fabi-version=2 for GCC, turn off LTO #142
Use the g++ `-fabi-version=2` compiler option, as suggested by @ArtiiP
to fix problems similar to:

```
Fatal Error: Mismatch between the program and library build versions
detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1002,wx
containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1009,wx
containers,compatible with 2.8).
Aborted
```

Turn LTO off by default until I fix it for newer gcc/binutils, currently
with gcc7 ar segfaults linking vbamcore.
2017-09-01 05:06:26 -07:00
Rafael Kitover 1a27f81342 installdeps: use -j$(nproc) not -j8 in info #146
Replace the hardcoded `make -j8` command in the build instructions with
a `-j` parameter that is the number of the host's CPUs minus one.

Subtracting 1 is done to reduce chances of overloading the host.

If the value is `1`, then don't print the `-j` flag at all.
2017-08-31 16:56:06 -07:00
Rafael Kitover 8b2e8f87d4 only use -mtune=generic on x86/amd64 #146
This flags breaks the build on e.g. ARM, so only use it when a PC
architecture (x86 or amd64) has been detected. Thanks to ZachBacon for
spotting this.
2017-08-30 14:42:08 -07:00
Zach Bacon 350619be93 Merge branch 'master' of https://github.com/visualboyadvance-m/visualboyadvance-m 2017-08-27 22:02:03 -04:00
Zach Bacon c6d8939304 Made a tiny, itty bitty, little accident. Forgot to remove cairo option
from the xrc.
2017-08-27 22:01:19 -04:00
Rafael Kitover e0f79f32a5 remove version.h in ConfigManager and AutoBuild.h
ConfigManager does not use any version info, but is part of libvbamcore,
so removing the `#include` makes rebuilds after git changes much much
faster.

Remove the AutoBuild.h includes from ConfigManager.cpp and SDL.cpp (the
SDL port) because the information in that file does not seem to be used
and it also includes version.h, forcing those files to rebuild
unnecessarily.
2017-08-27 13:32:13 -07:00
Rafael Kitover 82d0b04a01 remove cairo references from README.md
Since Cairo was dropped in 1583a226, remove all references to it in
README.md .
2017-08-27 13:22:41 -07:00
Rafael Kitover 2179215a8b fix rebuilds on git changes
Use cmake to generate the version.h from version.h.in which is a cleaned
up version of the old version.h with the git short sha into the build
directory, and include the version.h from there.

Continue to use the GetGitRevisionDescription plugin to make the cmake
configuration state depend on the current sha of HEAD, but throw away
the results (for the time being.)

This makes rebuilds after git changes such as a commit only recompile a
couple of files instead of the whole tree.
2017-08-27 13:20:17 -07:00
Zach Bacon 23ed930de1 Say good bye to cairo 2017-08-27 13:32:32 -04:00
Zach Bacon 1583a226f4 *Removal of the cairo renderer, it never performed well to begin with. 2017-08-27 13:11:34 -04:00
Rafael Kitover 1a8f2f9886 "no throttle" fixes/cleanups
`throttle == 0` is supposed to emulate at full speed and drop audio
data, this is different from `throttle == 100` which is emulation
throttled at normal speed, the default setting.

Fix the recently rewritten SoundSDL sound driver to make `throttle == 0`
work, and make some minor changes to clean up the relevant code in the
XAudio2 sound driver.
2017-08-27 07:21:27 -07:00
Rafael Kitover 9bca4f7292 document how to provide symbolic backtraces
Add a "REPORTING CRASH BUGS" section to the README.md with instructions
for how to provide a symbolic backtrace on Linux and MSYS2.

Add a "Crash bugs" section the the issue template with a link to said
README.md section.
2017-08-17 14:25:27 -07:00
Rafael Kitover 1e3a85a34b cleanup SoundSDL #139 #130 #97 #67 #65 #46 #47
Rewrite SoundSDL (the SDL sound driver).

Clean up the code and eliminate all deadlocks/hangs/crashes (hopefully.)

Many of the deadlocks were caused by initialize() not de-initializing
properly and causing the audio callback thread to deadlock, fix this.

Also use better logic for the semaphore controls, which will also
hopefully increase audio quality.

Use better logic for the throttle control, with throttle == 0 being the
same as throttle == 100 and implement setThrottle().

Also increase the buffer size to 300ms and the number of samples to
2048, for hopefully less choppiness in audio overall.
2017-08-17 02:44:40 -07:00
Rafael Kitover f88faef1b2 SoundSDL: write silence when paused #139
The SDL API documentation for the audio callback specifies that the
callback *MUST* write to the buffer and not just return:

https://wiki.libsdl.org/SDL_AudioSpec#Remarks

write silence to the buffer (value taken from the AudioSpec returned
from OpenAudioDevice) when the emulator is paused.
2017-08-16 15:20:05 -07:00
Rafael Kitover 4d7e102e26 hopefully fix resize artifacts on game panel #138
Paint the whole GameArea (containing the emulator graphics panel) black
on size events for both the GameArea and the panel.

This will hopefully fix reports of garbage around the panel when going
full screen with the OpenGL driver on Linux.
2017-08-16 04:02:12 -07:00
Rafael Kitover 346d97a760 remove default F11 keybinding for save state #137
Remove F11 as the default key for save state (GS=) in the defkeys array
in opts.cpp and leave it unmapped by default, because it conflicts with
the menu XRC mapping for full screen which is also F11 on non-macOS
platforms.
2017-08-16 03:36:18 -07:00
Rafael Kitover 5e9c9093c0 SoundSDL: lock conditional code cleanup
Move the `bool lock` condition used to wait for sound data to be
exhausted from two places in the code into the `bool should_wait()`
member function.
2017-08-16 03:20:10 -07:00
Rafael Kitover 03a20820cb temp fix for deadlocks in SoundSDL on pause #139
SDL_PauseAudioDevice seems to be causing thread deadlocks in combination
with Wx threads (e.g. on menu activation or modal dialogs.)

Remove these calls from SoundSDL::pause() and SoundSDL::resume() for the
time being so that deadlocks do not happen.

This effectively allows pausing, but on resume there is no sound for 2-3
seconds until the buffer is filled again.

This will need a proper fix at a later time.
2017-08-15 15:30:27 -07:00
Nicola Spanti (RyDroid) 2da2d9c41d Improving README 2017-08-14 15:28:52 -07:00
Rafael Kitover fb15aed223 fix memory viewer xrc on wx 3.1+ #127
Remove the wxALIGN_CENTRE_VERTICAL flag from items that have the
wxEXPAND flag in the MemViewer.xrc because wx 3.1+ warns about the flags
being incompatible.
2017-08-09 03:03:56 -07:00
Rafael Kitover 1d0eece046 let cmake escape -D preproc. definitions
As cmake now warns when policies are set to OLD, change the CMP0005
policy to NEW.

What this does is have cmake escape -D preprocessor definitions passed
to e.g. add_definitions() starting in cmake 2.6 . This is fine since the
minimum cmake version we support is 2.8.12 . It also makes the code
cleaner since we don't have to escape quotes anymore ourselves. This
will also work better on different platforms, where different escapes
may be needed.

Remove all quote escapes from string params to add_definitions() for
this policy change to work.
2017-08-09 02:34:40 -07:00
Avindra Goolcharan 0bdbcf3188 SUSE Lint: fix a few classes of warnings #136
- drop unused variables

- unused-but-set-variable

- stray trailing comments

- in viewsupt.cpp replace redundant expression with variable that holds the same value
2017-08-08 20:05:38 -07:00
Avindra Goolcharan dd91abf72e fix errors reported by SUSE's post-build linter
In StartRFUSocket() in gba/GBALink.cpp move a postincrement out of an
expression to a following statement, because the evaluation order is
undefined.

In GetDevices() in wx/openal.cpp replace an #else with an #endif so that
the function has a default return statement visible to the linter.

In FilterThread::Entry() add a `return 0;` (ExitCode) statement at the
end even though it is probably never reached.

In the TransferToWindow() for the positive double validator widget in
wx/widgets/wxmisc.cpp add a default `return true;`, for the rare case
there is no double value, in which case the string representation would
be displayed (since it is a subclass of wxGenericValidator(wxString&) .)
2017-08-07 20:31:08 -07:00
Rafael Kitover d118c457b1 regenerate translation files
Run po/update_pot.sh and rebuild all .po files.
2017-08-03 23:33:30 -07:00
Rafael Kitover c99a58faee fix a memory leak due to wrong syntax
In C++ arrays are deleted with `delete[]` and not `delete`.
2017-08-03 16:29:37 -07:00
Zach Bacon 997b97573f
Added updated and new translations 2017-06-03 12:19:28 -04:00
Zach Bacon ebfc8fdb12
Updated translation pot file 2017-06-03 12:11:53 -04:00
Rafael Kitover 783475bf39 switch to cmake module GNUInstallDirs #116
See:

https://cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs

Use these variables to set all installation paths.

Add link and note about module to README.md .
2017-05-24 04:25:45 -07:00