diff --git a/JGE/Makefile b/JGE/Makefile index 28f84a4f3..5962f652c 100644 --- a/JGE/Makefile +++ b/JGE/Makefile @@ -82,7 +82,7 @@ OBJS = $(GENERIC_OBJS) $(LINUX_OBJS) TARGET_LIB = libjge.a TARGET_HGE = libhgetools.a INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include -CXXFLAGS += -DLINUX +CXXFLAGS += -DLINUX $(FMOD) CXXFLAGS += $(INCDIR) LIBDIR = lib/linux endif @@ -95,7 +95,7 @@ ifeq ($(TARGET_ARCHITECTURE),psp) include $(PSPSDK)/lib/build.mak endif -all: $(DEFAULT_RULE) hge +all: $(DEFAULT_RULE) Makefile.$(TARGET_ARCHITECTURE) hge debug: $(DEFAULT_RULE) hge @@ -117,5 +117,11 @@ $(TARGET_HGE): $(HGE_OBJS) ar r $(TARGET_HGE) $(HGE_OBJS) clean: - $(RM) -f $(OBJS) $(HGE_OBJS) + $(RM) -f $(OBJS) $(HGE_OBJS) Makefile.$(TARGET_ARCHITECTURE) endif + +Makefile.linux: + g++ -o /dev/null src/testfeatures.c -L$(LIBDIR) -lfmod-3.75 + @if [ "0" == "$?" ]; then echo 'FMOD=-DWITH_FMOD'; else echo 'FMOD=-DWITHOUT_FMOD'; fi > $@ + +-include Makefile.$(TARGET_ARCHITECTURE) diff --git a/JGE/include/JSoundSystem.h b/JGE/include/JSoundSystem.h index 5751818b9..441b25513 100644 --- a/JGE/include/JSoundSystem.h +++ b/JGE/include/JSoundSystem.h @@ -51,9 +51,13 @@ public: int getPlayTime(); #if defined (WIN32) || defined (LINUX) - FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs + #ifdef WITH_FMOD + FSOUND_SAMPLE* mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs + #else + void* mTrack; + #endif #else - JMP3* mTrack; + JMP3* mTrack; #endif }; @@ -62,16 +66,20 @@ public: //------------------------------------------------------------------------------------------------ class JSample { -public: - JSample(); - ~JSample(); + public: + JSample(); + ~JSample(); - int mVoice; + int mVoice; #if defined (WIN32) || defined (LINUX) - FSOUND_SAMPLE *mSample; + #ifdef WITH_FMOD + FSOUND_SAMPLE *mSample; + #else + void* mSample; + #endif #else - WAVDATA *mSample; + WAVDATA *mSample; #endif }; diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index 09bcf65e4..9cac07a91 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -75,9 +75,9 @@ #include #endif #ifdef LINUX - typedef unsigned char byte; - typedef unsigned long DWORD; - typedef unsigned char BYTE; + typedef uint8_t byte; + typedef uint32_t DWORD; + typedef uint8_t BYTE; typedef bool BOOL; #endif @@ -87,8 +87,6 @@ #endif #if defined (WIN32) || defined (LINUX) - #include "../Dependencies/include/fmod.h" - typedef int8_t s8; typedef int16_t s16; diff --git a/JGE/src/JGE.cpp b/JGE/src/JGE.cpp index 2c10ba5a9..daf4c0751 100644 --- a/JGE/src/JGE.cpp +++ b/JGE/src/JGE.cpp @@ -20,8 +20,6 @@ ////////////////////////////////////////////////////////////////////////// #if defined (WIN32) // WIN32 specific code -#include "../../Dependencies/include/png.h" -#include "../../Dependencies/include/fmod.h" int JGE::GetTime(void) { diff --git a/JGE/src/Xmain.cpp b/JGE/src/Xmain.cpp index b15ac9edf..3970ec13d 100644 --- a/JGE/src/Xmain.cpp +++ b/JGE/src/Xmain.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "../../JGE/include/JGE.h" #include "../../JGE/include/JTypes.h" @@ -49,7 +50,7 @@ Display* gXDisplay = NULL; Window gXWindow = NULL; GLXWindow glxWin = NULL; -static queue< pair > gKeyBuffer; +static queue< pair > gKeyBuffer; static u32 gControllerState = 0; static u32 gPrevControllerState = 0; static u32 gHolds = 0; @@ -80,7 +81,7 @@ static const struct { KeySym keysym; u32 pspCode; } gDefaultBindings[] = { XK_F3, PSP_CTRL_NOTE } }; -static vector< pair > gKeyCodes; +static vector< pair > gKeyCodes; GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window { @@ -210,7 +211,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits __attribute__(( } for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i) - gKeyCodes.push_back(make_pair(XKeysymToKeycode(gXDisplay, gDefaultBindings[i].keysym), gDefaultBindings[i].pspCode)); + gKeyCodes.push_back(make_pair(gDefaultBindings[i].keysym, gDefaultBindings[i].pspCode)); // Get a suitable framebuffer config int numReturned; @@ -437,26 +438,32 @@ int main(int argc, char* argv[]) switch (event.type) { case KeyPress: - if (XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1) == XK_F) - fullscreen(); - for (vector< pair >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) - if (event.xkey.keycode == it->first) - { - if (!(gHolds & it->second)) - gKeyBuffer.push(*it); - gControllerState |= it->second; - gHolds |= it->second; - break; - } + { + KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1); + if (XK_F == sym) + fullscreen(); + for (vector< pair >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) + if (sym == it->first) + { + if (!(gHolds & it->second)) + gKeyBuffer.push(*it); + gControllerState |= it->second; + gHolds |= it->second; + break; + } + } break; case KeyRelease: - for (vector< pair >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) - if (event.xkey.keycode == it->first) - { - gControllerState &= ~it->second; - gHolds &= ~it->second; - break; - } + { + KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1); + for (vector< pair >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) + if (sym == it->first) + { + gControllerState &= ~it->second; + gHolds &= ~it->second; + break; + } + } break; case ConfigureNotify: ReSizeGLScene(event.xconfigure.width, event.xconfigure.height); diff --git a/JGE/src/pc/JGfx.cpp b/JGE/src/pc/JGfx.cpp index 8baa84133..054c3e30c 100644 --- a/JGE/src/pc/JGfx.cpp +++ b/JGE/src/pc/JGfx.cpp @@ -17,7 +17,6 @@ #include "../../Dependencies/include/png.h" -#include "../../Dependencies/include/fmod.h" #ifdef __cplusplus extern "C" { diff --git a/JGE/src/pc/JSfx.cpp b/JGE/src/pc/JSfx.cpp index cd7483276..4fe8e0def 100644 --- a/JGE/src/pc/JSfx.cpp +++ b/JGE/src/pc/JSfx.cpp @@ -8,8 +8,12 @@ // //------------------------------------------------------------------------------------- -#include "../../Dependencies/include/png.h" + +#ifdef WITH_FMOD #include "../../Dependencies/include/fmod.h" +#else +#define FSOUND_FREE 0 +#endif #include "../../include/JSoundSystem.h" #include "../../include/JFileSystem.h" @@ -25,16 +29,19 @@ void JMusic::Update(){ } int JMusic::getPlayTime(){ +#ifdef WITH_FMOD return FSOUND_GetCurrentPosition(JSoundSystem::GetInstance()->mChannel)/44.1; //todo more generic, here it's only 44kHz +#else + return 0; +#endif } JMusic::~JMusic() { - JSoundSystem::GetInstance()->StopMusic(this); - //JSoundSystem::GetInstance()->FreeMusic(this); - - if (mTrack) - FSOUND_Sample_Free(mTrack); +#ifdef WITH_FMOD + JSoundSystem::GetInstance()->StopMusic(this); + if (mTrack) FSOUND_Sample_Free(mTrack); +#endif } @@ -46,162 +53,172 @@ JSample::JSample() JSample::~JSample() { - //JSoundSystem::GetInstance()->FreeSample(this); - if (mSample) - FSOUND_Sample_Free(mSample); +#ifdef WITH_FMOD + if (mSample) FSOUND_Sample_Free(mSample); +#endif } ////////////////////////////////////////////////////////////////////////// JSoundSystem* JSoundSystem::mInstance = NULL; - JSoundSystem* JSoundSystem::GetInstance() { - if (mInstance == NULL) - { - mInstance = new JSoundSystem(); - mInstance->InitSoundSystem(); - } - - return mInstance; + if (mInstance == NULL) + { + mInstance = new JSoundSystem(); + mInstance->InitSoundSystem(); + } + return mInstance; } void JSoundSystem::Destroy() { - if (mInstance) - { - mInstance->DestroySoundSystem(); - delete mInstance; - mInstance = NULL; - } + if (mInstance) + { + mInstance->DestroySoundSystem(); + delete mInstance; + mInstance = NULL; + } } JSoundSystem::JSoundSystem() { - mVolume = 0; + mVolume = 0; mSampleVolume = 0; mChannel = FSOUND_FREE; } - JSoundSystem::~JSoundSystem() { - } - void JSoundSystem::InitSoundSystem() { - FSOUND_Init(44100, 32, 0); +#ifdef WITH_FMOD + FSOUND_Init(44100, 32, 0); +#endif } void JSoundSystem::DestroySoundSystem() { - FSOUND_Close(); - +#ifdef WITH_FMOD + FSOUND_Close(); +#endif } JMusic *JSoundSystem::LoadMusic(const char *fileName) { - JMusic* music = new JMusic(); - if (music) +#ifndef WITH_FMOD + return NULL; +#elif + JMusic* music = new JMusic(); + if (music) + { + JFileSystem* fileSystem = JFileSystem::GetInstance(); + if (fileSystem->OpenFile(fileName)) { - JFileSystem* fileSystem = JFileSystem::GetInstance(); - if (fileSystem->OpenFile(fileName)) - { - - int size = fileSystem->GetFileSize(); - char *buffer = new char[size]; - fileSystem->ReadFile(buffer, size); - music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); + int size = fileSystem->GetFileSize(); + char *buffer = new char[size]; + fileSystem->ReadFile(buffer, size); + music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); - delete[] buffer; - fileSystem->CloseFile(); - } - + delete[] buffer; + fileSystem->CloseFile(); } - - return music; + } + return music; +#endif } void JSoundSystem::PlayMusic(JMusic *music, bool looping) { - - if (music && music->mTrack) - { - mChannel = FSOUND_PlaySound(mChannel, music->mTrack); - SetMusicVolume(mVolume); +#ifdef WITH_FMOD + if (music && music->mTrack) + { + mChannel = FSOUND_PlaySound(mChannel, music->mTrack); + SetMusicVolume(mVolume); - if (looping) - FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL); - else - FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF); - - } + if (looping) + FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL); + else + FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF); + } +#endif } void JSoundSystem::StopMusic(JMusic *music) { - FSOUND_StopSound(mChannel); +#ifdef WITH_FMOD + FSOUND_StopSound(mChannel); +#endif } void JSoundSystem::SetVolume(int volume) { - SetMusicVolume(volume); - SetSfxVolume(volume); + SetMusicVolume(volume); + SetSfxVolume(volume); } void JSoundSystem::SetMusicVolume(int volume) { - if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55); - mVolume = volume; +#ifdef WITH_FMOD + if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55); +#endif + mVolume = volume; } void JSoundSystem::SetSfxVolume(int volume){ //this sets the volume to all channels then reverts back the volume for music.. - //that's a bit dirty but it works - FSOUND_SetVolumeAbsolute(FSOUND_ALL,volume * 2.55); + //that's a bit dirty but it works +#ifdef WITH_FMOD + FSOUND_SetVolumeAbsolute(FSOUND_ALL, volume * 2.55); +#endif mSampleVolume = volume; SetMusicVolume(mVolume); } JSample *JSoundSystem::LoadSample(const char *fileName) { - JSample* sample = new JSample(); - if (sample) +#ifndef WITH_FMOD + return NULL; +#else + JSample* sample = new JSample(); + if (sample) + { + JFileSystem* fileSystem = JFileSystem::GetInstance(); + if (fileSystem->OpenFile(fileName)) { - JFileSystem* fileSystem = JFileSystem::GetInstance(); - if (fileSystem->OpenFile(fileName)) - { - int size = fileSystem->GetFileSize(); - char *buffer = new char[size]; - fileSystem->ReadFile(buffer, size); - sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); - - delete[] buffer; - fileSystem->CloseFile(); - }else - sample->mSample = NULL; - - } + int size = fileSystem->GetFileSize(); + char *buffer = new char[size]; + fileSystem->ReadFile(buffer, size); + sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size); - return sample; + delete[] buffer; + fileSystem->CloseFile(); + }else + sample->mSample = NULL; + + } + return sample; +#endif } void JSoundSystem::PlaySample(JSample *sample) { +#ifdef WITH_FMOD if (sample && sample->mSample){ - int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample); + int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample); FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55); } +#endif } diff --git a/JGE/src/testfeatures.c b/JGE/src/testfeatures.c new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/JGE/src/testfeatures.c @@ -0,0 +1 @@ +int main() {} diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index 89fb75e74..bdcbe3e42 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -40,9 +40,9 @@ INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 LIBDIR = ../../JGE/lib/psp else OBJS += objs/TestSuiteAI.o -INCDIR = -I ../../JGE/include -I ../../JGE/src -LIBDIR = -L ../../JGE/lib/linux -L ../../JGE -LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lglut -lhgetools -lfmod-3.75 +INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include +LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib +LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 $(FMOD) CFLAGS = $(INCDIR) -DLINUX ASFLAGS = $(CXXFLAGS) @@ -55,7 +55,7 @@ CFLAGS := -Wall -W -Werror -Wno-unused $(CFLAGS) CXXFLAGS += $(CFLAGS) # -fno-exceptions -LDFLAGS = $(LIBS) +LDFLAGS += $(LIBS) @@ -74,7 +74,7 @@ else -$(TARGET): $(OBJS) ../../JGE/lib/linux/libjge.a +$(TARGET): Makefile.$(TARGET_ARCHITECTURE) $(OBJS) ../../JGE/lib/linux/libjge.a g++ -o $(TARGET) $(OBJS) $(LIBS) $(LIBDIR) linux: $(TARGET) @@ -82,7 +82,7 @@ linux: $(TARGET) debug: linux clean: - $(RM) $(OBJS) + $(RM) $(OBJS) Makefile.$(TARGET_ARCHITECTURE) endif @@ -95,4 +95,12 @@ $(DEPS): deps/%.d: src/%.cpp .DEFAULT: @echo $@ has been deleted : updating deps. +Makefile.psp: + echo > Makefile.psp + +Makefile.linux: + g++ -o /dev/null src/testfeatures.c $(LIBDIR) -lfmod-3.75 + @if [ "0" == "$?" ]; then echo 'FMOD=-lfmod-3.75'; else echo 'FMOD='; fi > $@ + -include $(DEPS) +-include Makefile.$(TARGET_ARCHITECTURE) diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 7f301e088..c6c20ec24 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -381,7 +381,7 @@ void GameStateMenu::Update(float dt) //Debug #ifdef _DEBUG char buf[4096]; - sprintf(buf, "\n==\nTotal MTGCard: %i\nTotal CardPrimitives: %i\n==\n", mParent->collection->collection.size(), mParent->collection->primitives.size()); + sprintf(buf, "\n==\nTotal MTGCard: %lu\nTotal CardPrimitives: %lu\n==\n", (long unsigned)mParent->collection->collection.size(), (long unsigned)mParent->collection->primitives.size()); OutputDebugString(buf); #endif diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index 27c442552..66ed5f787 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -317,7 +317,11 @@ unsigned long WCachedSample::size(){ return 0; #if defined WIN32 || defined LINUX + #if defined __LP64__ + return 0; + #else return FSOUND_Sample_GetLength(sample->mSample); + #endif #else return sample->mSample->fileSize; #endif @@ -425,4 +429,4 @@ WTrackedQuad::WTrackedQuad(string _resname) { } WTrackedQuad::~WTrackedQuad() { if(quad) SAFE_DELETE(quad); -} \ No newline at end of file +} diff --git a/projects/mtg/src/testfeatures.c b/projects/mtg/src/testfeatures.c new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/projects/mtg/src/testfeatures.c @@ -0,0 +1 @@ +int main() {}