浏览代码

Compilation fix for non-WIN systems (cont.)

louyihua 8 年之前
父节点
当前提交
56cbdfb63f
共有 13 个文件被更改,包括 49 次插入16 次删除
  1. 1 1
      README.txt
  2. 2 1
      android/jni/src/Android.mk
  3. 22 0
      config_types.h
  4. 1 1
      input.c
  5. 1 1
      main.c
  6. 1 1
      main.h
  7. 10 4
      oggplay.c
  8. 1 1
      rixplay.cpp
  9. 1 0
      sdlpal.vcxproj
  10. 3 0
      sdlpal.vcxproj.filters
  11. 3 3
      sound.c
  12. 1 1
      uigame.c
  13. 2 2
      util.c

+ 1 - 1
README.txt

@@ -96,7 +96,7 @@ sure to use lower-case file name in UNIX-like operating systems) in the game
 directory created by the above step. If no configuration file exists, SDLPAL
 directory created by the above step. If no configuration file exists, SDLPAL
 uses default values that supports the original resources of DOS version.
 uses default values that supports the original resources of DOS version.
 
 
-Please refer the 'sdlpal.cfg.example' in src directory for its format.
+Please refer to the 'sdlpal.cfg.example' for configuration file format.
 
 
 
 
 -END OF FILE-
 -END OF FILE-

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

@@ -5,8 +5,9 @@ include $(CLEAR_VARS)
 LOCAL_MODULE := main
 LOCAL_MODULE := main
 
 
 SDL_PATH := ../SDL2
 SDL_PATH := ../SDL2
