diff --git a/Common/Crypto/md5.cpp b/Common/Crypto/md5.cpp index 7fff7713da..22a8395656 100644 --- a/Common/Crypto/md5.cpp +++ b/Common/Crypto/md5.cpp @@ -35,7 +35,6 @@ #include "md5.h" #include -#include /* * 32-bit integer manipulation macros (little endian) @@ -291,38 +290,6 @@ void md5( unsigned char *input, int ilen, unsigned char output[16] ) memset( &ctx, 0, sizeof( md5_context ) ); } -/* - * output = MD5( file contents ) - */ -int md5_file( char *path, unsigned char output[16] ) -{ - FILE *f; - size_t n; - md5_context ctx; - unsigned char buf[1024]; - - if( ( f = fopen( path, "rb" ) ) == NULL ) - return( 1 ); - - md5_starts( &ctx ); - - while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) - md5_update( &ctx, buf, (int) n ); - - md5_finish( &ctx, output ); - - memset( &ctx, 0, sizeof( md5_context ) ); - - if( ferror( f ) != 0 ) - { - fclose( f ); - return( 2 ); - } - - fclose( f ); - return( 0 ); -} - /* * MD5 HMAC context setup */ diff --git a/Common/Crypto/sha1.cpp b/Common/Crypto/sha1.cpp index 17ad930986..05deccc97f 100644 --- a/Common/Crypto/sha1.cpp +++ b/Common/Crypto/sha1.cpp @@ -325,38 +325,6 @@ void sha1( unsigned char *input, int ilen, unsigned char output[20] ) memset( &ctx, 0, sizeof( sha1_context ) ); } -/* - * output = SHA-1( file contents ) - */ -int sha1_file( char *path, unsigned char output[20] ) -{ - FILE *f; - size_t n; - sha1_context ctx; - unsigned char buf[1024]; - - if( ( f = fopen( path, "rb" ) ) == NULL ) - return( 1 ); - - sha1_starts( &ctx ); - - while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 ) - sha1_update( &ctx, buf, (int) n ); - - sha1_finish( &ctx, output ); - - memset( &ctx, 0, sizeof( sha1_context ) ); - - if( ferror( f ) != 0 ) - { - fclose( f ); - return( 2 ); - } - - fclose( f ); - return( 0 ); -} - /* * SHA-1 HMAC context setup */ diff --git a/Common/OSVersion.cpp b/Common/OSVersion.cpp index 646c0b2579..ef60b85ef5 100644 --- a/Common/OSVersion.cpp +++ b/Common/OSVersion.cpp @@ -35,6 +35,25 @@ bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, u #endif } +bool IsVistaOrHigher() { +#if PPSSPP_PLATFORM(UWP) + return true; +#else + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op = VER_GREATER_EQUAL; + ZeroMemory(&osvi, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(osvi); + osvi.dwMajorVersion = 6; // Vista is 6.0 + osvi.dwMinorVersion = 0; + + VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); + VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); + + return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; +#endif +} + std::string GetWindowsVersion() { const bool IsWindowsXPSP2 = DoesVersionMatchWindows(5, 1, 2, 0, false); const bool IsWindowsXPSP3 = DoesVersionMatchWindows(5, 1, 3, 0, false); diff --git a/Common/OSVersion.h b/Common/OSVersion.h index 7e8283fcdb..2b17d304eb 100644 --- a/Common/OSVersion.h +++ b/Common/OSVersion.h @@ -4,6 +4,7 @@ #ifdef _MSC_VER +bool IsVistaOrHigher(); bool DoesVersionMatchWindows(uint32_t major, uint32_t minor, uint32_t spMajor, uint32_t spMinor, bool acceptGreater); std::string GetWindowsVersion(); std::string GetWindowsSystemArchitecture(); diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 07060d80e6..324c8b73eb 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "base/basictypes.h" diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 838c884776..3cc97c5e32 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -19,7 +19,7 @@ #include #include "profiler/profiler.h" - +#include "gfx/gl_common.h" #include "gfx_es2/glsl_program.h" #include "thin3d/thin3d.h" diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 958189a978..d7081d6a8c 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -21,7 +21,6 @@ #include #include -#include "gfx/gl_common.h" #include "ext/native/thin3d/thin3d.h" // Keeps track of allocated FBOs. // Also provides facilities for drawing and later converting raw @@ -40,7 +39,7 @@ class ShaderManagerGLES; // Simple struct for asynchronous PBO readbacks struct AsyncPBO { - GLuint handle; + uint32_t handle; u32 maxSize; u32 fb_address; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 9d8d06a4f3..ed04784b28 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include #include "base/display.h" @@ -69,9 +71,12 @@ #include "UI/InstallZipScreen.h" #include "UI/ProfilerDraw.h" -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) #include "Windows/MainWindow.h" #endif +#if !PPSSPP_PLATFORM(UWP) +#include "gfx/gl_common.h" +#endif #ifndef MOBILE_DEVICE AVIDump avi; @@ -150,15 +155,16 @@ void EmuScreen::bootGame(const std::string &filename) { coreParam.cpuCore = (CPUCore)g_Config.iCpuCore; coreParam.gpuCore = GPUCORE_GLES; switch (GetGPUBackend()) { + case GPUBackend::DIRECT3D11: + coreParam.gpuCore = GPUCORE_DIRECTX11; + break; +#if !PPSSPP_PLATFORM(UWP) case GPUBackend::OPENGL: coreParam.gpuCore = GPUCORE_GLES; break; case GPUBackend::DIRECT3D9: coreParam.gpuCore = GPUCORE_DIRECTX9; break; - case GPUBackend::DIRECT3D11: - coreParam.gpuCore = GPUCORE_DIRECTX11; - break; case GPUBackend::VULKAN: coreParam.gpuCore = GPUCORE_VULKAN; if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) { @@ -172,6 +178,7 @@ void EmuScreen::bootGame(const std::string &filename) { #endif } break; +#endif } if (g_Config.bSoftwareRendering) { coreParam.gpuCore = GPUCORE_SOFTWARE; @@ -228,6 +235,7 @@ void EmuScreen::bootComplete() { #endif memset(virtKeys, 0, sizeof(virtKeys)); +#if !PPSSPP_PLATFORM(UWP) if (GetGPUBackend() == GPUBackend::OPENGL) { const char *renderer = (const char*)glGetString(GL_RENDERER); if (strstr(renderer, "Chainfire3D") != 0) { @@ -240,6 +248,7 @@ void EmuScreen::bootComplete() { osm.Show("WARNING: GfxDebugOutput is enabled via ppsspp.ini. Things may be slow.", 10.0f, 0xFF30a0FF, -1, true); } } +#endif if (Core_GetPowerSaving()) { I18NCategory *sy = GetI18NCategory("System"); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 4d0bccbd2d..74d8d5fcbb 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -16,6 +16,8 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include + +#include "ppsspp_config.h" #include "base/colorutil.h" #include "base/timeutil.h" #include "gfx_es2/draw_buffer.h" @@ -253,7 +255,7 @@ void GameScreen::update(InputState &input) { } UI::EventReturn GameScreen::OnShowInFolder(UI::EventParams &e) { -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) std::string str = std::string("explorer.exe /select,\"") + ReplaceAll(gamePath_, "/", "\\") + "\""; _wsystem(ConvertUTF8ToWString(str).c_str()); #endif diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3d462e4166..e8a0327711 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "ppsspp_config.h" + #include "base/display.h" // Only to check screen aspect ratio with pixel_yres/pixel_xres #include "base/colorutil.h" @@ -59,8 +61,10 @@ #include #include "util/text/utf8.h" #include "Windows/W32Util/ShellUtil.h" -#include "Windows/W32Util/Misc.h" +#endif +#if !PPSSPP_PLATFORM(UWP) +#include "gfx/gl_common.h" #endif #ifdef IOS @@ -80,6 +84,10 @@ bool GameSettingsScreen::UseVerticalLayout() const { // This needs before run CheckGPUFeatures() // TODO: Remove this if fix the issue bool CheckSupportInstancedTessellation() { +#if PPSSPP_PLATFORM(UWP) + return true; +#else + // TODO: Make work with non-GL backends int maxVertexTextureImageUnits; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxVertexTextureImageUnits); bool vertexTexture = maxVertexTextureImageUnits >= 3; // At least 3 for hardware tessellation @@ -88,6 +96,7 @@ bool CheckSupportInstancedTessellation() { bool textureFloat = gl_extensions.ARB_texture_float || gl_extensions.OES_texture_float || gl_extensions.OES_texture_half_float; return instanceRendering && vertexTexture && textureFloat; +#endif } void GameSettingsScreen::CreateViews() { @@ -647,7 +656,7 @@ void GameSettingsScreen::CreateViews() { #if defined(USING_WIN_UI) systemSettings->Add(new CheckBox(&g_Config.bBypassOSKWithKeyboard, sy->T("Enable Windows native keyboard", "Enable Windows native keyboard"))); #endif -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) SavePathInMyDocumentChoice = systemSettings->Add(new CheckBox(&installed_, sy->T("Save path in My Documents", "Save path in My Documents"))); SavePathInMyDocumentChoice->OnClick.Handle(this, &GameSettingsScreen::OnSavePathMydoc); SavePathInOtherChoice = systemSettings->Add(new CheckBox(&otherinstalled_, sy->T("Save path in installed.txt", "Save path in installed.txt"))); @@ -809,7 +818,7 @@ UI::EventReturn GameSettingsScreen::OnJitAffectingSetting(UI::EventParams &e) { return UI::EVENT_DONE; } -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) { const std::string PPSSPPpath = File::GetExeDirectory(); @@ -987,7 +996,7 @@ void GlobalSettingsScreen::CreateViews() { }*/ void GameSettingsScreen::CallbackRenderingBackend(bool yes) { -#if defined(_WIN32) +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) // If the user ends up deciding not to restart, set the config back to the current backend // so it doesn't get switched by accident. if (yes) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 35c4f9d232..f69bea1a87 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -23,6 +23,7 @@ // // Windows has its own code that bypasses the framework entirely. +#include "ppsspp_config.h" // Background worker threads should be spawned in NativeInit and joined // in NativeShutdown. @@ -268,7 +269,7 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo #endif } -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) bool CheckFontIsUsable(const wchar_t *fontFace) { wchar_t actualFontFace[1024] = { 0 }; @@ -481,7 +482,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch // Note to translators: do not translate this/add this to PPSSPP-lang's files. // It's intended to be custom for every user. // Only add it to your own personal copies of PPSSPP. -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) // TODO: Could allow a setting to specify a font file to load? // TODO: Make this a constant if we can sanely load the font on other systems? AddFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL); @@ -535,7 +536,7 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { // memset(&ui_theme, 0, sizeof(ui_theme)); // New style theme -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) ui_theme.uiFont = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 22); ui_theme.uiFontSmall = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 15); ui_theme.uiFontSmaller = UI::FontStyle(UBUNTU24, g_Config.sFont.c_str(), 12); @@ -582,7 +583,7 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { if (!uiTexture) { PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory."); ELOG("Failed to load ui_atlas.zim"); -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UINT ExitCode = 0; ExitProcess(ExitCode); #endif @@ -1046,7 +1047,7 @@ void NativeShutdown() { exit(0); #endif -#ifdef _WIN32 +#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) RemoveFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL); #endif } diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 33c57b7df9..60b000f32e 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -4,9 +4,11 @@ #include #include "thread/threadutil.h" +#include "Common/OSVersion.h" #include "Core/Reporting.h" #include "Core/Util/AudioFormat.h" #include "Windows/W32Util/Misc.h" +#include "Common/OSVersion.h" #include "dsoundstream.h" diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index 543ce0229f..12c5c1244a 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -9,6 +9,7 @@ #include "Core/Config.h" #include "Core/Reporting.h" +#include "Common/OSVersion.h" #include "Windows/GPU/D3D9Context.h" #include "Windows/W32Util/Misc.h" #include "thin3d/thin3d.h" diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index ae4905a1c7..f7db70d477 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "ppsspp_config.h" #include "CommonWindows.h" #include @@ -8,19 +9,12 @@ #include "Misc.h" #include "util/text/utf8.h" -bool IsVistaOrHigher() { - OSVERSIONINFOEX osvi; - DWORDLONG dwlConditionMask = 0; - int op = VER_GREATER_EQUAL; - ZeroMemory(&osvi, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(osvi); - osvi.dwMajorVersion = 6; // Vista is 6.0 - osvi.dwMinorVersion = 0; - - VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); - VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); - - return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; +bool KeyDownAsync(int vkey) { +#if PPSSPP_PLATFORM(UWP) + return 0; +#else + return (GetAsyncKeyState(vkey) & 0x8000) != 0; +#endif } namespace W32Util diff --git a/Windows/W32Util/Misc.h b/Windows/W32Util/Misc.h index 2d0030ba0b..f73e72b548 100644 --- a/Windows/W32Util/Misc.h +++ b/Windows/W32Util/Misc.h @@ -2,8 +2,6 @@ #include "Common/CommonWindows.h" -bool IsVistaOrHigher(); - namespace W32Util { void CenterWindow(HWND hwnd); @@ -36,10 +34,7 @@ struct GenericListViewDef // the most significant bit states whether the key is currently down. // simply checking if it's != 0 is not enough, as bit0 is set if // the key was pressed between the last call to GetAsyncKeyState -inline bool KeyDownAsync(int vkey) -{ - return (GetAsyncKeyState(vkey) & 0x8000) != 0; -} +bool KeyDownAsync(int vkey); class GenericListControl {