This removes remaining dependencies on Windows in the FAudio code by
removing the device notification code and switching to portable
`condition_variable` for the buffer end notification event.
This moves all of the audio code in the wx frontend to the
`src/wx/audio` folder and simplifies many call sites by having one
generic API to enumerate audio devices and create the audio driver.
In addition, this fixes many corner cases in device enumerations and
moves handling of the default device to the respective audio backends,
rather than pushing it to the UI.
Finally, this changes the `Sound/AudioDevice` setting to use the
underlying device ID, rather than the user-facing name.
Pass `/fd certHash /td certHash` to signtool as they are required
arguments.
signtool comes with Visual Studio and now works and we don't need to
require osslsigncode anymore.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Corrected the current FAudio output code, FAudio api wasn't
a direct 1 for 1 code replacement. Adjusted the existing
code structure so that FAudioVoiceCallBack struct
was being properly called on.
Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
This fixes a number of issues with the current implementation. Namely,
some options were not properly saved and the audio driver was not
properly reloaded when some options were changed.
In addition, this moves most sound-related options to `g_owned_opts` and
simplifies many call sites.
Add -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing to
compile and link options for gcc/clang always.
Rename struct yy_buffer_state in src/sdl/expr-lex.cpp to struct
yy_buffer_state_sdl because it breaks when linking the SDL binary with
-Werror=odr.
Fix#1260
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Add a toggle for SDL GameController Mode in the game key configuration
dialog, default enabled.
On check or uncheck, change the option and reinitialize joysticks, not
using GameController mode if it is disabled.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Pass -Wno-deprecated-copy only for C++, gcc gives a warning for C.
Pass -Wno-unused-command-line-argument for clang only, gcc gives a
warning about it.
Add a failsafe for gcc/clang static link flags if libstdc++ or
libpthread is not available as a static library.
Move link command adjustment script invocations to src/wx, the target is
not yet defined in the toolchain.
Add -lws2_32 to the end of the link command for gcc on Windows because
of link order issues with those symbols.
Disable LTO for gcc on Windows, as it is broken.
Don't install extra-cmake-modules on MINGW32, that package is not
available there.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Bring back setting the MSYS variable under MSYS2, it's still being used
in a few places.
Link the SDL2::SDL2-static target for static builds.
Add -static-libgcc and -static-libstdc++ to the gcc/clang toolchain for
static builds.
Edit wxWidgets_LIBRARIES under MSYS2 to specify liblzma.a explicitly
because for some reason it's not being linked statically by default for
static builds.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
When using vcpkg as the toolchain, pass NO_DEFAULT_PATH to
find_package(wxWidgets ...) so that the default cmake
FindwxWidgets.cmake is not included.
Set wxWidgets_DIR to the
<vcpkg-root>/installed/<triplet>/share/wxwidgets vcpkg port directory
for the subsequent find_package() calls to find the port-installed
wxWidgetsConfig.cmake file.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* Bring the wx frontend more in-line with the rest of the codebase.
* Always default to Unicode APIs on Windows.
* Clean up all include guards and headers.
* Create multiple components library. These depend on the core code and
are used by multiple frontends.
* Clean up the filters declaration by moving them to a common header in
`components/filters/filters.h`.
* Clean up the include guards and include orders.
* Fix the modified paths in `src/debian/copyright` to match their new
location.
* Move src/apu/, src/gb/ and src/gba/ to src/core/.
* Clean up include guards and headers.
* Rename `BKPT_SUPPORT` to `VBAM_ENABLE_DEBUGGER` and remove the
`NO_DEBUGGER` define.
* Clean out all of the dependent headers.
* Modify generated version.h to improve the dependency chain and isolate
the generated file to its own sub-directory within the build
directory.
* Remove duplicate function definitions between the libretro and other
frontends by merging them into a common source file.
* Also move `systemMessage()` and message IDs definitions to core/base.
* Clean up and modernize many file utility methods.
* Clean up source set and public headers.
* Make the fex library an OBJECT library to speed up build.
* Clean up the only fex include to use the full path to the header.
* Use add_compile_definitions everywhere.
* Remove unused intermediate target.
* Add ASAN support for MSVC.
* Remove duplicate option definitions.
* Configure MinGW separately from the toolchain
* Move toolchain-specific options to their own files.
* Clean up and modernize the use of toolchain options.
* Use modern cmake LTO support.
* Remove dead cmake code and cmake functions available in upstream cmake.
* Update README.md to remove references to removed build options.
In preparation for including the finished FAudio support, link the cmake
FAudio target FAudio::FAudio when the feature is enabled.
Add pthreads to vcpkg deps and use the installed PThreads4W on Windows.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Use cmake find_program() to find powershell.exe on Windows because
invoking `powershell` or `powershell.exe` without a path sometimes fails
for some reason. Use the standard location on Windows 11 as a hint.
Make the `pwsh` executable REQUIRED when installing vcpkg packages
on non-Windows.
Use find_program() to find the zip executable before downloading it on
Windows vcpkg builds.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Don't convert wx-config and wxrc into UNIX commands on a Windows host,
as the paths may have spaces in them and this will break the invocation.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Update all URLs in the code and documentation to the new domain
visualboyadvance-m.org and also fix the date for the last release in the
CHANGELOG.md.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Because of reported framerate issues with the SDL sound driver, remove
it and make XAudio2 the default on Windows and OpenAL the default
everywhere else.
Rewrite the "sdl" value from users' configs to the new default.
Make OpenAL a mandatory dependency as well.
Fix#709
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
In SoundConfig.xrc and DisplayConfig.xrc use the 'option' property
to fully expand the contents.
In NetLink.xrc add a label at the top of the dialog explaining that Link
will likely not work over the internet or over LAN.
Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Check for musl libc in Patch.cpp and use fseeko()/ftello() in that case
instead of fseeko64()/ftello64() as well, as the 64 variants are glibc
extensions.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Useful for app stores like KDE's discover and gnome software
Also updated to current specifications of appstream
Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
Fix the Linux-specific date command in the cmake code, and skip the ABI
check for vcpkg, because it is failing for some reason on Linux+vcpkg.
The resulting executable works perfectly.
This should also help on mac, I will test this later.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
The GameArea was setting incorrect minimum size during initialization
due to the MainFrame not being entirely loaded, this caused the
MainFrame to not be resized properly on initialization. Resetting the
MainFrame minimum size after everything has been loaded fixes the issue.
This also changes MainFrame to ignore events sent before initialization
is complete, which should speed up startup a bit.
Fixes#1186
Previously, the status bar was always shown at startup, even if the
status bar had been previously disabled. This fixes the issue by hiding
the status bar when it is first set up, if needed.
Use the wxString-returning form of wxRegex.GetMatch() because the bool
form always returns true if the initial match succeeded, causing every
hat direction in the config to be interpreted as north, the first
condition in the if statement.
Fix#1192
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Start Network Link is not allowed while Local mode is selected, but
state change of Local mode was ignored until an option which triggers
EnableNetworkMenu() was selected.
Removed EnableNetworkMenu() from the Configuration option because it
doesn't change anything related to Link menu state.
Add references to frameworks being linked to `buildInputs` in
`default.nix`. Remove `-framework System` from `wxWidgets_LIBRARIES` in
the cmake code as it's not necessary and nix does it have it in
`darwin.apple_sdk.frameworks`.
TODO:
Debug build currently builds and runs. Release build builds but does not
run because of a problem with the dylib bundling.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
On initialization, if wxWidgets was compiled without EGL support, check
in environment variables if running under Wayland and if so tell GDK to
prefer using an X11 backend, causing the program to launch under
xwayland.
Fix#1028
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
In doMirroring() do nothing if the ROM size is greater than 32MB. This
fixes these ROMs automatically working without disabling mirroring in
settings.
Fix#1046
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
The NO_LINK build had bitrot and was no longer building. This fixes the
issue by properly disabling Link-related code, including unreachable
functions when the project is built with ENABLE_LINK=FALSE
Previously, MBC7 EEPROM was saved at address 0xa000 in memory, rather
than inside the `gbRam` data buffer. This was inconsistent with other
mappers, resulting in issues like the EEPROM data being cleared on
`gbReset`.
Fixes#1173
Since Wii and Wii U are both big-endian systems, we need to call in the Makefile for Libretro cores that these must use big endian code for be able to work, otherwise the emulation will just give a white screen.
Fix by Ploggy, many thanks to him.
Separate writing the version into the Info.plist on macOS into a
separate action from the online updates Sparkle framework into a
separate POST_BUILD action because we are not using Sparkle for macOS
builds right now due to codesigning issues.
Also sort tags by reverse tag name in the cmake git version extractor
because a tag was rewritten.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
CMAKE_CROSSCOMPILING is true when building arm64 on an x64 host, so
ignore this on MSVC.
Eventually we want to run osslsigncode through wine when cross compiling
for win32 on other platforms, or use the native signtool.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Check if the OpenGL context is valid on every operation, and if not
re-initialize it. Also rebind the textures every time the frame is
drawn.
Also rename the SetCurrent method to SetContext, which is clearer.
Fix#643Fix#767Fix#840Fix#843
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Make a bool SetCurrent() wrapper over checking the wxGL_IMPLICIT_CONTEXT
define and executing the appropriate behavior to set the OpenGL context.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Change the cmake code to install the translations gettext .mo files into
the .app bundle for non-release builds too.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
First launch would fail because wx does not create the configuration
directory by itself if it does not exist.
This also fixes an incorrect menu option.
The lz77 uncompresssion software BIOS implementation was exiting early
when uncompressing data, if the overall length was larger than
advertised in the function parameter. However, real GBA BIOS does read
further than the advertised length, so we do here too. This fixes
Advance Wars title screen.
This also adds a SoundDriverVSyncOn implementation, silencing an error
for some Shrek games, though they still cannot properly boot with an
emulated BIOS.
Fixes#789
* Removes wxAcceleratorEntryUnicode and assorted arrays in favor of a
new class, `config::Shortcuts`, which handles UserInput assignment to
commands and resolution at runtime. `config::Shortcuts` also handles the
INI user configuration in a backwards-compatible way. Runtime
resolution of UserInput to command is also now logarithmic rather than
linear.
* The same shortcut can no longer be assigned to 2 different commands,
which fixes#158.
* Moves the `AccelConfig` dialog to its own dedicated class.
This replaces all uses of wxJoyKeyCtrl with a new custom widget,
UserInputControl. Internally, this class keeps track of UserInputs
associated with the current control, allowing direct access to the
UserInputs, rather than going through string conversions.
Acceleration handling is simplified by going through UserInput -
converted to the key, mod, joy triplet for now - rather than handling
string comparisons.
The `wxAcceleratorTable` for the `GameArea` panel was initialized with an
array of `wxAcceleratorEntryUnicode`, while the API calls for an array
of `wxAcceleratorEntry`. This resulted in the array not being properly
interpreted by the `wxAcceleratorEntry`. This fixes the issue by using
`wxAcceleratorEntry` to instantiate the array.
These can be accessed via the global gbCartData object. In addition,
this cleans up gbMemory to remove dead code that was used as a
workaround for ROM hacks.
We rely on the rom size in the cartridge header as a proxy for the RAM
size. Only 3 cartridges exist that use MBC7, Korokoro Kirby / Kirby
Tilt'n'Rumble and Command Master. Both versions of Kirby use a 256 bytes
EEPROM while Command Master uses a 512 bytes EEPROM. There does not seem
to be any other way to reliably get the EEPROM size for MBC7 cartridges.
Some MBC7 cartridges use 512 bytes EEPROM rather than 256 bytes. For
compatibility with older versions, we keep saving and loading 256 bytes
of EEPROM for every MBC7 cartridge. TODOs have been left to figure out
how to identify the EEPROM capacity properly.
* Removes all of the per-mapper helper functions in favor of an
iovec-like structure that is set on ROM load and ROM patch.
* Changes the MBC7 RAM size to 256 bytes, which is what the cart
actually uses.
* Works around issues with homebrews by overriding some of the header
data. For instance, battery is disabled if a cart specifies a battery
but no RAM and no RTC.
Test: This was tested with every known RTC/RAM/Battery variations by
creating a battery file before these changes and checking that the
battery file is still loaded properly with these changes applied. The
reverse was also tested to ensure compatibility.
* Simplifies most of the GB save/load state code and changes many
of the global variable uses to go through gbCartData instead.
* Changes all battery reads to use gzFiles. This seems to have been an
oversight in an earlier refactor of the code.
* Removes some unused variables and stops exporting internal-only
functions in GB.cpp/gb.h.
Breaking change: Cartridges with no mapper, but a save battery should
now properly save and load changes. However, this type of cartridge has
not been used in any commercially released software for Game Boy so the
exact intended behavior is speculative.
Add MOVE_START/MOVE_END events to detect when the window is moved or
resized and pause sound on Windows to prevent the DirectSound driver
from looping.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Make some tweaks to the cmake files to support
CMAKE_BUILD_TYPE=RelWithDebInfo, release with debug information for MSVC
vcpkg builds.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* Moves most directory settings to g_owned_opts.
* Converts the DirectoriesConfig dialog to the new structure.
* Various includes clean-ups.
Breaking change: Loading a GB/GBC/GBA ROM when the ROM directory setting
is unset for that platform will now populate the per-platform ROM
directory setting.
Further testing showed some limitations with the current GB header
parsing. Many homebrew and some licensed cartridges do not follow the
expected format. In particular, the manufacturer code used in the "new
format" is not always used properly.
Some mapper flags seem to not actually exist in practice. These have
been documented as comments.
The header parsing code was creating string objects with '\0' bytes,
this is now properly sanitized.
The destination code flag was not being set properly. This has been
fixed.
This adds checks for every allocation failure in the core Game Boy
emulator. In addition, this replaces some magic values defined
constant expressions and removes an unused function.
This also removes asserts for failed allocations in GB.cpp, they now
report a failure to the caller.
Pause only sound on menu open on Windows, and resume on menu close if
emulator is not paused.
This is to avoid DirectSound looping on menu open.
Fix#788Fix#1077
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
On Linux, when not running under Wayland and the app was built with XSS
(X ScreenSaver) support, optionally suspend the X11 screensaver when a
ROM is loaded and not paused.
Add a "Suspend ScreenSaver" checkbox in UI Settings bound to an option
to enable this feature, visible only under X11.
Defaults to off, as there is already a call to suspend the screensaver
on joystick input, which may be sufficient for the user.
TODO: Add necessary support for other platforms.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This adds a new class, gbCartData to do all of the GB/GBC header parsing
in a single location.
Breaking change: ROMs advertising a 2 KiB RAM size now properly only
have 2 KiB allocated for RAM, whereas it used to be 8 KiB. This was
tested with the one aftermarket ROM making use of this RAM size
(Quartet), with no issue. Save files and save state files should still
be compatible since the RAM was saved with the correct 2 KiB size.
Some software (like the EU version of Digimon Racing) relies on the
SIOCNT register being properly updated when no cable is connected.
Otherwise, they risk getting stuck in a loop waiting for an update on
the SIOCNT register.
This changes all of the options handled by the GameBoyConfig dialog to
use the new Option type. This also fixes a number of small issues
related to palette handling and GB emulation:
* Modifying the custom GB palette no longer incorrectly applies to GBC
and SGB modes.
* Loading a GB save state (not GBC or SGB) properly applies the
user-defined palettte and not the one in the save state.
* The GBC core now accepts .gbc BIOS files.
Finally, this modifies and renames wxFarRadio to widgets::GroupCheckBox.
In addition GroupCheckBoxes can now be loaded and fully configured from
the XRC file rather than having to be manually configured on dialog
initialization.
This game cart may have a flashcontroller but no flashram onboard, the game automatically goes down the Flash Type path and hits a stackoverflow at cpuSaveGameFunc after cpuSramEnabled returns as false
I'm not sure of the specifics, but with this change it seems to avoid this condition.
I have tested a number of titles that create Sram, 512 and 1024Mbit flash and they all still seem to just fine.