Browse Source

Compilation fix

louyihua 8 years ago
parent
commit
0d76153910
9 changed files with 47 additions and 30 deletions
  1. 1 1
      Makefile
  2. 21 0
      common.h
  3. 16 17
      input.c
  4. 0 1
      itemmenu.c
  5. 4 0
      libmad/music_mad.c
  6. 1 1
      liboggvorbis/include/ogg/config_types.h
  7. 2 8
      oggplay.c
  8. 1 1
      rixplay.cpp
  9. 1 1
      yj1.c

+ 1 - 1
Makefile

@@ -32,7 +32,7 @@ FILES += $(ADPLUG_FILES)
 FILES += $(LIBMAD_FILES)
 FILES += $(LIBOGGVORBIS_FILES)
 
-CFLAGS = `sdl-config --cflags` -g -Wall -O2 -fno-strict-aliasing
+CFLAGS = `sdl-config --cflags` -g -Wall -O2 -fno-strict-aliasing -Iliboggvorbis/include -Iliboggvorbis/src
 LDFLAGS = `sdl-config --libs` -lstdc++ -lm
 
 $(TARGET):

+ 21 - 0
common.h

@@ -74,6 +74,23 @@ extern "C"
 #define min(a, b)    (((a) < (b)) ? (a) : (b))
 #endif
 
+/* This is need when compiled with SDL 1.2 */
+#ifndef SDL_FORCE_INLINE
+#if defined(_MSC_VER)
+#define SDL_FORCE_INLINE __forceinline
+#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
+#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
+#else
+#define SDL_FORCE_INLINE static SDL_INLINE
+#endif
+#endif /* SDL_FORCE_INLINE not defined */
+
+#if defined(_MSC_VER)
+#define PAL_FORCE_INLINE static SDL_FORCE_INLINE
+#else
+#define PAL_FORCE_INLINE SDL_FORCE_INLINE
+#endif
+
 #if defined (__SYMBIAN32__)
 
 #undef  _WIN32
@@ -160,6 +177,10 @@ FILE *MY_fopen(const char *path, const char *mode);
 #define SDL_INIT_CDROM        0	  /* Compatibility with SDL 1.2 */
 #endif
 
+#ifndef SDL_AUDIO_BITSIZE
+# define SDL_AUDIO_BITSIZE(x)         (x & 0xFF)
+#endif
+
 #ifdef _WIN32
 
 #include <windows.h>

+ 16 - 17
input.c

@@ -25,7 +25,12 @@
 #include <math.h>
 
 volatile PALINPUTSTATE   g_InputState;
+#if PAL_HAS_JOYSTICKS
 static SDL_Joystick     *g_pJoy = NULL;
+#endif
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
+#define SDL_JoystickNameForIndex SDL_JoystickName
+#endif
 BOOL                     g_fUseJoystick = TRUE;
 
 #if defined(GPH)
