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
This commit is contained in:
wagic.the.homebrew
2011-04-21 13:16:11 +00:00
parent 5eb36fecc0
commit 8ff6839c8d
26 changed files with 257 additions and 252 deletions

View File

@@ -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)

View File

@@ -19,9 +19,7 @@
#include <map>
#include <string>
#if defined (WIN32) || defined (LINUX) || defined(IOS)
#else
#if defined (PSP)
#include <pspiofilemgr.h>
#include <pspiofilemgr_fcntl.h>
#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;

View File

@@ -28,18 +28,26 @@
#include <Qt>
typedef u32 LocalKeySym;
#define LOCAL_KEY_NONE Qt::Key_unknown
#elif defined(WIN32)
#include <windows.h>
typedef WPARAM LocalKeySym;
#define LOCAL_KEY_NONE ((WPARAM)-1)
#elif defined(LINUX)
#include <X11/XKBlib.h>
#include <X11/keysym.h>
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

View File

@@ -11,15 +11,9 @@
#ifndef _MD2MODEL_H
#define _MD2MODEL_H
#if defined (WIN32) || defined (LINUX) || defined (IOS)
#else
#if defined (PSP)
#include <pspgu.h>
#include <pspgum.h>
#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;

View File

@@ -15,15 +15,9 @@
using namespace std;
#if defined (WIN32) || defined (LINUX) || defined (IOS)
#else
#if defined (PSP)
#include <pspgu.h>
#include <pspgum.h>
#endif

View File

@@ -16,9 +16,9 @@
#include <string.h>
#include <stdarg.h>
#if (!defined IOS)
#if (!defined IOS) && (!defined ANDROID)
#include <gif_lib.h>
#endif //IOS
#endif //IOS ANDROID
#include "JTypes.h"
@@ -27,9 +27,7 @@
#include <windows.h>
#elif defined (LINUX) || defined(IOS)
#else
#elif defined (PSP)
#include <pspgu.h>
#include <pspkernel.h>
@@ -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)

View File

@@ -27,10 +27,7 @@
#include <windows.h>
#define WITH_FMOD
#elif defined (LINUX) || defined (IOS)
#else
#elif defined (PSP)
#include <pspgu.h>
#include <pspkernel.h>
#include <pspdisplay.h>
@@ -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
};

View File

@@ -11,10 +11,10 @@
#ifndef _SPRITE_H_
#define _SPRITE_H_
#if defined (WIN32) || defined(LINUX) || defined(IOS)
#include <math.h>
#else
#if defined (PSP)
#include <fastmath.h>
#else
#include <math.h>
#endif
#include <vector>

View File

@@ -11,11 +11,7 @@
#ifndef _JTYPES_H
#define _JTYPES_H
#if defined (WIN32) || defined (LINUX) || defined (IOS)
#include <stdint.h>
#else
#if defined (PSP)
#include <pspgu.h>
#include <pspgum.h>
@@ -27,9 +23,12 @@
#include <string.h>
#include <pspaudiolib.h>
#include <psprtc.h>
#include "JAudio.h"
#else
#include <stdint.h>
#endif
#ifndef __GNUC__
@@ -46,6 +45,11 @@ enum {
JGE_ERR_GENERIC = -5,
};
#ifdef PSP
#include <fastmath.h>
#else
#include <math.h>
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846f
@@ -81,7 +85,7 @@ enum {
#ifdef WIN32
#include <windows.h>
#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 <OpenGLES/ES2/glext.h>
#import <OpenGLES/ES1/gl.h>
# import <OpenGLES/ES1/glext.h>
#elif defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#elif defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
//Android GL1 support TODO
/*
#elif defined (ANDROID)
#include <GLES/gl.h>
#include <GLES/glext.h>
*/
//Android GL2 support
#elif defined (ANDROID)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#else
# include <QtOpenGL>
#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;

View File

@@ -1,7 +1,7 @@
#ifndef THREADING_H
#define THREADING_H
#if defined (WIN32) || defined (LINUX)
#if !defined(PSP)
#include <boost/date_time.hpp>
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>

View File

@@ -11,12 +11,10 @@
#ifndef _VECTOR2D_H
#define _VECTOR2D_H
#ifdef WIN32
#include <math.h>
#elif (defined LINUX) || (defined IOS)
#include <math.h>
#else
#ifdef PSP
#include <fastmath.h>
#else
#include <math.h>
#endif

View File

@@ -18,6 +18,7 @@
#include "hgerect.h"
#include <list>
#include <string.h>
class JQuad;

Binary file not shown.

View File

@@ -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
}
}
}

View File

@@ -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
//////////////////////////////////////////////////////////////////////////

View File

@@ -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;

View File

@@ -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();

View File

@@ -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)

View File

@@ -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;
/*

View File

@@ -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

View File

@@ -3,9 +3,7 @@
#include <JGE.h>
#if defined (WIN32) || defined (LINUX) || defined (IOS)
#else
#if defined (PSP)
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>

View File

@@ -3,10 +3,10 @@
#include <JGE.h>
#include <JLogger.h>
#include <JRenderer.h>
#if defined (WIN32) || defined (LINUX) || defined (IOS)
#include <time.h>
#else
#if defined (PSP)
#include <pspfpu.h>
#else
#include <time.h>
#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();

View File

@@ -10,7 +10,7 @@ using std::map;
static map<const LocalKeySym, KeyRep> fattable;
static map<const JButton, KeyRep> 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<JQuad*>(NULL));
fattable[key] = k;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}