Compare commits

...

75 Commits

Author SHA1 Message Date
Fabrice de Gans
91b0bbaebd [Input] Unify UserInput event handling
This adds a custom UserInputEvent for handling joypad and keyboard input
for both accelerators and emulator control configuration.

These changes fix a number of issues with the wxWidgets implementation
of key down / up event handling. In particular, every "down" event now
has a corresponding "up" event. All of the special handling that was
done in multiple places to handle shortcuts is now done in a new class,
`UserInputEventSender`, simplifying multiple call sites.

This is another step towards complete unification of UserInput handling,
which will prevent double assignment between shortcuts and emulator
controls.

Bug: #745
2024-04-22 18:06:12 -07:00
Squall Leonhart
cc65ef2849 doc: add system requirements to README.md
Add system requirements and a link to the DirectX redist for Windows to
the README.md.
2024-04-18 09:13:39 +00:00
Fabrice de Gans
32627f6b85 [Dialogs] Save and restore dialog positions
This changes most dialogs in the wx frontend to use a common base
abstraction, `dialogs::BaseDialog`. This base class sets up common
style options for every dialog and automatically saves and restores the
dialog position.

In addition, this moves the first time show position of the dialog to be
slightly to the bottom and right of the main window, even if the main
window is on a screen other than the main screen.
2024-04-18 09:02:08 +00:00
Rafael Kitover
41952d0625 build: update macOS linker tool to 1.5
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-18 08:02:51 +00:00
Rafael Kitover
0c39a5ba7a build: override FindGettext to not update po files
Copy the cmake 3.28.3 FindGettext.cmake to cmake/ and comment out the
line that updates the po file from the pot. Because we download po files
from transifex we don't want this.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 22:12:46 +00:00
Rafael Kitover
1b77d6594c build: update macOS build to ffmpeg 7.0
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 16:59:28 +00:00
Rafael Kitover
8d08223dbc build: fix compatibility with older ffmpeg
Check LIBAVCODEC_VERSION_MAJOR and use the older channel_layout API if
it's below 60.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 16:19:12 +00:00
Rafael Kitover
af6028a9dd build: fix build for nix on macOS
Add the NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM env var to the macOS CI as
faudio has not been marked compatible with macOS yet.

Remove FindGettext.cmake as it is a core cmake module that is available
in the versions of cmake we support now.

Add support for nix to MacPackageManagers.cmake and add brew gettext to
CMAKE_IGNORE_PATH when not using brew. Also update the cmake style.

Add faudio, libintl and the System framework to buildInputs in
default.nix.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 15:30:30 +00:00
Rafael Kitover
ff3b5ee042 build: update mac link tool to 1.4
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-16 02:13:37 +00:00
Rafael Kitover
b52edf52ff build: fix building on macOS with Homebrew
Move setting up the environment for macOS Homebrew earlier in
Options.cmake, as well as finding pkgconfig.

Update gcc/clang toolchain to not pass a gcc-specific option to clang.

Add faudio to list of brew packages to get in installdeps.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-15 23:30:34 +00:00
Rafael Kitover
6766b9ca54 build: fix ffmpeg 7.x compat
Update from the channels/channel_layout API to the new ch_layout API,
assume two channel stereo always.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-15 23:28:56 +00:00
Rafael Kitover
8eae2e5b90 build: add FAudio to nix deps
Add faudio to nix dependencies for both macOS and Linux.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:15:54 +00:00
Rafael Kitover
50d17363ea build: fail finding FAudio silently
Change the find_package() call for FAudio to QUIET to not show a giant
warning when it's not available.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:09:37 +00:00
Rafael Kitover
795f25bb85 build: fix nix deps for OpenGL
Change Linux nix dependencies in default.nix for OpenGL from mesa to
libGL and libGLU, also fixing the compile error for the SDL binary.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-14 10:06:54 +00:00
Ruben
647be137f6 gba: set cpsr=spsr when switching to FIQ mode
The CPSR register needs to be restored from SPSR when switching modes.
This is currently being done for all mode switches /except/ for FIQ,
which is very likely just an oversight rather than intended behaviour.

This fixes the random crashing in OpenLara, as well as fixing random
glitching of my own project that uses FIQ mode switches. The issue
happens "at random" because it requires an interrupt to occur while in
FIQ mode, and it must also fire inside a section of code that relies on
the status flags (or the CPSR register in general): When exiting the
interrupt exception, the CPSR register is supposed to be restored from
SPSR, but this isn't being done when switching from IRQ mode back to FIQ
mode, which results in CPSR (and thus the status flags) being corrupted.
For example, SUBS r0, #1; [interrupt]; BNE 1b would trigger the bug, but
[interrupt]; SUBS r0, #1; BNE 1b wouldn't, and neither would
SUBS r0,#1; BNE 1b; [interrupt].
2024-04-12 15:49:45 +00:00
Rafael Kitover
8abe3e79da build: remove -lgcc from static link flags
Remove -lgcc from static link flags for gcc/clang, clang does not
support this and -static-libgcc is enough.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-12 15:44:27 +00:00
Rafael Kitover
710ffeb1b2 build: update mac build
Update dists for gettext and gsed to get around new compile errors from
clang.

Update SDL and ffmpeg and add FAudio.

Make some other minor adjustments for recent changes.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 22:52:35 +00:00
Rafael Kitover
a855ff54f4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 16:00:21 +00:00
Rafael Kitover
dbb5e534e4 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-10 00:00:21 +00:00
Rafael Kitover
753956963c translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-09 07:00:21 +00:00
Rafael Kitover
b00e23f5b5 build: enable FAudio on non-Windows
Enable FAudio on non-Windows too if the cmake support is found.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-08 04:02:48 +00:00
Fabrice de Gans
8ef9a66b74 [FAudio] Switch to portable condition_variable
This removes remaining dependencies on Windows in the FAudio code by
removing the device notification code and switching to portable
`condition_variable` for the buffer end notification event.
2024-04-07 16:33:22 -07:00
Rafael Kitover
0e503a525e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-07 11:00:30 +00:00
Rafael Kitover
b4b020401c translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-07 11:00:07 +00:00
Fabrice de Gans
f4835674ed [Audio] Rework audio devices enumeration
This moves all of the audio code in the wx frontend to the
`src/wx/audio` folder and simplifies many call sites by having one
generic API to enumerate audio devices and create the audio driver.

In addition, this fixes many corner cases in device enumerations and
moves handling of the default device to the respective audio backends,
rather than pushing it to the UI.

Finally, this changes the `Sound/AudioDevice` setting to use the
underlying device ID, rather than the user-facing name.
2024-04-07 03:51:39 -07:00
Rafael Kitover
4104a3d179 build: fix codesigning Windows bins with signtool
Pass `/fd certHash /td certHash` to signtool as they are required
arguments.

signtool comes with Visual Studio and now works and we don't need to
require osslsigncode anymore.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 23:45:14 +00:00
Rafael Kitover
1e1ec2e330 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 18:00:20 +00:00
Rafael Kitover
ff21f8da21 build: enable FAudio sound driver on Windows
Enable FAudio on Windows if cmake can find it.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 11:22:20 +00:00
Rafael Kitover
775a571f75 build: fix detecting Visual Studio default vcpkg
Make the regular expression against VCPKG_ROOT less specific for
detecting the default Visual Studio vcpkg, for some reason it stopped
working.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 11:09:34 +00:00
Fabrice de Gans
64abd3e8dc [Audio] Remove manual memory allocations
* Remove explicit calls to new or malloc in favor of owned objects.
* Move AudioSdl to the sdl frontend, it is no longer used by the wx
  frontend.
2024-04-06 03:42:33 -07:00
Rafael Kitover
56320ec6d1 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-06 08:00:20 +00:00
Zach Bacon
311b232ee5 FAudio: Implement and have functional FAudio output
Corrected the current FAudio output code, FAudio api wasn't
a direct 1 for 1 code replacement. Adjusted the existing
code structure so that FAudioVoiceCallBack struct
was being properly called on.

Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
2024-04-05 15:37:39 -07:00
Rafael Kitover
0e13cc9346 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-05 02:00:21 +00:00
Rafael Kitover
b455de01c6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-04 22:00:27 +00:00
Rafael Kitover
c3053d3819 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-04 22:00:08 +00:00
Fabrice de Gans
c8106573d8 [Dialogs] Move SoundConfig dialog to its own class
This fixes a number of issues with the current implementation. Namely,
some options were not properly saved and the audio driver was not
properly reloaded when some options were changed.
In addition, this moves most sound-related options to `g_owned_opts` and
simplifies many call sites.
2024-04-04 14:22:23 -07:00
Fabrice de Gans
047ad27777 [Dialogs] Prevent viewers from causing a crash
Some of the viewers dialogs were not properly set up and were causing a
crash at runtime.
2024-04-04 12:10:44 -07:00
Rafael Kitover
ecd16a21dc translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 14:00:25 +00:00
Rafael Kitover
1594fda1b6 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 13:00:22 +00:00
Rafael Kitover
de9b3a211b translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 12:00:22 +00:00
Rafael Kitover
045c98d8fa build: only use -Werror=lto-type-mismatch on gcc
Only pass -Werror=lto-type-mismatch to gcc, clang does not have this
option and throws a warning.

Also quote some barewords in if() statements.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-03 10:30:04 +00:00
Fabrice de Gans
4ace296b3a [Build] Improve the TRANSLATIONS_ONLY build speed
* Move CMake dependencies checkout to `cmake/Dependencies.cmake`.
* Disable most dependencies checkout from the `TRANSLATIONS_ONLY` build.
* Remove the debug/translations_only GitHub Action.
2024-04-02 11:56:19 -07:00
Rafael Kitover
011adce23e translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 17:00:21 +00:00
Rafael Kitover
cc99ec0c14 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 13:00:37 +00:00
Rafael Kitover
1d652edf83 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-02 13:00:07 +00:00
Fabrice de Gans
db08ca93af [Build] Improve CI build coverage
This reworks the CI coverage to add `TRANSLATIONS_ONLY=ON` and libretro
builds to GitHub Actions.
2024-04-01 23:28:20 -07:00
Rafael Kitover
3518dc6a05 build: fix LTO on Linux
Add -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing to
compile and link options for gcc/clang always.

Rename struct yy_buffer_state in src/sdl/expr-lex.cpp to struct
yy_buffer_state_sdl because it breaks when linking the SDL binary with
-Werror=odr.

Fix #1260

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 21:40:35 -07:00
Rafael Kitover
cc9a03ce48 Add toggle: SDL GameController mode for joysticks
Add a toggle for SDL GameController Mode in the game key configuration
dialog, default enabled.

On check or uncheck, change the option and reinitialize joysticks, not
using GameController mode if it is disabled.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 21:21:53 -07:00
Fabrice de Gans
8576733c0d [Build] Remove lingering references to OpenAl
OpenAl is now required to build.
2024-04-01 21:14:51 -07:00
Rafael Kitover
c6da7e384e build: add faudio to list of optional vcpkg deps
Add faudio to list of optional vcpkg deps linked to ENABLE_FAUDIO.

This codepath is not used right now as we are using binary packages.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-04-01 14:17:48 +00:00
Rafael Kitover
98abb8c2e8 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-31 02:00:22 +00:00
Rafael Kitover
0556192238 build: fix MSYS2 check
Fix cmake logic for detecting MSYS2 "$ENV{MSYSTEM_PREFIX}".

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-31 01:16:36 +00:00
Rafael Kitover
d9432ebb14 build: fix build on MINGW{64,32}/UCRT64 on MSYS2
Pass -Wno-deprecated-copy only for C++, gcc gives a warning for C.

Pass -Wno-unused-command-line-argument for clang only, gcc gives a
warning about it.

Add a failsafe for gcc/clang static link flags if libstdc++ or
libpthread is not available as a static library.

Move link command adjustment script invocations to src/wx, the target is
not yet defined in the toolchain.

Add -lws2_32 to the end of the link command for gcc on Windows because
of link order issues with those symbols.

Disable LTO for gcc on Windows, as it is broken.

Don't install extra-cmake-modules on MINGW32, that package is not
available there.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 20:14:32 +00:00
Rafael Kitover
f57cad67c4 build: fix static linking on MSYS2 CLANG64
Bring back setting the MSYS variable under MSYS2, it's still being used
in a few places.

Link the SDL2::SDL2-static target for static builds.

Add -static-libgcc and -static-libstdc++ to the gcc/clang toolchain for
static builds.

Edit wxWidgets_LIBRARIES under MSYS2 to specify liblzma.a explicitly
because for some reason it's not being linked statically by default for
static builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 18:06:25 +00:00
Rafael Kitover
ce7cc4e223 build: add FAudio to MSYS2 deps
In preparation for FAudio support, add the dependency to ./installdeps
for MSYS2 toolchains.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-30 17:37:20 +00:00
Rafael Kitover
8183a005af translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-29 02:00:21 +00:00
Rafael Kitover
75a34cd098 translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-28 02:00:21 +00:00
Rafael Kitover
23e1573442 build: set wxWidgets_DIR with vcpkg
When using vcpkg as the toolchain, pass NO_DEFAULT_PATH to
find_package(wxWidgets ...) so that the default cmake
FindwxWidgets.cmake is not included.

Set wxWidgets_DIR to the
<vcpkg-root>/installed/<triplet>/share/wxwidgets vcpkg port directory
for the subsequent find_package() calls to find the port-installed
wxWidgetsConfig.cmake file.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-27 03:02:33 +00:00
Fabrice de Gans
98b51910eb [Build] Remove ENABLE_NLS, fix TRANSLATIONS_ONLY
* Remove the ENABLE_NLS option, it is now always enabled.
* Fix the TRANSLATIONS_ONLY build to properly build the zip file.
2024-03-26 17:38:12 -07:00
Rafael Kitover
c3f0aa2edf translations: transifex pull
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-26 22:18:10 +00:00
Rafael Kitover
ea596e4cb0 translations: rebuild source .pot
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-03-26 22:17:52 +00:00
Fabrice de Gans
68adb14b07 [Build] Use Toolchain-gcc-clang for non-MSVC
Apple compiler ID is defined as `AppleClang`. Rather than explicitly
adding every single compiler ID, this changes the build to try to apply
settings for GCC for every non-MSVC-like compilers.
2024-03-18 17:12:51 -07:00
Fabrice de Gans
a565cea8e9 [Build] Remove the OpenGL check
This is no longer necessary with modern CMake.
2024-03-18 23:56:22 +00:00
Fabrice de Gans
6ac95d373f [Build] Rework wx/CMakeLists.txt
* Bring the wx frontend more in-line with the rest of the codebase.
* Always default to Unicode APIs on Windows.
* Clean up all include guards and headers.
2024-03-18 23:56:22 +00:00
Fabrice de Gans
d4430ca440 [Build] Move SDL build configuration to sdl/
* Clean up SDL includes and include guards.
* Add the sdl target to `sdl/CMakeLists.txt`.
2024-03-17 14:41:07 -07:00
Fabrice de Gans
000c7f854c [Build] Move non-core common code to components/
* Create multiple components library. These depend on the core code and
  are used by multiple frontends.
* Clean up the filters declaration by moving them to a common header in
  `components/filters/filters.h`.
* Clean up the include guards and include orders.
* Fix the modified paths in `src/debian/copyright` to match their new
  location.
2024-03-16 17:32:09 -07:00
Fabrice de Gans
047bd935ea [Build] Move the core emulator to src/core/
* Move src/apu/, src/gb/ and src/gba/ to src/core/.
* Clean up include guards and headers.
* Rename `BKPT_SUPPORT` to `VBAM_ENABLE_DEBUGGER` and remove the
  `NO_DEBUGGER` define.
2024-03-16 14:35:36 -07:00
Fabrice de Gans
33cb9a66d4 [Build] Move System.h and most of Util.h to core/
* Move System.h to core/base.
* Move most of the functionality out of Util.h to core/base.
* Fix corresponding headers.
2024-03-15 20:43:57 -07:00
Fabrice de Gans
f8374b52a8 [Build] Move more of src/common to src/core/base
* Clean out all of the dependent headers.
* Modify generated version.h to improve the dependency chain and isolate
  the generated file to its own sub-directory within the build
  directory.
2024-03-15 19:51:52 -07:00
Fabrice de Gans
2f10e71f1d [Build] Cleanup files in src/common
* Remove unused files.
* Move files used only by the SDL frontend to the sdl folder.
* Remove contains.h in favor of manual iterator parsing.
2024-03-15 17:05:16 -07:00
Fabrice de Gans
8f92d99968 [Build] Move file-related utilities to core/base
* Remove duplicate function definitions between the libretro and other
  frontends by merging them into a common source file.
