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
+5 -6
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();
+3 -3
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;
+1 -2
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;
+46 -47
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;
}
+8 -10
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;
}