diff --git a/.github/workflows/uwp.yml b/.github/workflows/uwp.yml new file mode 100644 index 000000000..be76356ff --- /dev/null +++ b/.github/workflows/uwp.yml @@ -0,0 +1,48 @@ +name: Windows UWP CI + +on: [push, pull_request] + +jobs: + build: + runs-on: windows-latest + + env: + VCPKG_ROOT: ${{ github.workspace }}/vcpkg + + steps: + - uses: actions/cache@v2 + id: cache + with: + path: $HOME/ccache + key: ccache-${{ github.sha }} + restore-keys: ccache- + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: true + + - name: bootstrap vcpkg + run: | + git clone https://github.com/microsoft/vcpkg + vcpkg/bootstrap-vcpkg.bat + + - name: CMake + run: | + cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DCMAKE_SYSTEM_PROCESSOR=AMD64 -DCMAKE_CROSSCOMPILING=OFF -DUSE_VULKAN=OFF -DUSE_GLES=ON -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake + cmake --build build --config Release --parallel 2 + shell: cmd + + - name: Package app + run: | + mkdir build\artifact + cd build\AppPackages\flycast\flycast_1.0.0.0_x64_Test + mkdir tmp + makeappx.exe unpack /v /p .\flycast_1.0.0.0_x64.msix /d tmp + copy ..\..\..\Release\*.dll tmp + makeappx pack /d tmp /p ..\..\..\artifact\flycast.appx + + - uses: actions/upload-artifact@v2 + with: + name: flycast-uwp + path: build/artifact diff --git a/CMakeLists.txt b/CMakeLists.txt index a80221778..d85a7ec4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1359,6 +1359,7 @@ if(NOT LIBRETRO) shell/uwp/flycast150.png shell/uwp/flycast50.png shell/uwp/flycast44.png + shell/uwp/splash.png shell/uwp/flycast44.targetsize-48_altform-unplated.png shell/uwp/flycast44.targetsize-48_altform-lightunplated.png core/deps/SDL/src/main/winrt/SDL2-WinRTResource_BlankCursor.cur diff --git a/core/deps/ggpo/lib/ggpo/ggpo_types.h b/core/deps/ggpo/lib/ggpo/ggpo_types.h index 530883554..54abecdf5 100644 --- a/core/deps/ggpo/lib/ggpo/ggpo_types.h +++ b/core/deps/ggpo/lib/ggpo/ggpo_types.h @@ -25,7 +25,7 @@ #endif #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -#define TARGET_UWP 1 +#define TARGET_UWP #endif /* diff --git a/core/deps/miniupnpc/CMakeLists.txt b/core/deps/miniupnpc/CMakeLists.txt index 12747b33a..4c42d3db9 100644 --- a/core/deps/miniupnpc/CMakeLists.txt +++ b/core/deps/miniupnpc/CMakeLists.txt @@ -35,7 +35,11 @@ if (NOT WIN32) target_compile_definitions(miniupnpc-private INTERFACE _XOPEN_SOURCE=600) endif () else () - target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends + if (WINDOWS_STORE) + target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0A00 _WINSOCK_DEPRECATED_NO_WARNINGS) + else () + target_compile_definitions(miniupnpc-private INTERFACE _WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends + endif () endif () if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") diff --git a/core/deps/patches/libchdr.patch b/core/deps/patches/libchdr.patch index 100f0732f..4aa215c78 100644 --- a/core/deps/patches/libchdr.patch +++ b/core/deps/patches/libchdr.patch @@ -1,10 +1,10 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9842447..f1b3c43 100644 +index 06bc77c..9ac12fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,8 @@ option(INSTALL_STATIC_LIBS "Install static libraries" OFF) option(WITH_SYSTEM_ZLIB "Use system provided zlib library" OFF) - + if(CMAKE_C_COMPILER_ID MATCHES "GNU") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC -O3 -flto") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) @@ -13,3 +13,37 @@ index 9842447..f1b3c43 100644 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) +@@ -34,7 +34,11 @@ add_subdirectory(deps/lzma-19.00 EXCLUDE_FROM_ALL) + + # zlib + if (WITH_SYSTEM_ZLIB) +- pkg_check_modules(ZLIB REQUIRED zlib) ++ if (WINDOWS_STORE) ++ find_package(ZLIB REQUIRED) ++ else() ++ pkg_check_modules(ZLIB REQUIRED zlib) ++ endif() + list(APPEND PLATFORM_INCLUDES ${ZLIB_INCLUDE_DIRS}) + list(APPEND PLATFORM_LIBS ${ZLIB_LIBRARIES}) + else() +@@ -68,6 +72,10 @@ if (INSTALL_STATIC_LIBS) + ) + endif() + ++if(MSVC) ++ target_compile_definitions(chdr-static PRIVATE _CRT_SECURE_NO_WARNINGS) ++endif() ++ + if (BUILD_SHARED_LIBS) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +@@ -79,7 +87,7 @@ if (BUILD_SHARED_LIBS) + + if(MSVC) + target_compile_definitions(chdr PUBLIC "CHD_DLL") +- target_compile_definitions(chdr PRIVATE "CHD_DLL_EXPORTS") ++ target_compile_definitions(chdr PRIVATE "CHD_DLL_EXPORTS" _CRT_SECURE_NO_WARNINGS) + elseif(APPLE) + target_link_options(chdr PRIVATE -Wl,-dead_strip -Wl,-exported_symbol,_chd_*) + else() + diff --git a/core/deps/picotcp/include/arch/pico_msvc.h b/core/deps/picotcp/include/arch/pico_msvc.h index 226cd7c4d..fddd4b96c 100644 --- a/core/deps/picotcp/include/arch/pico_msvc.h +++ b/core/deps/picotcp/include/arch/pico_msvc.h @@ -1,9 +1,11 @@ #ifndef PICO_SUPPORT_MSVC #define PICO_SUPPORT_MSVC +#pragma pack(push, 8) #include #include #include +#pragma pack(pop) #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 diff --git a/core/network/net_platform.h b/core/network/net_platform.h index e50222e06..9b2b8f67f 100644 --- a/core/network/net_platform.h +++ b/core/network/net_platform.h @@ -62,6 +62,8 @@ typedef SOCKET sock_t; #define L_EAGAIN WSAEWOULDBLOCK #define get_last_error() (WSAGetLastError()) #define perror(s) do { INFO_LOG(MODEM, "%s: Winsock error: %d\n", (s) != NULL ? (s) : "", WSAGetLastError()); } while (false) +#define SHUT_WR SD_SEND +#define SHUT_RD SD_RECEIVE #endif bool is_local_address(u32 addr); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index 05682f622..7fa9350da 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -401,7 +401,17 @@ void gui_open_settings() { gui_state = GuiState::Commands; HideOSD(); - emu.stop(); +#ifdef TARGET_UWP + if (config::ThreadedRendering) + { + static std::future f; + f = std::async(std::launch::async, [] { + emu.stop(); + }); + } + else +#endif + emu.stop(); } else chat.toggle(); @@ -413,7 +423,6 @@ void gui_open_settings() else if (gui_state == GuiState::Loading) { gameLoader.cancel(); - gui_state = GuiState::Main; } else if (gui_state == GuiState::Commands) { @@ -2258,12 +2267,25 @@ static void gui_network_start() if (ImGui::Button("Cancel", ImVec2(100.f * scaling, 0.f))) { NetworkHandshake::instance->stop(); +#ifdef TARGET_UWP + static std::future f; + f = std::async(std::launch::async, [] { + try { + networkStatus.get(); + } + catch (const FlycastException& e) { + } + emu.unloadGame(); + gui_state = GuiState::Main; + }); +#else try { networkStatus.get(); } catch (const FlycastException& e) { } gui_state = GuiState::Main; emu.unloadGame(); +#endif } ImGui::PopStyleVar(); @@ -2311,10 +2333,7 @@ static void gui_display_loadscreen() ImGui::SetCursorPosX((currentwidth - 100.f * scaling) / 2.f + ImGui::GetStyle().WindowPadding.x); ImGui::SetCursorPosY(126.f * scaling); if (ImGui::Button("Cancel", ImVec2(100.f * scaling, 0.f))) - { gameLoader.cancel(); - gui_state = GuiState::Main; - } } } catch (const FlycastException& ex) { ERROR_LOG(BOOT, "%s", ex.what()); diff --git a/core/rend/gui_util.h b/core/rend/gui_util.h index 32dcc7fb1..0135badfe 100644 --- a/core/rend/gui_util.h +++ b/core/rend/gui_util.h @@ -80,12 +80,32 @@ public: void cancel() { progress.cancelled = true; +#ifdef TARGET_UWP + if (future.valid()) + { + if (progress.cancelled) + return; + static std::future f; + f = std::async(std::launch::async, [this] { + try { + future.get(); + } + catch (const FlycastException& e) { + } + emu.unloadGame(); + gui_state = GuiState::Main; + }); + return + } +#else if (future.valid()) try { future.get(); } catch (const FlycastException& e) { } +#endif emu.unloadGame(); + gui_state = GuiState::Main; } bool ready() diff --git a/shell/uwp/package.appxManifest b/shell/uwp/package.appxManifest index 3da60db04..c4cc060dd 100644 --- a/shell/uwp/package.appxManifest +++ b/shell/uwp/package.appxManifest @@ -1,10 +1,10 @@ - + - + Flycast @@ -25,11 +25,12 @@ BackgroundColor="transparent" Square150x150Logo="flycast150.png" Square44x44Logo="flycast44.png"> - + + diff --git a/shell/uwp/splash.png b/shell/uwp/splash.png new file mode 100644 index 000000000..69bc5a340 Binary files /dev/null and b/shell/uwp/splash.png differ diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..7966eae7f --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "name": "flycast", + "version-string": "1.2.0-dev", + "dependencies": [ + "angle", + "sdl2", + "zlib" + ] +} \ No newline at end of file