* Also move `systemMessage()` and message IDs definitions to core/base.
* Clean up and modernize many file utility methods.
2024-03-15 16:04:45 -07:00
Fabrice de Gans
ce12db1e06 [Build] Move fex/ to src/core/fex/
* Clean up source set and public headers.
* Make the fex library an OBJECT library to speed up build.
* Clean up the only fex include to use the full path to the header.
2024-03-15 12:16:40 -07:00
Fabrice de Gans
d8a1886ccb [Build] Use new way of setting /Z flag with MSVC
CMake 3.25 introduced the CMAKE_MSVC_DEBUG_INFORMATION_FORMAT to set the
/Z flag for MSVC toolchains. Use it rather than modifying the compile
options if possible. We revert to setting the compile options manually
if the CMake version is too old.
2024-03-15 11:32:38 -07:00
Fabrice de Gans
1d051d0e6e [Build] Make powershell optional on non-Windows (#1248)
Fixes: #1247
2024-03-15 11:32:24 -07:00
Fabrice de Gans
f96e42fe04 build: cmake refactor and improvements
* Use add_compile_definitions everywhere.
* Remove unused intermediate target.
* Add ASAN support for MSVC.
* Remove duplicate option definitions.
* Configure MinGW separately from the toolchain
2024-03-15 16:19:01 +00:00
441 changed files with 45191 additions and 35568 deletions

View File

@@ -1,27 +1,57 @@
name: macOS Latest Build
on: [push, pull_request]
#on: workflow_dispatch
jobs:
build:
strategy:
matrix:
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
runs-on: macos-latest
env:
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM: 1
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Configure
# Cmake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: >-
nix-shell --command 'cmake -B build -G Ninja ${{ matrix.cmake_build }} -DENABLE_LTO=OFF ${{ matrix.cmake_options }}'
- name: Build
- if: matrix.build_options != 'libretro'
name: Build
run: >-
nix-shell --command 'ninja -C build'
# Libretro build
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: >-
nix-shell --command 'make -C src/libretro ${{ matrix.libretro_build }}'

View File

@@ -5,8 +5,27 @@ jobs:
build:
strategy:
matrix:
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
runs-on: windows-latest
env:
MSYSTEM: CLANG64
@@ -16,7 +35,7 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup msys2
@@ -27,11 +46,19 @@ jobs:
- name: Install deps
run: >-
bash installdeps
- name: Configure
run: >-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
run: ninja -C build
- name: Install
# CMake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: cmake -B build -G Ninja ${{ matrix.cmake_build }} -DENABLE_LTO=OFF ${{ matrix.cmake_options }}
- if: matrix.build_options != 'libretro'
name: Build
run: ninja -C build
- if: matrix.build_options != 'libretro'
name: Install
run: ninja -C build install
# Libretro build
- if: matrix.build_options == 'libretro'
name: Build libretro core
run: make -C src/libretro ${{ matrix.libretro_build }} CC=clang CXX=clang++

View File

@@ -5,26 +5,59 @@ jobs:
build:
strategy:
matrix:
cmake_compiler: ['-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++', '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++']
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_compiler: [gcc, clang]
build_type: [release, debug]
build_options: [default, link_off, translations_only, libretro]
include:
- cmake_compiler: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
build_compiler: gcc
- cmake_compiler: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'
build_compiler: clang
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- libretro_build: 'DEBUG=0'
build_type: release
build_options: libretro
- libretro_build: 'DEBUG=1'
build_type: debug
build_options: libretro
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
- build_type: release
build_options: translations_only
build_compiler: clang
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: >-
bash installdeps; if [ "${{ matrix.compiler }}" = clang ]; then sudo apt -y install clang; fi
bash installdeps; if [ "${{ matrix.build_compiler }}" = clang ]; then sudo apt -y install clang; fi
- name: Configure
# CMake build
- if: matrix.build_options != 'libretro'
name: Configure CMake
run: >-
cmake -B build -G Ninja ${{ matrix.cmake_compiler }} ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
- if: matrix.build_options != 'libretro'
name: Build
run: ninja -C build
- name: Install
- if: matrix.build_options != 'libretro'
name: Install
run: sudo ninja -C build install
# Libretro build
- name: Build libretro core
if: matrix.build_options == 'libretro'
run: make -C src/libretro ${{ matrix.libretro_build }}

View File

@@ -5,32 +5,51 @@ jobs:
build:
strategy:
matrix:
msvc_arch: ['x64', 'x64_x86']
msvc_arch: ['x64', 'amd64_x86', 'amd64_arm64']
# TODO: Re-add "Visual Studio 17 2022" once it's working.
cmake_generator: ['Ninja']
# cmake_generator: ['Ninja', '"Visual Studio 17 2022"']
cmake_build: ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_BUILD_TYPE=Debug']
cmake_options: ['', '-DENABLE_LINK=OFF', '-DENABLE_SDL=ON']
build_type: [release, debug]
build_options: [default, link_off, translations_only]
include:
- cmake_build: '-DCMAKE_BUILD_TYPE=Release'
build_type: release
- cmake_build: '-DCMAKE_BUILD_TYPE=Debug'
build_type: debug
- cmake_options: '-DENABLE_LINK=OFF'
build_options: link_off
- cmake_options: '-DTRANSLATIONS_ONLY=ON'
build_options: translations_only
- cmake_vcpkg_triplet: 'x64-windows-static'
msvc_arch: x64
- cmake_vcpkg_triplet: 'x86-windows-static'
msvc_arch: amd64_x86
- cmake_vcpkg_triplet: 'arm64-windows-static'
msvc_arch: amd64_arm64
exclude:
# Exclude debug/translations_only build
- build_type: debug
build_options: translations_only
- build_type: release
build_options: translations_only
msvc_arch: amd64_x86
- build_type: release
build_options: translations_only
msvc_arch: amd64_arm64
runs-on: windows-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare Visual Studio environment
uses: ilammy/msvc-dev-cmd@v1.12.0
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: ${{ matrix.msvc_arch }}
- name: Configure (x64)
if: matrix.msvc_arch == 'x64'
- name: Configure
run: >-
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=x64-windows-static ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Configure (x86)
if: matrix.msvc_arch == 'x64_x86'
run: >-
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=x86-windows-static ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
cmake -B build -G ${{ matrix.cmake_generator }} -DVCPKG_TARGET_TRIPLET=${{ matrix.cmake_vcpkg_triplet }} ${{ matrix.cmake_build }} ${{ matrix.cmake_options }}
- name: Build
run: cmake --build build

View File

@@ -20,6 +20,7 @@ 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)
@@ -28,7 +29,7 @@ if(WIN32)
HINTS "/Windows/System32/WindowsPowerShell/v1.0"
REQUIRED)
else()
find_program(POWERSHELL pwsh REQUIRED)
find_program(POWERSHELL pwsh)
endif()
include(Set-Toolchain-vcpkg)
@@ -46,6 +47,29 @@ if(NOT CMAKE_CXX_COMPILER_LAUNCHER)
endif()
endif()
find_package(Git)
# Make sure we pull in the submodules on windows and mingw.
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")
set(SUBMODULE_MANUAL_UPDATE TRUE)
execute_process(
COMMAND "${GIT_EXECUTABLE}" submodule update --init --remote --recursive
RESULT_VARIABLE SUBMODULE_UPDATE_STATUS
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/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()
endif()
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD 11)
@@ -53,13 +77,6 @@ set(CMAKE_C_STANDARD_REQUIRED True)
project(VBA-M C CXX)
find_package(Git)
find_package(PkgConfig)
include(GNUInstallDirs)
include(Options)
include(Architecture)
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
endif()
@@ -75,76 +92,25 @@ 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()
set(ALL_TARGETS fex visualboyadvance-m vbamcore vbam)
add_custom_target(generate)
#Output all binaries at top level
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(NOT HTTPS)
add_definitions(-DNO_HTTPS)
endif()
if(WIN32 OR CMAKE_TOOLCHAIN_FILE MATCHES "[Mm][Ii][Nn][Gg][Ww]")
# Win32 deps submodule
set(git_checkout FALSE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(git_checkout TRUE)
execute_process(
COMMAND git submodule update --init --remote --recursive
RESULT_VARIABLE git_status
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(NOT (git_checkout AND git_status EQUAL 0))
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
endif()
endif()
endif()
if(MSVC)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# TODO: We should update the XAudio headers to build with clang-cl. See
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
add_definitions(-DNO_XAUDIO2)
endif()
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
if(ENABLE_GBA_LOGGING)
add_definitions(-DGBA_LOGGING )
endif()
if(ENABLE_MMX)
add_definitions(-DMMX)
endif()
# The SDL port can't be built without debugging support
if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
message(SEND_ERROR "The SDL port can't be built without debugging support")
endif()
# this has to run after the toolchain is initialized so it can't be in
# Win32deps.cmake
if(MINGW)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
endif()
include(GNUInstallDirs)
include(Options)
include(Architecture)
include(Toolchain)
include(Dependencies)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GitTagVersion)
git_version(VERSION REVISION VERSION_RELEASE)
git_version(VBAM_VERSION VBAM_REVISION VBAM_VERSION_RELEASE)
# only use the plugin to tie the configure state to the sha to force rebuilds
# of files that depend on version.h
@@ -193,648 +159,24 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
endif()
# no git or no tags, use ChangeLog
if(NOT VERSION)
if(NOT VBAM_VERSION)
include(ChangeLogVersion)
changelog_version(VERSION REVISION VERSION_RELEASE)
endif()
# generate version.h
include_directories(${CMAKE_BINARY_DIR})
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1,\\2,\\3,0" WIN_VERSION "${VERSION}")
configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
endif()
# hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
include(VbamFunctions)
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if($ENV{MSYSTEM} STREQUAL CLANG64)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
endif()
# We do not support amd64 asm yet
if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.")
endif()
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
if(MSVC)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
endif()
execute_process(
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
endif()
enable_language(ASM_NASM)
set(ASM_ENABLED ON)
endif()
if(NOT WIN32)
find_library(PTHREAD_LIB pthread)
if(PTHREAD_LIB)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREAD_LIB})
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${PTHREAD_LIB})
endif()
elseif(MINGW)
if(NOT VBAM_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lpthread)
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} -lpthread)
else()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic")
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic")
endif()
else()
find_package(PThreads4W)
if(PThreads4W_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} PThreads4W::PThreads4W)
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} PThreads4W::PThreads4W)
endif()
endif()
# Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(OpenGL_GL_PREFERENCE LEGACY)
endif()
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
# Add libsamplerate to SDL2 with vcpkg
unset(SDL2_LIBRARY_TEMP)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(WIN32)
unset(arch_suffix)
unset(path_prefix)
if(VCPKG_TARGET_TRIPLET MATCHES -static)
set(arch_suffix -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(path_prefix debug)
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
else()
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
endif()
endif()
set(SDL2_TARGETS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
# set the standard libraries all ports use
set(
VBAMCORE_LIBS
vbamcore
fex
${SDL2_TARGETS}
${SFML_LIBRARIES}
${OPENGL_LIBRARIES}
${ZLIB_LIBRARY}
)
if(ENABLE_FFMPEG)
if(NOT FFMPEG_LIBRARIES)
message(FATAL_ERROR "ENABLE_FFMPEG was specified, but required versions of ffmpeg libraries cannot be found!")
endif()
if(APPLE)
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices)
if(UPSTREAM_RELEASE)
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -lbz2 -ltiff -framework DiskArbitration -lfreetype -lfontconfig -llzma -lxml2 -lharfbuzz)
endif()
elseif(WIN32)
set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid)
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt ${WIN32_MEDIA_FOUNDATION_LIBS})
if(MSYS AND VBAM_STATIC)
foreach(lib tiff jbig lzma)
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${lib}.a")
list(APPEND FFMPEG_LIBRARIES "${lib}")
endforeach()
endif()
endif()
else()
add_definitions(-DNO_FFMPEG)
endif()
if(NOT ENABLE_ONLINEUPDATES)
add_definitions(-DNO_ONLINEUPDATES)
endif()
if(ENABLE_LIRC)
set(WITHLIRC 1)
else()
set(WITHLIRC 0)
endif()
# C defines
add_definitions(-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" -DWITH_LIRC=${WITHLIRC})
add_definitions(-DPKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam" -DPACKAGE=)
add_definitions(-D__STDC_FORMAT_MACROS)
# For C++, default to nonstd::optional and nonstd::variant for now due to mac
# build issues.
if(APPLE)
add_definitions(-Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_NONSTD)
add_definitions(-Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD)
else()
add_definitions(-Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_STD)
add_definitions(-Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_STD)
endif()
if(ENABLE_LINK)
# IPC linking code needs sem_timedwait which can be either in librt or pthreads
if(NOT WIN32)
find_library(RT_LIB rt)
if(RT_LIB)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIB})
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${RT_LIB})
endif()
endif()
include(CheckFunctionExists)
check_function_exists(sem_timedwait SEM_TIMEDWAIT)
if(SEM_TIMEDWAIT)
add_definitions(-DHAVE_SEM_TIMEDWAIT)
endif()
else()
add_definitions(-DNO_LINK)
endif()
# The debugger is enabled by default
if(NOT ENABLE_DEBUGGER)
add_definitions(-DNO_DEBUGGER)
else()
add_definitions(-DBKPT_SUPPORT)
endif()
# The ASM core is disabled by default because we don't know on which platform we are
if(NOT ENABLE_ASM_CORE)
add_definitions(-DC_CORE)
changelog_version(VBAM_VERSION VBAM_REVISION VBAM_VERSION_RELEASE)
endif()
# Enable internationalization
if(ENABLE_NLS)
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
add_definitions(-DENABLE_NLS)
add_definitions(-DLOCALEDIR="${LOCALEDIR}")
# for now, only GBALink.cpp uses gettext() directly
if(APPLE)
# use Homebrew gettext if available
if(EXISTS "/usr/local/opt/gettext")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib")
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin")
endif()
endif()
if(ENABLE_LINK OR ENABLE_WX)
find_path(LIBINTL_INC libintl.h)
find_library(LIBINTL_LIB NAMES libintl intl)
find_library(LIBICONV_LIB NAMES libiconv iconv)
find_library(LIBCHARSET_LIB NAMES libcharset charset)
if(LIBINTL_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIB})
list(APPEND VBAMCORE_LIBS ${LIBINTL_LIB})
endif()
if(LIBICONV_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_LIB})
list(APPEND VBAMCORE_LIBS ${LIBICONV_LIB})
endif()
if(LIBCHARSET_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_LIB})
list(APPEND VBAMCORE_LIBS ${LIBCHARSET_LIB})
endif()
include(CheckFunctionExists)
check_function_exists(gettext GETTEXT_FN)
if(NOT (LIBINTL_INC OR GETTEXT_FN))
message(FATAL_ERROR "NLS requires libintl/gettext")
endif()
include_directories(${LIBINTL_INC})
endif()
endif()
include(Toolchain)
if(APPLE)
add_definitions(-DMACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_definitions(-DELF)
endif()
if(X86_64)
add_definitions(-D__AMD64__ -D__X86_64__)
endif()
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
if(NOT TRANSLATIONS_ONLY)
add_subdirectory(fex)
add_subdirectory(third_party/include/nonstd)
add_subdirectory(third_party/include/stb)
add_subdirectory(src/core)
add_subdirectory(src/components)
add_subdirectory(src/sdl)
endif()
set(
SRC_MAIN
src/Util.cpp
src/common/dictionary.c
src/common/iniparser.c
src/common/Patch.cpp
src/common/memgzio.c
src/common/SoundSDL.cpp
)
if(MSVC)
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
endif()
set(
HDR_MAIN
src/System.h
src/Util.h
src/common/array.h
src/common/dictionary.h
src/common/iniparser.h
src/common/memgzio.h
src/common/Port.h
src/common/sizes.h
src/common/SoundDriver.h
src/common/SoundSDL.h
)
if(MSVC)
set(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
endif()
if(ENABLE_FFMPEG)
set(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp)
set(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h)
endif()
if(ENABLE_NLS)
set(HDR_MAIN ${HDR_MAIN} src/NLS.h)
endif()
set(
SRC_GBA
src/gba/agbprint.cpp
src/gba/bios.cpp
src/gba/Cheats.cpp
src/gba/CheatSearch.cpp
# Built with flex -o debugger-expr-lex.cpp -P dexp_ debugger-expr.l
src/gba/debugger-expr-lex.cpp
# Built with bison -L c -o debugger-expr-yacc.cpp -H -p dexp_ debugger-expr.y
# The yyerrorlab label handler was manually commented out to silence a
# compiler warning.
src/gba/debugger-expr-yacc.cpp
src/gba/EEprom.cpp
src/gba/ereader.cpp
src/gba/Flash.cpp
src/gba/GBA.cpp
src/gba/GBAGfx.cpp
src/gba/GBALink.cpp
src/gba/GBASockClient.cpp
src/gba/GBA-thumb.cpp
src/gba/GBA-arm.cpp
src/gba/gbafilter.cpp
src/gba/Globals.cpp
src/gba/Mode0.cpp
src/gba/Mode1.cpp
src/gba/Mode2.cpp
src/gba/Mode3.cpp
src/gba/Mode4.cpp
src/gba/Mode5.cpp
src/gba/RTC.cpp
src/gba/Sound.cpp
src/gba/Sram.cpp
)
if(ENABLE_DEBUGGER)
list(APPEND SRC_GBA
src/gba/BreakpointStructures.cpp
)
endif()
set(
HDR_GBA
src/gba/agbprint.h
src/gba/bios.h
src/gba/BreakpointStructures.h
src/gba/Cheats.h
src/gba/CheatSearch.h
src/gba/debugger-expr-yacc.hpp
src/gba/EEprom.h
src/gba/ereader.h
src/gba/Flash.h
src/gba/GBA.h
src/gba/GBAcpu.h
src/gba/gbafilter.h
src/gba/GBAGfx.h
src/gba/GBAinline.h
src/gba/GBALink.h
src/gba/GBASockClient.h
src/gba/Globals.h
src/gba/RTC.h
src/gba/Sound.h
src/gba/Sram.h
)
set(
SRC_GB
src/gb/GB.cpp
src/gb/gbCartData.cpp
src/gb/gbCheats.cpp
src/gb/gbDis.cpp
src/gb/gbGfx.cpp
src/gb/gbGlobals.cpp
src/gb/gbMemory.cpp
src/gb/gbPrinter.cpp
src/gb/gbSGB.cpp
src/gb/gbSound.cpp
)
set(
HDR_GB
src/gb/gb.h
src/gb/gbCartData.h
src/gb/gbCheats.h
src/gb/gbCodes.h
src/gb/gbCodesCB.h
src/gb/gbGlobals.h
src/gb/gbMemory.h
src/gb/gbPrinter.h
src/gb/gbSGB.h
src/gb/gbSound.h
)
set(
SRC_APU
src/apu/Blip_Buffer.cpp
src/apu/Effects_Buffer.cpp
src/apu/Gb_Apu.cpp
src/apu/Gb_Apu_State.cpp
src/apu/Gb_Oscs.cpp
src/apu/Multi_Buffer.cpp
)
set(
HDR_APU
src/apu/blargg_common.h #Unused(?) but in the VS projects
src/apu/blargg_config.h #Unused(?) but in the VS projects
src/apu/blargg_source.h
src/apu/Blip_Buffer.h
src/apu/Effects_Buffer.h
src/apu/Gb_Apu.h
src/apu/Gb_Oscs.h
src/apu/Multi_Buffer.h
)
set(
SRC_SDL
src/sdl/ConfigManager.cpp
src/sdl/SDL.cpp
src/sdl/filters.cpp
src/sdl/text.cpp
src/sdl/inputSDL.cpp
src/sdl/expr.cpp
src/sdl/exprNode.cpp
src/sdl/expr-lex.cpp
src/common/version.cpp
)
set(
HDR_SDL
src/sdl/ConfigManager.h
src/sdl/filters.h
src/sdl/text.h
src/sdl/inputSDL.h
src/sdl/expr.cpp.h
src/sdl/exprNode.h
src/common/version_cpp.h
)
set(
SRC_FILTERS
src/filters/2xSaI.cpp
src/filters/admame.cpp
src/filters/bilinear.cpp
src/filters/hq2x.cpp
src/filters/interframe.cpp
src/filters/pixel.cpp
src/filters/scanline.cpp
src/filters/simpleFilter.cpp
src/filters/xbrzfilter.cpp
src/filters/xBRZ/xbrz.cpp
)
set(
HDR_FILTERS
src/filters/hq2x.h
src/filters/interp.h
src/filters/lq2x.h
src/filters/xBRZ/xbrz_config.h
src/filters/xBRZ/xbrz.h
src/filters/xBRZ/xbrz_tools.h
)
set(
SRC_HQ_C
src/filters/hq/c/hq_implementation.cpp
)
set(
HDR_HQ_C
src/filters/hq/c/hq3x_pattern.h
src/filters/hq/c/hq4x_pattern.h
src/filters/hq/c/hq_base.h
src/filters/hq/c/hq_shared.h
)
set(
SRC_HQ_ASM
src/filters/hq/asm/hq3x_16.asm
src/filters/hq/asm/hq3x_32.asm
src/filters/hq/asm/hq4x_16.asm
src/filters/hq/asm/hq4x_32.asm
src/filters/hq/asm/hq3x32.cpp
)
if(ENABLE_ASM_SCALERS)
set(SRC_FILTERS ${SRC_FILTERS} ${SRC_HQ_ASM})
if(ENABLE_MMX)
set(SRC_FILTERS ${SRC_FILTERS} src/filters/2xSaImmx.asm)
endif()
else()
set(SRC_FILTERS ${SRC_FILTERS} ${SRC_HQ_C})
set(HDR_FILTERS ${HDR_FILTERS} ${HDR_HQ_C})
add_definitions(-DNO_ASM)
endif()
set(
SRC_DEBUGGER
src/gba/armdis.cpp
src/gba/elf.cpp
)
set(
HDR_DEBUGGER
src/gba/armdis.h
src/gba/elf.h
)
if(ENABLE_DEBUGGER)
set(
SRC_DEBUGGER
${SRC_DEBUGGER}
src/gba/remote.cpp
)
set(
HDR_DEBUGGER
${HDR_DEBUGGER}
src/gba/remote.h
)
endif()
set(
HDR_STB_IMAGE
third_party/include/stb/stb_image.h
third_party/include/stb/stb_image_write.h
)
include_directories(
${ZLIB_INCLUDE_DIR}
fex
third_party/include
third_party/include/stb
)
if(ENABLE_FFMPEG)
include_directories(
${FFMPEG_INCLUDE_DIRS}
)
endif()
if(NOT TRANSLATIONS_ONLY)
add_library(
vbamcore
STATIC
${PROJECT_SRCS}
${SRC_MAIN}
${HDR_MAIN}
${SRC_GBA}
${HDR_GBA}
${SRC_GB}
${HDR_GB}
${SRC_APU}
${HDR_APU}
${SRC_FILTERS}
${HDR_FILTERS}
${SRC_DEBUGGER}
${HDR_DEBUGGER}
${HDR_STB_IMAGE}
)
add_dependencies(vbamcore generate)
target_include_directories(vbamcore PUBLIC ${SDL2_INCLUDE_DIRS})
endif()
if((NOT TRANSLATIONS_ONLY) AND ENABLE_SDL)
add_executable(
vbam
WIN32
${SRC_SDL}
${HDR_SDL}
)
if(WIN32)
set(WIN32_LIBRARIES wsock32 ws2_32 winmm version imm32)
endif()
if(MSVC)
# the debug lib libcmtd is linked in debug mode, so don't link the normal version
set_target_properties(vbam PROPERTIES LINK_FLAGS_DEBUG "/nodefaultlib:libcmt")
endif()
if(ENABLE_LIRC)
set(LIRC_CLIENT_LIBRARY lirc_client)
endif()
target_link_libraries(
vbam
${VBAMCORE_LIBS}
${WIN32_LIBRARIES}
${LIRC_CLIENT_LIBRARY}
)
if(WIN32)
target_link_libraries(vbam ${SDL2MAIN_LIBRARY})
endif()
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
if(WIN32)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
RENAME vbam.cfg
)
else()
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
RENAME vbam.cfg
)
endif()
endif()
if(ENABLE_WX)
add_subdirectory(src/wx)
endif()
if(ENABLE_WX)
# Native Language Support
if(ENABLE_NLS)
add_subdirectory(po)
endif()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vba-over.ini DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/vbam)
# manual pages
if(UNIX)
if(ENABLE_SDL)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
endif()
if(ENABLE_WX)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
endif()
endif()
add_subdirectory(src/wx)
add_subdirectory(po/wxvbam)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "TGZ")
@@ -843,5 +185,3 @@ 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")
include(CPack)
# vim:sw=4 et tw=0:

