Browse Source

[WIP] Refactor 3 (cont): Fix WP(ARM) compilation bug & move the location of SDL2 folder

louyihua 8 years ago
parent
commit
85c5018aac

+ 3 - 3
.gitignore

@@ -216,6 +216,6 @@ GeneratedArtifacts/
 _Pvt_Extensions/
 ModelManifest.xml
 
-# Windows Phone associated file
-winrt/SDL2/*
-!winphone/SDL2/README.txt
+# SDL2 associated file
+SDL2/*
+!SDL2/README.txt

+ 12 - 0
SDL2/README.txt

@@ -0,0 +1,12 @@
+Download SDL 2.0 source code from http://libsdl.org/ and extract here.
+
+Special notes for Windows RT versions:
+To make the screen shot function work properly, you need to modify the project files within the 
+VisualC-WinRT directory (including SDL-WinPhone81.vcxproj, SDL-WinRT81.vcxproj & SDL-UWP.vcxproj)
+by manually place the library file 'sdlpal.common.lib' before the 'msvcrt[d].lib'. This work can 
+be done by adding the following LINK options:
+
+"sdlpal.common.lib" "vccorlib[d].lib" "msvcrt[d].lib" /NODEFAULTLIB:"vccorlib[d].lib" /NODEFAULTLIB:"msvcrt[d].lib"
+
+Note the the optional 'd' postfix is used only in debug builds. This work can also be done through
+the Visual Studio's GUI.

+ 1 - 1
common.h

@@ -227,7 +227,7 @@ extern "C"
 # define PAL_CREDIT           "Rikku2000"
 # define PAL_PORTYEAR         "2013"
 
-#elif defined (__WINPHONE__) || defined(__WINRT__)
+#elif defined(__WINRT__)
 
 #define PAL_PREFIX            UTIL_BasePath()
 #define PAL_SAVE_PREFIX       UTIL_SavePath()

+ 3 - 11
input.c

@@ -38,10 +38,6 @@ BOOL                     g_fUseJoystick = TRUE;
 #define MAX_DEADZONE 16384
 #endif
 
-#if defined(__WINPHONE__)
-static unsigned int g_uiLastBackKeyTime = 0;
-#endif
-
 static VOID
 PAL_KeyboardEventFilter(
    const SDL_Event       *lpEvent
@@ -207,15 +203,11 @@ PAL_KeyboardEventFilter(
          g_InputState.dwKeyPress |= kKeyThrowItem;
          break;
 
-#if defined(__WINPHONE__)
+#if defined(__WINRT__)
       case SDLK_AC_BACK:
-         if (!gpGlobals->fInMainGame || !SDL_TICKS_PASSED(SDL_GetTicks(), g_uiLastBackKeyTime + 800))
-         {
-            // If game not started, or user press the BACK key quickly twice, force to exit
+         // If game not started, exit directly
+         if (!gpGlobals->fInMainGame)
             PAL_Shutdown();
-            exit(0);
-		 }
-         g_uiLastBackKeyTime = SDL_GetTicks();
 #endif
       case SDLK_q:
          g_InputState.dwKeyPress |= kKeyFlee;

+ 1 - 22
main.c

@@ -31,13 +31,6 @@
 
 # include <fat.h>
 
-#elif defined(__WINPHONE__)
-
-# include <setjmp.h>
-
-static jmp_buf g_exit_jmp_env;
-# define LONGJMP_EXIT_CODE          0xff
-
 #endif
 
 #define BITMAPNUM_SPLASH_UP         (gConfig.fIsWIN95 ? 0x03 : 0x26)
@@ -77,7 +70,7 @@ PAL_Init(
    //
 #if defined(DINGOO)
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) == -1)
-#elif defined (__WINPHONE__)
+#elif defined (__WINRT__)
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1)
 #else
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK) == -1)
@@ -188,8 +181,6 @@ PAL_Shutdown(
 #if defined(GPH)
 	chdir("/usr/gp2x");
 	execl("./gp2xmenu", "./gp2xmenu", NULL);
-#elif defined(__WINPHONE__)
-	longjmp(g_exit_jmp_env, LONGJMP_EXIT_CODE);
 #endif
 	UTIL_Platform_Quit();
 }
@@ -522,18 +513,6 @@ main(
       buf[p - argv[0]] = '\0';
       chdir(buf);
    }
-#elif defined(__WINPHONE__)
-   //
-   // In windows phone, calling exit(0) directly will cause an abnormal exit.
-   // By using setjmp/longjmp to avoid this.
-   //
-   if (setjmp(g_exit_jmp_env) == LONGJMP_EXIT_CODE) return 0;
-
-   // We should first check the SD card before running actual codes
-   UTIL_BasePath();
-
-   SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeRight");
-   SDL_SetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, "1");
 #endif
 
    UTIL_OpenLog();

+ 2 - 2
overlay.c

@@ -1,7 +1,7 @@
-#if PAL_HAS_TOUCH
-
 #include "common.h"
 
+#if PAL_HAS_TOUCH
+
 const static uint32_t bmp_count[] = {
 	0x000cd604,0x0002453a,0x0002423d,0x00023f3f,0x00023d43,0x00023c43,0x00023b45,0x00023b45,0x00023946,0x00019f47,0x00008b0f,0x00019c47,0x00008815,0x00013847,0x00005d04,0x0000851b,
 	0x00013047,0x00005214,0x00008221,0x00012c47,0x00004c1c,0x00008025,0x00012a47,0x00004820,0x00007e29,0x00012847,0x00004424,0x00007c2d,0x00012647,0x00004128,0x00007b2f,0x00012447,

+ 0 - 1
winrt/SDL2/README.txt

@@ -1 +0,0 @@
-Download SDL2 source code from http://libsdl.org/ and extract here.

+ 1 - 15
winrt/SDLPal.Common/WinRTUtil.cpp

@@ -137,23 +137,9 @@ BOOL UTIL_TouchEnabled(VOID)
 #include "SDL.h"
 #include "SDL_endian.h"
 
-# include <setjmp.h>
-
-static jmp_buf g_exit_jmp_env;
-# define LONGJMP_EXIT_CODE          0xff
-
 extern "C"
 INT UTIL_Platform_Init(int argc, char* argv[])
 {
-	//
-	// In windows phone, calling exit(0) directly will cause an abnormal exit.
-	// By using setjmp/longjmp to avoid this.
-	//
-	if (setjmp(g_exit_jmp_env) == LONGJMP_EXIT_CODE) return -1;
-
-	// We should first check the SD card before running actual codes
-	UTIL_BasePath();
-
 	SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeRight");
 	SDL_SetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, "1");
 
@@ -163,5 +149,5 @@ INT UTIL_Platform_Init(int argc, char* argv[])
 extern "C"
 VOID UTIL_Platform_Quit(VOID)
 {
-	longjmp(g_exit_jmp_env, LONGJMP_EXIT_CODE);
+	Windows::ApplicationModel::Core::CoreApplication::Exit();
 }

+ 1 - 1
winrt/SDLPal.WindowsPhone.sln

@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 14
 VisualStudioVersion = 14.0.25123.0
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-WinPhone81", "SDL2\VisualC-WinRT\WinPhone81_VS2013\SDL-WinPhone81.vcxproj", "{48FADC0E-964D-4DAB-BCED-372E0AD19577}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-WinPhone81", "..\SDL2\VisualC-WinRT\WinPhone81_VS2013\SDL-WinPhone81.vcxproj", "{48FADC0E-964D-4DAB-BCED-372E0AD19577}"
 	ProjectSection(ProjectDependencies) = postProject
 		{35839F1B-8B1C-4858-91FA-807A693E703F} = {35839F1B-8B1C-4858-91FA-807A693E703F}
 	EndProjectSection

+ 2 - 4
winrt/SDLPal.WindowsPhone/SDLPal.Common.vcxproj

@@ -111,8 +111,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
     <ClCompile>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <CompileAsWinRT>false</CompileAsWinRT>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <SDLCheck>true</SDLCheck>
       <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).Common.pdb</ProgramDataBaseFileName>
     </ClCompile>
@@ -125,8 +124,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
     <ClCompile>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <CompileAsWinRT>false</CompileAsWinRT>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <SDLCheck>true</SDLCheck>
       <ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).Common.pdb</ProgramDataBaseFileName>
     </ClCompile>

+ 8 - 8
winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj

@@ -62,24 +62,24 @@
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;__WINPHONE__=1;PAL_HAS_TOUCH=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
@@ -95,7 +95,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;__WINPHONE__=1;PAL_HAS_TOUCH=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
@@ -111,7 +111,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
     <ClCompile>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;__WINPHONE__=1;PAL_HAS_TOUCH=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
@@ -127,7 +127,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
     <ClCompile>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;__WINPHONE__=1;PAL_HAS_TOUCH=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>

+ 5 - 5
winrt/SDLPal.WindowsPhone/SDLPal.vcxproj

@@ -71,19 +71,19 @@
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
-    <IncludePath>..\SDL2\include;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\SDL2\include;$(IncludePath)</IncludePath>
     <IntDir>$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
@@ -206,7 +206,7 @@
     <ClCompile Include="..\SDLPal.Common\WinRTUtil.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\SDL2\VisualC-WinRT\WinPhone81_VS2013\SDL-WinPhone81.vcxproj">
+    <ProjectReference Include="..\..\SDL2\VisualC-WinRT\WinPhone81_VS2013\SDL-WinPhone81.vcxproj">
       <Project>{48fadc0e-964d-4dab-bced-372e0ad19577}</Project>
     </ProjectReference>
     <ProjectReference Include="..\SDLPal.WindowsPhone\SDLPal.Common.vcxproj">