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 3f8f97910..58e443ed0 100644 Binary files a/JGE/lib/psp/libhgetools.a and b/JGE/lib/psp/libhgetools.a differ 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; }