View File

@@ -3,6 +3,7 @@
- [Visual Boy Advance - M](#visual-boy-advance---m)
- [System Requirements](#system-requirements)
- [Building](#building)
- [Building a Libretro core](#building-a-libretro-core)
- [Visual Studio Support](#visual-studio-support)
@@ -56,6 +57,17 @@ the `translations.zip` to the same directory as the executable.
If you are having issues, try resetting the config file first, go to `Help ->
Factory Reset`.
## System Requirements
Windows 7, 8.1 or 10/11, Linux distro's 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.
- 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.
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:
@@ -148,7 +160,7 @@ And the following development libraries:
- [zlib](https://zlib.net/) (required)
- [mesa](https://mesa3d.org/) (if using X11 or any OpenGL otherwise)
- [ffmpeg](https://ffmpeg.org/) (optional, at least version `4.0.4`, for game recording)
- [gettext](https://www.gnu.org/software/gettext/) and gettext-tools (optional, with ENABLE_NLS)
- [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)
@@ -205,7 +217,6 @@ Here is the complete list:
| ENABLE_SDL | Build the SDL port | OFF |
| ENABLE_WX | Build the wxWidgets port | ON |
| ENABLE_DEBUGGER | Enable the debugger | ON |
| ENABLE_NLS | Enable translations | 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 |
@@ -218,7 +229,6 @@ Here is the complete list:
| 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_OPENAL | Enable OpenAL for the wxWidgets port | AUTO |
| 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 |

View File

@@ -21,3 +21,32 @@ linkage:
short: Shared
long: Create shared libraries/DLLs
linkage: shared
useLink:
default: withlink
choices:
withlink:
short: WithLink
long: Enable the Link feature
settings:
ENABLE_LINK: ON
nolink:
short: NoLink
long: Disable the Link feature
settings:
ENABLE_LINK: OFF
useDebugger:
default: withdebugger
choices:
withdebugger:
short: WithDebugger
long: Enable the Debugger feature
settings:
ENABLE_DEBUGGER: ON
nodebugger:
short: NoDebugger
long: Disable the Debugger feature
settings:
ENABLE_DEBUGGER: OFF
ENABLE_SDL: OFF

View File

@@ -1,3 +1,7 @@
if(TRANSLATIONS_ONLY)
return()
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR)
if(NOT CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
@@ -63,3 +67,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "[aA][aA][rR][cC][hH]|[aA][rR][mM]")
set(CMAKE_CROSSCOMPILING TRUE)
endif()
endif()
# We do not support amd64 asm yet
if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.")
endif()

122
cmake/Dependencies.cmake Normal file
View File

@@ -0,0 +1,122 @@
if(TRANSLATIONS_ONLY)
return()
endif()
# Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(OpenGL_GL_PREFERENCE LEGACY)
endif()
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
# Add libsamplerate to SDL2 with vcpkg
unset(SDL2_LIBRARY_TEMP)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(WIN32)
unset(arch_suffix)
unset(path_prefix)
if(VCPKG_TARGET_TRIPLET MATCHES -static)
set(arch_suffix -static)
endif()
if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
set(path_prefix debug)
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
else()
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
endif()
endif()
if(VBAM_STATIC)
set(VBAM_SDL2_LIBS SDL2::SDL2-static ${SDL2_LIBRARY_TEMP})
else()
set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
endif()
if(ENABLE_FFMPEG)
if(NOT FFMPEG_LIBRARIES)
message(FATAL_ERROR "ENABLE_FFMPEG was specified, but required versions of ffmpeg libraries cannot be found!")
endif()
if(APPLE)
list(APPEND FFMPEG_LDFLAGS "SHELL:-framework CoreText" "SHELL:-framework ApplicationServices")
if(UPSTREAM_RELEASE)
list(APPEND FFMPEG_LDFLAGS -lbz2 -ltiff "SHELL:-framework DiskArbitration" -lfreetype -lfontconfig -llzma -lxml2 -lharfbuzz)
endif()
elseif(WIN32)
set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid)
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt ${WIN32_MEDIA_FOUNDATION_LIBS})
if(MSYS AND VBAM_STATIC)
foreach(lib tiff jbig lzma)
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${lib}.a")
list(APPEND FFMPEG_LIBRARIES "${lib}")
endforeach()
endif()
endif()
else()
add_compile_definitions(NO_FFMPEG)
endif()
if(ENABLE_LINK)
# IPC linking code needs sem_timedwait which can be either in librt or pthreads
if(NOT WIN32)
find_library(RT_LIB rt)
if(RT_LIB)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIB})
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${RT_LIB})
endif()
endif()
include(CheckFunctionExists)
check_function_exists(sem_timedwait SEM_TIMEDWAIT)
if(SEM_TIMEDWAIT)
add_compile_definitions(HAVE_SEM_TIMEDWAIT)
endif()
else()
add_compile_definitions(NO_LINK)
endif()
# for now, only GBALink.cpp uses gettext() directly
if(APPLE)
# use Homebrew gettext if available
if(EXISTS "/usr/local/opt/gettext")
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib")
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin")
endif()
endif()
if(ENABLE_LINK OR ENABLE_WX)
find_path(LIBINTL_INC libintl.h)
find_library(LIBINTL_LIB NAMES libintl intl)
find_library(LIBICONV_LIB NAMES libiconv iconv)
find_library(LIBCHARSET_LIB NAMES libcharset charset)
if(LIBINTL_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIB})
list(APPEND NLS_LIBS ${LIBINTL_LIB})
endif()
if(LIBICONV_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBICONV_LIB})
list(APPEND NLS_LIBS ${LIBICONV_LIB})
endif()
if(LIBCHARSET_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_LIB})
list(APPEND NLS_LIBS ${LIBCHARSET_LIB})
endif()
include(CheckFunctionExists)
check_function_exists(gettext GETTEXT_FN)
if(NOT (LIBINTL_INC OR GETTEXT_FN))
message(FATAL_ERROR "NLS requires libintl/gettext")
endif()
endif()

View File