@@ -488,7 +493,7 @@ PAL_JoystickEventFilter(
 
 --*/
 {
-#ifdef PAL_HAS_JOYSTICKS
+#if PAL_HAS_JOYSTICKS
    switch (lpEvent->type)
    {
 #if defined (GEKKO)
@@ -1025,25 +1030,19 @@ PAL_InitInput(
    //
    // Check for joystick
    //
-#ifdef PAL_HAS_JOYSTICKS
+#if PAL_HAS_JOYSTICKS
    if (SDL_NumJoysticks() > 0 && g_fUseJoystick)
    {
-      g_pJoy = SDL_JoystickOpen(0);
-
-      //
-      // HACKHACK: applesmc and Android Accelerometer shouldn't be considered as real joysticks
-      //
-      if (strcmp(SDL_JoystickName(g_pJoy), "applesmc") == 0 || strcmp(SDL_JoystickName(g_pJoy), "Android Accelerometer") == 0)
+      int i;
+	  for (i = 0; i < SDL_NumJoysticks(); i++)
       {
-         SDL_JoystickClose(g_pJoy);
-
-         if (SDL_NumJoysticks() > 1)
-         {
-            g_pJoy = SDL_JoystickOpen(1);
-         }
-         else
+         //
+         // HACKHACK: applesmc and Android Accelerometer shouldn't be considered as real joysticks
+         //
+         if (strcmp(SDL_JoystickNameForIndex(i), "applesmc") != 0 && strcmp(SDL_JoystickNameForIndex(i), "Android Accelerometer") != 0)
          {
-            g_pJoy = NULL;
+            g_pJoy = SDL_JoystickOpen(i);
+            break;
          }
       }
 
@@ -1078,7 +1077,7 @@ PAL_ShutdownInput(
 
 --*/
 {
-#ifdef PAL_HAS_JOYSTICKS
+#if PAL_HAS_JOYSTICKS
 #if SDL_VERSION_ATLEAST(2,0,0)
    if (g_pJoy != NULL)
    {

+ 0 - 1
itemmenu.c

@@ -54,7 +54,6 @@ PAL_ItemSelectMenuUpdate(
    const int          iItemsPerLine = 34 / gpGlobals->dwWordLength;
    const int          iItemTextWidth = 8 * gpGlobals->dwWordLength + 20;
    const int          iLinesPerPage = 7 - gpGlobals->dwExtraItemDescLines;
-   const int          iBoxHeightOffset = gpGlobals->dwExtraItemDescLines * 16;
    const int          iCursorXOffset = gpGlobals->dwWordLength * 5 / 2;
    const int          iAmountXOffset = gpGlobals->dwWordLength * 8 + 1;
    const int          iPageLineOffset = (iLinesPerPage + 1) / 2;

+ 4 - 0
libmad/music_mad.c

@@ -26,6 +26,10 @@
 #include "music_mad.h"
 #include "../resampler.h" /* SDLPAL */
 
+#ifndef SDL_AUDIO_BITSIZE
+# define SDL_AUDIO_BITSIZE(x)         (x & 0xFF)
+#endif
+
 mad_data *
 mad_openFile(const char *filename, SDL_AudioSpec *mixer, int resampler_quality) {
   SDL_RWops *rw;

+ 1 - 1
liboggvorbis/include/ogg/config_types.h

@@ -2,7 +2,7 @@
 #ifndef _CONFIG_TYPES_H
 #define _CONFIG_TYPES_H
 
-#if defined(__ANDROID__) || defined(__IOS__)
+#if defined(__ANDROID__) || defined(__IOS__) || defined(__linux__)
 
 /* Android or iOS compiler */
 #	include <stdint.h>

+ 2 - 8
oggplay.c

@@ -43,12 +43,6 @@
 
 #define OGG_BUFFER_LENGTH 4096
 
-#if defined(_MSC_VER)
-#define FORCE_INLINE static SDL_FORCE_INLINE
-#else
-#define FORCE_INLINE SDL_FORCE_INLINE
-#endif
-
 typedef struct tagOGGPLAYER
 {
 	MUSICPLAYER_FUNCTIONS;
@@ -72,7 +66,7 @@ typedef struct tagOGGPLAYER
 	BOOL             fUseResampler;
 } OGGPLAYER, *LPOGGPLAYER;
 
-FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
+PAL_FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
 {
 	int val = (int)(floor(pcm * 32767.f + .5f) * volume);
 	/* might as well guard against clipping */
@@ -85,7 +79,7 @@ FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
 	return (ogg_int16_t)val;
 }
 
-FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
+PAL_FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
 {
 	if (gpGlobals->iAudioChannels == 2) {
 		stream[0] = SDL_SwapLE16(resampler_get_and_remove_sample(player->resampler[0]));

+ 1 - 1
rixplay.cpp

@@ -17,6 +17,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+#include <math.h>
 #include "global.h"
 #include "players.h"
 #include "sound.h"
@@ -78,7 +79,6 @@ RIX_FillBuffer(
 --*/
 {
 	LPRIXPLAYER pRixPlayer = (LPRIXPLAYER)object;
-	const INT block_size = SDL_AUDIO_BITSIZE(SOUND_GetAudioSpec()->format) * SOUND_GetAudioSpec()->channels;
 	const INT max_volume = gpGlobals->iVolume * 3 / 4;
 
 	if (pRixPlayer == NULL || !pRixPlayer->fReady)

+ 1 - 1
yj1.c

@@ -349,7 +349,7 @@ static int yj2_build_tree(YJ2_Tree *tree)
 	return 1;
 }
 
-static int yj2_bt(const char* data, unsigned int pos)
+static int yj2_bt(const unsigned char* data, unsigned int pos)
 {
 	return (data[pos >> 3] & (unsigned char)(1 << (pos & 0x7))) >> (pos & 0x7);
 }