Browse Source

Merge pull request #3 from sdlpal/move_platform_specific_code

Move most platform-specific code into separate files
Yihua LOU 7 years ago
parent
commit
6d8dca0fd4
60 changed files with 1071 additions and 636 deletions
  1. 2 2
      3ds/Makefile
  2. 36 0
      3ds/pal_config.h
  3. 47 0
      3ds/pal_utils.c
  4. 1 1
      android/jni/src/Android.mk
  5. 22 0
      android/jni/src/pal_config.h
  6. 0 7
      audio.h
  7. 76 301
      common.h
  8. 1 1
      dingux/Makefile.dingux
  9. 22 0
      dingux/pal_config.h
  10. 52 0
      dingux/pal_utils.c
  11. 1 1
      emscripten/Makefile
  12. 1 1
      emscripten/Makefile.wasm
  13. 28 0
      emscripten/pal_config.h
  14. 2 2
      gph/Makefile.gph
  15. 25 0
      gph/pal_config.h
  16. 109 0
      gph/pal_utils.c
  17. 1 0
      incomplete_ports/README.txt
  18. 61 0
      incomplete_ports/pal_config.h
  19. 67 0
      incomplete_ports/pal_utils.c
  20. 49 141
      input.c
  21. 7 0
      input.h
  22. 2 0
      ios/SDLPal/SDLPal.xcodeproj/project.pbxproj
  23. 32 0
      ios/pal_config.h
  24. 0 0
      macos/English.lproj/InfoPlist.strings
  25. 0 0
      macos/Info.plist
  26. 31 25
      Pal.xcodeproj/project.pbxproj
  27. 0 0
      macos/Pal.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  28. 34 0
      macos/pal_config.h
  29. 0 0
      macos/sdlpal.icns
  30. 6 32
      main.c
  31. 0 3
      palcfg.h
  32. 1 1
      psp/Makefile.psp
  33. 9 0
      psp/main_PSP.c
  34. 24 0
      psp/pal_config.h
  35. 4 4
      resampler.c
  36. 0 11
      sound.c
  37. 1 1
      uigame.c
  38. 1 1
      unix/Makefile
  39. 35 0
      unix/pal_config.h
  40. 2 11
      util.c
  41. 0 25
      util.h
  42. 7 24
      video.c
  43. 3 3
      wii/Makefile.wii
  44. 25 0
      wii/pal_config.h
  45. 87 0
      wii/pal_utils.c
  46. 38 0
      win32/pal_config.h
  47. 5 4
      win32/sdlpal.vcxproj
  48. 3 0
      win32/sdlpal.vcxproj.filters
  49. 4 0
      win32/win32.cpp
  50. 12 2
      winrt/SDLPal.Common/WinRTUtil.cpp
  51. 7 6
      winrt/SDLPal.UWP/SDLPal.Core.vcxproj
  52. 3 0
      winrt/SDLPal.UWP/SDLPal.Core.vcxproj.filters
  53. 6 6
      winrt/SDLPal.UWP/SDLPal.UWP.vcxproj
  54. 7 6
      winrt/SDLPal.Windows/SDLPal.Core.vcxproj
  55. 3 0
      winrt/SDLPal.Windows/SDLPal.Core.vcxproj.filters
  56. 6 6
      winrt/SDLPal.Windows/SDLPal.vcxproj
  57. 5 4
      winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj
  58. 3 0
      winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj.filters
  59. 4 4
      winrt/SDLPal.WindowsPhone/SDLPal.vcxproj
  60. 51 0
      winrt/pal_config.h

+ 2 - 2
3ds/Makefile

@@ -31,7 +31,7 @@ include $(DEVKITARM)/3ds_rules
 #---------------------------------------------------------------------------------
 TARGET		:=	sdlpal
 BUILD		:=	build
-SOURCES		:=	.. ../adplug ../libmad
+SOURCES		:=	. .. ../adplug ../libmad
 
 APP_TITLE	:=	SDLPAL
 APP_DESCRIPTION :=	Pal DOS for 3DS
@@ -48,7 +48,7 @@ CFLAGS	:=	-g -Wall -O2 -mword-relocations \
 			-fomit-frame-pointer -ffunction-sections \
 			$(ARCH)
 
-CFLAGS	+=	$(INCLUDE) -DARM11 -D_3DS -D__3DS__ -D__N3DS__
+CFLAGS	+=	$(INCLUDE) -DARM11 -D_3DS -D__3DS__ -D__N3DS__ -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I.
 
 CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++14
 

+ 36 - 0
3ds/pal_config.h

@@ -0,0 +1,36 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# define PAL_PREFIX            "sdmc:/3ds/sdlpal/"
+# define PAL_SAVE_PREFIX       "sdmc:/3ds/sdlpal/"
+# define PAL_CONFIG_PREFIX     "sdmc:/3ds/sdlpal/"
+# define PAL_SCREENSHOT_PREFIX "sdmc:/3ds/sdlpal/"
+
+# define PAL_AUDIO_DEFAULT_BUFFER_SIZE   2048
+
+# define PAL_HAS_JOYSTICKS     0
+# define PAL_HAS_MP3           0
+# define PAL_HAS_OGG           0
+# define PAL_HAS_TOUCH         0
+
+# define PAL_DEFAULT_WINDOW_WIDTH   320
+# define PAL_DEFAULT_WINDOW_HEIGHT  240
+
+# define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_TOPSCR | SDL_CONSOLEBOTTOM | SDL_FULLSCREEN)
+
+# define PAL_SDL_INIT_FLAGS	   (SDL_INIT_VIDEO | SDL_INIT_AUDIO)
+
+# define PAL_PLATFORM         "Nintendo 3DS"
+# define PAL_CREDIT           "ZephRay"
+# define PAL_PORTYEAR         "2017"
+
+# define PAL_LARGE           static
+# define PAL_FORCE_UPDATE_ON_PALETTE_SET
+
+# define PAL_FILESYSTEM_IGNORE_CASE 1
+
+# define PAL_SCALE_SCREEN   FALSE
+
+# include <3ds.h>
+
+#endif

+ 47 - 0
3ds/pal_utils.c

@@ -0,0 +1,47 @@
+
+#include "main.h"
+
+static void init_filter()
+{
+	SDL_N3DSKeyBind(KEY_A, SDLK_RETURN);
+	SDL_N3DSKeyBind(KEY_B, SDLK_ESCAPE);
+	SDL_N3DSKeyBind(KEY_CPAD_UP, SDLK_UP);
+	SDL_N3DSKeyBind(KEY_CPAD_DOWN, SDLK_DOWN);
+	SDL_N3DSKeyBind(KEY_CPAD_LEFT, SDLK_LEFT);
+	SDL_N3DSKeyBind(KEY_CPAD_RIGHT, SDLK_RIGHT);
+}
+
+BOOL
+UTIL_GetScreenSize(
+	DWORD *pdwScreenWidth,
+	DWORD *pdwScreenHeight
+)
+{
+	return FALSE;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+	LPCSTR  lpszFileName
+)
+{
+	return FALSE;
+}
+
+INT
+UTIL_Platform_Init(
+	int argc,
+	char* argv[]
+)
+{
+	PAL_RegisterInputFilter(init_filter, NULL, NULL);
+	gConfig.fLaunchSetting = FALSE;
+	return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+	VOID
+)
+{
+}

+ 1 - 1
android/jni/src/Android.mk