@@ -1,231 +1,232 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindGettext
# -----------
#
# Find GNU gettext tools
#
# This module looks for the GNU gettext tools. This module defines the
# following values:
#
# ::
#
# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
# GETTEXT_FOUND: True if gettext has been found.
# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
#
#
#
# Additionally it provides the following macros:
#
# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
#
# ::
#
# This will create a target "translations" which will convert the
# given input po files into the binary output mo file. If the
# ALL option is used, the translations will also be created when
# building the default target.
#
# GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
# LANGUAGES <lang1> <lang2> ... )
#
# ::
#
# Process the given pot file to mo files.
# If INSTALL_DESTINATION is given then automatically install rules will
# be created, the language subdirectory will be taken into account
# (by default use share/locale/).
# If ALL is specified, the pot file is processed when building the all traget.
# It creates a custom target "potfile".
#
# GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
# PO_FILES <po1> <po2> ... )
#
# ::
#
# Process the given po files to mo files for the given language.
# If INSTALL_DESTINATION is given then automatically install rules will
# be created, the language subdirectory will be taken into account
# (by default use share/locale/).
# If ALL is specified, the po files are processed when building the all traget.
# It creates a custom target "pofiles".
#
# .. note::
# If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
#[=======================================================================[.rst:
FindGettext
-----------
Find GNU gettext tools
This module looks for the GNU gettext tools. This module defines the
following values:
::
GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
GETTEXT_FOUND: True if gettext has been found.
GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
Additionally it provides the following macros:
GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
::
This will create a target "translations" which will convert the
given input po files into the binary output mo file. If the
ALL option is used, the translations will also be created when
building the default target.
GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
LANGUAGES <lang1> <lang2> ... )
::
Process the given pot file to mo files.
If INSTALL_DESTINATION is given then automatically install rules will
be created, the language subdirectory will be taken into account
(by default use share/locale/).
If ALL is specified, the pot file is processed when building the all target.
It creates a custom target "potfile".
GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
PO_FILES <po1> <po2> ... )
::
Process the given po files to mo files for the given language.
If INSTALL_DESTINATION is given then automatically install rules will
be created, the language subdirectory will be taken into account
(by default use share/locale/).
If ALL is specified, the po files are processed when building the all target.
It creates a custom target "pofiles".
.. versionadded:: 3.2
If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
#]=======================================================================]
find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
if(GETTEXT_MSGMERGE_EXECUTABLE)
execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
OUTPUT_VARIABLE gettext_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
if (gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_2}")
endif()
unset(gettext_version)
unset(msgmerge_name)
unset(msgmerge_namewe)
get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
if (gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_2}")
endif()
unset(gettext_version)
unset(msgmerge_name)
unset(msgmerge_namewe)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext
REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE
VERSION_VAR GETTEXT_VERSION_STRING)
function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name)
set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
if(NOT currentCounter)
set(currentCounter 1)
endif()
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
math(EXPR currentCounter "${currentCounter} + 1")
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
if(NOT currentCounter)
set(currentCounter 1)
endif()
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
math(EXPR currentCounter "${currentCounter} + 1")
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
endfunction()
macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
# make it a real variable, so we can modify it here
set(_firstPoFile "${_firstPoFileArg}")
# make it a real variable, so we can modify it here
set(_firstPoFile "${_firstPoFileArg}")
set(_gmoFiles)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
set(_gmoFiles)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
set(_addToAll)
if(${_firstPoFile} STREQUAL "ALL")
set(_addToAll "ALL")
set(_firstPoFile)
endif()
set(_addToAll)
if(${_firstPoFile} STREQUAL "ALL")
set(_addToAll "ALL")
set(_firstPoFile)
endif()
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
get_filename_component(_abs_PATH ${_absFile} PATH)
string(REGEX REPLACE "^.*/([^/]+)(\\.[^.]+)$" "\\1" _lang ${_absFile})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
foreach (_currentPoFile ${_firstPoFile} ${ARGN})
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
get_filename_component(_abs_PATH ${_absFile} PATH)
get_filename_component(_lang ${_absFile} NAME_WE)
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
add_custom_command(
OUTPUT ${_gmoFile}
#COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile}
)
add_custom_command(
OUTPUT ${_gmoFile}
# COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
DEPENDS ${_absPotFile} ${_absFile}
)
install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
set(_gmoFiles ${_gmoFiles} ${_gmoFile})
install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
set(_gmoFiles ${_gmoFiles} ${_gmoFile})
endforeach ()
endforeach ()
if(NOT TARGET translations)
add_custom_target(translations)
endif()
if(NOT TARGET translations)
add_custom_target(translations)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName)
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
add_dependencies(translations ${uniqueTargetName})
add_dependencies(translations ${uniqueTargetName})
endmacro()
function(GETTEXT_PROCESS_POT_FILE _potFile)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs LANGUAGES)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs LANGUAGES)
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
get_filename_component(_potName ${_potFile} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
foreach (_lang ${_parsedArguments_LANGUAGES})
set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
foreach (_lang ${_parsedArguments_LANGUAGES})
set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
add_custom_command(
OUTPUT "${_poFile}"
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
DEPENDS ${_absPotFile}
)
add_custom_command(
OUTPUT "${_poFile}"
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
DEPENDS ${_absPotFile}
)
add_custom_command(
OUTPUT "${_gmoFile}"
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
DEPENDS ${_absPotFile} ${_poFile}
)
add_custom_command(
OUTPUT "${_gmoFile}"
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
DEPENDS ${_absPotFile} ${_poFile}
)
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach ()
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach ()
if(NOT TARGET potfiles)
add_custom_target(potfiles)
add_custom_target(potfiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName)
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
add_dependencies(potfiles ${uniqueTargetName})
add_dependencies(potfiles ${uniqueTargetName})
endfunction()
function(GETTEXT_PROCESS_PO_FILES _lang)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs PO_FILES)
set(_gmoFiles)
set(_options ALL)
set(_oneValueArgs INSTALL_DESTINATION)
set(_multiValueArgs PO_FILES)
set(_gmoFiles)
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
get_filename_component(_name ${_current_PO_FILE} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
add_custom_command(OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
get_filename_component(_name ${_current_PO_FILE} NAME)
string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
add_custom_command(OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach()
if(_parsedArguments_INSTALL_DESTINATION)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
endif()
list(APPEND _gmoFiles ${_gmoFile})
endforeach()
if(NOT TARGET pofiles)
add_custom_target(pofiles)
add_custom_target(pofiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
if(_parsedArguments_ALL)
add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
else()
add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
endif()
add_dependencies(pofiles ${uniqueTargetName})
add_dependencies(pofiles ${uniqueTargetName})
endfunction()

View File

@@ -57,7 +57,7 @@
# define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES)
add_definitions(-DSFML_STATIC)
add_compile_definitions(SFML_STATIC)
endif()
# define the list of search paths for headers and libraries

View File

@@ -11,8 +11,8 @@
# In addition, the following commands are called with the package manager's
# paths:
#
# INCLUDE_DIRECTORIES()
# LINK_DIRECTORIES()
# include_directories()
# link_directories()
#
# The paths of package managers not currently in $ENV{PATH} are added to
# CMAKE_IGNORE_PATH .
@@ -41,68 +41,75 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IF(NOT APPLE)
RETURN()
ENDIF()
if(NOT APPLE)
return()
endif()
IF(EXISTS /usr/local/bin/brew AND $ENV{PATH} MATCHES "(^|:)/usr/local/bin/?(:|$)")
MESSAGE("-- Configuring for Mac Homebrew")
if(NOT "$ENV{IN_NIX_SHELL}" STREQUAL "")
message(STATUS "Configuring for Nix")
SET(MAC_HOMEBREW ON)
set(NIX ON)
SET(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
elseif(EXISTS /usr/local/bin/brew AND $ENV{PATH} MATCHES "(^|:)/usr/local/bin/?(:|$)")
message(STATUS "Configuring for Mac Homebrew")
SET(CMAKE_FRAMEWORK_PATH /usr/local/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(MAC_HOMEBREW ON)
SET(CMAKE_INCLUDE_PATH /usr/local/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/usr/local/include")
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_LIBRARY_PATH /usr/local/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/usr/local/lib")
set(CMAKE_FRAMEWORK_PATH /usr/local/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_PROGRAM_PATH /usr/local/bin ${CMAKE_PROGRAM_PATH})
set(CMAKE_INCLUDE_PATH /usr/local/include ${CMAKE_INCLUDE_PATH})
include_directories("/usr/local/include")
set(CMAKE_LIBRARY_PATH /usr/local/lib ${CMAKE_LIBRARY_PATH})
link_directories("/usr/local/lib")
set(CMAKE_PROGRAM_PATH /usr/local/bin ${CMAKE_PROGRAM_PATH})
set(ZLIB_ROOT /usr/local/opt/zlib)
ELSEIF(EXISTS /opt/local/bin/port AND $ENV{PATH} MATCHES "(^|:)/opt/local/bin/?(:|$)")
MESSAGE("-- Configuring for MacPorts")
elseif(EXISTS /opt/local/bin/port AND $ENV{PATH} MATCHES "(^|:)/opt/local/bin/?(:|$)")
message(STATUS "Configuring for MacPorts")
SET(MACPORTS ON)
set(MACPORTS ON)
SET(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /sw /sw/bin /sw/include /sw/Library/Frameworks /sw/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_FRAMEWORK_PATH /opt/local/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(CMAKE_FRAMEWORK_PATH /opt/local/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/opt/local/include")
set(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
include_directories("/opt/local/include")
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/opt/local/lib")
set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
link_directories("/opt/local/lib")
SET(CMAKE_PROGRAM_PATH /opt/local/bin ${CMAKE_PROGRAM_PATH})
ELSEIF(EXISTS /sw/bin/fink AND $ENV{PATH} MATCHES "(^|:)/sw/bin/?(:|$)")
MESSAGE("-- Configuring for Fink")
set(CMAKE_PROGRAM_PATH /opt/local/bin ${CMAKE_PROGRAM_PATH})
elseif(EXISTS /sw/bin/fink AND $ENV{PATH} MATCHES "(^|:)/sw/bin/?(:|$)")
message(STATUS "Configuring for Fink")
SET(FINK ON)
set(FINK ON)
SET(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
set(CMAKE_IGNORE_PATH /opt/local /opt/local/bin /opt/local/include /opt/local/Library/Frameworks /opt/local/lib ${CMAKE_IGNORE_PATH})
SET(CMAKE_FRAMEWORK_PATH /sw/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
set(CMAKE_FRAMEWORK_PATH /sw/Library/Frameworks ${CMAKE_FRAMEWORK_PATH})
SET(CMAKE_INCLUDE_PATH /sw/include ${CMAKE_INCLUDE_PATH})
INCLUDE_DIRECTORIES("/sw/include")
set(CMAKE_INCLUDE_PATH /sw/include ${CMAKE_INCLUDE_PATH})
include_directories("/sw/include")
SET(CMAKE_LIBRARY_PATH /sw/lib ${CMAKE_LIBRARY_PATH})
LINK_DIRECTORIES("/sw/lib")
set(CMAKE_LIBRARY_PATH /sw/lib ${CMAKE_LIBRARY_PATH})
link_directories("/sw/lib")
SET(CMAKE_PROGRAM_PATH /sw/bin ${CMAKE_PROGRAM_PATH})
ELSE()
set(CMAKE_PROGRAM_PATH /sw/bin ${CMAKE_PROGRAM_PATH})
else()
# no package manager found or active, do nothing
RETURN()
ENDIF()
return()
endif()
# only ignore /usr/local if brew is installed and not in the PATH
# in other cases, it is the user's personal installations
IF(NOT MAC_HOMEBREW AND EXISTS /usr/local/bin/brew)
SET(CMAKE_IGNORE_PATH /usr/local /usr/local/bin /usr/local/include /usr/local/Library/Frameworks /usr/local/lib ${CMAKE_IGNORE_PATH})
ENDIF()
if(NOT MAC_HOMEBREW AND EXISTS /usr/local/bin/brew)
set(CMAKE_IGNORE_PATH /usr/local /usr/local/bin /usr/local/include /usr/local/Library/Frameworks /usr/local/lib /usr/local/opt/gettext/bin /usr/local/opt/gettext/lib ${CMAKE_IGNORE_PATH})
endif()

View File

@@ -184,8 +184,10 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("CHANGELOG.md.work") -replace "`r`n", "`n"

View File

@@ -1,16 +1,23 @@
option(BUILD_TESTING "Build testing" ON)
option(BUILD_SHARED_LIBS "Build dynamic libraries" OFF)
option(ENABLE_SDL "Build the SDL port" ON)
option(ENABLE_WX "Build the wxWidgets port" ON)
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
if(TRANSLATIONS_ONLY)
set(BUILD_DEFAULT OFF)
else()
set(BUILD_DEFAULT ON)
endif()
option(ENABLE_SDL "Build the SDL port" ${BUILD_DEFAULT})
option(ENABLE_WX "Build the wxWidgets port" ${BUILD_DEFAULT})
option(ENABLE_DEBUGGER "Enable the debugger" ON)
option(ENABLE_ASAN "Enable -fsanitize=<option>, address by default, requires debug build" OFF)
option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF)
# Static linking
set(VBAM_STATIC_DEFAULT OFF)
if(VCPKG_TARGET_TRIPLET MATCHES -static OR CMAKE_TOOLCHAIN_FILE MATCHES "mxe|-static")
set(VBAM_STATIC_DEFAULT ON)
elseif(MINGW OR (NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL ""))
elseif(MINGW OR MSYS)
# Default to static builds on MinGW and all MSYS2 envs.
set(VBAM_STATIC_DEFAULT ON)
endif()
@@ -47,18 +54,30 @@ cmake_dependent_option(ENABLE_MMX "Enable MMX" ${MMX_DEFAULT} "ENABLE_ASM_SCALER
option(ENABLE_LIRC "Enable LIRC support" OFF)
# Link / SFML
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()
# Add support for Homebrew, MacPorts and Fink on macOS
option(DISABLE_MACOS_PACKAGE_MANAGERS "Set to TRUE to disable support for macOS Homebrew, MacPorts and Fink." FALSE)
if(APPLE AND NOT DISABLE_MACOS_PACKAGE_MANAGERS)
include(MacPackageManagers)
endif()
set(ENABLE_LINK_DEFAULT OFF)
if(SFML_FOUND)
set(ENABLE_LINK_DEFAULT ON)
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()
endif()
option(ENABLE_LINK "Enable GBA linking functionality" ${ENABLE_LINK_DEFAULT})
@@ -67,7 +86,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 DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG)
if(NOT TRANSLATIONS_ONLY AND NOT DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG)
set(FFMPEG_DEFAULT ON)
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
@@ -99,7 +118,7 @@ option(ENABLE_ONLINEUPDATES "Enable online update checks" ${ONLINEUPDATES_DEFAUL
option(HTTPS "Use https URL for winsparkle" ON)
# We generally don't want LTO when debugging because it makes linking slow
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LTO_DEFAULT OFF)
else()
set(LTO_DEFAULT ON)
@@ -108,18 +127,8 @@ option(ENABLE_LTO "Compile with Link Time Optimization" ${LTO_DEFAULT})
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
# Add support for Homebrew, MacPorts and Fink on macOS
option(DISABLE_MACOS_PACKAGE_MANAGERS "Set to TRUE to disable support for macOS Homebrew, MacPorts and Fink." FALSE)
if(APPLE AND NOT DISABLE_MACOS_PACKAGE_MANAGERS)
include(MacPackageManagers)
endif()
option(ENABLE_NLS "Enable translations" ON)
option(UPSTREAM_RELEASE "do some optimizations and release automation tasks" OFF)
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
if(WIN32)
# not yet implemented
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
@@ -133,6 +142,23 @@ if(WIN32)
option(ENABLE_XAUDIO2 "Enable xaudio2 sound output for the wxWidgets port" ${XAUDIO2_DEFAULT})
endif()
option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" OFF)
set(ENABLE_FAUDIO_DEFAULT OFF)
find_package(FAudio QUIET)
if(FAudio_FOUND)
set(ENABLE_FAUDIO_DEFAULT ON)
endif()
option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" ${ENABLE_FAUDIO_DEFAULT})
option(ZIP_SUFFIX [=[suffix for release zip files, e.g. "-somebranch".zip]=] OFF)
# The SDL port can't be built without debugging support
if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
message(FATAL_ERROR "The SDL port can't be built without debugging support")
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()

View File

@@ -1,16 +0,0 @@
function(make_path_run_wrapper cmd target)
get_filename_component(name "${target}" NAME)
get_filename_component(cmd_resolved "${cmd}" REALPATH)
get_filename_component(base_name "${cmd_resolved}" NAME)
get_filename_component(dir_name "${cmd_resolved}" DIRECTORY)
set(source "${target}.c")
configure_file(src/gcc-wrap.c.in "${source}")
include(HostCompile)
host_compile("${source}" "${target}")
add_custom_target(generate_${name} DEPENDS "${CMAKE_BINARY_DIR}/${name}")
add_dependencies(generate generate_${name})
endfunction()

View File

@@ -1,3 +1,7 @@
if(TRANSLATIONS_ONLY)
return()
endif()
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
if(NOT WIN32)
return()
@@ -49,7 +53,7 @@ endif()
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 "^C:/Program Files/Microsoft Visual Studio/")
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "Visual Studio")
message(FATAL_ERROR "Error updating vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components")
endif()
endfunction()
@@ -116,7 +120,7 @@ function(vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet powershell ou
string(REPLACE "-" "." pkg_ver ${pkg_ver})
if(NOT DEFINED VCPKG_INSTALLED_COUNT)
if(VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")
if(VCPKG_ROOT MATCHES "Visual Studio")
execute_process(
COMMAND ${powershell}
-executionpolicy bypass -noprofile
@@ -320,6 +324,9 @@ function(vcpkg_remove_optional_deps vcpkg_exe)
endfunction()
function(vcpkg_set_toolchain)
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to use vcpkg binaries.")
endif()
if(NOT DEFINED ENV{VCPKG_ROOT})
get_filename_component(preferred_root ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE)

View File

@@ -0,0 +1,37 @@
if(NOT ENABLE_ASAN)
return()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_cxx_compiler_flag(/fsanitize=address MSVC_ASAN_SUPPORTED)
if(MSVC_ASAN_SUPPORTED)
add_compile_options(/fsanitize=address)
add_compile_definitions(_DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
else()
# ASAN does not work on non-debug builds for GCC and Clang.
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
# It is necessary to modify the linker flagas for the compiler check to work.
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
endif()

View File

@@ -1,50 +1,34 @@
include(CheckCXXCompilerFlag)
if(X86_32 OR X86_64)
add_compile_options(-mfpmath=sse -msse2)
endif()
if(X86_64)
# Require and optimize for Core2 level support, tune for generic.
add_compile_options(-march=core2 -mtune=generic)
elseif(X86_32)
# Optimize for pentium-mmx and tune for generic for older builds.
add_compile_options(-march=pentium-mmx -mtune=generic)
if(UPSTREAM_RELEASE)
if(X86_64)
# Require and optimize for Core2 level support, tune for generic.
add_compile_options(-march=core2 -mtune=generic)
elseif(X86_32)
# Optimize for pentium-mmx and tune for generic for older builds.
add_compile_options(-march=pentium-mmx -mtune=generic)
endif()
endif()
# Common flags.
add_compile_options(
-pipe
-Wno-unused-command-line-argument
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy>
-Wformat
-Wformat-security
-feliminate-unused-debug-types
-fdiagnostics-color=always
)
if(ENABLE_ASAN)
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
set(ENABLE_ASAN OFF)
endif()
# It is necessary to modify the linker flagas for the compiler check to work.
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-unused-command-line-argument)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-feliminate-unused-debug-types)
endif()
# check if ssp flags are supported.
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
if(STACK_PROTECTOR_SUPPORTED)
@@ -61,13 +45,30 @@ if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
add_compile_options(-fPIC)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
else()
add_compile_options(-Ofast -fomit-frame-pointer)
endif()
# for some reason this is necessary
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
include_directories(/usr/local/include)
endif()
if(VBAM_STATIC)
if(APPLE)
add_link_options(-static-libstdc++)
else()
add_link_options(-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
endif()
endif()
# To support LTO, this must always fail.
add_compile_options(-Werror=odr -Werror=strict-aliasing)
add_link_options( -Werror=odr -Werror=strict-aliasing)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Werror=lto-type-mismatch)
add_link_options( -Werror=lto-type-mismatch)
endif()

View File

@@ -1,41 +0,0 @@
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_C_COMPILER}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_CXX_COMPILER}")
else()
return()
endif()
foreach(tool ar ranlib ld nm objdump as)
execute_process(
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
OUTPUT_VARIABLE prog_path
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# for FreeBSD
if(NOT prog_path MATCHES "^/")
get_filename_component(
abs_path ${prog_path} ABSOLUTE
BASE_DIR /usr/local/llvm-devel/bin
)
if(EXISTS ${abs_path})
set(prog_path ${abs_path})
endif()
endif()
if(prog_path MATCHES "^/")
if(tool STREQUAL ld)
set(tool linker)
elseif(tool STREQUAL as)
set(tool asm_compiler)
endif()
string(TOUPPER ${tool} utool)
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
endif()
endforeach()

View File

@@ -1,59 +1,10 @@
# this has to run after the toolchain is initialized so it can't be in
# Win32deps.cmake
if (NOT MINGW)
return()
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")
# Win32 deps submodule
set(git_checkout FALSE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(git_checkout TRUE)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --remote --recursive
RESULT_VARIABLE git_status
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(NOT (git_checkout AND git_status EQUAL 0))
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
endif()
endif()
# hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if($ENV{MSYSTEM} STREQUAL CLANG64)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
endif()
# link libgcc/libstdc++ statically on mingw
# and adjust link command when making a static binary
if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC)
# some dists don't have a static libpthread
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ")
if(WIN32)
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
else()
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
endif()
# 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

@@ -1,7 +1,7 @@
# Set the runtime library properly.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC-specific flags (not supported by clang-cl).
add_compile_options(/nologo)
if (NOT CMAKE_GENERATOR MATCHES "Ninja")
@@ -20,6 +20,11 @@ add_compile_definitions(
__STDC_LIMIT_MACROS
__STDC_CONSTANT_MACROS
_CRT_SECURE_NO_WARNINGS
_UNICODE
UNICODE
WINVER=0x0A00
NTDDI_VERSION=0x0A000007
NOMINMAX
)
add_compile_options(
/W4
@@ -28,18 +33,18 @@ add_compile_options(
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG DEBUG)
add_compile_definitions(_DEBUG)
add_compile_options(/Ob0 /Od /RTC1)
if (CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT ENABLE_ASAN)
# Use Edit and Continue with MSVC.
add_compile_options(/ZI)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue" CACHE STRING "" FORCE)
else()
add_compile_options(/Zi)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
endif()
else()
add_compile_definitions(NDEBUG)
add_compile_options(/MT /Oi /Gy /Zi)
add_compile_options(/MT /Oi /Gy)
add_link_options(/OPT:REF /OPT:ICF)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_compile_options(/O1 /Ob1)
@@ -50,6 +55,19 @@ else()
endif()
endif()
if(CMAKE_VERSION VERSION_LESS "3.25")
# Backwards-compatible way of setting the /Z option.
if(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "EditAndContinue")
add_compile_options(/ZI)
elseif(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "ProgramDatabase")
add_compile_options(/Zi)
elseif(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT STREQUAL "Embedded")
add_compile_options(/Z7)
else()
message(FATAL_ERROR "Unknown value for CMAKE_MSVC_DEBUG_INFORMATION_FORMAT: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}")
endif()
endif()
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
# We need to explicitly set all of these to override the CMake defaults.

View File

@@ -1,11 +1,23 @@
if(TRANSLATIONS_ONLY)
return()
endif()
# Compiler stuff
include(CheckCXXCompilerFlag)
include(ProcessorCount)
ProcessorCount(num_cpus)
if (ENABLE_LTO)
if(ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED)
if (LTO_SUPPORTED)
# MINGW64 does not support LTO
if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LTO_SUPPORTED FALSE)
endif()
if(LTO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "LTO is not supported by the compiler, diasabling LTO")
@@ -13,23 +25,102 @@ if (ENABLE_LTO)
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
# TODO: This should also be done for clang-cl.
include(Toolchain-llvm)
# Output all binaries at top level
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(NOT HTTPS)
add_compile_definitions(NO_HTTPS)
endif()
if(ENABLE_GBA_LOGGING)
add_compile_definitions(GBA_LOGGING )
endif()
if(ENABLE_MMX)
add_compile_definitions(MMX)
endif()
if(NOT ENABLE_ONLINEUPDATES)
add_compile_definitions(NO_ONLINEUPDATES)
endif()
# The debugger is enabled by default
if(ENABLE_DEBUGGER)
add_compile_definitions(VBAM_ENABLE_DEBUGGER)
endif()
# The ASM core is disabled by default because we don't know on which platform we are
if(NOT ENABLE_ASM_CORE)
add_compile_definitions(C_CORE)
endif()
# Set up "src" and generated directory as a global include directory.
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
include_directories(
${CMAKE_SOURCE_DIR}/src
${VBAM_GENERATED_DIR}
)
# C defines
add_compile_definitions(HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam")
add_compile_definitions(__STDC_FORMAT_MACROS)
add_compile_definitions(LOCALEDIR="${LOCALEDIR}")
# Common compiler settings.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
if(APPLE)
add_compile_definitions(MACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_compile_definitions(ELF)
endif()
if(X86_64)
add_compile_definitions(__AMD64__ __X86_64__)
endif()
# Enable ASAN if requested and supported.
include(Toolchain-asan)
# MINGW/MSYS-specific settings.
include(Toolchain-mingw)
# Toolchain-specific settings.
if(MSVC)
# This also includes clang-cl.
include(Toolchain-msvc)
elseif(MINGW)
include(Toolchain-mingw)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
include(Toolchain-gcc-clang)
else()
message(FATAL_ERROR "Unsupported compiler")
include(Toolchain-gcc-clang)
endif()
# Assembler flags.
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
if(MSVC)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
endif()
execute_process(
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
endif()
enable_language(ASM_NASM)
set(ASM_ENABLED ON)
endif()
# Assembler flags
if(ASM_ENABLED)
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
endif()

View File

@@ -75,8 +75,10 @@ Ignore the following cmake error.
endwhile()
# Convert to UNIX line endings on Windows, just copy the file otherwise.
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
if(NOT DEFINED POWERSHELL)
message(FATAL_ERROR "Powershell is required to convert line endings on Windows.")
endif()
execute_process(
COMMAND ${POWERSHELL} -NoLogo -NoProfile -ExecutionPolicy Bypass -Command [=[
$text = [IO.File]::ReadAllText("appcast.xml.work") -replace "`r`n", "`n"

View File

@@ -1,48 +1,3 @@
# From: https://stackoverflow.com/a/41416298/262458
function(REMOVE_DUPES ARG_STR OUTPUT)
set(ARG_LIST ${ARG_STR})
separate_arguments(ARG_LIST)
list(REMOVE_DUPLICATES ARG_LIST)
string (REGEX REPLACE "([^\\]|^);" "\\1 " _TMP_STR "${ARG_LIST}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
# From: https://stackoverflow.com/a/7216542
function(JOIN VALUES GLUE OUTPUT)
string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
# On MSYS2 transform wx lib paths to native paths for Ninja.
function(normalize_wx_paths)
if(MSYS)
set(libs "")
foreach(lib ${wxWidgets_LIBRARIES})
if(NOT lib MATCHES "^(-Wl,|-mwindows$|-pipe$)")
if(lib MATCHES "^/")
cygpath(lib "${lib}")
endif()
if(VBAM_STATIC AND lib MATCHES "^-l(wx.*|jpeg|tiff|jbig|lzma|expat)$")
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${CMAKE_MATCH_1}.a")
endif()
list(APPEND libs "${lib}")
endif()
endforeach()
set(wxWidgets_LIBRARIES "${libs}" PARENT_SCOPE)
endif()
endfunction()
macro(cleanup_wx_vars)
if(wxWidgets_CXX_FLAGS)
list(REMOVE_ITEM wxWidgets_CXX_FLAGS -fpermissive)
endif()
endmacro()
function(cygpath var path)
execute_process(
@@ -157,5 +112,3 @@ function(find_wx_util var util)
set(${var} ${util} PARENT_SCOPE)
endforeach()
endfunction()
# vim:sw=4 sts et:

View File

@@ -2,7 +2,7 @@ with import <nixpkgs> {};
stdenv.mkDerivation {
name = "visualboyadvance-m";
buildInputs = if stdenv.isDarwin then
[ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 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 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 ]
else
[ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 mesa 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 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 ];
}

View File

@@ -2,59 +2,27 @@
Developer Information File
==========================
Known preprocessor switches:
- SDL: Defined for the SDL version
- GBA_LOGGING: Enables logging for the GBA core
- FINAL_VERSION: Defined for release versions, disables additional GBA logging and completely disables GB logging. Increases the amount of CPU cycles being emulated in one go.
- BKPT_SUPPORT
- VBAM_ENABLE_DEBUGGER: Enable remote debugging support
- MMX: Enable MMX instruction set
- NO_ASM: Use C++ version of hq3x/4x filters
- RGB555: Use 16bit colors with 5bit green instead of 6bit green in hq3x/4x filters (C++ version)
- NO_OGL: Exclude OpenGL code
- NO_D3D: Exclude Direct3D code
- NO_OAL: Exclude OpenAL code
- NO_XAUDIO2: Exclude XAudio2 code (the XAudio2 interface is DirectSound's successor)
- VBAM_ENABLE_XAUDIO2: Enable XAudio2 code (the XAudio2 interface is DirectSound's successor)
- VBAM_ENABLE_FAUDIO: Enable FAudio code (the FAudio interface is an open source multiplatform re-implementation of XAudio2)
- NO_LINK: Exclude linking code (joybus, multilink, ...)
- WIN64: This macro is only defined for 64 bit builds
Download locations:
NASM: http://nasm.us/
DirectX SDK: http://msdn.microsoft.com/en-us/xna/aa937788.aspx
OpenAL SDK: http://connect.creativelabs.com/openal/default.aspx
OpenGL files: http://www.opengl.org/registry/
zlib: http://zlib.net/
libpng: http://libpng.org/pub/png/libpng.html
You can find pre-built versions of zlib & libpng at:
http://spacy51.sp.funpic.de/VBA-M/libs/
Just extract them somewhere and point Visual C++ 2008 to the include & lib folders.
They are built with the static C runtime (this is what the release builds use).
###########################
# --- Build Systems --- #
###########################
===Win32/MFC===
This is the full-featured Windows build using the MFC GUI.
The project files are located in /project/vc2008_mfc (VBA2008.sln) and /project/vs2010_mfc (VBA2010.sln).
Anyone distributing builds should be using MSVC 2010 SP1, the unpatched release has a bug where it applies SSE2 updates to mov and other instructions resulting in illegal instruction errors on cpu's only supporting SSE.
You also have to install Microsoft's DirectX SDK for Direct3D, DirectInput & XAudio2.
If you want to enable OpenAL sound output, install the OpenAL SDK. If you do not want it, add NO_OAL to the VBA-M project's preprocessor definitions.
SubWCRev.exe is used to append the svn versioning to the output executable, this as of TortoiseSVN 1.7, is only available by installing TortoiseSVN.
All other dependencies for MSVC builds may be found in the ../dependencies directory (above /trunk).
Normally, Windows users will want to checkout the root of the repository instead of just the trunk directory. Afterwards, simply opening the .sln of choice, setting preprocessor definitions, and hitting build is all that's required.
===*nix/GTK===
===src/sdl===
This is the standard build configuration on non-Windows.
Running cmake will inform you of any packages you need to install.
===*/wxw===
The wxWidgets interface is an in-development frontend meant to be more cross-platform friendly than MFC and GTK.
===src/wx===
The wxWidgets interface is an in-development frontend meant to be more cross-platform friendly than MFC and SDL.
Running cmake will inform you of any packages you need to install.
NOTE: In addition to what cmake currently checks for, you will also need the wxrc tool and libgdiplus.

View File

@@ -1,46 +0,0 @@
#Do not use this file directly. Always use the top level CMakeLists.txt file
#File extractors so the user doesn't have to extract the rom before playing it
# Source files definition
SET(SRC_FEX
7z_C/7zAlloc.c
7z_C/7zBuf.c
7z_C/7zCrc.c
7z_C/7zCrcOpt.c
7z_C/7zDec.c
7z_C/7zIn.c
7z_C/7zStream.c
7z_C/Bcj2.c
7z_C/Bra86.c
7z_C/Bra.c
7z_C/CpuArch.c
7z_C/Lzma2Dec.c
7z_C/LzmaDec.c
7z_C/Ppmd7.c
7z_C/Ppmd7Dec.c
fex/Binary_Extractor.cpp
fex/blargg_common.cpp
fex/blargg_errors.cpp
fex/Data_Reader.cpp
fex/fex.cpp
fex/File_Extractor.cpp
fex/Gzip_Extractor.cpp
fex/Gzip_Reader.cpp
fex/Rar_Extractor.cpp
fex/Zip7_Extractor.cpp
fex/Zip_Extractor.cpp
fex/Zlib_Inflater.cpp
)
INCLUDE_DIRECTORIES(
.
${ZLIB_INCLUDE_DIRS}
)
ADD_LIBRARY(
fex
STATIC
${SRC_FEX}
)
add_dependencies(fex generate)

View File

@@ -1,7 +1,6 @@
#!/bin/sh
CMAKE=cmake
ENABLE_OPENAL=1
ENABLE_FFMPEG=1
main() {
@@ -25,10 +24,6 @@ check_command_line_args() {
usage
quit 0
;;
--no-openal)
ENABLE_OPENAL=
shift
;;
--no-ffmpeg)
ENABLE_FFMPEG=
shift
@@ -355,9 +350,8 @@ 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"
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"
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs libopenal-dev"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs libavcodec-dev libavformat-dev libswscale-dev libavutil-dev $libswresample_dev"
check sudo apt-get -qy install $pkgs
@@ -407,8 +401,7 @@ debian_installdeps() {
fi
fi
deps="gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets"
[ -n "$ENABLE_OPENAL" ] && deps="$deps openal"
deps="gcc zlib ffmpeg gettext sdl2 sfml openal wxwidgets openal"
[ -n "$ENABLE_FFMPEG" ] && deps="$deps ffmpeg"
set --
@@ -510,9 +503,6 @@ fedora_installdeps() {
*ffmpeg*)
[ -z "$ENABLE_FFMPEG" ] && continue
;;
*openal*)
[ -z "$ENABLE_OPENAL" ] && continue
;;
esac
pkg_arch=
@@ -601,15 +591,9 @@ fedora_installdeps() {
;;
esac
# install static deps
for pkg in zlib gettext SDL2 wxWidgets3; do
for pkg in zlib gettext SDL2 wxWidgets3 openal-soft; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
if [ -n "$ENABLE_OPENAL" ]; then
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
fi
# get the necessary win32 headers
git submodule update --init --remote --recursive
@@ -707,9 +691,6 @@ rhel_installdeps() {
*ffmpeg*)
[ -z "$ENABLE_FFMPEG" ] && continue
;;
*openal*)
[ -z "$ENABLE_OPENAL" ] && continue
;;
esac
if [ -n "$amd64" ]; then
@@ -790,15 +771,9 @@ rhel_installdeps() {
;;
esac
# install static deps
for pkg in zlib gettext SDL2 wxWidgets; do
for pkg in zlib gettext SDL2 wxWidgets openal-soft; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
if [ -n "$ENABLE_OPENAL" ]; then
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
fi
# get the necessary win32 headers
git submodule update --init --remote --recursive
@@ -824,9 +799,8 @@ suse_installdeps() {
tools="make cmake ccache nasm gettext-tools pkg-config ccache zip sfml2-devel ninja"
libs="gcc gcc-c++ libSDL2-devel wxWidgets-3_0-devel" # ffmpeg-devel
libs="gcc gcc-c++ libSDL2-devel wxWidgets-3_0-devel openal-soft-devel" # ffmpeg-devel
[ -n "$ENABLE_OPENAL" ] && libs="$libs openal-soft-devel"
# ffmpeg requires packman repos
if [ "$target" = m32 ]; then
@@ -894,9 +868,8 @@ archlinux_installdeps() {
$pacman -Q gtk3-classic >/dev/null 2>&1 && gtk=gtk3-classic
libs="zlib mesa gettext sdl2 wxgtk3 $gtk sfml"
libs="zlib mesa gettext sdl2 wxgtk3 $gtk sfml openal"
[ -n "$ENABLE_OPENAL" ] && libs="$libs openal"
[ -n "$ENABLE_FFMPEG" ] && libs="$libs ffmpeg"
if [ -z "$target" -o "$target" = m32 ]; then
@@ -991,9 +964,7 @@ EOF
fi
done
deps="zlib gettext pkg-config sdl2 wxmsw"
[ -n "$ENABLE_OPENAL" ] && deps="$deps openal"
deps="zlib gettext pkg-config sdl2 wxmsw openal"
# and the actual deps
for p in $deps; do
@@ -1024,9 +995,7 @@ solus_installdeps() {
check sudo eopkg -y install -c system.devel
check sudo eopkg -y install git ccache ninja
set -- sdl2-devel wxwidgets-devel libgtk-2-devel libgtk-3-devel libglu-devel
[ -n "$ENABLE_OPENAL" ] && set -- "$@" openal-soft-devel
set -- sdl2-devel wxwidgets-devel libgtk-2-devel libgtk-3-devel libglu-devel openal-soft-devel
if [ -n "$amd64" -a "$target" = m32 ]; then
info_msg 'Calculating dependencies, this will take a while..'
@@ -1102,14 +1071,13 @@ gentoo_installdeps() {
sys-devel/binutils \
media-libs/libsdl2 \
media-libs/libsfml \
media-libs/openal \
x11-libs/wxGTK:$wx_slot \
sys-libs/zlib \
dev-util/pkgconf \
dev-lang/nasm \
dev-build/ninja"
[ -n "$ENABLE_OPENAL" ] && ebuilds="$ebuilds media-libs/openal"
[ -n "$ENABLE_FFMPEG" ] && ebuilds="$ebuilds media-video/ffmpeg"
check sudo emerge -vna $ebuilds
@@ -1152,9 +1120,14 @@ windows_installdeps() {
;;
esac
pkgs="$pkgs SDL2 sfml wxWidgets3.2 zlib binutils cmake crt-git extra-cmake-modules headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb ccache"
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"
case "$target" in
*x86_64)
pkgs="$pkgs extra-cmake-modules"
;;
esac
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs openal"
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"
set --
@@ -1219,7 +1192,7 @@ brew_installdeps() {
check brew -v update
brews="nasm cmake ccache gettext pkg-config sdl2 wxwidgets ccache ninja"
brews="nasm cmake ccache gettext pkg-config sdl2 wxwidgets faudio ccache ninja zlib"
[ -n "$ENABLE_FFMPEG" ] && brews="$brews ffmpeg"

View File

@@ -1,4 +0,0 @@
IF(ENABLE_WX)
add_subdirectory(wxvbam)
ENDIF(ENABLE_WX)

View File

@@ -1,8 +1,7 @@
if(NOT TRANSLATIONS_ONLY AND NOT ENABLE_WX)
return()
endif()
file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po")
gettext_create_translations(
wxvbam.pot
${po_files}
)
add_dependencies(visualboyadvance-m translations)
gettext_create_translations(wxvbam.pot ${po_files})

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

3807
po/wxvbam/ja_JP.po Normal file

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

3805
po/wxvbam/ur_PK.po Normal file

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

@@ -51,7 +51,6 @@ parts:
- libopenal-dev
- libwxgtk3.0-gtk3-dev
cmake-parameters:
- -DENABLE_OPENAL=ON
- -DENABLE_SDL=OFF
- -DCMAKE_INSTALL_PREFIX=/usr

View File

@@ -1,29 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __AUTOBUILD_H__
#define __AUTOBUILD_H__
#include "version.h"
// change the FALSE to TRUE for autoincrement of build number
#define INCREMENT_VERSION FALSE
#define FILEVER 2, 0, 0, 600
#define PRODUCTVER 2, 0, 0, 600
#define STRFILEVER "2, 0, 0, 600\0"
#define STRPRODUCTVER "2, 0, 0, 600\0"
#endif //__AUTOBUILD_H__

View File

@@ -1,910 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#ifndef _WIN32
#include <sys/stat.h>
#include <unistd.h>
#else // _WIN32
#include <direct.h>
#include <io.h>
#endif // _WIN32
#include <zlib.h>
#define STB_IMAGE_IMPLEMENTATION
extern "C" {
#include "stb_image.h"
}
#define STBI_MSC_SECURE_CRT
#define STB_IMAGE_WRITE_IMPLEMENTATION
extern "C" {
#include "stb_image_write.h"
}
#include "NLS.h"
#include "System.h"
#include "Util.h"
#include "common/Port.h"
#include "gba/Flash.h"
#include "gba/GBA.h"
#include "gba/Globals.h"
#include "gba/RTC.h"
#include "fex/fex.h"
extern "C" {
#include "common/memgzio.h"
}
#include "gb/gbGlobals.h"
#include "gba/gbafilter.h"
#ifndef _MSC_VER
#define _stricmp strcasecmp
#endif // ! _MSC_VER
extern int systemColorDepth;
extern int systemRedShift;
extern int systemGreenShift;
extern int systemBlueShift;
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];
static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzCloseFunc)(gzFile) = NULL;
static z_off_t(ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL;
#define MAX_CART_SIZE 0x8000000 // 128MB
bool FileExists(const char *filename)
{
#ifdef _WIN32
return (_access(filename, 0) != -1);
#else
struct stat buffer;
return (stat(filename, &buffer) == 0);
#endif
}
#ifdef _WIN32
#include <windows.h>
wchar_t* utf8ToUtf16(const char *utf8)
{
wchar_t *utf16 = nullptr;
size_t size = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL , 0);
if (size == 0) return nullptr; // error
utf16 = new wchar_t[size];
size = MultiByteToWideChar(CP_UTF8, 0, utf8 , -1, utf16, size);
if (size == 0) {
delete[] utf16;
return nullptr; // error
}
return utf16;
}
#endif // _WIN32
FILE* utilOpenFile(const char *filename, const char *mode)
{
FILE *f = NULL;
#ifdef _WIN32
wchar_t *wfilename = utf8ToUtf16(filename);
if (!wfilename) return nullptr;
wchar_t *wmode = utf8ToUtf16(mode);
if (!wmode) {
delete[] wfilename;
return nullptr;
}
f = _wfopen(wfilename, wmode);
delete[] wfilename;
delete[] wmode;
#else
f = fopen(filename, mode);
#endif // _WIN32
return f;
}
// Get user-specific config dir manually.
// apple: ~/Library/Application Support/
// windows: %APPDATA%/
// unix: ${XDG_CONFIG_HOME:-~/.config}/
std::string get_xdg_user_config_home()
{
std::string path;
#ifdef __APPLE__
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_CONFIG_HOME");
if (!xdg_var || !*xdg_var)
{
std::string xdg_default(getenv("HOME"));
path = xdg_default + "/.config";
}
else
{
path = xdg_var;
}
#endif
return path + FILE_SEP;
}
// Get user-specific data dir manually.
// apple: ~/Library/Application Support/
// windows: %APPDATA%/
// unix: ${XDG_DATA_HOME:-~/.local/share}/
std::string get_xdg_user_data_home()
{
std::string path;
#ifdef __APPLE__
std::string home(getenv("HOME"));
path = home + "/Library/Application Support";
#elif _WIN32
char *app_data_env = getenv("LOCALAPPDATA");
if (!app_data_env) app_data_env = getenv("APPDATA");
std::string app_data(app_data_env);
path = app_data;
#else // Unix
char *xdg_var = getenv("XDG_DATA_HOME");
if (!xdg_var || !*xdg_var)
{
std::string xdg_default(getenv("HOME"));
path = xdg_default + "/.local/share";
}
else
{
path = xdg_var;
}
#endif
return path + FILE_SEP;
}
void utilReadScreenPixels(uint8_t *dest, int w, int h)
{
uint8_t *b = dest;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16: {
uint16_t *p = (uint16_t *)(g_pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)g_pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
*b++ = *pixU8++; // R
*b++ = *pixU8++; // G
*b++ = *pixU8++; // B
} else {
uint8_t blue = *pixU8++;
uint8_t green = *pixU8++;
uint8_t red = *pixU8++;
*b++ = red;
*b++ = green;
*b++ = blue;
}
}
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(g_pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
pixU32++;
}
} break;
}
}
#define CHANNEL_NUM 3 // RGB
bool utilWritePNGFile(const char *fileName, int w, int h, uint8_t *pix)
{
uint8_t *writeBuffer = new uint8_t[w * h * CHANNEL_NUM];
uint8_t *b = writeBuffer;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth)
{
case 16: {
uint16_t *p = (uint16_t *)(pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
*b++ = *pixU8++; // R
*b++ = *pixU8++; // G
*b++ = *pixU8++; // B
} else {
uint8_t blue = *pixU8++;
uint8_t green = *pixU8++;
uint8_t red = *pixU8++;
*b++ = red;
*b++ = green;
*b++ = blue;
}
}
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
}
pixU32++;
}
} break;
}
bool ret = (0 != stbi_write_png(fileName, w, h, CHANNEL_NUM, writeBuffer, w * CHANNEL_NUM));
delete[] writeBuffer;
return ret;
}
void utilPutDword(uint8_t *p, uint32_t value)
{
*p++ = value & 255;
*p++ = (value >> 8) & 255;
*p++ = (value >> 16) & 255;
*p = (value >> 24) & 255;
}
void utilPutWord(uint8_t *p, uint16_t value)
{
*p++ = value & 255;
*p = (value >> 8) & 255;
}
#ifndef __LIBRETRO__
bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
{
uint8_t writeBuffer[512 * 3];
FILE *fp = fopen(fileName, "wb");
if (!fp) {
systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName);
return false;
}
struct {
uint8_t ident[2];
uint8_t filesize[4];
uint8_t reserved[4];
uint8_t dataoffset[4];
uint8_t headersize[4];
uint8_t width[4];
uint8_t height[4];
uint8_t planes[2];
uint8_t bitsperpixel[2];
uint8_t compression[4];
uint8_t datasize[4];
uint8_t hres[4];
uint8_t vres[4];
uint8_t colors[4];
uint8_t importantcolors[4];
// uint8_t pad[2];
} bmpheader;
memset(&bmpheader, 0, sizeof(bmpheader));
bmpheader.ident[0] = 'B';
bmpheader.ident[1] = 'M';
uint32_t fsz = sizeof(bmpheader) + w * h * 3;
utilPutDword(bmpheader.filesize, fsz);
utilPutDword(bmpheader.dataoffset, 0x36);
utilPutDword(bmpheader.headersize, 0x28);
utilPutDword(bmpheader.width, w);
utilPutDword(bmpheader.height, h);
utilPutDword(bmpheader.planes, 1);
utilPutDword(bmpheader.bitsperpixel, 24);
utilPutDword(bmpheader.datasize, 3 * w * h);
fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
uint8_t *b = writeBuffer;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16: {
uint16_t *p = (uint16_t *)(pix + (w + 2) * (h)*2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint16_t v = *p++;
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
p++; // skip black pixel for filters
p++; // skip black pixel for filters
p -= 2 * (w + 2);
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
case 24: {
uint8_t *pixU8 = (uint8_t *)pix + 3 * w * (h - 1);
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift > systemBlueShift) {
*b++ = *pixU8++; // B
*b++ = *pixU8++; // G
*b++ = *pixU8++; // R
} else {
uint8_t red = *pixU8++;
uint8_t green = *pixU8++;
uint8_t blue = *pixU8++;
*b++ = blue;
*b++ = green;
*b++ = red;
}
}
pixU8 -= 2 * 3 * w;
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
case 32: {
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1) * (h));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
}
pixU32++;
pixU32 -= 2 * (w + 1);
fwrite(writeBuffer, 1, 3 * w, fp);
b = writeBuffer;
}
} break;
}
fclose(fp);
return true;
}
#endif /* !__LIBRETRO__ */
bool utilIsGBAImage(const char *file)
{
coreOptions.cpuIsMultiBoot = false;
if (strlen(file) > 4) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) ||
(_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0))
return true;
if (_stricmp(p, ".mb") == 0) {
coreOptions.cpuIsMultiBoot = true;
return true;
}
}
}
return false;
}
bool utilIsGBImage(const char *file)
{
if (strlen(file) > 4) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) ||
(_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) ||
(_stricmp(p, ".sgb") == 0))
return true;
}
}
return false;
}
bool utilIsGzipFile(const char *file)
{
if (strlen(file) > 3) {
const char *p = strrchr(file, '.');
if (p != NULL) {
if (_stricmp(p, ".gz") == 0)
return true;
if (_stricmp(p, ".z") == 0)
return true;
}
}
return false;
}
// strip .gz or .z off end
void utilStripDoubleExtension(const char *file, char *buffer)
{
if (buffer != file) // allows conversion in place
strcpy(buffer, file);
if (utilIsGzipFile(file)) {
char *p = strrchr(buffer, '.');
if (p)
*p = 0;
}
}
// Opens and scans archive using accept(). Returns fex_t if found.
// If error or not found, displays message and returns NULL.
static fex_t *scan_arc(const char *file, bool (*accept)(const char *), char (&buffer)[2048])
{
fex_t *fe;
fex_err_t err = fex_open(&fe, file);
if (!fe) {
systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s: %s"), file, err);
return NULL;
}
// Scan filenames
bool found = false;
while (!fex_done(fe)) {
strncpy(buffer, fex_name(fe), sizeof buffer);
buffer[sizeof buffer - 1] = '\0';
utilStripDoubleExtension(buffer, buffer);
if (accept(buffer)) {
found = true;
break;
}
err = fex_next(fe);
if (err) {
systemMessage(MSG_BAD_ZIP_FILE,
N_("Cannot read archive %s: %s"),
file,
err);
fex_close(fe);
return NULL;
}
}
if (!found) {
systemMessage(MSG_NO_IMAGE_ON_ZIP, N_("No image found in file %s"), file);
fex_close(fe);
return NULL;
}
return fe;
}
static bool utilIsImage(const char *file)
{
return utilIsGBAImage(file) || utilIsGBImage(file);
}
IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048]);
IMAGE_TYPE utilFindType(const char *file)
{
char buffer[2048];
return utilFindType(file, buffer);
}
IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048])
{
#ifdef WIN32
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if (!pwText) {
return IMAGE_UNKNOWN;
}
MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum);
//char *file_conv = fex_wide_to_path(file);
char *file_conv = (char *)file;
// if ( !utilIsImage( file_conv ) ) // TODO: utilIsArchive() instead?
// {
fex_t *fe = scan_arc(file_conv, utilIsImage, buffer);
if (!fe)
return IMAGE_UNKNOWN;
fex_close(fe);
file = buffer;
// }
//free(file_conv);
#else
// if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead?
// {
fex_t *fe = scan_arc(file, utilIsImage, buffer);
if (!fe)
return IMAGE_UNKNOWN;
fex_close(fe);
file = buffer;
// }
#endif
return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB;
}
static int utilGetSize(int size)
{
int res = 1;
while (res < size)
res <<= 1;
return res;
}
uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data, int &size)
{
// find image file
char buffer[2048];
#ifdef WIN32
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if (!pwText) {
return NULL;
}
MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum);
//char *file_conv = fex_wide_to_path(file);
char *file_conv = (char *)file;
delete[] pwText;
fex_t *fe = scan_arc(file_conv, accept, buffer);
if (!fe)
return NULL;
//free(file_conv);
#else
fex_t *fe = scan_arc(file, accept, buffer);
if (!fe)
return NULL;
#endif
// Allocate space for image
fex_err_t err = fex_stat(fe);
int fileSize = fex_size(fe);
if (size == 0)
size = fileSize;
if (size > MAX_CART_SIZE)
return NULL;
uint8_t *image = data;
if (image == NULL) {
// allocate buffer memory if none was passed to the function
image = (uint8_t *)malloc(utilGetSize(size));
if (image == NULL) {
fex_close(fe);
systemMessage(MSG_OUT_OF_MEMORY,
N_("Failed to allocate memory for %s"),
"data");
return NULL;
}
size = fileSize;
}
// Read image
int read = fileSize <= size ? fileSize : size; // do not read beyond file
err = fex_read(fe, image, read);
fex_close(fe);
if (err) {
systemMessage(MSG_ERROR_READING_IMAGE,
N_("Error reading image from %s: %s"),
buffer,
err);
if (data == NULL)
free(image);
return NULL;
}
size = fileSize;
return image;
}
void replaceAll(std::string &str, const std::string &from, const std::string &to)
{
if (from.empty())
return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with
// 'yx'
}
}
void utilExtract(const char *filepath, const char *filename)
{
fex_t *fex;
std::string archive_name(filepath);
archive_name.append(filename);
fex_open(&fex, archive_name.c_str());
while (!fex_done(fex)) {
std::string extracted_filename(filepath);
extracted_filename.append(fex_name(fex));
#ifdef WIN32
replaceAll(extracted_filename, "/", "\\");
#endif
std::string new_dir(filepath);
new_dir.append(fex_name(fex));
#ifdef WIN32
replaceAll(new_dir, "/", "\\");
#endif
new_dir = new_dir.substr(0, new_dir.find_last_of("\\"));
if (!FileExists(new_dir.c_str()))
mkdir(new_dir.c_str()
#ifndef WIN32
,
0777
#endif
);
if (FileExists(extracted_filename.c_str())) {
std::string new_name(filepath);
new_name.append("old-");
new_name.append(fex_name(fex));
#ifdef WIN32
replaceAll(new_name, "/", "\\");
#endif
remove(new_name.c_str());
rename(extracted_filename.c_str(), new_name.c_str());
}
FILE *extracted_file = fopen(extracted_filename.c_str(), "wb");
const void *p;
fex_data(fex, &p);
fwrite(p, fex_size(fex), 1, extracted_file);
fclose(extracted_file);
fex_next(fex);
}
fex_close(fex);
}
void utilWriteInt(gzFile gzFile, int i)
{
utilGzWrite(gzFile, &i, sizeof(int));
}
int utilReadInt(gzFile gzFile)
{
int i = 0;
utilGzRead(gzFile, &i, sizeof(int));
return i;
}
void utilReadData(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzRead(gzFile, data->address, data->size);
data++;
}
}
void utilReadDataSkip(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzSeek(gzFile, data->size, SEEK_CUR);
data++;
}
}
void utilWriteData(gzFile gzFile, variable_desc *data)
{
while (data->address) {
utilGzWrite(gzFile, data->address, data->size);
data++;
}
}
gzFile utilAutoGzOpen(const char *file, const char *mode)
{
#ifdef _WIN32
wchar_t *wfile = utf8ToUtf16(file);
if (!wfile) return nullptr;
gzFile handler = gzopen_w(wfile, mode);
delete[] wfile;
return handler;
#else
return gzopen(file, mode);
#endif
}
gzFile utilGzOpen(const char *file, const char *mode)
{
utilGzWriteFunc = (int(ZEXPORT *)(gzFile, void *const, unsigned int))gzwrite;
utilGzReadFunc = gzread;
utilGzCloseFunc = gzclose;
utilGzSeekFunc = gzseek;
return utilAutoGzOpen(file, mode);
}
gzFile utilMemGzOpen(char *memory, int available, const char *mode)
{
utilGzWriteFunc = memgzwrite;
utilGzReadFunc = memgzread;
utilGzCloseFunc = memgzclose;
utilGzSeekFunc = memgzseek;
return memgzopen(memory, available, mode);
}
int utilGzWrite(gzFile file, const voidp buffer, unsigned int len)
{
return utilGzWriteFunc(file, buffer, len);
}
int utilGzRead(gzFile file, voidp buffer, unsigned int len)
{
return utilGzReadFunc(file, buffer, len);
}
int utilGzClose(gzFile file)
{
return utilGzCloseFunc(file);
}
z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence)
{
return utilGzSeekFunc(file, offset, whence);
}
long utilGzMemTell(gzFile file)
{
return memtell(file);
}
void utilGBAFindSave(const int size)
{
uint32_t *p = (uint32_t *)&g_rom[0];
uint32_t *end = (uint32_t *)(&g_rom[0] + size);
int detectedSaveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;
while (p < end) {
uint32_t d = READ32LE(p);
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
if (detectedSaveType == 0 || detectedSaveType == 4)
detectedSaveType = 1;
}
} else if (d == 0x4D415253) {
if (memcmp(p, "SRAM_", 5) == 0) {
if (detectedSaveType == 0 || detectedSaveType == 1 ||
detectedSaveType == 4)
detectedSaveType = 2;
}
} else if (d == 0x53414C46) {
if (memcmp(p, "FLASH1M_", 8) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 3;
flashSize = 0x20000;
}
} else if (memcmp(p, "FLASH512_", 9) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 3;
flashSize = 0x10000;
}
} else if (memcmp(p, "FLASH", 5) == 0) {
if (detectedSaveType == 0) {
detectedSaveType = 4;
flashSize = 0x10000;
}
}
} else if (d == 0x52494953) {
if (memcmp(p, "SIIRTC_V", 8) == 0)
rtcFound = true;
}
p++;
}
// if no matches found, then set it to NONE
if (detectedSaveType == 0) {
detectedSaveType = 5;
}
if (detectedSaveType == 4) {
detectedSaveType = 3;
}
rtcEnable(rtcFound);
rtcEnableRumble(!rtcFound);
coreOptions.saveType = detectedSaveType;
flashSetSize(flashSize);
}
void utilUpdateSystemColorMaps(bool lcd)
{
switch (systemColorDepth) {
case 16: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal(systemColorMap16, 0x10000);
} break;
case 24:
case 32: {
for (int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift);
}
if (lcd)
gbafilter_pal32(systemColorMap32, 0x10000);
} break;
}
}
// Check for existence of file.
bool utilFileExists(const char *filename)
{
FILE *f = fopen(filename, "r");
if (f == NULL) {
return false;
} else {
fclose(f);
return true;
}
}

