J :
* Key buffer update : Add functions & clean the file
This commit is contained in:
+144
-124
@@ -25,31 +25,35 @@
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
void JGEControl();
|
void JGEControl();
|
||||||
BOOL JGEGetKeyState(int key);
|
BOOL JGEGetKeyState(int key);
|
||||||
bool JGEGetButtonState(u32 button);
|
bool JGEGetButtonState(u32 button);
|
||||||
bool JGEGetButtonClick(u32 button);
|
bool JGEGetButtonClick(u32 button);
|
||||||
|
u32 JGEReadKey();
|
||||||
|
void JGEResetInput();
|
||||||
|
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
|
|
||||||
void JGEControl();
|
void JGEControl();
|
||||||
BOOL JGEGetKeyState(int key);
|
BOOL JGEGetKeyState(int key);
|
||||||
bool JGEGetButtonState(uint32_t button);
|
bool JGEGetButtonState(u32 button);
|
||||||
bool JGEGetButtonClick(uint32_t button);
|
bool JGEGetButtonClick(u32 button);
|
||||||
|
u32 JGEReadKey();
|
||||||
|
void JGEResetInput();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <pspgu.h>
|
#include <pspgu.h>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspdisplay.h>
|
#include <pspdisplay.h>
|
||||||
#include <pspdebug.h>
|
#include <pspdebug.h>
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pspaudiolib.h>
|
#include <pspaudiolib.h>
|
||||||
#include <psprtc.h>
|
#include <psprtc.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -71,155 +75,171 @@ class JMusic;
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
class JGE
|
class JGE
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
JApp *mApp;
|
JApp *mApp;
|
||||||
// JResourceManager *mResourceManager;
|
// JResourceManager *mResourceManager;
|
||||||
// JFileSystem* mFileSystem;
|
// JFileSystem* mFileSystem;
|
||||||
|
|
||||||
// JParticleSystem* mParticleSystem;
|
// JParticleSystem* mParticleSystem;
|
||||||
// JMotionSystem* mMotionSystem;
|
// JMotionSystem* mMotionSystem;
|
||||||
|
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
float mDeltaTime;
|
float mDeltaTime;
|
||||||
|
|
||||||
JMusic *mCurrentMusic;
|
JMusic *mCurrentMusic;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
SceCtrlData mCtrlPad;
|
SceCtrlData mCtrlPad;
|
||||||
u32 mOldButtons;
|
u32 mOldButtons;
|
||||||
|
|
||||||
u64 mLastTime;
|
u64 mLastTime;
|
||||||
u32 mTickFrequency;
|
u32 mTickFrequency;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool mDone;
|
bool mDone;
|
||||||
|
|
||||||
float mDelta;
|
float mDelta;
|
||||||
|
|
||||||
bool mDebug;
|
bool mDebug;
|
||||||
|
|
||||||
bool mPaused;
|
bool mPaused;
|
||||||
|
|
||||||
char mDebuggingMsg[256];
|
char mDebuggingMsg[256];
|
||||||
|
|
||||||
bool mCriticalAssert;
|
bool mCriticalAssert;
|
||||||
const char *mAssertFile;
|
const char *mAssertFile;
|
||||||
int mAssertLine;
|
int mAssertLine;
|
||||||
|
|
||||||
|
|
||||||
static JGE* mInstance;
|
static JGE* mInstance;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get JGE instance.
|
/// Get JGE instance.
|
||||||
///
|
///
|
||||||
/// @return JGE instance.
|
/// @return JGE instance.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
static JGE* GetInstance();
|
static JGE* GetInstance();
|
||||||
static void Destroy();
|
static void Destroy();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Run();
|
void Run();
|
||||||
void End();
|
void End();
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
void Render();
|
void Render();
|
||||||
|
|
||||||
void Pause();
|
void Pause();
|
||||||
void Resume();
|
void Resume();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Return system timer in milliseconds.
|
/// Return system timer in milliseconds.
|
||||||
///
|
///
|
||||||
/// @return System time in milliseconds.
|
/// @return System time in milliseconds.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
int GetTime(void);
|
int GetTime(void);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Return elapsed time since last frame update.
|
/// Return elapsed time since last frame update.
|
||||||
///
|
///
|
||||||
/// @return Elapsed time in seconds.
|
/// @return Elapsed time in seconds.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
float GetDelta();
|
float GetDelta();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Return frame rate.
|
/// Return frame rate.
|
||||||
///
|
///
|
||||||
/// @note This is just 1.0f/GetDelat().
|
/// @note This is just 1.0f/GetDelat().
|
||||||
///
|
///
|
||||||
/// @return Number of frames per second.
|
/// @return Number of frames per second.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
float GetFPS();
|
float GetFPS();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Check the current state of a button.
|
/// Check the current state of a button.
|
||||||
///
|
///
|
||||||
/// @param button - Button id.
|
/// @param button - Button id.
|
||||||
///
|
///
|
||||||
/// @return Button state.
|
/// @return Button state.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool GetButtonState(u32 button);
|
bool GetButtonState(u32 button);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Check if a button is down the first time.
|
/// Check if a button is down the first time.
|
||||||
///
|
///
|
||||||
/// @param button - Button id.
|
/// @param button - Button id.
|
||||||
///
|
///
|
||||||
/// @return Button state.
|
/// @return Button state.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool GetButtonClick(u32 button);
|
bool GetButtonClick(u32 button);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get x value of the analog pad.
|
/// Get the next keypress.
|
||||||
///
|
///
|
||||||
/// @return X value (0 to 255).
|
/// @return Next pressed button, or 0 if none.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
u8 GetAnalogX();
|
u32 ReadButton();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get y value of the analog pad.
|
/// Reset the input buffer.
|
||||||
///
|
/// This is necessary because there might be phases when GetButtonState
|
||||||
/// @return Y value (0 to 255).
|
/// or GetButtonClick are used, thereby accumulating keypresses in the
|
||||||
//////////////////////////////////////////////////////////////////////////
|
/// key buffer.
|
||||||
u8 GetAnalogY();
|
///
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
void ResetInput();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Get x value of the analog pad.
|
||||||
|
///
|
||||||
|
/// @return X value (0 to 255).
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
u8 GetAnalogX();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Get y value of the analog pad.
|
||||||
|
///
|
||||||
|
/// @return Y value (0 to 255).
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
u8 GetAnalogY();
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get if the system is ended or not.
|
/// Get if the system is ended or not.
|
||||||
///
|
///
|
||||||
/// @return Status of the system.
|
/// @return Status of the system.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool IsDone() { return mDone; }
|
bool IsDone() { return mDone; }
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Set the user's core application class.
|
/// Set the user's core application class.
|
||||||
///
|
///
|
||||||
/// @param app - User defined application class.
|
/// @param app - User defined application class.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void SetApp(JApp *app);
|
void SetApp(JApp *app);
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Print debug message.
|
/// Print debug message.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void printf(const char *format, ...);
|
void printf(const char *format, ...);
|
||||||
|
|
||||||
|
|
||||||
void Assert(const char *filename, long lineNumber);
|
void Assert(const char *filename, long lineNumber);
|
||||||
|
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
void SetDelta(int delta);
|
void SetDelta(int delta);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
JGE();
|
JGE();
|
||||||
~JGE();
|
~JGE();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+180
-180
@@ -25,24 +25,24 @@
|
|||||||
|
|
||||||
int JGE::GetTime(void)
|
int JGE::GetTime(void)
|
||||||
{
|
{
|
||||||
return (int)GetTickCount();
|
return (int)GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 JGE::GetAnalogX()
|
u8 JGE::GetAnalogX()
|
||||||
{
|
{
|
||||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||||
|
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u8 JGE::GetAnalogY()
|
u8 JGE::GetAnalogY()
|
||||||
{
|
{
|
||||||
if (JGEGetKeyState(VK_UP)) return 0;
|
if (JGEGetKeyState(VK_UP)) return 0;
|
||||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||||
|
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (LINUX) // Unix specific code
|
#elif defined (LINUX) // Unix specific code
|
||||||
@@ -51,27 +51,27 @@ u8 JGE::GetAnalogY()
|
|||||||
|
|
||||||
int JGE::GetTime(void)
|
int JGE::GetTime(void)
|
||||||
{
|
{
|
||||||
return (int)time(NULL);
|
return (int)time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 JGE::GetAnalogX()
|
u8 JGE::GetAnalogX()
|
||||||
{
|
{
|
||||||
/* FIXME
|
/* FIXME
|
||||||
if (JGEGetKeyState(VK_LEFT)) return 0;
|
if (JGEGetKeyState(VK_LEFT)) return 0;
|
||||||
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
if (JGEGetKeyState(VK_RIGHT)) return 0xff;
|
||||||
*/
|
*/
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u8 JGE::GetAnalogY()
|
u8 JGE::GetAnalogY()
|
||||||
{
|
{
|
||||||
/* FIXME
|
/* FIXME
|
||||||
if (JGEGetKeyState(VK_UP)) return 0;
|
if (JGEGetKeyState(VK_UP)) return 0;
|
||||||
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
if (JGEGetKeyState(VK_DOWN)) return 0xff;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -82,58 +82,58 @@ u8 JGE::GetAnalogY()
|
|||||||
|
|
||||||
JGE::JGE()
|
JGE::JGE()
|
||||||
{
|
{
|
||||||
mApp = NULL;
|
mApp = NULL;
|
||||||
|
|
||||||
strcpy(mDebuggingMsg, "");
|
strcpy(mDebuggingMsg, "");
|
||||||
mCurrentMusic = NULL;
|
mCurrentMusic = NULL;
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
// mResourceManager = new JResourceManager();
|
// mResourceManager = new JResourceManager();
|
||||||
// mFileSystem = new JFileSystem();
|
// mFileSystem = new JFileSystem();
|
||||||
|
|
||||||
// mParticleSystem = NULL;//new JParticleSystem(500);
|
// mParticleSystem = NULL;//new JParticleSystem(500);
|
||||||
// mMotionSystem = NULL;//new JMotionSystem();
|
// mMotionSystem = NULL;//new JMotionSystem();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JGE::~JGE()
|
JGE::~JGE()
|
||||||
{
|
{
|
||||||
JRenderer::Destroy();
|
JRenderer::Destroy();
|
||||||
JFileSystem::Destroy();
|
JFileSystem::Destroy();
|
||||||
JSoundSystem::Destroy();
|
JSoundSystem::Destroy();
|
||||||
//JParticleSystem::Destroy();
|
//JParticleSystem::Destroy();
|
||||||
|
|
||||||
//DestroyGfx();
|
//DestroyGfx();
|
||||||
//DestroySfx();
|
//DestroySfx();
|
||||||
|
|
||||||
// if (mResourceManager != NULL)
|
// if (mResourceManager != NULL)
|
||||||
// delete mResourceManager;
|
// delete mResourceManager;
|
||||||
//
|
//
|
||||||
// if (mFileSystem != NULL)
|
// if (mFileSystem != NULL)
|
||||||
// delete mFileSystem;
|
// delete mFileSystem;
|
||||||
//
|
//
|
||||||
// if (mParticleSystem != NULL)
|
// if (mParticleSystem != NULL)
|
||||||
// delete mParticleSystem;
|
// delete mParticleSystem;
|
||||||
//
|
//
|
||||||
// if (mMotionSystem != NULL)
|
// if (mMotionSystem != NULL)
|
||||||
// delete mMotionSystem;
|
// delete mMotionSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void JGE::Init()
|
void JGE::Init()
|
||||||
{
|
{
|
||||||
mDone = false;
|
mDone = false;
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
mCriticalAssert = false;
|
mCriticalAssert = false;
|
||||||
|
|
||||||
JRenderer::GetInstance();
|
JRenderer::GetInstance();
|
||||||
JFileSystem::GetInstance();
|
JFileSystem::GetInstance();
|
||||||
JSoundSystem::GetInstance();
|
JSoundSystem::GetInstance();
|
||||||
//JParticleSystem::GetInstance();
|
//JParticleSystem::GetInstance();
|
||||||
|
|
||||||
//InitSfx();
|
//InitSfx();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JGE::Run()
|
void JGE::Run()
|
||||||
@@ -143,34 +143,34 @@ void JGE::Run()
|
|||||||
|
|
||||||
void JGE::SetDelta(int delta)
|
void JGE::SetDelta(int delta)
|
||||||
{
|
{
|
||||||
mDeltaTime = (float)delta / 1000.0f; // change to second
|
mDeltaTime = (float)delta / 1000.0f; // change to second
|
||||||
}
|
}
|
||||||
|
|
||||||
float JGE::GetDelta()
|
float JGE::GetDelta()
|
||||||
{
|
{
|
||||||
return mDeltaTime;
|
return mDeltaTime;
|
||||||
//return hge->Timer_GetDelta()*1000;
|
//return hge->Timer_GetDelta()*1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float JGE::GetFPS()
|
float JGE::GetFPS()
|
||||||
{
|
{
|
||||||
//return (float)hge->Timer_GetFPS();
|
//return (float)hge->Timer_GetFPS();
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JGE::GetButtonState(u32 button)
|
bool JGE::GetButtonState(u32 button)
|
||||||
{
|
{
|
||||||
//return (gButtons&button)==button;
|
//return (gButtons&button)==button;
|
||||||
return JGEGetButtonState(button);
|
return JGEGetButtonState(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JGE::GetButtonClick(u32 button)
|
bool JGE::GetButtonClick(u32 button)
|
||||||
{
|
{
|
||||||
//return (gButtons&button)==button && (gOldButtons&button)!=button;
|
//return (gButtons&button)==button && (gOldButtons&button)!=button;
|
||||||
return JGEGetButtonClick(button);
|
return JGEGetButtonClick(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 JGE::ReadButton()
|
u32 JGE::ReadButton()
|
||||||
@@ -195,38 +195,38 @@ void JGE::ResetInput()
|
|||||||
|
|
||||||
JGE::JGE()
|
JGE::JGE()
|
||||||
{
|
{
|
||||||
mApp = NULL;
|
mApp = NULL;
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
// mResourceManager = new JResourceManager();
|
// mResourceManager = new JResourceManager();
|
||||||
// mFileSystem = new JFileSystem();
|
// mFileSystem = new JFileSystem();
|
||||||
//
|
//
|
||||||
// mParticleSystem = new JParticleSystem(500);
|
// mParticleSystem = new JParticleSystem(500);
|
||||||
// mMotionSystem = new JMotionSystem();
|
// mMotionSystem = new JMotionSystem();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JGE::~JGE()
|
JGE::~JGE()
|
||||||
{
|
{
|
||||||
JRenderer::Destroy();
|
JRenderer::Destroy();
|
||||||
JSoundSystem::Destroy();
|
JSoundSystem::Destroy();
|
||||||
JFileSystem::Destroy();
|
JFileSystem::Destroy();
|
||||||
|
|
||||||
//DestroyGfx();
|
//DestroyGfx();
|
||||||
//DestroySfx();
|
//DestroySfx();
|
||||||
|
|
||||||
// delete mResourceManager;
|
// delete mResourceManager;
|
||||||
// delete mFileSystem;
|
// delete mFileSystem;
|
||||||
// delete mParticleSystem;
|
// delete mParticleSystem;
|
||||||
// delete mMotionSystem;
|
// delete mMotionSystem;
|
||||||
|
|
||||||
// if (mApp != NULL)
|
// if (mApp != NULL)
|
||||||
// {
|
// {
|
||||||
// mApp->Destroy();
|
// mApp->Destroy();
|
||||||
// delete mApp;
|
// delete mApp;
|
||||||
// mApp = NULL;
|
// mApp = NULL;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,43 +234,43 @@ void JGE::Init()
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef DEBUG_PRINT
|
#ifdef DEBUG_PRINT
|
||||||
mDebug = true;
|
mDebug = true;
|
||||||
#else
|
#else
|
||||||
mDebug = false;
|
mDebug = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mDebug)
|
if (mDebug)
|
||||||
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
|
pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
|
||||||
|
|
||||||
strcpy(mDebuggingMsg, "");
|
strcpy(mDebuggingMsg, "");
|
||||||
|
|
||||||
sceCtrlSetSamplingCycle(0);
|
sceCtrlSetSamplingCycle(0);
|
||||||
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
|
||||||
|
|
||||||
JRenderer::GetInstance();
|
JRenderer::GetInstance();
|
||||||
JFileSystem::GetInstance();
|
JFileSystem::GetInstance();
|
||||||
JSoundSystem::GetInstance();
|
JSoundSystem::GetInstance();
|
||||||
|
|
||||||
mDone = false;
|
mDone = false;
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
mCriticalAssert = false;
|
mCriticalAssert = false;
|
||||||
|
|
||||||
//InitSfx();
|
//InitSfx();
|
||||||
|
|
||||||
//Create();
|
//Create();
|
||||||
|
|
||||||
// mCurrMS = 1.0f;
|
// mCurrMS = 1.0f;
|
||||||
// mFPSSlice = 0;
|
// mFPSSlice = 0;
|
||||||
|
|
||||||
//struct timeval tp;
|
//struct timeval tp;
|
||||||
//gettimeofday(&tp, NULL);
|
//gettimeofday(&tp, NULL);
|
||||||
//mTimeBase = tp.tv_sec;
|
//mTimeBase = tp.tv_sec;
|
||||||
|
|
||||||
//mLastTime = GetTime();
|
//mLastTime = GetTime();
|
||||||
|
|
||||||
|
|
||||||
mTickFrequency = sceRtcGetTickResolution();
|
mTickFrequency = sceRtcGetTickResolution();
|
||||||
sceRtcGetCurrentTick(&mLastTime);
|
sceRtcGetCurrentTick(&mLastTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,35 +278,35 @@ void JGE::Init()
|
|||||||
int JGE::GetTime(void)
|
int JGE::GetTime(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
u64 curr;
|
u64 curr;
|
||||||
sceRtcGetCurrentTick(&curr);
|
sceRtcGetCurrentTick(&curr);
|
||||||
|
|
||||||
return (int)(curr / mTickFrequency);
|
return (int)(curr / mTickFrequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float JGE::GetDelta()
|
float JGE::GetDelta()
|
||||||
{
|
{
|
||||||
return mDelta;
|
return mDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float JGE::GetFPS()
|
float JGE::GetFPS()
|
||||||
{
|
{
|
||||||
return 1.0f / mDelta;
|
return 1.0f / mDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JGE::GetButtonState(u32 button)
|
bool JGE::GetButtonState(u32 button)
|
||||||
{
|
{
|
||||||
return (mCtrlPad.Buttons&button)==button;
|
return (mCtrlPad.Buttons&button)==button;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool JGE::GetButtonClick(u32 button)
|
bool JGE::GetButtonClick(u32 button)
|
||||||
{
|
{
|
||||||
return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button;
|
return (mCtrlPad.Buttons&button)==button && (mOldButtons&button)!=button;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 JGE::ReadButton()
|
u32 JGE::ReadButton()
|
||||||
@@ -320,55 +320,55 @@ void JGE::ResetInput()
|
|||||||
|
|
||||||
u8 JGE::GetAnalogX()
|
u8 JGE::GetAnalogX()
|
||||||
{
|
{
|
||||||
return mCtrlPad.Lx;
|
return mCtrlPad.Lx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
u8 JGE::GetAnalogY()
|
u8 JGE::GetAnalogY()
|
||||||
{
|
{
|
||||||
return mCtrlPad.Ly;
|
return mCtrlPad.Ly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Run()
|
void JGE::Run()
|
||||||
{
|
{
|
||||||
|
|
||||||
u64 curr;
|
u64 curr;
|
||||||
|
|
||||||
while (!mDone)
|
while (!mDone)
|
||||||
|
{
|
||||||
|
if (!mPaused)
|
||||||
{
|
{
|
||||||
if (!mPaused)
|
sceRtcGetCurrentTick(&curr);
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
if (mDebug)
|
||||||
|
{
|
||||||
|
if (strlen(mDebuggingMsg)>0)
|
||||||
{
|
{
|
||||||
sceRtcGetCurrentTick(&curr);
|
pspDebugScreenSetXY(0, 0);
|
||||||
|
pspDebugScreenPrintf(mDebuggingMsg);
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
if (mDebug)
|
|
||||||
{
|
|
||||||
if (strlen(mDebuggingMsg)>0)
|
|
||||||
{
|
|
||||||
pspDebugScreenSetXY(0, 0);
|
|
||||||
pspDebugScreenPrintf(mDebuggingMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mOldButtons = mCtrlPad.Buttons;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mOldButtons = mCtrlPad.Buttons;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif ///// PSP specified code
|
#endif ///// PSP specified code
|
||||||
@@ -380,100 +380,100 @@ JGE* JGE::mInstance = NULL;
|
|||||||
|
|
||||||
JGE* JGE::GetInstance()
|
JGE* JGE::GetInstance()
|
||||||
{
|
{
|
||||||
if (mInstance == NULL)
|
if (mInstance == NULL)
|
||||||
{
|
{
|
||||||
mInstance = new JGE();
|
mInstance = new JGE();
|
||||||
}
|
}
|
||||||
|
|
||||||
//gCount++;
|
//gCount++;
|
||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Destroy()
|
void JGE::Destroy()
|
||||||
{
|
{
|
||||||
//gCount--;
|
//gCount--;
|
||||||
if (mInstance)
|
if (mInstance)
|
||||||
{
|
{
|
||||||
delete mInstance;
|
delete mInstance;
|
||||||
mInstance = NULL;
|
mInstance = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::SetApp(JApp *app)
|
void JGE::SetApp(JApp *app)
|
||||||
{
|
{
|
||||||
mApp = app;
|
mApp = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Update()
|
void JGE::Update()
|
||||||
{
|
{
|
||||||
if (mApp != NULL)
|
if (mApp != NULL)
|
||||||
mApp->Update();
|
mApp->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JGE::Render()
|
void JGE::Render()
|
||||||
{
|
{
|
||||||
JRenderer* renderer = JRenderer::GetInstance();
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
|
||||||
renderer->BeginScene();
|
renderer->BeginScene();
|
||||||
|
|
||||||
if (mApp != NULL)
|
if (mApp != NULL)
|
||||||
mApp->Render();
|
mApp->Render();
|
||||||
|
|
||||||
renderer->EndScene();
|
renderer->EndScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::End()
|
void JGE::End()
|
||||||
{
|
{
|
||||||
mDone = true;
|
mDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void JGE::printf(const char *format, ...)
|
void JGE::printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
va_start(list, format);
|
va_start(list, format);
|
||||||
vsprintf(mDebuggingMsg, format, list);
|
vsprintf(mDebuggingMsg, format, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
// FILE *f = fopen("jge.log", "a+");
|
// FILE *f = fopen("jge.log", "a+");
|
||||||
// fprintf(f, "%s\n", mDebuggingMsg);
|
// fprintf(f, "%s\n", mDebuggingMsg);
|
||||||
// fclose(f);
|
// fclose(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Pause()
|
void JGE::Pause()
|
||||||
{
|
{
|
||||||
if (mPaused) return;
|
if (mPaused) return;
|
||||||
|
|
||||||
mPaused = true;
|
mPaused = true;
|
||||||
if (mApp != NULL)
|
if (mApp != NULL)
|
||||||
mApp->Pause();
|
mApp->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Resume()
|
void JGE::Resume()
|
||||||
{
|
{
|
||||||
if (mPaused)
|
if (mPaused)
|
||||||
{
|
{
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
if (mApp != NULL)
|
if (mApp != NULL)
|
||||||
mApp->Resume();
|
mApp->Resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JGE::Assert(const char *filename, long lineNumber)
|
void JGE::Assert(const char *filename, long lineNumber)
|
||||||
{
|
{
|
||||||
mAssertFile = filename;
|
mAssertFile = filename;
|
||||||
mAssertLine = lineNumber;
|
mAssertLine = lineNumber;
|
||||||
mCriticalAssert = true;
|
mCriticalAssert = true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user