@@ -9,7 +9,7 @@ LOCAL_MODULE := main
 
 OGG_PATH := ../../../liboggvorbis
 
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/src
+LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/$(SDL_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/include $(LOCAL_PATH)/$(OGG_PATH)/src
 
 LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
     $(wildcard $(LOCAL_PATH)/../../../*.cpp) $(wildcard $(LOCAL_PATH)/../../../*.c) \

+ 22 - 0
android/jni/src/pal_config.h

@@ -0,0 +1,22 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# define PAL_PREFIX            "/mnt/sdcard/sdlpal/"
+# define PAL_SAVE_PREFIX       "/mnt/sdcard/sdlpal/"
+# define PAL_HAS_TOUCH         1
+# define PAL_DEFAULT_WINDOW_WIDTH   320
+# define PAL_DEFAULT_WINDOW_HEIGHT  200
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
+# endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "Android"
+# define PAL_CREDIT           "Rikku2000"
+# define PAL_PORTYEAR         "2013"
+
+#endif

+ 0 - 7
audio.h

@@ -91,13 +91,6 @@ AUDIO_SoundEnabled(
    VOID
 );
 
-#ifdef PSP
-VOID
-SOUND_Reload(
-	VOID
-);
-#endif
-
 #define AUDIO_IsIntegerConversion(a) (((a) % gConfig.iSampleRate) == 0 || (gConfig.iSampleRate % (a)) == 0)
 
 #ifdef __cplusplus

+ 76 - 301
common.h

@@ -49,27 +49,33 @@ extern "C"
 
 #if SDL_VERSION_ATLEAST(2,0,0)
 
-#define SDLK_KP1     SDLK_KP_1
-#define SDLK_KP2     SDLK_KP_2
-#define SDLK_KP3     SDLK_KP_3
-#define SDLK_KP4     SDLK_KP_4
-#define SDLK_KP5     SDLK_KP_5
-#define SDLK_KP6     SDLK_KP_6
-#define SDLK_KP7     SDLK_KP_7
-#define SDLK_KP8     SDLK_KP_8
-#define SDLK_KP9     SDLK_KP_9
-#define SDLK_KP0     SDLK_KP_0
-
-#define SDL_HWSURFACE     0
+# define SDLK_KP1     SDLK_KP_1
+# define SDLK_KP2     SDLK_KP_2
+# define SDLK_KP3     SDLK_KP_3
+# define SDLK_KP4     SDLK_KP_4
+# define SDLK_KP5     SDLK_KP_5
+# define SDLK_KP6     SDLK_KP_6
+# define SDLK_KP7     SDLK_KP_7
+# define SDLK_KP8     SDLK_KP_8
+# define SDLK_KP9     SDLK_KP_9
+# define SDLK_KP0     SDLK_KP_0
+
+# define SDL_HWSURFACE     0
+
+#else
+
+# ifndef PAL_FATAL_OUTPUT
+#  define PAL_FATAL_OUTPUT(s)
+# endif
 
 #endif
 
 #ifndef max
-#define max fmax
+# define max fmax
 #endif
 
 #ifndef min
-#define min fmin
+# define min fmin
 #endif
 
 /* This is need when compiled with SDL 1.2 */
@@ -84,245 +90,75 @@ extern "C"
 #endif /* SDL_FORCE_INLINE not defined */
 
 #if defined(_MSC_VER)
-#define PAL_FORCE_INLINE static SDL_FORCE_INLINE
+# define PAL_FORCE_INLINE static SDL_FORCE_INLINE
 #else
-#define PAL_FORCE_INLINE SDL_FORCE_INLINE
+# define PAL_FORCE_INLINE SDL_FORCE_INLINE
 #endif
 
-#if defined (__SYMBIAN32__)
-
-#undef  _WIN32
-#undef  SDL_INIT_JOYSTICK
-#define SDL_INIT_JOYSTICK     0
-#define PAL_HAS_MOUSE         1
-#define PAL_PREFIX            "e:/data/pal/"
-#define PAL_SAVE_PREFIX       "e:/data/pal/"
-# ifdef __S60_5X__
-#  define PAL_DEFAULT_WINDOW_WIDTH   640
-#  define PAL_DEFAULT_WINDOW_HEIGHT  360
-# else
-#  define PAL_DEFAULT_WINDOW_WIDTH   320
-#  define PAL_DEFAULT_WINDOW_HEIGHT  240
-# endif
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
-# endif
-
-# define PAL_PLATFORM         "  Symbian S60 \x79FB\x690D (c) 2009, netwan."
-# define PAL_CREDIT           "netwan"
-# define PAL_PORTYEAR         "2009"
-
-#elif defined (GEKKO)
-
-#define PAL_HAS_JOYSTICKS     1
-#define PAL_HAS_MOUSE         0
-#define PAL_PREFIX            "SD:/apps/sdlpal/"
-#define PAL_SAVE_PREFIX       "SD:/apps/sdlpal/"
-
-#define PAL_DEFAULT_WINDOW_WIDTH   640
-#define PAL_DEFAULT_WINDOW_HEIGHT  480
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
-# endif
-
-# define PAL_PLATFORM         "Nintendo WII"
-# define PAL_CREDIT           "Rikku2000"
-# define PAL_PORTYEAR         "2012"
-
-#elif defined (PSP)
-
-#define PAL_HAS_JOYSTICKS     0
-#define PAL_PREFIX            "ms0:/"
-#define PAL_SAVE_PREFIX       "ms0:/PSP/SAVEDATA/SDLPAL/"
-
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  240
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
-# endif
-
-# define PAL_PLATFORM         "Sony PSP"
-# define PAL_CREDIT           "(Unknown)"
-# define PAL_PORTYEAR         "2011"
-
-#elif defined(GPH) || defined(DINGOO)
-
-#define PAL_PREFIX            "./"
-#define PAL_SAVE_PREFIX       "./"
-
-#  define PAL_DEFAULT_WINDOW_WIDTH   320
-#  define PAL_DEFAULT_WINDOW_HEIGHT  240
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
-# endif
-
-# if defined(GPH)
-#  define PAL_PLATFORM         "GPH Caanoo & Wiz"
-# else
-#  define PAL_PLATFORM         "DINGOO & Dingux"
-# endif
-# define PAL_CREDIT           "Rikku2000"
-# define PAL_PORTYEAR         "2011"
-
-#elif defined(NDS)
-
-#define PAL_PREFIX            "./"
-#define PAL_SAVE_PREFIX       "./"
+#ifdef _WIN32
 
-#  define PAL_DEFAULT_WINDOW_WIDTH   293
-#  define PAL_DEFAULT_WINDOW_HEIGHT  196
+# include <windows.h>
+# include <io.h>
 
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
+# if defined(_MSC_VER)
+#  if _MSC_VER < 1900
+#   define vsnprintf _vsnprintf
+#   define snprintf _snprintf
+#  endif
+#  define strdup _strdup
+#  pragma warning (disable:4244)
 # endif
 
-# define PAL_PLATFORM         "Nintendo DS"
-# define PAL_CREDIT           "(Unknown)"
-# define PAL_PORTYEAR         "2012"
-
-#elif defined (__N3DS__)
-
-#define PAL_PREFIX            "sdmc:/3ds/sdlpal/"
-#define PAL_SAVE_PREFIX       "sdmc:/3ds/sdlpal/"
-#define PAL_CONFIG_PREFIX     "sdmc:/3ds/sdlpal/"
-#define PAL_SCREENSHOT_PREFIX "sdmc:/3ds/sdlpal/"
-
-#define PAL_AUDIO_DEFAULT_BUFFER_SIZE   2048
-
-#define PAL_HAS_JOYSTICKS     0
-#define PAL_HAS_MP3           0
-#define PAL_HAS_OGG           0
-#define PAL_HAS_TOUCH         0
-
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  240
-
-#define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_TOPSCR | SDL_CONSOLEBOTTOM | SDL_FULLSCREEN)
-
-# define PAL_PLATFORM         "Nintendo 3DS"
-# define PAL_CREDIT           "ZephRay"
-# define PAL_PORTYEAR         "2017"
-
-#elif defined (__IOS__)
-
-#define PAL_PREFIX            UTIL_BasePath()
-#define PAL_SAVE_PREFIX       UTIL_SavePath()
-#define PAL_HAS_TOUCH         1
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  200
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
+# ifndef _LPCBYTE_DEFINED
+#  define _LPCBYTE_DEFINED
+typedef const BYTE *LPCBYTE;
 # endif
 
-# define PAL_PLATFORM         "Apple iOS"
-# define PAL_CREDIT           "(Unknown)"
-# define PAL_PORTYEAR         "2015"
-
-#elif defined (__ANDROID__)
+#else
 
-#define PAL_PREFIX            "/mnt/sdcard/sdlpal/"
-#define PAL_SAVE_PREFIX       "/mnt/sdcard/sdlpal/"
-#define PAL_HAS_TOUCH         1
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  200
+# include <unistd.h>
+# include <dirent.h>
 
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
+# ifndef FALSE
+#  define FALSE               0
 # endif
-
-# define PAL_PLATFORM         "Android"
-# define PAL_CREDIT           "Rikku2000"
-# define PAL_PORTYEAR         "2013"
-
-#elif defined(__WINRT__)
-
-#define PAL_PREFIX            UTIL_BasePath()
-#define PAL_SAVE_PREFIX       UTIL_SavePath()
-#define PAL_CONFIG_PREFIX     UTIL_ConfigPath()
-#define PAL_SCREENSHOT_PREFIX UTIL_ScreenShotPath()
-#define PAL_HAS_TOUCH         1
-#define PAL_AUDIO_DEFAULT_BUFFER_SIZE   4096
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  200
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+# ifndef TRUE
+#  define TRUE                1
 # endif
+# define VOID                void
+typedef char                CHAR;
+typedef wchar_t             WCHAR;
+typedef short               SHORT;
+typedef long                LONG;
 
-# define PAL_PLATFORM         "Windows Runtime"
-# define PAL_CREDIT           "(Unknown)"
-# define PAL_PORTYEAR         "2015"
-
-#elif defined (__EMSCRIPTEN__)
-
-#include <emscripten.h>
-#define SDL_Delay emscripten_sleep
-
-#define PAL_PREFIX            "data/"
-#define PAL_SAVE_PREFIX       "data/"
-#define PAL_HAS_TOUCH         0
-#define PAL_DEFAULT_WINDOW_WIDTH   320
-#define PAL_DEFAULT_WINDOW_HEIGHT  200
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
-# endif
-
-# define PAL_PLATFORM         "Emscripten"
-# define PAL_CREDIT           "palxex"
-# define PAL_PORTYEAR         "2016"
-
-#else
+typedef unsigned long       ULONG, *PULONG;
+typedef unsigned short      USHORT, *PUSHORT;
+typedef unsigned char       UCHAR, *PUCHAR;
 
-# ifndef PAL_HAS_JOYSTICKS
-#  define PAL_HAS_JOYSTICKS    1
+typedef unsigned short      WORD, *LPWORD;
+typedef unsigned int        DWORD, *LPDWORD;
+typedef int                 INT, *LPINT;
+# ifndef __OBJC__
+typedef int                 BOOL, *LPBOOL;
 # endif
+typedef unsigned int        UINT, *PUINT, UINT32, *PUINT32;
+typedef unsigned char       BYTE, *LPBYTE;
+typedef const BYTE         *LPCBYTE;
+typedef float               FLOAT, *LPFLOAT;
+typedef void               *LPVOID;
+typedef const void         *LPCVOID;
+typedef CHAR               *LPSTR;
+typedef const CHAR         *LPCSTR;
+typedef WCHAR              *LPWSTR;
+typedef const WCHAR        *LPCWSTR;
 
-#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
-# define PAL_ALLOW_KEYREPEAT   1
-# define PAL_HAS_SDLCD         1
 #endif
 
-# define PAL_PREFIX            "./"
-# define PAL_SAVE_PREFIX       "./"
-
-# define PAL_DEFAULT_WINDOW_WIDTH   640
-# define PAL_DEFAULT_WINDOW_HEIGHT  400
-# define PAL_DEFAULT_FULLSCREEN_HEIGHT 480
-
-# if SDL_VERSION_ATLEAST(2,0,0)
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | (gConfig.fFullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0))
-# else
-#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
-# endif
-
-# define PAL_PLATFORM         NULL
-# define PAL_CREDIT           NULL
-# define PAL_PORTYEAR         NULL
-
-#endif
+/* When porting SDLPAL to a new platform, please make a separate directory and put a file 
+   named 'pal_config.h' that contains marco definitions & header includes into the directory.
+   The example of this file can be found in directories of existing portings.
+ */
+#include "pal_config.h"
 
 #ifndef PAL_DEFAULT_FULLSCREEN_HEIGHT
 # define PAL_DEFAULT_FULLSCREEN_HEIGHT PAL_DEFAULT_WINDOW_HEIGHT
@@ -360,77 +196,16 @@ extern "C"
 # define PAL_SCREENSHOT_PREFIX PAL_SAVE_PREFIX
 #endif
 
-#ifdef _WIN32
-
-#include <windows.h>
-#include <io.h>
-
-#if defined(_MSC_VER)
-# if _MSC_VER < 1900
-#  define vsnprintf _vsnprintf
-#  define snprintf _snprintf
-# endif
-# define strdup _strdup
-# pragma warning (disable:4244)
-#endif
-
-#ifndef _LPCBYTE_DEFINED
-# define _LPCBYTE_DEFINED
-typedef const BYTE *LPCBYTE;
-#endif
-
-#ifndef __WINRT__
-# define PAL_HAS_NATIVEMIDI  1
-#endif
-
-#else
-
-#include <unistd.h>
-#include <dirent.h>
-
-#ifndef FALSE
-#define FALSE               0
-#endif
-#ifndef TRUE
-#define TRUE                1
-#endif
-#define VOID                void
-typedef char                CHAR;
-typedef wchar_t             WCHAR;
-typedef short               SHORT;
-typedef long                LONG;
-
-typedef unsigned long       ULONG, *PULONG;
-typedef unsigned short      USHORT, *PUSHORT;
-typedef unsigned char       UCHAR, *PUCHAR;
-
-typedef unsigned short      WORD, *LPWORD;
-typedef unsigned int        DWORD, *LPDWORD;
-typedef int                 INT, *LPINT;
-#ifndef __OBJC__
-typedef int                 BOOL, *LPBOOL;
-#endif
-typedef unsigned int        UINT, *PUINT, UINT32, *PUINT32;
-typedef unsigned char       BYTE, *LPBYTE;
-typedef const BYTE         *LPCBYTE;
-typedef float               FLOAT, *LPFLOAT;
-typedef void               *LPVOID;
-typedef const void         *LPCVOID;
-typedef CHAR               *LPSTR;
-typedef const CHAR         *LPCSTR;
-typedef WCHAR              *LPWSTR;
-typedef const WCHAR        *LPCWSTR;
-
+#ifndef PAL_HAS_NATIVEMIDI
+# define PAL_HAS_NATIVEMIDI  0
 #endif
 
-#ifndef PAL_HAS_NATIVEMIDI
-#define PAL_HAS_NATIVEMIDI  0
+#ifndef PAL_LARGE
+# define PAL_LARGE
 #endif
 
-#if defined (__SYMBIAN32__) || defined (__N3DS__)
-#define PAL_LARGE           static
-#else
-#define PAL_LARGE           /* */
+#ifndef PAL_SCALE_SCREEN
+# define PAL_SCALE_SCREEN   TRUE
 #endif
 
 #define __WIDETEXT(quote) L##quote

+ 1 - 1
dingux/Makefile.dingux

@@ -7,7 +7,7 @@ CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
 CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
 OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DDINGOO -DPAL_CLASSIC
+CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DDINGOO -DPAL_CLASSIC -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I.
 CXXFLAGS = $(CFLAGS)
 LDFLAGS = `sdl-config --libs`
 

+ 22 - 0
dingux/pal_config.h

@@ -0,0 +1,22 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+#define PAL_PREFIX            "./"
+#define PAL_SAVE_PREFIX       "./"
+
+#  define PAL_DEFAULT_WINDOW_WIDTH   320
+#  define PAL_DEFAULT_WINDOW_HEIGHT  240
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
+# endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "DINGOO & Dingux"
+# define PAL_CREDIT           "Rikku2000"
+# define PAL_PORTYEAR         "2011"
+
+#endif

+ 52 - 0
dingux/pal_utils.c

@@ -0,0 +1,52 @@
+
+#include "main.h"
+
+static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
+{
+	switch (lpEvent->type)
+	{
+	case SDLK_SPACE:
+		state->dwKeyPress = kKeyMenu;
+		return 1;
+
+	case SDLK_LCTRL:
+		state->dwKeyPress = kKeySearch;
+		return 1;
+	}
+	return 0;
+}
+
+BOOL
+UTIL_GetScreenSize(
+	DWORD *pdwScreenWidth,
+	DWORD *pdwScreenHeight
+)
+{
+	return FALSE;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+	LPCSTR  lpszFileName
+)
+{
+	return FALSE;
+}
+
+INT
+UTIL_Platform_Init(
+	int argc,
+	char* argv[]
+)
+{
+	PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
+	gConfig.fLaunchSetting = FALSE;
+	return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+	VOID
+)
+{
+}

+ 1 - 1
emscripten/Makefile

@@ -9,7 +9,7 @@ CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../libog
 CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
 OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CFLAGS = -I${EMSCRIPTEN_TOOLCHAIN}/include/SDL2 -g -Wall -O2 -fno-strict-aliasing -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
+CFLAGS = -I${EMSCRIPTEN_TOOLCHAIN}/include/SDL2 -g -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
 LDFLAGS = -L${EMSCRIPTEN_TOOLCHAIN}/lib -lSDL2 -lm -lstdc++ --preload-file data -s TOTAL_MEMORY=134217728 -s TOTAL_STACK=5242880 --emrun -s DEMANGLE_SUPPORT=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 -s 'EMTERPRETIFY_FILE="sdlpal.bc"'
 
 .c.o:

+ 1 - 1
emscripten/Makefile.wasm

@@ -9,7 +9,7 @@ CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../libog
 CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
 OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CFLAGS = -I${EMSCRIPTEN_TOOLCHAIN}/include/SDL2 -g -Wall -O2 -fno-strict-aliasing -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
+CFLAGS = -I${EMSCRIPTEN_TOOLCHAIN}/include/SDL2 -g -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
 LDFLAGS = -L${EMSCRIPTEN_TOOLCHAIN}/lib -lSDL2 -lm -lstdc++ --preload-file data -s TOTAL_MEMORY=134217728 -s TOTAL_STACK=5242880 --emrun -s DEMANGLE_SUPPORT=1 -s WASM=1 -s ASYNCIFY=1
 
 .c.o:

+ 28 - 0
emscripten/pal_config.h

@@ -0,0 +1,28 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# include <emscripten.h>
+# define SDL_Delay emscripten_sleep
+
+# define PAL_PREFIX            "data/"
+# define PAL_SAVE_PREFIX       "data/"
+# define PAL_HAS_TOUCH         0
+# define PAL_DEFAULT_WINDOW_WIDTH   320
+# define PAL_DEFAULT_WINDOW_HEIGHT  200
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
+# endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "Emscripten"
+# define PAL_CREDIT           "palxex"
+# define PAL_PORTYEAR         "2016"
+
+# include <ctype.h>
+# include <sys/time.h>
+
+#endif

+ 2 - 2
gph/Makefile.gph

@@ -13,12 +13,12 @@ DEVICE = -DCAANOO
 endif
 endif
 
-SOURCES = . ./adplug
+SOURCES = . .. ../adplug
 CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
 CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
 OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGPH $(DEVICE) -DPAL_CLASSIC
+CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGPH $(DEVICE) -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I.
 CXXFLAGS = $(CFLAGS)
 LDFLAGS = `sdl-config --libs`
 

+ 25 - 0
gph/pal_config.h

@@ -0,0 +1,25 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+#define PAL_PREFIX            "./"
+#define PAL_SAVE_PREFIX       "./"
+
+#  define PAL_DEFAULT_WINDOW_WIDTH   320
+#  define PAL_DEFAULT_WINDOW_HEIGHT  240
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
+# endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "GPH Caanoo & Wiz"
+# define PAL_CREDIT           "Rikku2000"
+# define PAL_PORTYEAR         "2011"
+
+# define MIN_DEADZONE -16384
+# define MAX_DEADZONE 16384
+
+#endif

+ 109 - 0
gph/pal_utils.c

@@ -0,0 +1,109 @@
+
+#include "main.h"
+
+static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
+{
+	switch (lpEvent->type)
+	{
+	case SDL_JOYAXISMOTION:
+		switch (lpEvent->jaxis.axis)
+		{
+		case 0:
+			//
+			// X axis
+			//
+			if (lpEvent->jaxis.value > MAX_DEADZONE) {
+				state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+				state->dir = kDirEast;
+				state->dwKeyPress = kKeyRight;
+			}
+			else if (lpEvent->jaxis.value < MIN_DEADZONE) {
+				state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+				state->dir = kDirWest;
+				state->dwKeyPress = kKeyLeft;
+			}
+			else {
+				state->dir = kDirUnknown;
+			}
+			return 1;
+		case 1:
+			//
+			// Y axis
+			//
+			if (lpEvent->jaxis.value > MAX_DEADZONE) {
+				state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+				state->dir = kDirSouth;
+				state->dwKeyPress = kKeyDown;
+			}
+			else if (lpEvent->jaxis.value < MIN_DEADZONE) {
+				state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+				state->dir = kDirNorth;
+				state->dwKeyPress = kKeyUp;
+			}
+			else {
+				state->dir = kDirUnknown;
+			}
+			return 1;
+		}
+		break;
+
+	case SDL_JOYBUTTONDOWN:
+		switch (lpEvent->jbutton.button)
+		{
+#if defined(GP2XWIZ)
+		case 14:
+#elif defined(CAANOO)
+		case 3:
+#endif
+			state->dwKeyPress = kKeyMenu;
+			return 1;
+
+#if defined(GP2XWIZ)
+		case 13:
+#elif defined(CAANOO)
+		case 2:
+#endif
+			state->dwKeyPress = kKeySearch;
+			return 1;
+		}
+		break;
+	}
+	return 0;
+}
+
+BOOL
+UTIL_GetScreenSize(
+	DWORD *pdwScreenWidth,
+	DWORD *pdwScreenHeight
+)
+{
+	return FALSE;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+	LPCSTR  lpszFileName
+)
+{
+	return FALSE;
+}
+
+INT
+UTIL_Platform_Init(
+	int argc,
+	char* argv[]
+)
+{
+	PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
+	gConfig.fLaunchSetting = FALSE;
+	return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+	VOID
+)
+{
+	chdir("/usr/gp2x");
+	execl("./gp2xmenu", "./gp2xmenu", NULL);
+}

+ 1 - 0
incomplete_ports/README.txt

@@ -0,0 +1 @@
+This directory contains ports that are incomplete.

+ 61 - 0
incomplete_ports/pal_config.h

@@ -0,0 +1,61 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+#if defined (__SYMBIAN32__)
+
+#undef  _WIN32
+#undef  SDL_INIT_JOYSTICK
+#define SDL_INIT_JOYSTICK     0
+#define PAL_HAS_MOUSE         1
+#define PAL_PREFIX            "e:/data/pal/"
+#define PAL_SAVE_PREFIX       "e:/data/pal/"
+# ifdef __S60_5X__
+#  define PAL_DEFAULT_WINDOW_WIDTH   640
+#  define PAL_DEFAULT_WINDOW_HEIGHT  360
+# else
+#  define PAL_DEFAULT_WINDOW_WIDTH   320
+#  define PAL_DEFAULT_WINDOW_HEIGHT  240
+# endif
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_FATAL_OUTPUT(s)   UTIL_WriteLog(LOG_DEBUG,"[0x%08x][%s][%s] - %s",(long)TerminateOnError,"TerminateOnError",__FILE__, (s)); SDL_Delay(3000)
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "  Symbian S60 \x79FB\x690D (c) 2009, netwan."
+# define PAL_CREDIT           "netwan"
+# define PAL_PORTYEAR         "2009"
+
+# define PAL_LARGE           static
+# define PAL_FORCE_UPDATE_ON_PALETTE_SET
+
+# if !defined (__S60_5X__)
+#  define PAL_SCALE_SCREEN   FALSE
+# endif
+
+#elif defined(NDS)
+
+#define PAL_PREFIX            "./"
+#define PAL_SAVE_PREFIX       "./"
+
+#  define PAL_DEFAULT_WINDOW_WIDTH   293
+#  define PAL_DEFAULT_WINDOW_HEIGHT  196
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "Nintendo DS"
+# define PAL_CREDIT           "(Unknown)"
+# define PAL_PORTYEAR         "2012"
+
+#endif
+
+#endif

+ 67 - 0
incomplete_ports/pal_utils.c

@@ -0,0 +1,67 @@
+
+#include "main.h"
+#if defined(NDS)
+#include <fat.h>
+#endif
+
+#if defined(__SYMBIAN32__)
+static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
+{
+	//
+	// Symbian-specific stuff
+	//
+	switch (lpEvent->type)
+	{
+	case SDLK_0:
+		VIDEO_ToggleScaleScreen();
+		return 1;
+	case SDLK_1:
+		AUDIO_DecreaseVolume();
+		return 1;
+	case SDLK_3:
+		AUDIO_IncreaseVolume();
+		return 1;
+	}
+	return 0;
+}
+#endif
+
+BOOL
+UTIL_GetScreenSize(
+	DWORD *pdwScreenWidth,
+	DWORD *pdwScreenHeight
+)
+{
+	return FALSE;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+	LPCSTR  lpszFileName
+)
+{
+	return FALSE;
+}
+
+INT
+UTIL_Platform_Init(
+	int argc,
+	char* argv[]
+)
+{
+#if defined(NDS)
+	fatInitDefault();
+#endif
+#if defined(__SYMBIAN32__)
+	PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
+#endif
+	gConfig.fLaunchSetting = FALSE;
+	return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+	VOID
+)
+{
+}

+ 49 - 141
input.c

@@ -24,10 +24,6 @@
 #include "main.h"
 #include <math.h>
 
-#ifdef __N3DS__
-#include <3ds.h>
-#endif
-
 volatile PALINPUTSTATE   g_InputState;
 #if PAL_HAS_JOYSTICKS
 static SDL_Joystick     *g_pJoy = NULL;
@@ -37,10 +33,14 @@ static SDL_Joystick     *g_pJoy = NULL;
 #endif
 BOOL                     g_fUseJoystick = TRUE;
 
-#if defined(GPH)
-#define MIN_DEADZONE -16384
-#define MAX_DEADZONE 16384
-#endif
+static void _default_init_filter() {}
+static int _default_input_event_filter(const SDL_Event *event, volatile PALINPUTSTATE *state) { return 0; }
+static void _default_input_shutdown_filter() {}
+
+static void (*input_init_filter)() = _default_init_filter;
+static int (*input_event_filter)(const SDL_Event *, volatile PALINPUTSTATE *) = _default_input_event_filter;
+static void (*input_shutdown_filter)() = _default_input_shutdown_filter;
+
 
 static VOID
 PAL_KeyboardEventFilter(
@@ -88,20 +88,6 @@ PAL_KeyboardEventFilter(
 
       switch (lpEvent->key.keysym.sym)
       {
-#ifdef __SYMBIAN32__
-      //
-      // Symbian-specific stuff
-      //
-      case SDLK_0:
-         VIDEO_ToggleScaleScreen();
-         break;
-      case SDLK_1:
-         AUDIO_DecreaseVolume();
-         break;
-      case SDLK_3:
-         AUDIO_IncreaseVolume();
-         break;
-#endif
       case SDLK_UP:
       case SDLK_KP8:
          if (gpGlobals->fInBattle || g_InputState.dir != kDirNorth)
@@ -142,15 +128,6 @@ PAL_KeyboardEventFilter(
          }
          break;
 
-#if defined(DINGOO)
-      case SDLK_SPACE:
-         g_InputState.dwKeyPress = kKeyMenu;
-         break;
-
-      case SDLK_LCTRL:
-         g_InputState.dwKeyPress = kKeySearch;
-         break;
-#else
       case SDLK_ESCAPE:
       case SDLK_INSERT:
       case SDLK_LALT:
@@ -206,12 +183,6 @@ PAL_KeyboardEventFilter(
          g_InputState.dwKeyPress |= kKeyThrowItem;
          break;
 
-#if defined(__WINRT__)
-      case SDLK_AC_BACK:
-         // If game not started, exit directly
-         if (!gpGlobals->fInMainGame)
-            PAL_Shutdown(0);
-#endif
       case SDLK_q:
          g_InputState.dwKeyPress |= kKeyFlee;
          break;
@@ -229,7 +200,6 @@ PAL_KeyboardEventFilter(
       case SDLK_p:
          VIDEO_SaveScreenshot();
          break;
-#endif
 
       default:
          break;
@@ -496,36 +466,6 @@ PAL_JoystickEventFilter(
 #if PAL_HAS_JOYSTICKS
    switch (lpEvent->type)
    {
-#if defined (GEKKO)
-   case SDL_JOYHATMOTION:
-      switch (lpEvent->jhat.value)
-      {
-      case SDL_HAT_LEFT:
-        g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-        g_InputState.dir = kDirWest;
-        g_InputState.dwKeyPress = kKeyLeft;
-        break;
-
-      case SDL_HAT_RIGHT:
-        g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-        g_InputState.dir = kDirEast;
-        g_InputState.dwKeyPress = kKeyRight;
-        break;
-
-      case SDL_HAT_UP:
-        g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-        g_InputState.dir = kDirNorth;
-        g_InputState.dwKeyPress = kKeyUp;
-        break;
-
-      case SDL_HAT_DOWN:
-        g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-        g_InputState.dir = kDirSouth;
-        g_InputState.dwKeyPress = kKeyDown;
-        break;
-      }
-      break;
-#else
    case SDL_JOYAXISMOTION:
       //
       // Moved an axis on joystick
@@ -536,19 +476,6 @@ PAL_JoystickEventFilter(
          //
          // X axis
          //
-#if defined(GPH)
-      if (lpEvent->jaxis.value > MAX_DEADZONE) {
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirEast;
-         g_InputState.dwKeyPress = kKeyRight;
-      } else if (lpEvent->jaxis.value < MIN_DEADZONE) {
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirWest;
-         g_InputState.dwKeyPress = kKeyLeft;
-      } else {
-         g_InputState.dir = kDirUnknown;
-      }
-#else
          if (lpEvent->jaxis.value > 20000)
          {
             if (g_InputState.dir != kDirEast)
@@ -576,26 +503,12 @@ PAL_JoystickEventFilter(
             }
             g_InputState.prevdir = kDirUnknown;
          }
-#endif
          break;
 
       case 1:
          //
          // Y axis
          //
-#if defined(GPH)
-      if (lpEvent->jaxis.value > MAX_DEADZONE) {
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirSouth;
-         g_InputState.dwKeyPress = kKeyDown;
-      } else if (lpEvent->jaxis.value < MIN_DEADZONE) {
-         g_InputState.prevdir = (gpGlobals->fInBattle ? kDirUnknown : g_InputState.dir);
-         g_InputState.dir = kDirNorth;
-         g_InputState.dwKeyPress = kKeyUp;
-      } else {
-         g_InputState.dir = kDirUnknown;
-      }
-#else
          if (lpEvent->jaxis.value > 20000)
          {
             if (g_InputState.dir != kDirSouth)
@@ -623,46 +536,14 @@ PAL_JoystickEventFilter(
             }
             g_InputState.prevdir = kDirUnknown;
          }
-#endif
          break;
       }
       break;
-#endif
 
    case SDL_JOYBUTTONDOWN:
       //
       // Pressed the joystick button
       //
-#if defined(GPH)
-      switch (lpEvent->jbutton.button)
-      {
-#if defined(GP2XWIZ)
-      case 14:
-#elif defined(CAANOO)
-      case 3:
-#endif
-         g_InputState.dwKeyPress = kKeyMenu;
-         break;
-
-#if defined(GP2XWIZ)
-      case 13:
-#elif defined(CAANOO)
-      case 2:
-#endif
-         g_InputState.dwKeyPress = kKeySearch;
-         break;
-#else
-#if defined(GEKKO)
-      switch (lpEvent->jbutton.button)
-      {
-      case 2:
-         g_InputState.dwKeyPress |= kKeyMenu;
-         break;
-
-      case 3:
-         g_InputState.dwKeyPress |= kKeySearch;
-         break;
-#else
       switch (lpEvent->jbutton.button & 1)
       {
       case 0:
@@ -672,8 +553,6 @@ PAL_JoystickEventFilter(
       case 1:
          g_InputState.dwKeyPress |= kKeySearch;
          break;
-#endif
-#endif
       }
       break;
    }
@@ -1083,14 +962,7 @@ PAL_InitInput(
    SDL_EnableKeyRepeat(0, 0);
 #endif
 
-#ifdef __N3DS__
-   SDL_N3DSKeyBind(KEY_A, SDLK_RETURN);
-   SDL_N3DSKeyBind(KEY_B, SDLK_ESCAPE);
-   SDL_N3DSKeyBind(KEY_CPAD_UP, SDLK_UP);
-   SDL_N3DSKeyBind(KEY_CPAD_DOWN, SDLK_DOWN);
-   SDL_N3DSKeyBind(KEY_CPAD_LEFT, SDLK_LEFT);
-   SDL_N3DSKeyBind(KEY_CPAD_RIGHT, SDLK_RIGHT);
-#endif
+   input_init_filter();
 }
 
 VOID
@@ -1113,21 +985,22 @@ PAL_ShutdownInput(
 --*/
 {
 #if PAL_HAS_JOYSTICKS
-#if SDL_VERSION_ATLEAST(2,0,0)
+# if SDL_VERSION_ATLEAST(2,0,0)
    if (g_pJoy != NULL)
    {
       SDL_JoystickClose(g_pJoy);
       g_pJoy = NULL;
    }
-#else
+# else
    if (SDL_JoystickOpened(0))
    {
       assert(g_pJoy != NULL);
       SDL_JoystickClose(g_pJoy);
       g_pJoy = NULL;
    }
+# endif
 #endif
-#endif
+   input_shutdown_filter();
 }
 
 VOID
@@ -1177,7 +1050,7 @@ PAL_PollEvent(
    SDL_Event evt;
 
    int ret = SDL_PollEvent(&evt);
-   if (ret != 0)
+   if (ret != 0 && !input_event_filter(&evt, &g_InputState))
    {
       PAL_EventFilter(&evt);
    }
@@ -1189,3 +1062,38 @@ PAL_PollEvent(
 
    return ret;
 }
+
+VOID
+PAL_RegisterInputFilter(
+   void (*init_filter)(),
+   int (*event_filter)(const SDL_Event *, volatile PALINPUTSTATE *),
+   void (*shutdown_filter)()
+)
+/*++
+  Purpose:
+
+    Register caller-defined input event filter.
+
+  Parameters:
+
+    [IN] init_filter - Filter that will be called inside PAL_InitInput
+	[IN] event_filter - Filter that will be called inside PAL_PollEvent, 
+	                    return non-zero value from this filter disables
+						further internal event processing.
+	[IN] shutdown_filter - Filter that will be called inside PAL_ShutdownInput
+
+	Passing NULL to either parameter means the caller does not provide such filter.
+
+  Return value:
+
+    None.
+
+--*/
+{
+	if (init_filter)
+		input_init_filter = init_filter;
+	if (event_filter)
+		input_event_filter = event_filter;
+	if (shutdown_filter)
+		input_shutdown_filter = shutdown_filter;
+}

+ 7 - 0
input.h

@@ -92,6 +92,13 @@ PAL_SetTouchBounds(
    SDL_Rect renderRect
 );
 
+VOID
+PAL_RegisterInputFilter(
+   void (*init_filter)(),
+   int (*event_filter)(const SDL_Event *, volatile PALINPUTSTATE *),
+   void (*shutdown_filter)()
+);
+
 extern BOOL g_fUseJoystick;
 
 #ifdef __cplusplus

+ 2 - 0
ios/SDLPal/SDLPal.xcodeproj/project.pbxproj

@@ -341,6 +341,7 @@
 		C622BE711E474CD5000C8970 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
 		C622BE731E474CE2000C8970 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
 		C622BE751E474CFC000C8970 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
+		C626FFBF1E5BCBE700E39DD9 /* pal_config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = pal_config.h; path = ../../pal_config.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -559,6 +560,7 @@
 		71655066195BB372006E1227 /* SDLPal */ = {
 			isa = PBXGroup;
 			children = (
+				C626FFBF1E5BCBE700E39DD9 /* pal_config.h */,
 				57FB015A1B7A50E0005FCF4C /* codepage.h */,
 				57FB015B1B7A50E0005FCF4C /* fontglyph.h */,
 				57FB015C1B7A50E0005FCF4C /* mp3play.c */,

+ 32 - 0
ios/pal_config.h

@@ -0,0 +1,32 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# define PAL_PREFIX            UTIL_BasePath()
+# define PAL_SAVE_PREFIX       UTIL_SavePath()
+# define PAL_HAS_TOUCH         1
+# define PAL_DEFAULT_WINDOW_WIDTH   320
+# define PAL_DEFAULT_WINDOW_HEIGHT  200
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_FULLSCREEN)
+# endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         "Apple iOS"
+# define PAL_CREDIT           "(Unknown)"
+# define PAL_PORTYEAR         "2015"
+
+LPCSTR
+UTIL_BasePath(
+   VOID
+);
+
+LPCSTR
+UTIL_SavePath(
+   VOID
+);
+
+#endif

English.lproj/InfoPlist.strings → macos/English.lproj/InfoPlist.strings


Info.plist → macos/Info.plist


+ 31 - 25
Pal.xcodeproj/project.pbxproj

@@ -146,7 +146,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
-		002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = SOURCE_ROOT; };
+		002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../main.c; sourceTree = SOURCE_ROOT; };
 		089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
 		29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
@@ -279,21 +279,21 @@
 		7104FD660D772F6300A97E53 /* video.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; path = video.c; sourceTree = "<group>"; };
 		7104FD670D772F6300A97E53 /* video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = video.h; sourceTree = "<group>"; };
 		7104FD680D772F6300A97E53 /* yj1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yj1.c; sourceTree = "<group>"; };
-		7104FD9A0D772FBC00A97E53 /* binfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = binfile.cpp; path = adplug/binfile.cpp; sourceTree = SOURCE_ROOT; };
-		7104FD9B0D772FBC00A97E53 /* binfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = binfile.h; path = adplug/binfile.h; sourceTree = SOURCE_ROOT; };
-		7104FD9C0D772FBC00A97E53 /* binio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = binio.cpp; path = adplug/binio.cpp; sourceTree = SOURCE_ROOT; };
-		7104FD9D0D772FBC00A97E53 /* binio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = binio.h; path = adplug/binio.h; sourceTree = SOURCE_ROOT; };
-		7104FD9E0D772FBC00A97E53 /* emuopl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = emuopl.cpp; path = adplug/emuopl.cpp; sourceTree = SOURCE_ROOT; };
-		7104FD9F0D772FBC00A97E53 /* emuopl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = emuopl.h; path = adplug/emuopl.h; sourceTree = SOURCE_ROOT; };
-		7104FDA00D772FBC00A97E53 /* fmopl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fmopl.c; path = adplug/fmopl.c; sourceTree = SOURCE_ROOT; };
-		7104FDA10D772FBC00A97E53 /* fmopl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fmopl.h; path = adplug/fmopl.h; sourceTree = SOURCE_ROOT; };
-		7104FDA20D772FBC00A97E53 /* fprovide.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fprovide.cpp; path = adplug/fprovide.cpp; sourceTree = SOURCE_ROOT; };
-		7104FDA30D772FBC00A97E53 /* fprovide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fprovide.h; path = adplug/fprovide.h; sourceTree = SOURCE_ROOT; };
-		7104FDA40D772FBC00A97E53 /* opl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = opl.h; path = adplug/opl.h; sourceTree = SOURCE_ROOT; };
-		7104FDA50D772FBC00A97E53 /* player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = player.cpp; path = adplug/player.cpp; sourceTree = SOURCE_ROOT; };
-		7104FDA60D772FBC00A97E53 /* player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = player.h; path = adplug/player.h; sourceTree = SOURCE_ROOT; };
-		7104FDA70D772FBC00A97E53 /* rix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rix.cpp; path = adplug/rix.cpp; sourceTree = SOURCE_ROOT; };
-		7104FDA80D772FBC00A97E53 /* rix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rix.h; path = adplug/rix.h; sourceTree = SOURCE_ROOT; };
+		7104FD9A0D772FBC00A97E53 /* binfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = binfile.cpp; path = adplug/binfile.cpp; sourceTree = "<group>"; };
+		7104FD9B0D772FBC00A97E53 /* binfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = binfile.h; path = adplug/binfile.h; sourceTree = "<group>"; };
+		7104FD9C0D772FBC00A97E53 /* binio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = binio.cpp; path = adplug/binio.cpp; sourceTree = "<group>"; };
+		7104FD9D0D772FBC00A97E53 /* binio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = binio.h; path = adplug/binio.h; sourceTree = "<group>"; };
+		7104FD9E0D772FBC00A97E53 /* emuopl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = emuopl.cpp; path = adplug/emuopl.cpp; sourceTree = "<group>"; };
+		7104FD9F0D772FBC00A97E53 /* emuopl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = emuopl.h; path = adplug/emuopl.h; sourceTree = "<group>"; };
+		7104FDA00D772FBC00A97E53 /* fmopl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fmopl.c; path = adplug/fmopl.c; sourceTree = "<group>"; };
+		7104FDA10D772FBC00A97E53 /* fmopl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fmopl.h; path = adplug/fmopl.h; sourceTree = "<group>"; };
+		7104FDA20D772FBC00A97E53 /* fprovide.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fprovide.cpp; path = adplug/fprovide.cpp; sourceTree = "<group>"; };
+		7104FDA30D772FBC00A97E53 /* fprovide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fprovide.h; path = adplug/fprovide.h; sourceTree = "<group>"; };
+		7104FDA40D772FBC00A97E53 /* opl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = opl.h; path = adplug/opl.h; sourceTree = "<group>"; };
+		7104FDA50D772FBC00A97E53 /* player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = player.cpp; path = adplug/player.cpp; sourceTree = "<group>"; };
+		7104FDA60D772FBC00A97E53 /* player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = player.h; path = adplug/player.h; sourceTree = "<group>"; };
+		7104FDA70D772FBC00A97E53 /* rix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rix.cpp; path = adplug/rix.cpp; sourceTree = "<group>"; };
+		7104FDA80D772FBC00A97E53 /* rix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = rix.h; path = adplug/rix.h; sourceTree = "<group>"; };
 		71147E3E14085E31003FB2DB /* surroundopl.cpp */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.cpp.cpp; name = surroundopl.cpp; path = adplug/surroundopl.cpp; sourceTree = "<group>"; };
 		71147E3F14085E31003FB2DB /* surroundopl.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = surroundopl.h; path = adplug/surroundopl.h; sourceTree = "<group>"; };
 		7138FD0B1424E4810060DE76 /* demuopl.h */ = {isa = PBXFileReference; fileEncoding = 18446744071562067968; lastKnownFileType = sourcecode.c.h; name = demuopl.h; path = adplug/demuopl.h; sourceTree = "<group>"; };
@@ -333,15 +333,16 @@
 		71E23E8E13F6D1AD001287B6 /* timer.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = timer.h; path = libmad/timer.h; sourceTree = "<group>"; };
 		71E27E030D8C7E2F0048BA16 /* fight.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = fight.c; sourceTree = "<group>"; };
 		71E27E040D8C7E2F0048BA16 /* fight.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = fight.h; sourceTree = "<group>"; };
-		71F0F6D10DAA63B400F88C16 /* ending.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = ending.c; sourceTree = SOURCE_ROOT; };
-		71F0F6D20DAA63B400F88C16 /* ending.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = ending.h; sourceTree = SOURCE_ROOT; };
-		71F0F6D30DAA63B400F88C16 /* itemmenu.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = itemmenu.c; sourceTree = SOURCE_ROOT; };
-		71F0F6D40DAA63B400F88C16 /* itemmenu.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = itemmenu.h; sourceTree = SOURCE_ROOT; };
-		71F0F6D50DAA63B400F88C16 /* magicmenu.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = magicmenu.c; sourceTree = SOURCE_ROOT; };
-		71F0F6D60DAA63B400F88C16 /* magicmenu.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = magicmenu.h; sourceTree = SOURCE_ROOT; };
+		71F0F6D10DAA63B400F88C16 /* ending.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = ending.c; sourceTree = "<group>"; };
+		71F0F6D20DAA63B400F88C16 /* ending.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = ending.h; sourceTree = "<group>"; };
+		71F0F6D30DAA63B400F88C16 /* itemmenu.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = itemmenu.c; sourceTree = "<group>"; };
+		71F0F6D40DAA63B400F88C16 /* itemmenu.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = itemmenu.h; sourceTree = "<group>"; };
+		71F0F6D50DAA63B400F88C16 /* magicmenu.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; path = magicmenu.c; sourceTree = "<group>"; };
+		71F0F6D60DAA63B400F88C16 /* magicmenu.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; path = magicmenu.h; sourceTree = "<group>"; };
 		8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		8D1107320486CEB800E47090 /* Pal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pal.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		C602B0011CEF3E6C003A7B09 /* palcfg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = palcfg.c; sourceTree = "<group>"; };
+		C626FFC31E5BD49100E39DD9 /* pal_config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = pal_config.h; path = macos/pal_config.h; sourceTree = "<group>"; };
 		C65BC11C1CFAF1780037E9A2 /* overlay.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = overlay.c; sourceTree = "<group>"; };
 		C65BC11E1CFAF7790037E9A2 /* audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = audio.c; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -402,6 +403,7 @@
 		29B97315FDCFA39411CA2CEA /* Other Sources */ = {
 			isa = PBXGroup;
 			children = (
+				C626FFC31E5BD49100E39DD9 /* pal_config.h */,
 				7104FD3A0D772F6300A97E53 /* battle.c */,
 				71F0F6D10DAA63B400F88C16 /* ending.c */,
 				71E27E030D8C7E2F0048BA16 /* fight.c */,
@@ -467,6 +469,7 @@
 				C65BC11E1CFAF7790037E9A2 /* audio.c */,
 			);
 			name = "Other Sources";
+			path = ..;
 			sourceTree = "<group>";
 		};
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
@@ -494,7 +497,8 @@
 				5757D21F1B7A3D5800464A74 /* include */,
 				5757D2281B7A3D5800464A74 /* src */,
 			);
-			path = liboggvorbis;
+			name = liboggvorbis;
+			path = ../liboggvorbis;
 			sourceTree = "<group>";
 		};
 		5757D21F1B7A3D5800464A74 /* include */ = {
@@ -669,6 +673,7 @@
 				7104FDA80D772FBC00A97E53 /* rix.h */,
 			);
 			name = adplug;
+			path = ..;
 			sourceTree = "<group>";
 		};
 		71E23E7013F6D188001287B6 /* libmad */ = {
@@ -706,6 +711,7 @@
 				71E23E8E13F6D1AD001287B6 /* timer.h */,
 			);
 			name = libmad;
+			path = ..;
 			sourceTree = "<group>";
 		};
 /* End PBXGroup section */
@@ -889,8 +895,8 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
 				HEADER_SEARCH_PATHS = (
 					/Library/Frameworks/SDL2.framework/Headers,
-					./liboggvorbis/include,
-					./liboggvorbis/src,
+					../liboggvorbis/include,
+					../liboggvorbis/src,
 					"$(HEADER_SEARCH_PATHS)",
 				);
 				INFOPLIST_FILE = Info.plist;

Pal.xcodeproj/project.xcworkspace/contents.xcworkspacedata → macos/Pal.xcodeproj/project.xcworkspace/contents.xcworkspacedata


+ 34 - 0
macos/pal_config.h

@@ -0,0 +1,34 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# ifndef PAL_HAS_JOYSTICKS
+#  define PAL_HAS_JOYSTICKS    1
+# endif
+
+# if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+#  define PAL_ALLOW_KEYREPEAT   1
+#  define PAL_HAS_SDLCD         1
+# endif
+
+# define PAL_PREFIX            "./"
+# define PAL_SAVE_PREFIX       "./"
+
+# define PAL_DEFAULT_WINDOW_WIDTH   640
+# define PAL_DEFAULT_WINDOW_HEIGHT  400
+# define PAL_DEFAULT_FULLSCREEN_HEIGHT 480
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | (gConfig.fFullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0))
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         NULL
+# define PAL_CREDIT           NULL
+# define PAL_PORTYEAR         NULL
+
+# define PAL_HAS_CONFIG_PAGE  1
+
+#endif

sdlpal.icns → macos/sdlpal.icns


+ 6 - 32
main.c

@@ -23,12 +23,6 @@
 
 #include "main.h"
 
-#if defined (NDS) && defined (GEKKO)
-
-# include <fat.h>
-
-#endif
-
 #if defined(LONGJMP_EXIT)
 #include <setjmp.h>
 
@@ -64,20 +58,10 @@ PAL_Init(
 {
    int           e;
 
-#if defined (NDS) && defined (GEKKO)
-   fatInitDefault();
-#endif
-
    //
    // Initialize defaults, video and audio
    //
-#if defined(DINGOO)
-   if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) == -1)
-#elif defined (__WINRT__) || defined (__N3DS__)
-   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)
-#endif
+   if (SDL_Init(PAL_SDL_INIT_FLAGS) == -1)
    {
 #if defined (_WIN32) && SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
       //
@@ -193,19 +177,13 @@ PAL_Shutdown(
    UTIL_CloseLog();
 
    SDL_Quit();
-#if defined(GPH)
-	chdir("/usr/gp2x");
-	execl("./gp2xmenu", "./gp2xmenu", NULL);
-#endif
-	UTIL_Platform_Quit();
+   UTIL_Platform_Quit();
 #if defined(LONGJMP_EXIT)
-	longjmp(g_exit_jmp_buf, exit_code);
+   longjmp(g_exit_jmp_buf, exit_code);
+#elif defined (NDS)
+   while (1);
 #else
-# if defined (NDS)
-	while (1);
-# else
-	exit(exit_code);
-# endif
+   exit(exit_code);
 #endif
 }
 
@@ -547,10 +525,6 @@ main(
 
    UTIL_OpenLog();
 
-#if defined(_WIN32) && SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
-   putenv("SDL_VIDEODRIVER=directx");
-#endif
-
    PAL_LoadConfig(TRUE);
 
    //

+ 0 - 3
palcfg.h

@@ -28,9 +28,6 @@ extern "C"
 # endif
 
 #include "palcommon.h"
-#ifdef __EMSCRIPTEN__
-#include <ctype.h>
-#endif
 
 #define     PAL_MAX_SAMPLERATE           48000
 #define     PAL_MAX_VOLUME               100

+ 1 - 1
psp/Makefile.psp

@@ -14,7 +14,7 @@ OBJS = adplug/binfile.o adplug/emuopl.o adplug/fprovide.o adplug/rix.o \
 PSPSDK = $(shell psp-config --pspsdk-path)
 
 INCDIR = 
-CFLAGS = -O3 -G0 -Wall -g `$(PSPSDK)/../bin/sdl-config --cflags` -DPSP=1
+CFLAGS = -O3 -G0 -Wall -g `$(PSPSDK)/../bin/sdl-config --cflags` -DPSP=1 -I.
 CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti `$(PSPSDK)/../bin/sdl-config --cflags`
 ASFLAGS = $(CFLAGS)
 

+ 9 - 0
psp/main_PSP.c

@@ -34,6 +34,15 @@ PSP_MODULE_INFO("SDLPAL", 0, 1, 1);
 PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
 PSP_HEAP_SIZE_KB(PSP_HEAP_MEMSIZE);
 
+void
+SOUND_Reload(
+	void
+)
+{
+	fclose(gSndPlayer.mkf);
+	SOUND_LoadMKF();
+}
+
 //
 //Exit callback
 //

+ 24 - 0
psp/pal_config.h

@@ -0,0 +1,24 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# define PAL_HAS_JOYSTICKS     0
+# define PAL_PREFIX            "ms0:/"
+# define PAL_SAVE_PREFIX       "ms0:/PSP/SAVEDATA/SDLPAL/"
+
+# define PAL_DEFAULT_WINDOW_WIDTH   320
+# define PAL_DEFAULT_WINDOW_HEIGHT  240
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | SDL_FULLSCREEN)
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+# define PAL_SCALE_SCREEN   FALSE
+
+# define PAL_PLATFORM         "Sony PSP"
+# define PAL_CREDIT           "(Unknown)"
+# define PAL_PORTYEAR         "2011"
+
+#endif

+ 4 - 4
resampler.c

@@ -3,10 +3,10 @@
 #define _USE_MATH_DEFINES
 #include <math.h>
 #if !defined(__MINGW32__) && !defined(__EMSCRIPTEN__)
-#if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__))
-#include <xmmintrin.h>
-#define RESAMPLER_SSE
-#endif
+# if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__))
+#  include <xmmintrin.h>
+#  define RESAMPLER_SSE
+# endif
 #endif
 
 #ifdef _MSC_VER

+ 0 - 11
sound.c

@@ -1031,14 +1031,3 @@ SOUND_Init(
 
 	return NULL;
 }
-
-#ifdef PSP
-void
-SOUND_Reload(
-	void
-	)
-{
-	fclose(gSndPlayer.mkf);
-	SOUND_LoadMKF();
-}
-#endif

+ 1 - 1
uigame.c

@@ -2011,7 +2011,7 @@ PAL_QuitGame(
    VOID
 )
 {
-#ifndef __N3DS__
+#if PAL_HAS_CONFIG_PAGE
 	WORD wReturnValue = PAL_TripleMenu(SYSMENU_LABEL_LAUNCHSETTING);
 #else
 	WORD wReturnValue = PAL_ConfirmMenu(); // No config menu available

+ 1 - 1
unix/Makefile

@@ -8,7 +8,7 @@ CFILES = $(wildcard ../adplug/*.c) $(wildcard ../libmad/*.c) $(wildcard ../libog
 CPPFILES = $(wildcard ../adplug/*.cpp) $(wildcard ../*.cpp) $(wildcard ./*.cpp)
 OBJFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CCFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
+CCFLAGS = `sdl2-config --cflags` -g -Wall -O2 -fno-strict-aliasing -I. -I../ -I../liboggvorbis/include -I../liboggvorbis/src -DPAL_HAS_PLATFORM_SPECIFIC_UTILS
 CXXFLAGS = $(CCFLAGS) -std=c++11 `fltk-config --cxxflags`
 CFLAGS = $(CCFLAGS) -std=gnu99 `fltk-config --cflags`
 LDFLAGS = `sdl2-config --libs` `fltk-config --ldflags` -lstdc++ -lm

+ 35 - 0
unix/pal_config.h

@@ -0,0 +1,35 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# ifndef PAL_HAS_JOYSTICKS
+#  define PAL_HAS_JOYSTICKS    1
+# endif
+
+# if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+#  define PAL_ALLOW_KEYREPEAT   1
+#  define PAL_HAS_SDLCD         1
+# endif
+
+# define PAL_PREFIX            "./"
+# define PAL_SAVE_PREFIX       "./"
+
+# define PAL_DEFAULT_WINDOW_WIDTH   640
+# define PAL_DEFAULT_WINDOW_HEIGHT  400
+# define PAL_DEFAULT_FULLSCREEN_HEIGHT 480
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | (gConfig.fFullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0))
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+#  define PAL_FATAL_OUTPUT(s)   system(va("beep; xmessage -center \"FATAL ERROR: %s\"", (s)))
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+# define PAL_PLATFORM         NULL
+# define PAL_CREDIT           NULL
+# define PAL_PORTYEAR         NULL
+
+# define PAL_HAS_CONFIG_PAGE  1
+
+#endif

+ 2 - 11
util.c

@@ -330,16 +330,7 @@ TerminateOnError(
 	  PAL_Shutdown(255);
    }
 #else
-
-# if defined(_WIN32)
-   MessageBoxA(0, string, "FATAL ERROR", MB_ICONERROR);
-# elif defined(__linux__)
-   system(va("beep; xmessage -center \"FATAL ERROR: %s\"", string));
-# elif defined(__SYMBIAN32__)
-   UTIL_WriteLog(LOG_DEBUG,"[0x%08x][%s][%s] - %s",(long)TerminateOnError,"TerminateOnError",__FILE__, string);
-   SDL_Delay(3000);
-# endif
-
+   PAL_FATAL_OUTPUT(string);
 #endif
 
 #ifdef _DEBUG
@@ -497,7 +488,7 @@ UTIL_OpenFileForMode(
 	else
 		fp = fopen(va("%s%s", gConfig.pszGamePath, lpszFileName), szMode);
 
-#if !(defined(_WIN32) || defined(__N3DS__))
+#if !defined(PAL_FILESYSTEM_IGNORE_CASE)
 	if (fp == NULL)
 	{
 		//

+ 0 - 25
util.h

@@ -108,26 +108,6 @@ UTIL_CloseFile(
    FILE                *fp
 );
 
-LPCSTR
-UTIL_BasePath(
-   VOID
-);
-
-LPCSTR
-UTIL_SavePath(
-   VOID
-);
-
-LPCSTR
-UTIL_ConfigPath(
-   VOID
-);
-
-LPCSTR
-UTIL_ScreenShotPath(
-	VOID
-);
-
 BOOL
 UTIL_GetScreenSize(
    DWORD *pdwScreenWidth,
@@ -139,11 +119,6 @@ UTIL_IsAbsolutePath(
 	LPCSTR  lpszFileName
 );
 
-BOOL
-UTIL_TouchEnabled(
-   VOID
-);
-
 INT
 UTIL_Platform_Init(
    int argc,

+ 7 - 24
video.c

@@ -20,9 +20,6 @@
 //
 
 #include "main.h"
-#ifndef __WIN32__
-#include <sys/time.h>
-#endif
 
 // Screen buffer
 SDL_Surface              *gpScreen           = NULL;
@@ -44,11 +41,7 @@ static SDL_Surface       *gpScreenReal       = NULL;
 
 volatile BOOL g_bRenderPaused = FALSE;
 
-#if (defined (__SYMBIAN32__) && !defined (__S60_5X__)) || defined (PSP) || defined (GEKKO) || defined(__N3DS__)
-   static BOOL bScaleScreen = FALSE;
-#else
-   static BOOL bScaleScreen = TRUE;
-#endif
+static BOOL bScaleScreen = PAL_SCALE_SCREEN;
 
 // Shake times and level
 static WORD               g_wShakeTime       = 0;
@@ -571,7 +564,7 @@ VIDEO_SetPalette(
    SDL_SetPalette(gpScreen, SDL_LOGPAL | SDL_PHYSPAL, rgPalette, 0, 256);
    SDL_SetPalette(gpScreenBak, SDL_LOGPAL | SDL_PHYSPAL, rgPalette, 0, 256);
    SDL_SetPalette(gpScreenReal, SDL_LOGPAL | SDL_PHYSPAL, rgPalette, 0, 256);
-#if (defined (__SYMBIAN32__)) || (defined (__N3DS__))
+# if defined(PAL_FORCE_UPDATE_ON_PALETTE_SET)
    {
       static UINT32 time = 0;
       if (SDL_GetTicks() - time > 50)
@@ -580,7 +573,7 @@ VIDEO_SetPalette(
 	      time = SDL_GetTicks();
       }
    }
-#endif
+# endif
 #endif
 }
 
@@ -634,18 +627,10 @@ VIDEO_Resize(
 
    if (gpScreenReal == NULL)
    {
-#ifdef __SYMBIAN32__
-#ifdef __S60_5X__
-      gpScreenReal = SDL_SetVideoMode(640, 360, 8, SDL_SWSURFACE);
-#else
-      gpScreenReal = SDL_SetVideoMode(320, 240, 8, SDL_SWSURFACE);
-#endif
-#else
       //
-      // Fall back to 640x480 software windowed mode.
+      // Fall back to software windowed mode in default size.
       //
-      gpScreenReal = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);
-#endif
+      gpScreenReal = SDL_SetVideoMode(PAL_DEFAULT_WINDOW_WIDTH, PAL_DEFAULT_WINDOW_HEIGHT, 8, SDL_SWSURFACE);
    }
 
    SDL_SetPalette(gpScreenReal, SDL_PHYSPAL | SDL_LOGPAL, palette, 0, i);
@@ -686,7 +671,7 @@ VIDEO_ToggleScaleScreen(
 /*++
   Purpose:
 
-    Toggle scalescreen mode.
+    Toggle scalescreen mode, only used in some platforms.
 
   Parameters:
 
@@ -698,11 +683,9 @@ VIDEO_ToggleScaleScreen(
 
 --*/
 {
-#ifdef __SYMBIAN32__
    bScaleScreen = !bScaleScreen;
-   VIDEO_Resize(320, 240);
+   VIDEO_Resize(PAL_DEFAULT_WINDOW_WIDTH, PAL_DEFAULT_WINDOW_HEIGHT);
    VIDEO_UpdateScreen(NULL);
-#endif
 }
 
 VOID

+ 3 - 3
wii/Makefile.wii

@@ -2,12 +2,12 @@ TARGET = boot
 
 HOST = powerpc-eabi-
 
-SOURCES = . ./adplug
-CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
+SOURCES = . .. ../adplug
+CFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c)) 
 CPPFILES = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
 OFILES = $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
 
-CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGEKKO -DPAL_CLASSIC
+CFLAGS = -g -Wall -O2 `sdl-config --cflags` -DGEKKO -DPAL_HAS_PLATFORM_SPECIFIC_UTILS -I.
 CXXFLAGS = $(CFLAGS)
 LDFLAGS = `sdl-config --libs` -DGEKKO -mrvl
 

+ 25 - 0
wii/pal_config.h

@@ -0,0 +1,25 @@
+#ifndef PAL_CONFIG_H
+# define PAL_CONFIG_H
+
+# define PAL_HAS_JOYSTICKS     1
+# define PAL_HAS_MOUSE         0
+# define PAL_PREFIX            "SD:/apps/sdlpal/"
+# define PAL_SAVE_PREFIX       "SD:/apps/sdlpal/"
+
+# define PAL_DEFAULT_WINDOW_WIDTH   640
+# define PAL_DEFAULT_WINDOW_HEIGHT  480
+
+# if SDL_VERSION_ATLEAST(2,0,0)
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE)
+# else
+#  define PAL_VIDEO_INIT_FLAGS  (SDL_SWSURFACE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+# endif
+
+# define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+# define PAL_SCALE_SCREEN   FALSE
+
+# define PAL_PLATFORM         "Nintendo WII"
+# define PAL_CREDIT           "Rikku2000"
+# define PAL_PORTYEAR         "2012"
+
+#endif

+ 87 - 0
wii/pal_utils.c

@@ -0,0 +1,87 @@
+
+#include "main.h"
+#include <fat.h>
+
+static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
+{
+	switch (lpEvent->type)
+	{
+	case SDL_JOYHATMOTION:
+		switch (lpEvent->jhat.value)
+		{
+		case SDL_HAT_LEFT:
+			state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+			state->dir = kDirWest;
+			state->dwKeyPress = kKeyLeft;
+			break;
+
+		case SDL_HAT_RIGHT:
+			state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+			state->dir = kDirEast;
+			state->dwKeyPress = kKeyRight;
+			break;
+
+		case SDL_HAT_UP:
+			state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+			state->dir = kDirNorth;
+			state->dwKeyPress = kKeyUp;
+			break;
+
+		case SDL_HAT_DOWN:
+			state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
+			state->dir = kDirSouth;
+			state->dwKeyPress = kKeyDown;
+			break;
+		}
+		return 1;
+
+	case SDL_JOYBUTTONDOWN:
+		switch (lpEvent->jbutton.button)
+		{
+		case 2:
+			state->dwKeyPress |= kKeyMenu;
+			return 1;
+
+		case 3:
+			state->dwKeyPress |= kKeySearch;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+BOOL
+UTIL_GetScreenSize(
+	DWORD *pdwScreenWidth,
+	DWORD *pdwScreenHeight
+)
+{
+	return FALSE;
+}
+
+BOOL
+UTIL_IsAbsolutePath(
+	LPCSTR  lpszFileName
+)
+{
+	return FALSE;
+}
+
+INT
+UTIL_Platform_Init(
+	int argc,
+	char* argv[]
+)
+{
+	fatInitDefault();
+	PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
+	gConfig.fLaunchSetting = FALSE;
+	return 0;
+}
+
+VOID
+UTIL_Platform_Quit(
+	VOID
+)
+{
+}

+ 38 - 0
win32/pal_config.h

@@ -0,0 +1,38 @@
+#pragma once
+
+#ifndef PAL_HAS_JOYSTICKS
+# define PAL_HAS_JOYSTICKS    1
+#endif
+
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+# define PAL_ALLOW_KEYREPEAT   1
+# define PAL_HAS_SDLCD         1
+#endif
+
+#define PAL_PREFIX            "./"
+#define PAL_SAVE_PREFIX       "./"
+
+#define PAL_DEFAULT_WINDOW_WIDTH   640
+#define PAL_DEFAULT_WINDOW_HEIGHT  400
+#define PAL_DEFAULT_FULLSCREEN_HEIGHT 480
+
+#if SDL_VERSION_ATLEAST(2,0,0)
+# define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | (gConfig.fFullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0))
+#else
+# define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+# define PAL_FATAL_OUTPUT(s)   MessageBoxA(0, (s), "FATAL ERROR", MB_ICONERROR)
+#endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_CDROM | SDL_INIT_NOPARACHUTE | SDL_INIT_JOYSTICK)
+
+#define PAL_PLATFORM         NULL
+#define PAL_CREDIT           NULL
+#define PAL_PORTYEAR         NULL
+
+#define PAL_HAS_NATIVEMIDI  1
+
+#define PAL_HAS_CONFIG_PAGE 1
+
+#define PAL_FILESYSTEM_IGNORE_CASE 1
+
+#define PAL_HAS_NATIVEMIDI  1

+ 5 - 4
win32/sdlpal.vcxproj

@@ -97,7 +97,7 @@
       </HeaderFileName>
     </Midl>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.\;..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -126,7 +126,7 @@
       </HeaderFileName>
     </Midl>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.\;..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -155,7 +155,7 @@
       </HeaderFileName>
     </Midl>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.\;..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -186,7 +186,7 @@
       </HeaderFileName>
     </Midl>
     <ClCompile>
-      <AdditionalIncludeDirectories>..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.\;..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>PAL_HAS_PLATFORM_SPECIFIC_UTILS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -414,6 +414,7 @@
     <ClInclude Include="..\libmad\stream.h" />
     <ClInclude Include="..\libmad\synth.h" />
     <ClInclude Include="..\libmad\timer.h" />
+    <ClInclude Include="pal_config.h" />
     <ClInclude Include="resource.h" />
   </ItemGroup>
   <ItemGroup>

+ 3 - 0
win32/sdlpal.vcxproj.filters

@@ -652,6 +652,9 @@
     <ClInclude Include="..\audio.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="pal_config.h">
+      <Filter>platform</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\sdlpal.ico">

+ 4 - 0
win32/win32.cpp

@@ -265,6 +265,10 @@ INT_PTR CALLBACK LauncherDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
 
 extern "C" int UTIL_Platform_Init(int argc, char* argv[])
 {
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+	putenv("SDL_VIDEODRIVER=directx");
+#endif
+
 	g_hInstance = GetModuleHandle(nullptr);
 #ifndef __MINGW32__ // mingw's windows sdk dont support GetThreadUILanguage, since it's a vista+ API
 	g_wLanguage = GetThreadUILanguage();

+ 12 - 2
winrt/SDLPal.Common/WinRTUtil.cpp

@@ -6,8 +6,7 @@
 #include <ppltasks.h>
 #include "../SDLPal.Common/AsyncHelper.h"
 #include "../SDLPal.Common/StringHelper.h"
-#include "../../global.h"
-#include "../../palcfg.h"
+#include "../../main.h"
 
 #include "SDL.h"
 #include "SDL_endian.h"
@@ -149,6 +148,17 @@ static int SDLCALL WinRT_EventFilter(void *userdata, SDL_Event * event)
 	return 0;
 }
 
+static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
+{
+	if (lpEvent->type == SDL_KEYDOWN &&
+		lpEvent->key.keysym.sym == SDLK_AC_BACK &&
+		!gpGlobals->fInMainGame)
+	{
+		PAL_Shutdown(0);
+	}
+	return 0;
+}
+
 extern "C"
 INT UTIL_Platform_Init(int argc, char* argv[])
 {

+ 7 - 6
winrt/SDLPal.UWP/SDLPal.Core.vcxproj

@@ -132,7 +132,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -146,7 +146,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -160,7 +160,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -174,7 +174,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -188,7 +188,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -202,7 +202,7 @@
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <CompileAsWinRT>false</CompileAsWinRT>
       <SDLCheck>true</SDLCheck>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
@@ -324,6 +324,7 @@
     <ClInclude Include="..\..\uigame.h" />
     <ClInclude Include="..\..\util.h" />
     <ClInclude Include="..\..\video.h" />
+    <ClInclude Include="..\pal_config.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\adlibemu.c" />

+ 3 - 0
winrt/SDLPal.UWP/SDLPal.Core.vcxproj.filters

@@ -374,6 +374,9 @@
     <ClInclude Include="..\..\palcfg.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\pal_config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\binfile.cpp">

+ 6 - 6
winrt/SDLPal.UWP/SDLPal.UWP.vcxproj

@@ -135,7 +135,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
@@ -148,7 +148,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
@@ -161,7 +161,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
@@ -174,7 +174,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
@@ -187,7 +187,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>
@@ -200,7 +200,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common;$(OutDir)../SDLPal.Core</AdditionalLibraryDirectories>

+ 7 - 6
winrt/SDLPal.Windows/SDLPal.Core.vcxproj

@@ -133,7 +133,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -144,7 +144,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -155,7 +155,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -166,7 +166,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -177,7 +177,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -188,7 +188,7 @@
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <PreprocessorDefinitions>LONGJMP_EXIT;PAL_HAS_PLATFORM_SPECIFIC_UTILS;_CRT_SECURE_NO_WARNINGS;__WINRT__=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
@@ -306,6 +306,7 @@
     <ClInclude Include="..\..\uigame.h" />
     <ClInclude Include="..\..\util.h" />
     <ClInclude Include="..\..\video.h" />
+    <ClInclude Include="..\pal_config.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\adlibemu.c" />

+ 3 - 0
winrt/SDLPal.Windows/SDLPal.Core.vcxproj.filters

@@ -374,6 +374,9 @@
     <ClInclude Include="..\..\palcfg.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\pal_config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\binfile.cpp">

+ 6 - 6
winrt/SDLPal.Windows/SDLPal.vcxproj

@@ -132,7 +132,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>
@@ -145,7 +145,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>
@@ -158,7 +158,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>
@@ -171,7 +171,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>
@@ -184,7 +184,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>
@@ -197,7 +197,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalLibraryDirectories>$(OutDir)../SDLPal.Common.Windows;$(OutDir)../SDLPal.Core.Windows</AdditionalLibraryDirectories>

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

@@ -85,7 +85,7 @@
     <ClCompile>
       <PreprocessorDefinitions>LONGJMP_EXIT;_CRT_SECURE_NO_WARNINGS;PAL_HAS_PLATFORM_SPECIFIC_UTILS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
@@ -100,7 +100,7 @@
     <ClCompile>
       <PreprocessorDefinitions>LONGJMP_EXIT;_CRT_SECURE_NO_WARNINGS;PAL_HAS_PLATFORM_SPECIFIC_UTILS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
@@ -115,7 +115,7 @@
     <ClCompile>
       <PreprocessorDefinitions>LONGJMP_EXIT;_CRT_SECURE_NO_WARNINGS;PAL_HAS_PLATFORM_SPECIFIC_UTILS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
@@ -130,7 +130,7 @@
     <ClCompile>
       <PreprocessorDefinitions>LONGJMP_EXIT;_CRT_SECURE_NO_WARNINGS;PAL_HAS_PLATFORM_SPECIFIC_UTILS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
-      <AdditionalIncludeDirectories>..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\..\liboggvorbis\include;$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <CompileAsWinRT>false</CompileAsWinRT>
       <DisableSpecificWarnings>
       </DisableSpecificWarnings>
@@ -251,6 +251,7 @@
     <ClInclude Include="..\..\uigame.h" />
     <ClInclude Include="..\..\util.h" />
     <ClInclude Include="..\..\video.h" />
+    <ClInclude Include="..\pal_config.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\adlibemu.c" />

+ 3 - 0
winrt/SDLPal.WindowsPhone/SDLPal.Core.vcxproj.filters

@@ -374,6 +374,9 @@
     <ClInclude Include="..\..\palcfg.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\pal_config.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\adplug\binfile.cpp">

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

@@ -98,7 +98,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -111,7 +111,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -124,7 +124,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlibd.lib;msvcrtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -137,7 +137,7 @@
       <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
       <DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
       <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\;..\SDLPal.Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <AdditionalDependencies>dxgi.lib;dxguid.lib;sdlpal.core.lib;sdlpal.common.lib;vccorlib.lib;msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>

+ 51 - 0
winrt/pal_config.h

@@ -0,0 +1,51 @@
+#pragma once
+
+#define PAL_PREFIX            UTIL_BasePath()
+#define PAL_SAVE_PREFIX       UTIL_SavePath()
+#define PAL_CONFIG_PREFIX     UTIL_ConfigPath()
+#define PAL_SCREENSHOT_PREFIX UTIL_ScreenShotPath()
+#define PAL_HAS_TOUCH         1
+#define PAL_AUDIO_DEFAULT_BUFFER_SIZE   4096
+#define PAL_DEFAULT_WINDOW_WIDTH   320
+#define PAL_DEFAULT_WINDOW_HEIGHT  200
+
+#if SDL_VERSION_ATLEAST(2,0,0)
+# define PAL_VIDEO_INIT_FLAGS  (SDL_WINDOW_SHOWN)
+#else
+# define PAL_VIDEO_INIT_FLAGS  (SDL_HWSURFACE | SDL_RESIZABLE | (gConfig.fFullScreen ? SDL_FULLSCREEN : 0))
+#endif
+
+#define PAL_SDL_INIT_FLAGS	(SDL_INIT_VIDEO | SDL_INIT_AUDIO)
+
+#define PAL_PLATFORM         "Windows Runtime"
+#define PAL_CREDIT           "(Unknown)"
+#define PAL_PORTYEAR         "2015"
+
+#define PAL_HAS_CONFIG_PAGE  1
+
+#define PAL_FILESYSTEM_IGNORE_CASE 1
+
+LPCSTR
+UTIL_BasePath(
+   VOID
+);
+
+LPCSTR
+UTIL_SavePath(
+   VOID
+);
+
+LPCSTR
+UTIL_ConfigPath(
+   VOID
+);
+
+LPCSTR
+UTIL_ScreenShotPath(
+   VOID
+);
+
+BOOL
+UTIL_TouchEnabled(
+   VOID
+);