From 8ff6839c8df99f900a6297dfce8bcafcec0eb848 Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew" Date: Thu, 21 Apr 2011 13:16:11 +0000 Subject: [PATCH] Some preparation work for new platform support. - Added a "PSP" compile-time define to clean up some compile time checks (replaced !WIN32 && !LINUX && !IOS with PSP) -- Wil, I am aware that this is redundant with the PSPENV variable you introduced recently, I think we can clean that up easily -- This looks like lots of changes, but most of the time I just moved some blocks here and there -- tested on VC 2010, PSP, and a bit of NDK -- I might have broken maemo, iOS, or Linux compilation, can you guys check? - Fixed some warnings reported by NDK - NDK still does not compile because recent boost additions (mutex, etc...) are apparently not supported --- JGE/Makefile | 2 +- JGE/include/JFileSystem.h | 10 +-- JGE/include/JGE.h | 10 ++- JGE/include/JMD2Model.h | 14 +--- JGE/include/JOBJModel.h | 8 +- JGE/include/JRenderer.h | 15 ++-- JGE/include/JSoundSystem.h | 31 ++++---- JGE/include/JSprite.h | 6 +- JGE/include/JTypes.h | 115 +++++++++++++++------------ JGE/include/Threading.h | 2 +- JGE/include/Vector2D.h | 8 +- JGE/include/hge/hgeparticle.h | 1 + JGE/lib/psp/libhgetools.a | Bin 35852 -> 35236 bytes JGE/src/JFileSystem.cpp | 52 ++++++------ JGE/src/JGE.cpp | 34 ++++---- JGE/src/JLBFont.cpp | 2 +- JGE/src/JMD2Model.cpp | 40 +++++----- JGE/src/JSprite.cpp | 12 +-- JGE/src/unzip/unzip.c | 10 ++- projects/mtg/Makefile | 2 +- projects/mtg/include/utils.h | 4 +- projects/mtg/src/GameApp.cpp | 11 ++- projects/mtg/src/TranslateKeys.cpp | 6 +- projects/mtg/src/WCachedResource.cpp | 3 +- projects/mtg/src/WFont.cpp | 93 +++++++++++----------- projects/mtg/src/utils.cpp | 18 ++--- 26 files changed, 257 insertions(+), 252 deletions(-) diff --git a/JGE/Makefile b/JGE/Makefile index 30df89337..ea088f242 100644 --- a/JGE/Makefile +++ b/JGE/Makefile @@ -83,7 +83,7 @@ PSPDIR = $(shell psp-config --psp-prefix) OBJS = $(GENERIC_OBJS) $(PSP_OBJS) TARGET_HGE = libhgetools.a INCDIR = include/psp include/psp/freetype2 ../Boost -CXXFLAGS += -O2 -G0 -DPSPENV +CXXFLAGS += -O2 -G0 -DPSPENV -DPSP LIBDIR = lib/psp endif ifeq ($(TARGET_ARCHITECTURE),linux) diff --git a/JGE/include/JFileSystem.h b/JGE/include/JFileSystem.h index ecba92a70..036848195 100644 --- a/JGE/include/JFileSystem.h +++ b/JGE/include/JFileSystem.h @@ -19,9 +19,7 @@ #include #include -#if defined (WIN32) || defined (LINUX) || defined(IOS) - -#else +#if defined (PSP) #include #include #endif @@ -130,10 +128,10 @@ private: char *mPassword; bool mZipAvailable; void preloadZip(const string& filename); -#if defined (WIN32) || defined (LINUX) || defined(IOS) - FILE *mFile; -#else +#if defined (PSP) SceUID mFile; +#else + FILE *mFile; #endif unzFile mZipFile; int mFileSize; diff --git a/JGE/include/JGE.h b/JGE/include/JGE.h index 6601f1b53..f3ac1b54a 100644 --- a/JGE/include/JGE.h +++ b/JGE/include/JGE.h @@ -28,18 +28,26 @@ #include typedef u32 LocalKeySym; #define LOCAL_KEY_NONE Qt::Key_unknown + #elif defined(WIN32) #include typedef WPARAM LocalKeySym; #define LOCAL_KEY_NONE ((WPARAM)-1) + #elif defined(LINUX) #include #include typedef KeySym LocalKeySym; #define LOCAL_KEY_NONE XK_VoidSymbol + +#elif defined(ANDROID) // This is temporary until we understand how to send real key events from Java +typedef long unsigned int LocalKeySym; +#define LOCAL_KEY_NONE 0 + #else typedef u32 LocalKeySym; #define LOCAL_KEY_NONE ((u32)-1) + #endif @@ -51,7 +59,7 @@ u8 JGEGetAnalogX(); u8 JGEGetAnalogY(); bool JGEToggleFullscreen(); -#if !defined(WIN32) && !defined(LINUX) && !defined(IOS) +#if defined (PSP) // hack to fix a typedef definition of u32 inside of newlib's stdint.h // this used to be defined as an unsigned long, but as of minpspw 11.1, it's diff --git a/JGE/include/JMD2Model.h b/JGE/include/JMD2Model.h index 2ef86dce0..2bdf25bc0 100644 --- a/JGE/include/JMD2Model.h +++ b/JGE/include/JMD2Model.h @@ -11,15 +11,9 @@ #ifndef _MD2MODEL_H #define _MD2MODEL_H -#if defined (WIN32) || defined (LINUX) || defined (IOS) - -#else - +#if defined (PSP) #include #include - - - #endif @@ -236,10 +230,10 @@ private: void CheckNextState(); -#if defined (WIN32) || defined (LINUX) || defined (IOS) - void CalculateNormal(float *p1, float *p2, float *p3); -#else +#if defined (PSP) void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3); +#else + void CalculateNormal(float *p1, float *p2, float *p3); #endif MD2Animation **mAnimations; diff --git a/JGE/include/JOBJModel.h b/JGE/include/JOBJModel.h index 557da2726..fadb0a923 100644 --- a/JGE/include/JOBJModel.h +++ b/JGE/include/JOBJModel.h @@ -15,15 +15,9 @@ using namespace std; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - -#else - +#if defined (PSP) #include #include - - - #endif diff --git a/JGE/include/JRenderer.h b/JGE/include/JRenderer.h index 20cd74bbd..70c9da261 100644 --- a/JGE/include/JRenderer.h +++ b/JGE/include/JRenderer.h @@ -16,9 +16,9 @@ #include #include -#if (!defined IOS) +#if (!defined IOS) && (!defined ANDROID) #include -#endif //IOS +#endif //IOS ANDROID #include "JTypes.h" @@ -27,9 +27,7 @@ #include -#elif defined (LINUX) || defined(IOS) - -#else +#elif defined (PSP) #include #include @@ -80,8 +78,7 @@ protected: public: -#if defined (WIN32) || defined (LINUX) || defined (IOS) -#else +#if defined (PSP) int PixelSize(int textureMode); #endif @@ -575,13 +572,15 @@ private: #if (!defined IOS) void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); int LoadPNG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); +#if (!defined ANDROID) void LoadGIF(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); int image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode = 0, int TextureFormat = TEXTURE_FORMAT); +#endif // (ANDROID) How can we get gif support for android ? #endif //(IOS) static JRenderer* mInstance; -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if (!defined PSP) GLuint mCurrentTex; #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) || (defined WIN32) diff --git a/JGE/include/JSoundSystem.h b/JGE/include/JSoundSystem.h index 6b22b0f2c..6a14b0f0b 100644 --- a/JGE/include/JSoundSystem.h +++ b/JGE/include/JSoundSystem.h @@ -27,10 +27,7 @@ #include #define WITH_FMOD -#elif defined (LINUX) || defined (IOS) - -#else - +#elif defined (PSP) #include #include #include @@ -73,16 +70,17 @@ public: #else -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + JMP3* mTrack; +#else #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; -#endif -#endif +#endif //WITH_FMOD + +#endif //PSP +#endif //USE_PHONON }; @@ -97,19 +95,20 @@ class JSample int mVoice; unsigned long fileSize(); -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + WAVDATA *mSample; +#else #ifdef WITH_FMOD FSOUND_SAMPLE *mSample; #else #ifdef USE_PHONON Phonon::AudioOutput* mOutput; Phonon::MediaObject* mMediaObject; -#endif +#endif //USE_PHONON void* mSample; - #endif -#else - WAVDATA *mSample; -#endif + #endif //WITH_FMOD + +#endif //PSP }; diff --git a/JGE/include/JSprite.h b/JGE/include/JSprite.h index 8a7f8fd8c..05e67b414 100644 --- a/JGE/include/JSprite.h +++ b/JGE/include/JSprite.h @@ -11,10 +11,10 @@ #ifndef _SPRITE_H_ #define _SPRITE_H_ -#if defined (WIN32) || defined(LINUX) || defined(IOS) -#include -#else +#if defined (PSP) #include +#else +#include #endif #include diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index 5e48ee813..d657295ff 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -11,11 +11,7 @@ #ifndef _JTYPES_H #define _JTYPES_H -#if defined (WIN32) || defined (LINUX) || defined (IOS) - -#include - -#else +#if defined (PSP) #include #include @@ -27,9 +23,12 @@ #include #include #include - #include "JAudio.h" +#else + +#include + #endif #ifndef __GNUC__ @@ -46,6 +45,11 @@ enum { JGE_ERR_GENERIC = -5, }; +#ifdef PSP +#include +#else +#include +#endif #ifndef M_PI #define M_PI 3.14159265358979323846f @@ -81,7 +85,7 @@ enum { #ifdef WIN32 #include #endif -#if defined(LINUX) || defined(IOS) +#if defined(LINUX) || defined(IOS) || defined (ANDROID) typedef uint8_t byte; typedef uint32_t DWORD; typedef uint8_t BYTE; @@ -98,47 +102,27 @@ enum { #import #import # import -#elif defined (WIN32) || defined (LINUX) - #include +#elif defined (WIN32) || defined (LINUX) + #include #include + +//Android GL1 support TODO +/* +#elif defined (ANDROID) + #include + #include +*/ +//Android GL2 support +#elif defined (ANDROID) + #include + #include + #endif #else # include #endif -#if defined (WIN32) || defined (LINUX) || defined (IOS) - -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; - - - #define BLEND_ZERO GL_ZERO - #define BLEND_ONE GL_ONE - #define BLEND_SRC_COLOR GL_SRC_COLOR - #define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR - #define BLEND_SRC_ALPHA GL_SRC_ALPHA - #define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA - #define BLEND_DST_ALPHA GL_DST_ALPHA - #define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA - #define BLEND_DST_COLOR GL_DST_COLOR - #define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR - #define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE - - #define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - #define RGBA(r, g, b, a) (((a) << 24) | ((b) << 16) | ((g) << 8) | (r)) - - #define TEXTURE_FORMAT 0 - #define GU_PSM_8888 0 - #define GU_PSM_5551 0 - #define GU_PSM_4444 0 - #define GU_PSM_5650 0 - #define PIXEL_TYPE DWORD - -#else // PSP +#if defined (PSP) #ifndef ABGR8888 #define ABGR8888 @@ -225,6 +209,37 @@ typedef uint32_t u32; ScePspFVector3 pos; } PSPVertex3D; +#else //non PSP + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; + + + #define BLEND_ZERO GL_ZERO + #define BLEND_ONE GL_ONE + #define BLEND_SRC_COLOR GL_SRC_COLOR + #define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR + #define BLEND_SRC_ALPHA GL_SRC_ALPHA + #define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA + #define BLEND_DST_ALPHA GL_DST_ALPHA + #define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA + #define BLEND_DST_COLOR GL_DST_COLOR + #define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR + #define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE + + #define ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) + #define RGBA(r, g, b, a) (((a) << 24) | ((b) << 16) | ((g) << 8) | (r)) + + #define TEXTURE_FORMAT 0 + #define GU_PSM_8888 0 + #define GU_PSM_5551 0 + #define GU_PSM_4444 0 + #define GU_PSM_5650 0 + #define PIXEL_TYPE DWORD #endif @@ -338,14 +353,14 @@ public: int mFilter; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - GLuint mTexId; - u8* mBuffer; -#else +#if defined (PSP) int mTextureFormat; int mTexId; bool mInVideoRAM; PIXEL_TYPE* mBits; +#else + GLuint mTexId; + u8* mBuffer; #endif }; @@ -449,15 +464,15 @@ public: JTexture* mTex; -#if defined (WIN32) || defined(LINUX) || defined(IOS) +#if defined (PSP) + PIXEL_TYPE mColor[4]; // up to 4 vertices + int mBlend; // GU_TFX_MODULATE, GU_TFX_DECAL, GU_TFX_BLEND, GU_TFX_REPLACE, GU_TFX_ADD +#else float mTX0; float mTY0; float mTX1; float mTY1; JColor mColor[4]; // up to 4 vertices -#else - PIXEL_TYPE mColor[4]; // up to 4 vertices - int mBlend; // GU_TFX_MODULATE, GU_TFX_DECAL, GU_TFX_BLEND, GU_TFX_REPLACE, GU_TFX_ADD #endif float mX; diff --git a/JGE/include/Threading.h b/JGE/include/Threading.h index 7cd0938fd..d024470f9 100644 --- a/JGE/include/Threading.h +++ b/JGE/include/Threading.h @@ -1,7 +1,7 @@ #ifndef THREADING_H #define THREADING_H -#if defined (WIN32) || defined (LINUX) +#if !defined(PSP) #include #include #include diff --git a/JGE/include/Vector2D.h b/JGE/include/Vector2D.h index 78546b31a..2c2066912 100644 --- a/JGE/include/Vector2D.h +++ b/JGE/include/Vector2D.h @@ -11,12 +11,10 @@ #ifndef _VECTOR2D_H #define _VECTOR2D_H -#ifdef WIN32 -#include -#elif (defined LINUX) || (defined IOS) -#include -#else +#ifdef PSP #include +#else +#include #endif diff --git a/JGE/include/hge/hgeparticle.h b/JGE/include/hge/hgeparticle.h index b2a4094d8..22d53239c 100644 --- a/JGE/include/hge/hgeparticle.h +++ b/JGE/include/hge/hgeparticle.h @@ -18,6 +18,7 @@ #include "hgerect.h" #include +#include class JQuad; diff --git a/JGE/lib/psp/libhgetools.a b/JGE/lib/psp/libhgetools.a index 3f8f97910cf99a4bfa36231f67ee6bfa2f5bb6d9..58e443ed04dd447c84696f33d2b8d1157fe2b13d 100644 GIT binary patch delta 6950 zcmbuDe{9s{9mk(LzIVN|t-V6ERSP}fgklRlXrV=m6etyyY~4g{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!ToxTbCoRsVdtkJlDVyLt7b9^{8Q0-3vB9k!bLcneMj9wG6(Y>7DCDg{*SyboC!dlEUIq z?Bb7L44zXt4vZJY5I5x_E%x`Hsm)Pss}#q_0g>EFX1D(6NJ9P5k%4+ktJq3Ei<}w{ ziZRchCyjv5tl)Hx_eU4Zga3kL%EsY7gF9E)@KkV!h2H}d5&(D8#%9X|xs@!Mse#|RQ} z)ToG~E{Jlh`kitm&~q%5qtYUd%82-Bl}Hcng7QljjKRLisszUjr~o}ND7M(I4S9|k zk-{+-T<#8{mmIST$}#((svQw=%xMwFv@^+7Tc=~Uh+}%3?iX>)W)a8e9}|`L{xQKZ S`p0CV4BjTE-QM!VEq?+>;)`AY diff --git a/JGE/src/JFileSystem.cpp b/JGE/src/JFileSystem.cpp index 2ef60ee8c..d76a100c3 100644 --- a/JGE/src/JFileSystem.cpp +++ b/JGE/src/JFileSystem.cpp @@ -92,10 +92,10 @@ void JFileSystem::Destroy() JFileSystem::JFileSystem() { mZipAvailable = false; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mFile = NULL; +#if defined (PSP) + mFile = -1; #else - mFile = -1; + mFile = NULL; #endif mPassword = NULL; mZipFile = NULL; @@ -197,7 +197,15 @@ bool JFileSystem::OpenFile(const string &filename) } else { -#if defined (WIN32) || defined (LINUX)|| defined (IOS) +#if defined (PSP) + mFile = sceIoOpen(path.c_str(), PSP_O_RDONLY, 0777); + if (mFile > 0) + { + mFileSize = sceIoLseek(mFile, 0, PSP_SEEK_END); + sceIoLseek(mFile, 0, PSP_SEEK_SET); + return true; + } +#else mFile = fopen(path.c_str(), "rb"); if (mFile != NULL) { @@ -206,14 +214,6 @@ bool JFileSystem::OpenFile(const string &filename) fseek(mFile, 0, SEEK_SET); return true; } -#else - mFile = sceIoOpen(path.c_str(), PSP_O_RDONLY, 0777); - if (mFile > 0) - { - mFileSize = sceIoLseek(mFile, 0, PSP_SEEK_END); - sceIoLseek(mFile, 0, PSP_SEEK_SET); - return true; - } #endif } @@ -229,30 +229,30 @@ void JFileSystem::CloseFile() return; } -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + if (mFile > 0) + sceIoClose(mFile); +#else if (mFile != NULL) fclose(mFile); -#else - if (mFile > 0) - sceIoClose(mFile); #endif } int JFileSystem::ReadFile(void *buffer, int size) { - if (mZipAvailable && mZipFile != NULL) - { - return unzReadCurrentFile(mZipFile, buffer, size); - } - else - { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - return fread(buffer, 1, size, mFile); + if (mZipAvailable && mZipFile != NULL) + { + return unzReadCurrentFile(mZipFile, buffer, size); + } + else + { +#if defined (PSP) + return sceIoRead(mFile, buffer, size); #else - return sceIoRead(mFile, buffer, size); + return fread(buffer, 1, size, mFile); #endif - } + } } diff --git a/JGE/src/JGE.cpp b/JGE/src/JGE.cpp index b21e57ecd..fda3ca660 100644 --- a/JGE/src/JGE.cpp +++ b/JGE/src/JGE.cpp @@ -313,22 +313,8 @@ JGE::~JGE() -#if defined (WIN32) || defined (LINUX) || defined (IOS) -// Non-PSP code - -void JGE::Init() -{ - mDone = false; - mPaused = false; - mCriticalAssert = false; - JRenderer::GetInstance(); - JFileSystem::GetInstance(); - JSoundSystem::GetInstance(); - LeftClickedProcessed(); -} - -////////////////////////////////////////////////////////////////////////// -#else ///// PSP specific code +#if defined (PSP) +// PSP Specific code void JGE::Init() { @@ -432,7 +418,21 @@ void JGE::Run() } } -#endif ///// PSP specific code + +////////////////////////////////////////////////////////////////////////// +#else ///// Non PSP code +void JGE::Init() +{ + mDone = false; + mPaused = false; + mCriticalAssert = false; + JRenderer::GetInstance(); + JFileSystem::GetInstance(); + JSoundSystem::GetInstance(); + LeftClickedProcessed(); +} + +#endif ///// Non PSP code ////////////////////////////////////////////////////////////////////////// diff --git a/JGE/src/JLBFont.cpp b/JGE/src/JLBFont.cpp index 85d13ebae..61ef856ca 100644 --- a/JGE/src/JLBFont.cpp +++ b/JGE/src/JLBFont.cpp @@ -222,7 +222,7 @@ float JLBFont::GetStringWidth(const char *string) const { ch = *p - 32; p++; - if (ch < 0) continue; + //if (ch < 0) continue; //TODO useless test per compiler's message, char always positive, bug needs fixing here len += mCharWidth[ch+mBase] + mTracking; } len -= mTracking; diff --git a/JGE/src/JMD2Model.cpp b/JGE/src/JMD2Model.cpp index 50fe14f2c..835e3f1c0 100644 --- a/JGE/src/JMD2Model.cpp +++ b/JGE/src/JMD2Model.cpp @@ -220,10 +220,10 @@ bool JMD2Model::Load(char *filename, char *textureName) //------------------------------------------------------------------------------------------------- // given 3 points, calculates the normal to the points -#if defined (WIN32) || defined (LINUX) || defined (IOS) -void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3) -#else +#if defined (PSP) void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, float *p3) +#else +void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3) #endif { float a[3], b[3], result[3]; @@ -244,21 +244,21 @@ void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, fl // calculate the length of the normal length = (float)sqrt(result[0]*result[0] + result[1]*result[1] + result[2]*result[2]); -#if defined (WIN32) || defined (LINUX) || defined (IOS) - // normalize and specify the normal -#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) - glNormal3f(result[0]/length, result[1]/length, result[2]/length); -#else - // FIXME -#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) - -#else +#if defined (PSP) if (length == 0.0f) length = SMALLEST_FP; normal->x = result[0]/length; normal->y = result[1]/length; normal->z = result[2]/length; +#else + // normalize and specify the normal +#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) + glNormal3f(result[0]/length, result[1]/length, result[2]/length); +#else + // FIXME +#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0) + #endif } @@ -278,12 +278,12 @@ void JMD2Model::Render(int frameNum) mRenderer->BindTexture(mModel->modelTex); -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if !defined (PSP) // display the textured model with proper lighting normals #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) || (defined GL_VERSION_ES_CM_1_1) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -299,7 +299,7 @@ void JMD2Model::Render(int frameNum) #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)|| (defined GL_VERSION_ES_CM_1_1) float vertex_data[]={ pointList[mModel->triIndex[i].meshIndex[0]].x, pointList[mModel->triIndex[i].meshIndex[0]].y, pointList[mModel->triIndex[i].meshIndex[0]].z, pointList[mModel->triIndex[i].meshIndex[2]].x, pointList[mModel->triIndex[i].meshIndex[2]].y, pointList[mModel->triIndex[i].meshIndex[2]].z, @@ -333,7 +333,7 @@ void JMD2Model::Render(int frameNum) } #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) || (defined GL_VERSION_ES_CM_1_1) glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop #else glEnd(); @@ -482,11 +482,11 @@ void JMD2Model::Render() mRenderer->BindTexture(mModel->modelTex); -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if !defined (PSP) #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) // FIXME -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) || (defined GL_VERSION_ES_CM_1_1) glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); #else @@ -541,7 +541,7 @@ void JMD2Model::Render() #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) // FIXME -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) || (defined GL_VERSION_ES_CM_1_1) float vertex_data[]={ vertex[0].x, vertex[0].y, vertex[0].z, vertex[2].x, vertex[2].y, vertex[2].z, @@ -575,7 +575,7 @@ void JMD2Model::Render() } #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) // FIXME -#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) +#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1) || (defined GL_VERSION_ES_CM_1_1) glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop #else glEnd(); diff --git a/JGE/src/JSprite.cpp b/JGE/src/JSprite.cpp index 8bdd835ad..0bd5612e2 100644 --- a/JGE/src/JSprite.cpp +++ b/JGE/src/JSprite.cpp @@ -145,11 +145,11 @@ void JSprite::Render() // //mQuad->SetColor(ARGB(alpha,255,255,255)); -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + mFrames[mCurrentFrame]->SetColor(MAKE_COLOR(alpha, mColor)); +#else mFrames[mCurrentFrame]->SetColor(alpha<<24 | mColor); // mQuad->SetFlip(mFlipped[mCurrentFrame], false); -#else - mFrames[mCurrentFrame]->SetColor(MAKE_COLOR(alpha, mColor)); #endif // mQuad->SetHFlip(mFlipped[mCurrentFrame]); // } @@ -306,10 +306,10 @@ void JSprite::SetHotSpot(float x, float y, int index) } -#if defined (WIN32) || defined (LINUX) || defined (IOS) -void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&0x00ffffff); } -#else +#if defined (PSP) void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&~MASK_ALPHA); } +#else +void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&0x00ffffff); } #endif // void JSprite::SetBlendMode(int blend, int index) diff --git a/JGE/src/unzip/unzip.c b/JGE/src/unzip/unzip.c index 9ad4766d8..0b122e4fe 100644 --- a/JGE/src/unzip/unzip.c +++ b/JGE/src/unzip/unzip.c @@ -608,11 +608,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file, /* we check the magic */ if (err==UNZ_OK) + { if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; - + } if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; @@ -688,10 +689,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file, uSizeRead = extraFieldBufferSize; if (lSeek!=0) + { if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; @@ -713,10 +716,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file, uSizeRead = commentBufferSize; if (lSeek!=0) + { if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; @@ -977,11 +982,12 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, if (err==UNZ_OK) + { if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; - + } if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; /* diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index 0d88de228..98ecea153 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -37,7 +37,7 @@ PSP_EBOOT_UNKPNG = pic0.png PSP_EBOOT_PIC1 = pic1.png INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost LIBDIR = ../../JGE/lib/psp -CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSPENV +CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSPENV -DPSP else OBJS += objs/TestSuiteAI.o INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost diff --git a/projects/mtg/include/utils.h b/projects/mtg/include/utils.h index 20d328ebd..867381aef 100644 --- a/projects/mtg/include/utils.h +++ b/projects/mtg/include/utils.h @@ -3,9 +3,7 @@ #include -#if defined (WIN32) || defined (LINUX) || defined (IOS) - -#else +#if defined (PSP) #include #include #include diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index 1344e3a3b..d2c5303a7 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -3,10 +3,10 @@ #include #include #include -#if defined (WIN32) || defined (LINUX) || defined (IOS) -#include -#else +#if defined (PSP) #include +#else +#include #endif #include "WResourceManager.h" @@ -85,7 +85,7 @@ void GameApp::Create() #if !defined(QT_CONFIG) && !defined(IOS) #if defined (WIN32) _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); -#elif not defined (LINUX) +#elif defined (PSP) pspFpuSetEnable(0); //disable FPU Exceptions until we find where the FPU errors come from #endif #endif //QT_CONFIG @@ -356,8 +356,7 @@ void GameApp::Update() mCurrentState = mNextState; -#if defined (WIN32) || defined (LINUX) -#else +#if defined (PSP) /* int maxLinear = ramAvailableLineareMax(); int ram = ramAvailable(); diff --git a/projects/mtg/src/TranslateKeys.cpp b/projects/mtg/src/TranslateKeys.cpp index fd60acf6c..ae44eb3c2 100644 --- a/projects/mtg/src/TranslateKeys.cpp +++ b/projects/mtg/src/TranslateKeys.cpp @@ -10,7 +10,7 @@ using std::map; static map fattable; static map slimtable; -#if defined(LINUX) || defined (IOS) +#if defined(LINUX) || defined (IOS) || defined (ANDROID) const KeyRep& translateKey(LocalKeySym key) { { @@ -20,13 +20,13 @@ const KeyRep& translateKey(LocalKeySym key) } char* str = NULL; -#if !defined(QT_CONFIG) && !defined(IOS) +#if !defined(QT_CONFIG) && !defined(IOS) && !defined(ANDROID) str = XKeysymToString(key); #endif // QT_CONFIG if (!str) { str = NEW char[11]; - sprintf(str, "%lu", key); + sprintf(str, "%lu", key); //TODO: Wagic is not supposed to know that a key actually is an unsingned long, so this part should probably be platform specific (move to JGE ?) } const KeyRep k = make_pair(str, static_cast(NULL)); fattable[key] = k; diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index edcd560ee..ddc52983d 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -134,8 +134,7 @@ unsigned long WCachedTexture::size() if (!texture) return 0; unsigned int pixel_size = 4; -#if defined WIN32 || defined LINUX || defined IOS -#else +#if defined(PSP) pixel_size = JRenderer::GetInstance()->PixelSize(texture->mTextureFormat); #endif return texture->mTexHeight * texture->mTexWidth * pixel_size; diff --git a/projects/mtg/src/WFont.cpp b/projects/mtg/src/WFont.cpp index c939bfb6a..c40c775c6 100644 --- a/projects/mtg/src/WFont.cpp +++ b/projects/mtg/src/WFont.cpp @@ -10,12 +10,7 @@ static PIXEL_TYPE gencolor(int id, PIXEL_TYPE color) { unsigned int a, r, g, b, r0, g0, b0; -#if defined (WIN32) || defined (LINUX) - a = (color >> 24) & 0xFF; - r = (color >> 16) & 0xFF; - g = (color >> 8) & 0xFF; - b = (color >> 0) & 0xFF; -#else // PSP +#if defined (PSP) # if defined (ABGR8888) a = (color >> 24) & 0xFF; b = (color >> 16) & 0xFF; @@ -32,6 +27,11 @@ static PIXEL_TYPE gencolor(int id, PIXEL_TYPE color) g = ((color >> 4) & 0x0F) << 4; r = ((color >> 0) & 0x0F) << 4; # endif +#else // non PSP + a = (color >> 24) & 0xFF; + r = (color >> 16) & 0xFF; + g = (color >> 8) & 0xFF; + b = (color >> 0) & 0xFF; #endif r0 = g0 = b0 = 255; @@ -204,7 +204,7 @@ WFBFont::WFBFont(int inFontID, const char *fontname, int lineheight, bool useVid mSprites = NEW JQuad*[mCacheSize]; mGBCode = NEW int[mCacheSize]; -#if defined (WIN32) || defined (LINUX) +#if !defined (PSP) mCharBuffer = NEW u32[mFontSize*mFontSize]; #endif @@ -246,8 +246,7 @@ WFBFont::~WFBFont() if (mCharBuffer) delete[] mCharBuffer; } -#if defined (WIN32) || defined (LINUX) -#else +#if defined (PSP) static void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width) { unsigned int rowblocks = (width >> 4); @@ -283,14 +282,14 @@ int WFBFont::PreCacheChar(const u8 *ch) int index = mCurr++; if (mCurr >= mCacheSize) mCurr = 0; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - int x = 0; - int y = 0; - memset(mCharBuffer, 0, sizeof(u32) * mFontSize * mFontSize); -#else +#if defined (PSP) u8* pTexture = (u8*) mTexture->mBits; int x; int y = (int) mSprites[index]->mY; +#else + int x = 0; + int y = 0; + memset(mCharBuffer, 0, sizeof(u32) * mFontSize * mFontSize); #endif if (doubleWidthChar(ch)) @@ -319,10 +318,10 @@ int WFBFont::PreCacheChar(const u8 *ch) #if 1 for (; j < offset; j++) { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); #endif x++; } @@ -334,19 +333,19 @@ int WFBFont::PreCacheChar(const u8 *ch) gray = src[(i * size + j - offset) / 2]; gray = ((j - offset) & 1) ? (gray & 0xF0) : ((gray & 0x0F) << 4); if (gray) gray |= 0x0F; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(gray, 255, 255, 255); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(gray, 255, 255, 255), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(gray, 255, 255, 255); #endif x++; } for (; j < mFontSize; j++) { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); #endif x++; } @@ -355,12 +354,12 @@ int WFBFont::PreCacheChar(const u8 *ch) mGBCode[index] = code; -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + sceKernelDcacheWritebackAll(); +#else x = (int)mSprites[index]->mX; y = (int)mSprites[index]->mY; glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer); -#else - sceKernelDcacheWritebackAll(); #endif return index; } @@ -645,7 +644,7 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool useV mSprites = NEW JQuad*[mCacheSize]; mGBCode = NEW int[mCacheSize]; -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if !defined (PSP) mCharBuffer = NEW u32[mFontSize*mFontSize]; #endif @@ -681,14 +680,14 @@ int WGBKFont::PreCacheChar(const u8 *ch) int index = mCurr++; if (mCurr >= mCacheSize) mCurr = 0; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - int x = 0; - int y = 0; - memset(mCharBuffer, 0, sizeof(u32) * mFontSize * mFontSize); -#else +#if defined(PSP) u8* pTexture = (u8*) mTexture->mBits; int x; int y = (int) mSprites[index]->mY; +#else + int x = 0; + int y = 0; + memset(mCharBuffer, 0, sizeof(u32) * mFontSize * mFontSize); #endif if (mIndex) code = mIndex[code]; @@ -709,19 +708,19 @@ int WGBKFont::PreCacheChar(const u8 *ch) // set up the font texture buffer for (unsigned int i = 0; i < mFontSize; i++) { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - x = 0; -#else +#if defined (PSP) x = (int) mSprites[index]->mX; +#else + x = 0; #endif unsigned int j = 0; #if 1 for (; j < offset; j++) { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); #endif x++; } @@ -733,19 +732,19 @@ int WGBKFont::PreCacheChar(const u8 *ch) gray = src[(i * size + j - offset) / 2]; gray = ((j - offset) & 1) ? (gray & 0xF0) : ((gray & 0x0F) << 4); if (gray) gray |= 0x0F; -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(gray, 255, 255, 255); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(gray, 255, 255, 255), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(gray, 255, 255, 255); #endif x++; } for (; j < mFontSize; j++) { -#if defined (WIN32) || defined (LINUX) || defined (IOS) - mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); -#else +#if defined (PSP) SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE); +#else + mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0); #endif x++; } @@ -754,12 +753,12 @@ int WGBKFont::PreCacheChar(const u8 *ch) mGBCode[index] = code; -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + sceKernelDcacheWritebackAll(); +#else x = (int)mSprites[index]->mX; y = (int)mSprites[index]->mY; glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer); -#else - sceKernelDcacheWritebackAll(); #endif return index; } diff --git a/projects/mtg/src/utils.cpp b/projects/mtg/src/utils.cpp index 555d8168a..2ca3ee3eb 100644 --- a/projects/mtg/src/utils.cpp +++ b/projects/mtg/src/utils.cpp @@ -59,7 +59,14 @@ int WRand() int filesize(const char * filename) { int file_size = 0; -#if defined (WIN32) || defined (LINUX) || defined (IOS) +#if defined (PSP) + int file = sceIoOpen(filename, PSP_O_RDONLY, 0777); + if (file > 0) + { + file_size = sceIoLseek(file, 0, PSP_SEEK_END); + sceIoClose(file); + } +#else FILE * file = fopen(filename, "rb"); if (file != NULL) { @@ -67,15 +74,6 @@ int filesize(const char * filename) file_size = ftell(file); fclose(file); } - -#else - int file = sceIoOpen(filename, PSP_O_RDONLY, 0777); - if (file > 0) - { - file_size = sceIoLseek(file, 0, PSP_SEEK_END); - sceIoClose(file); - } - #endif return file_size; }