140 Commits
Author SHA1 Message Date
SSimco 317e207948 Updated release workflow 2024-09-22 00:36:31 +03:00
SSimco da7af728a9 Fixed dep 2024-09-21 21:58:40 +03:00
SSimco bc2b573053 Fixed key text not showing 2024-09-21 21:56:55 +03:00
SSimco 25ea6ddf47 Merge branch 'main' into android 2024-09-21 21:52:34 +03:00
SSimco be23c47cac Pass c++ exception to java for renderer functions 2024-09-21 21:48:37 +03:00
SSimco 80ea25b10f Added support for opening titles using file managers 2024-09-21 20:48:39 +03:00
SSimco cc10f93030 Updated android workflow to create storefile only if the secret is available 2024-09-04 13:51:29 +03:00
SSimco 75223fcf36 Refactored fileutils code 2024-09-04 11:30:03 +03:00
SSimco 882c840ae6 Removed unused icon 2024-09-04 07:40:52 +03:00
SSimco 0037544a00 Refactored game list code & added option to remove & add multiple game paths 2024-09-03 19:34:15 +03:00
SSimco 1485d0e315 Updated icon 2024-09-03 19:27:14 +03:00
SSimco 81c0e4a465 Added support for motion 2024-09-02 14:25:04 +03:00
SSimco d0eac6f470 Fixed not being able to resize some buttons 2024-09-01 22:34:47 +03:00
SSimco 3678a0e474 Added option to show graphic packs for installed games only 2024-09-01 22:34:44 +03:00
SSimco f0effa0f31 Fixed github workflow for android 2024-09-01 17:45:33 +03:00
SSimco dceec9e20a Added options to show the gamepad & added a menu when in game 2024-09-01 17:44:33 +03:00
SSimco c1fc52d169 Updated overlay settings 2024-09-01 09:47:46 +03:00
SSimco 52d73c2f3e Fix count cycles macro for count cycles > 4095 2024-09-01 09:42:45 +03:00
SSimco d5d686c3bf Fixed gamepad volume enable/disable toggle 2024-09-01 07:25:52 +03:00
SSimco 3e8d56c022 Refactor code 2024-09-01 07:25:49 +03:00
SSimco 972e655a9b Send touch events to Input manager 2024-08-31 11:28:58 +03:00
SSimco 5e129a87cb Update deprecated attribute 2024-08-30 20:23:52 +03:00
SSimco 73c864f196 WIP: refactor code 2024-08-30 20:22:58 +03:00
SSimco 655dd1ca2f Cleanup code 2024-08-30 20:22:39 +03:00
SSimco 15e64c48e3 Add x64 check for ATTR_MS_ABI 2024-08-30 20:22:18 +03:00
SSimco 87315d3457 Update xbyak dep 2024-08-30 20:21:26 +03:00
SSimco c2fb43ca96 Update recompiler tests 2024-08-30 20:15:29 +03:00
SSimco 89bdaad188 Update xbyak 2024-08-27 10:50:52 +03:00
SSimco 527ac0e575 Implement DCBZ 2024-08-26 20:15:43 +03:00
SSimco 8e38264c10 Merge branch 'main' into android 2024-08-26 16:07:04 +03:00
SSimco 912a4af5b4 Merge branch 'main' into android 2024-08-26 16:06:43 +03:00
ExvergeandGitHub 1e15f337ec GX2: Use atomic pointers rather than mutex (#3)
* Revert "fix for recompiler/interperter crash on arm"

This reverts commit fb03e66041.

* gx2: Use atomic pointers for GX2WriteGatherPipeState
2024-08-26 12:22:55 +03:00
SSimco df40605042 Fix nav 2024-08-26 12:21:30 +03:00
SSimco 691974bc96 Updated gradle 2024-08-26 12:21:04 +03:00
SSimco 860966a946 Added arm64 toolchain cmake file 2024-08-26 12:20:37 +03:00
SSimco 4c929264fe Update xbyak dependency & reimplement some instructions 2024-08-26 12:18:01 +03:00
SSimco 14a29617fe WIP: recompiler tests 2024-08-26 12:16:30 +03:00
SSimco 92f7342fbd Fix typo 2024-07-28 10:23:46 +03:00
SSimco 30a1221067 Refactor code 2024-07-27 22:56:44 +03:00
9dbc01db13 Fix typos in fs wrappers
* Fix typos in fs wrappers

---------

Co-authored-by: SSimco <37044560+SSimco@users.noreply.github.com>
2024-07-13 11:16:01 +03:00
SSimco 987cb7799b Refactored common layout & update game item text size 2024-07-09 19:28:02 +03:00
SSimco 3f5d6eda66 Added ci for building the android app 2024-07-09 14:28:50 +03:00
SSimco aae6313fdb Merge branch 'main' into android 2024-07-09 11:23:13 +03:00
SSimco 7e4a0a5264 Cleanup android code 2024-07-08 19:55:38 +03:00
SSimco 7be7cf46d1 Added overlay settings 2024-07-08 19:46:53 +03:00
SSimco bb10cfbf62 Remove pre-rotation work 2024-07-08 19:19:22 +03:00
SSimco bab67d7df0 Use tick effect 2024-05-28 09:32:38 +03:00
SSimco e05d07b426 Update games fragment design 2024-05-26 18:25:36 +03:00
SSimco b50880e7d4 Added thread fences to FiberBoost & fixed x64 build 2024-05-26 17:52:14 +03:00
SSimco f1dec91ae1 Added input overlay 2024-05-26 17:51:32 +03:00
SSimco 8a4b99b3e1 Updated gradle build 2024-05-26 17:50:03 +03:00
SSimco fb03e66041 fix for recompiler/interperter crash on arm 2024-05-25 07:07:33 +03:00
SSimco 9760bafb8a Fix crash in graphic packs fragment 2024-04-09 08:13:09 +03:00
SSimco b4c70f09d5 Apply clang-format to all c++ android files 2024-04-07 23:39:35 +03:00
SSimco 3c916747af Added graphic packs settings 2024-04-07 23:33:49 +03:00
SSimco 275a46f97f Replace x86 intrinsics with sse2neon on arm64 & refactor code 2024-02-21 20:31:10 +02:00
SSimco 610cced493 Recompiler fix 2024-02-16 22:50:07 +02:00
SSimco 36157ae5e7 Fix crash in input fragments 2024-02-16 22:49:11 +02:00
SSimco 00a5c44464 Merge branch 'android-2' into android-jit 2024-02-16 22:40:30 +02:00
SSimco f5cf6b7ca6 Updated ndkVersion & build without HIDAPI on android 2024-01-20 22:59:52 +02:00
SSimco 47f4c6b79e Added debug build type appIdsuffix 2024-01-20 21:47:42 +02:00
SSimco 748070bc12 Revert "Added libucontext for android & replaced x86 intrinsics with sse2neon implementations"
This reverts commit 8e666d32d0.
2024-01-20 21:44:37 +02:00
SSimco 179bf2c145 Merge branch 'main' into android-2 2024-01-20 21:41:24 +02:00
SSimco 8e666d32d0 Added libucontext for android & replaced x86 intrinsics with sse2neon implementations 2023-12-27 16:14:44 +02:00
SSimco 47091d836b Fixed build 2023-12-23 22:44:10 +02:00
SSimco fda05a5a00 Merge branch 'android' into android-2 2023-12-23 18:00:09 +02:00
SSimco 036551aab7 Fix crash in input settings fragment 2023-10-25 09:49:59 +03:00
SSimco 80543ba2c6 Fix build 2023-10-23 01:10:11 +03:00
SSimco 99e908c708 WIP jit 2023-10-22 18:39:07 +03:00
SSimco aca4534108 Merge remote-tracking branch 'origin/jit-aarch64' into android-jit 2023-08-02 06:20:24 +03:00
SSimco 3ef1f7cca9 Merge branch 'jit-work' into jit-aarch64 2023-08-01 18:24:28 +03:00
SSimco e3aaa58cc8 Merge branch 'main' into android 2023-07-30 14:52:30 +03:00
SSimco a6f09536c6 Refactor android native code 2023-07-30 14:29:33 +03:00
SSimco e83359b9d8 Remove gui dependency from all projects except CemuBin 2023-07-30 12:07:37 +03:00
SSimco 85deb01568 Move wxGui files to gui & remove AndroidGui 2023-07-29 09:45:40 +03:00
SSimco 67e171c48e Remove guiWrapper from gui project & replace all functions with callbacks 2023-07-29 09:38:31 +03:00
SSimco 7cf80d26e2 Fix wrong check 2023-07-22 20:46:53 +03:00
SSimco fb87aa7261 Add option to search for games 2023-07-06 06:53:56 +03:00
SSimco 26f5d8dfab Refactor adapters & add audio, graphics and game folder settings 2023-07-04 20:27:09 +03:00
SSimco ddc29f1206 Replace most adapters with a generic one 2023-07-03 17:35:18 +03:00
SSimco 5da49b59eb Disable DSUControllerProvider on Android 2023-07-03 14:21:19 +03:00
SSimco 14fb7c8a2a Print stacktrace on crashes on Android 2023-07-03 10:44:53 +03:00
SSimco 29841a3fb2 Add support for controller on Android 2023-07-02 22:05:55 +03:00
SSimco 8006ec36ef Create TV audio device at the start of the application 2023-06-22 13:18:03 +03:00
SSimco 5a4e27e702 Fix crash when calling JNI methods while inside a fiber & add support reading games from folder 2023-06-18 17:21:57 +03:00
SSimco f60abeddcd Add support for reading game files using SAF 2023-06-17 23:19:17 +03:00
SSimco 3c8fe805b8 Fix trying to acquire image when the surface is lost 2023-06-15 06:53:59 +03:00
SSimco 479e7c427a Add dialog to confirm exit in emulation activity 2023-06-15 06:53:22 +03:00
SSimco b1fef19a63 Add pre-rotation for Android 2023-06-13 11:25:22 +03:00
SSimco 785a37e503 Add settings, games and emulation activities 2023-06-12 15:49:48 +03:00
SSimco 12e7f9956c Add icon & title loader classes and JNI project 2023-06-11 07:50:44 +03:00
SSimco a03ce9a746 Fix android build 2023-06-10 13:45:15 +03:00
SSimco 05f3444207 Add android project to src 2023-06-08 08:54:05 +03:00
SSimco 6aed5dde46 Make SDL & OpenGL optional and fix build on Android 2023-06-08 08:52:02 +03:00
SSimco be77df52b9 Move wxWidgets gui to wxGui 2023-06-07 12:45:02 +03:00
SSimco e315a7ecb0 Remove wxWidgets dependencies 2023-06-07 11:33:34 +03:00
SSimco c0147f0c2e Move audioDebugger to ui 2023-06-07 10:24:46 +03:00
SSimco 466f03febc Move screenshot logic with wxWidgets to guiWrapper 2023-06-07 10:23:13 +03:00
SSimco 8b265a9843 Move logic for getting button name for keyboard keys to guiWrapper 2023-06-07 09:15:46 +03:00
SSimco 8193ebf7d4 Remove wxMessageBoxes from non-gui code 2023-06-07 09:11:53 +03:00
Exzap 3590ad9099 PPCRec: Implement MFCR and MTCRF 2023-03-13 05:10:44 +01:00
Exzap 97e39e37fc PPCRec: FPRs now use the shared register allocator 2023-02-06 18:03:18 +01:00
Exzap d8bccfe32f PPCRec: Further work on support for typed registers in RA
Additionally there is no more range limit for virtual RegIDs, making the entire uint16 space available in theory
2023-02-05 21:20:26 +01:00
Exzap 6a63eb8871 PPCRec: Partial support for typed registers in RA 2023-02-04 17:54:46 +01:00
Exzap cb619b143d PPCRec: Initial support for typed registers 2023-02-02 17:18:36 +01:00
Exzap 5d96191e00 PPCRec: Fix capitalization in include 2023-01-30 06:57:48 +01:00
Exzap e9ac89da14 PPCRec: Use agnostic breakpoints 2023-01-30 06:30:29 +01:00
Exzap 9dae9461ad PPCRec: Use IMLReg type in FPR RA 2023-01-30 06:01:39 +01:00
Exzap 8e834e6c6e PPCRec: Unify code + misc RA preparation
Whoopsie
2023-01-30 03:52:43 +01:00
Exzap 8fffefedcc PPCRec: Simplify PPC and IML logic instructions
Also implement PPC NAND instruction
2023-01-29 14:57:57 +01:00
Exzap 9ef079cdf8 PPCRec: Use IMLReg in more places, unify and simplify var names 2023-01-29 14:57:57 +01:00
Exzap ac175bcc62 PPCRec: Refactor load/store instructions 2023-01-29 14:57:57 +01:00
Exzap f59f4af582 PPCRec: Refactoring and clean up 2023-01-29 14:57:57 +01:00
Exzap e0dd7f3bf9 PPCRec: Rework CR bit handling
CR bits are now resident in registers instead of being baked into the instruction definitions. Same for XER SO, and LWARX reservation EA and value.

Reworked LWARX/STWCX, CRxx ops, compare and branch instructions. As well as RC bit handling. Not all CR-related instructions are reimplemented yet.

Introduced atomic_cmp_store operation to allow implementing STWCX in architecture agnostic IML

Removed legacy CR-based compare and jump operations
2023-01-29 14:57:57 +01:00
Exzap 5b07df5f29 PPCRec: Avoid complex optimizations in backend
It's better to do it in a lowering pass so that the backend code can be kept as simple as possible
2023-01-29 14:56:20 +01:00
Exzap b5d237e40e PPCRec: Rework carry bit and generalize carry IML instructions
Carry bit is now resident in a register-allocated GPR instead of being backed directly into IML instructions

All the PowerPC carry ADD* and SUB* instructions as well as SRAW/SRAWI have been reworked to use more generalized IML instructions for handling carry

IML instructions now support two named output registers instead of only one (easily extendable to arbitrary count)
2023-01-29 14:56:20 +01:00
Exzap db4563879e PPCRec: Further unify CR code 2023-01-29 14:56:20 +01:00
Exzap abb7df11e6 PPCRec: Streamline instructions + unify code for CR updates 2023-01-29 14:56:20 +01:00
Exzap dfcd1232e1 PPCRec: New compare and cond jump instrs, update RA
Storing the condition result in a register instead of imitating PPC CR lets us simplify the backend a lot. Only implemented as PoC for BDZ/BDNZ so far.
2023-01-29 14:56:20 +01:00
Exzap 02fef01a2f PPCRec: New x86-64 code emitter 2023-01-29 14:56:20 +01:00
Exzap 2976fa78c5 PPCRec: Rename register constants to avoid name collision 2023-01-29 14:56:20 +01:00
Exzap 058d13f70d PPCRec: Make register pool for RA configurable 2023-01-29 14:56:20 +01:00
Exzap 906f397839 PPCRec: Make LSWI/STWSI more generic + GPR temporaries storage 2023-01-29 14:56:20 +01:00
Exzap dae91088fc PPCRec: Clean up unused flags 2023-01-29 14:56:20 +01:00
Exzap 5207e9c2df PPCRec: Remove now unused PPC_ENTER and jumpMarkAddress 2023-01-29 14:56:20 +01:00
Exzap 88485c32bb PPCRec: Fix single segment loop not being detected
Also removed associatedPPCAddress field from IMLInstruction as it's no longer used
2023-01-29 14:56:20 +01:00
Exzap dbe73e8eff PPCRec: Unify BCCTR and BCLR code
Instead of having fixed macros for BCCTR/BCCTRL/BCLR/BCLRL we now have only one single macro instruction that takes the jump destination as a register parameter.
This also allows us to reuse an already loaded LR register (by something like MTLR) instead of loading it again from memory.

As a necessary requirement for this: The register allocator now has support for read operations in suffix instructions
2023-01-29 14:56:20 +01:00
Exzap bdfc99e9d5 PPCRec: Fix merge conflicts 2023-01-29 14:56:20 +01:00
Exzap 98e398c92e PPCRec: Reworked IML builder to work with basic-blocks
Intermediate commit while I'm still fixing things but I didn't want to pile on too many changes in a single commit.
New:
Reworked PPC->IML converter to first create a graph of basic blocks and then turn those into IML segment(s). This was mainly done to decouple IML design from having PPC specific knowledge like branch target addresses. The previous design also didn't allow to preserve cycle counting properly in all cases since it was based on IML instruction counting.
The new solution supports functions with non-continuous body. A pretty common example for this is when functions end with a trailing B instruction to some other place.

Current limitations:
- BL inlining not implemented
- MFTB not implemented
- BCCTR and BCLR are only partially implemented
2023-01-29 14:56:20 +01:00
Exzap 400b107b8c PPCRec: Move X64 files into subdirectory and rename 2023-01-29 14:55:19 +01:00
Exzap 294f9ed11b PPCRec: Emit x86 movd for non-AVX + more restructuring 2023-01-29 14:55:19 +01:00
Exzap 5ecc65dc45 PPCRec: Move IML register allocator 2023-01-29 14:55:19 +01:00
Exzap e36e7b5d18 PPCRec: Move IML optimizer file 2023-01-29 14:55:19 +01:00
Exzap ac57c31321 PPCRec: Move analyzer file + move some funcs to IMLInstruction 2023-01-29 14:55:19 +01:00
Exzap c14300c6d4 PPCRec: Move debug printing + smaller clean up 2023-01-29 14:55:19 +01:00
Exzap 45403c242a PPCRec: Rename IML structs for better clarity 2023-01-29 14:55:19 +01:00
Exzap 0f1276e785 PPCRec: Move Segment and Instruction struct into separate files 2023-01-29 14:55:19 +01:00
Exzap 12723b6034 PPCRec: Use vector for instruction list 2023-01-29 14:55:19 +01:00
Exzap 954be7e6a3 PPCRec: Use vector for segment list + deduplicate RA file 2023-01-29 14:55:19 +01:00
Exzap 808b9aebdc Latte: Fix race condition on close during game boot 2023-01-29 14:55:19 +01:00
438 changed files with 49309 additions and 13726 deletions
+51
View File
@@ -0,0 +1,51 @@
name: Android build
on:
workflow_call:
workflow_dispatch:
push:
branches: ["android"]
pull_request:
branches: ["android"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
- name: Create store file
env:
ANDROID_STORE_FILE_BASE64: ${{ secrets.ANDROID_STORE_FILE_BASE64 }}
ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
if: "${{ env.ANDROID_STORE_FILE_BASE64 != '' }}"
run: |
cd ./src/android
base64 --decode <<< "${ANDROID_STORE_FILE_BASE64}" > store.jks
ANDROID_STORE_FILE=$(pwd)/store.jks
echo -e "keyStorePassword=$ANDROID_KEY_STORE_PASSWORD\nkeyAlias=$ANDROID_KEY_ALIAS\nstoreFile=$ANDROID_STORE_FILE\n" > keystore.properties
- name: Build Cemu for Android
run: |
cd ./src/android
./gradlew assembleRelease
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cemu-android
path: |
./src/android/app/build/outputs/apk/release/*.apk
./src/android/app/build/outputs/apk/release/*.aab
@@ -0,0 +1,46 @@
name: Deploy experimental android release
on:
workflow_dispatch:
jobs:
call-release-build:
uses: ./.github/workflows/android_build.yml
secrets: inherit
deploy:
name: Deploy experimental release
runs-on: ubuntu-22.04
needs: [call-release-build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: cemu-android
path: cemu-android
- name: Initialize
run: |
mkdir upload
sudo apt install zip
- name: Set version dependent vars
run: |
echo "CEMU_VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Create release from apk
run: |
VERSION=${{ env.CEMU_VERSION }}
echo "Cemu Version is $VERSION"
ls cemu-android
mv cemu-android/*.apk upload/Cemu-$VERSION.apk
- name: Create release
run: |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz
tar xvzf ghr.tar.gz; rm ghr.tar.gz
echo "[INFO] Release tag: v${{ env.CEMU_VERSION }}"
RELEASE_BODY=$(printf "Experimental release\n%s" "Latest commit ${{ env.CEMU_VERSION }}")
ghr_v0.15.0_linux_amd64/ghr -b "$RELEASE_BODY" -t ${{ secrets.GITHUB_TOKEN }} -n "Cemu ${{ env.CEMU_VERSION }}" "${{ env.CEMU_VERSION }}" ./upload
+1
View File
@@ -17,6 +17,7 @@
.idea/
build/
build_arm
cmake-build-*/
out/
.cache/
+4 -1
View File
@@ -1,6 +1,6 @@
[submodule "dependencies/ZArchive"]
path = dependencies/ZArchive
url = https://github.com/Exzap/ZArchive
url = https://github.com/SSimco/ZArchive
shallow = true
[submodule "dependencies/cubeb"]
path = dependencies/cubeb
@@ -18,3 +18,6 @@
path = dependencies/imgui
url = https://github.com/ocornut/imgui
shallow = true
[submodule "dependencies/xbyak_aarch64"]
path = dependencies/xbyak_aarch64
url = https://github.com/fujitsu/xbyak_aarch64
+27 -8
View File
@@ -35,15 +35,22 @@ if (ENABLE_VCPKG)
)
endif()
if(UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE AND NOT VCPKG_TARGET_ANDROID)
set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports_linux")
elseif(APPLE)
set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports_mac")
else()
set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports")
endif()
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
if(VCPKG_TARGET_ANDROID)
set(ENV{ANDROID_NDK_HOME} ${ANDROID_NDK})
set(ENV{VCPKG_ROOT} "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/vcpkg_android.cmake")
else()
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()
# Set this so that all the various find_package() calls don't need an explicit
# CONFIG option
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
@@ -70,8 +77,10 @@ add_definitions(-DEMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH})
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# enable link time optimization for release builds
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
if(NOT ANDROID)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)
endif()
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CemuBin)
@@ -143,11 +152,17 @@ option(ENABLE_WXWIDGETS "Build with wxWidgets UI (Currently required)" ON)
set(THREADS_PREFER_PTHREAD_FLAG true)
find_package(Threads REQUIRED)
find_package(SDL2 REQUIRED)
if(ENABLE_SDL)
find_package(SDL2 REQUIRED)
add_compile_definitions("HAS_SDL=1")
endif()
find_package(CURL REQUIRED)
find_package(pugixml REQUIRED)
find_package(RapidJSON REQUIRED)
find_package(Boost COMPONENTS program_options filesystem nowide REQUIRED)
if(ANDROID)
find_package(Boost COMPONENTS context iostreams REQUIRED)
endif()
find_package(libzip REQUIRED)
find_package(glslang REQUIRED)
find_package(ZLIB REQUIRED)
@@ -162,7 +177,7 @@ if (NOT TARGET glslang::SPIRV AND TARGET SPIRV)
add_library(glslang::SPIRV ALIAS SPIRV)
endif()
if (UNIX AND NOT APPLE)
if (UNIX AND NOT APPLE AND NOT ANDROID)
find_package(X11 REQUIRED)
if (ENABLE_WAYLAND)
find_package(Wayland REQUIRED Client)
@@ -201,7 +216,7 @@ if (ENABLE_HIDAPI)
add_compile_definitions(HAS_HIDAPI)
endif ()
if(UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE AND NOT ANDROID)
if(ENABLE_FERAL_GAMEMODE)
add_compile_definitions(ENABLE_FERAL_GAMEMODE)
add_subdirectory(dependencies/gamemode EXCLUDE_FROM_ALL)
@@ -231,6 +246,10 @@ endif()
add_subdirectory("dependencies/ih264d" EXCLUDE_FROM_ALL)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)")
add_subdirectory("dependencies/xbyak_aarch64" EXCLUDE_FROM_ALL)
endif()
find_package(ZArchive)
if (NOT ZArchive_FOUND)
add_subdirectory("dependencies/ZArchive" EXCLUDE_FROM_ALL)
Executable
+11
View File
@@ -0,0 +1,11 @@
#! /bin/env bash
# rm -rf build_arm
set -e
cmake -S . -B build_arm -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DENABLE_VCPKG=OFF \
-DCMAKE_TOOLCHAIN_FILE=./cmake/debian-arm64toolchain.cmake \
-DENABLE_WAYLAND=OFF \
-DENABLE_HIDAPI=OFF \
-DENABLE_NSYSHID_LIBUSB=OFF \
-G Ninja
cmake --build build_arm
+9
View File
@@ -0,0 +1,9 @@
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
set(CMAKE_ASM_COMPILER_TARGET aarch64-linux-gnu)
set(CMAKE_C_COMPILER clang-16)
set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu)
set(CMAKE_CXX_COMPILER clang++-16)
set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu)
set(PKG_CONFIG_EXECUTABLE "aarch64-linux-gnu-pkg-config")
set(PKGCONFIG_EXECUTABLE "aarch64-linux-gnu-pkg-config")
+99
View File
@@ -0,0 +1,99 @@
#
# vcpkg_android.cmake
#
# Helper script when using vcpkg with cmake. It should be triggered via the variable VCPKG_TARGET_ANDROID
#
# For example:
# if (VCPKG_TARGET_ANDROID)
# include("cmake/vcpkg_android.cmake")
# endif()
#
# This script will:
# 1 & 2. check the presence of needed env variables: ANDROID_NDK_HOME and VCPKG_ROOT
# 3. set VCPKG_TARGET_TRIPLET according to ANDROID_ABI
# 4. Combine vcpkg and Android toolchains by setting CMAKE_TOOLCHAIN_FILE
# and VCPKG_CHAINLOAD_TOOLCHAIN_FILE
# Note: VCPKG_TARGET_ANDROID is not an official Vcpkg variable.
# it is introduced for the need of this script
if (VCPKG_TARGET_ANDROID)
#
# 1. Check the presence of environment variable ANDROID_NDK_HOME
#
if (NOT DEFINED ENV{ANDROID_NDK_HOME})
message(FATAL_ERROR "
Please set an environment variable ANDROID_NDK_HOME
For example:
export ANDROID_NDK_HOME=/home/your-account/Android/Sdk/ndk-bundle
Or:
export ANDROID_NDK_HOME=/home/your-account/Android/android-ndk-r21b
")
endif()
#
# 2. Check the presence of environment variable VCPKG_ROOT
#
if (NOT DEFINED ENV{VCPKG_ROOT})
message(FATAL_ERROR "
Please set an environment variable VCPKG_ROOT
For example:
export VCPKG_ROOT=/path/to/vcpkg
")
endif()
#
# 3. Set VCPKG_TARGET_TRIPLET according to ANDROID_ABI
#
# There are four different Android ABI, each of which maps to
# a vcpkg triplet. The following table outlines the mapping from vcpkg architectures to android architectures
#
# |VCPKG_TARGET_TRIPLET | ANDROID_ABI |
# |---------------------------|----------------------|
# |arm64-android | arm64-v8a |
# |arm-android | armeabi-v7a |
# |x64-android | x86_64 |
# |x86-android | x86 |
#
# The variable must be stored in the cache in order to successfully the two toolchains.
#
if (ANDROID_ABI MATCHES "arm64-v8a")
set(VCPKG_TARGET_TRIPLET "arm64-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "armeabi-v7a")
set(VCPKG_TARGET_TRIPLET "arm-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "x86_64")
set(VCPKG_TARGET_TRIPLET "x64-android" CACHE STRING "" FORCE)
elseif(ANDROID_ABI MATCHES "x86")
set(VCPKG_TARGET_TRIPLET "x86-android" CACHE STRING "" FORCE)
else()
message(FATAL_ERROR "
Please specify ANDROID_ABI
For example
cmake ... -DANDROID_ABI=armeabi-v7a
Possible ABIs are: arm64-v8a, armeabi-v7a, x64-android, x86-android
")
endif()
message("vcpkg_android.cmake: VCPKG_TARGET_TRIPLET was set to ${VCPKG_TARGET_TRIPLET}")
#
# 4. Combine vcpkg and Android toolchains
#
# vcpkg and android both provide dedicated toolchains:
#
# vcpkg_toolchain_file=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
# android_toolchain_file=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
#
# When using vcpkg, the vcpkg toolchain shall be specified first.
# However, vcpkg provides a way to preload and additional toolchain,
# with the VCPKG_CHAINLOAD_TOOLCHAIN_FILE option.
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE $ENV{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake)
set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
message("vcpkg_android.cmake: CMAKE_TOOLCHAIN_FILE was set to ${CMAKE_TOOLCHAIN_FILE}")
message("vcpkg_android.cmake: VCPKG_CHAINLOAD_TOOLCHAIN_FILE was set to ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
endif(VCPKG_TARGET_ANDROID)
-7
View File
@@ -17,9 +17,6 @@
*****************************************************************************
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
#ifdef __ANDROID__
#include <log/log.h>
#endif
#include "ih264_typedefs.h"
#include "ih264_macros.h"
#include "ih264_platform_macros.h"
@@ -902,10 +899,6 @@ WORD32 ih264d_read_mmco_commands(struct _DecStruct * ps_dec)
{
if (j >= MAX_REF_BUFS)
{
#ifdef __ANDROID__
ALOGE("b/25818142");
android_errorWriteLog(0x534e4554, "25818142");
#endif
ps_dpb_cmds->u1_num_of_commands = 0;
return -1;
}
Vendored Submodule
+1
+41 -20
View File
@@ -18,6 +18,8 @@ elseif(UNIX)
VK_USE_PLATFORM_MACOS_MVK
VK_USE_PLATFORM_METAL_EXT
)
elseif(ANDROID)
add_compile_definitions(VK_USE_PLATFORM_ANDROID_KHR)
else()
add_compile_definitions(
VK_USE_PLATFORM_XLIB_KHR # legacy. Do we need to support XLIB surfaces?
@@ -40,7 +42,11 @@ add_compile_definitions(VK_NO_PROTOTYPES)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_subdirectory(Common)
add_subdirectory(gui)
if(ANDROID)
add_subdirectory(android/app/src/main/cpp)
else()
add_subdirectory(gui)
endif()
add_subdirectory(Cafe)
add_subdirectory(Cemu)
add_subdirectory(config)
@@ -51,28 +57,34 @@ add_subdirectory(imgui)
add_subdirectory(resource)
add_subdirectory(asm)
add_executable(CemuBin
main.cpp
mainLLE.cpp
)
if(ANDROID)
add_library(CemuBin STATIC
main.cpp
mainLLE.cpp
)
else()
add_executable(CemuBin
main.cpp
mainLLE.cpp
)
if(MSVC AND MSVC_VERSION EQUAL 1940)
# workaround for an msvc issue on VS 17.10 where generated ILK files are too large
# see https://developercommunity.visualstudio.com/t/After-updating-to-VS-1710-the-size-of-/10665511
set_target_properties(CemuBin PROPERTIES LINK_FLAGS "/INCREMENTAL:NO")
endif()
if(MSVC AND MSVC_VERSION EQUAL 1940)
# workaround for an msvc issue on VS 17.10 where generated ILK files are too large
# see https://developercommunity.visualstudio.com/t/After-updating-to-VS-1710-the-size-of-/10665511
set_target_properties(CemuBin PROPERTIES LINK_FLAGS "/INCREMENTAL:NO")
endif()
if(WIN32)
target_sources(CemuBin PRIVATE
resource/cemu.rc
if(WIN32)
target_sources(CemuBin PRIVATE
resource/cemu.rc
../dist/windows/cemu.manifest
)
endif()
set_property(TARGET CemuBin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET CemuBin PROPERTY WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>)
set(OUTPUT_NAME "Cemu_$<LOWER_CASE:$<CONFIG>>")
endif()
set_property(TARGET CemuBin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET CemuBin PROPERTY WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>)
set(OUTPUT_NAME "Cemu_$<LOWER_CASE:$<CONFIG>>")
if (MACOS_BUNDLE)
set_property(TARGET CemuBin PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/resource/MacOSXBundleInfo.plist.in")
@@ -122,13 +134,22 @@ target_link_libraries(CemuBin PRIVATE
CemuCommon
CemuComponents
CemuConfig
CemuGui
CemuInput
CemuUtil
OpenGL::GL
SDL2::SDL2
)
if(NOT ANDROID)
target_link_libraries(CemuBin PRIVATE CemuGui)
endif()
if(ENABLE_OPENGL)
target_link_libraries(CemuBin PRIVATE OpenGL::GL)
endif()
if(ENABLE_SDL)
target_link_libraries(CemuBin PRIVATE SDL2::SDL2)
endif()
if(UNIX AND NOT APPLE)
# due to nasm output some linkers will make stack executable
# cemu does not require this so we explicity disable it
+41 -17
View File
@@ -67,24 +67,23 @@ add_library(CemuCafe
HW/Espresso/Recompiler/PPCFunctionBoundaryTracker.h
HW/Espresso/Recompiler/PPCRecompiler.cpp
HW/Espresso/Recompiler/PPCRecompiler.h
HW/Espresso/Recompiler/PPCRecompilerImlAnalyzer.cpp
HW/Espresso/Recompiler/RecompilerTests.cpp
HW/Espresso/Recompiler/IML/IML.h
HW/Espresso/Recompiler/IML/IMLSegment.cpp
HW/Espresso/Recompiler/IML/IMLSegment.h
HW/Espresso/Recompiler/IML/IMLInstruction.cpp
HW/Espresso/Recompiler/IML/IMLInstruction.h
HW/Espresso/Recompiler/IML/IMLDebug.cpp
HW/Espresso/Recompiler/IML/IMLAnalyzer.cpp
HW/Espresso/Recompiler/IML/IMLOptimizer.cpp
HW/Espresso/Recompiler/IML/IMLRegisterAllocator.cpp
HW/Espresso/Recompiler/IML/IMLRegisterAllocator.h
HW/Espresso/Recompiler/IML/IMLRegisterAllocatorRanges.cpp
HW/Espresso/Recompiler/IML/IMLRegisterAllocatorRanges.h
HW/Espresso/Recompiler/PPCRecompilerImlGen.cpp
HW/Espresso/Recompiler/PPCRecompilerImlGenFPU.cpp
HW/Espresso/Recompiler/PPCRecompilerIml.h
HW/Espresso/Recompiler/PPCRecompilerImlOptimizer.cpp
HW/Espresso/Recompiler/PPCRecompilerImlRanges.cpp
HW/Espresso/Recompiler/PPCRecompilerImlRanges.h
HW/Espresso/Recompiler/PPCRecompilerImlRegisterAllocator2.cpp
HW/Espresso/Recompiler/PPCRecompilerImlRegisterAllocator.cpp
HW/Espresso/Recompiler/PPCRecompilerIntermediate.cpp
HW/Espresso/Recompiler/PPCRecompilerX64AVX.cpp
HW/Espresso/Recompiler/PPCRecompilerX64BMI.cpp
HW/Espresso/Recompiler/PPCRecompilerX64.cpp
HW/Espresso/Recompiler/PPCRecompilerX64FPU.cpp
HW/Espresso/Recompiler/PPCRecompilerX64Gen.cpp
HW/Espresso/Recompiler/PPCRecompilerX64GenFPU.cpp
HW/Espresso/Recompiler/PPCRecompilerX64.h
HW/Espresso/Recompiler/x64Emit.hpp
HW/Latte/Common/RegisterSerializer.cpp
HW/Latte/Common/RegisterSerializer.h
HW/Latte/Common/ShaderSerializer.cpp
@@ -522,10 +521,36 @@ add_library(CemuCafe
TitleList/TitleList.h
)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
target_sources(CemuCafe PRIVATE
HW/Espresso/Recompiler/BackendX64/BackendX64AVX.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64BMI.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64FPU.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64Gen.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64GenFPU.cpp
HW/Espresso/Recompiler/BackendX64/BackendX64.h
HW/Espresso/Recompiler/BackendX64/X64Emit.hpp
HW/Espresso/Recompiler/BackendX64/x86Emitter.h
)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)")
target_sources(CemuCafe PRIVATE
HW/Espresso/Recompiler/BackendAArch64/BackendAArch64.cpp
HW/Espresso/Recompiler/BackendAArch64/BackendAArch64.h
)
endif()
if(APPLE)
target_sources(CemuCafe PRIVATE "HW/Latte/Renderer/Vulkan/CocoaSurface.mm")
endif()
if(ANDROID)
target_sources(CemuCafe PRIVATE
Filesystem/fscDeviceAndroidSAF.cpp
Filesystem/fscDeviceAndroidSAF.h
)
endif()
set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_include_directories(CemuCafe PUBLIC "../")
@@ -536,7 +561,6 @@ target_link_libraries(CemuCafe PRIVATE
CemuCommon
CemuComponents
CemuConfig
CemuGui
CemuInput
CemuResource
CemuUtil
@@ -572,8 +596,8 @@ if (ENABLE_NSYSHID_LIBUSB)
endif ()
endif ()
if (ENABLE_WXWIDGETS)
target_link_libraries(CemuCafe PRIVATE wx::base wx::core)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)")
target_link_libraries(CemuCafe PRIVATE xbyak_aarch64)
endif()
if(WIN32)
+27 -11
View File
@@ -1,5 +1,4 @@
#include "Cafe/OS/common/OSCommon.h"
#include "gui/wxgui.h"
#include "Cafe/OS/libs/gx2/GX2.h"
#include "Cafe/GameProfile/GameProfile.h"
#include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h"
@@ -64,9 +63,6 @@
// HW interfaces
#include "Cafe/HW/SI/si.h"
// dependency to be removed
#include "gui/guiWrapper.h"
#include <time.h>
#if BOOST_OS_LINUX
@@ -171,7 +167,7 @@ void LoadMainExecutable()
applicationRPX = RPLLoader_LoadFromMemory(rpxData, rpxSize, (char*)_pathToExecutable.c_str());
if (!applicationRPX)
{
wxMessageBox(_("Failed to run this title because the executable is damaged"));
cemuLog_log(LogType::Force, "Failed to run this title because the executable is damaged");
cemuLog_createLogFile(false);
cemuLog_waitForFlush();
exit(0);
@@ -356,7 +352,9 @@ uint32 LoadSharedData()
void cemu_initForGame()
{
gui_updateWindowTitles(false, true, 0.0);
auto cafeSystemCallbacks = CafeSystem::getCafeSystemCallbacks();
if (cafeSystemCallbacks)
cafeSystemCallbacks->updateWindowTitles(false, true, 0.0);
// input manager apply game profile
InputManager::instance().apply_game_profile();
// log info for launched title
@@ -426,6 +424,20 @@ void cemu_initForGame()
namespace CafeSystem
{
CafeSystemCallbacks* sCafeSystemCallbacks = nullptr;
void registerCafeSystemCallbacks(CafeSystemCallbacks* cafeSystemCallbacks)
{
sCafeSystemCallbacks = cafeSystemCallbacks;
}
void unregisterCafeSystemCallbacks()
{
sCafeSystemCallbacks = nullptr;
}
CafeSystemCallbacks* getCafeSystemCallbacks()
{
return sCafeSystemCallbacks;
}
void InitVirtualMlcStorage();
void MlcStorageMountTitle(TitleInfo& titleInfo);
void MlcStorageUnmountAllTitles();
@@ -506,7 +518,9 @@ namespace CafeSystem
{
std::string buffer;
const char* platform = NULL;
#if BOOST_OS_WINDOWS
#if __ANDROID__
platform = "Android";
#elif BOOST_OS_WINDOWS
uint32 buildNumber;
std::string windowsVersionName = GetWindowsNamedVersion(buildNumber);
buffer = fmt::format("{} (Build {})", windowsVersionName, buildNumber);
@@ -805,10 +819,10 @@ namespace CafeSystem
// check for content folder
fs::path contentPath = executablePath.parent_path().parent_path().append("content");
std::error_code ec;
if (fs::is_directory(contentPath, ec))
if (cemu::fs::is_directory(contentPath, ec))
{
// mounting content folder
bool r = FSCDeviceHostFS_Mount(std::string("/vol/content").c_str(), _pathToUtf8(contentPath), FSC_PRIORITY_BASE);
bool r = FSCDeviceHost_Mount(std::string("/vol/content").c_str(), _pathToUtf8(contentPath), FSC_PRIORITY_BASE);
if (!r)
{
cemuLog_log(LogType::Force, "Failed to mount {}", _pathToUtf8(contentPath));
@@ -817,7 +831,7 @@ namespace CafeSystem
}
}
// mount code folder to a virtual temporary path
FSCDeviceHostFS_Mount(std::string("/internal/code/").c_str(), _pathToUtf8(executablePath.parent_path()), FSC_PRIORITY_BASE);
FSCDeviceHost_Mount(std::string("/internal/code/").c_str(), _pathToUtf8(executablePath.parent_path()), FSC_PRIORITY_BASE);
std::string internalExecutablePath = "/internal/code/";
internalExecutablePath.append(_pathToUtf8(executablePath.filename()));
_pathToExecutable = internalExecutablePath;
@@ -854,7 +868,9 @@ namespace CafeSystem
PPCTimer_waitForInit();
// start system
sSystemRunning = true;
gui_notifyGameLoaded();
auto cafeSystemCallbacks = CafeSystem::getCafeSystemCallbacks();
if (cafeSystemCallbacks)
cafeSystemCallbacks->notifyGameLoaded();
std::thread t(_LaunchTitleThread);
t.detach();
}
+11
View File
@@ -23,6 +23,17 @@ namespace CafeSystem
//BAD_META_DATA, - the title list only stores titles with valid meta, so this error code is impossible
};
class CafeSystemCallbacks
{
public:
virtual void updateWindowTitles(bool isIdle, bool isLoading, double fps) = 0;
virtual void notifyGameLoaded() = 0;
};
void registerCafeSystemCallbacks(CafeSystemCallbacks* cafeSystemCallbacks);
void unregisterCafeSystemCallbacks();
CafeSystemCallbacks* getCafeSystemCallbacks();
void Initialize();
void SetImplementation(SystemImplementation* impl);
void Shutdown();
+2 -5
View File
@@ -1,6 +1,4 @@
#include <wx/msgdlg.h>
#include <mutex>
#include <gui/helpers/wxHelpers.h>
#include "config/ActiveSettings.h"
#include "util/crypto/aes128.h"
@@ -75,7 +73,7 @@ void KeyCache_Prepare()
}
else
{
wxMessageBox(_("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to its own directory, the disk is full or if anti-virus software is blocking Cemu."), _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
cemuLog_log(LogType::Force, "Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to it's own directory, the disk is full or if anti-virus software is blocking Cemu.");
}
mtxKeyCache.unlock();
return;
@@ -108,8 +106,7 @@ void KeyCache_Prepare()
continue;
if( strishex(line) == false )
{
auto errorMsg = formatWxString(_("Error in keys.txt at line {}"), lineNumber);
wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
cemuLog_log(LogType::Force, "rror in keys.txt in line {}", lineNumber);
continue;
}
if(line.size() == 32 )
+15
View File
@@ -213,3 +213,18 @@ bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTarg
// redirect device
void fscDeviceRedirect_map();
void fscDeviceRedirect_add(std::string_view virtualSourcePath, size_t fileSize, const fs::path& targetFilePath, sint32 priority);
#if __ANDROID__
#include "Common/unix/FilesystemAndroid.h"
bool FSCDeviceAndroidSAF_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority);
#endif // __ANDROID__
inline bool FSCDeviceHost_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority)
{
#if __ANDROID__
if (FilesystemAndroid::isContentUri(std::string(hostTargetPath)))
return FSCDeviceAndroidSAF_Mount(mountPath, hostTargetPath, priority);
else
#endif // __ANDROID__
return FSCDeviceHostFS_Mount(mountPath, hostTargetPath, priority);
}
+235
View File
@@ -0,0 +1,235 @@
#include "Cafe/Filesystem/fscDeviceAndroidSAF.h"
#include <memory>
#include <stdexcept>
#include "Cafe/Filesystem/fsc.h"
#include "Common/FileStream.h"
#include "Common/unix/FilesystemAndroid.h"
FSCVirtualFile_AndroidSAF::~FSCVirtualFile_AndroidSAF()
{
if (m_type == FSC_TYPE_FILE)
delete m_fs;
}
sint32 FSCVirtualFile_AndroidSAF::fscGetType()
{
return m_type;
}
uint32 FSCVirtualFile_AndroidSAF::fscDeviceAndroidSAFFSFile_getFileSize()
{
if (m_type == FSC_TYPE_FILE)
{
if (m_fileSize > 0xFFFFFFFFULL)
cemu_assert_suspicious(); // files larger than 4GB are not supported by Wii U filesystem
return (uint32)m_fileSize;
}
return 0;
}
uint64 FSCVirtualFile_AndroidSAF::fscQueryValueU64(uint32 id)
{
if (m_type == FSC_TYPE_FILE)
{
if (id == FSC_QUERY_SIZE)
return fscDeviceAndroidSAFFSFile_getFileSize();
else if (id == FSC_QUERY_WRITEABLE)
return m_isWritable;
else
cemu_assert_unimplemented();
}
else if (m_type == FSC_TYPE_DIRECTORY)
{
if (id == FSC_QUERY_SIZE)
return fscDeviceAndroidSAFFSFile_getFileSize();
else
cemu_assert_unimplemented();
}
cemu_assert_unimplemented();
return 0;
}
uint32 FSCVirtualFile_AndroidSAF::fscWriteData(void* buffer, uint32 size)
{
throw std::logic_error("write not supported with SAF");
return 0;
}
uint32 FSCVirtualFile_AndroidSAF::fscReadData(void* buffer, uint32 size)
{
if (m_type != FSC_TYPE_FILE)
return 0;
if (size >= (2UL * 1024UL * 1024UL * 1024UL))
{
cemu_assert_suspicious();
return 0;
}
uint32 bytesLeft = (uint32)(m_fileSize - m_seek);
bytesLeft = std::min(bytesLeft, 0x7FFFFFFFu);
sint32 bytesToRead = std::min(bytesLeft, size);
uint32 bytesRead = m_fs->readData(buffer, bytesToRead);
m_seek += bytesRead;
return bytesRead;
}
void FSCVirtualFile_AndroidSAF::fscSetSeek(uint64 seek)
{
if (m_type != FSC_TYPE_FILE)
return;
this->m_seek = seek;
cemu_assert_debug(seek <= m_fileSize);
m_fs->SetPosition(seek);
}
uint64 FSCVirtualFile_AndroidSAF::fscGetSeek()
{
if (m_type != FSC_TYPE_FILE)
return 0;
return m_seek;
}
void FSCVirtualFile_AndroidSAF::fscSetFileLength(uint64 endOffset)
{
if (m_type != FSC_TYPE_FILE)
return;
m_fs->SetPosition(endOffset);
bool r = m_fs->SetEndOfFile();
m_seek = std::min(m_seek, endOffset);
m_fileSize = m_seek;
m_fs->SetPosition(m_seek);
if (!r)
cemuLog_log(LogType::Force, "fscSetFileLength: Failed to set size to 0x{:x}", endOffset);
}
bool FSCVirtualFile_AndroidSAF::fscDirNext(FSCDirEntry* dirEntry)
{
if (m_type != FSC_TYPE_DIRECTORY)
return false;
if (!m_files)
{
// init iterator on first iteration attempt
m_files = std::make_unique<std::vector<fs::path>>(FilesystemAndroid::listFiles(*m_path));
m_filesIterator = m_files->begin();
if (!m_files)
{
cemuLog_log(LogType::Force, "Failed to iterate directory: {}", _pathToUtf8(*m_path));
return false;
}
}
if (m_filesIterator == m_files->end())
return false;
const fs::path& file = *m_filesIterator;
std::string fileName = file.filename().generic_string();
if (fileName.size() >= sizeof(dirEntry->path) - 1)
fileName.resize(sizeof(dirEntry->path) - 1);
strncpy(dirEntry->path, fileName.data(), sizeof(dirEntry->path));
if (FilesystemAndroid::isDirectory(file))
{
dirEntry->isDirectory = true;
dirEntry->isFile = false;
dirEntry->fileSize = 0;
}
else
{
dirEntry->isDirectory = false;
dirEntry->isFile = true;
dirEntry->fileSize = 0;
auto fs = FileStream::openFile2(file);
if (fs)
{
dirEntry->fileSize = fs->GetSize();
delete fs;
}
}
m_filesIterator++;
return true;
}
FSCVirtualFile* FSCVirtualFile_AndroidSAF::OpenFile(const fs::path& path, FSC_ACCESS_FLAG accessFlags, sint32& fscStatus)
{
if (!HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE) && !HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR))
cemu_assert_debug(false); // not allowed. At least one of both flags must be set
if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::WRITE_PERMISSION) ||
HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::FILE_ALLOW_CREATE) ||
HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::FILE_ALWAYS_CREATE))
throw std::logic_error("writing and creating a file is not supported with SAF");
// attempt to open as file
if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE))
{
FileStream* fs = FileStream::openFile2(path);
if (fs)
{
FSCVirtualFile_AndroidSAF* vf = new FSCVirtualFile_AndroidSAF(FSC_TYPE_FILE);
vf->m_fs = fs;
vf->m_isWritable = false;
vf->m_fileSize = fs->GetSize();
fscStatus = FSC_STATUS_OK;
return vf;
}
}
// attempt to open as directory
if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR))
{
bool isExistingDir = FilesystemAndroid::exists(path);
if (isExistingDir)
{
FSCVirtualFile_AndroidSAF* vf = new FSCVirtualFile_AndroidSAF(FSC_TYPE_DIRECTORY);
vf->m_path.reset(new std::filesystem::path(path));
fscStatus = FSC_STATUS_OK;
return vf;
}
}
fscStatus = FSC_STATUS_FILE_NOT_FOUND;
return nullptr;
}
/* Device implementation */
class fscDeviceAndroidSAFFSC : public fscDeviceC
{
public:
FSCVirtualFile* fscDeviceOpenByPath(std::string_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override
{
*fscStatus = FSC_STATUS_OK;
FSCVirtualFile* vf = FSCVirtualFile_AndroidSAF::OpenFile(_utf8ToPath(path), accessFlags, *fscStatus);
cemu_assert_debug((bool)vf == (*fscStatus == FSC_STATUS_OK));
return vf;
}
bool fscDeviceCreateDir(std::string_view path, void* ctx, sint32* fscStatus) override
{
throw std::logic_error("creating a directory is not supported with SAF");
return false;
}
bool fscDeviceRemoveFileOrDir(std::string_view path, void* ctx, sint32* fscStatus) override
{
throw std::logic_error("removing a file or dir is not supported with SAF");
return false;
}
bool fscDeviceRename(std::string_view srcPath, std::string_view dstPath, void* ctx, sint32* fscStatus) override
{
throw std::logic_error("renaming not supported with SAF");
return false;
}
// singleton
public:
static fscDeviceAndroidSAFFSC& instance()
{
static fscDeviceAndroidSAFFSC _instance;
return _instance;
}
};
bool FSCDeviceAndroidSAF_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority)
{
return fsc_mount(mountPath, hostTargetPath, &fscDeviceAndroidSAFFSC::instance(), nullptr, priority) == FSC_STATUS_OK;
}
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include "Cafe/Filesystem/fsc.h"
class FSCVirtualFile_AndroidSAF : public FSCVirtualFile
{
public:
static FSCVirtualFile* OpenFile(const fs::path& path, FSC_ACCESS_FLAG accessFlags, sint32& fscStatus);
~FSCVirtualFile_AndroidSAF() override;
sint32 fscGetType() override;
uint32 fscDeviceAndroidSAFFSFile_getFileSize();
uint64 fscQueryValueU64(uint32 id) override;
uint32 fscWriteData(void* buffer, uint32 size) override;
uint32 fscReadData(void* buffer, uint32 size) override;
void fscSetSeek(uint64 seek) override;
uint64 fscGetSeek() override;
void fscSetFileLength(uint64 endOffset) override;
bool fscDirNext(FSCDirEntry* dirEntry) override;
private:
FSCVirtualFile_AndroidSAF(uint32 type) : m_type(type){};
uint32 m_type; // FSC_TYPE_*
class FileStream* m_fs{};
// file
uint64 m_seek{0};
uint64 m_fileSize{0};
bool m_isWritable{false};
// directory
std::unique_ptr<fs::path> m_path{};
std::unique_ptr<std::vector<fs::path>> m_files{};
std::vector<fs::path>::iterator m_filesIterator;
};
+7 -13
View File
@@ -5,9 +5,6 @@
#include "Cafe/OS/RPL/rpl_structs.h"
#include "boost/algorithm/string.hpp"
#include "gui/wxgui.h" // for wxMessageBox
#include "gui/helpers/wxHelpers.h"
// error handler
void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg)
{
@@ -40,13 +37,13 @@ void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumb
void PatchErrorHandler::showStageErrorMessageBox()
{
wxString errorMsg;
std::string errorMsg;
if (m_gp)
{
if (m_stage == STAGE::PARSER)
errorMsg.assign(formatWxString(_("Failed to load patches for graphic pack \'{}\'"), m_gp->GetName()));
errorMsg = fmt::format("Failed to load patches for graphic pack \'{}\'", m_gp->GetName());
else
errorMsg.assign(formatWxString(_("Failed to apply patches for graphic pack \'{}\'"), m_gp->GetName()));
errorMsg = fmt::format("Failed to apply patches for graphic pack \'{}\'", m_gp->GetName());
}
else
{
@@ -54,17 +51,14 @@ void PatchErrorHandler::showStageErrorMessageBox()
}
if (cemuLog_isLoggingEnabled(LogType::Patches))
{
errorMsg.append("\n \n")
.append(_("Details:"))
.append("\n");
errorMsg += "\n\nDetails:\n";
for (auto& itr : errorMessages)
{
errorMsg.append(itr);
errorMsg.append("\n");
errorMsg += itr;
errorMsg += "\n";
}
}
wxMessageBox(errorMsg, _("Graphic pack error"));
cemuLog_log(LogType::Force, "Graphic pack error: {}", errorMsg);
}
// loads Cemu-style patches (patch_<anything>.asm)

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