+OGG_PATH := ../../../liboggvorbis
 
 
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include ../../../liboggvorbis/include
+LOCAL_C_INCLUDES := $(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 \
 LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
 	../../../battle.c \
 	../../../battle.c \

+ 22 - 0
config_types.h

@@ -0,0 +1,22 @@
+
+#ifndef _CONFIG_TYPES_H
+#define _CONFIG_TYPES_H
+
+#if defined(__ANDROID__) || defined(__IOS__)
+
+/* Android or iOS compiler */
+#	include <stdint.h>
+typedef int16_t ogg_int16_t;
+typedef uint16_t ogg_uint16_t;
+typedef int32_t ogg_int32_t;
+typedef uint32_t ogg_uint32_t;
+typedef int64_t ogg_int64_t;
+
+#else
+
+#	error You should add the definitions of ogg_*_t types for your platform here.
+
+#endif
+
+#endif
+

+ 1 - 1
input.c

@@ -1115,7 +1115,7 @@ PAL_ProcessEvent(
 
 
 --*/
 --*/
 {
 {
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
    MIDI_CheckLoop();
    MIDI_CheckLoop();
 #endif
 #endif
    while (PAL_PollEvent(NULL));
    while (PAL_PollEvent(NULL));

+ 1 - 1
main.c

@@ -585,7 +585,7 @@ main(
          g_fUseJoystick = FALSE;
          g_fUseJoystick = FALSE;
          break;
          break;
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
       case 'm':
       case 'm':
          //
          //
          // Use MIDI music
          // Use MIDI music

+ 1 - 1
main.h

@@ -49,7 +49,7 @@
 #include "play.h"
 #include "play.h"
 #include "game.h"
 #include "game.h"
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
 #include "midi.h"
 #endif
 #endif
 
 

+ 10 - 4
oggplay.c

@@ -17,7 +17,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 //
 
 
-// This file is based on the decoder_example.c from libvorbis-1.3.4.
+// This file uses some code from decoder_example.c in libvorbis-1.3.4.
 
 
 #include "util.h"
 #include "util.h"
 #include "global.h"
 #include "global.h"
@@ -25,7 +25,7 @@
 #include "sound.h"
 #include "sound.h"
 #include <math.h>
 #include <math.h>
 #if PAL_HAS_OGG
 #if PAL_HAS_OGG
-#include <vorbis\vorbisfile.h>
+#include <vorbis/vorbisfile.h>
 
 
 #include "resampler.h"
 #include "resampler.h"
 
 
@@ -43,6 +43,12 @@
 
 
 #define OGG_BUFFER_LENGTH 4096
 #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
 typedef struct tagOGGPLAYER
 {
 {
 	MUSICPLAYER_FUNCTIONS;
 	MUSICPLAYER_FUNCTIONS;
@@ -66,7 +72,7 @@ typedef struct tagOGGPLAYER
 	BOOL             fUseResampler;
 	BOOL             fUseResampler;
 } OGGPLAYER, *LPOGGPLAYER;
 } OGGPLAYER, *LPOGGPLAYER;
 
 
-static SDL_FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
+FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
 {
 {
 	int val = (int)(floor(pcm * 32767.f + .5f) * volume);
 	int val = (int)(floor(pcm * 32767.f + .5f) * volume);
 	/* might as well guard against clipping */
 	/* might as well guard against clipping */
@@ -79,7 +85,7 @@ static SDL_FORCE_INLINE ogg_int16_t OGG_GetSample(float pcm, double volume)
 	return (ogg_int16_t)val;
 	return (ogg_int16_t)val;
 }
 }
 
 
-static SDL_FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
+FORCE_INLINE void OGG_FillResample(LPOGGPLAYER player, ogg_int16_t* stream)
 {
 {
 	if (gpGlobals->iAudioChannels == 2) {
 	if (gpGlobals->iAudioChannels == 2) {
 		stream[0] = SDL_SwapLE16(resampler_get_and_remove_sample(player->resampler[0]));
 		stream[0] = SDL_SwapLE16(resampler_get_and_remove_sample(player->resampler[0]));

+ 1 - 1
rixplay.cpp

@@ -213,7 +213,7 @@ RIX_FillBuffer(
 						int to_write = resampler_get_free_count(pRixPlayer->resampler[0]);
 						int to_write = resampler_get_free_count(pRixPlayer->resampler[0]);
 						if (to_write)
 						if (to_write)
 						{
 						{
-							short *tempBuf = (short*)_alloca(to_write * gpGlobals->iAudioChannels * sizeof(short));
+							short *tempBuf = (short*)alloca(to_write * gpGlobals->iAudioChannels * sizeof(short));
 							pRixPlayer->opl->update(tempBuf, to_write);
 							pRixPlayer->opl->update(tempBuf, to_write);
 							for (int i = 0; i < to_write; i++)
 							for (int i = 0; i < to_write; i++)
 								for (int j = 0; j < gpGlobals->iAudioChannels; j++)
 								for (int j = 0; j < gpGlobals->iAudioChannels; j++)

+ 1 - 0
sdlpal.vcxproj

@@ -469,6 +469,7 @@
     <ClInclude Include="battle.h" />
     <ClInclude Include="battle.h" />
     <ClInclude Include="codepage.h" />
     <ClInclude Include="codepage.h" />
     <ClInclude Include="common.h" />
     <ClInclude Include="common.h" />
+    <ClInclude Include="config_types.h" />
     <ClInclude Include="ending.h" />
     <ClInclude Include="ending.h" />
     <ClInclude Include="fight.h" />
     <ClInclude Include="fight.h" />
     <ClInclude Include="font.h" />
     <ClInclude Include="font.h" />

+ 3 - 0
sdlpal.vcxproj.filters

@@ -634,6 +634,9 @@
     <ClInclude Include="adplug\dbemuopl.h">
     <ClInclude Include="adplug\dbemuopl.h">
       <Filter>adplug</Filter>
       <Filter>adplug</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="config_types.h">
+      <Filter>liboggvorbis\include\ogg</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="sdlpal.ico">
     <None Include="sdlpal.ico">

+ 3 - 3
sound.c

@@ -27,7 +27,7 @@
 #include "resampler.h"
 #include "resampler.h"
 #include <math.h>
 #include <math.h>
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
 #include "midi.h"
 #endif
 #endif
 
 
@@ -769,7 +769,7 @@ SOUND_CloseAudio(
    }
    }
 #endif
 #endif
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
    MIDI_Play(0, FALSE);
    MIDI_Play(0, FALSE);
 #endif
 #endif
 
 
@@ -983,7 +983,7 @@ SOUND_PlayMUS(
 {
 {
 	SDL_mutexP(gSndPlayer.mtx);
 	SDL_mutexP(gSndPlayer.mtx);
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
    if (gpGlobals->eMusicType == MUSIC_MIDI)
    if (gpGlobals->eMusicType == MUSIC_MIDI)
    {
    {
       MIDI_Play(iNumRIX, fLoop);
       MIDI_Play(iNumRIX, fLoop);

+ 1 - 1
uigame.c

@@ -630,7 +630,7 @@ PAL_SystemMenu(
       // Music
       // Music
       //
       //
       g_fNoMusic = !PAL_SwitchMenu(!g_fNoMusic);
       g_fNoMusic = !PAL_SwitchMenu(!g_fNoMusic);
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
       if (gpGlobals->eMusicType == MUSIC_MIDI)
       if (gpGlobals->eMusicType == MUSIC_MIDI)
       {
       {
          if (g_fNoMusic)
          if (g_fNoMusic)

+ 2 - 2
util.c

@@ -25,7 +25,7 @@
 #include "util.h"
 #include "util.h"
 #include "input.h"
 #include "input.h"
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
 #include "midi.h"
 #include "midi.h"
 #endif
 #endif
 
 
@@ -277,7 +277,7 @@ UTIL_Delay(
       while (PAL_PollEvent(NULL));
       while (PAL_PollEvent(NULL));
    }
    }
 
 
-#ifdef PAL_HAS_NATIVEMIDI
+#if PAL_HAS_NATIVEMIDI
    MIDI_CheckLoop();
    MIDI_CheckLoop();
 #endif
 #endif
 }
 }