View File

@@ -1,11 +0,0 @@
#ifndef VBAM_BSD_H
#define VBAM_BSD_H
#define fopen64 fopen
#define fseeko64 fseeko
#define fseek64 fseek
#define ftell64 ftell
#define ftello64 ftello
#endif // VBAM_BSD_H

View File

@@ -1,9 +0,0 @@
#ifndef PATCH_H
#define PATCH_H
#include "../Util.h"
#include "Types.h"
bool applyPatch(const char *patchname, uint8_t **rom, int *size);
#endif // PATCH_H

View File

@@ -1,64 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2015 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_SOUND_DRIVER_H__
#define __VBA_SOUND_DRIVER_H__
#include <stdint.h> // for uint16_t
/**
* Sound driver abstract interface for the core to use to output sound.
* Subclass this to implement a new sound driver.
*/
class SoundDriver
{
public:
/**
* Destructor. Free the resources allocated by the sound driver.
*/
virtual ~SoundDriver(){};
/**
* Initialize the sound driver.
* @param sampleRate In Hertz
*/
virtual bool init(long sampleRate) = 0;
/**
* Tell the driver that the sound stream has paused
*/
virtual void pause() = 0;
/**
* Reset the sound driver
*/
virtual void reset() = 0;
/**
* Tell the driver that the sound stream has resumed
*/
virtual void resume() = 0;
/**
* Write length bytes of data from the finalWave buffer to the driver output buffer.
*/
virtual void write(uint16_t *finalWave, int length) = 0;
virtual void setThrottle(unsigned short throttle) = 0;
};
#endif // __VBA_SOUND_DRIVER_H__

