Compare commits

...

151 Commits

Author SHA1 Message Date
Rafael Kitover
fd7003a35f build: lower Intel macOS req to 10.10 from 10.15
Convert the C++17 code in the bundled SFML code to C++14 to allow for
targeting macOS 10.10 (Yosemite) instead of 10.15 (Catalina.)

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-30 18:17:17 +00:00
Rafael Kitover
4cf6cccbaf build: bundle SFML 3.x sys/network in third_party
Remove the SFML external dependency, include the SFML 3.0.1 system and
network libraries in third_party and adjust the build code, tools and
documentation accordingly.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-24 16:34:42 +00:00
Rafael Kitover
9e724ea4b8 build: support building ARM64 binary for Mac
Make some adjustments to the Mac build scripts to support building an
ARM64 binary for Apple Silicon.

Also support cross-compiling for Intel on Apple Silicon.

Also prefer using Ninja for CMake ports.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-22 05:55:19 +00:00
Rafael Kitover
eb26ec2ef6 Enable Hide Status Bar in UI Settings for macOS
Enable Hide Status Bar in UI Settings for macOS, it was previously
missing because the whole UI Settings submenu was removed on macOS.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-22 05:29:51 +00:00
Zach Bacon
6a9eeeaece core.sh Switched to github source for nasm
Nasm.us is down currently and unable to pull the tarball
down from that source.

Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
2025-04-21 00:00:19 -04:00
Squall Leonhart
9f6285842d initialize sound_buffer_len_ to silence a warning. 2025-04-16 02:20:53 +10:00
Rafael Kitover
e5ad7b3403 build: find_package(nanosvg) w/ vcpkg
When using vcpkg wxWidgets, call `find_package(nanosvg)` so that
`NanoSVG::` link target is available.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-12 22:47:55 +00:00
Squall Leonhart
94752f8314 [FAudio]Correct the behavior of device_changed check
Fixes the behavior to take the timeout into account properly, fixing the throttled behavior so that it matches (or strives to) the configured value instead of being stuck at <90%
2025-04-13 03:58:40 +10:00
Rafael Kitover
3c32bad886 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-12 08:00:19 +00:00
Rafael Kitover
8936feaa71 build: add libtiff to Nix derivation
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-11 22:43:18 +00:00
Rafael Kitover
f93a32ab0b build: add libtiff to brews on macOS
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-11 21:52:08 +00:00
Rafael Kitover
3fa850c15d build: capitalize ARCH_NAME in CMake
Use capitalized `ARM` instead of `arm` for ARCH_NAME in
Architecture.cmake so that the Mac Apple Silicon zip releases are
suffixed `ARM64` not `arm64`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-07 01:43:00 -07:00
Rafael Kitover
364776b833 build: s/-Ofast/-O3 -ffast-math/
Use `-O3 -ffast-math` instead of `-Ofast`, which is deprecated by the
latest clang. In both our options and for libretro.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-07 01:28:45 -07:00
Rafael Kitover
2d439f7ba6 build: fix link error on macOS
Add `tiff zstd deflate` to link libs for macOS to fix a link error
caused by libzstd and libdeflate not being linked for libtiff which is
linked by wxWidgets.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-07 01:24:02 -07:00
Rafael Kitover
11a6068a03 build: update vcpkg install command to new form
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-06 12:21:47 -07:00
Rafael Kitover
6139428207 translations: remove dup Chinese translations
Remove zh.po, which is not on Transifex anymore and zh-Hans.po, which I
have removed from Transifex just now, leaving zh-CN.po, as suggested by
@wuweiran.

Fix #1435.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-02 13:45:14 +00:00
Rafael Kitover
5a5579d27f build: minor followup on SFML 3.x API change
Followup on 29e85e5d (build: update Link SFML usage to SFML 3.x APIs,
2025-04-01) to alias an optional.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-02 09:07:54 +00:00
Rafael Kitover
29e85e5d87 build: update Link SFML usage to SFML 3.x APIs
Make some changes for the SFML Network library for the 3.x APIs.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-04-01 23:34:58 +00:00
Fabrice de Gans
e228394656 [Input] Process key down event for some controls
In #1424, the app event handler was disabling all key down events,
preventing controls that depend on them to properly handle these. This
was done to work around an issue on macOS where unhandled keyboard
events would fire an audio alert.
Since this breaks text controls, these changes check for the currently
focused window and let the event propagate for text controls.

Fixes #1434
2025-04-01 18:57:26 +02:00
Rafael Kitover
d5ac2a853b Revert "Update Link SFML usage to SFML 3.x APIs"
This reverts commit e82ae7bb13.

