J :
* Update for linux support.
This commit is contained in:
@@ -3186,7 +3186,7 @@ static int _gbk_mbtowc(ucs4_t *pwc, const u8 *s, int n)
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
|
||||
static int ascii_mbtowc ( ucs4_t *pwc, const u8 *s, int n)
|
||||
static int ascii_mbtowc ( ucs4_t *pwc, const u8 *s, int n __attribute__((unused)))
|
||||
{
|
||||
u8 c = *s;
|
||||
if (c < 0x80) {
|
||||
|
||||
@@ -67,7 +67,7 @@ bool JAnimator::Load(const char* scriptFile)
|
||||
element = script->ToElement();
|
||||
printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name"));
|
||||
|
||||
char *type[] =
|
||||
const char *type[] =
|
||||
{
|
||||
"ANIMATION_TYPE_LOOPING",
|
||||
"ANIMATION_TYPE_ONCE_AND_STAY",
|
||||
@@ -317,7 +317,7 @@ void JAnimator::SetHotSpot(float x, float y)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JAnimatorFrame::JAnimatorFrame(JAnimator* parent)
|
||||
JAnimatorFrame::JAnimatorFrame(JAnimator* parent __attribute__((unused)))
|
||||
{
|
||||
mTimer = 0.0f;
|
||||
mFrameTime = 100.0f;
|
||||
@@ -390,7 +390,7 @@ JAnimatorObject::~JAnimatorObject()
|
||||
|
||||
}
|
||||
|
||||
void JAnimatorObject::Update(float dt)
|
||||
void JAnimatorObject::Update(float dt __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+18
-16
@@ -3,12 +3,14 @@
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#pragma warning(disable : 4786)
|
||||
#ifndef LINUX
|
||||
#pragma warning(disable : 4786)
|
||||
#endif
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
@@ -47,7 +49,7 @@ void JFileSystem::Destroy()
|
||||
JFileSystem::JFileSystem()
|
||||
{
|
||||
mZipAvailable = false;
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mFile = NULL;
|
||||
#else
|
||||
mFile = -1;
|
||||
@@ -56,7 +58,7 @@ JFileSystem::JFileSystem()
|
||||
mZipFile = NULL;
|
||||
mFileSize = 0;
|
||||
|
||||
mResourceRoot = "Res/"; // default root folder
|
||||
mResourceRoot = "Res/"; // default root folder
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +76,7 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
|
||||
if (mZipFileName != zipfile)
|
||||
unzCloseCurrentFile(mZipFile); // close the previous zip file
|
||||
}
|
||||
|
||||
|
||||
mZipFileName = zipfile;
|
||||
mPassword = password;
|
||||
|
||||
@@ -96,7 +98,7 @@ void JFileSystem::DetachZipFile()
|
||||
{
|
||||
unzCloseCurrentFile(mZipFile);
|
||||
}
|
||||
|
||||
|
||||
mZipFile = NULL;
|
||||
mZipAvailable = false;
|
||||
}
|
||||
@@ -119,12 +121,12 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
mFileSize = fileInfo.uncompressed_size;
|
||||
else
|
||||
mFileSize = 0;
|
||||
|
||||
|
||||
return (unzOpenCurrentFilePassword(mZipFile, mPassword) == UNZ_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mFile = fopen(path.c_str(), "rb");
|
||||
if (mFile != NULL)
|
||||
{
|
||||
@@ -141,13 +143,13 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
sceIoLseek(mFile, 0, PSP_SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +158,7 @@ void JFileSystem::CloseFile()
|
||||
if (mZipAvailable && mZipFile != NULL)
|
||||
return;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
if (mFile != NULL)
|
||||
fclose(mFile);
|
||||
#else
|
||||
@@ -174,7 +176,7 @@ int JFileSystem::ReadFile(void *buffer, int size)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
return fread(buffer, 1, size, mFile);
|
||||
#else
|
||||
return sceIoRead(mFile, buffer, size);
|
||||
|
||||
+36
-36
@@ -3,7 +3,7 @@
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
// Copyright (c) 2007 Sijiu Duan (a.k.a. Chi80) <sijiu49@gmail.com>
|
||||
//
|
||||
@@ -89,7 +89,7 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
|
||||
mSprites = new JQuad*[mCacheSize];
|
||||
mGBCode = new int[mCacheSize];
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mCharBuffer = new DWORD[mFontSize*mFontSize];
|
||||
#endif
|
||||
|
||||
@@ -104,7 +104,7 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
|
||||
|
||||
mSprites[index] = new JQuad(mTexture, x*mFontSize, y*mFontSize, mFontSize, mFontSize);
|
||||
mSprites[index]->SetHotSpot(mFontSize/2, mFontSize/2);
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#else
|
||||
void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width, unsigned int height)
|
||||
{
|
||||
@@ -171,24 +171,24 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
code = ((DWORD)*ch)|0x10000;
|
||||
isChinese = false;
|
||||
}
|
||||
|
||||
|
||||
if (mGBCode[mCurr] != -1)
|
||||
{
|
||||
|
||||
|
||||
for (int i=0;i<mCacheSize;i++)
|
||||
{
|
||||
if (mGBCode[i] == code)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mCount++;
|
||||
|
||||
int index = mCurr++;
|
||||
if (mCurr >= mCacheSize)
|
||||
mCurr = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
@@ -206,14 +206,14 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
if (isChinese)
|
||||
{
|
||||
|
||||
|
||||
src = mChnFont + code * mBytesPerChar;
|
||||
for (int i=0;i<mBytesPerChar;)
|
||||
{
|
||||
|
||||
bitCount = mFontSize;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
x = 0;
|
||||
#else
|
||||
x = (int)mSprites[index]->mX;
|
||||
@@ -225,7 +225,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
BYTE bitMask = 0x80;
|
||||
for (int z=0;z<8&&bitCount;z++)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
if ((bits & bitMask) != 0)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
|
||||
else
|
||||
@@ -240,9 +240,9 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
x++;
|
||||
|
||||
bitCount--;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
y++;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
for (int i=0;i<size;)
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
x = 0;
|
||||
#else
|
||||
x = (int)mSprites[index]->mX;
|
||||
@@ -266,10 +266,10 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
// put char in the middle
|
||||
if (mFontSize <= 16)
|
||||
{
|
||||
|
||||
|
||||
for (n=0;n<(mFontSize-8)/2;n++)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
|
||||
@@ -286,7 +286,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
BYTE bitMask = 0x80;
|
||||
for (int z=0;z<8&&bitCount;z++)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
if ((bits & bitMask) != 0)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
|
||||
else
|
||||
@@ -296,7 +296,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
SwizzlePlot(pTexture, ARGB(255,255,255,255), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
|
||||
else
|
||||
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
|
||||
#endif
|
||||
#endif
|
||||
x++;
|
||||
bitMask >>= 1;
|
||||
bitCount--;
|
||||
@@ -305,10 +305,10 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
if (mFontSize <= 16)
|
||||
{
|
||||
|
||||
|
||||
for (n=0;n<(mFontSize-8)/2;n++)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
|
||||
@@ -321,15 +321,15 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mGBCode[index] = code;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
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();
|
||||
//sceKernelDcacheWritebackInvalidateAll();
|
||||
@@ -383,7 +383,7 @@ void JGBKFont::RenderEncodedString(const int* text, int count, float x, float y)
|
||||
}
|
||||
else if (text[n] == 0x8000d)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,7 +441,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
|
||||
}
|
||||
src += 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (*src > 0x80)
|
||||
{
|
||||
@@ -467,7 +467,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
if (*src < ' ') // control characters
|
||||
@@ -481,7 +481,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
|
||||
}
|
||||
src += 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (*src > 0x80)
|
||||
{
|
||||
@@ -512,8 +512,8 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
|
||||
yy += (mFontSize*mScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (xx>len)
|
||||
{
|
||||
@@ -528,7 +528,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
{
|
||||
int w=0;
|
||||
int h=0;
|
||||
|
||||
|
||||
switch(alignment)
|
||||
{
|
||||
case JGETEXT_RIGHT:
|
||||
@@ -551,9 +551,9 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
float xx = x;
|
||||
float yy = y;
|
||||
int index;
|
||||
|
||||
|
||||
bool isChinese=true;
|
||||
|
||||
|
||||
while (*src != 0)
|
||||
{
|
||||
if (yy + mFontSize < 0.0f) // don't render when outside viewport
|
||||
@@ -567,7 +567,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
}
|
||||
src += 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (*src > 0x80)
|
||||
{
|
||||
@@ -591,7 +591,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
|
||||
if (*src < ' ') // control characters
|
||||
@@ -603,7 +603,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
}
|
||||
src += 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (*src > 0x80)
|
||||
{
|
||||
@@ -621,7 +621,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
|
||||
xx-=3*(mFontSize*mScale)/16;
|
||||
isChinese = false;
|
||||
}
|
||||
|
||||
|
||||
mSprites[index]->SetColor(mColor);
|
||||
mRenderer->RenderQuad(mSprites[index], xx, yy, mRotation, mScale, mScale);
|
||||
if (mSmallEnglishFont && !isChinese)
|
||||
|
||||
+95
-63
@@ -3,9 +3,9 @@
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include "../include/JGE.h"
|
||||
@@ -19,16 +19,71 @@
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifdef WIN32
|
||||
|
||||
#if defined (WIN32) // WIN32 specific code
|
||||
#include "../../Dependencies/include/png.h"
|
||||
#include "../../Dependencies/include/fmod.h"
|
||||
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
return (int)GetTickCount();
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#elif defined (LINUX) // Unix specific code
|
||||
#include "png.h"
|
||||
#include "../Dependencies/include/fmod.h"
|
||||
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
return (int)time(NULL);
|
||||
}
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
*/
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
/* FIXME
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
*/
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) // Non-PSP code
|
||||
|
||||
JGE::JGE()
|
||||
{
|
||||
mApp = NULL;
|
||||
|
||||
|
||||
strcpy(mDebuggingMsg, "");
|
||||
mCurrentMusic = NULL;
|
||||
Init();
|
||||
@@ -54,25 +109,25 @@ JGE::~JGE()
|
||||
|
||||
// if (mResourceManager != NULL)
|
||||
// delete mResourceManager;
|
||||
//
|
||||
//
|
||||
// if (mFileSystem != NULL)
|
||||
// delete mFileSystem;
|
||||
//
|
||||
//
|
||||
// if (mParticleSystem != NULL)
|
||||
// delete mParticleSystem;
|
||||
//
|
||||
//
|
||||
// if (mMotionSystem != NULL)
|
||||
// delete mMotionSystem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
mDone = false;
|
||||
mPaused = false;
|
||||
mCriticalAssert = false;
|
||||
|
||||
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
@@ -83,7 +138,7 @@ void JGE::Init()
|
||||
|
||||
void JGE::Run()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void JGE::SetDelta(int delta)
|
||||
@@ -91,12 +146,6 @@ void JGE::SetDelta(int delta)
|
||||
mDeltaTime = (float)delta / 1000.0f; // change to second
|
||||
}
|
||||
|
||||
int JGE::GetTime(void)
|
||||
{
|
||||
return (int)GetTickCount();
|
||||
}
|
||||
|
||||
|
||||
float JGE::GetDelta()
|
||||
{
|
||||
return mDeltaTime;
|
||||
@@ -125,23 +174,6 @@ bool JGE::GetButtonClick(u32 button)
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
if (JGEGetKeyState(VK_UP)) return 0;
|
||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||
|
||||
return 0x80;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#else ///// PSP specified code
|
||||
@@ -149,7 +181,7 @@ u8 JGE::GetAnalogY()
|
||||
|
||||
|
||||
// include all the following so we only have one .o file
|
||||
//#include "../src/JGfx.cpp"
|
||||
//#include "../src/JGfx.cpp"
|
||||
//#include "../src/JSfx.cpp"
|
||||
|
||||
|
||||
@@ -193,7 +225,7 @@ JGE::~JGE()
|
||||
void JGE::Init()
|
||||
{
|
||||
|
||||
#ifdef DEBUG_PRINT
|
||||
#ifdef DEBUG_PRINT
|
||||
mDebug = true;
|
||||
#else
|
||||
mDebug = false;
|
||||
@@ -201,12 +233,12 @@ void JGE::Init()
|
||||
|
||||
if (mDebug)
|
||||
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
|
||||
|
||||
|
||||
strcpy(mDebuggingMsg, "");
|
||||
|
||||
sceCtrlSetSamplingCycle(0);
|
||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
||||
|
||||
|
||||
JRenderer::GetInstance();
|
||||
JFileSystem::GetInstance();
|
||||
JSoundSystem::GetInstance();
|
||||
@@ -218,7 +250,7 @@ void JGE::Init()
|
||||
//InitSfx();
|
||||
|
||||
//Create();
|
||||
|
||||
|
||||
// mCurrMS = 1.0f;
|
||||
// mFPSSlice = 0;
|
||||
|
||||
@@ -228,9 +260,9 @@ void JGE::Init()
|
||||
|
||||
//mLastTime = GetTime();
|
||||
|
||||
|
||||
|
||||
mTickFrequency = sceRtcGetTickResolution();
|
||||
sceRtcGetCurrentTick(&mLastTime);
|
||||
sceRtcGetCurrentTick(&mLastTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +272,7 @@ int JGE::GetTime(void)
|
||||
|
||||
u64 curr;
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
|
||||
|
||||
return (int)(curr / mTickFrequency);
|
||||
}
|
||||
|
||||
@@ -257,28 +289,28 @@ float JGE::GetFPS()
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonState(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button;
|
||||
bool JGE::GetButtonState(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool JGE::GetButtonClick(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button;
|
||||
bool JGE::GetButtonClick(u32 button)
|
||||
{
|
||||
return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
return mCtrlPad.Lx;
|
||||
u8 JGE::GetAnalogX()
|
||||
{
|
||||
return mCtrlPad.Lx;
|
||||
}
|
||||
|
||||
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
return mCtrlPad.Ly;
|
||||
u8 JGE::GetAnalogY()
|
||||
{
|
||||
return mCtrlPad.Ly;
|
||||
}
|
||||
|
||||
|
||||
@@ -292,14 +324,14 @@ void JGE::Run()
|
||||
if (!mPaused)
|
||||
{
|
||||
sceRtcGetCurrentTick(&curr);
|
||||
|
||||
|
||||
mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f;
|
||||
|
||||
|
||||
mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f;
|
||||
mLastTime = curr;
|
||||
|
||||
|
||||
sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
|
||||
// because sceCtrlReadBufferPositive waits for vsync internally
|
||||
|
||||
|
||||
Update();
|
||||
|
||||
Render();
|
||||
@@ -314,13 +346,13 @@ void JGE::Run()
|
||||
}
|
||||
|
||||
mOldButtons = mCtrlPad.Buttons;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif ///// PSP specified code
|
||||
@@ -336,7 +368,7 @@ JGE* JGE::GetInstance()
|
||||
{
|
||||
mInstance = new JGE();
|
||||
}
|
||||
|
||||
|
||||
//gCount++;
|
||||
return mInstance;
|
||||
}
|
||||
@@ -388,7 +420,7 @@ void JGE::End()
|
||||
void JGE::printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
|
||||
|
||||
va_start(list, format);
|
||||
vsprintf(mDebuggingMsg, format, list);
|
||||
va_end(list);
|
||||
|
||||
+140
-140
@@ -3,9 +3,9 @@
|
||||
// JGE is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include <malloc.h>
|
||||
@@ -64,15 +64,15 @@ JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
|
||||
}
|
||||
|
||||
|
||||
void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
|
||||
{
|
||||
*x=mX; *y=mY; *w=mWidth; *h=mHeight;
|
||||
void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
|
||||
{
|
||||
*x=mX; *y=mY; *w=mWidth; *h=mHeight;
|
||||
}
|
||||
|
||||
|
||||
void JQuad::SetTextureRect(float x, float y, float w, float h)
|
||||
{
|
||||
mX = x; mY = y; mWidth = w; mHeight = h;
|
||||
void JQuad::SetTextureRect(float x, float y, float w, float h)
|
||||
{
|
||||
mX = x; mY = y; mWidth = w; mHeight = h;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ JRenderer* JRenderer::GetInstance()
|
||||
mInstance = new JRenderer();
|
||||
mInstance->InitRenderer();
|
||||
}
|
||||
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ JRenderer::JRenderer()
|
||||
|
||||
JRenderer::~JRenderer()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void JRenderer::ResetPrivateVRAM()
|
||||
{
|
||||
//mCurrentPointer = mVideoBufferStart;
|
||||
void JRenderer::ResetPrivateVRAM()
|
||||
{
|
||||
//mCurrentPointer = mVideoBufferStart;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,11 +195,11 @@ void JRenderer::InitRenderer()
|
||||
|
||||
mSwizzle = 1;
|
||||
mVsync = false;
|
||||
|
||||
|
||||
mTexCounter = 0;
|
||||
mCurrentTex = -1;
|
||||
mCurrentBlend = -1;
|
||||
|
||||
|
||||
mFOV = 75.0f;
|
||||
|
||||
mImageFilter = NULL;
|
||||
@@ -227,7 +227,7 @@ void JRenderer::InitRenderer()
|
||||
}
|
||||
|
||||
//mCurrentPointer = mVideoBufferStart;
|
||||
|
||||
|
||||
sceGuOffset(2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2));
|
||||
sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@@ -235,15 +235,15 @@ void JRenderer::InitRenderer()
|
||||
//sceGuFrontFace(GU_CW);
|
||||
sceGuFrontFace(GU_CCW);
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
|
||||
|
||||
sceGuShadeModel(GU_SMOOTH);
|
||||
|
||||
|
||||
sceGuTexWrap(GU_REPEAT, GU_REPEAT);
|
||||
|
||||
// enable alpha channel
|
||||
sceGuEnable(GU_BLEND);
|
||||
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
|
||||
|
||||
|
||||
sceGuTexFilter(GU_LINEAR,GU_LINEAR);
|
||||
|
||||
if (m3DEnabled)
|
||||
@@ -260,7 +260,7 @@ void JRenderer::InitRenderer()
|
||||
sceGuClearDepth(0);
|
||||
|
||||
sceGuTexEnvColor(0xffffffff);
|
||||
|
||||
|
||||
sceGuTexScale(1.0f,1.0f);
|
||||
sceGuTexOffset(0.0f,0.0f);
|
||||
sceGuAmbientColor(0xffffffff);
|
||||
@@ -288,7 +288,7 @@ void JRenderer::SetTexBlend(int src, int dest)
|
||||
{
|
||||
mCurrTexBlendSrc = src;
|
||||
mCurrTexBlendDest = dest;
|
||||
|
||||
|
||||
int fixSrc = 0;
|
||||
int fixDest = 0;
|
||||
if (src == BLEND_ZERO)
|
||||
@@ -305,7 +305,7 @@ void JRenderer::SetTexBlend(int src, int dest)
|
||||
dest = GU_FIX;
|
||||
fixDest = 0x00FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
//glBlendFunc(src, dest);
|
||||
sceGuBlendFunc(GU_ADD, src, dest, fixSrc, fixDest);
|
||||
}
|
||||
@@ -343,9 +343,9 @@ void JRenderer::BeginScene()
|
||||
//if (mMode3D)
|
||||
sceGuClear(GU_DEPTH_BUFFER_BIT|GU_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
||||
sceGuTexMode(TEXTURE_FORMAT, 0, 0, mSwizzle);
|
||||
|
||||
sceGuTexMode(TEXTURE_FORMAT, 0, 0, mSwizzle);
|
||||
|
||||
if (mCurrentTextureFilter == TEX_FILTER_NEAREST)
|
||||
sceGuTexFilter(GU_NEAREST, GU_NEAREST); // GU_NEAREST good for tile-map
|
||||
@@ -362,7 +362,7 @@ void JRenderer::EndScene()
|
||||
|
||||
if (mVsync)
|
||||
sceDisplayWaitVblankStart();
|
||||
|
||||
|
||||
sceGuSwapBuffers();
|
||||
|
||||
mCurrentTex = -1;
|
||||
@@ -371,8 +371,8 @@ void JRenderer::EndScene()
|
||||
|
||||
|
||||
void JRenderer::EnableVSync(bool flag)
|
||||
{
|
||||
mVsync = flag;
|
||||
{
|
||||
mVsync = flag;
|
||||
}
|
||||
|
||||
|
||||
@@ -390,13 +390,13 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(2 * sizeof(struct VertexColor));
|
||||
|
||||
vertices[0].color = color;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[1].color = color;
|
||||
vertices[1].x = x + width;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].x = x + width;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
@@ -414,44 +414,44 @@ void JRenderer::FillRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
|
||||
|
||||
vertices[0].color = colors[0];
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[1].color = colors[1];
|
||||
vertices[1].x = x + width;
|
||||
vertices[1].y = y;
|
||||
vertices[1].x = x + width;
|
||||
vertices[1].y = y;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
vertices[2].color = colors[2];
|
||||
vertices[2].x = x;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].x = x;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].z = 0.0f;
|
||||
|
||||
vertices[3].color = colors[3];
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y + height;
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y + height;
|
||||
vertices[3].z = 0.0f;
|
||||
/*
|
||||
|
||||
vertices[0].color = colors[0];
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[1].color = colors[1];
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
vertices[2].color = colors[2];
|
||||
vertices[2].x = x + width;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].x = x + width;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].z = 0.0f;
|
||||
|
||||
vertices[3].color = colors[3];
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y;
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y;
|
||||
vertices[3].z = 0.0f;
|
||||
*/
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
@@ -468,28 +468,28 @@ void JRenderer::DrawRect(float x, float y, float width, float height, PIXEL_TYPE
|
||||
struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(5 * sizeof(struct VertexColor));
|
||||
|
||||
vertices[0].color = color;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[1].color = color;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + height;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
vertices[2].color = color;
|
||||
vertices[2].x = x + width;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].x = x + width;
|
||||
vertices[2].y = y + height;
|
||||
vertices[2].z = 0.0f;
|
||||
|
||||
vertices[3].color = color;
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y;
|
||||
vertices[3].x = x + width;
|
||||
vertices[3].y = y;
|
||||
vertices[3].z = 0.0f;
|
||||
|
||||
vertices[4].color = color;
|
||||
vertices[4].x = x;
|
||||
vertices[4].y = y;
|
||||
vertices[4].x = x;
|
||||
vertices[4].y = y;
|
||||
vertices[4].z = 0.0f;
|
||||
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
@@ -506,13 +506,13 @@ void JRenderer::DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE colo
|
||||
struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(2 * sizeof(struct VertexColor));
|
||||
|
||||
vertices[0].color = color;
|
||||
vertices[0].x = x1;
|
||||
vertices[0].y = y1;
|
||||
vertices[0].x = x1;
|
||||
vertices[0].y = y1;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[1].color = color;
|
||||
vertices[1].x = x2;
|
||||
vertices[1].y = y2;
|
||||
vertices[1].x = x2;
|
||||
vertices[1].y = y2;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
@@ -529,8 +529,8 @@ void JRenderer::Plot(float x, float y, PIXEL_TYPE color)
|
||||
struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(1 * sizeof(struct VertexColor));
|
||||
|
||||
vertices[0].color = color;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
@@ -549,8 +549,8 @@ void JRenderer::PlotArray(float *x, float *y, int count, PIXEL_TYPE color)
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
vertices[i].color = color;
|
||||
vertices[i].x = x[i];
|
||||
vertices[i].y = y[i];
|
||||
vertices[i].x = x[i];
|
||||
vertices[i].y = y[i];
|
||||
vertices[i].z = 0.0f;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
|
||||
if (mCurrentBlend != quad->mBlend)
|
||||
{
|
||||
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
|
||||
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
|
||||
mCurrentBlend = quad->mBlend;
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
|
||||
if (quad->mHFlipped)// || quad->mVFlipped)
|
||||
{
|
||||
|
||||
|
||||
for (end = quad->mX, start = quad->mX+quad->mWidth; start > end; start -= SLICE_SIZE_F)
|
||||
{
|
||||
// allocate memory on the current display list for temporary storage
|
||||
@@ -616,32 +616,32 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
destWidth = width*xScale;
|
||||
}
|
||||
|
||||
vertices[0].u = start;
|
||||
vertices[0].u = start;
|
||||
vertices[0].v = quad->mY;
|
||||
vertices[0].color = quad->mColor[0];//.color;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[2].u = start - width;
|
||||
vertices[2].u = start - width;
|
||||
vertices[2].v = quad->mY;
|
||||
vertices[2].color = quad->mColor[2];//.color;
|
||||
vertices[2].x = x + destWidth;
|
||||
vertices[2].y = y;
|
||||
vertices[2].x = x + destWidth;
|
||||
vertices[2].y = y;
|
||||
vertices[2].z = 0.0f;
|
||||
|
||||
vertices[1].u = start;
|
||||
vertices[1].u = start;
|
||||
vertices[1].v = quad->mY + quad->mHeight;
|
||||
vertices[1].color = quad->mColor[1];//.color;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + destHeight;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + destHeight;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
vertices[3].u = start - width;
|
||||
vertices[3].u = start - width;
|
||||
vertices[3].v = quad->mY + quad->mHeight;
|
||||
vertices[3].color = quad->mColor[3];//.color;
|
||||
vertices[3].x = x + destWidth;
|
||||
vertices[3].y = y + destHeight;
|
||||
vertices[3].x = x + destWidth;
|
||||
vertices[3].y = y + destHeight;
|
||||
vertices[3].z = 0.0f;
|
||||
|
||||
if (quad->mVFlipped)
|
||||
@@ -655,7 +655,7 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
xx = (cosAngle*(vertices[i].x-xo) - sinAngle*(vertices[i].y-yo) + xo);
|
||||
yy = (sinAngle*(vertices[i].x-xo) + cosAngle*(vertices[i].y-yo) + yo);
|
||||
yy = (sinAngle*(vertices[i].x-xo) + cosAngle*(vertices[i].y-yo) + yo);
|
||||
vertices[i].x = xx;
|
||||
vertices[i].y = yy;
|
||||
}
|
||||
@@ -684,32 +684,32 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
destWidth = width*xScale;
|
||||
}
|
||||
|
||||
vertices[0].u = start;
|
||||
vertices[0].u = start;
|
||||
vertices[0].v = quad->mY;
|
||||
vertices[0].color = quad->mColor[0];//.color;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].x = x;
|
||||
vertices[0].y = y;
|
||||
vertices[0].z = 0.0f;
|
||||
|
||||
vertices[2].u = start + width;
|
||||
vertices[2].u = start + width;
|
||||
vertices[2].v = quad->mY;
|
||||
vertices[2].color = quad->mColor[2];//.color;
|
||||
vertices[2].x = x + destWidth;
|
||||
vertices[2].y = y;
|
||||
vertices[2].x = x + destWidth;
|
||||
vertices[2].y = y;
|
||||
vertices[2].z = 0.0f;
|
||||
|
||||
vertices[1].u = start;
|
||||
vertices[1].u = start;
|
||||
vertices[1].v = quad->mY + quad->mHeight;
|
||||
vertices[1].color = quad->mColor[1];//.color;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + destHeight;
|
||||
vertices[1].x = x;
|
||||
vertices[1].y = y + destHeight;
|
||||
vertices[1].z = 0.0f;
|
||||
|
||||
vertices[3].u = start + width;
|
||||
vertices[3].u = start + width;
|
||||
vertices[3].v = quad->mY + quad->mHeight;
|
||||
vertices[3].color = quad->mColor[3];//.color;
|
||||
vertices[3].x = x + destWidth;
|
||||
vertices[3].y = y + destHeight;
|
||||
vertices[3].x = x + destWidth;
|
||||
vertices[3].y = y + destHeight;
|
||||
vertices[3].z = 0.0f;
|
||||
|
||||
if (quad->mVFlipped)
|
||||
@@ -717,13 +717,13 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
|
||||
Swap(&vertices[0].v, &vertices[2].v);
|
||||
Swap(&vertices[1].v, &vertices[3].v);
|
||||
}
|
||||
|
||||
|
||||
if (angle != 0.0f)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
xx = (cosAngle*(vertices[i].x-xo) - sinAngle*(vertices[i].y-yo) + xo);
|
||||
yy = (sinAngle*(vertices[i].x-xo) + cosAngle*(vertices[i].y-yo) + yo);
|
||||
yy = (sinAngle*(vertices[i].x-xo) + cosAngle*(vertices[i].y-yo) + yo);
|
||||
vertices[i].x = xx;
|
||||
vertices[i].y = yy;
|
||||
}
|
||||
@@ -747,7 +747,7 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
|
||||
|
||||
if (mCurrentBlend != quad->mBlend)
|
||||
{
|
||||
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
|
||||
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
|
||||
mCurrentBlend = quad->mBlend;
|
||||
}
|
||||
|
||||
@@ -755,49 +755,49 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
|
||||
// in order to rotate, we use 4 vertices this time
|
||||
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(4 * sizeof(struct Vertex));
|
||||
|
||||
vertices[0].u = quad->mX;
|
||||
vertices[0].u = quad->mX;
|
||||
vertices[0].v = quad->mY;
|
||||
|
||||
vertices[1].u = quad->mX;
|
||||
vertices[1].u = quad->mX;
|
||||
vertices[1].v = quad->mY + quad->mHeight;
|
||||
|
||||
vertices[2].u = quad->mX + quad->mWidth;
|
||||
vertices[2].u = quad->mX + quad->mWidth;
|
||||
vertices[2].v = quad->mY;
|
||||
|
||||
vertices[3].u = quad->mX + quad->mWidth;
|
||||
vertices[3].u = quad->mX + quad->mWidth;
|
||||
vertices[3].v = quad->mY + quad->mHeight;
|
||||
|
||||
// for (int i=0;i<4;i++)
|
||||
// {
|
||||
// vertices[i].color = points[i].color;
|
||||
// vertices[i].x = points[i].x;
|
||||
// vertices[i].y = points[i].y;
|
||||
// vertices[i].x = points[i].x;
|
||||
// vertices[i].y = points[i].y;
|
||||
// vertices[i].z = points[i].z;
|
||||
// }
|
||||
|
||||
vertices[0].color = points[3].color;
|
||||
vertices[0].x = points[3].x;
|
||||
vertices[0].y = points[3].y;
|
||||
vertices[0].x = points[3].x;
|
||||
vertices[0].y = points[3].y;
|
||||
vertices[0].z = points[3].z;
|
||||
|
||||
vertices[1].color = points[0].color;
|
||||
vertices[1].x = points[0].x;
|
||||
vertices[1].y = points[0].y;
|
||||
vertices[1].x = points[0].x;
|
||||
vertices[1].y = points[0].y;
|
||||
vertices[1].z = points[0].z;
|
||||
|
||||
vertices[2].color = points[2].color;
|
||||
vertices[2].x = points[2].x;
|
||||
vertices[2].y = points[2].y;
|
||||
vertices[2].x = points[2].x;
|
||||
vertices[2].y = points[2].y;
|
||||
vertices[2].z = points[2].z;
|
||||
|
||||
vertices[3].color = points[1].color;
|
||||
vertices[3].x = points[1].x;
|
||||
vertices[3].y = points[1].y;
|
||||
vertices[3].x = points[1].x;
|
||||
vertices[3].y = points[1].y;
|
||||
vertices[3].z = points[1].z;
|
||||
|
||||
|
||||
|
||||
sceGuDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_32BITF|TEXTURE_COLOR_FORMAT|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, vertices);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ void JRenderer::ScreenShot(const char* filename)
|
||||
png_infop info_ptr;
|
||||
FILE* fp;
|
||||
u8* line;
|
||||
|
||||
|
||||
fp = fopen(filename, "wb");
|
||||
if (!fp) return;
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
@@ -849,25 +849,25 @@ void JRenderer::ScreenShot(const char* filename)
|
||||
switch (pixelformat) {
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_565:
|
||||
color = vram16[x + y * bufferwidth];
|
||||
r = (color & 0x1f) << 3;
|
||||
r = (color & 0x1f) << 3;
|
||||
g = ((color >> 5) & 0x3f) << 2 ;
|
||||
b = ((color >> 11) & 0x1f) << 3 ;
|
||||
break;
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_5551:
|
||||
color = vram16[x + y * bufferwidth];
|
||||
r = (color & 0x1f) << 3;
|
||||
r = (color & 0x1f) << 3;
|
||||
g = ((color >> 5) & 0x1f) << 3 ;
|
||||
b = ((color >> 10) & 0x1f) << 3 ;
|
||||
break;
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_4444:
|
||||
color = vram16[x + y * bufferwidth];
|
||||
r = (color & 0xf) << 4;
|
||||
r = (color & 0xf) << 4;
|
||||
g = ((color >> 4) & 0xf) << 4 ;
|
||||
b = ((color >> 8) & 0xf) << 4 ;
|
||||
break;
|
||||
case PSP_DISPLAY_PIXEL_FORMAT_8888:
|
||||
color = vram32[x + y * bufferwidth];
|
||||
r = color & 0xff;
|
||||
r = color & 0xff;
|
||||
g = (color >> 8) & 0xff;
|
||||
b = (color >> 16) & 0xff;
|
||||
break;
|
||||
@@ -921,16 +921,16 @@ static void swizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int
|
||||
{
|
||||
unsigned int blockx, blocky;
|
||||
unsigned int j;
|
||||
|
||||
|
||||
unsigned int width_blocks = (width / 16);
|
||||
unsigned int height_blocks = (height / 8);
|
||||
|
||||
|
||||
unsigned int src_pitch = (width-16)/4;
|
||||
unsigned int src_row = width * 8;
|
||||
|
||||
|
||||
const u8* ysrc = in;
|
||||
u32* dst = (u32*)out;
|
||||
|
||||
|
||||
for (blocky = 0; blocky < height_blocks; ++blocky)
|
||||
{
|
||||
const u8* xsrc = ysrc;
|
||||
@@ -1110,7 +1110,7 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
|
||||
textureInfo.mBits = (u8 *)bits;
|
||||
textureInfo.mWidth = cinfo.output_width;
|
||||
textureInfo.mWidth = cinfo.output_width;
|
||||
textureInfo.mHeight = cinfo.output_height;
|
||||
textureInfo.mTexWidth = tw;
|
||||
textureInfo.mTexHeight = th;
|
||||
@@ -1126,7 +1126,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
|
||||
TextureInfo textureInfo;
|
||||
textureInfo.mVRAM = false;
|
||||
textureInfo.mBits = NULL;
|
||||
|
||||
|
||||
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
|
||||
LoadJPG(textureInfo, filename, mode);
|
||||
else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL)
|
||||
@@ -1134,7 +1134,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
|
||||
else
|
||||
LoadPNG(textureInfo, filename, mode);
|
||||
|
||||
if (textureInfo.mBits == NULL)
|
||||
if (textureInfo.mBits == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -1192,7 +1192,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return;
|
||||
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL) {
|
||||
//fclose(fp);
|
||||
@@ -1226,7 +1226,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int texWidth = getNextPower2(width);
|
||||
int texHeight = getNextPower2(height);
|
||||
|
||||
@@ -1236,7 +1236,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
int size = texWidth * texHeight * sizeof(PIXEL_TYPE);
|
||||
|
||||
{
|
||||
|
||||
|
||||
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
|
||||
{
|
||||
//bits = (PIXEL_TYPE*) (0x04000000+0x40000000+mCurrentPointer);
|
||||
@@ -1251,7 +1251,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
videoRAMUsed = false;
|
||||
bits = (PIXEL_TYPE*) memalign(16, size);
|
||||
}
|
||||
|
||||
|
||||
PIXEL_TYPE* buffer = bits;
|
||||
|
||||
if (mSwizzle)
|
||||
@@ -1262,10 +1262,10 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
p32 = (u32*) buffer;
|
||||
p16 = (u16*) p32;
|
||||
|
||||
for (y = 0; y < (int)height; y++)
|
||||
for (y = 0; y < (int)height; y++)
|
||||
{
|
||||
png_read_row(png_ptr, (u8*) line, png_bytep_NULL);
|
||||
for (x = 0; x < (int)width; x++)
|
||||
for (x = 0; x < (int)width; x++)
|
||||
{
|
||||
u32 color32 = line[x];
|
||||
u16 color16;
|
||||
@@ -1309,9 +1309,9 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
free (line);
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||
|
||||
|
||||
fileSystem->CloseFile();
|
||||
|
||||
|
||||
if (done)
|
||||
{
|
||||
textureInfo.mBits = (u8 *)bits;
|
||||
@@ -1321,7 +1321,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
textureInfo.mTexHeight = texHeight;
|
||||
textureInfo.mVRAM = videoRAMUsed;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1375,7 +1375,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
||||
|
||||
switch (RecordType) {
|
||||
case IMAGE_DESC_RECORD_TYPE:
|
||||
{
|
||||
{
|
||||
if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)
|
||||
{
|
||||
DGifCloseFile(GifFileIn);
|
||||
@@ -1401,7 +1401,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
||||
|
||||
bool done = false;
|
||||
PIXEL_TYPE* bits = NULL;
|
||||
|
||||
|
||||
size = textureInfo.mTexWidth * textureInfo.mTexHeight * sizeof(PIXEL_TYPE);
|
||||
|
||||
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
|
||||
@@ -1440,7 +1440,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
||||
|
||||
DWORD * curr = p32;
|
||||
DWORD * imgdata = p32;
|
||||
for (i = 0; i < GifFileIn->Image.Height; i ++)
|
||||
for (i = 0; i < GifFileIn->Image.Height; i ++)
|
||||
{
|
||||
imgdata = curr;
|
||||
if (DGifGetLine(GifFileIn, LineIn, GifFileIn->Image.Width) == GIF_ERROR)
|
||||
@@ -1554,7 +1554,7 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
||||
//FILE * fp = fopen(filename, "rb");
|
||||
//if(fp == NULL)
|
||||
// return;
|
||||
|
||||
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(filename))
|
||||
return;
|
||||
@@ -1592,7 +1592,7 @@ JTexture* JRenderer::CreateTexture(int width, int height, int mode)
|
||||
|
||||
tex->mTexWidth = getNextPower2(width);
|
||||
tex->mTexHeight = getNextPower2(height);
|
||||
|
||||
|
||||
int size = tex->mTexWidth * tex->mTexHeight * sizeof(PIXEL_TYPE);
|
||||
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
|
||||
{
|
||||
@@ -1623,7 +1623,7 @@ JTexture* JRenderer::CreateTexture(int width, int height, int mode)
|
||||
// {
|
||||
// if (tex->mBits && !tex->mInVideoRAM)
|
||||
// free(tex->mBits);
|
||||
//
|
||||
//
|
||||
// delete tex;
|
||||
// tex = NULL;
|
||||
// }
|
||||
@@ -2036,7 +2036,7 @@ void JRenderer::DrawRoundRect( float x1,float y1, float w,float h,float radius,P
|
||||
JRenderer::GetInstance()->DrawLine(x1+(radius-q),y1+i+radius,x1+(radius-nextq),y1+i+radius,color);
|
||||
JRenderer::GetInstance()->DrawLine(x2+radius+q,y1+i+radius,x2+radius+nextq,y1+i+radius,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2077,7 +2077,7 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
||||
angle = 0;
|
||||
}
|
||||
|
||||
y+=h;
|
||||
y+=h;
|
||||
for(int i=90; i<135; i++)
|
||||
{
|
||||
vertices[i+1].color = color;
|
||||
|
||||
+3
-3
@@ -25,10 +25,10 @@ JGuiObject::JGuiObject(int id): mId(id)
|
||||
JGuiObject::~JGuiObject()
|
||||
{
|
||||
// JGERelease();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
bool JGuiObject::Leaving(u32 key)
|
||||
bool JGuiObject::Leaving(u32 key __attribute__((unused)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ int JGuiObject::GetId()
|
||||
}
|
||||
|
||||
|
||||
void JGuiObject::Update(float dt)
|
||||
void JGuiObject::Update(float dt __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+28
-28
@@ -3,9 +3,9 @@
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ JRenderer* JLBFont::mRenderer = NULL;
|
||||
JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
{
|
||||
mRenderer = JRenderer::GetInstance();
|
||||
|
||||
|
||||
mHeight = 0;
|
||||
mScale = 1.0f;
|
||||
mRotation = mSpacing = 0.0f;
|
||||
@@ -33,27 +33,27 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
mTexture = NULL;
|
||||
mQuad = NULL;
|
||||
mBase = 0;
|
||||
|
||||
|
||||
char filename[256];
|
||||
short buffer[1024];
|
||||
|
||||
|
||||
|
||||
|
||||
sprintf(filename, "%s.dat", fontname);
|
||||
|
||||
|
||||
//FILE *file;
|
||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||
if (!fileSys->OpenFile(filename)) return;
|
||||
|
||||
fileSys->ReadFile((u8 *)buffer, 2048);
|
||||
fileSys->CloseFile();
|
||||
|
||||
|
||||
sprintf(filename, "%s.png", fontname);
|
||||
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
||||
|
||||
if (mTexture == NULL) return;
|
||||
|
||||
|
||||
mHeight = (float) lineheight;
|
||||
|
||||
|
||||
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f, mHeight);
|
||||
|
||||
float a, b, c;
|
||||
@@ -63,7 +63,7 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
|
||||
// there are 16x16 characters in the texture map.
|
||||
float cellHeight = mTexture->mHeight/16.0f;
|
||||
|
||||
|
||||
int n = 0;
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
a = (float)buffer[n*4+1]; // character width
|
||||
b = (float)buffer[n*4+2];
|
||||
c = (float)buffer[n*4+3];
|
||||
|
||||
|
||||
mXPos[n] = x;
|
||||
mYPos[n] = y;
|
||||
mCharWidth[n] = a+b+c;
|
||||
@@ -83,18 +83,18 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
||||
|
||||
y += cellHeight;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
JLBFont::~JLBFont()
|
||||
{
|
||||
if (mQuad)
|
||||
delete mQuad;
|
||||
|
||||
if (mTexture)
|
||||
if (mTexture)
|
||||
delete mTexture;
|
||||
|
||||
|
||||
// JGERelease();
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
|
||||
float dx = x, dy = y;
|
||||
|
||||
if (mQuad == NULL) return;
|
||||
|
||||
|
||||
float width = GetStringWidth(string);
|
||||
|
||||
|
||||
if (align == JGETEXT_RIGHT)
|
||||
dx -= width;
|
||||
else if (align == JGETEXT_CENTER)
|
||||
@@ -123,7 +123,7 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
|
||||
p++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -131,11 +131,11 @@ void JLBFont::printf(float x, float y, const char *format, ...)
|
||||
{
|
||||
char buffer[PRINTF_BUFFER_SIZE];
|
||||
va_list list;
|
||||
|
||||
|
||||
va_start(list, format);
|
||||
vsprintf(buffer, format, list);
|
||||
va_end(list);
|
||||
|
||||
|
||||
DrawString(buffer, x, y);
|
||||
}
|
||||
|
||||
@@ -151,10 +151,10 @@ void JLBFont::SetColor(PIXEL_TYPE color)
|
||||
float JLBFont::GetStringWidth(const char *string) const
|
||||
{
|
||||
float len = 0.0f;
|
||||
|
||||
|
||||
const char *p = string;
|
||||
char ch;
|
||||
|
||||
|
||||
while (*p)
|
||||
{
|
||||
ch = *p - 32;
|
||||
@@ -162,7 +162,7 @@ float JLBFont::GetStringWidth(const char *string) const
|
||||
if (ch < 0) continue;
|
||||
len += mCharWidth[ch+mBase];
|
||||
}
|
||||
|
||||
|
||||
return len*mScale;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ float JLBFont::GetRotation() const { return mRotation; }
|
||||
float JLBFont::GetTracking() const { return mTracking; }
|
||||
float JLBFont::GetHeight() const { return mHeight; }
|
||||
|
||||
void JLBFont::SetBase(int base)
|
||||
{
|
||||
mBase = (base==0)?0:128;
|
||||
void JLBFont::SetBase(int base)
|
||||
{
|
||||
mBase = (base==0)?0:128;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// given 3 points, calculates the normal to the points
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3)
|
||||
#else
|
||||
void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, float *p3)
|
||||
@@ -243,7 +243,7 @@ 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]);
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
// normalize and specify the normal
|
||||
glNormal3f(result[0]/length, result[1]/length, result[2]/length);
|
||||
|
||||
@@ -273,7 +273,7 @@ void JMD2Model::Render(int frameNum)
|
||||
mRenderer->BindTexture(mModel->modelTex);
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
|
||||
// display the textured model with proper lighting normals
|
||||
@@ -465,7 +465,7 @@ void JMD2Model::Render()
|
||||
|
||||
mRenderer->BindTexture(mModel->modelTex);
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
@@ -34,7 +34,7 @@ int JOBJModel::ReadLine(char *output, const char *buffer, int start, int size)
|
||||
while (start < size && buffer[start] != '\n' && buffer[start] != '\r')
|
||||
output[index++] = buffer[start++];
|
||||
|
||||
while (start < size && buffer[start] == '\n' || buffer[start] == '\r')
|
||||
while ((start < size && buffer[start] == '\n') || buffer[start] == '\r')
|
||||
start++;
|
||||
|
||||
output[index] = 0;
|
||||
|
||||
@@ -90,7 +90,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
// FIELD_COUNT
|
||||
// };
|
||||
|
||||
char* lifeValues[] =
|
||||
const char* lifeValues[] =
|
||||
{
|
||||
"speed",
|
||||
"size",
|
||||
@@ -104,7 +104,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
"gravity"
|
||||
};
|
||||
|
||||
char* typeNames[] =
|
||||
const char* typeNames[] =
|
||||
{
|
||||
"POINT",
|
||||
"AREA",
|
||||
@@ -113,7 +113,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
"CIRCLE"
|
||||
};
|
||||
|
||||
char* modeNames[] =
|
||||
const char* modeNames[] =
|
||||
{
|
||||
"REPEAT",
|
||||
"ONCE",
|
||||
@@ -121,8 +121,6 @@ bool JParticleEffect::Load(const char* filename)
|
||||
"CONTINUOUS"
|
||||
};
|
||||
|
||||
int i;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// One effect per file only, well, we may extend it later to permit
|
||||
// multiple effect definitions:
|
||||
@@ -159,7 +157,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0)
|
||||
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||
|
||||
for (i=0;i<sizeof(modeNames)/sizeof(char*);i++)
|
||||
for (unsigned int i=0;i<sizeof(modeNames)/sizeof(char*);i++)
|
||||
{
|
||||
if (strcmp(element->Attribute("mode"), modeNames[i])==0)
|
||||
{
|
||||
@@ -170,7 +168,7 @@ bool JParticleEffect::Load(const char* filename)
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i=0;i<sizeof(typeNames)/sizeof(char*);i++)
|
||||
for (unsigned i=0;i<sizeof(typeNames)/sizeof(char*);i++)
|
||||
{
|
||||
if (strcmp(element->Attribute("type"), typeNames[i])==0)
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ void JParticleEmitter::SetQuad(JQuad *quad)
|
||||
|
||||
void JParticleEmitter::Update(float dt)
|
||||
{
|
||||
JParticleSystem* particleSys = mParent->GetParticleSystem();
|
||||
// JParticleSystem* particleSys = mParent->GetParticleSystem();
|
||||
|
||||
mActiveParticleCount = 0;
|
||||
|
||||
@@ -185,7 +185,7 @@ void JParticleEmitter::Update(float dt)
|
||||
|
||||
void JParticleEmitter::EmitParticles(int count)
|
||||
{
|
||||
JParticleSystem* particleSys = mParent->GetParticleSystem();
|
||||
// JParticleSystem* particleSys = mParent->GetParticleSystem();
|
||||
|
||||
JParticleData *dataPtr;
|
||||
JParticle* particle;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
|
||||
//
|
||||
// Licensed under the BSD license, see LICENSE in JGE root for details.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
#include "../include/JGE.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
JResourceManager::JResourceManager()
|
||||
{
|
||||
//mResourceRoot = "Res/"; // default root folder
|
||||
//mResourceRoot = "Res/"; // default root folder
|
||||
|
||||
mTextureList.clear();
|
||||
mTextureList.reserve(16);
|
||||
@@ -43,7 +43,7 @@ JResourceManager::JResourceManager()
|
||||
// mParticleEffectList.clear();
|
||||
// mParticleEffectList.reserve(8);
|
||||
// mParticleEffectMap.clear();
|
||||
//
|
||||
//
|
||||
// mMotionEmitterList.clear();
|
||||
// mMotionEmitterList.reserve(16);
|
||||
// mMotionEmitterMap.clear();
|
||||
@@ -52,7 +52,7 @@ JResourceManager::JResourceManager()
|
||||
|
||||
JResourceManager::~JResourceManager()
|
||||
{
|
||||
|
||||
|
||||
RemoveAll();
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ void JResourceManager::RemoveAll()
|
||||
|
||||
// for (vector<JParticleEffect *>::iterator effect = mParticleEffectList.begin(); effect != mParticleEffectList.end(); ++effect)
|
||||
// delete *effect;
|
||||
//
|
||||
//
|
||||
// mParticleEffectList.clear();
|
||||
// mParticleEffectMap.clear();
|
||||
//
|
||||
//
|
||||
// for (vector<JMotionEmitter *>::iterator emitter = mMotionEmitterList.begin(); emitter != mMotionEmitterList.end(); ++emitter)
|
||||
// delete *emitter;
|
||||
//
|
||||
//
|
||||
// mMotionEmitterList.clear();
|
||||
// mMotionEmitterMap.clear();
|
||||
|
||||
@@ -109,7 +109,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
string path = /*mResourceRoot + */resourceName;
|
||||
|
||||
// TiXmlDocument doc(path.c_str());
|
||||
//
|
||||
//
|
||||
// if (!doc.LoadFile()) return false;
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
TiXmlNode* node = 0;
|
||||
TiXmlElement* element = 0;
|
||||
|
||||
resource = doc.FirstChild("resource");
|
||||
resource = doc.FirstChild("resource");
|
||||
if (resource)
|
||||
{
|
||||
element = resource->ToElement();
|
||||
@@ -161,10 +161,10 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
float value;
|
||||
float hotspotX = 0.0f;
|
||||
float hotspotY = 0.0f;
|
||||
|
||||
|
||||
if (element->QueryFloatAttribute("x", &value) == TIXML_SUCCESS)
|
||||
x = value;
|
||||
|
||||
|
||||
if (element->QueryFloatAttribute("y", &value) == TIXML_SUCCESS)
|
||||
y = value;
|
||||
|
||||
@@ -192,10 +192,10 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
|
||||
// if (element->QueryFloatAttribute("regx", &value) == TIXML_SUCCESS)
|
||||
// hotspotX = width/2;
|
||||
//
|
||||
//
|
||||
// if (element->QueryFloatAttribute("regy", &value) == TIXML_SUCCESS)
|
||||
// hotspotY = height/2;
|
||||
|
||||
|
||||
int id = CreateQuad(quadName, textureName, x, y, width, height);
|
||||
if (id != INVALID_ID)
|
||||
{
|
||||
@@ -223,9 +223,9 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
fileSystem->CloseFile();
|
||||
delete[] xmlBuffer;
|
||||
// JGERelease();
|
||||
@@ -243,7 +243,7 @@ int JResourceManager::CreateTexture(const string &textureName)
|
||||
string path = /*mResourceRoot + */textureName;
|
||||
|
||||
printf("creating texture:%s\n", path.c_str());
|
||||
|
||||
|
||||
JTexture *tex = JRenderer::GetInstance()->LoadTexture(path.c_str());
|
||||
|
||||
if (tex == NULL)
|
||||
@@ -252,7 +252,7 @@ int JResourceManager::CreateTexture(const string &textureName)
|
||||
int id = mTextureList.size();
|
||||
mTextureList.push_back(tex);
|
||||
mTextureMap[textureName] = id;
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
else
|
||||
@@ -286,7 +286,7 @@ int JResourceManager::CreateQuad(const string &quadName, const string &textureNa
|
||||
|
||||
if (itr == mQuadMap.end())
|
||||
{
|
||||
JTexture *tex = GetTexture(textureName);
|
||||
JTexture *tex = GetTexture(textureName);
|
||||
if (tex == NULL)
|
||||
{
|
||||
int texId = CreateTexture(textureName); // load texture if necessary
|
||||
@@ -302,7 +302,7 @@ int JResourceManager::CreateQuad(const string &quadName, const string &textureNa
|
||||
mQuadList.push_back(new JQuad(tex, x, y, width, height));
|
||||
|
||||
mQuadMap[quadName] = id;
|
||||
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
@@ -340,13 +340,13 @@ int JResourceManager::LoadJLBFont(const string &fontName, int height)
|
||||
string path = /*mResourceRoot + */fontName;
|
||||
|
||||
printf("creating font:%s\n", path.c_str());
|
||||
|
||||
|
||||
int id = mFontList.size();
|
||||
///////////////////////////////////////
|
||||
mFontList.push_back(new JLBFont(path.c_str(), height, true));
|
||||
mFontList.push_back(new JLBFont(path.c_str(), height, true));
|
||||
|
||||
mFontMap[fontName] = id;
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
else
|
||||
@@ -383,16 +383,16 @@ int JResourceManager::LoadMusic(const string &musicName)
|
||||
string path = /*mResourceRoot + */musicName;
|
||||
|
||||
printf("creating music:%s\n", path.c_str());
|
||||
|
||||
|
||||
JMusic *music = JSoundSystem::GetInstance()->LoadMusic(path.c_str());
|
||||
if (music == NULL)
|
||||
return INVALID_ID;
|
||||
|
||||
int id = mMusicList.size();
|
||||
mMusicList.push_back(music);
|
||||
mMusicList.push_back(music);
|
||||
|
||||
mMusicMap[musicName] = id;
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
else
|
||||
@@ -429,16 +429,16 @@ int JResourceManager::LoadSample(const string &sampleName)
|
||||
string path = /*mResourceRoot + */sampleName;
|
||||
|
||||
printf("creating sample:%s\n", path.c_str());
|
||||
|
||||
|
||||
JSample *sample = JSoundSystem::GetInstance()->LoadSample(path.c_str());
|
||||
if (sample == NULL)
|
||||
return INVALID_ID;
|
||||
|
||||
int id = mSampleList.size();
|
||||
mSampleList.push_back(sample);
|
||||
mSampleList.push_back(sample);
|
||||
|
||||
mSampleMap[sampleName] = id;
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
else
|
||||
@@ -465,46 +465,46 @@ JSample *JResourceManager::GetSample(int id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// int JResourceManager::RegisterParticleEffect(const string &effectName)
|
||||
// {
|
||||
// map<string, int>::iterator itr = mParticleEffectMap.find(effectName);
|
||||
//
|
||||
//
|
||||
// if (itr == mParticleEffectMap.end())
|
||||
// {
|
||||
// string path = mResourceRoot + effectName;
|
||||
// printf("creating effect:%s\n", path.c_str());
|
||||
// JParticleEffect *effect = new JParticleEffect(path.c_str());
|
||||
//
|
||||
//
|
||||
// if (effect == NULL)
|
||||
// return INVALID_ID;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// int id = mParticleEffectList.size();
|
||||
// mParticleEffectList.push_back(effect);
|
||||
//
|
||||
//
|
||||
// mParticleEffectMap[effectName] = id;
|
||||
//
|
||||
//
|
||||
// return id;
|
||||
//
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// return itr->second;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JParticleEffect *JResourceManager::GetParticleEffect(const string &effectName)
|
||||
// {
|
||||
// map<string, int>::iterator itr = mParticleEffectMap.find(effectName);
|
||||
//
|
||||
//
|
||||
// if (itr == mParticleEffectMap.end())
|
||||
// return NULL;
|
||||
// else
|
||||
// return mParticleEffectList[itr->second];
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JParticleEffect *JResourceManager::GetParticleEffect(int id)
|
||||
// {
|
||||
// if (id >=0 && id < (int)mParticleEffectList.size())
|
||||
@@ -512,48 +512,48 @@ JSample *JResourceManager::GetSample(int id)
|
||||
// else
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// int JResourceManager::RegisterMotionEmitter(const string &emitterName)
|
||||
// {
|
||||
// map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName);
|
||||
//
|
||||
//
|
||||
// if (itr == mMotionEmitterMap.end())
|
||||
// {
|
||||
// string path = mResourceRoot + emitterName;
|
||||
// printf("creating effect:%s\n", path.c_str());
|
||||
// JMotionEmitter *emitter = new JMotionEmitter();
|
||||
//
|
||||
//
|
||||
// if (emitter == NULL)
|
||||
// return INVALID_ID;
|
||||
//
|
||||
//
|
||||
// emitter->LoadMotionML(path.c_str());
|
||||
//
|
||||
//
|
||||
// int id = mMotionEmitterList.size();
|
||||
// mMotionEmitterList.push_back(emitter);
|
||||
//
|
||||
//
|
||||
// mMotionEmitterMap[emitterName] = id;
|
||||
//
|
||||
//
|
||||
// return id;
|
||||
//
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// return itr->second;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JMotionEmitter *JResourceManager::GetMotionEmitter(const string &emitterName)
|
||||
// {
|
||||
// map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName);
|
||||
//
|
||||
//
|
||||
// if (itr == mMotionEmitterMap.end())
|
||||
// return NULL;
|
||||
// else
|
||||
// return mMotionEmitterList[itr->second];
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JMotionEmitter *JResourceManager::GetMotionEmitter(int id)
|
||||
// {
|
||||
// if (id >=0 && id < (int)mMotionEmitterList.size())
|
||||
|
||||
+4
-4
@@ -144,7 +144,7 @@ void JSprite::Render()
|
||||
// //mQuad->SetColor(ARGB(alpha,255,255,255));
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
mFrames[mCurrentFrame]->SetColor(alpha<<24 | mColor);
|
||||
// mQuad->SetFlip(mFlipped[mCurrentFrame], false);
|
||||
#else
|
||||
@@ -305,7 +305,7 @@ void JSprite::SetHotSpot(float x, float y, int index)
|
||||
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&0x00ffffff); }
|
||||
#else
|
||||
void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&~MASK_ALPHA); }
|
||||
@@ -344,7 +344,7 @@ void JSprite::SetCurrentFrameIndex(int frame)
|
||||
|
||||
JQuad* JSprite::GetCurrentFrame()
|
||||
{
|
||||
if (mCurrentFrame < mFrames.size())
|
||||
if (mCurrentFrame < (signed int)mFrames.size())
|
||||
return mFrames[mCurrentFrame];
|
||||
else
|
||||
return NULL;
|
||||
@@ -358,7 +358,7 @@ int JSprite::GetFrameCount()
|
||||
|
||||
JQuad* JSprite::GetFrame(int index)
|
||||
{
|
||||
if (index < mFrames.size())
|
||||
if (index < (signed int)mFrames.size())
|
||||
return mFrames[index];
|
||||
else
|
||||
return NULL;
|
||||
|
||||
+9
-8
@@ -19,8 +19,9 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#pragma comment( lib, "freetype.lib" )
|
||||
|
||||
#ifndef LINUX
|
||||
#pragma comment( lib, "freetype.lib" )
|
||||
#endif
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JRenderer.h"
|
||||
@@ -257,7 +258,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
|
||||
FT_GlyphSlot slot = mFace->glyph;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
DWORD *texBuffer = new DWORD[mMaxCharWidth*mMaxCharHeight];
|
||||
memset(texBuffer, 0, mMaxCharWidth*mMaxCharHeight*sizeof(DWORD));
|
||||
#else
|
||||
@@ -277,7 +278,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
int top = mSize-slot->bitmap_top+1;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
int offset = top*mMaxCharWidth + slot->bitmap_left + 2;
|
||||
#else
|
||||
int xx = x + slot->bitmap_left + 2;
|
||||
@@ -302,7 +303,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
grey = slot->bitmap.buffer[i * slot->bitmap.width + j];
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
texBuffer[i*mMaxCharWidth+j+offset] = RGBA(255, 255, 255, grey);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(grey,255,255,255), (xx+j)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE, mTexHeight);
|
||||
@@ -325,7 +326,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
if (bits&mask)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
texBuffer[i*mMaxCharWidth+j*8+k+offset] = RGBA(255, 255, 255, 255);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(255,255,255,255), (xx+j*8+k)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE, mTexHeight);
|
||||
@@ -343,7 +344,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
|
||||
mXAdvance[mCurr] = (u8)(slot->advance.x>>6);
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mMaxCharWidth, mMaxCharHeight, GL_RGBA, GL_UNSIGNED_BYTE, texBuffer);
|
||||
#else
|
||||
sceKernelDcacheWritebackAll();
|
||||
@@ -357,7 +358,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
if (mCurr >= mMaxCharCount)
|
||||
mCurr = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
delete [] texBuffer;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
hgeDistortionMesh::hgeDistortionMesh(int cols, int rows)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
//hge=hgeCreate(HGE_VERSION);
|
||||
|
||||
nRows=rows;
|
||||
@@ -39,7 +39,7 @@ hgeDistortionMesh::hgeDistortionMesh(int cols, int rows)
|
||||
disp_array[i].y=0.0f;
|
||||
disp_array[i].u=0.0f;
|
||||
disp_array[i].v=0.0f;
|
||||
|
||||
|
||||
disp_array[i].z=0.5f;
|
||||
disp_array[i].color=ARGB(0xFF,0xFF,0xFF,0xFF);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ hgeDistortionMesh& hgeDistortionMesh::operator= (const hgeDistortionMesh &dm)
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void hgeDistortionMesh::SetTexture(JTexture* tex)
|
||||
@@ -133,7 +133,7 @@ void hgeDistortionMesh::SetTextureRect(float x, float y, float w, float h)
|
||||
}
|
||||
}
|
||||
|
||||
void hgeDistortionMesh::SetBlendMode(int blend)
|
||||
void hgeDistortionMesh::SetBlendMode(int blend __attribute__((unused)))
|
||||
{
|
||||
// quad.blend=blend;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const char FNTCHARTAG[] = "Char";
|
||||
char hgeFont::buffer[256];
|
||||
|
||||
|
||||
hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
|
||||
{
|
||||
//void *data;
|
||||
DWORD size;
|
||||
@@ -35,7 +35,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
int i, x, y, w, h, a, c;
|
||||
|
||||
// Setup variables
|
||||
|
||||
|
||||
//hge=hgeCreate(HGE_VERSION);
|
||||
|
||||
fHeight=0.0f;
|
||||
@@ -53,7 +53,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
memset( &letters, 0, sizeof(letters) );
|
||||
memset( &pre, 0, sizeof(letters) );
|
||||
memset( &post, 0, sizeof(letters) );
|
||||
|
||||
|
||||
// Load font description
|
||||
|
||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||
@@ -67,7 +67,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
//memcpy(desc,data,size);
|
||||
fileSys->ReadFile(desc, size);
|
||||
desc[size]=0;
|
||||
|
||||
|
||||
//hge->Resource_Free(data);
|
||||
fileSys->CloseFile();
|
||||
|
||||
@@ -75,7 +75,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
if(strcmp(linebuf, FNTHEADERTAG))
|
||||
{
|
||||
// hge->System_Log("Font %s has incorrect format.", szFont);
|
||||
delete[] desc;
|
||||
delete[] desc;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
hTexture = renderer->LoadTexture(buf);
|
||||
if(!hTexture)
|
||||
{
|
||||
delete[] desc;
|
||||
delete[] desc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
|
||||
}
|
||||
}
|
||||
|
||||
delete[] desc;
|
||||
delete[] desc;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ void hgeFont::printfb(float x, float y, float w, float h, int align, const char
|
||||
prevword=&pbuf[i];
|
||||
pbuf=&pbuf[i+1];
|
||||
}
|
||||
|
||||
|
||||
tx=x;
|
||||
ty=y;
|
||||
hh=fHeight*fSpacing*fScale*lines;
|
||||
|
||||
@@ -35,7 +35,7 @@ distribution.
|
||||
const TiXmlString::size_type TiXmlString::npos = static_cast< size_type >(-1);
|
||||
|
||||
// Null rep.
|
||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, '\0' };
|
||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||
|
||||
|
||||
void TiXmlString::reserve (size_type cap)
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,8 @@ distribution.
|
||||
|
||||
// Note tha "PutString" hardcodes the same list. This
|
||||
// is less flexible than it appears. Changing the entries
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
{
|
||||
{ "&", 5, '&' },
|
||||
{ "<", 4, '<' },
|
||||
@@ -53,16 +53,16 @@ TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
// Including the basic of this table, which determines the #bytes in the
|
||||
// sequence from the lead byte. 1 placed for invalid sequences --
|
||||
// although the result will be junk, pass it through as much as possible.
|
||||
// Beware of the non-characters in UTF-8:
|
||||
// Beware of the non-characters in UTF-8:
|
||||
// ef bb bf (Microsoft "lead bytes")
|
||||
// ef bf be
|
||||
// ef bf bf
|
||||
// ef bf bf
|
||||
|
||||
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
||||
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
||||
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
|
||||
|
||||
const int TiXmlBase::utf8ByteTable[256] =
|
||||
const int TiXmlBase::utf8ByteTable[256] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
|
||||
@@ -74,9 +74,9 @@ const int TiXmlBase::utf8ByteTable[256] =
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
||||
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
|
||||
@@ -90,7 +90,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
const unsigned long BYTE_MARK = 0x80;
|
||||
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||
|
||||
if (input < 0x80)
|
||||
if (input < 0x80)
|
||||
*length = 1;
|
||||
else if ( input < 0x800 )
|
||||
*length = 2;
|
||||
@@ -104,22 +104,22 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
output += *length;
|
||||
|
||||
// Scary scary fall throughs.
|
||||
switch (*length)
|
||||
switch (*length)
|
||||
{
|
||||
case 4:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 3:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 2:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 1:
|
||||
--output;
|
||||
--output;
|
||||
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
{
|
||||
// This will only work for low-ascii, everything else is assumed to be a valid
|
||||
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// conservative approach.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -150,7 +150,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
{
|
||||
// This will only work for low-ascii, everything else is assumed to be a valid
|
||||
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// to figure out alhabetical vs. not across encoding. So take a very
|
||||
// conservative approach.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -223,7 +223,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
case '\r':
|
||||
// bump down to the next line
|
||||
++row;
|
||||
col = 0;
|
||||
col = 0;
|
||||
// Eat the character
|
||||
++p;
|
||||
|
||||
@@ -265,11 +265,11 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
// In these cases, don't advance the column. These are
|
||||
// 0-width spaces.
|
||||
if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else
|
||||
{ p +=3; ++col; } // A normal character.
|
||||
}
|
||||
@@ -321,10 +321,10 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
||||
while ( *p )
|
||||
{
|
||||
const unsigned char* pU = (const unsigned char*)p;
|
||||
|
||||
|
||||
// Skip the stupid Microsoft UTF-8 Byte order marks
|
||||
if ( *(pU+0)==TIXML_UTF_LEAD_0
|
||||
&& *(pU+1)==TIXML_UTF_LEAD_1
|
||||
&& *(pU+1)==TIXML_UTF_LEAD_1
|
||||
&& *(pU+2)==TIXML_UTF_LEAD_2 )
|
||||
{
|
||||
p += 3;
|
||||
@@ -353,7 +353,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
|
||||
while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
|
||||
++p;
|
||||
}
|
||||
|
||||
@@ -406,11 +406,11 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
|
||||
// After that, they can be letters, underscores, numbers,
|
||||
// hyphens, or colons. (Colons are valid ony for namespaces,
|
||||
// but tinyxml can't tell namespaces from names.)
|
||||
if ( p && *p
|
||||
if ( p && *p
|
||||
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
|
||||
{
|
||||
while( p && *p
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
|| *p == '_'
|
||||
|| *p == '-'
|
||||
|| *p == '.'
|
||||
@@ -458,7 +458,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
ucs += mult * (*q - 'a' + 10);
|
||||
else if ( *q >= 'A' && *q <= 'F' )
|
||||
ucs += mult * (*q - 'A' + 10 );
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 16;
|
||||
--q;
|
||||
@@ -481,7 +481,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
{
|
||||
if ( *q >= '0' && *q <= '9' )
|
||||
ucs += mult * (*q - '0');
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 10;
|
||||
--q;
|
||||
@@ -558,10 +558,10 @@ bool TiXmlBase::StringEqual( const char* p,
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
bool caseInsensitive,
|
||||
TiXmlEncoding encoding )
|
||||
{
|
||||
@@ -632,7 +632,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
// This "pre-streaming" will never read the closing ">" so the
|
||||
// sub-tag can orient itself.
|
||||
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
{
|
||||
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
@@ -654,7 +654,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
if ( in->good() )
|
||||
{
|
||||
// We now have something we presume to be a node of
|
||||
// We now have something we presume to be a node of
|
||||
// some sort. Identify it, and call the node to
|
||||
// continue streaming.
|
||||
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
|
||||
@@ -763,7 +763,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
encoding = TIXML_ENCODING_UTF8;
|
||||
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
|
||||
else
|
||||
else
|
||||
encoding = TIXML_ENCODING_LEGACY;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
}
|
||||
|
||||
void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
|
||||
{
|
||||
{
|
||||
// The first error in a chain is more accurate - don't set again!
|
||||
if ( error )
|
||||
return;
|
||||
@@ -818,7 +818,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// What is this thing?
|
||||
// What is this thing?
|
||||
// - Elements start with a letter or underscore, but xml is reserved.
|
||||
// - Comments: <!--
|
||||
// - Decleration: <?xml
|
||||
@@ -906,7 +906,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
return;
|
||||
}
|
||||
(*tag) += (char) c ;
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
}
|
||||
@@ -916,7 +916,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
|
||||
// If not, identify and stream.
|
||||
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '/' )
|
||||
{
|
||||
// All good!
|
||||
@@ -933,7 +933,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
StreamWhiteSpace( in, tag );
|
||||
|
||||
// Do we have text?
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
{
|
||||
// Yep, text.
|
||||
TiXmlText text( "" );
|
||||
@@ -966,7 +966,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
|
||||
@@ -1075,7 +1075,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
// Empty tag.
|
||||
if ( *p != '>' )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
||||
return 0;
|
||||
}
|
||||
return (p+1);
|
||||
@@ -1175,8 +1175,8 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
LinkEndChild( textNode );
|
||||
else
|
||||
delete textNode;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// We hit a '<'
|
||||
// Have we hit a new element or an end tag? This could also be
|
||||
@@ -1192,7 +1192,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
{
|
||||
p = node->Parse( p, data, encoding );
|
||||
LinkEndChild( node );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
@@ -1206,7 +1206,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1216,7 +1216,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1229,7 +1229,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
if ( c == '>' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1274,7 +1274,7 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1285,12 +1285,12 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
(*tag) += (char) c;
|
||||
|
||||
if ( c == '>'
|
||||
if ( c == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '-'
|
||||
&& tag->at( tag->length() - 3 ) == '-' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* end;
|
||||
|
||||
if ( *p == '\'' )
|
||||
@@ -1396,7 +1396,7 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
if ( cdata )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1407,19 +1407,19 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
(*tag) += (char) c;
|
||||
|
||||
if ( c == '>'
|
||||
if ( c == '>'
|
||||
&& tag->at( tag->length() - 2 ) == ']'
|
||||
&& tag->at( tag->length() - 3 ) == ']' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->peek();
|
||||
int c = in->peek();
|
||||
if ( c == '<' )
|
||||
return;
|
||||
if ( c <= 0 )
|
||||
@@ -1471,7 +1471,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
|
||||
++p;
|
||||
}
|
||||
|
||||
TIXML_STRING dummy;
|
||||
TIXML_STRING dummy;
|
||||
p = ReadText( p, &dummy, false, endTag, false, encoding );
|
||||
return p;
|
||||
}
|
||||
@@ -1545,19 +1545,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( StringEqual( p, "version", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
version = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "encoding", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
encoding = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "standalone", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
standalone = attrib.Value();
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user