View File

@@ -1,28 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2008 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_TYPES_H__
#define __VBA_TYPES_H__
#ifdef __LIBRETRO__
#include <stdint.h>
#else
#include <zlib.h>
#include "cstdint.h"
#endif
#endif // __VBA_TYPES_H__

View File

@@ -1,10 +0,0 @@
#ifndef CONTAINS_HPP_
#define CONTAINS_HPP_
template <class C, class V>
bool contains(const C& container, const V& val)
{
return (container.find(val) != container.end());
}
#endif /* CONTAINS_HPP_ */

View File

@@ -1,18 +0,0 @@
#ifndef CSTDINT_H
#define CSTDINT_H
#if defined(__has_include)
# if __has_include(<cstdint>)
# include <cstdint>
// necessary on Mac OS X Lion 10.7 or any clang <= 3.0
# elif __has_include(<tr1/cstdint>)
# include <tr1/cstdint>
# else
// throw error
# include <cstdint>
# endif
#else
# include <cstdint>
#endif
#endif // CSTDINT_H

View File

@@ -1,669 +0,0 @@
/*
Range
=====
Copyright (c) 2009-2011 Khaled Alshaya
Distributed under the Boost Software License, version 1.0
(See the license at: http://www.boost.org/license_1_0.txt).
*/
/*
Rationale
=========
In Python, there is a beautiful function called "range".
"range" allows the programmer to iterate over a range elegantly.
This concept is not as general as "for-loops" in C++,
but non the less, it expresses the intent of the programmer
clearer than the general "for-loops" in many cases.
Design
======
Range is made to be STL-like library. In fact, it is
built on top of the concepts of STL. The library is designed to
work with STL algorithms as well. Range is more flexible
than the Python "range", because:
Range is an "immutable ordered random access container"
Specifications
==============
Range satisfies the following requirements:
* Immutable.
* Random Access Container.
* Random Access Iterator Interface.
* Constant Time Complexity Operations.
Range models an ordered sequence of elements,
where a range is defined by:
[begin, end)
* begin: the first element in the range. (Inclusive)
* end : the last element in the range. (Exclusive)
* step : the distance between two consecutive elements in a range.
where each element in the range is defined by:
element = begin + step * i
* i: is the index of the element in range.
The following precondition must be met for the sequence
to be a valid range:
step != 0
&&
(
begin <= end && step > 0
||
begin >= end && step < 0
)
Portability
===========
Range Generator is written in standard C++ (C++98). It depends
-only- on the standard C++ library.
*/
#ifndef range_h__
#define range_h__
// using std::range
// using std::size_t from <cstddef>
// using std::ceil from <cmath>
#include <iterator>
#include <stdexcept>
#include <cstddef>
#include <cmath>
namespace Range
{
template <class IntegerType>
struct basic_range
{
struct const_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_iterator_impl(): r(0), index(0)
{ }
const_iterator_impl(const const_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_iterator_impl& operator=(const const_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
return r->m_first_element + r->m_step*index;
}
// operator->
// is not implemented because the value_type is an integer type
// and primitive types in C++ don't define member functions.
const_iterator_impl& operator++()
{
++index;
return *this;
}
const_iterator_impl operator++(int)
{
const_iterator_impl temp = *this;
++index;
return temp;
}
const_iterator_impl& operator--()
{
--index;
return *this;
}
const_iterator_impl operator--(int)
{
const_iterator_impl temp = *this;
--index;
return temp;
}
const_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_iterator_impl operator+
(const const_iterator_impl& lhs, difference_type increment)
{
const_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_iterator_impl operator-(difference_type decrement) const
{
const_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_index = index + offset;
return r->m_first_element + r->m_step*new_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
struct const_reverse_iterator_impl
{
typedef IntegerType value_type;
typedef std::size_t size_type;
typedef IntegerType difference_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef
std::random_access_iterator_tag
iterator_category;
const_reverse_iterator_impl(): r(0), index(0)
{ }
const_reverse_iterator_impl(const const_reverse_iterator_impl& rhs)
: r(rhs.r), index(rhs.index)
{ }
const_reverse_iterator_impl(basic_range<IntegerType> const * p_range, size_type p_index)
:r(p_range), index(p_index)
{ }
const_reverse_iterator_impl& operator=(const const_reverse_iterator_impl& rhs)
{
r = rhs.r;
index = rhs.index;
return *this;
}
bool operator==(const const_reverse_iterator_impl& rhs) const
{
return *r == *(rhs.r) && index == rhs.index;
}
bool operator!=(const const_reverse_iterator_impl& rhs) const
{
return !(*this == rhs);
}
bool operator<(const const_reverse_iterator_impl& rhs) const
{
return index < rhs.index;
}
bool operator>(const const_reverse_iterator_impl& rhs) const
{
return index > rhs.index;
}
bool operator<=(const const_reverse_iterator_impl& rhs) const
{
return index <= rhs.index;
}
bool operator>=(const const_reverse_iterator_impl& rhs) const
{
return index >= rhs.index;
}
value_type operator*() const
{
size_type reverse_index
= (r->m_element_count - 1) - index;
return r->m_first_element + r->m_step*reverse_index;
}
// operator->
// is not implemented because the value_type is integer type
// and primitive types in C++ don't define member functions.
const_reverse_iterator_impl& operator++()
{
++index;
return *this;
}
const_reverse_iterator_impl operator++(int)
{
const_reverse_iterator_impl temp = *this;
++index;
return temp;
}
const_reverse_iterator_impl& operator--()
{
--index;
return *this;
}
const_reverse_iterator_impl operator--(int)
{
const_reverse_iterator_impl temp = *this;
--index;
return temp;
}
const_reverse_iterator_impl& operator+=(difference_type increment)
{
index += increment;
return *this;
}
// operator+
// is friend operator but operator-
// is not, because we want to allow the following for "+":
// iterator+5
// 5+iterator
// For the "-" it is not correct to do so, because
// iterator-5 != 5-iterator
friend const_reverse_iterator_impl operator+
(const const_reverse_iterator_impl& lhs, difference_type increment)
{
const_reverse_iterator_impl sum;
sum.r = lhs.r;
sum.index = lhs.index + increment;
return sum;
}
const_reverse_iterator_impl& operator-=(difference_type decrement)
{
index -= decrement;
return *this;
}
const_reverse_iterator_impl operator-(difference_type decrement) const
{
const_reverse_iterator_impl shifted_iterator;
shifted_iterator.r = r;
shifted_iterator.index = index - decrement;
return shifted_iterator;
}
difference_type operator-(const const_reverse_iterator_impl& rhs) const
{
return index - rhs.index;
}
value_type operator[](difference_type offset) const
{
size_type new_reverse_index
= (r->m_element_count - 1) - (index + offset);
return r->m_first_element + r->m_step*new_reverse_index;
}
private:
basic_range<IntegerType> const * r;
size_type index;
};
typedef IntegerType value_type;
typedef const_iterator_impl iterator;
typedef const_iterator_impl const_iterator;
typedef const_reverse_iterator_impl reverse_iterator;
typedef const_reverse_iterator_impl const_reverse_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* pointer;
typedef IntegerType difference_type;
typedef std::size_t size_type;
// In the case of default construction,
// the range is considered as an empty range with no elements.
// step can be anything other than 0. 1 is
// an implementation convention, and it doesn't have
// a significance in this case because the range is empty.
basic_range(): m_first_element(0), m_element_count(0), m_step(1)
{ }
// first_element: is begin in specifications.
// last_element: is end in specifications.
basic_range(value_type first_element, value_type last_element, value_type step)
: m_first_element(first_element),
m_step(step)
{
// We need to count the number of elements.
// The only case where a range is invalid,
// when the step=0. It means that the range
// is infinite, because the number of elements
// in a range, is the length of that range
// divided by the difference between
// every two successive elements.
if(step == 0)
throw std::out_of_range("Invalid Range: step can't be equal to zero!");
if(first_element < last_element && step < 0)
throw std::out_of_range("Invalid Range: step can't be backward, while the range is forward!");
if(first_element > last_element && step > 0)
throw std::out_of_range("Invalid Range: step can't be forward, while the range is backward!");
m_element_count = (last_element-first_element)/step;
if( (last_element-first_element)%step != 0 )
++m_element_count;
}
// The following constructor, determines the step
// automatically. If the range is forward, then
// step will be one. If the range is backward,
// step will be minus one. If the begin is equal
// to end, then the step must not equal to zero
// and it is set to one as a convention.
basic_range(value_type first_element, value_type last_element)
: m_first_element(first_element)
{
if(last_element >= first_element) *this = basic_range<IntegerType>(first_element, last_element, 1);
else *this = basic_range<IntegerType>(first_element, last_element, -1);
}
// The following constructor is a shortcut
// if you want the first element as zero.
// the step is determined automatically, based
// on the last element. If the last element is
// positive, then step is one, but if it is negative
// then step is minus one.
basic_range<IntegerType>(value_type last_element)
: m_first_element(0)
{
if(last_element >= m_first_element) *this = basic_range<IntegerType>(m_first_element, last_element, 1);
else *this = basic_range<IntegerType>(m_first_element, last_element, -1);
}
basic_range<IntegerType>(const basic_range<IntegerType>& r)
: m_first_element(r.m_first_element),
m_element_count(r.m_element_count),
m_step(r.m_step)
{ }
basic_range<IntegerType>& operator=(const basic_range<IntegerType>& r)
{
m_first_element = r.m_first_element;
m_element_count = r.m_element_count;
m_step = r.m_step;
return *this;
}
bool operator==(const basic_range<IntegerType>& r) const
{
return m_first_element == r.m_first_element
&&
m_element_count == r.m_element_count
&&
m_step == r.m_step;
}
bool operator!=(const basic_range<IntegerType>& r) const
{
return !(*this == r);
}
// The following four functions enable the user to compare
// ranges using ( <, >, <=, >=).
// The comparison between two ranges is a simple lexicographical
// comparison(element by element). By convention, if two ranges
// R1, R2 where R1 has a smaller number of elements. Then if
// R1 contains more elements but all R1 elements are found in R2
// R1 is considered less than R2.
bool operator<(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return true;
if(m_element_count > 0 && r.m_element_count == 0)
return false;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return true;
if(m_first_element > r.m_first_element)
return false;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return true;
if(m_element_count > 1 && r.m_element_count == 1)
return false;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return true;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return false;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count < r.m_element_count;
}
bool operator>(const basic_range<IntegerType>& r) const
{
// ********** This function needs refactoring.
if(m_element_count == 0 && r.m_element_count == 0)
return false;
if(m_element_count == 0 && r.m_element_count > 0)
return false;
if(m_element_count > 0 && r.m_element_count == 0)
return true;
// At this point, both has at least one element.
if(m_first_element < r.m_first_element)
return false;
if(m_first_element > r.m_first_element)
return true;
// At this point, the first element of both are equal.
if(m_element_count == 1 && r.m_element_count == 1)
return false;
if(m_element_count == 1 && r.m_element_count > 1)
return false;
if(m_element_count > 1 && r.m_element_count == 1)
return true;
// At this point, both have at least two elements with
// a similar first element. Note than the final answer
// in this case depends on the second element only, because
// we don't need to compare the elements further.
// Note that the second element is at (index == 1), because
// the first element is at (index == 0).
if(m_first_element+m_step*1 < r.m_first_element+r.m_step*1)
return false;
if(m_first_element+m_step*1 > r.m_first_element+r.m_step*1)
return true;
// if the first two elements of both ranges are equal, then
// they are co-linear ranges(because the step is constant).
// In that case, they comparison depends only on
// the size of the ranges by convention.
return m_element_count > r.m_element_count;
}
bool operator <=(const basic_range<IntegerType>& r) const
{
return !(*this > r);
}
bool operator >=(const basic_range<IntegerType>& r) const
{
return !(*this < r);
}
const_iterator begin() const
{
return const_iterator(this, 0);
}
const_iterator end() const
{
return const_iterator(this, m_element_count);
}
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(this, 0);
}
const_reverse_iterator rend() const
{
return const_reverse_iterator(this, m_element_count);
}
size_type size() const
{
return m_element_count;
}
size_type max_size() const
{
// Because this is an immutable container,
// max_size() == size()
return m_element_count;
}
bool empty() const
{
return m_element_count == 0;
}
// exist() and find() are similar except that
// find() returns the index of the element.
iterator find(value_type element) const
{
value_type element_index = (element - m_first_element) / m_step;
bool in_range = element_index >= 0 && element_index < m_element_count &&
(element - m_first_element) % m_step == 0;
if(in_range)
return begin() + element_index;
return end();
}
bool exist(value_type element) const
{
return find(element) != end();
}
// In the standard, the operator[]
// should return a const reference.
// Because Range Generator doesn't store its elements
// internally, we return a copy of the value.
// In any case, this doesn't affect the semantics of the operator.
value_type operator[](size_type index) const
{
return m_first_element + m_step*index;
}
private:
// m_first_element: begin (see specifications).
// m_element_count: (end - begin) / step
value_type m_first_element, m_element_count, m_step;
};
// This is the default type of range!
typedef basic_range<int> range;
}
#endif // range_h__

View File

@@ -1,6 +0,0 @@
#include "version_cpp.h"
#include "version.h"
const char* const vba_name_and_subversion = VBA_NAME_AND_SUBVERSION;
const char* const vbam_version = VBAM_VERSION;

View File

@@ -1,8 +0,0 @@
#ifndef VBAM_VERSION_CPP_H
#define VBAM_VERSION_CPP_H
extern const char* const vba_name_and_subversion;
extern const char* const vbam_version;
#endif /* VBAM_VERSION_CPP_H */

View File

@@ -0,0 +1,6 @@
add_subdirectory(av_recording)
add_subdirectory(draw_text)
add_subdirectory(filters)
add_subdirectory(filters_agb)
add_subdirectory(filters_interframe)
add_subdirectory(user_config)

View File

@@ -0,0 +1,18 @@
if(NOT ENABLE_FFMPEG)
return()
endif()
add_library(vbam-components-av-recording OBJECT)
target_sources(vbam-components-av-recording
PRIVATE av_recording.cpp
PUBLIC av_recording.h
)
target_include_directories(vbam-components-av-recording
PUBLIC ${FFMPEG_INCLUDE_DIRS}
)
target_link_libraries(vbam-components-av-recording
PUBLIC ${FFMPEG_LIBRARIES}
)

View File

@@ -1,4 +1,4 @@
#include "ffmpeg.h"
#include "components/av_recording/av_recording.h"
#define STREAM_FRAME_RATE 60
#define STREAM_PIXEL_FORMAT AV_PIX_FMT_YUV420P
@@ -137,18 +137,12 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
}
}
if (!isSupported && acodec->supported_samplerates) return MRET_ERR_NOCODEC;
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
#if LIBAVCODEC_VERSION_MAJOR >= 60
av_channel_layout_from_mask(&(aenc->ch_layout), AV_CH_LAYOUT_STEREO);
#else
aenc->channel_layout = AV_CH_LAYOUT_STEREO;
if (acodec->channel_layouts)
{
aenc->channel_layout = acodec->channel_layouts[0];
for (int i = 0; acodec->channel_layouts[i]; ++i)
{
if (acodec->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
aenc->channel_layout = AV_CH_LAYOUT_STEREO;
}
}
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
aenc->channels = 2;
#endif
aenc->time_base = { 1, aenc->sample_rate };
ast->time_base = { 1, STREAM_FRAME_RATE };
// open and use codec on stream
@@ -169,7 +163,11 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
audioframeTmp = av_frame_alloc();
if (!audioframeTmp) return MRET_ERR_BUFSIZE;
audioframeTmp->format = IN_SOUND_FORMAT;
audioframeTmp->channel_layout = aenc->channel_layout;
#if LIBAVCODEC_VERSION_MAJOR >= 60
audioframeTmp->ch_layout = aenc->ch_layout;
#else
audioframeTmp->channel_layout = AV_CH_LAYOUT_STEREO;
#endif
audioframeTmp->sample_rate = aenc->sample_rate;
audioframeTmp->nb_samples = nb_samples;
if (nb_samples)
@@ -181,7 +179,11 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
audioframe = av_frame_alloc();
if (!audioframe) return MRET_ERR_BUFSIZE;
audioframe->format = aenc->sample_fmt;
audioframe->channel_layout = aenc->channel_layout;
#if LIBAVCODEC_VERSION_MAJOR >= 60
audioframe->ch_layout = aenc->ch_layout;
#else
audioframe->channel_layout = AV_CH_LAYOUT_STEREO;
#endif
audioframe->sample_rate = aenc->sample_rate;
audioframe->nb_samples = nb_samples;
if (nb_samples)
@@ -195,10 +197,15 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
{
return MRET_ERR_BUFSIZE;
}
av_opt_set_int (swr, "in_channel_count", aenc->channels, 0);
#if LIBAVCODEC_VERSION_MAJOR >= 60
av_opt_set_chlayout (swr, "in_chlayout", &(aenc->ch_layout),0);
av_opt_set_chlayout (swr, "out_chlayout", &(aenc->ch_layout),0);
#else
av_opt_set_int (swr, "in_channel_count", 2, 0);
av_opt_set_int (swr, "out_channel_count", 2, 0);
#endif
av_opt_set_int (swr, "in_sample_rate", aenc->sample_rate, 0);
av_opt_set_sample_fmt(swr, "in_sample_fmt", IN_SOUND_FORMAT, 0);
av_opt_set_int (swr, "out_channel_count", aenc->channels, 0);
av_opt_set_int (swr, "out_sample_rate", aenc->sample_rate, 0);
av_opt_set_sample_fmt(swr, "out_sample_fmt", aenc->sample_fmt, 0);
if (swr_init(swr) < 0)
@@ -207,8 +214,8 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
return MRET_ERR_BUFSIZE;
}
// auxiliary buffer for setting up frames for encode
audioBufferSize = nb_samples * aenc->channels * sizeof(uint16_t);
audioBuffer = (uint16_t *) calloc(nb_samples * aenc->channels, sizeof(uint16_t));
audioBufferSize = nb_samples * 2 * sizeof(uint16_t);
audioBuffer = (uint16_t *) calloc(nb_samples * 2, sizeof(uint16_t));
if (!audioBuffer) return MRET_ERR_BUFSIZE;
samplesInAudioBuffer = 0;
posInAudioBuffer = 0;
@@ -565,7 +572,7 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
{
if (!isRecording) return MRET_OK;
AVCodecContext *c = aenc;
int samples_size = av_samples_get_buffer_size(NULL, c->channels, audioframeTmp->nb_samples, IN_SOUND_FORMAT, 1);
int samples_size = av_samples_get_buffer_size(NULL, 2, audioframeTmp->nb_samples, IN_SOUND_FORMAT, 1);
int realLength = length / sizeof *aud;
bool isMissing = false;
@@ -606,7 +613,7 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
pkt->data = NULL;
pkt->size = 0;
if (avcodec_fill_audio_frame(audioframeTmp, c->channels, IN_SOUND_FORMAT, (const uint8_t *)audioBuffer, samples_size, 1) < 0)
if (avcodec_fill_audio_frame(audioframeTmp, 2, IN_SOUND_FORMAT, (const uint8_t *)audioBuffer, samples_size, 1) < 0)
{
return MRET_ERR_RECORDING;
}

View File

@@ -1,12 +1,12 @@
#ifndef WX_FFMPEG_H
#define WX_FFMPEG_H
#ifndef VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_
#define VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_
// simplified interface for recording audio and/or video from emulator
extern "C" {
/* From: http://redino.net/blog/2013/12/uint64_c-defined-including-libavformatavformat-h-vs-2008/ */
#include <stdint.h>
#include <cstdint>
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
@@ -29,7 +29,6 @@ extern "C" {
}
#include <vector>
#include <string>
namespace recording {
@@ -127,4 +126,4 @@ class MediaRecorder
}
#endif /* WX_FFMPEG_H */
#endif // VBAM_COMPONENTS_AV_RECORDING_AV_RECORDING_H_

View File

@@ -0,0 +1,10 @@
add_library(vbam-components-draw-text OBJECT)
target_sources(vbam-components-draw-text
PRIVATE draw_text.cpp
PUBLIC draw_text.h
)
target_link_libraries(vbam-components-draw-text
PRIVATE vbam-core-base
)

View File

@@ -20,7 +20,9 @@
/* Code originally from fceu/drawing.h file, adapted by Forgotten
*/
#include "../System.h"
#include "components/draw_text/draw_text.h"
#include "core/base/system.h"
extern int RGB_LOW_BITS_MASK;

View File

@@ -17,4 +17,11 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_
#define VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_
#include <cstdint>
extern void drawText(uint8_t*, int, int, int, const char*, bool);
#endif // VBAM_COMPONENTS_DRAW_TEXT_DRAW_TEXT_H_

View File

@@ -0,0 +1,47 @@
add_library(vbam-components-filters OBJECT)
target_sources(vbam-components-filters
PRIVATE
internal/2xSaI.cpp
internal/admame.cpp
internal/bilinear.cpp
internal/hq2x.cpp
internal/hq2x.h
internal/interp.h
internal/lq2x.h
internal/pixel.cpp
internal/scanline.cpp
internal/simpleFilter.cpp
internal/xBRZ/xbrz.cpp
internal/xBRZ/xbrz.h
internal/xBRZ/xbrz_config.h
internal/xBRZ/xbrz_tools.h
internal/xbrzfilter.cpp
PUBLIC
filters.h
)
if(ENABLE_ASM_SCALERS)
target_sources(vbam-components-filters
PRIVATE
internal/hq/asm/hq3x_16.asm
internal/hq/asm/hq3x_32.asm
internal/hq/asm/hq4x_16.asm
internal/hq/asm/hq4x_32.asm
internal/hq/asm/hq3x32.cpp
internal/hq/asm/macros.mac
)
if(ENABLE_MMX)
set(SRC_FILTERS ${SRC_FILTERS} internal/2xSaImmx.asm)
endif()
else()
target_sources(vbam-components-filters
PRIVATE
internal/hq/c/hq3x_pattern.h
internal/hq/c/hq4x_pattern.h
internal/hq/c/hq_base.h
internal/hq/c/hq_implementation.cpp
internal/hq/c/hq_shared.h
)
endif()

View File

@@ -1,14 +1,12 @@
#ifndef FILTERS_H
#define FILTERS_H
#ifndef VBAM_COMPONENTS_FILTERS_FILTERS_H_
#define VBAM_COMPONENTS_FILTERS_FILTERS_H_
#include <cstdint>
// FIXME: these should be in a system header included by all users and all
// files which define these functions
// most 16-bit filters require space in src rounded up to uint32_t
// those that take delta take 1 src line of pixels, rounded up to uint32_t size
// initial value appears to be all-0xff
#include "../filters/interframe.hpp"
void Pixelate32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
void Pixelate(uint8_t* src, uint32_t spitch, uint8_t* delta, uint8_t* dst, uint32_t dstp, int w, int h);
// next 3*2 use Init_2xSaI(555|565) and do not take into account
@@ -71,4 +69,4 @@ void xbrz4x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t ds
void xbrz5x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
void xbrz6x32(uint8_t* src, uint32_t spitch, uint8_t*, uint8_t* dst, uint32_t dstp, int w, int h);
#endif /* FILTERS_H */
#endif // VBAM_COMPONENTS_FILTERS_FILTERS_H_

View File

@@ -1,4 +1,4 @@
#include "../System.h"
#include "core/base/system.h"
extern int RGB_LOW_BITS_MASK;

View File

@@ -35,7 +35,7 @@
* - the whole source code of the program is released with the binary.
*/
#include "../System.h"
#include <cstdint>
#ifdef MMX
extern "C" bool cpu_mmx;

View File

@@ -4,7 +4,7 @@
** Written: 6/14/00 - JSF
**/
#include "../System.h"
#include "core/base/system.h"
#define RGB(r,g,b) ((r)>>3) << systemRedShift |\
((g) >> 3) << systemGreenShift |\

View File

@@ -27,7 +27,7 @@
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*/
#include "../System.h"
#include "interp.h"
/***************************************************************************/

View File

@@ -28,12 +28,10 @@
* do so, delete this exception statement from your version.
*/
#ifndef __INTERP_H
#define __INTERP_H
#ifndef VBAM_COMPONENTS_FILTERS_INTERNAL_INTERP_H
#define VBAM_COMPONENTS_FILTERS_INTERNAL_INTERP_H
#define __STDC_CONSTANT_MACROS
#include <stdint.h>
#include <cstdint>
typedef uint16_t interp_uint16;
typedef uint32_t interp_uint32;
@@ -342,4 +340,4 @@ static void interp_set(unsigned bits_per_pixel)
}
}
#endif
#endif // VBAM_COMPONENTS_FILTERS_INTERNAL_INTERP_H

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