Sorry, somehow I pushed to the wrong branch.
2025-03-29 19:40:59 +00:00
Rafael Kitover
e82ae7bb13 Update Link SFML usage to SFML 3.x APIs
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-29 18:54:53 +00:00
Rafael Kitover
20b82d8ab7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-29 04:00:24 +00:00
Rafael Kitover
8d26b4f49f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-25 23:00:22 +00:00
Fabrice de Gans
3fdc30f7d7 Mark wxEVT_KEY_DOWN as processed in wxvbamApp (#1424)
This prevents wxWidgets from triggering the alert sound on macOS.
There should be no side effect from this.

Fixes #1384
2025-03-22 16:24:14 -07:00
Rafael Kitover
57211ddc77 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-20 19:00:21 +00:00
Squall Leonhart
2de7efd9eb Reallocate GBA ROM to the the new size(#1422)
The GBA ROM was erroneously reallocated to the constant `ROM_SIZE`.

Closes #1421
2025-03-15 13:39:57 -07:00
Rafael Kitover
5b4559f4ee translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-07 13:00:21 +00:00
Rafael Kitover
6178526cd9 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-03-06 09:00:20 +00:00
Rafael Kitover
c8a1d8eb2e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-28 23:00:26 +00:00
Rafael Kitover
6e3883937b translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-28 22:00:21 +00:00
Rafael Kitover
8dd647914a translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-20 17:00:21 +00:00
Rafael Kitover
0dae126a29 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-20 16:00:22 +00:00
Rafael Kitover
5038cd7ba5 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-16 23:00:22 +00:00
Rafael Kitover
ddd8fca044 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-11 19:00:21 +00:00
Rafael Kitover
25c85a83d9 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-11 18:00:21 +00:00
Fabrice de Gans
32dd410954 [build] Disable link (#1411)
SFML 2 no longer compiles with a modern compiler and we are blocked on
SFML 3 being available in vcpkg to fix it. There is no easy way to
backport fixes to SFML 2 so disable link for the time being.
2025-02-08 15:13:10 -08:00
Fabrice de Gans
e4f17d33ce [Sound] Set volume on game startup (#1410)
On startup, the internal emulator sound volume is set to 100%. The user
value in the wx frontend is not used until the emulator volume slider is
modified, resulting in games starting with volume at 100% on startup.

This fixes #1407 by always setting the internal emulator sound volume on
game startup.
2025-02-08 12:57:12 -08:00
Rafael Kitover
2ab707c0ca build: update default.nix
Update default.nix to remove gcc from the macOS package set and add
clang/llvm/libcxx to the Linux package set.

Change 'epoxy' in the Linux package set to the new package name
'libepoxy'.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-02-02 09:42:05 +00:00
Rafael Kitover
4dba928765 build: update installdeps for OpenSUSE
Update `installdeps` for current OpenSUSE wxWidgets and FFmpeg packages.

Disable 32 bit cross builds in OpenSUSE because those packages are no
longer available.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-29 20:21:32 +00:00
Rafael Kitover
3d6550d161 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-25 18:00:22 +00:00
Rafael Kitover
3cf12f2594 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-15 15:00:25 +00:00
Rafael Kitover
de1ec01c78 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-13 18:00:26 +00:00
Rafael Kitover
295abb9cd0 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-13 15:00:26 +00:00
Rafael Kitover
8260b62482 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-13 13:00:22 +00:00
Rafael Kitover
d18c6f115f Use faster sqrt() for xBRZ for XP builds
Use the `sqrt()` introduced in 615e5863 (Add fast-inverse SSE1 sqrt()
from Quake 3 Arena, 2025-01-12) or the xBRZ filters for Windows XP 32
bit builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-12 15:50:29 +00:00
Squall Leonhart
d36f80b5e6 Add fast-inverse SSE1 sqrt() from Quake 3 Arena
Add the Quake 3 Arena fast-inverse `sqrt()` using SSE1 intrinsics to
third_party.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-12 15:50:02 +00:00
Rafael Kitover
44aa859e6d build: add cmake var and cpp macro for XP builds
Add the WINXP CMake variable and WINXP CPP macro for MinGW 32 bit
Windows XP builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-12 15:04:14 +00:00
Rafael Kitover
5a2d3a6f95 build: set arch to pentium3 not -mmx for XP builds
Set the gcc architecture to pentium3 not pentium-mmx for Windows XP 32
bit builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-12 10:04:07 +00:00
PunkPangolin
d6b939c428 Set developer id/component type in metainfo.xml
Add developer block to `metainfo.xml` with id 'visualboyadvance-m.org'.

Also set component type to 'desktop-application'.

This file is used to describe the application on Linux.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-09 20:07:45 +00:00
Rafael Kitover
8b8be7d4a8 Revert "Change domain to temporary"
This reverts commit 72364fd1a4.
2025-01-08 13:12:40 +00:00
Rafael Kitover
72364fd1a4 Change domain to temporary
Domain has expired, change links to temporary domain.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2025-01-08 13:09:49 +00:00
Rafael Kitover
c6da07feb3 build: link avrt for OpenAL on WIN32
For static builds for Windows, link `avrt`, a system library that is now
required by OpenAL.

Also remove our version of `FindOpenAL.cmake` in favor of the
system-provided version.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-12-16 13:47:48 +00:00
Rafael Kitover
94979eff97 build: initialize GTest submodule in CMake
Try to initialize the GTest Git submodule from the CMake code if it has
not been.

If that fails, turn off `BUILD_TESTING`.

We do not want to require recursive clones or initializing submodules
for users by default.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-12-16 13:09:02 +00:00
Rafael Kitover
e8494b56d1 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-12-13 05:08:59 +00:00
Fabrice de Gans
c85397518b [win32-deps] Update win32-deps (#1375) 2024-11-24 22:03:05 -08:00
Fabrice de Gans
cf2339822d [win32-deps] Use specific commit in submodule (#1374)
This will help make older builds reproducible.
2024-11-24 21:37:11 -08:00
Fabrice de Gans
dcb9ccca90 [gtest] Use googletest as a submodule (#1373)
Some Linux distributions use a hermetic build environment to build. This
resulted in issues with `FetchContent` attempting to download googletest
at configure time.
This fixes the issue by integrating googletest as a git submodule
instead of downloading it at configure time.
2024-11-24 12:39:10 -08:00
Fabrice de Gans
a8ec85d536 [GB] Add support for per-game overrides (#1370)
* [GB] Add support for per-game overrides

Alleyway is a buggy game that does not work properly when a Game Boy
Printer is connected. In order to work around this issue, this adds
upport for built-in per-software Game Boy overrides. In addition, this
renames various variables to make their meaning clearer.

* This only supports built-in overrides. External INI files are not
  supported.
* Only the Game Boy Printer option is supported, this only takes effect
  on game startup and the general configuration option is restored when
  the game is unloaded.
* As a result, it is possible to override the per-game override by
  manually setting the option while the game is running, this is working
  as intended.
* Future refactors of the option handling will manage overrides better.
* Switch `gbPrinterEnabled` default to off.

Fixes #1368
2024-11-24 12:15:26 -08:00
Rafael Kitover
611f3a3409 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-11-04 02:00:27 +00:00
Rafael Kitover
b6da6c490c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-11-04 01:00:23 +00:00
Fabrice de Gans
9d20ce9b59 [Input] Reset keyboard tracking on focus loss (#1357)
When pressing Alt+Tab, the "Alt" and "Tab" keys were considered in the
"pressed" state until the user pressed them again because the window is
no longer receiving keyboard events. This resulted in some shortcuts no
longer working, since "Alt" was always in the pressed state. This
changes the keyboard tracking to be reset when the application loses
focus, fixing the issue.

This change also adds tests for the keyboard tracking.
2024-10-08 18:22:17 -07:00
Squall Leonhart
709a322337 cherry pick d5d01a8b68 2024-10-07 00:26:31 +11:00
Rafael Kitover
cdfd37fc4e build: rename dependencies submodule -> win32-deps
Rename the Git submodule `dependencies` used for some dependent files
for Win32 builds to `win32-deps` and make the necessary adjustments to
the CMake code.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-10-04 20:05:52 +00:00
Rafael Kitover
4f8d0a8867 build: update harfbuzz for macOS builder
Update harfbuzz in the macOS builder from the ancient version to the
current release and switch it to using Meson.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-10-03 13:50:16 +00:00
Fabrice de Gans
b22e9fb709 Ignore illegal opcodes used by Wii U VC (#1351)
The Wii U VC emulator incorrectly allows for armv6 thumb instructions
(like LSRS). These cause an undefined instruction error on real hardware
but the Wii U VC emulator just ignores them. This change mimicks the Wii
U VC emulator behavior.
2024-09-29 23:13:11 -07:00
Rafael Kitover
4e2799b582 build: don't hardcode Windows certificate password
Use a file for the Windows code-signing certificate instead of
hardcoding it into the CMake code.

Update the developer manual with instructions on where to put the
Windows code-signing certificate and the file containing the password
for it.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-29 20:59:40 +00:00
Fabrice de Gans
7fa90531e6 Disable open menu tracking outside of Windows (#1350)
Tracking whether or not the menus are opened is necessary on Windows since menus stop
the main loop. This is not necessary on other platforms. In particular, on Mac, we do
not get a `wxEVT_MENU_CLOSE` event when opening a dialog from a shortcut, resulting in
the menu status tracking being incorrect.

Fixes #1348
2024-09-29 13:59:19 -07:00
Fabrice de Gans
e1c2ecc584 [dialogs] Display all controls in AccelConfig on Mac (#1349)
Calling `ExpandAll()` on the `wxTreeCtrl` would cause it to display outside of its
intended view, hiding other controls. Instead, this sets a minimum size for the tree
control, so the default window size is reasonable.

Fixes #1348
2024-09-28 10:38:28 -07:00
Rafael Kitover
4c450ab360 build: fix linking FAudio statically on MINGW
Link `FAudio.a` explicitly on MINGW toolchains, for some reason linking
`FAudio` with static preference no longer works.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-19 09:22:38 +00:00
Fabrice de Gans
d5e1a1f36b [GB] Properly set OPRI on startup
Previously, the OPRI register was always set to be in CGB mode when not
using the CGB BIOS, resulting in graphics corruption when running DMG
software in CGB mode without using the CGB BIOS. This fixes the issue by
properly setting bit 1 of the OPRI register as expected.

This was broken in #1119.
2024-09-17 18:52:35 -07:00
Rafael Kitover
821b9176bd build: do not use debug libs for RelWithDebInfo
Stop trying to use debug libs for `CMAKE_BUILD_TYPE=RelWithDebInfo`,
this also fixes the current link error with SFML.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-17 18:35:39 +00:00
Rafael Kitover
9031103c9a build: fix linking non-debug pcre for debug wx
Remove the cmake code that adds the pcre library because the wxWidgets
cmake code correctly includes it now, on both vcpkg and MSYS2.

Also fix up `wxWidgets_ROOT_DIR` and `wxWidgets_LIB_DIR` for debug
builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-15 19:53:27 +00:00
Rafael Kitover
557f897ead build: fix using host pkgconf for ARM64 cross bld
Set `VCPKG_HOST_TRIPLET` and `VCPKG_USE_HOST_TOOLS` when using an X64
host for an ARM64 cross build in order to use the host `pkgconf` and
possibly other tools.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-15 15:47:28 +00:00
Rafael Kitover
c8a4f66cf8 build: fix UpdateAppcast.cmake
Hardcode `git` instead of using `${GIT_EXECUTABLE}` which we are not
using anymore.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-15 12:50:00 +00:00
Zach Bacon
ddc93ec6e1 release v2.1.11
Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
2024-09-15 01:48:38 -04:00
Rafael Kitover
ab38ae8f24 doc: add keychain/notarization for Mac in dev man
Add information on unlocking the keychain for codesigning and setting up
credentials for notarization to the macOS binary section in the release
process section of the developer manual.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-14 08:38:02 +00:00
Rafael Kitover
d337688fa7 build: use ccache correctly in the macOS builder
Make compiler symlinks in the macOS builder instead of prepending
`ccache` to the compiler in the CC/CXX environment variables.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-14 07:53:34 +00:00
Rafael Kitover
3eea90afb6 build: set BUILD_TESTING=OFF when not git checkout
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-13 16:29:25 +00:00
Rafael Kitover
b3952d74a8 build: fix ENABLE_LIRC=ON
Fix the `ENABLE_LIRC` cmake option, pass an interface specifier to
`target_compile_definitions()`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-13 15:29:16 +00:00
Fabrice de Gans
be09125d52 Use relative paths for installation
The CMake documentation [1] advises against using `CMAKE_INSTALL_FULL_*`
in `install()` commands.

[1] https://cmake.org/cmake/help/v3.30/module/GNUInstallDirs.html#result-variables
2024-09-13 01:05:38 +00:00
Rafael Kitover
f264e7f807 Fix Help -> Translations URL
Fix the URL a browser is launched with when the `Help -> Translations`
menu item is selected to point to the project page on Transifex.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-12 17:35:40 +00:00
Rafael Kitover
fe0791762a build: update Windows dependencies submodule
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-12 14:17:16 +00:00
Fabrice de Gans
61f427dec1 Write shortcuts in the proper section (#1335)
Shortcuts were mistakenly written in `Keyboard/Keyboard` rather than in
the `Keyboard` section.
In addition, this properly fixes toggling checkable menu item options
via a shortcut.

Fixes #1334
2024-09-11 22:48:06 -07:00
Rafael Kitover
d619ee2bb1 build: fix installing GoogleTest
Add the `EXCLUDE_FROM_ALL` keyword to the `FetchContent_Declare` call
for GoogleTest, so that gtest/gmock are not installed with the project.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 14:43:34 +00:00
Rafael Kitover
7128e6dd08 build: update wxWidgets for macOS builder to 3.2.6
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 12:40:27 +00:00
Rafael Kitover
0decffea8d build: update macOS builder dists
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 11:42:26 +00:00
Rafael Kitover
9b60e17746 build: default to ENABLE_FFMPEG=OFF for MinGW32
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 11:20:02 +00:00
Rafael Kitover
26207038c9 Update WinSparkle to 0.8.1 and add ARM64
Update the included WinSparkle dll to 0.8.1 and add support for using
the ARM64 WinSparkle dll as well.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 11:07:19 +00:00
Rafael Kitover
90867bc802 doc: update developer manual release steps
Update the release steps in the developer manual to mention the
requirement for a GnuPG key, emphasize the editing the changelog step
and add instructions for putting `signtool.exe` in the `PATH` for the 32
bit Windows binary.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 10:10:13 +00:00
Rafael Kitover
7f49cd33ad build: rm FAudio from installdeps MINGW32 target
Do not try to install FAudio for the MINGW32 32 bit Windows MSYS2 target
in `installdeps`. We do not use it for the 32 bit build and there is no
package for it for MINGW32.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 09:23:27 +00:00
Rafael Kitover
d8342d3d67 doc: add ENABLE_FAUDIO to CMake opts in README.md
Describe `ENABLE_FAUDIO` in the table of CMake options in `README.md`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 08:59:26 +00:00
Rafael Kitover
12e840a8fa Remove non-user-facing changes from CHANGELOG.md
Remove non-user-facing changes from `CHANGELOG.md` for 2.1.10.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 08:52:12 +00:00
Zach Bacon
6ca609ac7e release v2.1.10
Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
2024-09-08 22:55:37 -04:00
Fabrice de Gans
2b8f9f71ff Copy string options rather than referencing them
This can lead to dandling references, though this is very unlikely. This
commit also removes a useless check.
2024-09-09 02:29:11 +00:00
Fabrice de Gans
e76cef79d2 Remove cast for UTF-16 -> UTF-8 conversion
Add convenience functions to call `config::utf16_to_utf8()` without a
cast.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-09 02:29:11 +00:00
Fabrice de Gans
7f06428df8 Disable dialog position save/restore on wxGTK (#1331)
This is currently broken on Wayland, resulting in dialogs showing up in
random locations.
2024-09-08 16:56:30 -07:00
Rafael Kitover
e4a9340409 Update README.md and Developer Manual
Update README.md and remove outdated information.

Update the Developer Manual and describe the current release process.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-08 05:42:34 +00:00
Rafael Kitover
5d7023a5d6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-07 18:00:22 +00:00
Rafael Kitover
3bd7c918cc build: fix cmake -DTAG_RELEASE functionality
Update the cmake -DTAG_RELEASE script to work with recent cmake changes.

Change it to not automatically make the release commit and tag, instead
specifying in the instructions that the person making the release must
edit the CHANGELOG.md and then run the commands, given in the
instructions, to make the release commit and tag.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-07 06:30:14 +00:00
Rafael Kitover
67e4944cdb translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-01 10:00:23 +00:00
Rafael Kitover
df4ff16e2c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-09-01 09:00:24 +00:00
Rafael Kitover
d4805065b3 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-31 14:00:23 +00:00
Rafael Kitover
e39b1f2c53 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-28 01:00:24 +00:00
Rafael Kitover
73b65a6553 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-28 00:00:23 +00:00
Rafael Kitover
9e556e6a56 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-21 14:00:34 +00:00
Rafael Kitover
11e73f2c61 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-21 13:00:24 +00:00
Rafael Kitover
e97b0448b7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-20 17:00:22 +00:00
Fabrice de Gans
aa6ed14b2a [FAudio] Always convert UTF-16 names (#1328)
On Windows, wchar_t is 16 bits and represents UTF-16 code units.
However, on other platforms, wchar_t is typically implemented as 32 bits
to represent UTF-32 code units. In order to work around this problem, we
always convert the string we get from FAudio, which is represented as
UTF-16 code units, into UTF-8 and let wxString handle the conversion to
its native type internally.
2024-08-17 21:02:01 -07:00
Rafael Kitover
2ce20c4f59 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-08-16 06:00:25 +00:00
Fabrice de Gans
e4ef4aa625 Propagate key events (#1323)
Previously, `wxEVT_KEY_DOWN` and `wxEVT_KEY_UP` were transformed into
`VBAM_EVT_USER_INPUT` and marked as processed early. This broke a number
of controls that rely on the traditional widgets events.

To fix this, we now filter the `wxEVT_KEY_*` and `wxEVT_CHAR` events in
the only widget we use that cares about them, `UserInputCtrl` instead of
filtering them at the application level.
2024-07-28 15:19:19 -07:00
Rafael Kitover
cf5cb40cb9 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-26 09:00:24 +00:00
Rafael Kitover
c450d14311 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-26 08:00:24 +00:00
Rafael Kitover
41572be3f2 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-24 11:00:23 +00:00
Rafael Kitover
4f8da1c574 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-24 09:00:24 +00:00
Rafael Kitover
32091669d4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-23 12:00:29 +00:00
Rafael Kitover
abd72a5b2e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-23 02:00:23 +00:00
Rafael Kitover
7e6349b19f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-22 13:00:22 +00:00
Rafael Kitover
0782be749e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-22 12:00:24 +00:00
Rafael Kitover
a7b545ab1a translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-15 03:00:22 +00:00
Rafael Kitover
1a564f900c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-13 10:00:25 +00:00
Rafael Kitover
3d4e03f85f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-08 12:00:23 +00:00
Rafael Kitover
fc17209ac7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-06 05:00:23 +00:00
Rafael Kitover
38877ef209 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 21:00:24 +00:00
Rafael Kitover
8691a15be8 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 20:00:32 +00:00
Rafael Kitover
961fd0304c translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 20:00:15 +00:00
Rafael Kitover
e2cf6ecba6 Add option to mute sound during speedup
Add core option to mute sound during speedup, implemented in the gba
core. Link the option to the SDL port as well.

Add the new Mute Sound option as a checkbox to the xrc for the
Speedup/Turbo dialog and improve the dialog appearance.

Fix the max values for the options speedup_throttle and
speedup_frame_skip.

Add base class for numeric OptionProxy types implementing the +=, -=
operators, increment/decrement operators and operator T(). Add tests for
these operators on numeric types.

Move Speedup/Turbo dialog code from guiinit.cpp to a dialog class and
rewrite it using validators.

Remove the "GL VIEWPORT" debug prints from panel.cpp.

Fix #865

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-07-05 12:14:58 -07:00
Avindra Goolcharan
7a0826a60c Migrate vba-m.com links in .github folder 2024-06-21 18:02:38 -04:00
Rafael Kitover
d516683a77 build: fix for wx using GTK2
Use the __WXGTK3__ macro to check for GTK3 when setting the gdk backend
to X11 when Wayland EGL is not available, GTK2 does not have this
function and always uses X11 anyway.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-06-14 11:10:00 +00:00
Rafael Kitover
834c7de86c build: update macOS builder dists
Update sdl2, faudio, wxWidgets and ffmpeg to the latest versions for the
macOS builder.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-06-06 05:32:51 +00:00
Fabrice de Gans
4f1a5dd726 [Test] Add tests for widgets code
This creates a vbam-wx-widgets target for the custom widgets code and
adds tests for them.
2024-05-29 19:30:35 -07:00
Rafael Kitover
5766b9b9c7 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-27 10:00:25 +00:00
Rafael Kitover
5d8426d317 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-27 09:00:26 +00:00
Rafael Kitover
63ec3528f1 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-26 07:00:24 +00:00
Fabrice de Gans
f646c3848c [Test] Change assert to custom CHECK macros
This changes the way we handle asserts to use a set of custom macros.
This greatly speeds up crashing, especially on Windows, and provides
assertions in release mode too.
2024-05-21 18:47:50 +00:00
Fabrice de Gans
09433875bc [CI] Remove workaround for MSVC CI
Upstream GitHub actions now uses a single toolchain version.
Fixes #1297
2024-05-19 16:14:22 -07:00
Fabrice de Gans
05c09ff506 [Build] Add devkitpro-based libretro targets to CI 2024-05-10 13:36:05 -07:00
Rafael Kitover
7f78fbb3c5 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 03:00:24 +00:00
Rafael Kitover
261e26f488 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 02:00:25 +00:00
Rafael Kitover
ed820708af translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-10 01:00:27 +00:00
Fabrice de Gans
5b8b6a0b47 [Test] Add tests for the EmulatedGamepad class 2024-05-09 17:48:48 -07:00
Fabrice de Gans
8809ce26b3 [Test] Add tests for the Bindings class
In addition to fixing a couple of minor bugs, this also creates some
utility functions to access the cmdtab data.

Finally, this disables tests on MSYS2 as they can be flaky.
2024-05-09 13:15:16 -07:00
Fabrice de Gans
a48625855b [Build] Share wx-related targets configuration
Breaking the main wx target down to multiple libraries had the side
effect that many build options were not properly applied to libraries.
This fixes the issue by having a common configuration function in CMake
to share most of the configuration between all of the wx-related
targets.
2024-05-09 12:28:05 -07:00
Rafael Kitover
55c1477d69 build: disable FAudio for 32 bit Windows builds
Disable FAudio for 32 bit Windows builds because it uses libraries that
Windows XP does not have.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 02:34:25 +00:00
Rafael Kitover
2d7a1ea25b build: fix faudio linkage regression on MSVC+vcpkg
Followup on 244149c0 (build: fix faudio static linkage, 2024-05-09)
which broke linking faudio on MSVC+vcpkg, go back to using the
FAudio::FAudio cmake target for MSVC.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 01:38:44 +00:00
Rafael Kitover
244149c00e build: fix faudio static linkage
Use "faudio" and dependent dlls on Windows instead of the FAudio::FAudio
cmake target, because the cmake target always links the faudio dll.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-09 01:25:05 +00:00
Fabrice de Gans
c0bcf3bfdf [Test] Add tests for many config classes
This also fixes a coupld of minor issues that were found while adding
tests.
2024-05-08 13:08:07 -07:00
Fabrice de Gans
13756bcbf9 [Test] Replace doctest with googletest
* Convert the only existing test (strutils) to googletest.
* Create a test target for vbam-wx-config.
* Add necessary fakes for the test binary.
* Add tests to CI.
2024-05-08 13:00:56 -07:00
Rafael Kitover
fc82e06270 build: do not build SDL bin on Windows or macOS
Stop enabling the SDL binary by default on Windows or macOS because it
usually only of interest to Linux users.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-08 12:53:52 +00:00
Rafael Kitover
df89beb256 build: disable gpg signatures by default
Add the GPG_SIGNATURES cmake option to control creating gpg clearsign
signatures for the translations and exe zips for UPSTREAM_RELEASE,
defaulting to OFF.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-07 02:59:17 +00:00
Rafael Kitover
82eda48e8f translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-06 06:00:30 +00:00
Rafael Kitover
b47787b317 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-05-06 06:00:12 +00:00
261 changed files with 54180 additions and 44266 deletions

View File

@@ -11,7 +11,7 @@ body:
- type: markdown
attributes:
value: |
Please try the nightly build from: https://nightly.vba-m.com and factory resetting the emulator from the Help menu.
Please try the nightly build from: https://nightly.visualboyadvance-m.org and factory resetting the emulator from the Help menu.
On Linux build master from source or use the edge snap.
And last but not least, search for existing reports via the filters bar on the issues page.
- type: markdown

View File

@@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: VBA-M Forum
url: https://board.vba-m.com/
url: https://board.visualboyadvance-m.org/
about: For general questions and support please join our forum or our
- name: VBA-M IRC Channel
url: https://web.libera.chat/#vba-m

View File

@@ -14,7 +14,7 @@ body:
- type: markdown
attributes:
value: |
Please try a nightly build from: https://nightly.vba-m.com to see if your idea has already been implemented.
Please try a nightly build from: https://nightly.visualboyadvance-m.org to see if your idea has already been implemented.
On Linux build master from source or use the edge snap.
And last but not least, search for existing requests via the filters bar on the issues page.
- type: textarea

33
.github/workflows/devkitpro-build.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Libretro Devkitpro
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
target_name: [ngc, wii, wiiu, switch]
build_type: [release, debug]
include:
- libretro_build: 'DEBUG=0'
build_type: release
- libretro_build: 'DEBUG=1'
build_type: debug
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: ngc
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: wii
- devkit_container: 'devkitpro/devkitppc:latest'
target_name: wiiu
- devkit_container: 'devkitpro/devkita64:latest'
target_name: switch
runs-on: ubuntu-latest
container: ${{ matrix.devkit_container }}
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
submodules: recursive
# Libretro build
- name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }} platform=${{ matrix.target_name }}

View File

@@ -1,4 +1,4 @@
name: macOS Latest Build
name: macOS Latest
on: [push, pull_request]
jobs:
@@ -55,3 +55,9 @@ jobs:
name: Build libretro core
run: >-
nix-shell --command 'make -C src/libretro ${{ matrix.libretro_build }}'
# Run tests
- if: matrix.build_options == 'default'
name: Run tests
run: >-
nix-shell --command 'cd build && ctest -j --output-on-failure'

View File

@@ -1,4 +1,4 @@
name: MSYS2 Build
name: MSYS2
on: [push, pull_request]
jobs:

View File

@@ -1,4 +1,4 @@
name: Ubuntu Latest Build
name: Ubuntu Latest
on: [push, pull_request]
jobs:
@@ -45,6 +45,9 @@ jobs:
run: >-
bash installdeps; if [ "${{ matrix.build_compiler }}" = clang ]; then sudo apt -y install clang; fi
- name: Install xvfb
run: sudo apt -y install xvfb
# CMake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
@@ -58,6 +61,11 @@ jobs:
run: sudo ninja -C build install
# Libretro build
- name: Build libretro core
if: matrix.build_options == 'libretro'
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }}
# Run tests
- if: matrix.build_options == 'default'
name: Run tests
run: cd build && xvfb-run ctest -j --output-on-failure

View File

@@ -1,4 +1,4 @@
name: Visual Studio Build
name: Visual Studio
on: [push, pull_request]
jobs:
@@ -37,54 +37,6 @@ jobs:
msvc_arch: amd64_arm64
runs-on: windows-latest
steps:
# TODO: Remove these 2 steps after May 13, 2024.
# See https://github.com/actions/runner-images/issues/9701 for details.
- name: Delete components
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$componentsToRemove= @(
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM64"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ARM64.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.x86.x64"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.x86.x64.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM64"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.ATL.ARM64.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM.Spectre"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM64"
"Microsoft.VisualStudio.Component.VC.14.38.17.8.MFC.ARM64.Spectre"
)
[string]$workloadArgs = $componentsToRemove | ForEach-Object {" --remove " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
# should be run twice
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
- name: Install components
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$componentsToAdd= @(
"Microsoft.VisualStudio.Component.VC.14.39.17.9.ARM64"
"Microsoft.VisualStudio.Component.VC.14.39.17.9.ARM64.Spectre"
"Microsoft.VisualStudio.Component.VC.14.39.17.9.x86.x64"
"Microsoft.VisualStudio.Component.VC.14.39.17.9.x86.x64.Spectre"
)
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
# should be run twice
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
- name: Checkout the code
uses: actions/checkout@v4
with:
@@ -101,3 +53,8 @@ jobs:
- name: Build
run: cmake --build build
# Run tests
- if: matrix.build_options == 'default' && matrix.msvc_arch != 'amd64_arm64'
name: Run tests
run: cd build && ctest -j --output-on-failure

10
.gitmodules vendored
View File

@@ -1,4 +1,6 @@
[submodule "dependencies"]
path = dependencies
url = https://github.com/visualboyadvance-m/dependencies.git
branch = master
[submodule "win32-deps"]
path = win32-deps
url = https://github.com/visualboyadvance-m/win32-deps.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git

View File

@@ -4,6 +4,68 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [2.1.11] - 2024-09-15
==========================
* 3eea90af - build: set BUILD_TESTING=OFF when not git checkout [rkitover]
* b3952d74 - build: fix ENABLE_LIRC=ON [rkitover]
* f264e7f8 - Fix Help -> Translations URL [rkitover]
* 61f427de - Write shortcuts in the proper section (#1335) [Steelskin]
* d619ee2b - build: fix installing GoogleTest [rkitover]
* 26207038 - Update WinSparkle to 0.8.1 and add ARM64 [rkitover]
## [2.1.10] - 2024-09-08
==========================
* 7f06428d - Disable dialog position save/restore on wxGTK (#1331) [Steelskin]
* e4ef4aa6 - Propagate key events (#1323) [Steelskin]
* e2cf6ecb - Add option to mute sound during speedup [rkitover]
* d516683a - build: fix for wx using GTK2 [rkitover]
* 834c7de8 - build: update macOS builder dists [rkitover]
* fc82e062 - build: do not build SDL bin on Windows or macOS [rkitover]
* d543784a - [UserInput] Filter key events globally [steelskin]
* 902c6c8e - [UserInput] Only process shortcut commands once [steelskin]
* b7765092 - [bindings] Set default shortcut for recent file 3 [steelskin]
* cc65ef28 - doc: add system requirements to README.md [danialhorton]
* 32627f6b - [Dialogs] Save and restore dialog positions [steelskin]
* 41952d06 - build: update macOS linker tool to 1.5 [rkitover]
* 0c39a5ba - build: override FindGettext to not update po files [rkitover]
* 1b77d659 - build: update macOS build to ffmpeg 7.0 [rkitover]
* 8d08223d - build: fix compatibility with older ffmpeg [rkitover]
* af6028a9 - build: fix build for nix on macOS [rkitover]
* b52edf52 - build: fix building on macOS with Homebrew [rkitover]
* 6766b9ca - build: fix ffmpeg 7.x compat [rkitover]
* 795f25bb - build: fix nix deps for OpenGL [rkitover]
* 647be137 - gba: set cpsr=spsr when switching to FIQ mode [40356555+Aikku93]
* 8abe3e79 - build: remove -lgcc from static link flags [rkitover]
* f4835674 - [Audio] Rework audio devices enumeration [steelskin]
* 775a571f - build: fix detecting Visual Studio default vcpkg [rkitover]
* 64abd3e8 - [Audio] Remove manual memory allocations [steelskin]
* 047ad277 - [Dialogs] Prevent viewers from causing a crash [steelskin]
* 045c98d8 - build: only use -Werror=lto-type-mismatch on gcc [rkitover]
* 3518dc6a - build: fix LTO on Linux [rkitover]
* cc9a03ce - Add toggle: SDL GameController mode for joysticks [rkitover]
* 8576733c - [Build] Remove lingering references to OpenAl [steelskin]
* 05561922 - build: fix MSYS2 check [rkitover]
* d9432ebb - build: fix build on MINGW{64,32}/UCRT64 on MSYS2 [rkitover]
* f57cad67 - build: fix static linking on MSYS2 CLANG64 [rkitover]
* 23e15734 - build: set wxWidgets_DIR with vcpkg [rkitover]
* 98b51910 - [Build] Remove ENABLE_NLS, fix TRANSLATIONS_ONLY [steelskin]
* a565cea8 - [Build] Remove the OpenGL check [steelskin]
* f96e42fe - build: cmake refactor and improvements [Steelskin]
* 07e49025 - Fix most remaining release warnings (#1243) [Steelskin]
* 18b97b43 - Fix various build warnings (#1242) [Steelskin]
* 13a16eb7 - Fix various warnings in filters and headers (#1241) [Steelskin]
* f46da1c5 - build: remove our version of FindSDL2.cmake [rkitover]
* 404e9a1a - build: add clang to ./installdeps for MSYS2 [rkitover]
* 613bd403 - Make menu more reasonably organized (#1230) [wwrustc]
* 215e3c5a - build: use find_program() to find powershell [rkitover]
* e5aa685f - build: don't use wx utils as UNIX cmds on Windows [rkitover]
* 9e4c8e17 - build: fix gentoo dependency namespaces [68k]
* 5f853b99 - Update metainfo.xml to new standards [jhonny.oliveira]
* e7d135db - Update links to new domain visualboyadvance-m.org [rkitover]
* 60fc096f - build: add libglu-devel for solus in installdeps [rkitover]
## [2.1.9] - 2024-02-03
=======================
* 84b0a3e3 - Remove SDL sound driver [rkitover]

View File

@@ -5,6 +5,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
if(WIN32)
include(RemoveStrawberryPerlFromPATH)
find_program(POWERSHELL
NAMES powershell.exe pwsh.exe
HINTS "/Windows/System32/WindowsPowerShell/v1.0"
REQUIRED)
else()
find_program(POWERSHELL pwsh)
endif()
if(UPDATE_APPCAST)
@@ -18,20 +25,10 @@ endif()
set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext wxwidgets)
set(VCPKG_DEPS_OPTIONAL
sfml ENABLE_LINK
ffmpeg ENABLE_FFMPEG
faudio ENABLE_FAUDIO
)
if(WIN32)
find_program(POWERSHELL
NAMES powershell.exe pwsh.exe
HINTS "/Windows/System32/WindowsPowerShell/v1.0"
REQUIRED)
else()
find_program(POWERSHELL pwsh)
endif()
include(Set-Toolchain-vcpkg)
# Use ccache if available and not already enabled on the command line.
@@ -54,7 +51,7 @@ if(GIT_FOUND AND WIN32)
# Win32 deps submodule
set(SUBMODULE_MANUAL_UPDATE FALSE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND NOT EXISTS "${CMAKE_SOURCE_DIR}/win32-deps/mingw-xaudio/include")
set(SUBMODULE_MANUAL_UPDATE TRUE)
execute_process(
COMMAND "${GIT_EXECUTABLE}" submodule update --init --remote --recursive
@@ -63,7 +60,7 @@ if(GIT_FOUND AND WIN32)
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/win32-deps/mingw-xaudio/include")
if(NOT (SUBMODULE_MANUAL_UPDATE AND SUBMODULE_UPDATE_STATUS EQUAL 0))
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
endif()
@@ -77,6 +74,39 @@ set(CMAKE_C_STANDARD_REQUIRED True)
project(VBA-M C CXX)
include(CTest)
include(FetchContent)
include(GNUInstallDirs)
include(Architecture)
include(Options)
include(Toolchain)
include(Dependencies)
# Disable tests when not in a git checkout.
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(BUILD_TESTING OFF)
endif()
# Configure gtest
if(BUILD_TESTING)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
if(NOT EXISTS third_party/googletest/CMakeLists.txt)
execute_process(
COMMAND git submodule update --init --recursive -- third_party/googletest
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()
if(EXISTS third_party/googletest/CMakeLists.txt)
add_subdirectory(./third_party/googletest)
include(GoogleTest)
else()
set(BUILD_TESTING OFF)
endif()
endif()
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
endif()
@@ -87,27 +117,11 @@ elseif(NOT CMAKE_BUILD_TYPE MATCHES "^(Release|Debug|RelWithDebInfo|MinSizeRel)$
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}', must be one of: 'Release', 'Debug', 'RelWithDebInfo' or 'MinSizeRel'")
endif()
# Link debug libs for RelWithDebInfo
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug")
endif()
set(MSYS OFF)
if(NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
include(CTest)
if(BUILD_TESTING)
enable_testing()
endif()
include(GNUInstallDirs)
include(Options)
include(Architecture)
include(Toolchain)
include(Dependencies)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GitTagVersion)
git_version(VBAM_VERSION VBAM_REVISION VBAM_VERSION_RELEASE)
@@ -168,8 +182,18 @@ endif()
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
if(NOT TRANSLATIONS_ONLY)
add_subdirectory(third_party/include/nonstd)
include_directories(third_party/include/nonstd)
include_directories(third_party/include/ghc)
add_subdirectory(third_party/include/stb)
if(ENABLE_LINK)
include_directories(third_party/sfml/include)
add_subdirectory(third_party/sfml/src/SFML/System EXCLUDE_FROM_ALL)
add_subdirectory(third_party/sfml/src/SFML/Network EXCLUDE_FROM_ALL)
set(SFML_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/third_party/sfml/include)
set(SFML_LIBRARIES sfml-system sfml-network)
endif()
add_subdirectory(src/core)
add_subdirectory(src/components)
add_subdirectory(src/sdl)
@@ -183,5 +207,5 @@ set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0-Git-${COMMITHASH}")
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/dependencies")
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/win32-deps")
include(CPack)

View File

@@ -9,17 +9,15 @@
- [Commit Message](#commit-message)
- [Collaboration on a Branch](#collaboration-on-a-branch)
- [Commits from Maintainers](#commits-from-maintainers)
- [Strings, Character Sets and Translations](#strings-character-sets-and-translations)
- [Pulling Updated Translations](#pulling-updated-translations)
- [Translations Message Catalog](#translations-message-catalog)
- [Interaction with non-wxWidgets Code](#interaction-with-non-wxwidgets-code)
- [Windows Native Development Environment Setup](#windows-native-development-environment-setup)
- [Miscellaneous](#miscellaneous)
- [Debug Messages](#debug-messages)
- [Release Process](#release-process)
- [Environment](#environment)
- [Certificates](#certificates)
- [Release Commit and Tag](#release-commit-and-tag)
- [64-bit Windows Binary](#64-bit-windows-binary)
- [32-bit Windows Binary](#32-bit-windows-binary)
- [64-bit Mac Binary](#64-bit-mac-binary)
- [ARM64 Windows Binary](#arm64-windows-binary)
- [macOS Binary](#macos-binary)
- [Final steps](#final-steps)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -53,11 +51,12 @@ Follow the following steps to process newly submitted issues:
- An issue is resolved by closing it in github. A commit that fixes the issue
should have the following line near the end of the body of the commit message:
```
- Fix #999.
Fix #999.
```
This will automatically close the issue and assign the closing commit in the
github metadata when it is merged to master. The issue can be reopened if
needed.
- A commit that is work towards resolving an issue, should have the issue number
preceded by a pound sign either at the end of a commit message title, if it is
of primary relevance to the issue, or the body otherwise.
@@ -70,7 +69,7 @@ Follow these guidelines always:
https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
the description of your work should be in the **commit message NOT the pull
, the description of your work should be in the **commit message NOT the pull
request description**.
The title line must be no more than 50 characters and the description must be
@@ -95,16 +94,21 @@ other projects, fewer is better.
The commit title line should be prefixed with an area, unless it involves the
wxWidgets GUI app, in which case it should **NOT** have a prefix.
If the commit is a user-facing functionality change or enhancement, the title
line of the commit must be a non-technical description of this change. For
example "Mute on speedup" because this will go into the changelog.
The text after the area prefix should not be capitalized.
Please use one of these area prefixes otherwise:
Please use one of these area prefixes for non-main-GUI-app commits:
- doc: documentation, README.md etc.
- build: cmake, installdeps, preprocessor compatibility defines, etc.
- gb-core: the GameBoy emulator core
- gba-core: the GameBoy Advance emulator core
- build: cmake, installdeps, preprocessor compatibility defines, compatibility
headers, etc.
- gb: the GameBoy emulator core
- gba: the GameBoy Advance emulator core
- libretro: the libretro core glue and build
- sdl-app: anything for the SDL app
- sdl: anything for the SDL port
- translations: anything related to translations
. Add other areas here if needed.
@@ -138,137 +142,79 @@ things in mind:
better to edit the history than to add more commits. Never add commits fixing
previous commits, only improving or adding to them.
- To update when someone else (very rudely you might say) did a `push -f`, `pull
--rebase` will **USUALLY** work. Verify the log, and if necessary do this
instead:
- To update when someone else updated the branch with a `push -f`
```bash
git status # should be clean, with your work having been already pushed
git fetch --all --prune
git reset --hard origin/<branch-name>
```
.
While actively working on a branch, keep it rebased on top of master.
- While actively working on a branch, keep it rebased on top of master.
#### Commits from Maintainers
Maintainers have the power to commit directly to master. This power must be
used responsibly, something I fail to do myself often, and will try to improve
upon.
Maintainers and project members have the power to commit directly to master.
This power must be used responsibly.
Make your most earnest attempt to follow these general guidelines to keep our
Make your best attempt to follow these general guidelines to keep our
history clean:
- Things that are a straight fix or improvement that does not require discussion
- Things that are a minor fix or improvement that does not require discussion
can be committed directly, keeping the following guidelines in mind.
- Bigger new features, code refactors and changes in architecture should go
through the PR process.
- Push code changes to a branch first, so they can run through the CI.
Differences in what different compilers allow is a problem that comes up
**VERY** frequently. As well as incompatibilities between different
configurations for both the C++ code and any supporting code.
- Push code changes to a branch first, so they can run through the CI. When you
open the commit in GitHub there is a little icon in the upper left corner that
shows the CI status for this commit. Differences in what different compilers
allow is a problem that comes up **VERY** frequently. As well as
incompatibilities between different configurations for both the C++ code and
any supporting code.
### Miscellaneous
### Strings, Character Sets and Translations
#### Debug Messages
#### Pulling Updated Translations
We have an override for `wxLogDebug()` to make it work even in non-debug builds
of wx and on windows, even in mintty.
Once in a while it is necessary to pull new and updated translations from
transifex.
For this you need the transifex client, available for Windows as well from
chocolatey as `transifex-client`.
To pull translations run:
```bash
tx pull -af
```
then check `git status` and if any message catalogs were updated, commit the
result as:
```bash
git commit -a --signoff -S -m'Transifex pull.'
git push
```
#### Translations Message Catalog
Strings that need to be translated by our wonderful translators on transifex
(thank you guys very much) need to be enclosed in `_("...")`, for example:
It works like `printf()`, e.g.:
```cpp
wxLogError(_("error: something very wrong"));
int foo = 42;
wxLogDebug(wxT("the value of foo = %d"), foo);
```
The next time you run cmake after adding a string to be translated, the `.pot`
message catalog source will be regenerated, and you will see a loud message
telling you to push to transifex.
Strings in the XRC XML GUI definition files are automatically added to the
message catalog as well.
If you are working on a branch or a PR, don't push to transifex until it has
been merged to master.
Once it is, push it with:
```bash
tx push -s
```
#### Interaction with non-wxWidgets Code
Use our `UTF8(...)` function to force any `wxString` to UTF-8 for use by other
libraries, screen output or OS APIs. For example:
From the core etc. the usual:
```cpp
fprintf(STDERR, "Error: %s\n", UTF8(err_msg));
fprintf(stderr, "...", ...);
```
, will work fine.
There is one exception to this, when using `wxString::Printf()` and such, you
can't pass another `wxString` to the `%s` format directly, use something like
this:
```cpp
wxString err;
err.Printf("Cannot read file: %s", fname.wc_str());
```
this uses the `wchar_t` UTF-16 representation on Windows and does nothing
elsewhere.
For calling Windows APIs with strings, use the wide char `W` variants and the
`wc_str()` method as well.
### Windows Native Development Environment Setup
This guide has been moved to:
https://github.com/rkitover/windows-dev-guide
You need a debug build for this to work or to even have a console on Windows.
Pass `-DCMAKE_BUILD_TYPE=Debug` to cmake.
### Release Process
#### Environment
#### GnuPG Key
The variable `VBAM_NO_PAUSE`, if set, will cause cmake to not pause before gpg
signing operations, you want to set this if you've disabled your gpg passphrase
to not require interaction during release builds.
You will need to create a GnuPG key for signing your commits and release tags,
and upload it to a keyserver.
gpg set up with your key is helpful for the release process on all environments
where a binary is built, but you can also make the detached signature files
yourself at the end of the process.
Make sure to install GnuPG on all environments where you will be making commits
and tags.
For codesigning windows binaries, put your certificate into
`~/.codesign/windows_comodo.pkcs12`.
#### Certificates
On Mac the 'Developer ID Application' certificate stored in your login keychain
is used, `keychain unlock` will prompt you for your login keychain password, to
avoid that set the `LOGIN_KEYCHAIN_PASSWORD` environment variable to your
password.
Make sure you have set up a Windows code signing certificate with the right
password and a Mac 'Developer ID Application' certificate.
Put the Windows certificate into `~/.codesign/windows_comodo.pkcs12` as a PKCS12
file that is password protected, and put the password for it into
`~/.codesign/windows_comodo.pkcs12.password`.
#### Release Commit and Tag
@@ -280,8 +226,10 @@ tag:
mkdir build && cd build
cmake .. -DTAG_RELEASE=TRUE
```
, follow the instructions to edit the `CHANGELOG.md` and then push the release:
then push the release:
To reiterate, **make sure you edit the `CHANGELOG.md`** to remove any
non-user-facing changes before you make the release commit.
```bash
git push
@@ -296,84 +244,126 @@ cmake .. -DTAG_RELEASE=UNDO
#### 64-bit Windows Binary
For this you will preferably need the powershell environment setup described
earlier, however you can use a regular Visual Studio 64 bit native developer
command prompt as well.
For this you will preferably need the PowerShell environment setup described
[here](https://github.com/rkitover/windows-dev-guide), or by starting the `x64
Native Tools Command Prompt` from your Start Menu.
```powershell
mkdir build
cd build
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Release -DUPSTREAM_RELEASE=TRUE -G Ninja
mkdir build-msvc64
cd build-msvc64
cmake .. -DCMAKE_BUILD_TYPE=Release -DUPSTREAM_RELEASE=TRUE -G Ninja
ninja
```
Collect the following files for the release:
- `visualboyadvance-m-Win-64bit.zip`
- `visualboyadvance-m-Win-64bit.zip.asc`
- `visualboyadvance-m-Win-x86_64.zip`
- `translations.zip`
- `translations.zip.asc`
Repeat the process for the debug build, with `-DCMAKE_BUILD_TYPE=Debug` and
collect this file:
- `visualboyadvance-m-Win-x86_64-debug.zip`
.
#### 32-bit Windows Binary
For this the optimal environment is a linux distribution with the mingw
toolchain, I use fedora.
The 32-bit build is a legacy build for Windows XP compatibility. You will need
the MinGW toolchain to build it. The easiest method is to use the MINGW32 MSYS2
environment.
You can set up a shell on a fedora distribution with docker as described here:
Make sure the Visual Studio `signtool.exe` is in your path, you can start MSYS2
with an inherited `PATH` from a Visual Studio enabled environment or add it to
your shell configuration.
https://gist.github.com/rkitover/6379764c619c10e829e4b2fa0ae243fd
If using fedora, the cross script will install all necessary dependencies, if
not install the base toolchain (mingw gcc, binutils, winpthreads) using the
preferred method for your distribution, you can also use mxe for this.
https://mxe.cc/
First install dependencies with:
```bash
sh tools/win/linux-cross-builder -32
./installdeps
```
You can also use msys2 on Windows, this is not recommended:
. Then build the 32-bit binary as follows:
```bash
sh tools/win/msys2-builder -32
mkdir build-mingw32
cd build-mingw32
cmake .. -DCMAKE_BUILD_TYPE=Release -DUPSTREAM_RELEASE=TRUE -G Ninja
ninja
```
. Collect this file for the release:
To set up msys2, see this guide:
- `visualboyadvance-m-Win-x86_32.zip`
https://gist.github.com/rkitover/d008324309044fc0cc742bdb16064454
. Then repeat the process for the debug build with `-DCMAKE_BUILD_TYPE=Debug`,
and collect this file:
Collect the following files from `~/vbam-build-mingw32/project` if using linux,
or `~/vbam-build-msys2-x86_64/project` if using msys2:
- `visualboyadvance-m-Win-x86_32-debug.zip`
.
- `visualboyadvance-m-Win-32bit.zip`
- `visualboyadvance-m-Win-32bit.zip.asc`
#### ARM64 Windows Binary
#### 64-bit Mac Binary
You will need the MSVC ARM64 cross toolchain to build this binary, if you used
the install script from [here](https://github.com/rkitover/windows-dev-guide)
you will have it installed, otherwise run Visual Studio Installer and install
the component.
To enter the ARM64 cross environment, edit the PowerShell profile described
[here](https://github.com/rkitover/windows-dev-guide) or use the `vcvarsall.bat`
script with the `amd64_arm64` argument as described
[here](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170).
From there the process is the same as for the 64-bit build, collect the
following files for the release:
- `visualboyadvance-m-Win-arm64.zip`
- 'visualboyadvance-m-Win-arm64-debug.zip'
.
#### macOS Binary
Install the latest Xcode for your OS.
You will need bash and (optionally) gpg from homebrew (which you will also need
to install):
```bash
brew install bash gnupg
```
You will need bash from Homebrew/nix/MacPorts/whatever to run the build script.
You will need a codesigning certificate from Apple, which you will be able to
generate once you join their developer program. This is the certificate of the
type 'Developer ID Application' stored in your login keychain. `keychain
unlock` will prompt you for your login keychain password, to avoid that set the
`LOGIN_KEYCHAIN_PASSWORD` environment variable to your password.
generate once you join their developer program from XCode. This is the
certificate of the type 'Developer ID Application' stored in your login
keychain.
If you are not using a GUI session, you will need to use a method to unlock your
login keychain before building so that your codesigning certificate can be used.
Adding the certificate and key to the System keychain is also a method that some
people use.
To unlock your keychain on login, you can add something like this to your
`~/.zshrc`:
```bash
/usr/local/bin/bash tools/osx/builder -64
security unlock-keychain -p "$(cat ~/.login-keychain-password)" login.keychain
```
, with your login password in that file.
For notarization to work, you will need to create an app-specific password on
https://appleid.apple.com , get your Team ID from your Apple Developer account,
and store them with this command:
```bash
xcrun notarytool store-credentials AC_PASSWORD \
--apple-id you@domain.com \
--team-id <DeveloperTeamID> \
--password <secret_app_specific_2FA_password>
```
. Once all of this is set up, run:
```bash
tools/osx/builder
```
, this will take a while because it builds all of the dependencies.
Collect the following files from `~/vbam-build-mac-64bit/project`:
- `visualboyadvance-m-Mac-64bit.zip`
- `visualboyadvance-m-Mac-64bit.zip.asc`
- `visualboyadvance-m-Mac-x86_64.zip`
- `visualboyadvance-m-Mac-x86_64-debug.zip`
.
#### Final steps
@@ -381,27 +371,26 @@ Go to the github releases tab, and make a release for the tag you pushed
earlier.
Put any notes to users and distro maintainers into the description as well as
the entries from `CHANGELOG.md` generated earlier from git by the release
commit script.
the generated entries from `CHANGELOG.md` you edited earlier.
Upload all files collected during the earlier builds, the complete list is:
- `translations.zip`
- `translations.zip.asc`
- `visualboyadvance-m-Mac-64bit.zip`
- `visualboyadvance-m-Mac-64bit.zip.asc`
- `visualboyadvance-m-Win-32bit.zip`
- `visualboyadvance-m-Win-32bit.zip.asc`
- `visualboyadvance-m-Win-64bit.zip`
- `visualboyadvance-m-Win-64bit.zip.asc`
- `visualboyadvance-m-Win-x86_64.zip`
- `visualboyadvance-m-Win-x86_64-debug.zip`
- `visualboyadvance-m-Win-x86_32.zip`
- `visualboyadvance-m-Win-x86_32-debug.zip`
- `visualboyadvance-m-Win-arm64.zip`
- 'visualboyadvance-m-Win-arm64-debug.zip'
- `visualboyadvance-m-Mac-x86_64.zip`
- `visualboyadvance-m-Mac-x86_64-debug.zip`
Update the winsparkle appcast.xml by running this cmake command:
Update the winsparkle `appcast.xml` by running this cmake command:
```bash
cmake .. -DUPDATE_APPCAST=TRUE
```
follow the instructions to push the change to the web data repo.
, follow the instructions to push the change to the web data repo.
Announce the release on reddit r/emulation and the forum.

172
README.md
View File

@@ -19,8 +19,6 @@
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
[![Join the chat at https://gitter.im/visualboyadvance-m/Lobby](https://badges.gitter.im/visualboyadvance-m/Lobby.svg)](https://gitter.im/visualboyadvance-m/Lobby)
Our bridged Discord server is [Here](https://discord.gg/EpfxEuGMKH).
We are also on *`#vba-m`* on [Libera IRC](https://libera.chat/) which has a [Web
@@ -59,35 +57,39 @@ Factory Reset`.
## System Requirements
Windows 7, 8.1 or 10/11, Linux distro's or macOS.
Windows XP, Vista, 7, 8.1 or 10/11, Linux distros or macOS.
2Ghz x86 (or x86-64) Intel Core 2 or AMD Athlon processor with SSE, Snapdragon 835
or newer CPU compatible with Arm for Windows.
2Ghz x86(or x86-64) Intel Core 2 or AMD Athlon processor with SSE, Snapdragon 835
or newer cpu compatible with Arm for Windows.
- Just a guideline, lower clock speeds and Celeron processors may be able to run at full
speed on lower settings, and Linux based ARM Operating systems have wider cpu support.
speed on lower settings, and Linux based ARM Operating systems have wider CPU support.
DirectX June 2010 Redist [Full](https://www.microsoft.com/en-au/download/details.aspx?id=8109) / [Websetup](https://www.microsoft.com/en-au/download/details.aspx?id=35) for Xaudio (Remember to uncheck Bing on the websetup)
DirectX June 2010 Redist
[Full](https://www.microsoft.com/en-au/download/details.aspx?id=8109) /
[Websetup](https://www.microsoft.com/en-au/download/details.aspx?id=35) for
Xaudio (Remember to uncheck Bing on the websetup.)
## Building
The basic formula to build vba-m is:
```shell
```bash
cd ~ && mkdir src && cd src
git clone https://github.com/visualboyadvance-m/visualboyadvance-m.git
cd visualboyadvance-m
./installdeps
# ./installdeps will give you build instructions, which will be similar to:
./installdeps # On Linux or macOS
mkdir build && cd build
cmake .. -G Ninja
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
ninja
```
`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch,
Solus, OpenSUSE, Gentoo and RHEL/CentOS) and Mac OS X (homebrew, macports or
fink.)
`./installdeps` is supported on MSYS2, Linux (Debian/Ubuntu, Fedora, Arch,
Solus, OpenSUSE, Gentoo and RHEL/CentOS) and Mac OS X (homebrew, MacPorts or
Fink.)
## Building a Libretro core
@@ -98,7 +100,7 @@ cd src/libretro
make -j`nproc`
```
Copy vbam_libretro.so to your RetroArch cores directory.
Copy `vbam_libretro.so` to your RetroArch cores directory.
## Visual Studio Support
@@ -118,14 +120,16 @@ environment loaded.
Using your own user-wide installation of vcpkg is supported, just make sure the
environment variable `VCPKG_ROOT` is set.
To build in the visual studio command prompt, use something like this:
To build in the Visual Studio `x64 Native Tools Command Prompt`, use something
like this:
```
mkdir build
cd build
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Debug -G Ninja
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
ninja
```
.
## Visual Studio Code Support
@@ -162,8 +166,7 @@ And the following development libraries:
- [ffmpeg](https://ffmpeg.org/) (optional, at least version `4.0.4`, for game recording)
- [gettext](https://www.gnu.org/software/gettext/) and gettext-tools
- [SDL2](https://www.libsdl.org/) (required)
- [SFML](https://www.sfml-dev.org/) (optional, for link)
- [OpenAL](https://www.openal.org/) or [openal-soft](https://kcat.strangesoft.net/openal.html) (required, a sound interface)
- [openal-soft](https://kcat.strangesoft.net/openal.html) (required, a sound interface)
- [wxWidgets](https://wxwidgets.org/) (required for GUI, 2.8 and non-stl builds are no longer supported)
On Linux and similar, you also need the version of GTK your wxWidgets is linked
@@ -183,61 +186,46 @@ This is supported on Fedora, Arch, Solus and MSYS2.
may be `win32` which is an alias for `mingw-w64-i686` to target 32 bit Windows,
or `mingw-w64-x86_64` for 64 bit Windows targets.
The target is implicit on MSys2 depending on which MINGW shell you started (the
The target is implicit on MSYS2 depending on which MINGW shell you started (the
value of `$MSYSTEM`.)
On Debian/Ubuntu this uses the MXE apt repository and works quite well.
On Fedora it can build using the Fedora MinGW packages, albeit with wx 2.8, no
OpenGL support, and no Link support for lack of SFML.
On Arch it currently doesn't work at all because the AUR stuff is completely
broken, I will at some point redo the arch stuff to use MXE as well.
## CMake Options
The CMake code tries to guess reasonable defaults for options, but you can
override them, for example:
```shell
cmake .. -DENABLE_LINK=NO -G Ninja
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_LINK=NO -G Ninja
```
Of particular interest is making **Release** or **Debug** builds, the default
mode is **Release**, to make a **Debug** build use something like:
```shell
cmake .. -DCMAKE_BUILD_TYPE=Debug -G Ninja
```
Here is the complete list:
. Here is the complete list:
| **CMake Option** | **What it Does** | **Defaults** |
|-----------------------|----------------------------------------------------------------------|-----------------------|
| ENABLE_SDL | Build the SDL port | OFF |
| ENABLE_WX | Build the wxWidgets port | ON |
| ENABLE_DEBUGGER | Enable the debugger | ON |
| ENABLE_ASM_CORE | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
| ENABLE_ASM | Enable the following two ASM options | ON for 32 bit builds |
| ENABLE_ASM_SCALERS | Enable x86 ASM graphic filters | ON for 32 bit builds |
| ENABLE_MMX | Enable MMX | ON for 32 bit builds |
| ENABLE_LINK | Enable GBA linking functionality (requires SFML) | AUTO |
| ENABLE_LIRC | Enable LIRC support | OFF |
| ENABLE_FFMPEG | Enable ffmpeg A/V recording | AUTO |
| ENABLE_ONLINEUPDATES | Enable online update checks | ON |
| ENABLE_LTO | Compile with Link Time Optimization (gcc and clang only) | ON for release build |
| ENABLE_GBA_LOGGING | Enable extended GBA logging | ON |
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
| ENABLE_ASAN | Enable libasan sanitizers (by default address, only in debug mode) | OFF |
| UPSTREAM_RELEASE | Do some release tasks, like codesigning, making zip and gpg sigs. | OFF |
| BUILD_TESTING | Build the tests and enable ctest support. | ON |
| VBAM_STATIC | Try link all libs statically (the following are set to ON if ON) | OFF |
| SDL2_STATIC | Try to link static SDL2 libraries | OFF |
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |
| FFMPEG_STATIC | Try to link static ffmpeg libraries | OFF |
| OPENAL_STATIC | Try to link static OpenAL libraries | OFF |
| TRANSLATIONS_ONLY | Build only the translations.zip and nothing else | OFF |
| `ENABLE_SDL` | Build the SDL port | OFF |
| `ENABLE_WX` | Build the wxWidgets port | ON |
| `ENABLE_DEBUGGER` | Enable the debugger | ON |
| `ENABLE_ASM_CORE` | Enable x86 ASM CPU cores (**BUGGY AND DANGEROUS**) | OFF |
| `ENABLE_ASM` | Enable the following two ASM options | ON for 32 bit builds |
| `ENABLE_ASM_SCALERS` | Enable x86 ASM graphic filters | ON for 32 bit builds |
| `ENABLE_MMX` | Enable MMX | ON for 32 bit builds |
| `ENABLE_LINK` | Enable GBA linking functionality | AUTO |
| `ENABLE_LIRC` | Enable LIRC support | OFF |
| `ENABLE_FFMPEG` | Enable ffmpeg A/V recording | AUTO |
| `ENABLE_ONLINEUPDATES` | Enable online update checks | ON |
| `ENABLE_LTO` | Compile with Link Time Optimization (gcc and clang only) | ON for release build |
| `ENABLE_GBA_LOGGING` | Enable extended GBA logging | ON |
| `ENABLE_XAUDIO2` | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
| `ENABLE_FAUDIO` | Enable faudio sound output for wxWidgets, | ON, not 32 bit Win |
| `ENABLE_ASAN` | Enable libasan sanitizers (by default address, only in debug mode) | OFF |
| `UPSTREAM_RELEASE` | Do some release tasks, like codesigning, making zip and gpg sigs. | OFF |
| `BUILD_TESTING` | Build the tests and enable ctest support. | ON |
| `VBAM_STATIC` | Try link all libs statically (the following are set to ON if ON) | OFF |
| `SDL2_STATIC` | Try to link static SDL2 libraries | OFF |
| `FFMPEG_STATIC` | Try to link static ffmpeg libraries | OFF |
| `OPENAL_STATIC` | Try to link static OpenAL libraries | OFF |
| `TRANSLATIONS_ONLY` | Build only the translations.zip and nothing else | OFF |
Note for distro packagers, we use the CMake module
[GNUInstallDirs](https://cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs)
@@ -247,52 +235,6 @@ On Unix to use a different version of wxWidgets, set
`wxWidgets_CONFIG_EXECUTABLE` to the path to the `wx-config` script you want to
use.
## MSys2 Notes
To run the resulting binary, you can simply type:
```shell
./visualboyadvance-m
```
in the shell where you built it.
If you built with `-DCMAKE_BUILD_TYPE=Debug`, you will get a console app and
will see debug messages, even in mintty.
If you want to start the binary from e.g. a shortcut or Explorer, you will need
to put `c:\msys64\mingw32\bin` for 32 bit builds and `c:\msys64\mingw64\bin`
for 64 bit builds in your PATH (to edit system PATH, go to Control Panel ->
System -> Advanced system settings -> Environment Variables.)
If you want to package the binary, you will need to include the MinGW DLLs it
depends on, they can install to the same directory as the binary.
Our own builds are static.
## Debug Messages
We have an override for `wxLogDebug()` to make it work even in non-debug builds
of wx and on windows, even in mintty.
It works like `printf()`, e.g.:
```cpp
int foo = 42;
wxLogDebug(wxT("the value of foo = %d"), foo);
```
From the core etc. the usual:
```cpp
fprintf(stderr, "...", ...);
```
will work fine.
You need a debug build for this to work or to even have a console on Windows.
Pass `-DCMAKE_BUILD_TYPE=Debug` to cmake.
## Reporting Crash Bugs
If the emulator crashes and you wish to report the bug, a backtrace made with
@@ -311,27 +253,25 @@ do something such as:
```shell
ulimit -c unlimited
```
in your shell to enable coredump files.
, in your shell to enable core files.
[This
post](https://ask.fedoraproject.org/en/question/98776/where-is-core-dump-located/?answer=98779#post-id-98779)
explains how to retrieve core dump on Fedora Linux (and possibly other
distributions.)
explains how to retrieve core dump on some distributions, when they are managed
by systemd.
Once you have the core dump file, open it with `gdb`, for example:
Once you have the core file, open it with `gdb`, for example:
```shell
gdb -c core ./visualboyadvance-m
```
In the `gdb` shell, to print the backtrace, type:
. In the `gdb` shell, to start the process and print the backtrace, type:
```
run
bt
```
This may be a bit of a hassle, but it helps us out immensely.
. This may be a bit of a hassle, but it helps us out immensely.
## Contributing

View File

@@ -56,10 +56,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|i[3-9]86|[aA][mM][dD]64")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "[aA][aA][rR][cC][hH]|[aA][rR][mM]")
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4) # 32 bit
set(ARCH_NAME arm32)
set(ARM32 ON)
set(ARCH_NAME ARM32)
set(WINARCH arm)
elseif(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
set(ARCH_NAME arm64)
set(ARM64 ON)
set(ARCH_NAME ARM64)
set(WINARCH arm64)
endif()

View File

@@ -23,7 +23,7 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(VCPKG_TARGET_TRIPLET MATCHES -static)
set(arch_suffix -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(path_prefix debug)
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
@@ -119,4 +119,3 @@ if(ENABLE_LINK OR ENABLE_WX)
message(FATAL_ERROR "NLS requires libintl/gettext")
endif()
endif()

View File

@@ -1,110 +0,0 @@
#.rst:
# FindOpenAL
# ----------
#
#
#
# Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if
# false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find
# the headers
#
# $OPENALDIR is an environment variable that would correspond to the
# ./configure --prefix=$OPENALDIR used in building OpenAL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module.
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# This makes the presumption that you are include al.h like
# #include "al.h"
# and not
# #include <AL/al.h>
# The reason for this is that the latter is not entirely portable.
# Windows/Creative Labs does not by default put their headers in AL/ and
# OS X uses the convention <OpenAL/al.h>.
#
# For Windows, Creative Labs seems to have added a registry key for their
# OpenAL 1.1 installer. I have added that key to the list of search paths,
# however, the key looks like it could be a little fragile depending on
# if they decide to change the 1.00.0000 number for bug fix releases.
# Also, they seem to have laid down groundwork for multiple library platforms
# which puts the library in an extra subdirectory. Currently there is only
# Win32 and I have hardcoded that here. This may need to be adjusted as
# platforms are introduced.
# The OpenAL 1.0 installer doesn't seem to have a useful key I can use.
# I do not know if the Nvidia OpenAL SDK has a registry key.
#
# For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger).
# To support the framework, I originally wrote special framework detection
# code in this module which I have now removed with CMake's introduction
# of native support for frameworks.
# In addition, OpenAL is open source, and it is possible to compile on Panther.
# Furthermore, due to bugs in the initial OpenAL release, and the
# transition to OpenAL 1.1, it is common to need to override the built-in
# framework.
# Per my request, CMake should search for frameworks first in
# the following order:
# ~/Library/Frameworks/OpenAL.framework/Headers
# /Library/Frameworks/OpenAL.framework/Headers
# /System/Library/Frameworks/OpenAL.framework/Headers
#
# On OS X, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# OPENAL_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
find_path(OPENAL_INCLUDE_DIR al.h
HINTS
ENV OPENALDIR
PATH_SUFFIXES AL OpenAL
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_OpenAL_ARCH_DIR libs/Win64)
else()
set(_OpenAL_ARCH_DIR libs/Win32)
endif()
find_library(OPENAL_LIBRARY
NAMES OpenAL al openal OpenAL32
HINTS
ENV OPENALDIR
PATH_SUFFIXES lib64 lib libs64 libs ${_OpenAL_ARCH_DIR}
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
unset(_OpenAL_ARCH_DIR)
# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR)

View File

@@ -1,365 +0,0 @@
# This script locates the SFML library
# ------------------------------------
#
# Usage
# -----
#
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
# example:
# find_package(SFML COMPONENTS graphics window system) # find the graphics, window and system modules
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
# example:
# find_package(SFML COMPONENTS ...) # no specific version required
# find_package(SFML 2 COMPONENTS ...) # any 2.x version
# find_package(SFML 2.4 COMPONENTS ...) # version 2.4 or greater
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
# description below).
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
# example:
# set(SFML_STATIC_LIBRARIES TRUE)
# find_package(SFML 2 COMPONENTS network system)
#
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
# to tell CMake where SFML is.
#
# Output
# ------
#
# This script defines the following variables:
# - For each specified module XXX (system, window, graphics, network, audio, main):
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
# - SFML_FOUND: true if all the required modules are found
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
#
# example:
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
# include_directories(${SFML_INCLUDE_DIR})
# add_executable(myapp ...)
# target_link_libraries(myapp ${SFML_LIBRARIES})
# define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES)
add_compile_definitions(SFML_STATIC)
endif()
# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
${SFML_ROOT}
$ENV{SFML_ROOT}
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
PATHS ${FIND_SFML_PATHS})
# check the version number
set(SFML_VERSION_OK TRUE)
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
# extract the major and minor version numbers from SFML/Config.hpp
# we have to handle framework a little bit differently:
if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
else()
set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
endif()
FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
STRING(REGEX REPLACE ".*#define *SFML_VERSION_MAJOR *([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
STRING(REGEX REPLACE ".*#define *SFML_VERSION_MINOR *([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
STRING(REGEX REPLACE ".*#define *SFML_VERSION_PATCH *([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}")
if (NOT "${SFML_VERSION_PATCH}" MATCHES "^[0-9]+$")
set(SFML_VERSION_PATCH 0)
endif()
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}")
# if we could extract them, compare with the requested version number
if (SFML_VERSION_MAJOR)
# transform version numbers to an integer
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}")
# compare them
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
set(SFML_VERSION_OK FALSE)
endif()
else()
# SFML version is < 2.0
if (SFML_REQUESTED_VERSION GREATER 10900)
set(SFML_VERSION_OK FALSE)
set(SFML_VERSION_MAJOR 1)
set(SFML_VERSION_MINOR x)
set(SFML_VERSION_PATCH x)
endif()
endif()
endif()
# find the requested modules
set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
# no suffix for sfml-main, it is always a static library
if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
# release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
else()
# static release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}-s
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# static debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# dynamic release library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
NAMES ${FIND_SFML_COMPONENT_NAME}
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# dynamic debug library
find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
NAMES ${FIND_SFML_COMPONENT_NAME}-d
PATH_SUFFIXES lib64 lib
PATHS ${FIND_SFML_PATHS})
# choose the entries that fit the requested link type
if(SFML_STATIC_LIBRARIES)
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
endif()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
endif()
else()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
endif()
if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
endif()
endif()
endif()
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
# library found
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
# if both are found, set SFML_XXX_LIBRARY to contain both
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
endif()
# if only one debug/release variant is found, set the other to be equal to the found one
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
# debug and not release
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
endif()
if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
# release and not debug
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
endif()
else()
# library not found
set(SFML_FOUND FALSE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
endif()
# mark as advanced
MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
# add to the global list of libraries
set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
endforeach()
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
if(SFML_STATIC_LIBRARIES)
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(FIND_SFML_OS_WINDOWS 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(FIND_SFML_OS_LINUX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(FIND_SFML_OS_FREEBSD 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(FIND_SFML_OS_MACOSX 1)
endif()
# start with an empty list
set(SFML_DEPENDENCIES)
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
# macro that searches for a 3rd-party library
macro(find_sfml_dependency output friendlyname)
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
if(${${output}} STREQUAL "${output}-NOTFOUND")
unset(output)
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
endif()
endmacro()
# sfml-system
list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
# update the list -- these are only system libraries, no need to find them
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
set(SFML_SYSTEM_DEPENDENCIES "pthread")
endif()
if(FIND_SFML_OS_LINUX)
set(SFML_SYSTEM_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} "rt")
endif()
if(FIND_SFML_OS_WINDOWS)
set(SFML_SYSTEM_DEPENDENCIES "winmm")
endif()
set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-network
list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
# update the list -- these are only system libraries, no need to find them
if(FIND_SFML_OS_WINDOWS)
set(SFML_NETWORK_DEPENDENCIES "ws2_32")
endif()
set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-window
list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
# find libraries
if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
find_sfml_dependency(X11_LIBRARY "X11" X11)
find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
endif()
if(FIND_SFML_OS_LINUX)
find_sfml_dependency(UDEV_LIBRARIES "UDev" udev libudev)
endif()
# update the list
if(FIND_SFML_OS_WINDOWS)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
elseif(FIND_SFML_OS_LINUX)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY} ${UDEV_LIBRARIES})
elseif(FIND_SFML_OS_FREEBSD)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY} "usbhid")
elseif(FIND_SFML_OS_MACOSX)
set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
endif()
set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-graphics
list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
# find libraries
find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
# update the list
set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY})
set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
endif()
# sfml-audio
list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
# find libraries
find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
find_sfml_dependency(OGG_LIBRARY "Ogg" ogg)
find_sfml_dependency(VORBIS_LIBRARY "Vorbis" vorbis)
find_sfml_dependency(VORBISFILE_LIBRARY "VorbisFile" vorbisfile)
find_sfml_dependency(VORBISENC_LIBRARY "VorbisEnc" vorbisenc)
find_sfml_dependency(FLAC_LIBRARY "FLAC" FLAC)
# update the list
set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${FLAC_LIBRARY} ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES})
endif()
endif()
# handle errors
if(NOT SFML_VERSION_OK)
# SFML version not ok
set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})")
set(SFML_FOUND FALSE)
elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
set(SFML_FOUND FALSE)
elseif(NOT SFML_FOUND)
# include directory or library not found
set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
endif()
if (NOT SFML_FOUND)
if(SFML_FIND_REQUIRED)
# fatal error
message(FATAL_ERROR ${FIND_SFML_ERROR})
elseif(NOT SFML_FIND_QUIETLY)
# error but continue
message("${FIND_SFML_ERROR}")
endif()
endif()
# handle success
if(SFML_FOUND AND NOT SFML_FIND_QUIETLY)
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}")
endif()

View File

@@ -10,10 +10,6 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(FATAL_ERROR "releases can only be done from a git clone")
endif()
if(NOT GIT_FOUND)
message(FATAL_ERROR "git is required to make a release")
endif()
find_program(GPG_EXECUTABLE gpg)
if(NOT GPG_EXECUTABLE)
@@ -35,7 +31,7 @@ function(make_release_commit_and_tag)
# First make sure we are on master.
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short --abbrev-ref=strict HEAD
COMMAND git rev-parse --short --abbrev-ref=strict HEAD
OUTPUT_VARIABLE git_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -46,7 +42,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} status --porcelain=2
COMMAND git status --porcelain=2
OUTPUT_VARIABLE git_status
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -59,7 +55,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} tag --sort=-v:refname
COMMAND git tag --sort=-v:refname
OUTPUT_VARIABLE git_tags
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -80,7 +76,7 @@ function(make_release_commit_and_tag)
endif()
execute_process(
COMMAND ${GIT_EXECUTABLE} log ${git_last_tag}.. "--pretty=format:* %h - %s [%aL]"
COMMAND git log ${git_last_tag}.. "--pretty=format:* %h - %s [%aL]"
OUTPUT_VARIABLE release_log
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -90,17 +86,17 @@ function(make_release_commit_and_tag)
if(TAG_RELEASE STREQUAL UNDO)
execute_process(
COMMAND ${GIT_EXECUTABLE} tag -d ${git_last_tag}
COMMAND git tag -d ${git_last_tag}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} reset HEAD~1
COMMAND git reset HEAD~1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} checkout HEAD CHANGELOG.md
COMMAND git checkout HEAD CHANGELOG.md
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
@@ -212,45 +208,37 @@ Ignore the following cmake error.
)
execute_process(
COMMAND ${GIT_EXECUTABLE} add CHANGELOG.md
COMMAND git add CHANGELOG.md
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Make the release commit.
message(FATAL_ERROR "
execute_process(
COMMAND ${GIT_EXECUTABLE} commit -m "release ${new_tag}" --signoff -S
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Release prepared.
# Make release tag.
Edit CHANGELOG.md to remove any non-user-facing commits, and optionally add any
release notes.
execute_process(
COMMAND ${GIT_EXECUTABLE} tag -s -m${new_tag} ${new_tag}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Run the following commands to commit the change:
message(FATAL_ERROR [=[
Release commit and tag generated.
**** IF YOU ARE SURE YOU WANT TO RELEASE ****
Run the following commands to push the release commit and tag:
git push
git push --tags
**** TO UNDO THE RELEASE ****
git commit -m'release ${new_tag}' --signoff -S
git tag -s -m'${new_tag}' ${new_tag}
To rollback these changes, run this command:
cmake .. -DTAG_RELEASE=UNDO
Ignore the "configuration incomplete" message following, this mode does not
==== IF YOU ARE SURE YOU WANT TO RELEASE, THIS **CANNOT** BE REVERSED ====
Run the following to push the release commit and tag:
git push
git push --tags
Ignore the 'configuration incomplete' message following, this mode does not
build anything.
]=])
")
endfunction()
make_release_commit_and_tag()

View File

@@ -8,7 +8,12 @@ else()
set(BUILD_DEFAULT ON)
endif()
option(ENABLE_SDL "Build the SDL port" ${BUILD_DEFAULT})
set(ENABLE_SDL_DEFAULT ${BUILD_DEFAULT})
if(WIN32 OR APPLE)
set(ENABLE_SDL_DEFAULT OFF)
endif()
option(ENABLE_SDL "Build the SDL port" ${ENABLE_SDL_DEFAULT})
option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT})
option(ENABLE_DEBUGGER "Enable the debugger" ON)
option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF)
@@ -25,7 +30,6 @@ option(VBAM_STATIC "Try to link all libraries statically" ${VBAM_STATIC_DEFAULT}
if(VBAM_STATIC)
set(SDL2_STATIC ON)
set(SFML_STATIC_LIBRARIES ON)
set(FFMPEG_STATIC ON)
set(OPENAL_STATIC ON)
set_property(GLOBAL PROPERTY LINK_SEARCH_START_STATIC ON)
@@ -63,21 +67,8 @@ endif()
find_package(PkgConfig)
# Link / SFML
if(TRANSLATIONS_ONLY)
set(ENABLE_LINK_DEFAULT OFF)
else()
find_package(SFML 2.4 COMPONENTS network system)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if(SFML_STATIC_LIBRARIES AND SFML_NETWORK_LIBRARY_STATIC_DEBUG AND SFML_SYSTEM_LIBRARY_STATIC_DEBUG)
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_STATIC_DEBUG} ${SFML_SYSTEM_LIBRARY_STATIC_DEBUG})
elseif(SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG AND SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG)
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG} ${SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG})
endif()
endif()
set(ENABLE_LINK_DEFAULT OFF)
if(SFML_FOUND)
set(ENABLE_LINK_DEFAULT ON)
endif()
if(NOT TRANSLATIONS_ONLY)
set(ENABLE_LINK_DEFAULT ON)
endif()
option(ENABLE_LINK "Enable GBA linking functionality" ${ENABLE_LINK_DEFAULT})
@@ -86,7 +77,7 @@ set(FFMPEG_DEFAULT OFF)
set(FFMPEG_COMPONENTS AVCODEC AVFORMAT SWSCALE AVUTIL SWRESAMPLE)
set(FFMPEG_COMPONENT_VERSIONS AVCODEC>=58.18.100 AVFORMAT>=58.12.100 SWSCALE>=5.1.100 AVUTIL>=56.14.100 SWRESAMPLE>=3.1.100)
if(NOT TRANSLATIONS_ONLY AND NOT DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG)
if(NOT TRANSLATIONS_ONLY AND (NOT DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG) AND (NOT (X86 AND MINGW)))
set(FFMPEG_DEFAULT ON)
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
@@ -146,7 +137,7 @@ set(ENABLE_FAUDIO_DEFAULT OFF)
find_package(FAudio QUIET)
if(FAudio_FOUND)
if(FAudio_FOUND AND NOT (MINGW AND X86))
set(ENABLE_FAUDIO_DEFAULT ON)
endif()
@@ -162,3 +153,5 @@ endif()
if(TRANSLATIONS_ONLY AND (ENABLE_SDL OR ENABLE_WX))
message(FATAL_ERROR "The SDL and wxWidgets ports can't be built when TRANSLATIONS_ONLY is enabled")
endif()
option(GPG_SIGNATURES "Create GPG signatures for release files" OFF)

View File

@@ -10,19 +10,28 @@ if(NOT DEFINED VCPKG_TARGET_TRIPLET)
# Check if we are in an MSVC environment.
find_program(cl_exe_path NAME cl.exe HINTS ENV PATH)
if($ENV{CXX} MATCHES "cl.exe$" OR cl_exe_path)
if(ENV{CXX} MATCHES "cl.exe$" OR cl_exe_path)
# Infer the architecture from the LIB folders.
foreach(LIB $ENV{LIB})
if(${LIB} MATCHES "x64$")
foreach(lib $ENV{LIB})
if(lib MATCHES "x64$")
set(VBAM_VCPKG_PLATFORM "x64-windows-static")
break()
endif()
if(${LIB} MATCHES "x86$")
if(lib MATCHES "x86$")
set(VBAM_VCPKG_PLATFORM "x86-windows-static")
break()
endif()
if(${LIB} MATCHES "ARM64$")
if(lib MATCHES "ARM64$")
set(VBAM_VCPKG_PLATFORM "arm64-windows-static")
foreach(path $ENV{PATH})
if(path MATCHES "[Hh]ost[Xx]64")
set(VCPKG_HOST_TRIPLET "x64-windows-static" CACHE STRING "Vcpkg host triplet" FORCE)
set(VCPKG_USE_HOST_TOOLS ON CACHE BOOL "Use vcpkg host tools" FORCE)
break()
endif()
endforeach()
break()
endif()
endforeach()
@@ -51,6 +60,28 @@ if(NOT DEFINED VCPKG_TARGET_TRIPLET)
message(STATUS "Inferred VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
endif()
function(vcpkg_seconds)
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
execute_process(
COMMAND cmd /c echo %TIME:~0,8%
OUTPUT_VARIABLE time
)
else()
execute_process(
COMMAND date +%H:%M:%S
OUTPUT_VARIABLE time
)
endif()
string(SUBSTRING "${time}" 0 2 hours)
string(SUBSTRING "${time}" 3 2 minutes)
string(SUBSTRING "${time}" 6 2 secs)
math(EXPR seconds "(${hours} * 60 * 60) + (${minutes} * 60) + ${secs}")
set(seconds ${seconds} PARENT_SCOPE)
endfunction()
function(vcpkg_check_git_status git_status)
# The VS vcpkg component cannot be written to without elevation.
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "Visual Studio")
@@ -471,7 +502,7 @@ function(vcpkg_set_toolchain)
# Install core deps.
execute_process(
COMMAND ${vcpkg_exe} install ${VCPKG_DEPS_QUALIFIED}
COMMAND ${vcpkg_exe} --triplet ${VCPKG_TARGET_TRIPLET} install ${pkg}
WORKING_DIRECTORY ${VCPKG_ROOT}
)
@@ -513,7 +544,7 @@ function(vcpkg_set_toolchain)
set(dep_qualified "${dep}:${VCPKG_TARGET_TRIPLET}")
execute_process(
COMMAND ${vcpkg_exe} install ${dep_qualified}
COMMAND --triplet ${VCPKG_TARGET_TRIPLET} ${vcpkg_exe} install ${dep}
WORKING_DIRECTORY ${VCPKG_ROOT}
)
@@ -545,14 +576,4 @@ endfunction()
vcpkg_set_toolchain()
# Make vcpkg use debug libs for RelWithDebInfo
set(orig_build_type ${CMAKE_BUILD_TYPE})
if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
set(CMAKE_BUILD_TYPE ${orig_build_type})
unset(orig_build_type)

View File

@@ -5,10 +5,16 @@ endif()
if(UPSTREAM_RELEASE)
if(X86_64)
# Require and optimize for Core2 level support, tune for generic.
add_compile_options(-march=core2 -mtune=generic)
if(APPLE)
add_compile_options(-march=core2 -mtune=skylake)
else()
add_compile_options(-march=core2 -mtune=generic)
endif()
elseif(X86_32)
# Optimize for pentium-mmx and tune for generic for older builds.
add_compile_options(-march=pentium-mmx -mtune=generic)
# Optimize for pentiumi3 and tune for generic for Windows XP builds.
set(WINXP TRUE)
add_compile_options(-march=pentium3 -mtune=generic)
add_compile_definitions(-DWINXP)
endif()
endif()
@@ -46,9 +52,9 @@ if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
add_compile_options(-ggdb3 -fno-omit-frame-pointer -Wall -Wextra)
else()
add_compile_options(-Ofast -fomit-frame-pointer)
add_compile_options(-O3 -ffast-math -fomit-frame-pointer)
endif()
# for some reason this is necessary

View File

@@ -3,8 +3,8 @@ if (NOT MINGW)
endif()
# this has to run after the toolchain is initialized.
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
include_directories("${CMAKE_SOURCE_DIR}/win32-deps/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/win32-deps/mingw-xaudio/include")
# Add Winsock as the last library linked because of broken link precedence.
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lws2_32")

View File

@@ -10,7 +10,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif()
endif()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
include_directories("${CMAKE_SOURCE_DIR}/win32-deps/msvc")
add_compile_definitions(
_FORCENAMELESSUNION
@@ -68,6 +68,8 @@ if(CMAKE_VERSION VERSION_LESS "3.25")
endif()
endif()
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++14>)
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
# We need to explicitly set all of these to override the CMake defaults.

View File

@@ -16,7 +16,7 @@ Ignore the following cmake error.
# Get last tag.
execute_process(
COMMAND ${GIT_EXECUTABLE} tag --sort=-v:refname
COMMAND git tag --sort=-v:refname
OUTPUT_VARIABLE git_tags
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -43,7 +43,7 @@ Ignore the following cmake error.
# Clone repo.
execute_process(
COMMAND ${GIT_EXECUTABLE} clone git@github.com:visualboyadvance-m/visualboyadvance-m.github.io web-data
COMMAND git clone git@github.com:visualboyadvance-m/visualboyadvance-m.github.io web-data
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
@@ -103,21 +103,21 @@ Ignore the following cmake error.
)
execute_process(
COMMAND ${GIT_EXECUTABLE} add appcast.xml
COMMAND git add appcast.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/web-data
)
# Commit the change.
execute_process(
COMMAND ${GIT_EXECUTABLE} commit -m "release ${new_tag}" --signoff -S
COMMAND git commit -m "release ${new_tag}" --signoff -S
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/web-data
)
# Make release tag.
execute_process(
COMMAND ${GIT_EXECUTABLE} tag -s -m${new_tag} ${new_tag}
COMMAND git tag -s -m${new_tag} ${new_tag}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/web-data
)

View File

@@ -1,175 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
doctest
-----
This module defines a function to help use the doctest test framework.
The :command:`doctest_discover_tests` discovers tests by asking the compiled test
executable to enumerate its tests. This does not require CMake to be re-run
when tests change. However, it may not work in a cross-compiling environment,
and setting test properties is less convenient.
This command is intended to replace use of :command:`add_test` to register
tests, and will create a separate CTest test for each doctest test case. Note
that this is in some cases less efficient, as common set-up and tear-down logic
cannot be shared by multiple test cases executing in the same instance.
However, it provides more fine-grained pass/fail information to CTest, which is
usually considered as more beneficial. By default, the CTest test name is the
same as the doctest name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
.. command:: doctest_discover_tests
Automatically add tests with CTest by querying the compiled test executable
for available tests::
doctest_discover_tests(target
[TEST_SPEC arg1...]
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[PROPERTIES name1 value1...]
[TEST_LIST var]
)
``doctest_discover_tests`` sets up a post-build command on the test executable
that generates the list of tests by parsing the output from running the test
with the ``--list-test-cases`` argument. This ensures that the full
list of tests is obtained. Since test discovery occurs at build time, it is
not necessary to re-run CMake when the list of tests changes.
However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
in order to function in a cross-compiling environment.
Additionally, setting properties on tests is somewhat less convenient, since
the tests are not available at CMake time. Additional test properties may be
assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
more fine-grained test control is needed, custom content may be provided
through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
directory property. The set of discovered tests is made accessible to such a
script via the ``<target>_TESTS`` variable.
The options are:
``target``
Specifies the doctest executable, which must be a known CMake executable
target. CMake will substitute the location of the built executable when
running the test.
``TEST_SPEC arg1...``
Specifies test cases, wildcarded test cases, tags and tag expressions to
pass to the doctest executable with the ``--list-test-cases`` argument.
``EXTRA_ARGS arg1...``
Any extra arguments to pass on the command line to each test case.
``WORKING_DIRECTORY dir``
Specifies the directory in which to run the discovered test cases. If this
option is not provided, the current binary directory is used.
``TEST_PREFIX prefix``
Specifies a ``prefix`` to be prepended to the name of each discovered test
case. This can be useful when the same test executable is being used in
multiple calls to ``doctest_discover_tests()`` but with different
``TEST_SPEC`` or ``EXTRA_ARGS``.
``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
be specified.
``PROPERTIES name1 value1...``
Specifies additional properties to be set on all tests discovered by this
invocation of ``doctest_discover_tests``.
``TEST_LIST var``
Make the list of tests available in the variable ``var``, rather than the
default ``<target>_TESTS``. This can be useful when the same test
executable is being used in multiple calls to ``doctest_discover_tests()``.
Note that this variable is only available in CTest.
#]=======================================================================]
#------------------------------------------------------------------------------
function(doctest_discover_tests TARGET)
cmake_parse_arguments(
""
""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES"
${ARGN}
)
if(NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
if(NOT _TEST_LIST)
set(_TEST_LIST ${TARGET}_TESTS)
endif()
## Generate a unique name based on the extra arguments
string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}")
string(SUBSTRING ${args_hash} 0 7 args_hash)
# Define rule to generate test list for aforementioned test executable
set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake")
set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
get_property(crosscompiling_emulator
TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR
)
add_custom_command(
TARGET ${TARGET} POST_BUILD
BYPRODUCTS "${ctest_tests_file}"
COMMAND "${CMAKE_COMMAND}"
-D "TEST_TARGET=${TARGET}"
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
-D "TEST_EXECUTOR=${crosscompiling_emulator}"
-D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
-D "TEST_SPEC=${_TEST_SPEC}"
-D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
-D "TEST_PROPERTIES=${_PROPERTIES}"
-D "TEST_PREFIX=${_TEST_PREFIX}"
-D "TEST_SUFFIX=${_TEST_SUFFIX}"
-D "TEST_LIST=${_TEST_LIST}"
-D "CTEST_FILE=${ctest_tests_file}"
-P "${_DOCTEST_DISCOVER_TESTS_SCRIPT}"
VERBATIM
)
file(WRITE "${ctest_include_file}"
"if(EXISTS \"${ctest_tests_file}\")\n"
" include(\"${ctest_tests_file}\")\n"
"else()\n"
" add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n"
"endif()\n"
)
if(NOT CMAKE_VERSION VERSION_LESS 3.10)
# Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY
APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
)
else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
if(NOT ${test_include_file_set})
set_property(DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}"
)
else()
message(FATAL_ERROR
"Cannot set more than one TEST_INCLUDE_FILE"
)
endif()
endif()
endfunction()
###############################################################################
set(_DOCTEST_DISCOVER_TESTS_SCRIPT
${CMAKE_CURRENT_LIST_DIR}/doctestAddTests.cmake
)

View File

@@ -1,81 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
set(prefix "${TEST_PREFIX}")
set(suffix "${TEST_SUFFIX}")
set(spec ${TEST_SPEC})
set(extra_args ${TEST_EXTRA_ARGS})
set(properties ${TEST_PROPERTIES})
set(script)
set(suite)
set(tests)
function(add_command NAME)
set(_args "")
foreach(_arg ${ARGN})
if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument
else()
set(_args "${_args} ${_arg}")
endif()
endforeach()
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
endfunction()
# Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}")
message(FATAL_ERROR
"Specified test executable '${TEST_EXECUTABLE}' does not exist"
)
endif()
if("${spec}" MATCHES .)
set(spec "--test-case=${spec}")
endif()
execute_process(
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-cases
OUTPUT_VARIABLE output
RESULT_VARIABLE result
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR
"Error running test executable '${TEST_EXECUTABLE}':\n"
" Result: ${result}\n"
" Output: ${output}\n"
)
endif()
string(REPLACE "\n" ";" output "${output}")
# Parse output
foreach(line ${output})
if("${line}" STREQUAL "===============================================================================" OR "${line}" MATCHES [==[^\[doctest\] ]==])
continue()
endif()
set(test ${line})
# use escape commas to handle properly test cases with commas inside the name
string(REPLACE "," "\\," test_name ${test})
# ...and add to script
add_command(add_test
"${prefix}${test}${suffix}"
${TEST_EXECUTOR}
"${TEST_EXECUTABLE}"
"--test-case=${test_name}"
${extra_args}
)
add_command(set_tests_properties
"${prefix}${test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
list(APPEND tests "${prefix}${test}${suffix}")
endforeach()
# Create a list of all discovered tests, which users may use to e.g. set
# properties on the tests
add_command(set ${TEST_LIST} ${tests})
# Write CTest script
file(WRITE "${CTEST_FILE}" "${script}")

View File

@@ -2,7 +2,7 @@ with import <nixpkgs> {};
stdenv.mkDerivation {
name = "visualboyadvance-m";
buildInputs = if stdenv.isDarwin then
[ ninja cmake gcc nasm faudio gettext libintl pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 darwin.apple_sdk.frameworks.System darwin.apple_sdk.frameworks.IOKit darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.QuartzCore darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.OpenGL darwin.apple_sdk.frameworks.OpenAL llvmPackages_latest.clang llvmPackages_latest.bintools ]
[ ninja cmake nasm faudio gettext libintl libtiff pkg-config zip zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 darwin.apple_sdk.frameworks.System darwin.apple_sdk.frameworks.IOKit darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.QuartzCore darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.OpenGL darwin.apple_sdk.frameworks.OpenAL llvmPackages_latest.clang llvmPackages_latest.bintools ]
else
[ ninja cmake gcc nasm faudio gettext libintl pkg-config zip sfml zlib openal ffmpeg wxGTK32 libGL libGLU glfw SDL2 gtk3-x11 pcre pcre2 util-linuxMinimal libselinux libsepol libthai libdatrie xorg.libXdmcp xorg.libXtst libxkbcommon epoxy dbus at-spi2-core ];
[ ninja cmake gcc clang llvm llvmPackages.libcxx nasm faudio gettext libintl libtiff pkg-config zip zlib openal ffmpeg wxGTK32 libGL libGLU glfw SDL2 gtk3-x11 pcre pcre2 util-linuxMinimal libselinux libsepol libthai libdatrie xorg.libXdmcp xorg.libXtst libxkbcommon libepoxy dbus at-spi2-core ];
}

Submodule dependencies deleted from e8ce758a98

View File

@@ -191,7 +191,7 @@ freebsd_installdeps() {
check sudo pkg update
pkgs="llvm-devel cmake ccache nasm ffmpeg gettext-tools gettext pkgconf sdl2 sfml wx31-gtk3 iconv zip ninja"
pkgs="llvm-devel cmake ccache nasm ffmpeg gettext-tools gettext pkgconf sdl2 wx31-gtk3 iconv zip ninja"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"
@@ -318,12 +318,6 @@ debian_installdeps() {
if [ -z "$target" ]; then
sudo apt-get -qq -y update
sfml_libs=
for lib in graphics window network; do
sfml_libs="$sfml_libs $(apt-cache search "libsfml-$lib" | sed 's/ - .*//' | sort -r | head -1)"
done
glew_lib=$(apt-cache search libglew | grep '^libglew[0-9]' | sed 's/ - .*//' | sort -r | head -1)
sdl_lib=$(apt-cache search '^libsdl2-2.0' | sed 's/ - .*//' | sort -r | head -1)
@@ -350,7 +344,7 @@ debian_installdeps() {
;;
esac
pkgs="build-essential g++ nasm cmake ccache gettext zlib1g-dev libgl1-mesa-dev libgettextpo-dev libsdl2-dev $sdl_lib libglu1-mesa-dev libglu1-mesa libgles2-mesa-dev libsfml-dev $sfml_libs $glew_lib $wx_libs libgtk2.0-dev libgtk-3-dev ccache zip ninja-build libopenal-dev"
pkgs="build-essential g++ nasm cmake ccache gettext zlib1g-dev libgl1-mesa-dev libgettextpo-dev libsdl2-dev $sdl_lib libglu1-mesa-dev libglu1-mesa libgles2-mesa-dev $glew_lib $wx_libs libgtk2.0-dev libgtk-3-dev ccache zip ninja-build libopenal-dev"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs libavcodec-dev libavformat-dev libswscale-dev libavutil-dev $libswresample_dev"
@@ -401,7 +395,7 @@ debian_installdeps() {
fi
fi
deps="gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets openal"
deps="gcc zlib ffmpeg gettext sdl2 openal wxwidgets openal"
[ -n "$ENABLE_FFMPEG" ] && deps="$deps ffmpeg"
set --
@@ -498,7 +492,7 @@ fedora_installdeps() {
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel SDL2-devel SFML-devel openal-soft-devel wxGTK-devel gtk3-devel; do
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel SDL2-devel openal-soft-devel wxGTK-devel gtk3-devel; do
case $pkg in
*ffmpeg*)
[ -z "$ENABLE_FFMPEG" ] && continue
@@ -597,8 +591,6 @@ fedora_installdeps() {
# get the necessary win32 headers
git submodule update --init --remote --recursive
warning='SFML is required for LINK support, Fedora does not currently have a MinGW SFML package, if you want LINK support you will need to install it manually'
fi
[ -z "$rpms_installed" ] && check sudo dnf -y --nogpgcheck --best --allowerasing install "$@"
@@ -684,8 +676,6 @@ rhel_installdeps() {
set -- --exclude='glibc32*'
fi
warning='RHEL does not currently have SFML packages, LINK support will be disabled'
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel SDL2-devel openal-soft-devel wxGTK3-devel gtk3-devel; do
case $pkg in
*ffmpeg*)
@@ -777,8 +767,6 @@ rhel_installdeps() {
# get the necessary win32 headers
git submodule update --init --remote --recursive
warning='SFML is required for LINK support, RHEL/EPEL does not currently have a MinGW SFML package, if you want LINK support you will need to install it manually'
fi
[ -z "$rpms_installed" ] && check sudo yum -y install "$@"
@@ -797,14 +785,12 @@ suse_installdeps() {
check_cross
installing
tools="make cmake ccache nasm gettext-tools pkg-config ccache zip sfml2-devel ninja"
tools="make cmake ccache nasm gettext-tools pkg-config ccache zip ninja"
libs="gcc gcc-c++ libSDL2-devel wxWidgets-3_0-devel openal-soft-devel" # ffmpeg-devel
# ffmpeg requires packman repos
libs="gcc gcc-c++ libSDL2-devel wxGTK3-3_2-devel openal-soft-devel ffmpeg-7-libavcodec-devel ffmpeg-7-libavdevice-devel ffmpeg-7-libavfilter-devel ffmpeg-7-libavformat-devel ffmpeg-7-libavutil-devel ffmpeg-7-libpostproc-devel ffmpeg-7-libswresample-devel ffmpeg-7-libswscale-devel"
if [ "$target" = m32 ]; then
libs=$(echo "$libs" | sed -E 's/([^ ]) ([^ ])/\1-32bit \2/g; s/$/-32bit/;')
error '32 bit cross builds are no longer supported on OpenSUSE'
fi
check sudo zypper in -y $tools $libs
@@ -868,7 +854,7 @@ archlinux_installdeps() {
$pacman -Q gtk3-classic >/dev/null 2>&1 && gtk=gtk3-classic
libs="zlib mesa gettext sdl2 wxgtk3 $gtk sfml openal"
libs="zlib mesa gettext sdl2 wxgtk3 $gtk openal"
[ -n "$ENABLE_FFMPEG" ] && libs="$libs ffmpeg"
@@ -884,7 +870,7 @@ archlinux_installdeps() {
else
# try to build 32 bit binaries
# lib32-sfml and lib32-ffmpeg are in AUR
# lib32-ffmpeg is in AUR
archlinux_require_yaourt
# enable multilib repos if not enabled
@@ -978,8 +964,6 @@ EOF
# get the necessary win32 headers
git submodule update --init --remote --recursive
warning 'SFML is required for LINK support, the SFML package in AUR is currently broken, if you want LINK support you will need to install it manually'
fi
build_instructions
@@ -1042,13 +1026,12 @@ solus_installdeps() {
done
else
# no 32bit versions of these
set -- "$@" SFML-devel ffmpeg-devel
set -- "$@" ffmpeg-devel
fi
check sudo eopkg -y install "$@"
if [ -n "$amd64" -a "$target" = m32 ]; then
warning 'SFML is required for LINK support, there is no 32 bit SFML package in Solus currently, if you want LINK support you will need to install it manually'
warning 'ffmpeg is required for game recording, there is no 32 bit ffmpeg package in Solus currently, you may wish to install it manually'
fi
@@ -1070,7 +1053,6 @@ gentoo_installdeps() {
dev-util/ccache \
sys-devel/binutils \
media-libs/libsdl2 \
media-libs/libsfml \
media-libs/openal \
x11-libs/wxGTK:$wx_slot \
sys-libs/zlib \
@@ -1088,7 +1070,7 @@ gentoo_installdeps() {
alpine_installdeps() {
installing
check sudo apk add cmake ninja g++ ccache nasm gettext-dev zlib-dev mesa-dev sdl2-dev glu-dev sfml-dev wxwidgets-dev gtk+3.0-dev zip
check sudo apk add cmake ninja g++ ccache nasm gettext-dev zlib-dev mesa-dev sdl2-dev glu-dev wxwidgets-dev gtk+3.0-dev zip
build_instructions
}
@@ -1118,9 +1100,12 @@ windows_installdeps() {
*i686*)
pkgs="$pkgs nasm"
;;
*)
pkgs="$pkgs FAudio"
;;
esac
pkgs="$pkgs SDL2 sfml FAudio wxWidgets3.2 zlib binutils cmake crt-git headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb ccache openal"
pkgs="$pkgs SDL2 wxWidgets3.2 zlib binutils cmake crt-git headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb ccache openal"
case "$target" in
*x86_64)
@@ -1192,15 +1177,10 @@ brew_installdeps() {
check brew -v update
brews="nasm cmake ccache gettext pkg-config sdl2 wxwidgets faudio ccache ninja zlib"
brews="nasm cmake ccache gettext libtiff pkg-config sdl2 wxwidgets faudio ccache ninja zlib"
[ -n "$ENABLE_FFMPEG" ] && brews="$brews ffmpeg"
# sfml brew currently broken in the travis mac environment
# if [ -z "$TRAVIS" ]; then
brews="$brews sfml"
# fi
# This is necessary for the GitHub Actions CI:
brew -v install python
brew link --overwrite python
@@ -1223,7 +1203,7 @@ macports_installdeps() {
check sudo port -v selfupdate
ports="cmake ccache nasm gettext pkgconfig libsdl2 sfml wxWidgets-3.0 libiconv ninja"
ports="cmake ccache nasm gettext pkgconfig libsdl2 wxWidgets-3.0 libiconv ninja"
[ -n "$ENABLE_FFMPEG" ] && ports="$ports ffmpeg"
@@ -1239,7 +1219,7 @@ fink_installdeps() {
check sudo fink -vy selfupdate
pkgs="cmake ccache nasm libgettext8-dev gettext-tools pkgconfig sdl2 wxwidgets300-osxcocoa libiconv-dev sfml24-dev ccache ninja"
pkgs="cmake ccache nasm libgettext8-dev gettext-tools pkgconfig sdl2 wxwidgets300-osxcocoa libiconv-dev ccache ninja"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,8 +19,6 @@ parts:
cmake-generator: Ninja
stage-packages:
- libsdl2-2.0-0
- libsfml-network2.5
- libsfml-system2.5
- libnotify4
- libsm6
- libopenal1
@@ -46,7 +44,6 @@ parts:
- zip
- libnotify-dev
- libsdl2-dev
- libsfml-dev
- libgtk-3-dev
- libopenal-dev
- libwxgtk3.0-gtk3-dev

View File

@@ -1,5 +1,13 @@
add_library(vbam-components-filters OBJECT)
unset(extra_src)
if(WINXP)
list(APPEND extra_src
${CMAKE_SOURCE_DIR}/third_party/quake3-sqrt/quake3-sqrt.h
)
target_include_directories(vbam-components-filters PRIVATE ${CMAKE_SOURCE_DIR}/third_party/quake3-sqrt)
endif()
target_sources(vbam-components-filters
PRIVATE
internal/2xSaI.cpp
@@ -17,6 +25,7 @@ target_sources(vbam-components-filters
internal/xBRZ/xbrz_config.h
internal/xBRZ/xbrz_tools.h
internal/xbrzfilter.cpp
${extra_src}
PUBLIC
filters.h

View File

@@ -21,6 +21,10 @@
#include <cmath> //std::sqrt
#include "xbrz_tools.h"
#ifdef WINXP
#include "quake3-sqrt.h"
#endif
// some gcc versions lie about having this C++17 feature
#define static_assert(x) static_assert(x, "assertion failed")
@@ -66,7 +70,9 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c
inline double fastSqrt(double n)
{
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__x86_64__) || defined(__i386__))
#ifdef WINXP
return quake3_sqrt((float)n);
#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__x86_64__) || defined(__i386__))
__asm__ ("fsqrt" : "+t" (n));
return n;
#elif defined(_MSC_VER) && defined(_M_IX86)

View File

@@ -136,3 +136,5 @@ if(ENABLE_LINK)
PRIVATE ${NLS_LIBS}
)
endif()
add_subdirectory(test)

View File

@@ -35,6 +35,7 @@ target_sources(vbam-core-base
version.cpp
PUBLIC
check.h
array.h
file_util.h
image_util.h
@@ -59,3 +60,5 @@ target_link_libraries(vbam-core-base
PRIVATE vbam-fex stb-image
PUBLIC ${ZLIB_LIBRARY}
)
add_subdirectory(test)

58
src/core/base/check.h Normal file
View File

@@ -0,0 +1,58 @@
#ifndef VBAM_CORE_BASE_CHECK_H_
#define VBAM_CORE_BASE_CHECK_H_
// This header defines a number of macros for checking conditions and crashing
// the program if they are not met.
// * VBAM_CHECK(condition) - crashes the program if the condition is not met.
// * VBAM_NOTREACHED() - crashes the program if this line of code is reached.
// In release builds, this macro also tells the compiler that this code path
// is unreachable, which can help the compiler generate better code.
// * VBAM_STRINGIFY(x) - converts the argument to a string literal.
// While a number of other macros are defined in this file, they are not
// intended for general use and should be avoided.
#if defined(__GNUC__) || defined(__clang__)
// GCC/Clang.
#define VBAM_IMMEDIATE_CRASH_DETAIL() __builtin_trap()
#define VBAM_INTRINSIC_UNREACHABLE_DETAIL() __builtin_unreachable()
#elif defined(_MSC_VER) // defined(__GNUC__) || defined(__clang__)
// MSVC.
#define VBAM_IMMEDIATE_CRASH_DETAIL() __debugbreak()
#define VBAM_INTRINSIC_UNREACHABLE_DETAIL() __assume(0)
#else // defined(__GNUC__) || defined(__clang__)
#error "Unsupported compiler"
#endif // defined(__GNUC__) || defined(__clang__)
#define VBAM_STRINGIFY_DETAIL(x) #x
#define VBAM_STRINGIFY(x) VBAM_STRINGIFY_DETAIL(x)
#define VBAM_REQUIRE_SEMICOLON_DETAIL() \
static_assert(true, "Require a semicolon after macros invocation.")
#define VBAM_CHECK(condition) \
if (!(condition)) { \
fputs("CHECK failed at " __FILE__ ":" VBAM_STRINGIFY(__LINE__) ": " #condition "\n", \
stderr); \
VBAM_IMMEDIATE_CRASH_DETAIL(); \
} \
VBAM_REQUIRE_SEMICOLON_DETAIL()
#if defined(DEBUG)
#define VBAM_NOTREACHED() \
fputs("NOTREACHED code reached at " __FILE__ ":" VBAM_STRINGIFY(__LINE__) "\n", stderr); \
VBAM_IMMEDIATE_CRASH_DETAIL()
#else // defined(DEBUG)
#define VBAM_NOTREACHED() VBAM_INTRINSIC_UNREACHABLE_DETAIL()
#endif // defined(DEBUG)
#endif // VBAM_CORE_BASE_CHECK_H_

View File

@@ -59,6 +59,7 @@ extern struct CoreOptions {
bool speedHack = false;
bool speedup = false;
bool speedup_throttle_frame_skip = false;
bool speedup_mute = true;
int cheatsEnabled = 1;
int cpuDisableSfx = 0;
int cpuSaveType = 0;
@@ -69,7 +70,7 @@ extern struct CoreOptions {
int skipSaveGameBattery = 1;
int skipSaveGameCheats = 0;
int useBios = 0;
int winGbPrinterEnabled = 1;
int gbPrinterEnabled = 0;
uint32_t speedup_throttle = 100;
uint32_t speedup_frame_skip = 9;
uint32_t throttle = 100;
@@ -125,4 +126,4 @@ extern int systemSpeed;
#define SYSTEM_SAVE_UPDATED 30
#define SYSTEM_SAVE_NOT_UPDATED 0
#endif // VBAM_CORE_BASE_SYSTEM_H_
#endif // VBAM_CORE_BASE_SYSTEM_H_

View File

@@ -0,0 +1,12 @@
# This defines the `vbam-core-base-test` library.
if(NOT BUILD_TESTING)
return()
endif()
add_library(vbam-core-base-test
INTERFACE
notreached.h)
target_link_libraries(vbam-core-base-test
INTERFACE GTest::gtest)

View File

@@ -0,0 +1,22 @@
#ifndef VBAM_CORE_BASE_TEST_NOTREACHED_H_
#define VBAM_CORE_BASE_TEST_NOTREACHED_H_
#include <gtest/gtest.h>
#if defined(DEBUG)
#define VBAM_EXPECT_NOTREACHED(statement) EXPECT_DEATH(statement, "NOTREACHED")
#else // defined(DEBUG)
// There is no way to test this in release builds as the compiler might optimize
// this code path away. Eat the statement to avoid unused variable warnings.
#define VBAM_EXPECT_NOTREACHED(statement) \
if constexpr (false) { \
statement; \
} \
static_assert(true, "")
#endif // defined(DEBUG)
#endif // VBAM_CORE_BASE_TEST_NOTREACHED_H_

View File

@@ -1,13 +1,13 @@
#include "core/gb/gb.h"
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include "core/base/check.h"
#include "core/base/file_util.h"
#include "core/base/message.h"
#include "core/base/sizes.h"
@@ -291,8 +291,7 @@ bool gbInitializeRom(size_t romSize) {
switch (g_gbCartData.validity()) {
case gbCartData::Validity::kValid:
case gbCartData::Validity::kUninitialized:
// Unreachable.
assert(false);
VBAM_NOTREACHED();
break;
case gbCartData::Validity::kSizeTooSmall:
systemMessage(MSG_UNSUPPORTED_ROM_SIZE,
@@ -1417,7 +1416,7 @@ void gbWriteMemory(uint16_t address, uint8_t value)
EmuReseted = false;
gbMemory[0xff02] = value;
if (gbSerialOn && (GetLinkMode() == LINK_GAMEBOY_IPC || GetLinkMode() == LINK_GAMEBOY_SOCKET
|| GetLinkMode() == LINK_DISCONNECTED || coreOptions.winGbPrinterEnabled)) {
|| GetLinkMode() == LINK_DISCONNECTED || coreOptions.gbPrinterEnabled)) {
gbSerialTicks = GBSERIAL_CLOCK_TICKS;
@@ -2970,8 +2969,13 @@ void gbReset()
inBios = true;
} else if (gbHardware & 0xa) {
// Set compatibility mode if it is a DMG ROM.
const uint8_t gbcFlag = g_gbCartData.SupportsCGB() ? 0x80 : 0x00;
gbMemory[0xff6c] = 0xfe | gbcFlag;
if (g_gbCartData.SupportsCGB()) {
// OPRI with bit 0 set to 0 = CGB mode.
gbMemory[0xff6c] = 0xfe;
} else {
// OPRI with bit 0 set to 1 = DMG mode.
gbMemory[0xff6c] = 0xff;
}
}
gbLine99Ticks = 1;

View File

@@ -2,8 +2,8 @@
#include <algorithm>
#include <array>
#include <cassert>
#include "core/base/check.h"
#include "core/base/sizes.h"
namespace {
@@ -62,7 +62,7 @@ char byte_to_char(uint8_t byte) {
} else if (byte < 16) {
return 'A' + (byte - 10);
} else {
assert(false);
VBAM_NOTREACHED();
return '\0';
}
}
@@ -98,7 +98,7 @@ bool is_valid_manufacturer_code(const std::string& manufacturer_code) {
constexpr size_t kHeaderGlobalChecksumAdress = 0x14e;
uint16_t get_rom_checksum(const uint8_t* romData, size_t romDataSize) {
assert(romData);
VBAM_CHECK(romData);
uint16_t checksum = 0;
for (size_t i = 0; i < romDataSize; i++) {
@@ -160,7 +160,7 @@ constexpr size_t kHeaderChecksumEndAdress = 0x14c;
} // namespace
gbCartData::gbCartData(const uint8_t* romData, size_t romDataSize) {
assert(romData);
VBAM_CHECK(romData);
if (romDataSize < sizeof(gbRomHeader)) {
validity_ = Validity::kSizeTooSmall;

View File

@@ -481,7 +481,7 @@ void gbaUpdateRomSize(int size)
if (size > romSize) {
romSize = size;
uint8_t* tmp = (uint8_t*)realloc(g_rom, SIZE_ROM);
uint8_t* tmp = (uint8_t*)realloc(g_rom, romSize);
g_rom = tmp;
uint16_t* temp = (uint16_t*)(g_rom + ((romSize + 1) & ~1));
@@ -3845,6 +3845,8 @@ void CPULoop(int ticks)
bool turbo_button_pressed = (joy >> 10) & 1;
#ifndef __LIBRETRO__
static uint32_t last_throttle;
static bool current_volume_saved = false;
static float current_volume;
if (turbo_button_pressed) {
if (coreOptions.speedup_frame_skip)
@@ -3859,10 +3861,23 @@ void CPULoop(int ticks)
if (coreOptions.speedup_throttle_frame_skip)
framesToSkip += static_cast<int>(std::ceil(double(coreOptions.speedup_throttle) / 100.0) - 1);
}
if (coreOptions.speedup_mute && !current_volume_saved) {
current_volume = soundGetVolume();
current_volume_saved = true;
soundSetVolume(0);
}
}
else if (speedup_throttle_set) {
soundSetThrottle(DowncastU16(last_throttle));
speedup_throttle_set = false;
else {
if (current_volume_saved) {
soundSetVolume(current_volume);
current_volume_saved = false;
}
if (speedup_throttle_set) {
soundSetThrottle(DowncastU16(last_throttle));
speedup_throttle_set = false;
}
}
#else
if (turbo_button_pressed)

View File

@@ -1822,6 +1822,16 @@ static INSN_REGPARM void thumbE0(uint32_t opcode)
busPrefetchCount = 0;
}
static INSN_REGPARM void thumbE8(uint32_t opcode)
{
#ifdef GBA_LOGGING
// TODO: This is (erroneously) used by some Wii U VC ROMs. We should have a configuration
// toggle to enable the correct hardware behavior, which would be to call CPUUndefinedException.
if (systemVerbose & VERBOSE_UNDEFINED)
log("Undefined Wii U THUMB instruction %04x at %08x (ignored)\n", opcode, armNextPC - 2);
#endif
}
// BLL #offset (forward)
static INSN_REGPARM void thumbF0(uint32_t opcode)
{
@@ -1979,7 +1989,7 @@ static insnfunc_t thumbInsnTable[1024] = {
thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0,
thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0,
thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0, thumbE0,
thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, // E8
thumbE8, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, // E8
thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI,
thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI,
thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI, thumbUI,

View File

@@ -26,7 +26,7 @@
#include <cstring>
#include <string>
#include <SFML/Network.hpp>
#include "SFML/Network.hpp"
#include <libintl.h>
#define _(x) gettext(x)
@@ -41,17 +41,22 @@
#define snprintf _snprintf
#endif
#ifdef UPDATE_REG
#undef UPDATE_REG
#endif
#define UPDATE_REG(address, value) WRITE16LE(((uint16_t*)&g_ioMem[address]), value)
static int vbaid = 0;
const char* MakeInstanceFilename(const char* Input)
{
if (vbaid == 0)
if (vbaid == 0) {
return Input;
}
static char* result = NULL;
if (result != NULL)
if (result != NULL) {
free(result);
}
result = (char*)malloc(strlen(Input) + 3);
char* p = strrchr((char*)Input, '.');
@@ -270,7 +275,7 @@ class RFUServer {
public:
sf::TcpSocket tcpsocket[5];
sf::IpAddress udpaddr[5];
sf::IpAddress udpaddr[5] = { sf::IpAddress{0}, sf::IpAddress{0}, sf::IpAddress{0}, sf::IpAddress{0}, sf::IpAddress{0} };
RFUServer(void);
sf::Packet& Serialize(sf::Packet& packet, int slave);
void DeSerialize(sf::Packet& packet, int slave);
@@ -283,7 +288,7 @@ class RFUClient {
int numbytes;
public:
sf::IpAddress serveraddr;
sf::IpAddress serveraddr{0};
unsigned short serverport;
bool transferring;
RFUClient(void);
@@ -392,7 +397,7 @@ enum {
typedef struct {
sf::TcpSocket tcpsocket;
sf::TcpListener tcplistener;
int numslaves;
uint16_t numslaves;
int connectedSlaves;
int type;
bool server;
@@ -412,7 +417,7 @@ class CableServer {
public:
sf::TcpSocket tcpsocket[4];
sf::IpAddress udpaddr[4];
sf::IpAddress udpaddr[4] = { sf::IpAddress{0}, sf::IpAddress{0}, sf::IpAddress{0}, sf::IpAddress{0} };
CableServer(void);
void Send(void);
void Recv(void);
@@ -430,7 +435,7 @@ class CableClient {
int numbytes;
public:
sf::IpAddress serveraddr;
sf::IpAddress serveraddr{0};
unsigned short serverport;
bool transferring;
CableClient(void);
@@ -520,33 +525,48 @@ LinkMode GetLinkMode()
return LINK_DISCONNECTED;
}
void GetLinkServerHost(char* const host, size_t size)
bool GetLinkServerHost(char* const host, size_t size)
{
if (host == NULL || size == 0)
return;
if (host == NULL || size == 0) {
return false;
}
host[0] = '\0';
if (linkDriver && linkDriver->mode == LINK_GAMECUBE_DOLPHIN)
if (linkDriver && linkDriver->mode == LINK_GAMECUBE_DOLPHIN) {
strncpy(host, joybusHostAddr.toString().c_str(), size);
else if (lanlink.server) {
if (IP_LINK_BIND_ADDRESS == "*")
strncpy(host, sf::IpAddress::getLocalAddress().toString().c_str(), size);
else
} else if (lanlink.server) {
if (IP_LINK_BIND_ADDRESS == "*") {
auto local_addr = sf::IpAddress::getLocalAddress();
if (local_addr) {
strncpy(host, local_addr.value().toString().c_str(), size);
} else {
return false;
}
} else {
strncpy(host, IP_LINK_BIND_ADDRESS.c_str(), size);
}
}
else
else {
strncpy(host, lc.serveraddr.toString().c_str(), size);
}
return true;
}
bool SetLinkServerHost(const char* host)
{
sf::IpAddress addr = sf::IpAddress(host);
sf::IpAddress addr{0};
auto resolved = sf::IpAddress::resolve(host);
if (!resolved) {
return false;
}
addr = resolved.value();
lc.serveraddr = addr;
joybusHostAddr = addr;
return addr != sf::IpAddress::None;
return true;
}
int GetLinkPlayerId()
@@ -1044,11 +1064,13 @@ static ConnectionState InitSocket()
{
linkid = 0;
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++) {
cable_data[i] = 0xffff;
}
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++) {
cable_gb_data[i] = 0xff;
}
if (lanlink.server) {
lanlink.connectedSlaves = 0;
@@ -1057,26 +1079,33 @@ static ConnectionState InitSocket()
// too bad Listen() doesn't take an address as well
// then again, old code used INADDR_ANY anyway
sf::IpAddress bind_ip = IP_LINK_BIND_ADDRESS == "*" ? sf::IpAddress::Any : IP_LINK_BIND_ADDRESS;
sf::IpAddress bind_ip{0};
if (lanlink.tcplistener.listen(IP_LINK_PORT, bind_ip) == sf::Socket::Error)
if (IP_LINK_BIND_ADDRESS != "*") {
auto resolved = sf::IpAddress::resolve(IP_LINK_BIND_ADDRESS);
if (resolved) {
bind_ip = resolved.value();
} else {
return LINK_ERROR;
}
}
if (lanlink.tcplistener.listen(IP_LINK_PORT, bind_ip) == sf::Socket::Status::Error) {
// Note: old code closed socket & retried once on bind failure
return LINK_ERROR; // FIXME: error code?
else
} else {
return LINK_NEEDS_UPDATE;
}
} else {
lc.serverport = IP_LINK_PORT;
if (lc.serveraddr == sf::IpAddress::None) {
lanlink.tcpsocket.setBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport);
if (status == sf::Socket::Status::Error || status == sf::Socket::Status::Disconnected) {
return LINK_ERROR;
} else {
lanlink.tcpsocket.setBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected)
return LINK_ERROR;
else
return LINK_NEEDS_UPDATE;
return LINK_NEEDS_UPDATE;
}
}
}
@@ -1090,11 +1119,11 @@ static ConnectionState ConnectUpdateSocket(char* const message, size_t size)
fdset.add(lanlink.tcplistener);
if (fdset.wait(sf::milliseconds(150))) {
int nextSlave = lanlink.connectedSlaves + 1;
uint16_t nextSlave = lanlink.connectedSlaves + 1;
sf::Socket::Status st = lanlink.tcplistener.accept(ls.tcpsocket[nextSlave]);
if (st == sf::Socket::Error) {
if (st == sf::Socket::Status::Error) {
for (int j = 1; j < nextSlave; j++)
ls.tcpsocket[j].disconnect();
@@ -1102,8 +1131,7 @@ static ConnectionState ConnectUpdateSocket(char* const message, size_t size)
newState = LINK_ERROR;
} else {
sf::Packet packet;
packet << static_cast<sf::Uint16>(nextSlave)
<< static_cast<sf::Uint16>(lanlink.numslaves);
packet << nextSlave << lanlink.numslaves;
ls.tcpsocket[nextSlave].send(packet);
@@ -1129,13 +1157,13 @@ static ConnectionState ConnectUpdateSocket(char* const message, size_t size)
sf::Packet packet;
sf::Socket::Status status = lanlink.tcpsocket.receive(packet);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected) {
if (status == sf::Socket::Status::Error || status == sf::Socket::Status::Disconnected) {
snprintf(message, size, N_("Network error."));
newState = LINK_ERROR;
} else if (status == sf::Socket::Done) {
} else if (status == sf::Socket::Status::Done) {
if (linkid == 0) {
sf::Uint16 receivedId, receivedSlaves;
uint16_t receivedId, receivedSlaves;
packet >> receivedId >> receivedSlaves;
if (packet) {
@@ -1540,7 +1568,7 @@ void RFUServer::Recv(void)
sf::Packet packet;
tcpsocket[i + 1].setBlocking(false);
sf::Socket::Status status = tcpsocket[i + 1].receive(packet);
if (status == sf::Socket::Disconnected) {
if (status == sf::Socket::Status::Disconnected) {
char message[30];
sprintf(message, _("Player %d disconnected."), i + 1);
systemScreenMessage(message);
@@ -1650,7 +1678,7 @@ void RFUClient::Recv(void)
}
sf::Packet packet;
sf::Socket::Status status = lanlink.tcpsocket.receive(packet);
if (status == sf::Socket::Disconnected) {
if (status == sf::Socket::Status::Disconnected) {
systemScreenMessage(_("Server disconnected."));
CloseLink();
return;
@@ -1671,7 +1699,7 @@ static ConnectionState ConnectUpdateRFUSocket(char* const message, size_t size)
sf::Socket::Status st = lanlink.tcplistener.accept(rfu_server.tcpsocket[nextSlave]);
if (st == sf::Socket::Error) {
if (st == sf::Socket::Status::Error) {
for (int j = 1; j < nextSlave; j++)
rfu_server.tcpsocket[j].disconnect();
@@ -1679,8 +1707,7 @@ static ConnectionState ConnectUpdateRFUSocket(char* const message, size_t size)
newState = LINK_ERROR;
} else {
sf::Packet packet;
packet << static_cast<sf::Uint16>(nextSlave)
<< static_cast<sf::Uint16>(lanlink.numslaves);
packet << nextSlave << lanlink.numslaves;
rfu_server.tcpsocket[nextSlave].send(packet);
@@ -1707,13 +1734,13 @@ static ConnectionState ConnectUpdateRFUSocket(char* const message, size_t size)
lanlink.tcpsocket.setBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.receive(packet);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected) {
if (status == sf::Socket::Status::Error || status == sf::Socket::Status::Disconnected) {
snprintf(message, size, N_("Network error."));
newState = LINK_ERROR;
} else if (status == sf::Socket::Done) {
} else if (status == sf::Socket::Status::Done) {
if (linkid == 0) {
sf::Uint16 receivedId, receivedSlaves;
uint16_t receivedId, receivedSlaves;
packet >> receivedId >> receivedSlaves;
if (packet) {

View File

@@ -86,8 +86,9 @@ extern bool SetLinkServerHost(const char* host);
* If in lan client mode, returns the IP adress of the host to connect to
* If in gamecube mode, returns the IP adress of the dolphin host
*
* @return false on error
*/
extern void GetLinkServerHost(char* const host, size_t size);
extern bool GetLinkServerHost(char* const host, size_t size);
/**
* Set the value in milliseconds of the timeout after which a connection is

View File

@@ -8,10 +8,7 @@
GBASockClient::GBASockClient(sf::IpAddress _server_addr)
{
if (_server_addr == sf::IpAddress::None)
server_addr = sf::IpAddress::getPublicAddress();
else
server_addr = _server_addr;
server_addr = _server_addr;
client.connect(server_addr, 0xd6ba);
client.setBlocking(false);
@@ -44,8 +41,9 @@ void GBASockClient::Send(std::vector<char> data)
// Returns cmd for convenience
char GBASockClient::ReceiveCmd(char* data_in, bool block)
{
if (IsDisconnected())
if (IsDisconnected()) {
return data_in[0];
}
std::size_t num_received = 0;
if (block || clock_sync == 0) {
@@ -53,8 +51,9 @@ char GBASockClient::ReceiveCmd(char* data_in, bool block)
Selector.add(client);
Selector.wait(sf::seconds(6));
}
if (client.receive(data_in, 5, num_received) == sf::Socket::Disconnected)
if (client.receive(data_in, 5, num_received) == sf::Socket::Status::Disconnected) {
Disconnect();
}
return data_in[0];
}
@@ -67,13 +66,15 @@ void GBASockClient::ReceiveClock(bool block)
char sync_ticks[4] = { 0, 0, 0, 0 };
std::size_t num_received = 0;
if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Status::Disconnected) {
Disconnect();
}
if (num_received == 4) {
clock_sync_ticks = 0;
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++) {
clock_sync_ticks |= (uint8_t)(sync_ticks[i]) << ((3 - i) * 8);
}
clock_sync += clock_sync_ticks;
}
}

View File

@@ -7,7 +7,7 @@
#include <cstdint>
#include <SFML/Network.hpp>
#include "SFML/Network.hpp"
class GBASockClient {
public:
@@ -24,7 +24,7 @@ public:
bool IsDisconnected();
private:
sf::IpAddress server_addr;
sf::IpAddress server_addr{0};
sf::TcpSocket client;
sf::TcpSocket clock_client;

View File

@@ -0,0 +1,13 @@
# This defines the `vbam-core-fake` library, which is used for providing a fake
# implementation of the core library for testing purposes.
if(NOT BUILD_TESTING)
return()
endif()
add_library(vbam-core-fake OBJECT)
target_sources(vbam-core-fake
PRIVATE
fake_core.cpp
)

View File

@@ -0,0 +1,94 @@
#include "core/base/system.h"
void systemMessage(int, const char*, ...) {}
void log(const char*, ...) {}
bool systemPauseOnFrame() {
return false;
}
void systemGbPrint(uint8_t*, int, int, int, int, int) {}
void systemScreenCapture(int) {}
void systemDrawScreen() {}
void systemSendScreen() {}
bool systemReadJoypads() {
return false;
}
uint32_t systemReadJoypad(int) {
return 0;
}
uint32_t systemGetClock() {
return 0;
}
void systemSetTitle(const char*) {}
std::unique_ptr<SoundDriver> systemSoundInit() {
return nullptr;
}
void systemOnWriteDataToSoundBuffer(const uint16_t* /*finalWave*/, int /*length*/) {}
void systemOnSoundShutdown() {}
void systemScreenMessage(const char*) {}
void systemUpdateMotionSensor() {}
int systemGetSensorX() {
return 0;
}
int systemGetSensorY() {
return 0;
}
int systemGetSensorZ() {
return 0;
}
uint8_t systemGetSensorDarkness() {
return 0;
}
void systemCartridgeRumble(bool) {}
void systemPossibleCartridgeRumble(bool) {}
void updateRumbleFrame() {}
bool systemCanChangeSoundQuality() {
return false;
}
void systemShowSpeed(int) {}
void system10Frames() {}
void systemFrame() {}
void systemGbBorderOn() {}
void (*dbgOutput)(const char* s, uint32_t addr);
void (*dbgSignal)(int sig, int number);
uint16_t systemColorMap16[0x10000];
uint32_t systemColorMap32[0x10000];
uint16_t systemGbPalette[24];
int systemRedShift;
int systemGreenShift;
int systemBlueShift;
int systemColorDepth;
int systemVerbose;
int systemFrameSkip;
int systemSaveUpdateCounter;
int systemSpeed;
int emulating = 0;

4
src/gb-over.ini Normal file
View File

@@ -0,0 +1,4 @@
# Game Boy Overrrides
[ALLEY WAY]
gbPrinter = 0

View File

@@ -79,7 +79,7 @@ else ifeq ($(platform), classic_armv7_a7)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,--no-undefined -fPIC
CFLAGS += -Ofast \
CFLAGS += -O3 -ffast-math \
-flto=4 -fwhole-program -fuse-linker-plugin \
-fdata-sections -ffunction-sections -Wl,--gc-sections \
-fno-stack-protector -fno-ident -fomit-frame-pointer \
@@ -112,7 +112,7 @@ else ifeq ($(platform), classic_armv8_a35)
fpic := -fPIC
SHARED := -shared
TILED_RENDERING=1
CFLAGS += -Ofast \
CFLAGS += -O3 -ffast-math \
-flto=4 -fwhole-program -fuse-linker-plugin \
-fdata-sections -ffunction-sections -Wl,--gc-sections \
-fno-stack-protector -fno-ident -fomit-frame-pointer \
@@ -311,7 +311,7 @@ else ifeq ($(platform), wiiu)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
ENDIANNESS_DEFINES += -DMSB_FIRST -DWORDS_BIGENDIAN=1
PLATFORM_DEFINES += -DGEKKO -DWIIU -DHW_RVL -mwup -mcpu=750 -meabi -mhard-float -D__ppc__
PLATFORM_DEFINES += -DGEKKO -DWIIU -DHW_WUP -mcpu=750 -meabi -mhard-float -D__ppc__
PLATFORM_DEFINES += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
STATIC_LINKING=1
TILED_RENDERING=1
@@ -322,17 +322,18 @@ else ifeq ($(platform), libnx)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DHAVE_THREADS=1
CFLAGS := $(DEFINES) -g -O3 \
-fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
-fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
CFLAGS += $(INCDIRS)
CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CFLAGS += -std=gnu11
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions
STATIC_LINKING=1
# Nintendo Switch (libtransistor)
# Nintendo Switch (devkitpro)
else ifeq ($(platform), switch)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
include $(LIBTRANSISTOR_HOME)/libtransistor.mk
CC = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-gcc$(EXE_EXT)
CXX = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-g++$(EXE_EXT)
AR = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-ar$(EXE_EXT)
STATIC_LINKING=1
TILED_RENDERING=1

View File

@@ -1,4 +1,3 @@
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
@@ -12,6 +11,7 @@
#include "components/filters_agb/filters_agb.h"
#include "components/filters_interframe/interframe.h"
#include "core/base/check.h"
#include "core/base/system.h"
#include "core/base/file_util.h"
#include "core/base/sizes.h"
@@ -177,8 +177,7 @@ static void* gb_rtcdata_prt(void)
case gbCartData::MapperType::kGameGenie:
case gbCartData::MapperType::kGameShark:
case gbCartData::MapperType::kUnknown:
// Unreachable.
assert(false);
VBAM_NOTREACHED();
return nullptr;
}
return nullptr;
@@ -205,8 +204,7 @@ static size_t gb_rtcdata_size(void)
case gbCartData::MapperType::kGameGenie:
case gbCartData::MapperType::kGameShark:
case gbCartData::MapperType::kUnknown:
// Unreachable.
assert(false);
VBAM_NOTREACHED();
break;
}
return 0;
@@ -272,8 +270,7 @@ static void gbInitRTC(void)
case gbCartData::MapperType::kGameGenie:
case gbCartData::MapperType::kGameShark:
case gbCartData::MapperType::kUnknown:
// Unreachable.
assert(false);
VBAM_NOTREACHED();
break;
}
}
@@ -593,7 +590,7 @@ void retro_init(void)
coreOptions.parseDebug = true;
coreOptions.cheatsEnabled = 0;
coreOptions.skipSaveGameBattery = 0;
coreOptions.winGbPrinterEnabled = 0;
coreOptions.gbPrinterEnabled = 0;
struct retro_log_callback log;
struct retro_rumble_interface rumble;
@@ -1456,8 +1453,7 @@ void retro_run(void)
case gbCartData::MapperType::kGameGenie:
case gbCartData::MapperType::kGameShark:
case gbCartData::MapperType::kUnknown:
// Unreachable.
assert(false);
VBAM_NOTREACHED();
break;
}
/* Initialize RTC using local time if needed */

View File

@@ -31,8 +31,8 @@ if(MSVC)
# We should probably use an external library for this.
target_sources(vbam
PRIVATE
${CMAKE_SOURCE_DIR}/dependencies/msvc/getopt.c
${CMAKE_SOURCE_DIR}/dependencies/msvc/getopt.h
${CMAKE_SOURCE_DIR}/win32-deps/msvc/getopt.c
${CMAKE_SOURCE_DIR}/win32-deps/msvc/getopt.h
)
endif()
@@ -61,7 +61,7 @@ endif()
if(ENABLE_LIRC)
target_link_libraries(vbam lirc_client)
target_compile_definitions(vbam VBAM_ENABLE_LIRC)
target_compile_definitions(vbam PUBLIC VBAM_ENABLE_LIRC)
endif()
if(WIN32)
@@ -71,15 +71,15 @@ endif()
# Installation scripts.
install(
PROGRAMS ${PROJECT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_CURRENT_LIST_DIR}/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
RENAME vbam.cfg
)
if(UNIX)
# man pages.
install(FILES ${CMAKE_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
install(FILES ${CMAKE_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6)
endif()

View File

@@ -98,7 +98,8 @@ enum named_opts
OPT_SOUND_FILTERING,
OPT_SPEEDUP_THROTTLE,
OPT_SPEEDUP_FRAME_SKIP,
OPT_NO_SPEEDUP_THROTTLE_FRAME_SKIP
OPT_NO_SPEEDUP_THROTTLE_FRAME_SKIP,
OPT_NO_SPEEDUP_MUTE
};
#define SOUND_MAX_VOLUME 2.0
@@ -188,7 +189,7 @@ struct option argOptions[] = {
{ "gb-emulator-type", required_argument, 0, OPT_GB_EMULATOR_TYPE },
{ "gb-frame-skip", required_argument, 0, OPT_GB_FRAME_SKIP },
{ "gb-palette-option", required_argument, 0, OPT_GB_PALETTE_OPTION },
{ "gb-printer", no_argument, &coreOptions.winGbPrinterEnabled, 1 },
{ "gb-printer", no_argument, &coreOptions.gbPrinterEnabled, 1 },
{ "gdb", required_argument, 0, 'G' },
{ "help", no_argument, &optPrintUsage, 1 },
{ "ifb-filter", required_argument, 0, 'I' },
@@ -232,9 +233,10 @@ struct option argOptions[] = {
{ "speedup-throttle", required_argument, 0, OPT_SPEEDUP_THROTTLE },
{ "speedup-frame-skip", required_argument, 0, OPT_SPEEDUP_FRAME_SKIP },
{ "no-speedup-throttle-frame-skip", no_argument, 0, OPT_NO_SPEEDUP_THROTTLE_FRAME_SKIP },
{ "no-speedup-mute", no_argument, 0, OPT_NO_SPEEDUP_MUTE },
{ "use-bios", no_argument, &coreOptions.useBios, 1 },
{ "verbose", required_argument, 0, 'v' },
{ "win-gb-printer-enabled", no_argument, &coreOptions.winGbPrinterEnabled, 1 },
{ "win-gb-printer-enabled", no_argument, &coreOptions.gbPrinterEnabled, 1 },
{ NULL, no_argument, NULL, 0 }
@@ -347,8 +349,9 @@ void LoadConfig()
coreOptions.speedup_throttle = ReadPref("speedupThrottle", 100);
coreOptions.speedup_frame_skip = ReadPref("speedupFrameSkip", 9);
coreOptions.speedup_throttle_frame_skip = ReadPref("speedupThrottleFrameSkip", 0);
coreOptions.speedup_mute = ReadPref("speedupMute", 1);
coreOptions.useBios = ReadPrefHex("useBiosGBA");
coreOptions.winGbPrinterEnabled = ReadPref("gbPrinter", 0);
coreOptions.gbPrinterEnabled = ReadPref("gbPrinter", 0);
int soundQuality = (ReadPrefHex("soundQuality", 1));
switch (soundQuality) {
@@ -990,6 +993,9 @@ int ReadOpts(int argc, char ** argv)
case OPT_NO_SPEEDUP_THROTTLE_FRAME_SKIP:
coreOptions.speedup_throttle_frame_skip = false;
break;
case OPT_NO_SPEEDUP_MUTE:
coreOptions.speedup_mute = false;
break;
}
}
return op;

View File

@@ -364,6 +364,10 @@ mirroringEnabled=1
saveType=1
mirroringEnabled=1
# Higurashi no Nakukoroni (Japan)
[HGRS]
saveType=2
# Koro Koro Puzzle - Happy Panechu! (Japan)
[KHPJ]
saveType=4

View File

@@ -31,6 +31,8 @@ set(VBAM_WX_COMMON
dialogs/joypad-config.h
dialogs/sound-config.cpp
dialogs/sound-config.h
dialogs/speedup-config.cpp
dialogs/speedup-config.h
drawing.h
extra-translations.cpp
gfxviewers.cpp
@@ -46,33 +48,6 @@ set(VBAM_WX_COMMON
viewsupt.h
wayland.cpp
wayland.h
# from external source with minor modifications
widgets/checkedlistctrl.cpp
widgets/checkedlistctrl.h
widgets/client-data.h
widgets/dpi-support.h
widgets/event-handler-provider.h
widgets/group-check-box.cpp
widgets/group-check-box.h
widgets/keep-on-top-styler.cpp
widgets/keep-on-top-styler.h
widgets/option-validator.cpp
widgets/option-validator.h
widgets/render-plugin.cpp
widgets/render-plugin.h
widgets/user-input-ctrl.cpp
widgets/user-input-ctrl.h
widgets/user-input-event.cpp
widgets/user-input-event.h
widgets/sdl-poller.cpp
widgets/sdl-poller.h
widgets/shortcut-menu-bar.cpp
widgets/shortcut-menu-bar.h
widgets/utils.cpp
widgets/utils.h
widgets/webupdatedef.h
widgets/wxmisc.h
widgets/wxmisc.cpp
wxhead.h
wxlogdebug.h
wxvbam.cpp
@@ -84,6 +59,7 @@ set(VBAM_WX_COMMON
${VBAM_GENERATED_DIR}/wx/builtin-over.h
${VBAM_GENERATED_DIR}/wx/cmdhandlers.h
${VBAM_GENERATED_DIR}/wx/cmd-evtable.h
${VBAM_GENERATED_DIR}/wx/gb-builtin-over.h
)
if(NOT ZIP_PROGRAM)
@@ -166,7 +142,7 @@ endif()
# wxWidgets configuration.
set(wxWidgets_USE_UNICODE ON)
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
endif()
if(VBAM_STATIC)
@@ -177,15 +153,27 @@ unset(wx_find_extra)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(wx_find_extra NO_DEFAULT_PATH)
set(wxWidgets_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/wxwidgets")
find_package(nanosvg)
endif()
set(ENABLE_OPENGL TRUE)
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl ${wx_find_extra})
if(NOT wxWidgets_FOUND)
find_package(wxWidgets COMPONENTS xrc xml html adv net core base ${wx_find_extra} REQUIRED)
target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL)
set(ENABLE_OPENGL FALSE)
endif()
# Fixup wxWidgets paths for vcpkg debug builds.
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(wxWidgets_ROOT_DIR "${wxWidgets_ROOT_DIR}/debug" CACHE INTERNAL "wxWidgets root directory" FORCE)
string(REGEX REPLACE "/lib$" "/debug/lib" wxWidgets_LIB_DIR "${wxWidgets_LIB_DIR}")
set(wxWidgets_LIB_DIR "${wxWidgets_LIB_DIR}" CACHE INTERNAL "wxWidgets library directory" FORCE)
endif()
# Find OpenAL (required).
find_package(OpenAL REQUIRED)
# Workaround of static liblzma not being found on MSYS2.
if(VBAM_STATIC AND MSYS)
unset(cleaned_up_wx_libs)
@@ -207,30 +195,120 @@ foreach(DEF ${wxWidgets_DEFINITIONS})
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${DEF}")
endforeach()
# Sets the wxWidgets dependencies for a given target.
function(configure_wx_deps target)
# Configure common settings for wx-based targets, like linking, include
# directories, compile options, and definitions.
function(configure_wx_target target)
get_target_property(target_type ${target} TYPE)
if (target_type STREQUAL "EXECUTABLE")
target_link_libraries(${target} ${wxWidgets_LIBRARIES})
target_include_directories(${target} PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_compile_options(${target} PRIVATE ${wxWidgets_CXX_FLAGS})
target_compile_definitions(${target} PRIVATE ${wxWidgets_DEFINITIONS})
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
target_compile_definitions(${target} PRIVATE ${wxWidgets_DEFINITIONS_DEBUG})
endif()
if(target_type STREQUAL "EXECUTABLE")
set(target_is_executable TRUE)
else()
target_link_libraries(${target} PUBLIC ${wxWidgets_LIBRARIES})
target_include_directories(${target} PUBLIC ${wxWidgets_INCLUDE_DIRS})
target_compile_options(${target} PUBLIC ${wxWidgets_CXX_FLAGS})
target_compile_definitions(${target} PUBLIC ${wxWidgets_DEFINITIONS})
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
target_compile_definitions(${target} PUBLIC ${wxWidgets_DEFINITIONS_DEBUG})
set(target_is_executable FALSE)
endif()
function(_add_link_libraries)
if(${target_is_executable})
target_link_libraries(${target} ${ARGN})
else()
target_link_libraries(${target} PUBLIC ${ARGN})
endif()
endif()
endfunction()
function(_add_include_directories)
if(${target_is_executable})
target_include_directories(${target} PRIVATE ${ARGN})
else()
target_include_directories(${target} PUBLIC ${ARGN})
endif()
endfunction()
function(_add_compile_options)
if(${target_is_executable})
target_compile_options(${target} PRIVATE ${ARGN})
else()
target_compile_options(${target} PUBLIC ${ARGN})
endif()
endfunction()
function(_add_compile_definitions)
if(${target_is_executable})
target_compile_definitions(${target} PRIVATE ${ARGN})
else()
target_compile_definitions(${target} PUBLIC ${ARGN})
endif()
endfunction()
# Core emulator.
_add_link_libraries(vbam-core)
# Nonstd.
_add_link_libraries(nonstd-lib)
_add_include_directories(${NONSTD_INCLUDE_DIR})
# wxWidgets.
_add_link_libraries(${wxWidgets_LIBRARIES})
_add_include_directories(${wxWidgets_INCLUDE_DIRS})
_add_compile_options(${wxWidgets_CXX_FLAGS})
_add_compile_definitions(${wxWidgets_DEFINITIONS})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
_add_compile_definitions(${wxWidgets_DEFINITIONS_DEBUG})
endif()
# OpenAL.
if(OPENAL_STATIC)
_add_compile_definitions(AL_LIBTYPE_STATIC)
if(WIN32)
list(APPEND OPENAL_LIBRARY avrt)
endif()
endif()
_add_include_directories(${OPENAL_INCLUDE_DIR})
_add_link_libraries(${OPENAL_LIBRARY})
# XAudio2.
if(ENABLE_XAUDIO2)
_add_compile_definitions(VBAM_ENABLE_XAUDIO2)
endif()
# FAudio.
if(ENABLE_FAUDIO)
_add_compile_definitions(VBAM_ENABLE_FAUDIO)
if(MSVC)
_add_link_libraries(FAudio::FAudio)
else()
if(WIN32)
if(MINGW AND VBAM_STATIC)
_add_link_libraries(FAudio.a)
else()
_add_link_libraries(FAudio)
endif()
_add_link_libraries(dxguid uuid winmm ole32 advapi32 user32 mfplat mfreadwrite mfuuid propsys)
else()
_add_link_libraries(FAudio)
endif()
endif()
endif()
# Direct3D.
if(NOT ENABLE_DIRECT3D)
_add_compile_definitions(NO_D3D)
endif()
# SDL2.
_add_link_libraries(${VBAM_SDL2_LIBS})
# OpenGL.
if(ENABLE_OPENGL)
_add_link_libraries(${OPENGL_LIBRARIES})
else()
_add_compile_definitions(NO_OGL)
endif()
endfunction()
# Sub-projects.
add_subdirectory(test)
add_subdirectory(config)
add_subdirectory(widgets)
set(VBAM_ICON visualboyadvance-m.icns)
set(VBAM_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/icons/${VBAM_ICON})
@@ -242,20 +320,17 @@ add_executable(
)
target_sources(visualboyadvance-m PRIVATE ${VBAM_WX_COMMON} ${VBAM_ICON_PATH})
target_include_directories(visualboyadvance-m PRIVATE ${NONSTD_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
target_include_directories(visualboyadvance-m PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(
visualboyadvance-m
nonstd-lib
vbam-core
vbam-components-draw-text
vbam-components-filters
vbam-components-filters-agb
vbam-components-filters-interframe
vbam-components-user-config
vbam-wx-config
${OPENGL_LIBRARIES}
${VBAM_SDL2_LIBS}
vbam-wx-widgets
)
# adjust link command when making a static binary for gcc
@@ -324,21 +399,15 @@ if(WIN32)
# Disable the auto-generated manifest from CMake.
target_link_options(visualboyadvance-m PRIVATE "/MANIFEST:NO")
endif()
# wxWidgets fails to bring in its dependency.
find_library(PCRE_LIB pcre2-16 REQUIRED)
target_link_libraries(visualboyadvance-m ${PCRE_LIB})
endif()
if(APPLE)
target_sources(visualboyadvance-m PRIVATE
macsupport.mm
widgets/dpi-support-mac.mm
)
else()
target_sources(visualboyadvance-m PRIVATE
widgets/dpi-support.cpp
)
target_link_libraries(visualboyadvance-m
tiff zstd deflate)
endif()
# link libgcc/libstdc++ statically on mingw
@@ -362,33 +431,17 @@ if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC)
endif()
endif()
# OpenAL.
find_package(OpenAL REQUIRED)
if(OPENAL_STATIC)
target_compile_definitions(visualboyadvance-m PRIVATE AL_LIBTYPE_STATIC)
endif()
target_include_directories(visualboyadvance-m PRIVATE ${OPENAL_INCLUDE_DIR})
target_link_libraries(visualboyadvance-m ${OPENAL_LIBRARY})
# XAudio2.
if(ENABLE_XAUDIO2)
target_sources(visualboyadvance-m PRIVATE audio/internal/xaudio2.cpp)
target_compile_definitions(visualboyadvance-m PRIVATE VBAM_ENABLE_XAUDIO2)
endif()
# Direct3D.
if(NOT ENABLE_DIRECT3D)
target_compile_definitions(visualboyadvance-m PRIVATE NO_D3D)
endif()
# FAudio.
if(ENABLE_FAUDIO)
target_sources(visualboyadvance-m PRIVATE audio/internal/faudio.cpp)
target_link_libraries(visualboyadvance-m FAudio::FAudio)
target_compile_definitions(visualboyadvance-m PRIVATE VBAM_ENABLE_FAUDIO)
endif()
configure_wx_deps(visualboyadvance-m)
configure_wx_target(visualboyadvance-m)
# we make some direct gtk/gdk calls on linux and such
# so need to link the gtk that wx was built with
@@ -475,7 +528,7 @@ host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
# Override wxrc when cross-compiling.
if(CMAKE_HOST_WIN32 AND CMAKE_CROSSCOMPILING)
set(WXRC ${CMAKE_SOURCE_DIR}/dependencies/wxrc/wxrc.exe)
set(WXRC ${CMAKE_SOURCE_DIR}/win32-deps/wxrc/wxrc.exe)
endif()
# Configure wxrc.
@@ -598,6 +651,12 @@ add_custom_command(
DEPENDS ${CMAKE_SOURCE_DIR}/src/vba-over.ini ${BIN2C}
)
add_custom_command(
OUTPUT ${VBAM_GENERATED_DIR}/wx/gb-builtin-over.h
COMMAND ${BIN2C} ${CMAKE_SOURCE_DIR}/src/gb-over.ini ${VBAM_GENERATED_DIR}/wx/gb-builtin-over.h gb_builtin_over
DEPENDS ${CMAKE_SOURCE_DIR}/src/gb-over.ini ${BIN2C}
)
set(VBAM_LOCALIZABLE_FILES ${VBAM_WX_COMMON} ${VBAM_LOCALIZABLE_WX_CONFIG_FILES})
list(APPEND VBAM_LOCALIZABLE_FILES
audio/internal/dsound.cpp
@@ -620,9 +679,9 @@ if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks")
endif()
if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES)
if(WIN32 AND (X86_64 OR ARM64 OR X86_32) AND ENABLE_ONLINEUPDATES)
if(NOT DEFINED WINSPARKLE_BIN_RELEASE_DIR)
set(WINSPARKLE_BIN_RELEASE_DIR ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0)
set(WINSPARKLE_BIN_RELEASE_DIR ${CMAKE_SOURCE_DIR}/win32-deps/WinSparkle-0.8.1)
endif()
target_include_directories(
@@ -631,9 +690,11 @@ if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES)
)
if(X86_64)
set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/x64/Release/WinSparkle.dll)
else()
set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/Release/WinSparkle.dll)
set(WINSPARKLE_DLL ${WINSPARKLE_BIN_RELEASE_DIR}/x64/Release/WinSparkle.dll)
elseif(ARM64)
set(WINSPARKLE_DLL ${WINSPARKLE_BIN_RELEASE_DIR}/ARM64/Release/WinSparkle.dll)
elseif(X86_32)
set(WINSPARKLE_DLL ${WINSPARKLE_BIN_RELEASE_DIR}/Release/WinSparkle.dll)
endif()
configure_file(autoupdater/wxmsw/winsparkle-path.h.in ${CMAKE_BINARY_DIR}/winsparkle-path.h)
@@ -742,7 +803,7 @@ endif()
if(UPSTREAM_RELEASE AND WIN32)
set(home "$ENV{HOME}")
if((MSVC OR NOT CMAKE_CROSSCOMPILING) AND NOT DEFINED ENV{MSYSTEM_PREFIX})
if(NOT home OR ((MSVC OR NOT CMAKE_CROSSCOMPILING) AND NOT DEFINED ENV{MSYSTEM_PREFIX}))
set(home "$ENV{USERPROFILE}")
endif()
@@ -750,8 +811,9 @@ if(UPSTREAM_RELEASE AND WIN32)
string(REGEX REPLACE "\\\\" "/" home "${home}")
set(cert "${home}/.codesign/windows_comodo.pkcs12")
file(STRINGS "${home}/.codesign/windows_comodo.pkcs12.password" cert_password)
if(EXISTS "${cert}")
if(EXISTS "${cert}" AND cert_password)
find_program(OSSLSIGNCODE_PROGRAM osslsigncode)
find_program(SIGNTOOL_PROGRAM signtool)
@@ -760,7 +822,7 @@ if(UPSTREAM_RELEASE AND WIN32)
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename visualboyadvance-m.exe visualboyadvance-m-unsigned.exe
COMMAND ${OSSLSIGNCODE_PROGRAM} sign -pkcs12 ${cert} -pass "vbam3!13" -t http://timestamp.digicert.com -n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m -in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe
COMMAND ${OSSLSIGNCODE_PROGRAM} sign -pkcs12 ${cert} -pass "${cert_password}" -t http://timestamp.digicert.com -n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m -in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
elseif(SIGNTOOL_PROGRAM)
@@ -768,7 +830,7 @@ if(UPSTREAM_RELEASE AND WIN32)
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy visualboyadvance-m.exe visualboyadvance-m-unsigned.exe
COMMAND ${SIGNTOOL_PROGRAM} sign /f ${cert} /fd certHash /td certHash /p "vbam3!13" /tr http://timestamp.digicert.com /du https://github.com/visualboyadvance-m/visualboyadvance-m /a visualboyadvance-m.exe
COMMAND ${SIGNTOOL_PROGRAM} sign /f ${cert} /fd certHash /td certHash /p "${cert_password}" /tr http://timestamp.digicert.com /du https://github.com/visualboyadvance-m/visualboyadvance-m /a visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
@@ -793,7 +855,7 @@ if(UPSTREAM_RELEASE AND WIN32)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
if(GPG_KEYS)
if(GPG_SIGNATURES AND GPG_KEYS)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/translations.zip.asc
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/translations.zip.asc
@@ -842,7 +904,7 @@ if(APPLE)
if(CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$")
add_custom_command(
TARGET visualboyadvance-m POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/tools/macOS/third_party_libs_tool ./visualboyadvance-m.app
COMMAND bash ${CMAKE_SOURCE_DIR}/tools/macOS/third_party_libs_tool ./visualboyadvance-m.app
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
endif()
@@ -970,20 +1032,16 @@ install(
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(BUILD_TESTING AND (NOT CMAKE_CROSSCOMPILING))
add_subdirectory(tests)
endif()
# Installation scripts.
install(
PROGRAMS ${PROJECT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES ${CMAKE_SOURCE_DIR}/src/vba-over.ini
DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/vbam
DESTINATION ${CMAKE_INSTALL_DATADIR}/vbam
)
if (UNIX)
install(FILES ${CMAKE_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
install(FILES ${CMAKE_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6)
endif()

View File

@@ -1,12 +1,12 @@
#include "wx/audio/audio.h"
#include "core/base/check.h"
#include "wx/audio/internal/openal.h"
#if defined(__WXMSW__)
#include "wx/audio/internal/dsound.h"
#endif
#if defined(VBAM_ENABLE_FAUDIO)
#include "wx/audio/internal/faudio.h"
#endif
@@ -39,8 +39,7 @@ std::vector<AudioDevice> EnumerateAudioDevices(const config::AudioApi& audio_api
case config::AudioApi::kLast:
default:
// This should never happen.
assert(false);
VBAM_NOTREACHED();
return {};
}
}
@@ -67,8 +66,7 @@ std::unique_ptr<SoundDriver> CreateSoundDriver(const config::AudioApi& api) {
case config::AudioApi::kLast:
default:
// This should never happen.
assert(false);
VBAM_NOTREACHED();
return nullptr;
}
}

View File

@@ -5,8 +5,6 @@
#include "wx/audio/internal/faudio.h"
#include <cassert>
#include <condition_variable>
#include <mutex>
#include <vector>
@@ -18,9 +16,11 @@
#include <wx/log.h>
#include <wx/translation.h>
#include "core/base/check.h"
#include "core/base/system.h"
#include "core/gba/gbaGlobals.h"
#include "wx/config/option-proxy.h"
#include "wx/config/strutils.h"
namespace audio {
namespace internal {
@@ -28,7 +28,7 @@ namespace internal {
namespace {
int FAGetDev(FAudio* fa) {
const wxString& audio_device = OPTION(kSoundAudioDevice);
const wxString audio_device = OPTION(kSoundAudioDevice).Get();
if (audio_device.empty()) {
// Just use the default device.
return 0;
@@ -48,7 +48,7 @@ int FAGetDev(FAudio* fa) {
if (hr != 0) {
continue;
}
const wxString device_id(reinterpret_cast<wchar_t*>(dd.DeviceID));
const wxString device_id = config::utf16_to_utf8(dd.DeviceID);
if (audio_device == device_id) {
return i;
}
@@ -59,6 +59,17 @@ int FAGetDev(FAudio* fa) {
class FAudio_BufferNotify : public FAudioVoiceCallback {
public:
FAudio_BufferNotify() {
OnBufferEnd = &FAudio_BufferNotify::StaticOnBufferEnd;
OnVoiceProcessingPassStart = &FAudio_BufferNotify::StaticOnVoiceProcessingPassStart;
OnVoiceProcessingPassEnd = &FAudio_BufferNotify::StaticOnVoiceProcessingPassEnd;
OnStreamEnd = &FAudio_BufferNotify::StaticOnStreamEnd;
OnBufferStart = &FAudio_BufferNotify::StaticOnBufferStart;
OnLoopEnd = &FAudio_BufferNotify::StaticOnLoopEnd;
OnVoiceError = &FAudio_BufferNotify::StaticOnVoiceError;
}
~FAudio_BufferNotify() = default;
// Waits for the buffer end event to be signaled for 10 seconds.
// Returns true if the buffer end event was signaled, false if the wait timed out.
bool WaitForSignal() {
@@ -71,17 +82,6 @@ public:
return was_signaled;
}
FAudio_BufferNotify() {
OnBufferEnd = &FAudio_BufferNotify::StaticOnBufferEnd;
OnVoiceProcessingPassStart = &FAudio_BufferNotify::StaticOnVoiceProcessingPassStart;
OnVoiceProcessingPassEnd = &FAudio_BufferNotify::StaticOnVoiceProcessingPassEnd;
OnStreamEnd = &FAudio_BufferNotify::StaticOnStreamEnd;
OnBufferStart = &FAudio_BufferNotify::StaticOnBufferStart;
OnLoopEnd = &FAudio_BufferNotify::StaticOnLoopEnd;
OnVoiceError = &FAudio_BufferNotify::StaticOnVoiceError;
}
~FAudio_BufferNotify() = default;
private:
// Signals that the buffer end event has occurred.
void SignalBufferEnd() {
@@ -120,8 +120,6 @@ public:
FAudio_Output();
~FAudio_Output();
void device_change();
private:
void close();
@@ -159,6 +157,7 @@ FAudio_Output::FAudio_Output() : buffer_count_(OPTION(kSoundBuffers)) {
playing = false;
freq_ = 0;
currentBuffer = 0;
sound_buffer_len_ = 0;
device_changed = false;
faud = nullptr;
mVoice = nullptr;
@@ -176,7 +175,7 @@ void FAudio_Output::close() {
if (sVoice) {
if (playing) {
assert(FAudioSourceVoice_Stop(sVoice, 0, FAUDIO_COMMIT_NOW) == 0);
VBAM_CHECK(FAudioSourceVoice_Stop(sVoice, 0, FAUDIO_COMMIT_NOW) == 0);
}
FAudioVoice_DestroyVoice(sVoice);
@@ -194,10 +193,6 @@ void FAudio_Output::close() {
}
}
void FAudio_Output::device_change() {
device_changed = true;
}
bool FAudio_Output::init(long sampleRate) {
if (failed || initialized)
return false;
@@ -259,7 +254,7 @@ bool FAudio_Output::init(long sampleRate) {
if (OPTION(kSoundUpmix)) {
// set up stereo upmixing
FAudioDeviceDetails dd{};
assert(FAudio_GetDeviceDetails(faud, 0, &dd) == 0);
VBAM_CHECK(FAudio_GetDeviceDetails(faud, 0, &dd) == 0);
std::vector<float> matrix(sizeof(float) * 2 * dd.OutputFormat.Format.nChannels);
bool matrixAvailable = true;
@@ -353,12 +348,12 @@ bool FAudio_Output::init(long sampleRate) {
if (matrixAvailable) {
hr = FAudioVoice_SetOutputMatrix(sVoice, nullptr, 2, dd.OutputFormat.Format.nChannels,
matrix.data(), FAUDIO_DEFAULT_CHANNELS);
assert(hr == 0);
VBAM_CHECK(hr == 0);
}
}
hr = FAudioSourceVoice_Start(sVoice, 0, FAUDIO_COMMIT_NOW);
assert(hr == 0);
VBAM_CHECK(hr == 0);
playing = true;
currentBuffer = 0;
device_changed = false;
@@ -380,7 +375,7 @@ void FAudio_Output::write(uint16_t* finalWave, int) {
}
FAudioSourceVoice_GetState(sVoice, &vState, flags);
assert(vState.BuffersQueued <= buffer_count_);
VBAM_CHECK(vState.BuffersQueued <= buffer_count_);
if (vState.BuffersQueued < buffer_count_) {
if (vState.BuffersQueued == 0) {
@@ -397,7 +392,7 @@ void FAudio_Output::write(uint16_t* finalWave, int) {
// the maximum number of buffers is currently queued
if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) {
// wait for one buffer to finish playing
if (notify.WaitForSignal()) {
if (!notify.WaitForSignal()) {
device_changed = true;
}
} else {
@@ -414,7 +409,7 @@ void FAudio_Output::write(uint16_t* finalWave, int) {
currentBuffer++;
currentBuffer %= (buffer_count_ + 1); // + 1 because we need one temporary buffer
[[maybe_unused]] uint32_t hr = FAudioSourceVoice_SubmitSourceBuffer(sVoice, &buf, nullptr);
assert(hr == 0);
VBAM_CHECK(hr == 0);
}
void FAudio_Output::pause() {
@@ -423,7 +418,7 @@ void FAudio_Output::pause() {
if (playing) {
[[maybe_unused]] uint32_t hr = FAudioSourceVoice_Stop(sVoice, 0, FAUDIO_COMMIT_NOW);
assert(hr == 0);
VBAM_CHECK(hr == 0);
playing = false;
}
}
@@ -434,7 +429,7 @@ void FAudio_Output::resume() {
if (!playing) {
[[maybe_unused]] int32_t hr = FAudioSourceVoice_Start(sVoice, 0, FAUDIO_COMMIT_NOW);
assert(hr == 0);
VBAM_CHECK(hr == 0);
playing = true;
}
}
@@ -445,7 +440,7 @@ void FAudio_Output::reset() {
if (playing) {
[[maybe_unused]] uint32_t hr = FAudioSourceVoice_Stop(sVoice, 0, FAUDIO_COMMIT_NOW);
assert(hr == 0);
VBAM_CHECK(hr == 0);
}
FAudioSourceVoice_FlushSourceBuffers(sVoice);
@@ -462,7 +457,7 @@ void FAudio_Output::setThrottle(unsigned short throttle_) {
[[maybe_unused]] uint32_t hr =
FAudioSourceVoice_SetFrequencyRatio(sVoice, (float)throttle_ / 100.0f, FAUDIO_COMMIT_NOW);
assert(hr == 0);
VBAM_CHECK(hr == 0);
}
} // namespace
@@ -489,8 +484,11 @@ std::vector<AudioDevice> GetFAudioDevices() {
}
std::vector<AudioDevice> devices;
#if defined(__WXMSW__)
// Add a separate default device on Windows.
devices.reserve(dev_count + 1);
devices.push_back({_("Default device"), wxEmptyString});
#endif
for (uint32_t i = 0; i < dev_count; i++) {
FAudioDeviceDetails dd;
@@ -499,9 +497,9 @@ std::vector<AudioDevice> GetFAudioDevices() {
continue;
}
const wxString display_name(reinterpret_cast<wchar_t*>(dd.DisplayName));
const wxString device_id(reinterpret_cast<wchar_t*>(dd.DeviceID));
// Convert to UTF-8.
const wxString display_name = config::utf16_to_utf8(dd.DisplayName);
const wxString device_id = config::utf16_to_utf8(dd.DeviceID);
devices.push_back({display_name, device_id});
}
@@ -514,4 +512,4 @@ std::unique_ptr<SoundDriver> CreateFAudioDriver() {
}
} // namespace internal
} // namespace audio
} // namespace audio

View File

@@ -30,13 +30,12 @@ typedef ALCboolean(ALC_APIENTRY* LPALCISEXTENSIONPRESENT)(ALCdevice* device,
typedef const ALCchar*(ALC_APIENTRY* LPALCGETSTRING)(ALCdevice* device, ALCenum param);
#endif
#include <cassert>
#include <wx/arrstr.h>
#include <wx/log.h>
#include <wx/translation.h>
#include <wx/utils.h>
#include "core/base/check.h"
#include "core/gba/gbaGlobals.h"
#include "core/gba/gbaSound.h"
#include "wx/config/option-proxy.h"
@@ -47,7 +46,7 @@ namespace internal {
namespace {
// Debug
#define ASSERT_SUCCESS assert(AL_NO_ERROR == alGetError())
#define ASSERT_SUCCESS VBAM_CHECK(AL_NO_ERROR == alGetError())
#ifndef LOGALL
// replace logging functions with comments
@@ -171,7 +170,7 @@ void OpenAL::debugState() {
bool OpenAL::init(long sampleRate) {
winlog("OpenAL::init\n");
assert(initialized == false);
VBAM_CHECK(initialized == false);
const wxString& audio_device = OPTION(kSoundAudioDevice);
if (!audio_device.empty()) {
@@ -191,9 +190,9 @@ bool OpenAL::init(long sampleRate) {
}
context = alcCreateContext(device, nullptr);
assert(context != nullptr);
VBAM_CHECK(context != nullptr);
ALCboolean retVal = alcMakeContextCurrent(context);
assert(ALC_TRUE == retVal);
VBAM_CHECK(ALC_TRUE == retVal);
alGenBuffers(OPTION(kSoundBuffers), buffer);
ASSERT_SUCCESS;
alGenSources(1, &source);
@@ -338,7 +337,7 @@ void OpenAL::write(uint16_t* finalWave, int length) {
return;
}
assert(nBuffersProcessed > 0);
VBAM_CHECK(nBuffersProcessed > 0);
// unqueue buffer
tempBuffer = 0;

View File

@@ -1,10 +1,6 @@
#ifndef WX_AUDIO_INTERNAL_XAUDIO2_H_
#define WX_AUDIO_INTERNAL_XAUDIO2_H_
#if !defined(VBAM_ENABLE_FAUDIO)
#error "This file should only be included if FAudio is enabled"
#endif
#include "wx/audio/audio.h"
namespace audio {

View File

@@ -11,6 +11,7 @@
#include <wx/msgdlg.h>
#include "components/filters_interframe/interframe.h"
#include "core/base/check.h"
#include "core/base/version.h"
#include "core/gb/gb.h"
#include "core/gb/gbCheats.h"
@@ -32,7 +33,7 @@
void MainFrame::GetMenuOptionBool(const wxString& menuName, bool* field)
{
assert(field);
VBAM_CHECK(field);
*field = !*field;
int id = wxXmlResource::GetXRCID(menuName);
@@ -48,7 +49,7 @@ void MainFrame::GetMenuOptionBool(const wxString& menuName, bool* field)
void MainFrame::GetMenuOptionConfig(const wxString& menu_name,
const config::OptionID& option_id) {
config::Option* option = config::Option::ByID(option_id);
assert(option);
VBAM_CHECK(option);
int id = wxXmlResource::GetXRCID(menu_name);
for (size_t i = 0; i < checkable_mi.size(); i++) {
@@ -64,7 +65,7 @@ void MainFrame::GetMenuOptionConfig(const wxString& menu_name,
option->SetInt(is_checked);
break;
default:
assert(false);
VBAM_CHECK(false);
return;
}
break;
@@ -73,7 +74,7 @@ void MainFrame::GetMenuOptionConfig(const wxString& menu_name,
void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
{
assert(field);
VBAM_CHECK(field);
int value = mask;
bool is_checked = ((*field) & (mask)) != (value);
int id = wxXmlResource::GetXRCID(menuName);
@@ -125,7 +126,7 @@ static void toggleBitVar(bool *menuValue, int *globalVar, int mask)
EVT_HANDLER(wxID_OPEN, "Open ROM...")
{
static int open_ft = 0;
const wxString& gba_rom_dir = OPTION(kGBAROMDir);
const wxString gba_rom_dir = OPTION(kGBAROMDir);
// FIXME: ignore if non-existent or not a dir
wxString pats = _(
@@ -157,7 +158,7 @@ EVT_HANDLER(wxID_OPEN, "Open ROM...")
EVT_HANDLER(OpenGB, "Open GB...")
{
static int open_ft = 0;
const wxString& gb_rom_dir = OPTION(kGBROMDir);
const wxString gb_rom_dir = OPTION(kGBROMDir);
// FIXME: ignore if non-existent or not a dir
wxString pats = _(
@@ -184,7 +185,7 @@ EVT_HANDLER(OpenGB, "Open GB...")
EVT_HANDLER(OpenGBC, "Open GBC...")
{
static int open_ft = 0;
const wxString& gbc_rom_dir = OPTION(kGBGBCROMDir);
const wxString gbc_rom_dir = OPTION(kGBGBCROMDir);
// FIXME: ignore if non-existent or not a dir
wxString pats = _(
@@ -1989,7 +1990,7 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
XRCCTRL(*dlg, "GameCode", wxControl)
->SetLabel(s);
cmt = wxString((const char*)&g_rom[0xa0], wxConvLibc, 12);
wxFileConfig* cfg = wxGetApp().overrides;
wxFileConfig* cfg = wxGetApp().overrides_.get();
if (cfg->HasGroup(s)) {
cfg->SetPath(s);
@@ -2023,7 +2024,7 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
if (panel->game_type() == IMAGE_GBA) {
agbPrintEnable(OPTION(kPrefAgbPrint));
wxString s = wxString((const char*)&g_rom[0xac], wxConvLibc, 4);
wxFileConfig* cfg = wxGetApp().overrides;
wxFileConfig* cfg = wxGetApp().overrides_.get();
bool chg;
if (cfg->HasGroup(s)) {
@@ -2218,7 +2219,7 @@ EVT_HANDLER(FAQ, "VBA-M support forum")
EVT_HANDLER(Translate, "Translations")
{
wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m"));
wxLaunchDefaultBrowser(wxT("https://explore.transifex.com/bgk/vba-m/"));
}
// was About
@@ -2296,7 +2297,7 @@ EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing")
EVT_HANDLER(Printer, "Enable printer emulation")
{
GetMenuOptionInt("Printer", &coreOptions.winGbPrinterEnabled, 1);
GetMenuOptionInt("Printer", &coreOptions.gbPrinterEnabled, 1);
#if (defined __WIN32__ || defined _WIN32)
#ifndef NO_LINK
gbSerialFunction = gbStartLink;
@@ -2304,7 +2305,7 @@ EVT_HANDLER(Printer, "Enable printer emulation")
gbSerialFunction = NULL;
#endif
#endif
if (coreOptions.winGbPrinterEnabled)
if (coreOptions.gbPrinterEnabled)
gbSerialFunction = gbPrinterSend;
update_opts();

View File

@@ -1,5 +1,5 @@
# This defines the vbam-wx-config target and the
# `VBAM_LOCALIZABLE_WX_CONFIG_FILES` variable, containing the list of
# `VBAM_LOCALIZABLE_WX_CONFIG_FILES` variable, containing the list of
# localizable files in the vbam-wx-config target.
# I don't like duplicating/triplicating code, so I only declare
@@ -61,11 +61,29 @@ target_sources(vbam-wx-config
user-input.h
)
target_link_libraries(vbam-wx-config
PUBLIC
nonstd-lib
vbam-core
)
configure_wx_target(vbam-wx-config)
configure_wx_deps(vbam-wx-config)
target_include_directories(vbam-wx-config PUBLIC ${NONSTD_INCLUDE_DIR})
if(BUILD_TESTING)
add_executable(vbam-wx-config-tests
bindings-test.cpp
command-test.cpp
emulated-gamepad-test.cpp
option-test.cpp
strutils-test.cpp
user-input-test.cpp
)
target_link_libraries(vbam-wx-config-tests
# Test deps.
vbam-core-fake
vbam-wx-fake-opts
# Target deps.
vbam-wx-config
GTest::gtest_main
)
configure_wx_target(vbam-wx-config-tests)
if (NOT CMAKE_CROSSCOMPILING)
gtest_discover_tests(vbam-wx-config-tests)
endif()
endif()

View File

@@ -0,0 +1,152 @@
#include "wx/config/bindings.h"
#include <gtest/gtest.h>
#include <wx/xrc/xmlres.h>
#include "wx/config/command.h"
#include "wx/config/user-input.h"
TEST(BindingsTest, Default) {
const config::Bindings bindings;
// Check that the default bindings are set up correctly.
auto inputs =
bindings.InputsForCommand(config::GameCommand(config::GameJoy(0), config::GameKey::Up));
EXPECT_TRUE(inputs.find(config::KeyboardInput('W')) != inputs.end());
EXPECT_TRUE(inputs.find(config::JoyInput(config::JoyId(0), config::JoyControl::HatNorth, 0)) !=
inputs.end());
inputs = bindings.InputsForCommand(config::ShortcutCommand(wxID_CLOSE));
EXPECT_TRUE(inputs.find(config::KeyboardInput('W', wxMOD_CMD)) != inputs.end());
inputs = bindings.InputsForCommand(config::ShortcutCommand(XRCID("LoadGame01")));
EXPECT_TRUE(inputs.find(config::KeyboardInput(WXK_F1)) != inputs.end());
// Check that the INI configuration for the keyboard is empty.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_TRUE(config.empty());
}
// Tests that assigning a default input to another command generates the right
// configuration.
TEST(BindingsTest, AssignDefault) {
config::Bindings bindings;
// Assign F1 to the "Close" command.
bindings.AssignInputToCommand(config::KeyboardInput(WXK_F1),
config::ShortcutCommand(wxID_CLOSE));
// The INI configuration should have NOOP set to F1, and Close set to F1.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_EQ(config.size(), 2);
EXPECT_EQ(config[0].first, "Keyboard/NOOP");
EXPECT_EQ(config[0].second, "F1");
EXPECT_EQ(config[1].first, "Keyboard/CLOSE");
EXPECT_EQ(config[1].second, "F1");
}
// Tests that unassigning a default input generates the right configuration.
TEST(BindingsTest, UnassignDefault) {
config::Bindings bindings;
// Unassign F1.
bindings.UnassignInput(config::KeyboardInput(WXK_F1));
// The INI configuration should have NOOP set to F1.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_EQ(config.size(), 1);
EXPECT_EQ(config[0].first, "Keyboard/NOOP");
EXPECT_EQ(config[0].second, "F1");
}
// Tests that re-assigning a default input to its default command generates the
// right configuration.
TEST(BindingsTest, ReassignDefault) {
config::Bindings bindings;
// Assign F1 to the "Close" command.
bindings.AssignInputToCommand(config::KeyboardInput(WXK_F1),
config::ShortcutCommand(wxID_CLOSE));
// Re-assign F1 to the "LoadGame01" command.
bindings.AssignInputToCommand(config::KeyboardInput(WXK_F1),
config::ShortcutCommand(XRCID("LoadGame01")));
// The INI configuration should be empty.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_TRUE(config.empty());
}
// Tests that assigning an input to "NOOP" properly disables the default input.
TEST(BindingsTest, AssignToNoop) {
config::Bindings bindings;
// Assign F1 to the "NOOP" command.
bindings.AssignInputToCommand(config::KeyboardInput(WXK_F1),
config::ShortcutCommand(XRCID("NOOP")));
const auto command = bindings.CommandForInput(config::KeyboardInput(WXK_F1));
EXPECT_FALSE(command.has_value());
// The INI configuration should have NOOP set to F1 and nothing more.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_EQ(config.size(), 1);
EXPECT_EQ(config[0].first, "Keyboard/NOOP");
EXPECT_EQ(config[0].second, "F1");
}
// Tests that assigning an input not used as a default shortcut to "NOOP" does
// nothing.
TEST(BindingsTest, AssignUnusedToNoop) {
config::Bindings bindings;
// Assign "T" to the "NOOP" command.
bindings.AssignInputToCommand(config::KeyboardInput('T'), config::ShortcutCommand(XRCID("NOOP")));
// The INI configuration should be empty.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_TRUE(config.empty());
// "T" should have no assignment.
const auto command = bindings.CommandForInput(config::KeyboardInput('T'));
EXPECT_FALSE(command.has_value());
}
// Tests that assigning a default input to a Game command works as expected.
TEST(BindingsTest, AssignDefaultToGame) {
config::Bindings bindings;
// Assign F1 to the "Up" command and clear all of the default input for the
// "Up" command.
bindings.AssignInputsToCommand({config::KeyboardInput(WXK_F1)},
config::GameCommand(config::GameJoy(0), config::GameKey::Up));
// The INI configuration should have NOOP set to F1.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_EQ(config.size(), 1);
EXPECT_EQ(config[0].first, "Keyboard/NOOP");
EXPECT_EQ(config[0].second, "F1");
EXPECT_EQ(
bindings.InputsForCommand(config::GameCommand(config::GameJoy(0), config::GameKey::Up)),
std::unordered_set<config::UserInput>{config::KeyboardInput(WXK_F1)});
EXPECT_EQ(bindings.CommandForInput(config::KeyboardInput(WXK_F1)),
config::Command(config::GameCommand(config::GameJoy(0), config::GameKey::Up)));
}
// Tests the "ClearCommandAssignments" method.
TEST(BindingsTest, ClearCommand) {
config::Bindings bindings;
// Clear "CLOSE" assignments.
bindings.ClearCommandAssignments(config::ShortcutCommand(wxID_CLOSE));
// The INI configuration should only have the NOOP assignment.
const auto config = bindings.GetKeyboardConfiguration();
EXPECT_EQ(config.size(), 1);
EXPECT_EQ(config[0].first, "Keyboard/NOOP");
EXPECT_EQ(config[0].second, "CTRL+W");
EXPECT_TRUE(bindings.InputsForCommand(config::ShortcutCommand(wxID_CLOSE)).empty());
}

View File

@@ -43,8 +43,8 @@ Bindings::Bindings(
input_to_control_(input_to_control.begin(), input_to_control.end()),
disabled_defaults_(disabled_defaults.begin(), disabled_defaults.end()) {}
std::vector<std::pair<int, wxString>> Bindings::GetKeyboardConfiguration() const {
std::vector<std::pair<int, wxString>> config;
std::vector<std::pair<wxString, wxString>> Bindings::GetKeyboardConfiguration() const {
std::vector<std::pair<wxString, wxString>> config;
config.reserve(control_to_inputs_.size() + 1);
if (!disabled_defaults_.empty()) {
@@ -52,7 +52,8 @@ std::vector<std::pair<int, wxString>> Bindings::GetKeyboardConfiguration() const
for (const auto& iter : disabled_defaults_) {
noop_inputs.insert(iter.first);
}
config.push_back(std::make_pair(NoopCommand(), UserInput::SpanToConfigString(noop_inputs)));
config.push_back(std::make_pair(ShortcutCommand(NoopCommand()).ToConfigString(),
UserInput::SpanToConfigString(noop_inputs)));
}
for (const auto& iter : control_to_inputs_) {
@@ -73,8 +74,8 @@ std::vector<std::pair<int, wxString>> Bindings::GetKeyboardConfiguration() const
}
if (!inputs.empty()) {
const int command_id = iter.first.shortcut().id();
config.push_back(std::make_pair(command_id, UserInput::SpanToConfigString(inputs)));
config.push_back(std::make_pair(iter.first.shortcut().ToConfigString(),
UserInput::SpanToConfigString(inputs)));
}
}
@@ -158,7 +159,7 @@ void Bindings::AssignInputToCommand(const UserInput& input, const Command& comma
}
void Bindings::AssignInputsToCommand(const std::unordered_set<UserInput>& inputs,
const Command& command) {
const Command& command) {
// Remove the existing binding if it exists.
const auto iter = control_to_inputs_.find(command);
if (iter != control_to_inputs_.end()) {
@@ -175,7 +176,7 @@ void Bindings::AssignInputsToCommand(const std::unordered_set<UserInput>& inputs
}
void Bindings::UnassignInput(const UserInput& input) {
assert(input);
VBAM_CHECK(input);
auto iter = input_to_control_.find(input);
if (iter == input_to_control_.end()) {
@@ -193,7 +194,7 @@ void Bindings::UnassignInput(const UserInput& input) {
// Otherwise, just remove it from the 2 maps.
auto command_iter = control_to_inputs_.find(iter->second);
assert(command_iter != control_to_inputs_.end());
VBAM_CHECK(command_iter != control_to_inputs_.end());
command_iter->second.erase(input);
if (command_iter->second.empty()) {
@@ -204,16 +205,19 @@ void Bindings::UnassignInput(const UserInput& input) {
}
void Bindings::ClearCommandAssignments(const Command& command) {
auto iter = control_to_inputs_.find(command);
const auto iter = control_to_inputs_.find(command);
if (iter == control_to_inputs_.end()) {
// Command not found, nothing to do.
return;
}
for (const UserInput& input : iter->second) {
input_to_control_.erase(input);
// Keep a copy of the inputs to unassign.
std::unordered_set<UserInput> inputs_to_unassign(iter->second);
// Unassign all inputs.
for (const UserInput& input : inputs_to_unassign) {
UnassignInput(input);
}
control_to_inputs_.erase(iter);
}
void Bindings::UnassignDefaultBinding(const UserInput& input) {
@@ -234,7 +238,7 @@ void Bindings::UnassignDefaultBinding(const UserInput& input) {
}
auto command_iter = control_to_inputs_.find(input_iter->second);
assert(command_iter != control_to_inputs_.end());
VBAM_CHECK(command_iter != control_to_inputs_.end());
command_iter->second.erase(input);
if (command_iter->second.empty()) {

View File

@@ -43,7 +43,7 @@ public:
// - User-added custom bindings. These appear under [Keyboard/CommandName].
// Essentially, this is a diff between the default shortcuts and the user
// configuration.
std::vector<std::pair<int, wxString>> GetKeyboardConfiguration() const;
std::vector<std::pair<wxString, wxString>> GetKeyboardConfiguration() const;
// Returns the game control configuration for the INI file. These go in the
// [Joypad] section of the INI file.

View File

@@ -1,7 +1,11 @@
#include "wx/config/cmdtab.h"
#include <algorithm>
#include <wx/wxcrt.h>
#include "core/base/check.h"
// Initializer for struct cmditem
cmditem new_cmditem(const wxString cmd,
const wxString name,
@@ -11,6 +15,41 @@ cmditem new_cmditem(const wxString cmd,
return cmditem {cmd, name, cmd_id, mask_flags, mi};
}
bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2) {
return wxStrcmp(cmd1.cmd, cmd2.cmd) < 0;
}
namespace config {
wxString GetCommandINIEntry(int command) {
for (const auto& cmd_item : cmdtab) {
if (cmd_item.cmd_id == command) {
return wxString::Format("Keyboard/%s", cmd_item.cmd);
}
}
// Command not found. This should never happen.
VBAM_NOTREACHED();
return wxEmptyString;
}
wxString GetCommandHelper(int command) {
for (const auto& cmd_item : cmdtab) {
if (cmd_item.cmd_id == command) {
return cmd_item.name;
}
}
// Command not found. This should never happen.
VBAM_NOTREACHED();
return wxEmptyString;
}
nonstd::optional<int> CommandFromConfigString(const wxString& config) {
const cmditem dummy = new_cmditem(config);
const auto iter = std::lower_bound(cmdtab.begin(), cmdtab.end(), dummy, [](const cmditem& cmd1, const cmditem& cmd2) {
return wxStrcmp(cmd1.cmd, cmd2.cmd) < 0;
});
if (iter == cmdtab.end() || iter->cmd != config) {
return nonstd::nullopt;
}
return iter->cmd_id;
}
} // namespace config

View File

@@ -3,6 +3,8 @@
#include <vector>
#include <optional.hpp>
#include <wx/string.h>
// Forward declaration.
@@ -29,8 +31,29 @@ cmditem new_cmditem(const wxString cmd = "",
int mask_flags = 0,
wxMenuItem* mi = nullptr);
// for binary search
bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2);
namespace config {
// Returns the command INI entry name for the given XRC ID. Will assert if
// the command is not found. The INI entry name is the command name prefixed
// with "Keyboard/". This is used to store the command in the INI file.
// Examples:
// * wxID_OPEN -> "Keyboard/OPEN"
// * XRCID("NOOP") -> "Keyboard/NOOP"
// O(n) search.
wxString GetCommandINIEntry(int xrc_id);
// Returns the command helper string for the given XRC ID. Will assert if
// the command is not found.
// O(n) search.
wxString GetCommandHelper(int xrc_id);
// Returns the XRC ID for the given command config name, without the
// "Keyboard/" prefix. Examples:
// * "OPEN" -> wxID_OPEN
// * "Keyboard/OPEN" -> nonstd::nullopt
// * "NOOP" -> XRCID("NOOP")
// O(log(n)) search.
nonstd::optional<int> CommandFromConfigString(const wxString& config);
}
// here are those conditions
enum { CMDEN_GB = (1 << 0), // GB ROM loaded

View File

@@ -0,0 +1,51 @@
#include "wx/config/command.h"
#include <gtest/gtest.h>
#include <wx/log.h>
TEST(GameCommandTest, Basic) {
config::GameCommand command(config::GameJoy(0), config::GameKey::Up);
EXPECT_EQ(command.joypad(), config::GameJoy(0));
EXPECT_EQ(command.game_key(), config::GameKey::Up);
EXPECT_EQ(command.ToConfigString(), "Joypad/1/Up");
}
TEST(ShortcutCommandTest, Basic) {
config::ShortcutCommand command(wxID_OPEN);
EXPECT_EQ(command.id(), wxID_OPEN);
EXPECT_EQ(command.ToConfigString(), "Keyboard/OPEN");
}
TEST(CommandTest, FromString) {
const auto game_command = config::Command::FromString("Joypad/1/Up");
ASSERT_TRUE(game_command.has_value());
ASSERT_TRUE(game_command->is_game());
const config::GameCommand& game = game_command->game();
EXPECT_EQ(game.joypad(), config::GameJoy(0));
EXPECT_EQ(game.game_key(), config::GameKey::Up);
const auto shortcut_command = config::Command::FromString("Keyboard/OPEN");
ASSERT_TRUE(shortcut_command.has_value());
ASSERT_TRUE(shortcut_command->is_shortcut());
const config::ShortcutCommand& shortcut = shortcut_command->shortcut();
EXPECT_EQ(shortcut.id(), wxID_OPEN);
}
TEST(CommandTest, FromStringInvalid) {
// Need to disable logging to test for errors.
const wxLogNull disable_logging;
const auto game_command = config::Command::FromString("Joypad/1/Invalid");
EXPECT_FALSE(game_command.has_value());
const auto shortcut_command = config::Command::FromString("Keyboard/INVALID");
EXPECT_FALSE(shortcut_command.has_value());
const auto invalid_command = config::Command::FromString("INVALID");
EXPECT_FALSE(invalid_command.has_value());
}

View File

@@ -108,15 +108,7 @@ wxString GameCommand::ToUXString() const {
}
wxString ShortcutCommand::ToConfigString() const {
for (const cmditem& cmd_item : cmdtab) {
if (cmd_item.cmd_id == id_) {
return wxString::Format("Keyboard/%s", cmd_item.cmd);
}
}
// Command not found. This should never happen.
assert(false);
return wxEmptyString;
return GetCommandINIEntry(id_);
}
// static
@@ -157,14 +149,13 @@ nonstd::optional<Command> Command::FromString(const wxString& name) {
return nonstd::nullopt;
}
const auto iter = std::lower_bound(cmdtab.begin(), cmdtab.end(),
cmditem{parts[1], wxString(), 0, 0, NULL}, cmditem_lt);
if (iter == cmdtab.end()) {
const auto xrc_id = CommandFromConfigString(parts[1]);
if (!xrc_id.has_value()) {
wxLogDebug("Command ID %s not found", parts[1]);
return nonstd::nullopt;
}
return Command(ShortcutCommand(iter->cmd_id));
return Command(ShortcutCommand(xrc_id.value()));
}
}

View File

@@ -2,7 +2,6 @@
#define VBAM_WX_CONFIG_COMMAND_H_
#include <array>
#include <cassert>
#include <functional>
#include <optional.hpp>
@@ -10,6 +9,8 @@
#include <wx/string.h>
#include "core/base/check.h"
namespace config {
// clang-format off
@@ -56,7 +57,7 @@ static constexpr size_t kNbJoypads = 4;
// Represents an emulated joypad. The internal index is zero-based.
class GameJoy {
public:
constexpr explicit GameJoy(size_t index) : index_(index) { assert(index < kNbJoypads); }
constexpr explicit GameJoy(size_t index) : index_(index) { VBAM_CHECK(index < kNbJoypads); }
// The underlying zero-based index for this emulated joypad.
constexpr size_t index() const { return index_; }
@@ -179,12 +180,12 @@ public:
bool is_shortcut() const { return tag() == Tag::kShortcut; }
const GameCommand& game() const {
assert(is_game());
VBAM_CHECK(is_game());
return nonstd::get<GameCommand>(control_);
}
const ShortcutCommand& shortcut() const {
assert(is_shortcut());
VBAM_CHECK(is_shortcut());
return nonstd::get<ShortcutCommand>(control_);
}
@@ -201,8 +202,7 @@ public:
return shortcut() < other.shortcut();
}
// Unreachable.
assert(false);
VBAM_NOTREACHED();
return false;
} else {
return tag_ < other.tag_;
@@ -260,8 +260,7 @@ struct std::hash<config::Command> {
return std::hash<config::ShortcutCommand>{}(control.shortcut());
}
// Unreachable.
assert(false);
VBAM_NOTREACHED();
return 0;
}
};

View File

@@ -31,7 +31,6 @@ LIST(SORT EVLINES)
STRING(REGEX REPLACE ",\n\$" "\n" EVLINES "${EVLINES}")
FILE(APPEND "${CMDTAB}" ${EVLINES})
FILE(APPEND "${CMDTAB}" "};\n")
FILE(APPEND "${CMDTAB}" "const int ncmds = sizeof(cmdtab) / sizeof(cmdtab[0]);\n")
# cmdhandlers.h contains prototypes for all handlers
FILE(WRITE "${EVPROTO}" "// Generated from cmdevents.cpp; do not edit\n")

Some files were not shown because too many files have changed in this diff Show More