* Update for linux support.
This commit is contained in:
jean.chalard
2008-11-05 13:38:39 +00:00
parent 89dae65237
commit ddf04e14e8
39 changed files with 975 additions and 786 deletions

View File

@@ -1,20 +1,118 @@
all: ifeq ($(MAKECMDGOALS),debug)
$(MAKE) -f Makefile.1xx install DEBUG = true
$(MAKE) -f Makefile.hge install endif
$(MAKE) -f Makefile.input install
1xx: GENERIC_OBJS = src/JApp.o src/JGBKFont.o \
$(MAKE) -f Makefile.1xx install src/JGE.o src/JGui.o src/JLBFont.o \
$(MAKE) -f Makefile.hge install src/JGameObject.o src/JSpline.o src/JAnimator.o \
$(MAKE) -f Makefile.input install src/JResourceManager.o src/JFileSystem.o \
src/JParticle.o src/JParticleEmitter.o src/JParticleEffect.o \
3xx: src/JParticleSystem.o \
$(MAKE) -f Makefile.3xx install src/unzip/ioapi.o src/unzip/mztools.o src/unzip/unzip.o \
$(MAKE) -f Makefile.hge install src/JSprite.o src/Vector2D.o \
$(MAKE) -f Makefile.input install src/tinyxml/tinystr.o src/tinyxml/tinyxml.o \
src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \
clean: src/Encoding.o src/JTTFont.o \
$(MAKE) -f Makefile.1xx clean src/JMD2Model.o src/JOBJModel.o src/vram.o
$(MAKE) -f Makefile.3xx clean PSP_OBJS = src/JGfx.o src/JSfx.o src/main.o
$(MAKE) -f Makefile.hge clean LINUX_OBJS = src/linux/JGfx.o src/linux/JSfx.o src/linuxmain.o
$(MAKE) -f Makefile.input clean
HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
src/hge/hgerect.o src/hge/hgevector.o \
src/hge/hgedistort.o src/hge/hgefont.o
CXXFLAGS = -W -Wall -Werror
ifdef DEBUG
CXXFLAGS += -ggdb3
endif
# Determination of target.
# TARGET_ARCHITECTURE variable will then be set to either linux or psp.
RESULT = $(shell which psp-config)
ifeq ($(RESULT),)
DEFAULT_RULE = linux
TARGET_ARCHITECTURE = linux
else
DEFAULT_RULE = 3xx
TARGET_ARCHITECTURE = psp
TARGET_LIB = libjge300.a
endif
ifeq ($(MAKECMDGOALS),linux)
DEFAULT_RULE = linux
TARGET_ARCHITECTURE = linux
endif
ifeq ($(MAKECMDGOALS),3xx)
DEFAULT_RULE = 3xx
TARGET_ARCHITECTURE = psp
TARGET_LIB = libjge300.a
endif
ifeq ($(MAKECMDGOALS),1xx)
DEFAULT_RULE = 1xx
OBJS = $(GENERIC_OBJS) $(PSP_OBJS)
TARGET_LIB = libjge100.a
TARGET_ARCHITECTURE = psp
CXXFLAGS += -DDEVHOOK -DPSPFW3XX
endif
ifeq ($(TARGET_ARCHITECTURE),psp)
PSPSDK = $(shell psp-config --pspsdk-path)
PSPDIR = $(shell psp-config --psp-prefix)
OBJS = $(GENERIC_OBJS) $(PSP_OBJS)
TARGET_HGE = libhgetools.a
INCDIR = -I include/psp include/psp/freetype2
CXXFLAGS += -G0
LIBDIR = lib/psp
LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++
endif
ifeq ($(TARGET_ARCHITECTURE),linux)
OBJS = $(GENERIC_OBJS) $(LINUX_OBJS)
TARGET_LIB = libjge.a
TARGET_HGE = libhgetools.a
INCDIR = $(shell freetype-config --cflags)
CXXFLAGS += -DLINUX
LIBDIR = lib/linux
endif
# Set definitive values for variables.
CXXFLAGS := $(INCDIR) $(CXXFLAGS)
LDFLAGS := $(LIBS)
TARGET_LIB := $(LIBDIR)/$(TARGET_LIB)
TARGET_HGE := $(LIBDIR)/$(TARGET_HGE)
ifeq ($(TARGET_ARCHITECTURE),psp)
include $(PSPSDK)/lib/build.mak
endif
all: $(DEFAULT_RULE) hge
debug: $(DEFAULT_RULE) hge
linux: $(TARGET_LIB)
@echo Making for Linux.
3xx: $(TARGET_LIB)
@echo Making for 3xx.
1xx: $(TARGET_LIB)
@echo Making for 1xx.
install: $(TARGET_LIB) hge
hge: $(TARGET_HGE)
clean:
rm -f $(OBJS) $(HGE_OBJS)
ifeq ($(TARGET_ARCHITECTURE),linux)
$(TARGET_LIB): $(OBJS)
ar r $(TARGET_LIB) $(OBJS)
$(TARGET_HGE): $(HGE_OBJS)
ar r $(TARGET_HGE) $(HGE_OBJS)
endif

View File

@@ -25,7 +25,7 @@ CFLAGS = -O2 -G0 -Wall -DDEVHOOK -DPSPFW3XX
LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++ LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++
include $(PSPSDK)/lib/build.mak #include $(PSPSDK)/lib/build.mak
install: $(TARGET_LIB) install: $(TARGET_LIB)
@cp libjge300.a lib/psp @cp libjge300.a lib/psp

34
JGE/Makefile.linux Normal file
View File

@@ -0,0 +1,34 @@
TARGET_LIB = libjge300.a
OBJS = src/JApp.o src/JGBKFont.o \
src/linux/JGfx.o \
src/JGui.o \
src/JGE.o \
src/JLBFont.o \
src/linux/JSfx.o \
src/JGameObject.o src/JSpline.o src/JAnimator.o \
src/JResourceManager.o \
src/JFileSystem.o \
src/JParticle.o src/JParticleEmitter.o src/JParticleEffect.o src/JParticleSystem.o \
src/unzip/ioapi.o src/unzip/mztools.o src/unzip/unzip.o \
src/JSprite.o src/Vector2D.o \
src/tinyxml/tinystr.o src/tinyxml/tinyxml.o \
src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \
src/linuxmain.o src/vram.o \
src/Encoding.o src/JTTFont.o \
src/JMD2Model.o src/JOBJModel.o
INCDIR = -I /usr/include/freetype2
LIBDIR = lib/psp
CXXFLAGS = $(INCDIR) -W -Wall -Werror -DDEVHOOK -DLINUX -ggdb3
LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++
#include $(PSPSDK)/lib/build.mak
install: $(TARGET_LIB)
@cp libjge300.a lib/linux
@echo "Done"
$(TARGET_LIB): $(OBJS)
ar r $(TARGET_LIB) $(OBJS)

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _FILE_SYSTEM_H_ #ifndef _FILE_SYSTEM_H_
@@ -16,7 +16,7 @@
#include <map> #include <map>
#include <string> #include <string>
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
#else #else
#include <pspiofilemgr.h> #include <pspiofilemgr.h>
@@ -47,58 +47,58 @@ public:
static void Destroy(); static void Destroy();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Attach ZIP archive to the file system. /// Attach ZIP archive to the file system.
/// ///
/// @param zipfile - Name of ZIP archive. /// @param zipfile - Name of ZIP archive.
/// @param password - Password for the ZIP archive. Default is NULL. /// @param password - Password for the ZIP archive. Default is NULL.
/// ///
/// @return Status of the attach operation. /// @return Status of the attach operation.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool AttachZipFile(const string &zipfile, char *password = NULL); bool AttachZipFile(const string &zipfile, char *password = NULL);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Release the attached ZIP archive. /// Release the attached ZIP archive.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void DetachZipFile(); void DetachZipFile();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Open file for reading. /// Open file for reading.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool OpenFile(const string &filename); bool OpenFile(const string &filename);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Read data from file. /// Read data from file.
/// ///
/// @param buffer - Buffer for reading. /// @param buffer - Buffer for reading.
/// @param size - Number of bytes to read. /// @param size - Number of bytes to read.
/// ///
/// @return Number of bytes read. /// @return Number of bytes read.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int ReadFile(void *buffer, int size); int ReadFile(void *buffer, int size);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get size of file. /// Get size of file.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetFileSize(); int GetFileSize();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Close file. /// Close file.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void CloseFile(); void CloseFile();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations /// Set root for all the following file operations
/// ///
/// @resourceRoot - New root. /// @resourceRoot - New root.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetResourceRoot(const string& resourceRoot); void SetResourceRoot(const string& resourceRoot);
@@ -113,7 +113,7 @@ private:
string mZipFileName; string mZipFileName;
char *mPassword; char *mPassword;
bool mZipAvailable; bool mZipAvailable;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
FILE *mFile; FILE *mFile;
#else #else
SceUID mFile; SceUID mFile;

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _JGE_H_ #ifndef _JGE_H_
@@ -32,12 +32,19 @@
bool JGEGetButtonState(u32 button); bool JGEGetButtonState(u32 button);
bool JGEGetButtonClick(u32 button); bool JGEGetButtonClick(u32 button);
#elif LINUX
void JGEControl();
BOOL JGEGetKeyState(int key);
bool JGEGetButtonState(uint32_t button);
bool JGEGetButtonClick(uint32_t button);
#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>
@@ -73,11 +80,11 @@ private:
// JMotionSystem* mMotionSystem; // JMotionSystem* mMotionSystem;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
float mDeltaTime; float mDeltaTime;
JMusic *mCurrentMusic; JMusic *mCurrentMusic;
#else #else
SceCtrlData mCtrlPad; SceCtrlData mCtrlPad;
u32 mOldButtons; u32 mOldButtons;
@@ -92,7 +99,7 @@ private:
float mDelta; float mDelta;
bool mDebug; bool mDebug;
bool mPaused; bool mPaused;
char mDebuggingMsg[256]; char mDebuggingMsg[256];
@@ -103,7 +110,7 @@ private:
static JGE* mInstance; static JGE* mInstance;
public: public:
@@ -187,7 +194,7 @@ public:
/// @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.
@@ -195,7 +202,7 @@ public:
/// @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.
@@ -206,7 +213,7 @@ public:
void Assert(const char *filename, long lineNumber); void Assert(const char *filename, long lineNumber);
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
void SetDelta(int delta); void SetDelta(int delta);
#endif #endif

View File

@@ -12,8 +12,6 @@
#ifndef _JGUI_H #ifndef _JGUI_H
#define _JGUI_H #define _JGUI_H
#include "JGE.h" #include "JGE.h"
#include "JSprite.h" #include "JSprite.h"

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
@@ -21,7 +21,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Bitmap font class for LMNOpc's Bitmap Font Builder: /// Bitmap font class for LMNOpc's Bitmap Font Builder:
/// http://www.lmnopc.com/bitmapfontbuilder/ /// http://www.lmnopc.com/bitmapfontbuilder/
/// ///
/// Two files are used for each font: /// Two files are used for each font:
/// 1: xxx.png, font bitmap. /// 1: xxx.png, font bitmap.
/// 2: xxx.dat, widths for each character /// 2: xxx.dat, widths for each character
@@ -34,11 +34,11 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Constructor. /// Constructor.
/// ///
/// @param fontname - Name of the font WITHOUT extensions. /// @param fontname - Name of the font WITHOUT extensions.
/// @param lineheight - Font height. /// @param lineheight - Font height.
/// @param useVideoRAM - Indicate to use video RAM to store the font image or not (PSP only). /// @param useVideoRAM - Indicate to use video RAM to store the font image or not (PSP only).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JLBFont(const char *fontname, int lineheight, bool useVideoRAM=false); JLBFont(const char *fontname, int lineheight, bool useVideoRAM=false);
@@ -46,104 +46,104 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Rendering text to screen. /// Rendering text to screen.
/// ///
/// @param string - text for rendering. /// @param string - text for rendering.
/// @param x - X position of text. /// @param x - X position of text.
/// @param y - Y position of text. /// @param y - Y position of text.
/// @align - Text aligment. /// @align - Text aligment.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void DrawString(const char *string, float x, float y, int align=JGETEXT_LEFT); void DrawString(const char *string, float x, float y, int align=JGETEXT_LEFT);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Rendering text to screen with syntax similar to printf of C/C++. /// Rendering text to screen with syntax similar to printf of C/C++.
/// ///
/// @param x - X position of text. /// @param x - X position of text.
/// @param y - Y position of text. /// @param y - Y position of text.
/// @param format - String formatting. /// @param format - String formatting.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void printf(float x, float y, const char *format, ...); void printf(float x, float y, const char *format, ...);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set font color. /// Set font color.
/// ///
/// @param color - color of font. /// @param color - color of font.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color); void SetColor(PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set scale for rendering. /// Set scale for rendering.
/// ///
/// @param scale - Scale for rendering characters. /// @param scale - Scale for rendering characters.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetScale(float scale); void SetScale(float scale);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set angle for rendering. /// Set angle for rendering.
/// ///
/// @param rot - Rotation angle in radian. /// @param rot - Rotation angle in radian.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetRotation(float rot); void SetRotation(float rot);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set font tracking. /// Set font tracking.
/// ///
/// @param tracking - Font tracking. /// @param tracking - Font tracking.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetTracking(float tracking); void SetTracking(float tracking);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get font color. /// Get font color.
/// ///
/// @return Font color. /// @return Font color.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
PIXEL_TYPE GetColor() const; PIXEL_TYPE GetColor() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get rendering scale. /// Get rendering scale.
/// ///
/// @return Rendering scale. /// @return Rendering scale.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetScale() const; float GetScale() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get rendering angle. /// Get rendering angle.
/// ///
/// @return Rendering angle. /// @return Rendering angle.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetRotation() const; float GetRotation() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get font tracking. /// Get font tracking.
/// ///
/// @return Font tracking. /// @return Font tracking.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetTracking() const; float GetTracking() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get height of font. /// Get height of font.
/// ///
/// @return Height of font. /// @return Height of font.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetHeight() const; float GetHeight() const;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get width of rendering string on screen. /// Get width of rendering string on screen.
/// ///
/// @param string - NULL terminated string. /// @param string - NULL terminated string.
/// ///
/// @return - Width in pixels /// @return - Width in pixels
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetStringWidth(const char *string) const; float GetStringWidth(const char *string) const;
@@ -152,9 +152,9 @@ public:
/// is from index 0-127 and the second from 128-255. You should use this /// is from index 0-127 and the second from 128-255. You should use this
/// function to select which set of characters you want to use. The index /// function to select which set of characters you want to use. The index
/// base should be either 0 or 128. /// base should be either 0 or 128.
/// ///
/// @param base - Base for the character set to use. /// @param base - Base for the character set to use.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetBase(int base); void SetBase(int base);

View File

@@ -11,7 +11,7 @@
#ifndef _MD2MODEL_H #ifndef _MD2MODEL_H
#define _MD2MODEL_H #define _MD2MODEL_H
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
#else #else
@@ -236,7 +236,7 @@ private:
void CheckNextState(); void CheckNextState();
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
void CalculateNormal(float *p1, float *p2, float *p3); void CalculateNormal(float *p1, float *p2, float *p3);
#else #else
void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3); void CalculateNormal(ScePspFVector3* normal, float *p1, float *p2, float *p3);

View File

@@ -15,7 +15,7 @@
using namespace std; using namespace std;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
#else #else

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _JRENDERER_H_ #ifndef _JRENDERER_H_
@@ -21,16 +21,18 @@
#include "JTypes.h" #include "JTypes.h"
#ifdef WIN32 #if defined (WIN32)
#include <windows.h> #include <windows.h>
#elif defined (LINUX)
#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>
@@ -54,7 +56,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// A collection of core rendering functions. /// A collection of core rendering functions.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class JRenderer class JRenderer
@@ -108,81 +110,81 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Taking a screen shot. /// Taking a screen shot.
/// ///
/// @note This function works on PSP only. A PNG file will be saved in /// @note This function works on PSP only. A PNG file will be saved in
/// the current folder of the game applicaton. /// the current folder of the game applicaton.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void ScreenShot(const char* filename); void ScreenShot(const char* filename);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Load a texture from file. /// Load a texture from file.
/// ///
/// @param filename - Name of file. /// @param filename - Name of file.
/// @param mode - Choose to put texture in VRAM (PSP only). /// @param mode - Choose to put texture in VRAM (PSP only).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JTexture* LoadTexture(const char* filename, int mode = 0); JTexture* LoadTexture(const char* filename, int mode = 0);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Create texture from memory on the fly. /// Create texture from memory on the fly.
/// ///
/// @param width - Width of texture. /// @param width - Width of texture.
/// @param height - Height of texture. /// @param height - Height of texture.
/// @param mode - Choose to put texture in VRAM (PSP only) /// @param mode - Choose to put texture in VRAM (PSP only)
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JTexture* CreateTexture(int width, int height, int mode = 0); JTexture* CreateTexture(int width, int height, int mode = 0);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Clear entire screen to a particular color. /// Clear entire screen to a particular color.
/// ///
/// @param color - Color to fill the screen. /// @param color - Color to fill the screen.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void ClearScreen(PIXEL_TYPE color); void ClearScreen(PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Enable VSync for the smoothness of moving objects. (PSP only) /// Enable VSync for the smoothness of moving objects. (PSP only)
/// ///
/// @param flag - true to enable, false to disable. /// @param flag - true to enable, false to disable.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EnableVSync(bool flag); void EnableVSync(bool flag);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Enable bi-linear filtering for better looking on-screen images. /// Enable bi-linear filtering for better looking on-screen images.
/// ///
/// @param flag - true to enable, false to disable. /// @param flag - true to enable, false to disable.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EnableTextureFilter(bool flag); void EnableTextureFilter(bool flag);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Remove all textures from VRAM (PSP only) /// Remove all textures from VRAM (PSP only)
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void ResetPrivateVRAM(); void ResetPrivateVRAM();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Enable/disable swizzle optimization. (PSP only) /// Enable/disable swizzle optimization. (PSP only)
/// ///
/// @param s - 1 to enable, 0 to disable. /// @param s - 1 to enable, 0 to disable.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetSwizzle(int s) { mSwizzle = s; } void SetSwizzle(int s) { mSwizzle = s; }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Bind texture to be used for the rendering followed. /// Bind texture to be used for the rendering followed.
/// ///
/// @param tex - Texture to use. /// @param tex - Texture to use.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BindTexture(JTexture *tex); void BindTexture(JTexture *tex);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set texture blending options. /// Set texture blending options.
/// ///
/// @par Blending options: /// @par Blending options:
/// ///
/// @code /// @code
@@ -193,9 +195,9 @@ public:
/// BLEND_ONE_MINUS_SRC_COLOR /// BLEND_ONE_MINUS_SRC_COLOR
/// BLEND_SRC_ALPHA /// BLEND_SRC_ALPHA
/// BLEND_ONE_MINUS_SRC_ALPHA /// BLEND_ONE_MINUS_SRC_ALPHA
/// BLEND_DST_ALPHA /// BLEND_DST_ALPHA
/// BLEND_ONE_MINUS_DST_ALPHA /// BLEND_ONE_MINUS_DST_ALPHA
/// BLEND_DST_COLOR /// BLEND_DST_COLOR
/// BLEND_ONE_MINUS_DST_COLOR /// BLEND_ONE_MINUS_DST_COLOR
/// BLEND_SRC_ALPHA_SATURATE /// BLEND_SRC_ALPHA_SATURATE
/// ///
@@ -203,29 +205,29 @@ public:
/// ///
/// @param src - Blending option for source image. /// @param src - Blending option for source image.
/// @param dest - Blending option for destination image. /// @param dest - Blending option for destination image.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetTexBlend(int src, int dest); void SetTexBlend(int src, int dest);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set texture blending option for source image. /// Set texture blending option for source image.
/// ///
/// @param src - Blending option for source image. /// @param src - Blending option for source image.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetTexBlendSrc(int src); void SetTexBlendSrc(int src);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set texture blending option for destination image. /// Set texture blending option for destination image.
/// ///
/// @param dest - Blending option for destination image. /// @param dest - Blending option for destination image.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetTexBlendDest(int dest); void SetTexBlendDest(int dest);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Enable rendering in 2D mode. /// Enable rendering in 2D mode.
/// ///
/// @note To be implemented. /// @note To be implemented.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -236,7 +238,7 @@ public:
/// Enable rendering in 3D mode. /// Enable rendering in 3D mode.
/// ///
/// @note To be implemented. /// @note To be implemented.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void Enable3D(); void Enable3D();
@@ -244,12 +246,12 @@ public:
/// Restrict all rendering to a rectangular area. /// Restrict all rendering to a rectangular area.
/// ///
/// @note This is just the glScissor() function of OpenGL. /// @note This is just the glScissor() function of OpenGL.
/// ///
/// @param x - Left of the clipping area. /// @param x - Left of the clipping area.
/// @param y - Top of the clipping area. /// @param y - Top of the clipping area.
/// @param width - Width of the clipping area. /// @param width - Width of the clipping area.
/// @param height - Height of the clipping area. /// @param height - Height of the clipping area.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetClip(int x, int y, int width, int height); void SetClip(int x, int y, int width, int height);
@@ -271,52 +273,52 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Rotate along X axis. /// Rotate along X axis.
/// ///
/// @param angle - Angle to rotate ( in radians). /// @param angle - Angle to rotate ( in radians).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void RotateX(float angle); void RotateX(float angle);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Rotate along Y axis. /// Rotate along Y axis.
/// ///
/// @param angle - Angle to rotate ( in radians). /// @param angle - Angle to rotate ( in radians).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void RotateY(float angle); void RotateY(float angle);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Rotate along Z axis. /// Rotate along Z axis.
/// ///
/// @param angle - Angle to rotate ( in radians). /// @param angle - Angle to rotate ( in radians).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void RotateZ(float angle); void RotateZ(float angle);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Push matrix. /// Push matrix.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void PushMatrix(); void PushMatrix();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Pop matrix. /// Pop matrix.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void PopMatrix(); void PopMatrix();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set the field of view angle (in degrees), effective at the next /// Set the field of view angle (in degrees), effective at the next
/// Enable3D() call. /// Enable3D() call.
/// ///
/// @param fov - The field of view angle (in degrees). /// @param fov - The field of view angle (in degrees).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetFOV(float fov); void SetFOV(float fov);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Render triangles. /// Render triangles.
/// ///
/// @param texture - Texture for the triangles. /// @param texture - Texture for the triangles.
/// @param tris - List of triangles. /// @param tris - List of triangles.
/// @param start - starting index (Note: Index of triangles, NOT vertices). /// @param start - starting index (Note: Index of triangles, NOT vertices).
@@ -370,7 +372,7 @@ public:
/// @param x2 - Ending vertex, x. /// @param x2 - Ending vertex, x.
/// @param y2 - Ending vertex, y. /// @param y2 - Ending vertex, y.
/// @param color - Filling color. /// @param color - Filling color.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color); void DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color);
@@ -383,23 +385,23 @@ public:
/// @param y2 - Ending vertex, y. /// @param y2 - Ending vertex, y.
/// @param lineWidth - Line width. /// @param lineWidth - Line width.
/// @param color - Filling color. /// @param color - Filling color.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void DrawLine(float x1, float y1, float x2, float y2, float lineWidth, PIXEL_TYPE color); void DrawLine(float x1, float y1, float x2, float y2, float lineWidth, PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Plot a pixel on screen. /// Plot a pixel on screen.
/// ///
/// @param x - X position of the pixel. /// @param x - X position of the pixel.
/// @param y - Y position of the pixel. /// @param y - Y position of the pixel.
/// @param color - Draw colour. /// @param color - Draw colour.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void Plot(float x, float y, PIXEL_TYPE color); void Plot(float x, float y, PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Plot an array of pixels. /// Plot an array of pixels.
/// ///
/// @param x - Array of X positions. /// @param x - Array of X positions.
/// @param y - Array of Y positions. /// @param y - Array of Y positions.
/// @param count - Number of pixels to plot. /// @param count - Number of pixels to plot.
@@ -410,7 +412,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw polygon with filled colour. /// Draw polygon with filled colour.
/// ///
/// @param x - Array of X positions. /// @param x - Array of X positions.
/// @param y - Array of Y positions. /// @param y - Array of Y positions.
/// @param count - Side count of the polygon. /// @param count - Side count of the polygon.
@@ -421,7 +423,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw polygon. /// Draw polygon.
/// ///
/// @param x - Array of X positions. /// @param x - Array of X positions.
/// @param y - Array of Y positions. /// @param y - Array of Y positions.
/// @param count - Side count of the polygon. /// @param count - Side count of the polygon.
@@ -429,10 +431,10 @@ public:
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color); void DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw symmetric polygon with certain number of sides. /// Draw symmetric polygon with certain number of sides.
/// ///
/// @param x - X positions of center of the polygon. /// @param x - X positions of center of the polygon.
/// @param y - Y positions of center of the polygon. /// @param y - Y positions of center of the polygon.
/// @param size - Size of polygon. /// @param size - Size of polygon.
@@ -445,7 +447,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw solid symmetric polygon with certain number of sides. /// Draw solid symmetric polygon with certain number of sides.
/// ///
/// @param x - X positions of center of the polygon. /// @param x - X positions of center of the polygon.
/// @param y - Y positions of center of the polygon. /// @param y - Y positions of center of the polygon.
/// @param size - Size of polygon. /// @param size - Size of polygon.
@@ -455,10 +457,10 @@ public:
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void FillPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color); void FillPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw circle with filled colour. /// Draw circle with filled colour.
/// ///
/// @param x - X positions of center of the circle. /// @param x - X positions of center of the circle.
/// @param y - Y positions of center of the circle. /// @param y - Y positions of center of the circle.
/// @param radius - Radius of circle. /// @param radius - Radius of circle.
@@ -469,7 +471,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Draw circle. /// Draw circle.
/// ///
/// @param x - X positions of center of the circle. /// @param x - X positions of center of the circle.
/// @param y - Y positions of center of the circle. /// @param y - Y positions of center of the circle.
/// @param radius - Radius of circle. /// @param radius - Radius of circle.
@@ -533,11 +535,11 @@ private:
static JRenderer* mInstance; static JRenderer* mInstance;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
GLuint mCurrentTex; GLuint mCurrentTex;
#else #else
u32 mVideoBufferStart; u32 mVideoBufferStart;
@@ -545,7 +547,7 @@ private:
PIXEL_TYPE* mVRAM; PIXEL_TYPE* mVRAM;
int mCurrentTex; int mCurrentTex;
int mCurrentBlend; int mCurrentBlend;
#endif #endif
bool mVsync; bool mVsync;
@@ -563,7 +565,7 @@ private:
JImageFilter* mImageFilter; JImageFilter* mImageFilter;
int mCurrentRenderMode; int mCurrentRenderMode;
float mFOV; float mFOV;
#ifdef USING_MATH_TABLE #ifdef USING_MATH_TABLE

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _JSOUNDSYSTEM_H_ #ifndef _JSOUNDSYSTEM_H_
@@ -22,13 +22,13 @@
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
#elif defined (LINUX)
#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>
@@ -48,12 +48,12 @@ public:
JMusic(); JMusic();
~JMusic(); ~JMusic();
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
#else #else
JCooleyesMP3* mTrack; JCooleyesMP3* mTrack;
#endif #endif
}; };
@@ -65,8 +65,8 @@ public:
~JSample(); ~JSample();
int mVoice; int mVoice;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mSample; FSOUND_SAMPLE *mSample;
#else #else
WAVDATA *mSample; WAVDATA *mSample;
@@ -75,7 +75,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Sound engine for playing sound effects (WAV) and background /// Sound engine for playing sound effects (WAV) and background
/// music (MP3). /// music (MP3).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -96,91 +96,91 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Load music. /// Load music.
/// ///
/// @note MP3 is the only supported format for the moment. /// @note MP3 is the only supported format for the moment.
/// ///
/// @param filename - Name of the music file. /// @param filename - Name of the music file.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JMusic *LoadMusic(const char *fileName); JMusic *LoadMusic(const char *fileName);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Delete music from memory. /// Delete music from memory.
/// ///
/// @param music - Music to be deleted. /// @param music - Music to be deleted.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//void FreeMusic(JMusic *music); //void FreeMusic(JMusic *music);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Play music. /// Play music.
/// ///
/// @param music - Music to be played. /// @param music - Music to be played.
/// @param looping - Play the music in a loop. /// @param looping - Play the music in a loop.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void PlayMusic(JMusic *music, bool looping = false); void PlayMusic(JMusic *music, bool looping = false);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Stop playing. /// Stop playing.
/// ///
/// @param music - Music to be stopped. /// @param music - Music to be stopped.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void StopMusic(JMusic *music); void StopMusic(JMusic *music);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Resume playing. /// Resume playing.
/// ///
/// @param music - Music to be resumed. /// @param music - Music to be resumed.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void ResumeMusic(JMusic *music); void ResumeMusic(JMusic *music);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Load sound effect. /// Load sound effect.
/// ///
/// @note WAV sound effect only. /// @note WAV sound effect only.
/// ///
/// @param fileName - Sound effect for loading. /// @param fileName - Sound effect for loading.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JSample *LoadSample(const char *fileName); JSample *LoadSample(const char *fileName);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Delete sound effect from memory. /// Delete sound effect from memory.
/// ///
/// @param sample - Sound to be deleted. /// @param sample - Sound to be deleted.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//void FreeSample(JSample *sample); //void FreeSample(JSample *sample);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Play sound effect. /// Play sound effect.
/// ///
/// @param sample - Sound for playing. /// @param sample - Sound for playing.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void PlaySample(JSample *sample); void PlaySample(JSample *sample);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set volume for audio playback. /// Set volume for audio playback.
/// ///
/// @param volume - New volume. /// @param volume - New volume.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetVolume(int volume); void SetVolume(int volume);
protected: protected:
JSoundSystem(); JSoundSystem();
~JSoundSystem(); ~JSoundSystem();
void InitSoundSystem(); void InitSoundSystem();
void DestroySoundSystem(); void DestroySoundSystem();
private: private:
#ifdef WIN32 #ifdef WIN32
JMusic *mCurrentMusic; JMusic *mCurrentMusic;

View File

@@ -3,15 +3,15 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _SPRITE_H_ #ifndef _SPRITE_H_
#define _SPRITE_H_ #define _SPRITE_H_
#ifdef WIN32 #if defined (WIN32) || defined(LINUX)
#include <math.h> #include <math.h>
#else #else
#include <fastmath.h> #include <fastmath.h>
@@ -36,15 +36,15 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Constructor. /// Constructor.
/// ///
/// @param tex - Texture for the first frame and the following frames. /// @param tex - Texture for the first frame and the following frames.
/// NULL to indicate no starting frame. /// NULL to indicate no starting frame.
/// @param x - X of the frame in texture. /// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture. /// @param y - Y of the frame in texture.
/// @param width - Width of the frame. /// @param width - Width of the frame.
/// @param height - Height of the frame. /// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped. /// @param flipped - Indicate if the frame is horizontally flipped.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JSprite(JTexture *tex=NULL, float x=0.0f, float y=0.0f, float width=0.0f, float height=0.0f, bool flipped = false); JSprite(JTexture *tex=NULL, float x=0.0f, float y=0.0f, float width=0.0f, float height=0.0f, bool flipped = false);
@@ -52,128 +52,128 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Update animation. /// Update animation.
/// ///
/// @param dt - Delta time since last update (in second). /// @param dt - Delta time since last update (in second).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
virtual void Update(float dt); virtual void Update(float dt);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Render current frame. /// Render current frame.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
virtual void Render(); virtual void Render();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set animation type. /// Set animation type.
/// ///
/// @param type - Animation type. /// @param type - Animation type.
/// ///
/// @code /// @code
/// ANIMATION_TYPE_LOOPING - Repeat playing (Default). /// ANIMATION_TYPE_LOOPING - Repeat playing (Default).
/// ANIMATION_TYPE_ONCE_AND_GONE - Play animation once only. /// ANIMATION_TYPE_ONCE_AND_GONE - Play animation once only.
/// ANIMATION_TYPE_ONCE_AND_BACK - Play to end and then stay at first frame. /// ANIMATION_TYPE_ONCE_AND_BACK - Play to end and then stay at first frame.
/// ANIMATION_TYPE_PINGPONG - Play forward then backward and repeat. /// ANIMATION_TYPE_PINGPONG - Play forward then backward and repeat.
/// @endcode /// @endcode
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetAnimationType(int type); void SetAnimationType(int type);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Enable/Disable sprite. /// Enable/Disable sprite.
/// ///
/// @param f - True to enable, false to disable. /// @param f - True to enable, false to disable.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetActive(bool f); void SetActive(bool f);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get current active status. /// Get current active status.
/// ///
/// @return Active status. /// @return Active status.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool IsActive(); bool IsActive();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Give sprite an id. /// Give sprite an id.
/// ///
/// @param id - Id. /// @param id - Id.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetId(int id); void SetId(int id);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get sprite id. /// Get sprite id.
/// ///
/// @return Sprite id. /// @return Sprite id.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetId(); int GetId();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Flip a frame or all frames horizontally when rendering. /// Flip a frame or all frames horizontally when rendering.
/// ///
/// @param flip - True to flip. /// @param flip - True to flip.
/// @param index - Frame index, -1 to flip all frames. /// @param index - Frame index, -1 to flip all frames.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetFlip(bool flip, int index = -1); void SetFlip(bool flip, int index = -1);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Add new animation frame. /// Add new animation frame.
/// ///
/// @param x - X of the frame in texture. /// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture. /// @param y - Y of the frame in texture.
/// @param width - Width of the frame. /// @param width - Width of the frame.
/// @param height - Height of the frame. /// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped. /// @param flipped - Indicate if the frame is horizontally flipped.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void AddFrame(float x, float y, float width, float height, bool flipped = false); void AddFrame(float x, float y, float width, float height, bool flipped = false);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Add new animation frame. /// Add new animation frame.
/// ///
/// @param tex - Texture for this frame and the following frames. /// @param tex - Texture for this frame and the following frames.
/// @param x - X of the frame in texture. /// @param x - X of the frame in texture.
/// @param y - Y of the frame in texture. /// @param y - Y of the frame in texture.
/// @param width - Width of the frame. /// @param width - Width of the frame.
/// @param height - Height of the frame. /// @param height - Height of the frame.
/// @param flipped - Indicate if the frame is horizontally flipped. /// @param flipped - Indicate if the frame is horizontally flipped.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void AddFrame(JTexture *tex, float x, float y, float width, float height, bool flipped = false); void AddFrame(JTexture *tex, float x, float y, float width, float height, bool flipped = false);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set playback duration for each frame. /// Set playback duration for each frame.
/// ///
/// @param duration - Playback duration (in second) for each frame. /// @param duration - Playback duration (in second) for each frame.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetDuration(float duration); void SetDuration(float duration);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get index of current frame. /// Get index of current frame.
/// ///
/// @return Index of current frame. /// @return Index of current frame.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetCurrentFrameIndex(); int GetCurrentFrameIndex();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set current frame to a particular index. /// Set current frame to a particular index.
/// ///
/// @param frame - The new index of current frame. /// @param frame - The new index of current frame.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetCurrentFrameIndex(int frame); void SetCurrentFrameIndex(int frame);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get current frame image (quad). /// Get current frame image (quad).
/// ///
/// @return Quad object. /// @return Quad object.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JQuad* GetCurrentFrame(); JQuad* GetCurrentFrame();
@@ -181,39 +181,39 @@ public:
/// Get numer of animation frames. /// Get numer of animation frames.
/// ///
/// @return Numer of animation frames. /// @return Numer of animation frames.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int GetFrameCount(); int GetFrameCount();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get frame image (quad). /// Get frame image (quad).
/// ///
/// @return Quad object. /// @return Quad object.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JQuad* GetFrame(int index); JQuad* GetFrame(int index);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Restart animation. /// Restart animation.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void RestartAnimation(); void RestartAnimation();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Start animation. /// Start animation.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void StartAnimation(); void StartAnimation();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Stop animation. /// Stop animation.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void StopAnimation(); void StopAnimation();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get animation status. /// Get animation status.
/// ///
/// @return animation status /// @return animation status
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -221,184 +221,184 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Move some distance from the current position. /// Move some distance from the current position.
/// ///
/// @param x - X distance to move. /// @param x - X distance to move.
/// @param y - Y distance to move. /// @param y - Y distance to move.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void Move(float x, float y); void Move(float x, float y);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set position of the sprite. /// Set position of the sprite.
/// ///
/// @param x - X position. /// @param x - X position.
/// @param y - Y position. /// @param y - Y position.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetPosition(float x, float y); void SetPosition(float x, float y);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set X position of the sprite. /// Set X position of the sprite.
/// ///
/// @param x - X position. /// @param x - X position.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetX(float x); void SetX(float x);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set Y position of the sprite. /// Set Y position of the sprite.
/// ///
/// @param y - Y position. /// @param y - Y position.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetY(float y); void SetY(float y);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get X position of the sprite. /// Get X position of the sprite.
/// ///
/// @return X position. /// @return X position.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetX(); float GetX();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get Y position of the sprite. /// Get Y position of the sprite.
/// ///
/// @return Y position. /// @return Y position.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetY(); float GetY();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get X velocity. /// Get X velocity.
/// ///
/// @return X velocity. /// @return X velocity.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetXVelocity(); float GetXVelocity();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get Y velocity. /// Get Y velocity.
/// ///
/// @return Y velocity. /// @return Y velocity.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetYVelocity(); float GetYVelocity();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set alpha value for rendering. /// Set alpha value for rendering.
/// ///
/// @param alpha - Alpha value. /// @param alpha - Alpha value.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetAlpha(float alpha); void SetAlpha(float alpha);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get alpha value. /// Get alpha value.
/// ///
/// @return Alpha value. /// @return Alpha value.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetAlpha(); float GetAlpha();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set scale of the sprite. /// Set scale of the sprite.
/// ///
/// @param hscale - Horizontal scale. /// @param hscale - Horizontal scale.
/// @param vscale - Vertical scale. /// @param vscale - Vertical scale.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetScale(float hscale, float vscale); void SetScale(float hscale, float vscale);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set scale of the sprite. /// Set scale of the sprite.
/// ///
/// @param scale - Scale for both horizontal and vertical dimension. /// @param scale - Scale for both horizontal and vertical dimension.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetScale(float scale); void SetScale(float scale);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get scale of the sprite. /// Get scale of the sprite.
/// ///
/// @return Scale of horizontal (assume same as the vertical). /// @return Scale of horizontal (assume same as the vertical).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetScale(); float GetScale();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set rotation factor of the sprite. /// Set rotation factor of the sprite.
/// ///
/// @param rot - Rotation angle in radian. /// @param rot - Rotation angle in radian.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetRotation(float rot); void SetRotation(float rot);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get rotation factor of the sprite. /// Get rotation factor of the sprite.
/// ///
/// @return Rotation angle in radian. /// @return Rotation angle in radian.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetRotation(); float GetRotation();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set moving speed of the sprite. /// Set moving speed of the sprite.
/// ///
/// @param speed - Moving speed. /// @param speed - Moving speed.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetSpeed(float speed); void SetSpeed(float speed);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get moving speed of the sprite. /// Get moving speed of the sprite.
/// ///
/// @return Moving speed. /// @return Moving speed.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetSpeed(); float GetSpeed();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set moving direction of the sprite. /// Set moving direction of the sprite.
/// ///
/// @param angle - Moving angle in radian. /// @param angle - Moving angle in radian.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetDirection(float angle); void SetDirection(float angle);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set moving direction of the sprite based on a targeting position. /// Set moving direction of the sprite based on a targeting position.
/// ///
/// @param x - X position of the target. /// @param x - X position of the target.
/// @param y - Y position of the target. /// @param y - Y position of the target.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetDirection(float x, float y); void SetDirection(float x, float y);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get moving direction of the sprite. /// Get moving direction of the sprite.
/// ///
/// @return Moving angle in radian. /// @return Moving angle in radian.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
float GetDirection(); float GetDirection();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set anchor point of a frame or all frames of the sprite. All rotation /// Set anchor point of a frame or all frames of the sprite. All rotation
/// and collision operations are based on this anchor point. /// and collision operations are based on this anchor point.
/// ///
/// @param x - X position of the anchor point. /// @param x - X position of the anchor point.
/// @param y - Y position of the anchor point. /// @param y - Y position of the anchor point.
/// @param index - Frame index, -1 for all frames. /// @param index - Frame index, -1 for all frames.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetHotSpot(float x, float y, int index=-1); void SetHotSpot(float x, float y, int index=-1);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set color of the sprite for rendering. /// Set color of the sprite for rendering.
/// ///
/// @param color - Color. /// @param color - Color.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color); void SetColor(PIXEL_TYPE color);
@@ -406,9 +406,9 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// \enum ANIMATION_TYPE /// \enum ANIMATION_TYPE
/// ///
/// Type of animation. /// Type of animation.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
enum ANIMATION_TYPE enum ANIMATION_TYPE
{ {
@@ -419,12 +419,12 @@ public:
ANIMATION_TYPE_PINGPONG ///< Play forward then backward and repeat. ANIMATION_TYPE_PINGPONG ///< Play forward then backward and repeat.
}; };
protected: protected:
static JRenderer* mRenderer; static JRenderer* mRenderer;
JTexture* mTex; JTexture* mTex;
vector<JQuad*> mFrames; vector<JQuad*> mFrames;
float mDuration; float mDuration;
@@ -434,24 +434,24 @@ protected:
int mAnimationType; int mAnimationType;
int mDelta; int mDelta;
bool mAnimating; bool mAnimating;
float mAlpha; float mAlpha;
PIXEL_TYPE mColor; PIXEL_TYPE mColor;
float mVScale; float mVScale;
float mHScale; float mHScale;
float mRotation; float mRotation;
float mDirection; float mDirection;
float mSpeed; float mSpeed;
int mId; int mId;
bool mActive; bool mActive;
float mX; float mX;
float mY; float mY;
}; };
@@ -459,12 +459,12 @@ protected:
class JSpriteList class JSpriteList
{ {
protected: protected:
int mCount; int mCount;
JSprite** mList; JSprite** mList;
//JSpriteList** mVictims; //JSpriteList** mVictims;
//JCollisionListener* mCollisionListener; //JCollisionListener* mCollisionListener;
public: public:
JSpriteList(int count); JSpriteList(int count);
~JSpriteList(); ~JSpriteList();

View File

@@ -3,15 +3,17 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _JTYPES_H #ifndef _JTYPES_H
#define _JTYPES_H #define _JTYPES_H
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
#include <sys/types.h>
#else #else
@@ -19,7 +21,7 @@
#include <pspgum.h> #include <pspgum.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>
@@ -64,12 +66,19 @@
#define BLEND_OPTION_BLEND GU_TFX_BLEND #define BLEND_OPTION_BLEND GU_TFX_BLEND
#endif #endif
#ifdef WIN32
#if defined (WIN32)
#include <windows.h> #include <windows.h>
#include <gl/gl.h> #endif
#include <gl/glu.h> #ifdef LINUX
typedef unsigned char byte;
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef bool BOOL;
#endif
#if defined (WIN32) || defined (LINUX)
#include <GL/gl.h>
#include <GL/glu.h>
#include "../Dependencies/include/fmod.h" #include "../Dependencies/include/fmod.h"
@@ -79,13 +88,20 @@
//#define u8 BYTE //#define u8 BYTE
//#define u16 WORD //#define u16 WORD
//#define u32 DWORD //#define u32 DWORD
/*
typedef signed char s8; typedef signed char s8;
typedef signed short s16; typedef signed short s16;
typedef signed long s32; typedef signed long s32;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
//Long ? typedef unsigned long u32;
typedef unsigned int u32; */
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
#define BLEND_ZERO GL_ZERO #define BLEND_ZERO GL_ZERO
@@ -103,7 +119,7 @@
#define ARGB(a, r, g, b) ((a << 24) | (r << 16) | (g << 8) | b) #define ARGB(a, r, g, b) ((a << 24) | (r << 16) | (g << 8) | b)
#define RGBA(r, g, b, a) ((a << 24) | (b << 16) | (g << 8) | r) #define RGBA(r, g, b, a) ((a << 24) | (b << 16) | (g << 8) | r)
enum PspCtrlButtons typedef enum PspCtrlButtons
{ {
PSP_CTRL_SELECT = 0x000001, PSP_CTRL_SELECT = 0x000001,
PSP_CTRL_START = 0x000008, PSP_CTRL_START = 0x000008,
@@ -119,8 +135,8 @@
PSP_CTRL_SQUARE = 0x008000, PSP_CTRL_SQUARE = 0x008000,
PSP_CTRL_HOME = 0x010000, PSP_CTRL_HOME = 0x010000,
PSP_CTRL_HOLD = 0x020000, PSP_CTRL_HOLD = 0x020000,
PSP_CTRL_NOTE = 0x800000, PSP_CTRL_NOTE = 0x800000
}; } PspCtrlButtons;
#define PIXEL_TYPE DWORD #define PIXEL_TYPE DWORD
@@ -191,11 +207,10 @@
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE #define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
#define SLICE_SIZE_F 64.0f #define SLICE_SIZE_F 64.0f
//LONG ??? typedef unsigned long DWORD;
typedef unsigned int DWORD;
#define BLEND_ZERO 0x1000 #define BLEND_ZERO 0x1000
#define BLEND_ONE 0x1002 #define BLEND_ONE 0x1002
#define BLEND_SRC_COLOR GU_SRC_COLOR #define BLEND_SRC_COLOR GU_SRC_COLOR
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR #define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
#define BLEND_SRC_ALPHA GU_SRC_ALPHA #define BLEND_SRC_ALPHA GU_SRC_ALPHA
@@ -212,7 +227,7 @@
//PIXEL_TYPE color; //PIXEL_TYPE color;
//ScePspFVector3 normal; //ScePspFVector3 normal;
ScePspFVector3 pos; ScePspFVector3 pos;
} PSPVertex3D; } PSPVertex3D;
#endif #endif
@@ -304,7 +319,7 @@ public:
int mFilter; int mFilter;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
GLuint mTexId; GLuint mTexId;
#else #else
@@ -316,10 +331,10 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Custom filter for processing the texture image while loading. You /// Custom filter for processing the texture image while loading. You
/// can change the pixels by using a custom filter before the image is /// can change the pixels by using a custom filter before the image is
/// created as a texture. /// created as a texture.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class JImageFilter class JImageFilter
{ {
@@ -339,7 +354,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Image quad. /// Image quad.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class JQuad class JQuad
{ {
@@ -347,74 +362,74 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Constructor. /// Constructor.
/// ///
/// @param tex - Texture of the quad. /// @param tex - Texture of the quad.
/// @param x - X position of the quad in texture. /// @param x - X position of the quad in texture.
/// @param y - Y position of the quad in texture. /// @param y - Y position of the quad in texture.
/// @param width - Width of the quad. /// @param width - Width of the quad.
/// @param height - Height of the quad. /// @param height - Height of the quad.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JQuad(JTexture *tex, float x, float y, float width, float height); JQuad(JTexture *tex, float x, float y, float width, float height);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set blending color of the quad. /// Set blending color of the quad.
/// ///
/// @param color - Color. /// @param color - Color.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetColor(PIXEL_TYPE color); void SetColor(PIXEL_TYPE color);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set anchor point of the quad. /// Set anchor point of the quad.
/// ///
/// @param x - X position of the anchor point. /// @param x - X position of the anchor point.
/// @param y - Y position of the anchor point. /// @param y - Y position of the anchor point.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetHotSpot(float x, float y); void SetHotSpot(float x, float y);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set UV positions of the quad. /// Set UV positions of the quad.
/// ///
/// @param x - X position of the quad in texture. /// @param x - X position of the quad in texture.
/// @param y - Y position of the quad in texture. /// @param y - Y position of the quad in texture.
/// @param w - Width of the quad. /// @param w - Width of the quad.
/// @param h - Height of the quad. /// @param h - Height of the quad.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetTextureRect(float x, float y, float w, float h); void SetTextureRect(float x, float y, float w, float h);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Get UV positions of the quad. /// Get UV positions of the quad.
/// ///
/// @return x - X position of the quad in texture. /// @return x - X position of the quad in texture.
/// @return y - Y position of the quad in texture. /// @return y - Y position of the quad in texture.
/// @return w - Width of the quad. /// @return w - Width of the quad.
/// @return h - Height of the quad. /// @return h - Height of the quad.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void GetTextureRect(float *x, float *y, float *w, float *h); void GetTextureRect(float *x, float *y, float *w, float *h);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set horizontal flipping. /// Set horizontal flipping.
/// ///
/// @param hflip - flipping flag; /// @param hflip - flipping flag;
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetHFlip(bool hflip) { mHFlipped = hflip; } void SetHFlip(bool hflip) { mHFlipped = hflip; }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Set vetical flipping. /// Set vetical flipping.
/// ///
/// @param hflip - flipping flag; /// @param hflip - flipping flag;
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetVFlip(bool vflip) { mVFlipped = vflip; } void SetVFlip(bool vflip) { mVFlipped = vflip; }
JTexture* mTex; JTexture* mTex;
#ifdef WIN32 #if defined (WIN32) || defined(LINUX)
float mTX0; float mTX0;
float mTY0; float mTY0;
float mTX1; float mTX1;
@@ -441,9 +456,9 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// \enum JFONT_TEXT_ALIGNMENT /// \enum JFONT_TEXT_ALIGNMENT
/// ///
/// Font alignment. /// Font alignment.
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
enum JFONT_TEXT_ALIGNMENT enum JFONT_TEXT_ALIGNMENT
{ {

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#ifndef _VECTOR2D_H #ifndef _VECTOR2D_H
@@ -13,6 +13,8 @@
#ifdef WIN32 #ifdef WIN32
#include <math.h> #include <math.h>
#elif defined LINUX
#include <math.h>
#else #else
#include <fastmath.h> #include <fastmath.h>
#endif #endif
@@ -31,7 +33,7 @@ struct Vector2D
inline Vector2D &operator /=(const float scalar) { x /= scalar; y /= scalar; return *this; } inline Vector2D &operator /=(const float scalar) { x /= scalar; y /= scalar; return *this; }
inline Vector2D &operator *=(const float scalar) { x *= scalar; y *= scalar; return *this; } inline Vector2D &operator *=(const float scalar) { x *= scalar; y *= scalar; return *this; }
inline Vector2D &operator +=(const Vector2D &v) { x += v.x; y += v.y; return *this; } inline Vector2D &operator +=(const Vector2D &v) { x += v.x; y += v.y; return *this; }
inline Vector2D &operator -=(const Vector2D &v) { x -= v.x; y -= v.y; return *this; } inline Vector2D &operator -=(const Vector2D &v) { x -= v.x; y -= v.y; return *this; }
@@ -41,14 +43,14 @@ struct Vector2D
// cross product // cross product
inline float operator ^ (const Vector2D &v) const { return (x * v.y) - (y * v.x); } inline float operator ^ (const Vector2D &v) const { return (x * v.y) - (y * v.x); }
// dot product // dot product
inline float operator * (const Vector2D &v) const { return (x*v.x) + (y*v.y); } inline float operator * (const Vector2D &v) const { return (x*v.x) + (y*v.y); }
inline float Dot(const Vector2D &v) const { return (x * v.x) + (y * v.y); }
inline float Cross(const Vector2D &v) const { return (x * v.y) - (y * v.x); }
inline float Dot(const Vector2D &v) const { return (x * v.x) + (y * v.y); }
inline float Cross(const Vector2D &v) const { return (x * v.y) - (y * v.x); }
inline Vector2D operator * (float s) const { return Vector2D(x*s, y*s); } inline Vector2D operator * (float s) const { return Vector2D(x*s, y*s); }
inline Vector2D operator / (float s) const { return Vector2D(x/s, y/s); } inline Vector2D operator / (float s) const { return Vector2D(x/s, y/s); }
@@ -68,4 +70,4 @@ struct Vector2D
}; };
#endif #endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3186,7 +3186,7 @@ static int _gbk_mbtowc(ucs4_t *pwc, const u8 *s, int n)
return RET_ILSEQ; 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; u8 c = *s;
if (c < 0x80) { if (c < 0x80) {

View File

@@ -67,7 +67,7 @@ bool JAnimator::Load(const char* scriptFile)
element = script->ToElement(); element = script->ToElement();
printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name")); printf("---- Loading %s:%s\n", element->Value(), element->Attribute("name"));
char *type[] = const char *type[] =
{ {
"ANIMATION_TYPE_LOOPING", "ANIMATION_TYPE_LOOPING",
"ANIMATION_TYPE_ONCE_AND_STAY", "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; mTimer = 0.0f;
mFrameTime = 100.0f; mFrameTime = 100.0f;
@@ -390,7 +390,7 @@ JAnimatorObject::~JAnimatorObject()
} }
void JAnimatorObject::Update(float dt) void JAnimatorObject::Update(float dt __attribute__((unused)))
{ {
} }

View File

@@ -3,12 +3,14 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 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/JGE.h"
#include "../include/JFileSystem.h" #include "../include/JFileSystem.h"
@@ -47,7 +49,7 @@ void JFileSystem::Destroy()
JFileSystem::JFileSystem() JFileSystem::JFileSystem()
{ {
mZipAvailable = false; mZipAvailable = false;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mFile = NULL; mFile = NULL;
#else #else
mFile = -1; mFile = -1;
@@ -56,7 +58,7 @@ JFileSystem::JFileSystem()
mZipFile = NULL; mZipFile = NULL;
mFileSize = 0; 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) if (mZipFileName != zipfile)
unzCloseCurrentFile(mZipFile); // close the previous zip file unzCloseCurrentFile(mZipFile); // close the previous zip file
} }
mZipFileName = zipfile; mZipFileName = zipfile;
mPassword = password; mPassword = password;
@@ -96,7 +98,7 @@ void JFileSystem::DetachZipFile()
{ {
unzCloseCurrentFile(mZipFile); unzCloseCurrentFile(mZipFile);
} }
mZipFile = NULL; mZipFile = NULL;
mZipAvailable = false; mZipAvailable = false;
} }
@@ -119,12 +121,12 @@ bool JFileSystem::OpenFile(const string &filename)
mFileSize = fileInfo.uncompressed_size; mFileSize = fileInfo.uncompressed_size;
else else
mFileSize = 0; mFileSize = 0;
return (unzOpenCurrentFilePassword(mZipFile, mPassword) == UNZ_OK); return (unzOpenCurrentFilePassword(mZipFile, mPassword) == UNZ_OK);
} }
else else
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mFile = fopen(path.c_str(), "rb"); mFile = fopen(path.c_str(), "rb");
if (mFile != NULL) if (mFile != NULL)
{ {
@@ -141,13 +143,13 @@ bool JFileSystem::OpenFile(const string &filename)
sceIoLseek(mFile, 0, PSP_SEEK_SET); sceIoLseek(mFile, 0, PSP_SEEK_SET);
return true; return true;
} }
#endif #endif
} }
return false; return false;
} }
@@ -156,7 +158,7 @@ void JFileSystem::CloseFile()
if (mZipAvailable && mZipFile != NULL) if (mZipAvailable && mZipFile != NULL)
return; return;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
if (mFile != NULL) if (mFile != NULL)
fclose(mFile); fclose(mFile);
#else #else
@@ -174,7 +176,7 @@ int JFileSystem::ReadFile(void *buffer, int size)
} }
else else
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
return fread(buffer, 1, size, mFile); return fread(buffer, 1, size, mFile);
#else #else
return sceIoRead(mFile, buffer, size); return sceIoRead(mFile, buffer, size);

View File

@@ -3,7 +3,7 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// Copyright (c) 2007 Sijiu Duan (a.k.a. Chi80) <sijiu49@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]; mSprites = new JQuad*[mCacheSize];
mGBCode = new int[mCacheSize]; mGBCode = new int[mCacheSize];
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mCharBuffer = new DWORD[mFontSize*mFontSize]; mCharBuffer = new DWORD[mFontSize*mFontSize];
#endif #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] = new JQuad(mTexture, x*mFontSize, y*mFontSize, mFontSize, mFontSize);
mSprites[index]->SetHotSpot(mFontSize/2, mFontSize/2); mSprites[index]->SetHotSpot(mFontSize/2, mFontSize/2);
index++; index++;
} }
} }
@@ -136,7 +136,7 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
} }
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
#else #else
void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width, unsigned int height) 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; code = ((DWORD)*ch)|0x10000;
isChinese = false; isChinese = false;
} }
if (mGBCode[mCurr] != -1) if (mGBCode[mCurr] != -1)
{ {
for (int i=0;i<mCacheSize;i++) for (int i=0;i<mCacheSize;i++)
{ {
if (mGBCode[i] == code) if (mGBCode[i] == code)
return i; return i;
} }
} }
mCount++; mCount++;
int index = mCurr++; int index = mCurr++;
if (mCurr >= mCacheSize) if (mCurr >= mCacheSize)
mCurr = 0; mCurr = 0;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
int x = 0; int x = 0;
int y = 0; int y = 0;
@@ -206,14 +206,14 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
if (isChinese) if (isChinese)
{ {
src = mChnFont + code * mBytesPerChar; src = mChnFont + code * mBytesPerChar;
for (int i=0;i<mBytesPerChar;) for (int i=0;i<mBytesPerChar;)
{ {
bitCount = mFontSize; bitCount = mFontSize;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
x = 0; x = 0;
#else #else
x = (int)mSprites[index]->mX; x = (int)mSprites[index]->mX;
@@ -225,7 +225,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
BYTE bitMask = 0x80; BYTE bitMask = 0x80;
for (int z=0;z<8&&bitCount;z++) for (int z=0;z<8&&bitCount;z++)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
if ((bits & bitMask) != 0) if ((bits & bitMask) != 0)
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255); mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
else else
@@ -240,9 +240,9 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
x++; x++;
bitCount--; bitCount--;
} }
} }
y++; y++;
} }
@@ -257,7 +257,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
for (int i=0;i<size;) for (int i=0;i<size;)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
x = 0; x = 0;
#else #else
x = (int)mSprites[index]->mX; x = (int)mSprites[index]->mX;
@@ -266,10 +266,10 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
// put char in the middle // put char in the middle
if (mFontSize <= 16) if (mFontSize <= 16)
{ {
for (n=0;n<(mFontSize-8)/2;n++) for (n=0;n<(mFontSize-8)/2;n++)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0); mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
#else #else
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight); 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; BYTE bitMask = 0x80;
for (int z=0;z<8&&bitCount;z++) for (int z=0;z<8&&bitCount;z++)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
if ((bits & bitMask) != 0) if ((bits & bitMask) != 0)
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255); mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
else 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); SwizzlePlot(pTexture, ARGB(255,255,255,255), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
else else
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight); SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight);
#endif #endif
x++; x++;
bitMask >>= 1; bitMask >>= 1;
bitCount--; bitCount--;
@@ -305,10 +305,10 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
if (mFontSize <= 16) if (mFontSize <= 16)
{ {
for (n=0;n<(mFontSize-8)/2;n++) for (n=0;n<(mFontSize-8)/2;n++)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0); mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
#else #else
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE, mCacheImageHeight); 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; mGBCode[index] = code;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
x = (int)mSprites[index]->mX; x = (int)mSprites[index]->mX;
y = (int)mSprites[index]->mY; y = (int)mSprites[index]->mY;
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer);
#else #else
sceKernelDcacheWritebackAll(); sceKernelDcacheWritebackAll();
//sceKernelDcacheWritebackInvalidateAll(); //sceKernelDcacheWritebackInvalidateAll();
@@ -383,7 +383,7 @@ void JGBKFont::RenderEncodedString(const int* text, int count, float x, float y)
} }
else if (text[n] == 0x8000d) else if (text[n] == 0x8000d)
{ {
} }
else else
{ {
@@ -441,7 +441,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
} }
src += 1; src += 1;
} }
else else
{ {
if (*src > 0x80) if (*src > 0x80)
{ {
@@ -467,7 +467,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
{ {
break; break;
} }
else else
{ {
if (*src < ' ') // control characters if (*src < ' ') // control characters
@@ -481,7 +481,7 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
} }
src += 1; src += 1;
} }
else else
{ {
if (*src > 0x80) if (*src > 0x80)
{ {
@@ -512,8 +512,8 @@ void JGBKFont::GetStringArea( BYTE* str, int *w, int *h)
yy += (mFontSize*mScale); yy += (mFontSize*mScale);
} }
} }
} }
} }
if (xx>len) if (xx>len)
{ {
@@ -528,7 +528,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
{ {
int w=0; int w=0;
int h=0; int h=0;
switch(alignment) switch(alignment)
{ {
case JGETEXT_RIGHT: case JGETEXT_RIGHT:
@@ -551,9 +551,9 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
float xx = x; float xx = x;
float yy = y; float yy = y;
int index; int index;
bool isChinese=true; bool isChinese=true;
while (*src != 0) while (*src != 0)
{ {
if (yy + mFontSize < 0.0f) // don't render when outside viewport 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; src += 1;
} }
else else
{ {
if (*src > 0x80) if (*src > 0x80)
{ {
@@ -591,7 +591,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
{ {
return; return;
} }
else else
{ {
if (*src < ' ') // control characters if (*src < ' ') // control characters
@@ -603,7 +603,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
} }
src += 1; src += 1;
} }
else else
{ {
if (*src > 0x80) if (*src > 0x80)
{ {
@@ -621,7 +621,7 @@ void JGBKFont::RenderString(BYTE* str, float x, float y, int alignment)
xx-=3*(mFontSize*mScale)/16; xx-=3*(mFontSize*mScale)/16;
isChinese = false; isChinese = false;
} }
mSprites[index]->SetColor(mColor); mSprites[index]->SetColor(mColor);
mRenderer->RenderQuad(mSprites[index], xx, yy, mRotation, mScale, mScale); mRenderer->RenderQuad(mSprites[index], xx, yy, mRotation, mScale, mScale);
if (mSmallEnglishFont && !isChinese) if (mSmallEnglishFont && !isChinese)

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include "../include/JGE.h" #include "../include/JGE.h"
@@ -19,16 +19,71 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#ifdef WIN32 #if defined (WIN32) // WIN32 specific code
#include "../../Dependencies/include/png.h" #include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.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() JGE::JGE()
{ {
mApp = NULL; mApp = NULL;
strcpy(mDebuggingMsg, ""); strcpy(mDebuggingMsg, "");
mCurrentMusic = NULL; mCurrentMusic = NULL;
Init(); Init();
@@ -54,25 +109,25 @@ JGE::~JGE()
// 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();
@@ -83,7 +138,7 @@ void JGE::Init()
void JGE::Run() void JGE::Run()
{ {
} }
void JGE::SetDelta(int delta) void JGE::SetDelta(int delta)
@@ -91,12 +146,6 @@ void JGE::SetDelta(int delta)
mDeltaTime = (float)delta / 1000.0f; // change to second mDeltaTime = (float)delta / 1000.0f; // change to second
} }
int JGE::GetTime(void)
{
return (int)GetTickCount();
}
float JGE::GetDelta() float JGE::GetDelta()
{ {
return mDeltaTime; 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 #else ///// PSP specified code
@@ -149,7 +181,7 @@ u8 JGE::GetAnalogY()
// include all the following so we only have one .o file // include all the following so we only have one .o file
//#include "../src/JGfx.cpp" //#include "../src/JGfx.cpp"
//#include "../src/JSfx.cpp" //#include "../src/JSfx.cpp"
@@ -193,7 +225,7 @@ JGE::~JGE()
void JGE::Init() void JGE::Init()
{ {
#ifdef DEBUG_PRINT #ifdef DEBUG_PRINT
mDebug = true; mDebug = true;
#else #else
mDebug = false; mDebug = false;
@@ -201,12 +233,12 @@ void JGE::Init()
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();
@@ -218,7 +250,7 @@ void JGE::Init()
//InitSfx(); //InitSfx();
//Create(); //Create();
// mCurrMS = 1.0f; // mCurrMS = 1.0f;
// mFPSSlice = 0; // mFPSSlice = 0;
@@ -228,9 +260,9 @@ void JGE::Init()
//mLastTime = GetTime(); //mLastTime = GetTime();
mTickFrequency = sceRtcGetTickResolution(); mTickFrequency = sceRtcGetTickResolution();
sceRtcGetCurrentTick(&mLastTime); sceRtcGetCurrentTick(&mLastTime);
} }
@@ -240,7 +272,7 @@ int JGE::GetTime(void)
u64 curr; u64 curr;
sceRtcGetCurrentTick(&curr); sceRtcGetCurrentTick(&curr);
return (int)(curr / mTickFrequency); return (int)(curr / mTickFrequency);
} }
@@ -257,28 +289,28 @@ float JGE::GetFPS()
} }
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;
} }
u8 JGE::GetAnalogX() u8 JGE::GetAnalogX()
{ {
return mCtrlPad.Lx; return mCtrlPad.Lx;
} }
u8 JGE::GetAnalogY() u8 JGE::GetAnalogY()
{ {
return mCtrlPad.Ly; return mCtrlPad.Ly;
} }
@@ -292,14 +324,14 @@ void JGE::Run()
if (!mPaused) if (!mPaused)
{ {
sceRtcGetCurrentTick(&curr); sceRtcGetCurrentTick(&curr);
mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f; mDelta = (curr-mLastTime) / (float)mTickFrequency;// * 1000.0f;
mLastTime = curr; mLastTime = curr;
sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
// because sceCtrlReadBufferPositive waits for vsync internally // because sceCtrlReadBufferPositive waits for vsync internally
Update(); Update();
Render(); Render();
@@ -314,13 +346,13 @@ void JGE::Run()
} }
mOldButtons = mCtrlPad.Buttons; mOldButtons = mCtrlPad.Buttons;
} }
} }
} }
#endif ///// PSP specified code #endif ///// PSP specified code
@@ -336,7 +368,7 @@ JGE* JGE::GetInstance()
{ {
mInstance = new JGE(); mInstance = new JGE();
} }
//gCount++; //gCount++;
return mInstance; return mInstance;
} }
@@ -388,7 +420,7 @@ void JGE::End()
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);

View File

@@ -3,9 +3,9 @@
// JGE is a hardware accelerated 2D game SDK for PSP/Windows. // JGE is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include <malloc.h> #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) void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
{ {
*x=mX; *y=mY; *w=mWidth; *h=mHeight; *x=mX; *y=mY; *w=mWidth; *h=mHeight;
} }
void JQuad::SetTextureRect(float x, float y, float w, float h) void JQuad::SetTextureRect(float x, float y, float w, float h)
{ {
mX = x; mY = y; mWidth = w; mHeight = h; mX = x; mY = y; mWidth = w; mHeight = h;
} }
@@ -147,7 +147,7 @@ JRenderer* JRenderer::GetInstance()
mInstance = new JRenderer(); mInstance = new JRenderer();
mInstance->InitRenderer(); mInstance->InitRenderer();
} }
return mInstance; return mInstance;
} }
@@ -169,13 +169,13 @@ JRenderer::JRenderer()
JRenderer::~JRenderer() JRenderer::~JRenderer()
{ {
} }
void JRenderer::ResetPrivateVRAM() void JRenderer::ResetPrivateVRAM()
{ {
//mCurrentPointer = mVideoBufferStart; //mCurrentPointer = mVideoBufferStart;
} }
@@ -195,11 +195,11 @@ void JRenderer::InitRenderer()
mSwizzle = 1; mSwizzle = 1;
mVsync = false; mVsync = false;
mTexCounter = 0; mTexCounter = 0;
mCurrentTex = -1; mCurrentTex = -1;
mCurrentBlend = -1; mCurrentBlend = -1;
mFOV = 75.0f; mFOV = 75.0f;
mImageFilter = NULL; mImageFilter = NULL;
@@ -227,7 +227,7 @@ void JRenderer::InitRenderer()
} }
//mCurrentPointer = mVideoBufferStart; //mCurrentPointer = mVideoBufferStart;
sceGuOffset(2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2)); sceGuOffset(2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2));
sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT); sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
@@ -235,15 +235,15 @@ void JRenderer::InitRenderer()
//sceGuFrontFace(GU_CW); //sceGuFrontFace(GU_CW);
sceGuFrontFace(GU_CCW); sceGuFrontFace(GU_CCW);
sceGuEnable(GU_TEXTURE_2D); sceGuEnable(GU_TEXTURE_2D);
sceGuShadeModel(GU_SMOOTH); sceGuShadeModel(GU_SMOOTH);
sceGuTexWrap(GU_REPEAT, GU_REPEAT); sceGuTexWrap(GU_REPEAT, GU_REPEAT);
// enable alpha channel // enable alpha channel
sceGuEnable(GU_BLEND); sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuTexFilter(GU_LINEAR,GU_LINEAR); sceGuTexFilter(GU_LINEAR,GU_LINEAR);
if (m3DEnabled) if (m3DEnabled)
@@ -260,7 +260,7 @@ void JRenderer::InitRenderer()
sceGuClearDepth(0); sceGuClearDepth(0);
sceGuTexEnvColor(0xffffffff); sceGuTexEnvColor(0xffffffff);
sceGuTexScale(1.0f,1.0f); sceGuTexScale(1.0f,1.0f);
sceGuTexOffset(0.0f,0.0f); sceGuTexOffset(0.0f,0.0f);
sceGuAmbientColor(0xffffffff); sceGuAmbientColor(0xffffffff);
@@ -288,7 +288,7 @@ void JRenderer::SetTexBlend(int src, int dest)
{ {
mCurrTexBlendSrc = src; mCurrTexBlendSrc = src;
mCurrTexBlendDest = dest; mCurrTexBlendDest = dest;
int fixSrc = 0; int fixSrc = 0;
int fixDest = 0; int fixDest = 0;
if (src == BLEND_ZERO) if (src == BLEND_ZERO)
@@ -305,7 +305,7 @@ void JRenderer::SetTexBlend(int src, int dest)
dest = GU_FIX; dest = GU_FIX;
fixDest = 0x00FFFFFF; fixDest = 0x00FFFFFF;
} }
//glBlendFunc(src, dest); //glBlendFunc(src, dest);
sceGuBlendFunc(GU_ADD, src, dest, fixSrc, fixDest); sceGuBlendFunc(GU_ADD, src, dest, fixSrc, fixDest);
} }
@@ -343,9 +343,9 @@ void JRenderer::BeginScene()
//if (mMode3D) //if (mMode3D)
sceGuClear(GU_DEPTH_BUFFER_BIT|GU_COLOR_BUFFER_BIT); 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) if (mCurrentTextureFilter == TEX_FILTER_NEAREST)
sceGuTexFilter(GU_NEAREST, GU_NEAREST); // GU_NEAREST good for tile-map sceGuTexFilter(GU_NEAREST, GU_NEAREST); // GU_NEAREST good for tile-map
@@ -362,7 +362,7 @@ void JRenderer::EndScene()
if (mVsync) if (mVsync)
sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart();
sceGuSwapBuffers(); sceGuSwapBuffers();
mCurrentTex = -1; mCurrentTex = -1;
@@ -371,8 +371,8 @@ void JRenderer::EndScene()
void JRenderer::EnableVSync(bool flag) 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)); struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(2 * sizeof(struct VertexColor));
vertices[0].color = color; vertices[0].color = color;
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[1].color = color; vertices[1].color = color;
vertices[1].x = x + width; vertices[1].x = x + width;
vertices[1].y = y + height; vertices[1].y = y + height;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
sceGuDisable(GU_TEXTURE_2D); 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].color = colors[0];
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[1].color = colors[1]; vertices[1].color = colors[1];
vertices[1].x = x + width; vertices[1].x = x + width;
vertices[1].y = y; vertices[1].y = y;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
vertices[2].color = colors[2]; vertices[2].color = colors[2];
vertices[2].x = x; vertices[2].x = x;
vertices[2].y = y + height; vertices[2].y = y + height;
vertices[2].z = 0.0f; vertices[2].z = 0.0f;
vertices[3].color = colors[3]; vertices[3].color = colors[3];
vertices[3].x = x + width; vertices[3].x = x + width;
vertices[3].y = y + height; vertices[3].y = y + height;
vertices[3].z = 0.0f; vertices[3].z = 0.0f;
/* /*
vertices[0].color = colors[0]; vertices[0].color = colors[0];
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[1].color = colors[1]; vertices[1].color = colors[1];
vertices[1].x = x; vertices[1].x = x;
vertices[1].y = y + height; vertices[1].y = y + height;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
vertices[2].color = colors[2]; vertices[2].color = colors[2];
vertices[2].x = x + width; vertices[2].x = x + width;
vertices[2].y = y + height; vertices[2].y = y + height;
vertices[2].z = 0.0f; vertices[2].z = 0.0f;
vertices[3].color = colors[3]; vertices[3].color = colors[3];
vertices[3].x = x + width; vertices[3].x = x + width;
vertices[3].y = y; vertices[3].y = y;
vertices[3].z = 0.0f; vertices[3].z = 0.0f;
*/ */
sceGuDisable(GU_TEXTURE_2D); 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)); struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(5 * sizeof(struct VertexColor));
vertices[0].color = color; vertices[0].color = color;
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[1].color = color; vertices[1].color = color;
vertices[1].x = x; vertices[1].x = x;
vertices[1].y = y + height; vertices[1].y = y + height;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
vertices[2].color = color; vertices[2].color = color;
vertices[2].x = x + width; vertices[2].x = x + width;
vertices[2].y = y + height; vertices[2].y = y + height;
vertices[2].z = 0.0f; vertices[2].z = 0.0f;
vertices[3].color = color; vertices[3].color = color;
vertices[3].x = x + width; vertices[3].x = x + width;
vertices[3].y = y; vertices[3].y = y;
vertices[3].z = 0.0f; vertices[3].z = 0.0f;
vertices[4].color = color; vertices[4].color = color;
vertices[4].x = x; vertices[4].x = x;
vertices[4].y = y; vertices[4].y = y;
vertices[4].z = 0.0f; vertices[4].z = 0.0f;
sceGuDisable(GU_TEXTURE_2D); 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)); struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(2 * sizeof(struct VertexColor));
vertices[0].color = color; vertices[0].color = color;
vertices[0].x = x1; vertices[0].x = x1;
vertices[0].y = y1; vertices[0].y = y1;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[1].color = color; vertices[1].color = color;
vertices[1].x = x2; vertices[1].x = x2;
vertices[1].y = y2; vertices[1].y = y2;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
sceGuDisable(GU_TEXTURE_2D); 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)); struct VertexColor* vertices = (struct VertexColor*)sceGuGetMemory(1 * sizeof(struct VertexColor));
vertices[0].color = color; vertices[0].color = color;
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
sceGuDisable(GU_TEXTURE_2D); 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++) for (int i=0;i<count;i++)
{ {
vertices[i].color = color; vertices[i].color = color;
vertices[i].x = x[i]; vertices[i].x = x[i];
vertices[i].y = y[i]; vertices[i].y = y[i];
vertices[i].z = 0.0f; 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) if (mCurrentBlend != quad->mBlend)
{ {
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA); sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
mCurrentBlend = quad->mBlend; 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) if (quad->mHFlipped)// || quad->mVFlipped)
{ {
for (end = quad->mX, start = quad->mX+quad->mWidth; start > end; start -= SLICE_SIZE_F) 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 // 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; destWidth = width*xScale;
} }
vertices[0].u = start; vertices[0].u = start;
vertices[0].v = quad->mY; vertices[0].v = quad->mY;
vertices[0].color = quad->mColor[0];//.color; vertices[0].color = quad->mColor[0];//.color;
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[2].u = start - width; vertices[2].u = start - width;
vertices[2].v = quad->mY; vertices[2].v = quad->mY;
vertices[2].color = quad->mColor[2];//.color; vertices[2].color = quad->mColor[2];//.color;
vertices[2].x = x + destWidth; vertices[2].x = x + destWidth;
vertices[2].y = y; vertices[2].y = y;
vertices[2].z = 0.0f; vertices[2].z = 0.0f;
vertices[1].u = start; vertices[1].u = start;
vertices[1].v = quad->mY + quad->mHeight; vertices[1].v = quad->mY + quad->mHeight;
vertices[1].color = quad->mColor[1];//.color; vertices[1].color = quad->mColor[1];//.color;
vertices[1].x = x; vertices[1].x = x;
vertices[1].y = y + destHeight; vertices[1].y = y + destHeight;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
vertices[3].u = start - width; vertices[3].u = start - width;
vertices[3].v = quad->mY + quad->mHeight; vertices[3].v = quad->mY + quad->mHeight;
vertices[3].color = quad->mColor[3];//.color; vertices[3].color = quad->mColor[3];//.color;
vertices[3].x = x + destWidth; vertices[3].x = x + destWidth;
vertices[3].y = y + destHeight; vertices[3].y = y + destHeight;
vertices[3].z = 0.0f; vertices[3].z = 0.0f;
if (quad->mVFlipped) 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++) for (int i=0;i<4;i++)
{ {
xx = (cosAngle*(vertices[i].x-xo) - sinAngle*(vertices[i].y-yo) + xo); 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].x = xx;
vertices[i].y = yy; vertices[i].y = yy;
} }
@@ -684,32 +684,32 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
destWidth = width*xScale; destWidth = width*xScale;
} }
vertices[0].u = start; vertices[0].u = start;
vertices[0].v = quad->mY; vertices[0].v = quad->mY;
vertices[0].color = quad->mColor[0];//.color; vertices[0].color = quad->mColor[0];//.color;
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].z = 0.0f; vertices[0].z = 0.0f;
vertices[2].u = start + width; vertices[2].u = start + width;
vertices[2].v = quad->mY; vertices[2].v = quad->mY;
vertices[2].color = quad->mColor[2];//.color; vertices[2].color = quad->mColor[2];//.color;
vertices[2].x = x + destWidth; vertices[2].x = x + destWidth;
vertices[2].y = y; vertices[2].y = y;
vertices[2].z = 0.0f; vertices[2].z = 0.0f;
vertices[1].u = start; vertices[1].u = start;
vertices[1].v = quad->mY + quad->mHeight; vertices[1].v = quad->mY + quad->mHeight;
vertices[1].color = quad->mColor[1];//.color; vertices[1].color = quad->mColor[1];//.color;
vertices[1].x = x; vertices[1].x = x;
vertices[1].y = y + destHeight; vertices[1].y = y + destHeight;
vertices[1].z = 0.0f; vertices[1].z = 0.0f;
vertices[3].u = start + width; vertices[3].u = start + width;
vertices[3].v = quad->mY + quad->mHeight; vertices[3].v = quad->mY + quad->mHeight;
vertices[3].color = quad->mColor[3];//.color; vertices[3].color = quad->mColor[3];//.color;
vertices[3].x = x + destWidth; vertices[3].x = x + destWidth;
vertices[3].y = y + destHeight; vertices[3].y = y + destHeight;
vertices[3].z = 0.0f; vertices[3].z = 0.0f;
if (quad->mVFlipped) 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[0].v, &vertices[2].v);
Swap(&vertices[1].v, &vertices[3].v); Swap(&vertices[1].v, &vertices[3].v);
} }
if (angle != 0.0f) if (angle != 0.0f)
{ {
for (int i=0;i<4;i++) for (int i=0;i<4;i++)
{ {
xx = (cosAngle*(vertices[i].x-xo) - sinAngle*(vertices[i].y-yo) + xo); 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].x = xx;
vertices[i].y = yy; vertices[i].y = yy;
} }
@@ -747,7 +747,7 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
if (mCurrentBlend != quad->mBlend) if (mCurrentBlend != quad->mBlend)
{ {
sceGuTexFunc(quad->mBlend, GU_TCC_RGBA); sceGuTexFunc(quad->mBlend, GU_TCC_RGBA);
mCurrentBlend = quad->mBlend; mCurrentBlend = quad->mBlend;
} }
@@ -755,49 +755,49 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
// in order to rotate, we use 4 vertices this time // in order to rotate, we use 4 vertices this time
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(4 * sizeof(struct Vertex)); 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[0].v = quad->mY;
vertices[1].u = quad->mX; vertices[1].u = quad->mX;
vertices[1].v = quad->mY + quad->mHeight; 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[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; vertices[3].v = quad->mY + quad->mHeight;
// for (int i=0;i<4;i++) // for (int i=0;i<4;i++)
// { // {
// vertices[i].color = points[i].color; // vertices[i].color = points[i].color;
// vertices[i].x = points[i].x; // vertices[i].x = points[i].x;
// vertices[i].y = points[i].y; // vertices[i].y = points[i].y;
// vertices[i].z = points[i].z; // vertices[i].z = points[i].z;
// } // }
vertices[0].color = points[3].color; vertices[0].color = points[3].color;
vertices[0].x = points[3].x; vertices[0].x = points[3].x;
vertices[0].y = points[3].y; vertices[0].y = points[3].y;
vertices[0].z = points[3].z; vertices[0].z = points[3].z;
vertices[1].color = points[0].color; vertices[1].color = points[0].color;
vertices[1].x = points[0].x; vertices[1].x = points[0].x;
vertices[1].y = points[0].y; vertices[1].y = points[0].y;
vertices[1].z = points[0].z; vertices[1].z = points[0].z;
vertices[2].color = points[2].color; vertices[2].color = points[2].color;
vertices[2].x = points[2].x; vertices[2].x = points[2].x;
vertices[2].y = points[2].y; vertices[2].y = points[2].y;
vertices[2].z = points[2].z; vertices[2].z = points[2].z;
vertices[3].color = points[1].color; vertices[3].color = points[1].color;
vertices[3].x = points[1].x; vertices[3].x = points[1].x;
vertices[3].y = points[1].y; vertices[3].y = points[1].y;
vertices[3].z = points[1].z; 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); 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; png_infop info_ptr;
FILE* fp; FILE* fp;
u8* line; u8* line;
fp = fopen(filename, "wb"); fp = fopen(filename, "wb");
if (!fp) return; if (!fp) return;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 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) { switch (pixelformat) {
case PSP_DISPLAY_PIXEL_FORMAT_565: case PSP_DISPLAY_PIXEL_FORMAT_565:
color = vram16[x + y * bufferwidth]; color = vram16[x + y * bufferwidth];
r = (color & 0x1f) << 3; r = (color & 0x1f) << 3;
g = ((color >> 5) & 0x3f) << 2 ; g = ((color >> 5) & 0x3f) << 2 ;
b = ((color >> 11) & 0x1f) << 3 ; b = ((color >> 11) & 0x1f) << 3 ;
break; break;
case PSP_DISPLAY_PIXEL_FORMAT_5551: case PSP_DISPLAY_PIXEL_FORMAT_5551:
color = vram16[x + y * bufferwidth]; color = vram16[x + y * bufferwidth];
r = (color & 0x1f) << 3; r = (color & 0x1f) << 3;
g = ((color >> 5) & 0x1f) << 3 ; g = ((color >> 5) & 0x1f) << 3 ;
b = ((color >> 10) & 0x1f) << 3 ; b = ((color >> 10) & 0x1f) << 3 ;
break; break;
case PSP_DISPLAY_PIXEL_FORMAT_4444: case PSP_DISPLAY_PIXEL_FORMAT_4444:
color = vram16[x + y * bufferwidth]; color = vram16[x + y * bufferwidth];
r = (color & 0xf) << 4; r = (color & 0xf) << 4;
g = ((color >> 4) & 0xf) << 4 ; g = ((color >> 4) & 0xf) << 4 ;
b = ((color >> 8) & 0xf) << 4 ; b = ((color >> 8) & 0xf) << 4 ;
break; break;
case PSP_DISPLAY_PIXEL_FORMAT_8888: case PSP_DISPLAY_PIXEL_FORMAT_8888:
color = vram32[x + y * bufferwidth]; color = vram32[x + y * bufferwidth];
r = color & 0xff; r = color & 0xff;
g = (color >> 8) & 0xff; g = (color >> 8) & 0xff;
b = (color >> 16) & 0xff; b = (color >> 16) & 0xff;
break; 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 blockx, blocky;
unsigned int j; unsigned int j;
unsigned int width_blocks = (width / 16); unsigned int width_blocks = (width / 16);
unsigned int height_blocks = (height / 8); unsigned int height_blocks = (height / 8);
unsigned int src_pitch = (width-16)/4; unsigned int src_pitch = (width-16)/4;
unsigned int src_row = width * 8; unsigned int src_row = width * 8;
const u8* ysrc = in; const u8* ysrc = in;
u32* dst = (u32*)out; u32* dst = (u32*)out;
for (blocky = 0; blocky < height_blocks; ++blocky) for (blocky = 0; blocky < height_blocks; ++blocky)
{ {
const u8* xsrc = ysrc; const u8* xsrc = ysrc;
@@ -1110,7 +1110,7 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
textureInfo.mBits = (u8 *)bits; textureInfo.mBits = (u8 *)bits;
textureInfo.mWidth = cinfo.output_width; textureInfo.mWidth = cinfo.output_width;
textureInfo.mHeight = cinfo.output_height; textureInfo.mHeight = cinfo.output_height;
textureInfo.mTexWidth = tw; textureInfo.mTexWidth = tw;
textureInfo.mTexHeight = th; textureInfo.mTexHeight = th;
@@ -1126,7 +1126,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
TextureInfo textureInfo; TextureInfo textureInfo;
textureInfo.mVRAM = false; textureInfo.mVRAM = false;
textureInfo.mBits = NULL; textureInfo.mBits = NULL;
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL) if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
LoadJPG(textureInfo, filename, mode); LoadJPG(textureInfo, filename, mode);
else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL) else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL)
@@ -1134,7 +1134,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
else else
LoadPNG(textureInfo, filename, mode); LoadPNG(textureInfo, filename, mode);
if (textureInfo.mBits == NULL) if (textureInfo.mBits == NULL)
return NULL; return NULL;
@@ -1192,7 +1192,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename)) return; if (!fileSystem->OpenFile(filename)) return;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) { if (png_ptr == NULL) {
//fclose(fp); //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); png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return; return;
} }
int texWidth = getNextPower2(width); int texWidth = getNextPower2(width);
int texHeight = getNextPower2(height); 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); int size = texWidth * texHeight * sizeof(PIXEL_TYPE);
{ {
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000) if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
{ {
//bits = (PIXEL_TYPE*) (0x04000000+0x40000000+mCurrentPointer); //bits = (PIXEL_TYPE*) (0x04000000+0x40000000+mCurrentPointer);
@@ -1251,7 +1251,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
videoRAMUsed = false; videoRAMUsed = false;
bits = (PIXEL_TYPE*) memalign(16, size); bits = (PIXEL_TYPE*) memalign(16, size);
} }
PIXEL_TYPE* buffer = bits; PIXEL_TYPE* buffer = bits;
if (mSwizzle) if (mSwizzle)
@@ -1262,10 +1262,10 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
p32 = (u32*) buffer; p32 = (u32*) buffer;
p16 = (u16*) p32; 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); 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]; u32 color32 = line[x];
u16 color16; u16 color16;
@@ -1309,9 +1309,9 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
free (line); free (line);
png_read_end(png_ptr, info_ptr); png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fileSystem->CloseFile(); fileSystem->CloseFile();
if (done) if (done)
{ {
textureInfo.mBits = (u8 *)bits; textureInfo.mBits = (u8 *)bits;
@@ -1321,7 +1321,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
textureInfo.mTexHeight = texHeight; textureInfo.mTexHeight = texHeight;
textureInfo.mVRAM = videoRAMUsed; textureInfo.mVRAM = videoRAMUsed;
} }
else else
{ {
@@ -1375,7 +1375,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
switch (RecordType) { switch (RecordType) {
case IMAGE_DESC_RECORD_TYPE: case IMAGE_DESC_RECORD_TYPE:
{ {
if (DGifGetImageDesc(GifFileIn) == GIF_ERROR) if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)
{ {
DGifCloseFile(GifFileIn); DGifCloseFile(GifFileIn);
@@ -1401,7 +1401,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
bool done = false; bool done = false;
PIXEL_TYPE* bits = NULL; PIXEL_TYPE* bits = NULL;
size = textureInfo.mTexWidth * textureInfo.mTexHeight * sizeof(PIXEL_TYPE); size = textureInfo.mTexWidth * textureInfo.mTexHeight * sizeof(PIXEL_TYPE);
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000) if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
@@ -1440,7 +1440,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
DWORD * curr = p32; DWORD * curr = p32;
DWORD * imgdata = p32; DWORD * imgdata = p32;
for (i = 0; i < GifFileIn->Image.Height; i ++) for (i = 0; i < GifFileIn->Image.Height; i ++)
{ {
imgdata = curr; imgdata = curr;
if (DGifGetLine(GifFileIn, LineIn, GifFileIn->Image.Width) == GIF_ERROR) 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"); //FILE * fp = fopen(filename, "rb");
//if(fp == NULL) //if(fp == NULL)
// return; // return;
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(filename)) if (!fileSys->OpenFile(filename))
return; return;
@@ -1592,7 +1592,7 @@ JTexture* JRenderer::CreateTexture(int width, int height, int mode)
tex->mTexWidth = getNextPower2(width); tex->mTexWidth = getNextPower2(width);
tex->mTexHeight = getNextPower2(height); tex->mTexHeight = getNextPower2(height);
int size = tex->mTexWidth * tex->mTexHeight * sizeof(PIXEL_TYPE); int size = tex->mTexWidth * tex->mTexHeight * sizeof(PIXEL_TYPE);
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000) if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
{ {
@@ -1623,7 +1623,7 @@ JTexture* JRenderer::CreateTexture(int width, int height, int mode)
// { // {
// if (tex->mBits && !tex->mInVideoRAM) // if (tex->mBits && !tex->mInVideoRAM)
// free(tex->mBits); // free(tex->mBits);
// //
// delete tex; // delete tex;
// tex = NULL; // 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(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); 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; angle = 0;
} }
y+=h; y+=h;
for(int i=90; i<135; i++) for(int i=90; i<135; i++)
{ {
vertices[i+1].color = color; vertices[i+1].color = color;

View File

@@ -25,10 +25,10 @@ JGuiObject::JGuiObject(int id): mId(id)
JGuiObject::~JGuiObject() JGuiObject::~JGuiObject()
{ {
// JGERelease(); // JGERelease();
}; }
bool JGuiObject::Leaving(u32 key) bool JGuiObject::Leaving(u32 key __attribute__((unused)))
{ {
return true; return true;
} }
@@ -52,7 +52,7 @@ int JGuiObject::GetId()
} }
void JGuiObject::Update(float dt) void JGuiObject::Update(float dt __attribute__((unused)))
{ {
} }

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 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) JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
{ {
mRenderer = JRenderer::GetInstance(); mRenderer = JRenderer::GetInstance();
mHeight = 0; mHeight = 0;
mScale = 1.0f; mScale = 1.0f;
mRotation = mSpacing = 0.0f; mRotation = mSpacing = 0.0f;
@@ -33,27 +33,27 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
mTexture = NULL; mTexture = NULL;
mQuad = NULL; mQuad = NULL;
mBase = 0; mBase = 0;
char filename[256]; char filename[256];
short buffer[1024]; short buffer[1024];
sprintf(filename, "%s.dat", fontname); sprintf(filename, "%s.dat", fontname);
//FILE *file; //FILE *file;
JFileSystem *fileSys = JFileSystem::GetInstance(); JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(filename)) return; if (!fileSys->OpenFile(filename)) return;
fileSys->ReadFile((u8 *)buffer, 2048); fileSys->ReadFile((u8 *)buffer, 2048);
fileSys->CloseFile(); fileSys->CloseFile();
sprintf(filename, "%s.png", fontname); sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM); mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
if (mTexture == NULL) return; if (mTexture == NULL) return;
mHeight = (float) lineheight; mHeight = (float) lineheight;
mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f, mHeight); mQuad = new JQuad(mTexture, 0.0f, 0.0f, 16.0f, mHeight);
float a, b, c; 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. // there are 16x16 characters in the texture map.
float cellHeight = mTexture->mHeight/16.0f; float cellHeight = mTexture->mHeight/16.0f;
int n = 0; int n = 0;
for (int i=0;i<16;i++) 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 a = (float)buffer[n*4+1]; // character width
b = (float)buffer[n*4+2]; b = (float)buffer[n*4+2];
c = (float)buffer[n*4+3]; c = (float)buffer[n*4+3];
mXPos[n] = x; mXPos[n] = x;
mYPos[n] = y; mYPos[n] = y;
mCharWidth[n] = a+b+c; mCharWidth[n] = a+b+c;
@@ -83,18 +83,18 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
y += cellHeight; y += cellHeight;
} }
} }
JLBFont::~JLBFont() JLBFont::~JLBFont()
{ {
if (mQuad) if (mQuad)
delete mQuad; delete mQuad;
if (mTexture) if (mTexture)
delete mTexture; delete mTexture;
// JGERelease(); // JGERelease();
} }
@@ -105,9 +105,9 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
float dx = x, dy = y; float dx = x, dy = y;
if (mQuad == NULL) return; if (mQuad == NULL) return;
float width = GetStringWidth(string); float width = GetStringWidth(string);
if (align == JGETEXT_RIGHT) if (align == JGETEXT_RIGHT)
dx -= width; dx -= width;
else if (align == JGETEXT_CENTER) else if (align == JGETEXT_CENTER)
@@ -123,7 +123,7 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
p++; p++;
} }
} }
@@ -131,11 +131,11 @@ void JLBFont::printf(float x, float y, const char *format, ...)
{ {
char buffer[PRINTF_BUFFER_SIZE]; char buffer[PRINTF_BUFFER_SIZE];
va_list list; va_list list;
va_start(list, format); va_start(list, format);
vsprintf(buffer, format, list); vsprintf(buffer, format, list);
va_end(list); va_end(list);
DrawString(buffer, x, y); DrawString(buffer, x, y);
} }
@@ -151,10 +151,10 @@ void JLBFont::SetColor(PIXEL_TYPE color)
float JLBFont::GetStringWidth(const char *string) const float JLBFont::GetStringWidth(const char *string) const
{ {
float len = 0.0f; float len = 0.0f;
const char *p = string; const char *p = string;
char ch; char ch;
while (*p) while (*p)
{ {
ch = *p - 32; ch = *p - 32;
@@ -162,7 +162,7 @@ float JLBFont::GetStringWidth(const char *string) const
if (ch < 0) continue; if (ch < 0) continue;
len += mCharWidth[ch+mBase]; len += mCharWidth[ch+mBase];
} }
return len*mScale; return len*mScale;
} }
@@ -175,7 +175,7 @@ float JLBFont::GetRotation() const { return mRotation; }
float JLBFont::GetTracking() const { return mTracking; } float JLBFont::GetTracking() const { return mTracking; }
float JLBFont::GetHeight() const { return mHeight; } float JLBFont::GetHeight() const { return mHeight; }
void JLBFont::SetBase(int base) void JLBFont::SetBase(int base)
{ {
mBase = (base==0)?0:128; mBase = (base==0)?0:128;
} }

View File

@@ -219,7 +219,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
// given 3 points, calculates the normal to the points // 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) void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3)
#else #else
void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, float *p3) 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 // calculate the length of the normal
length = (float)sqrt(result[0]*result[0] + result[1]*result[1] + result[2]*result[2]); 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 // normalize and specify the normal
glNormal3f(result[0]/length, result[1]/length, result[2]/length); glNormal3f(result[0]/length, result[1]/length, result[2]/length);
@@ -273,7 +273,7 @@ void JMD2Model::Render(int frameNum)
mRenderer->BindTexture(mModel->modelTex); mRenderer->BindTexture(mModel->modelTex);
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
// display the textured model with proper lighting normals // display the textured model with proper lighting normals
@@ -465,7 +465,7 @@ void JMD2Model::Render()
mRenderer->BindTexture(mModel->modelTex); mRenderer->BindTexture(mModel->modelTex);
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);

View File

@@ -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') while (start < size && buffer[start] != '\n' && buffer[start] != '\r')
output[index++] = buffer[start++]; output[index++] = buffer[start++];
while (start < size && buffer[start] == '\n' || buffer[start] == '\r') while ((start < size && buffer[start] == '\n') || buffer[start] == '\r')
start++; start++;
output[index] = 0; output[index] = 0;

View File

@@ -90,7 +90,7 @@ bool JParticleEffect::Load(const char* filename)
// FIELD_COUNT // FIELD_COUNT
// }; // };
char* lifeValues[] = const char* lifeValues[] =
{ {
"speed", "speed",
"size", "size",
@@ -104,7 +104,7 @@ bool JParticleEffect::Load(const char* filename)
"gravity" "gravity"
}; };
char* typeNames[] = const char* typeNames[] =
{ {
"POINT", "POINT",
"AREA", "AREA",
@@ -113,7 +113,7 @@ bool JParticleEffect::Load(const char* filename)
"CIRCLE" "CIRCLE"
}; };
char* modeNames[] = const char* modeNames[] =
{ {
"REPEAT", "REPEAT",
"ONCE", "ONCE",
@@ -121,8 +121,6 @@ bool JParticleEffect::Load(const char* filename)
"CONTINUOUS" "CONTINUOUS"
}; };
int i;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// One effect per file only, well, we may extend it later to permit // One effect per file only, well, we may extend it later to permit
// multiple effect definitions: // multiple effect definitions:
@@ -159,7 +157,7 @@ bool JParticleEffect::Load(const char* filename)
else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0) else if (strcmp(element->Attribute("blend"), "ADDITIVE")==0)
mParticleEmitters[mEmitterCount]->SetBlending(BLEND_SRC_ALPHA, BLEND_ONE); 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) if (strcmp(element->Attribute("mode"), modeNames[i])==0)
{ {
@@ -170,7 +168,7 @@ bool JParticleEffect::Load(const char* filename)
break; 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) if (strcmp(element->Attribute("type"), typeNames[i])==0)
{ {

View File

@@ -109,7 +109,7 @@ void JParticleEmitter::SetQuad(JQuad *quad)
void JParticleEmitter::Update(float dt) void JParticleEmitter::Update(float dt)
{ {
JParticleSystem* particleSys = mParent->GetParticleSystem(); // JParticleSystem* particleSys = mParent->GetParticleSystem();
mActiveParticleCount = 0; mActiveParticleCount = 0;
@@ -185,7 +185,7 @@ void JParticleEmitter::Update(float dt)
void JParticleEmitter::EmitParticles(int count) void JParticleEmitter::EmitParticles(int count)
{ {
JParticleSystem* particleSys = mParent->GetParticleSystem(); // JParticleSystem* particleSys = mParent->GetParticleSystem();
JParticleData *dataPtr; JParticleData *dataPtr;
JParticle* particle; JParticle* particle;

View File

@@ -3,9 +3,9 @@
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows. // JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
// //
// Licensed under the BSD license, see LICENSE in JGE root for details. // 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 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include "../include/JGE.h" #include "../include/JGE.h"
@@ -18,7 +18,7 @@
JResourceManager::JResourceManager() JResourceManager::JResourceManager()
{ {
//mResourceRoot = "Res/"; // default root folder //mResourceRoot = "Res/"; // default root folder
mTextureList.clear(); mTextureList.clear();
mTextureList.reserve(16); mTextureList.reserve(16);
@@ -43,7 +43,7 @@ JResourceManager::JResourceManager()
// mParticleEffectList.clear(); // mParticleEffectList.clear();
// mParticleEffectList.reserve(8); // mParticleEffectList.reserve(8);
// mParticleEffectMap.clear(); // mParticleEffectMap.clear();
// //
// mMotionEmitterList.clear(); // mMotionEmitterList.clear();
// mMotionEmitterList.reserve(16); // mMotionEmitterList.reserve(16);
// mMotionEmitterMap.clear(); // mMotionEmitterMap.clear();
@@ -52,7 +52,7 @@ JResourceManager::JResourceManager()
JResourceManager::~JResourceManager() JResourceManager::~JResourceManager()
{ {
RemoveAll(); RemoveAll();
} }
@@ -91,13 +91,13 @@ void JResourceManager::RemoveAll()
// for (vector<JParticleEffect *>::iterator effect = mParticleEffectList.begin(); effect != mParticleEffectList.end(); ++effect) // for (vector<JParticleEffect *>::iterator effect = mParticleEffectList.begin(); effect != mParticleEffectList.end(); ++effect)
// delete *effect; // delete *effect;
// //
// mParticleEffectList.clear(); // mParticleEffectList.clear();
// mParticleEffectMap.clear(); // mParticleEffectMap.clear();
// //
// for (vector<JMotionEmitter *>::iterator emitter = mMotionEmitterList.begin(); emitter != mMotionEmitterList.end(); ++emitter) // for (vector<JMotionEmitter *>::iterator emitter = mMotionEmitterList.begin(); emitter != mMotionEmitterList.end(); ++emitter)
// delete *emitter; // delete *emitter;
// //
// mMotionEmitterList.clear(); // mMotionEmitterList.clear();
// mMotionEmitterMap.clear(); // mMotionEmitterMap.clear();
@@ -109,7 +109,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
string path = /*mResourceRoot + */resourceName; string path = /*mResourceRoot + */resourceName;
// TiXmlDocument doc(path.c_str()); // TiXmlDocument doc(path.c_str());
// //
// if (!doc.LoadFile()) return false; // if (!doc.LoadFile()) return false;
@@ -135,7 +135,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
TiXmlNode* node = 0; TiXmlNode* node = 0;
TiXmlElement* element = 0; TiXmlElement* element = 0;
resource = doc.FirstChild("resource"); resource = doc.FirstChild("resource");
if (resource) if (resource)
{ {
element = resource->ToElement(); element = resource->ToElement();
@@ -161,10 +161,10 @@ bool JResourceManager::LoadResource(const string& resourceName)
float value; float value;
float hotspotX = 0.0f; float hotspotX = 0.0f;
float hotspotY = 0.0f; float hotspotY = 0.0f;
if (element->QueryFloatAttribute("x", &value) == TIXML_SUCCESS) if (element->QueryFloatAttribute("x", &value) == TIXML_SUCCESS)
x = value; x = value;
if (element->QueryFloatAttribute("y", &value) == TIXML_SUCCESS) if (element->QueryFloatAttribute("y", &value) == TIXML_SUCCESS)
y = value; y = value;
@@ -192,10 +192,10 @@ bool JResourceManager::LoadResource(const string& resourceName)
// if (element->QueryFloatAttribute("regx", &value) == TIXML_SUCCESS) // if (element->QueryFloatAttribute("regx", &value) == TIXML_SUCCESS)
// hotspotX = width/2; // hotspotX = width/2;
// //
// if (element->QueryFloatAttribute("regy", &value) == TIXML_SUCCESS) // if (element->QueryFloatAttribute("regy", &value) == TIXML_SUCCESS)
// hotspotY = height/2; // hotspotY = height/2;
int id = CreateQuad(quadName, textureName, x, y, width, height); int id = CreateQuad(quadName, textureName, x, y, width, height);
if (id != INVALID_ID) if (id != INVALID_ID)
{ {
@@ -223,9 +223,9 @@ bool JResourceManager::LoadResource(const string& resourceName)
// } // }
} }
} }
} }
fileSystem->CloseFile(); fileSystem->CloseFile();
delete[] xmlBuffer; delete[] xmlBuffer;
// JGERelease(); // JGERelease();
@@ -243,7 +243,7 @@ int JResourceManager::CreateTexture(const string &textureName)
string path = /*mResourceRoot + */textureName; string path = /*mResourceRoot + */textureName;
printf("creating texture:%s\n", path.c_str()); printf("creating texture:%s\n", path.c_str());
JTexture *tex = JRenderer::GetInstance()->LoadTexture(path.c_str()); JTexture *tex = JRenderer::GetInstance()->LoadTexture(path.c_str());
if (tex == NULL) if (tex == NULL)
@@ -252,7 +252,7 @@ int JResourceManager::CreateTexture(const string &textureName)
int id = mTextureList.size(); int id = mTextureList.size();
mTextureList.push_back(tex); mTextureList.push_back(tex);
mTextureMap[textureName] = id; mTextureMap[textureName] = id;
return id; return id;
} }
else else
@@ -286,7 +286,7 @@ int JResourceManager::CreateQuad(const string &quadName, const string &textureNa
if (itr == mQuadMap.end()) if (itr == mQuadMap.end())
{ {
JTexture *tex = GetTexture(textureName); JTexture *tex = GetTexture(textureName);
if (tex == NULL) if (tex == NULL)
{ {
int texId = CreateTexture(textureName); // load texture if necessary 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)); mQuadList.push_back(new JQuad(tex, x, y, width, height));
mQuadMap[quadName] = id; mQuadMap[quadName] = id;
return id; return id;
} }
@@ -340,13 +340,13 @@ int JResourceManager::LoadJLBFont(const string &fontName, int height)
string path = /*mResourceRoot + */fontName; string path = /*mResourceRoot + */fontName;
printf("creating font:%s\n", path.c_str()); printf("creating font:%s\n", path.c_str());
int id = mFontList.size(); 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; mFontMap[fontName] = id;
return id; return id;
} }
else else
@@ -383,16 +383,16 @@ int JResourceManager::LoadMusic(const string &musicName)
string path = /*mResourceRoot + */musicName; string path = /*mResourceRoot + */musicName;
printf("creating music:%s\n", path.c_str()); printf("creating music:%s\n", path.c_str());
JMusic *music = JSoundSystem::GetInstance()->LoadMusic(path.c_str()); JMusic *music = JSoundSystem::GetInstance()->LoadMusic(path.c_str());
if (music == NULL) if (music == NULL)
return INVALID_ID; return INVALID_ID;
int id = mMusicList.size(); int id = mMusicList.size();
mMusicList.push_back(music); mMusicList.push_back(music);
mMusicMap[musicName] = id; mMusicMap[musicName] = id;
return id; return id;
} }
else else
@@ -429,16 +429,16 @@ int JResourceManager::LoadSample(const string &sampleName)
string path = /*mResourceRoot + */sampleName; string path = /*mResourceRoot + */sampleName;
printf("creating sample:%s\n", path.c_str()); printf("creating sample:%s\n", path.c_str());
JSample *sample = JSoundSystem::GetInstance()->LoadSample(path.c_str()); JSample *sample = JSoundSystem::GetInstance()->LoadSample(path.c_str());
if (sample == NULL) if (sample == NULL)
return INVALID_ID; return INVALID_ID;
int id = mSampleList.size(); int id = mSampleList.size();
mSampleList.push_back(sample); mSampleList.push_back(sample);
mSampleMap[sampleName] = id; mSampleMap[sampleName] = id;
return id; return id;
} }
else else
@@ -465,46 +465,46 @@ JSample *JResourceManager::GetSample(int id)
return NULL; return NULL;
} }
// //
// //
// int JResourceManager::RegisterParticleEffect(const string &effectName) // int JResourceManager::RegisterParticleEffect(const string &effectName)
// { // {
// map<string, int>::iterator itr = mParticleEffectMap.find(effectName); // map<string, int>::iterator itr = mParticleEffectMap.find(effectName);
// //
// if (itr == mParticleEffectMap.end()) // if (itr == mParticleEffectMap.end())
// { // {
// string path = mResourceRoot + effectName; // string path = mResourceRoot + effectName;
// printf("creating effect:%s\n", path.c_str()); // printf("creating effect:%s\n", path.c_str());
// JParticleEffect *effect = new JParticleEffect(path.c_str()); // JParticleEffect *effect = new JParticleEffect(path.c_str());
// //
// if (effect == NULL) // if (effect == NULL)
// return INVALID_ID; // return INVALID_ID;
// //
// //
// int id = mParticleEffectList.size(); // int id = mParticleEffectList.size();
// mParticleEffectList.push_back(effect); // mParticleEffectList.push_back(effect);
// //
// mParticleEffectMap[effectName] = id; // mParticleEffectMap[effectName] = id;
// //
// return id; // return id;
// //
// } // }
// else // else
// return itr->second; // return itr->second;
// } // }
// //
// //
// JParticleEffect *JResourceManager::GetParticleEffect(const string &effectName) // JParticleEffect *JResourceManager::GetParticleEffect(const string &effectName)
// { // {
// map<string, int>::iterator itr = mParticleEffectMap.find(effectName); // map<string, int>::iterator itr = mParticleEffectMap.find(effectName);
// //
// if (itr == mParticleEffectMap.end()) // if (itr == mParticleEffectMap.end())
// return NULL; // return NULL;
// else // else
// return mParticleEffectList[itr->second]; // return mParticleEffectList[itr->second];
// } // }
// //
// //
// JParticleEffect *JResourceManager::GetParticleEffect(int id) // JParticleEffect *JResourceManager::GetParticleEffect(int id)
// { // {
// if (id >=0 && id < (int)mParticleEffectList.size()) // if (id >=0 && id < (int)mParticleEffectList.size())
@@ -512,48 +512,48 @@ JSample *JResourceManager::GetSample(int id)
// else // else
// return NULL; // return NULL;
// } // }
// //
// //
// //
// int JResourceManager::RegisterMotionEmitter(const string &emitterName) // int JResourceManager::RegisterMotionEmitter(const string &emitterName)
// { // {
// map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName); // map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName);
// //
// if (itr == mMotionEmitterMap.end()) // if (itr == mMotionEmitterMap.end())
// { // {
// string path = mResourceRoot + emitterName; // string path = mResourceRoot + emitterName;
// printf("creating effect:%s\n", path.c_str()); // printf("creating effect:%s\n", path.c_str());
// JMotionEmitter *emitter = new JMotionEmitter(); // JMotionEmitter *emitter = new JMotionEmitter();
// //
// if (emitter == NULL) // if (emitter == NULL)
// return INVALID_ID; // return INVALID_ID;
// //
// emitter->LoadMotionML(path.c_str()); // emitter->LoadMotionML(path.c_str());
// //
// int id = mMotionEmitterList.size(); // int id = mMotionEmitterList.size();
// mMotionEmitterList.push_back(emitter); // mMotionEmitterList.push_back(emitter);
// //
// mMotionEmitterMap[emitterName] = id; // mMotionEmitterMap[emitterName] = id;
// //
// return id; // return id;
// //
// } // }
// else // else
// return itr->second; // return itr->second;
// } // }
// //
// //
// JMotionEmitter *JResourceManager::GetMotionEmitter(const string &emitterName) // JMotionEmitter *JResourceManager::GetMotionEmitter(const string &emitterName)
// { // {
// map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName); // map<string, int>::iterator itr = mMotionEmitterMap.find(emitterName);
// //
// if (itr == mMotionEmitterMap.end()) // if (itr == mMotionEmitterMap.end())
// return NULL; // return NULL;
// else // else
// return mMotionEmitterList[itr->second]; // return mMotionEmitterList[itr->second];
// } // }
// //
// //
// JMotionEmitter *JResourceManager::GetMotionEmitter(int id) // JMotionEmitter *JResourceManager::GetMotionEmitter(int id)
// { // {
// if (id >=0 && id < (int)mMotionEmitterList.size()) // if (id >=0 && id < (int)mMotionEmitterList.size())

View File

@@ -144,7 +144,7 @@ void JSprite::Render()
// //mQuad->SetColor(ARGB(alpha,255,255,255)); // //mQuad->SetColor(ARGB(alpha,255,255,255));
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
mFrames[mCurrentFrame]->SetColor(alpha<<24 | mColor); mFrames[mCurrentFrame]->SetColor(alpha<<24 | mColor);
// mQuad->SetFlip(mFlipped[mCurrentFrame], false); // mQuad->SetFlip(mFlipped[mCurrentFrame], false);
#else #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); } void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&0x00ffffff); }
#else #else
void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&~MASK_ALPHA); } void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&~MASK_ALPHA); }
@@ -344,7 +344,7 @@ void JSprite::SetCurrentFrameIndex(int frame)
JQuad* JSprite::GetCurrentFrame() JQuad* JSprite::GetCurrentFrame()
{ {
if (mCurrentFrame < mFrames.size()) if (mCurrentFrame < (signed int)mFrames.size())
return mFrames[mCurrentFrame]; return mFrames[mCurrentFrame];
else else
return NULL; return NULL;
@@ -358,7 +358,7 @@ int JSprite::GetFrameCount()
JQuad* JSprite::GetFrame(int index) JQuad* JSprite::GetFrame(int index)
{ {
if (index < mFrames.size()) if (index < (signed int)mFrames.size())
return mFrames[index]; return mFrames[index];
else else
return NULL; return NULL;

View File

@@ -19,8 +19,9 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#pragma comment( lib, "freetype.lib" ) #ifndef LINUX
#pragma comment( lib, "freetype.lib" )
#endif
#include "../include/JGE.h" #include "../include/JGE.h"
#include "../include/JRenderer.h" #include "../include/JRenderer.h"
@@ -257,7 +258,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
FT_GlyphSlot slot = mFace->glyph; FT_GlyphSlot slot = mFace->glyph;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
DWORD *texBuffer = new DWORD[mMaxCharWidth*mMaxCharHeight]; DWORD *texBuffer = new DWORD[mMaxCharWidth*mMaxCharHeight];
memset(texBuffer, 0, mMaxCharWidth*mMaxCharHeight*sizeof(DWORD)); memset(texBuffer, 0, mMaxCharWidth*mMaxCharHeight*sizeof(DWORD));
#else #else
@@ -277,7 +278,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
{ {
int top = mSize-slot->bitmap_top+1; int top = mSize-slot->bitmap_top+1;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
int offset = top*mMaxCharWidth + slot->bitmap_left + 2; int offset = top*mMaxCharWidth + slot->bitmap_left + 2;
#else #else
int xx = x + slot->bitmap_left + 2; 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]; 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); texBuffer[i*mMaxCharWidth+j+offset] = RGBA(255, 255, 255, grey);
#else #else
SwizzlePlot(pTexture, ARGB(grey,255,255,255), (xx+j)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE, mTexHeight); 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) if (bits&mask)
{ {
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
texBuffer[i*mMaxCharWidth+j*8+k+offset] = RGBA(255, 255, 255, 255); texBuffer[i*mMaxCharWidth+j*8+k+offset] = RGBA(255, 255, 255, 255);
#else #else
SwizzlePlot(pTexture, ARGB(255,255,255,255), (xx+j*8+k)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE, mTexHeight); 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); 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); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mMaxCharWidth, mMaxCharHeight, GL_RGBA, GL_UNSIGNED_BYTE, texBuffer);
#else #else
sceKernelDcacheWritebackAll(); sceKernelDcacheWritebackAll();
@@ -357,7 +358,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
if (mCurr >= mMaxCharCount) if (mCurr >= mMaxCharCount)
mCurr = 0; mCurr = 0;
#ifdef WIN32 #if defined (WIN32) || defined (LINUX)
delete [] texBuffer; delete [] texBuffer;
#endif #endif

View File

@@ -20,7 +20,7 @@
hgeDistortionMesh::hgeDistortionMesh(int cols, int rows) hgeDistortionMesh::hgeDistortionMesh(int cols, int rows)
{ {
int i; int i;
//hge=hgeCreate(HGE_VERSION); //hge=hgeCreate(HGE_VERSION);
nRows=rows; nRows=rows;
@@ -39,7 +39,7 @@ hgeDistortionMesh::hgeDistortionMesh(int cols, int rows)
disp_array[i].y=0.0f; disp_array[i].y=0.0f;
disp_array[i].u=0.0f; disp_array[i].u=0.0f;
disp_array[i].v=0.0f; disp_array[i].v=0.0f;
disp_array[i].z=0.5f; disp_array[i].z=0.5f;
disp_array[i].color=ARGB(0xFF,0xFF,0xFF,0xFF); disp_array[i].color=ARGB(0xFF,0xFF,0xFF,0xFF);
} }
@@ -89,7 +89,7 @@ hgeDistortionMesh& hgeDistortionMesh::operator= (const hgeDistortionMesh &dm)
} }
return *this; return *this;
} }
void hgeDistortionMesh::SetTexture(JTexture* tex) 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; // quad.blend=blend;
} }

View File

@@ -24,7 +24,7 @@ const char FNTCHARTAG[] = "Char";
char hgeFont::buffer[256]; char hgeFont::buffer[256];
hgeFont::hgeFont(const char *szFont, bool bMipmap) hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
{ {
//void *data; //void *data;
DWORD size; DWORD size;
@@ -35,7 +35,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
int i, x, y, w, h, a, c; int i, x, y, w, h, a, c;
// Setup variables // Setup variables
//hge=hgeCreate(HGE_VERSION); //hge=hgeCreate(HGE_VERSION);
fHeight=0.0f; fHeight=0.0f;
@@ -53,7 +53,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
memset( &letters, 0, sizeof(letters) ); memset( &letters, 0, sizeof(letters) );
memset( &pre, 0, sizeof(letters) ); memset( &pre, 0, sizeof(letters) );
memset( &post, 0, sizeof(letters) ); memset( &post, 0, sizeof(letters) );
// Load font description // Load font description
JFileSystem* fileSys = JFileSystem::GetInstance(); JFileSystem* fileSys = JFileSystem::GetInstance();
@@ -67,7 +67,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
//memcpy(desc,data,size); //memcpy(desc,data,size);
fileSys->ReadFile(desc, size); fileSys->ReadFile(desc, size);
desc[size]=0; desc[size]=0;
//hge->Resource_Free(data); //hge->Resource_Free(data);
fileSys->CloseFile(); fileSys->CloseFile();
@@ -75,7 +75,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
if(strcmp(linebuf, FNTHEADERTAG)) if(strcmp(linebuf, FNTHEADERTAG))
{ {
// hge->System_Log("Font %s has incorrect format.", szFont); // hge->System_Log("Font %s has incorrect format.", szFont);
delete[] desc; delete[] desc;
return; return;
} }
@@ -98,7 +98,7 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap)
hTexture = renderer->LoadTexture(buf); hTexture = renderer->LoadTexture(buf);
if(!hTexture) if(!hTexture)
{ {
delete[] desc; delete[] desc;
return; 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]; prevword=&pbuf[i];
pbuf=&pbuf[i+1]; pbuf=&pbuf[i+1];
} }
tx=x; tx=x;
ty=y; ty=y;
hh=fHeight*fSpacing*fScale*lines; hh=fHeight*fSpacing*fScale*lines;

View File

@@ -35,7 +35,7 @@ distribution.
const TiXmlString::size_type TiXmlString::npos = static_cast< size_type >(-1); const TiXmlString::size_type TiXmlString::npos = static_cast< size_type >(-1);
// Null rep. // Null rep.
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, '\0' }; TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
void TiXmlString::reserve (size_type cap) void TiXmlString::reserve (size_type cap)

View File

@@ -2,23 +2,23 @@
www.sourceforge.net/projects/tinyxml www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) 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 This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
damages arising from the use of this software. damages arising from the use of this software.
Permission is granted to anyone to use this software for any Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions: 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 not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation software in a product, an acknowledgment in the product documentation
would be appreciated but is not required. 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. 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. distribution.
*/ */
@@ -38,8 +38,8 @@ distribution.
// Note tha "PutString" hardcodes the same list. This // Note tha "PutString" hardcodes the same list. This
// is less flexible than it appears. Changing the entries // is less flexible than it appears. Changing the entries
// or order will break putstring. // or order will break putstring.
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
{ {
{ "&amp;", 5, '&' }, { "&amp;", 5, '&' },
{ "&lt;", 4, '<' }, { "&lt;", 4, '<' },
@@ -53,16 +53,16 @@ TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
// Including the basic of this table, which determines the #bytes in the // Including the basic of this table, which determines the #bytes in the
// sequence from the lead byte. 1 placed for invalid sequences -- // sequence from the lead byte. 1 placed for invalid sequences --
// although the result will be junk, pass it through as much as possible. // 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 bb bf (Microsoft "lead bytes")
// ef bf be // ef bf be
// ef bf bf // ef bf bf
const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; 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 // 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 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, // 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, // 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, // 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, // 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, // 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, // 0xb0
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte 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 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 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 BYTE_MARK = 0x80;
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
if (input < 0x80) if (input < 0x80)
*length = 1; *length = 1;
else if ( input < 0x800 ) else if ( input < 0x800 )
*length = 2; *length = 2;
@@ -104,22 +104,22 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
output += *length; output += *length;
// Scary scary fall throughs. // Scary scary fall throughs.
switch (*length) switch (*length)
{ {
case 4: case 4:
--output; --output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK); *output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6; input >>= 6;
case 3: case 3:
--output; --output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK); *output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6; input >>= 6;
case 2: case 2:
--output; --output;
*output = (char)((input | BYTE_MARK) & BYTE_MASK); *output = (char)((input | BYTE_MARK) & BYTE_MASK);
input >>= 6; input >>= 6;
case 1: case 1:
--output; --output;
*output = (char)(input | FIRST_BYTE_MARK[*length]); *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 // 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 // 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. // conservative approach.
// if ( encoding == TIXML_ENCODING_UTF8 ) // 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 // 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 // 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. // conservative approach.
// if ( encoding == TIXML_ENCODING_UTF8 ) // if ( encoding == TIXML_ENCODING_UTF8 )
@@ -223,7 +223,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
case '\r': case '\r':
// bump down to the next line // bump down to the next line
++row; ++row;
col = 0; col = 0;
// Eat the character // Eat the character
++p; ++p;
@@ -265,11 +265,11 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
// In these cases, don't advance the column. These are // In these cases, don't advance the column. These are
// 0-width spaces. // 0-width spaces.
if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) 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 ) else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
p += 3; p += 3;
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
p += 3; p += 3;
else else
{ p +=3; ++col; } // A normal character. { p +=3; ++col; } // A normal character.
} }
@@ -321,10 +321,10 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
while ( *p ) while ( *p )
{ {
const unsigned char* pU = (const unsigned char*)p; const unsigned char* pU = (const unsigned char*)p;
// Skip the stupid Microsoft UTF-8 Byte order marks // Skip the stupid Microsoft UTF-8 Byte order marks
if ( *(pU+0)==TIXML_UTF_LEAD_0 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 ) && *(pU+2)==TIXML_UTF_LEAD_2 )
{ {
p += 3; p += 3;
@@ -353,7 +353,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
} }
else else
{ {
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
++p; ++p;
} }
@@ -406,11 +406,11 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
// After that, they can be letters, underscores, numbers, // After that, they can be letters, underscores, numbers,
// hyphens, or colons. (Colons are valid ony for namespaces, // hyphens, or colons. (Colons are valid ony for namespaces,
// but tinyxml can't tell namespaces from names.) // but tinyxml can't tell namespaces from names.)
if ( p && *p if ( p && *p
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
{ {
while( p && *p while( p && *p
&& ( IsAlphaNum( (unsigned char ) *p, encoding ) && ( IsAlphaNum( (unsigned char ) *p, encoding )
|| *p == '_' || *p == '_'
|| *p == '-' || *p == '-'
|| *p == '.' || *p == '.'
@@ -458,7 +458,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
ucs += mult * (*q - 'a' + 10); ucs += mult * (*q - 'a' + 10);
else if ( *q >= 'A' && *q <= 'F' ) else if ( *q >= 'A' && *q <= 'F' )
ucs += mult * (*q - 'A' + 10 ); ucs += mult * (*q - 'A' + 10 );
else else
return 0; return 0;
mult *= 16; mult *= 16;
--q; --q;
@@ -481,7 +481,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
{ {
if ( *q >= '0' && *q <= '9' ) if ( *q >= '0' && *q <= '9' )
ucs += mult * (*q - '0'); ucs += mult * (*q - '0');
else else
return 0; return 0;
mult *= 10; mult *= 10;
--q; --q;
@@ -558,10 +558,10 @@ bool TiXmlBase::StringEqual( const char* p,
return false; return false;
} }
const char* TiXmlBase::ReadText( const char* p, const char* TiXmlBase::ReadText( const char* p,
TIXML_STRING * text, TIXML_STRING * text,
bool trimWhiteSpace, bool trimWhiteSpace,
const char* endTag, const char* endTag,
bool caseInsensitive, bool caseInsensitive,
TiXmlEncoding encoding ) 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 // This "pre-streaming" will never read the closing ">" so the
// sub-tag can orient itself. // sub-tag can orient itself.
if ( !StreamTo( in, '<', tag ) ) if ( !StreamTo( in, '<', tag ) )
{ {
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
return; return;
@@ -654,7 +654,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
if ( in->good() ) 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 // some sort. Identify it, and call the node to
// continue streaming. // continue streaming.
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); 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; encoding = TIXML_ENCODING_UTF8;
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
else else
encoding = TIXML_ENCODING_LEGACY; 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 ) 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! // The first error in a chain is more accurate - don't set again!
if ( error ) if ( error )
return; return;
@@ -818,7 +818,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
return 0; return 0;
} }
// What is this thing? // What is this thing?
// - Elements start with a letter or underscore, but xml is reserved. // - Elements start with a letter or underscore, but xml is reserved.
// - Comments: <!-- // - Comments: <!--
// - Decleration: <?xml // - Decleration: <?xml
@@ -906,7 +906,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
return; return;
} }
(*tag) += (char) c ; (*tag) += (char) c ;
if ( c == '>' ) if ( c == '>' )
break; 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. // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
// If not, identify and stream. // If not, identify and stream.
if ( tag->at( tag->length() - 1 ) == '>' if ( tag->at( tag->length() - 1 ) == '>'
&& tag->at( tag->length() - 2 ) == '/' ) && tag->at( tag->length() - 2 ) == '/' )
{ {
// All good! // All good!
@@ -933,7 +933,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
StreamWhiteSpace( in, tag ); StreamWhiteSpace( in, tag );
// Do we have text? // Do we have text?
if ( in->good() && in->peek() != '<' ) if ( in->good() && in->peek() != '<' )
{ {
// Yep, text. // Yep, text.
TiXmlText 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 ); document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
return; return;
} }
if ( c == '>' ) if ( c == '>' )
break; break;
@@ -1075,7 +1075,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
// Empty tag. // Empty tag.
if ( *p != '>' ) 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 0;
} }
return (p+1); return (p+1);
@@ -1175,8 +1175,8 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
LinkEndChild( textNode ); LinkEndChild( textNode );
else else
delete textNode; delete textNode;
} }
else else
{ {
// We hit a '<' // We hit a '<'
// Have we hit a new element or an end tag? This could also be // 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 ); p = node->Parse( p, data, encoding );
LinkEndChild( node ); LinkEndChild( node );
} }
else else
{ {
return 0; return 0;
@@ -1206,7 +1206,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
if ( !p ) if ( !p )
{ {
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
} }
return p; return p;
} }
@@ -1216,7 +1216,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
{ {
while ( in->good() ) while ( in->good() )
{ {
int c = in->get(); int c = in->get();
if ( c <= 0 ) if ( c <= 0 )
{ {
TiXmlDocument* document = GetDocument(); TiXmlDocument* document = GetDocument();
@@ -1229,7 +1229,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
if ( c == '>' ) if ( c == '>' )
{ {
// All is well. // All is well.
return; return;
} }
} }
} }
@@ -1274,7 +1274,7 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
{ {
while ( in->good() ) while ( in->good() )
{ {
int c = in->get(); int c = in->get();
if ( c <= 0 ) if ( c <= 0 )
{ {
TiXmlDocument* document = GetDocument(); TiXmlDocument* document = GetDocument();
@@ -1285,12 +1285,12 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
(*tag) += (char) c; (*tag) += (char) c;
if ( c == '>' if ( c == '>'
&& tag->at( tag->length() - 2 ) == '-' && tag->at( tag->length() - 2 ) == '-'
&& tag->at( tag->length() - 3 ) == '-' ) && tag->at( tag->length() - 3 ) == '-' )
{ {
// All is well. // 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 ); if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
return 0; return 0;
} }
const char* end; const char* end;
if ( *p == '\'' ) if ( *p == '\'' )
@@ -1396,7 +1396,7 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
{ {
if ( cdata ) if ( cdata )
{ {
int c = in->get(); int c = in->get();
if ( c <= 0 ) if ( c <= 0 )
{ {
TiXmlDocument* document = GetDocument(); TiXmlDocument* document = GetDocument();
@@ -1407,19 +1407,19 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
(*tag) += (char) c; (*tag) += (char) c;
if ( c == '>' if ( c == '>'
&& tag->at( tag->length() - 2 ) == ']' && tag->at( tag->length() - 2 ) == ']'
&& tag->at( tag->length() - 3 ) == ']' ) && tag->at( tag->length() - 3 ) == ']' )
{ {
// All is well. // All is well.
return; return;
} }
} }
else else
{ {
while ( in->good() ) while ( in->good() )
{ {
int c = in->peek(); int c = in->peek();
if ( c == '<' ) if ( c == '<' )
return; return;
if ( c <= 0 ) if ( c <= 0 )
@@ -1471,7 +1471,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
++p; ++p;
} }
TIXML_STRING dummy; TIXML_STRING dummy;
p = ReadText( p, &dummy, false, endTag, false, encoding ); p = ReadText( p, &dummy, false, endTag, false, encoding );
return p; return p;
} }
@@ -1545,19 +1545,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
if ( StringEqual( p, "version", true, _encoding ) ) if ( StringEqual( p, "version", true, _encoding ) )
{ {
TiXmlAttribute attrib; TiXmlAttribute attrib;
p = attrib.Parse( p, data, _encoding ); p = attrib.Parse( p, data, _encoding );
version = attrib.Value(); version = attrib.Value();
} }
else if ( StringEqual( p, "encoding", true, _encoding ) ) else if ( StringEqual( p, "encoding", true, _encoding ) )
{ {
TiXmlAttribute attrib; TiXmlAttribute attrib;
p = attrib.Parse( p, data, _encoding ); p = attrib.Parse( p, data, _encoding );
encoding = attrib.Value(); encoding = attrib.Value();
} }
else if ( StringEqual( p, "standalone", true, _encoding ) ) else if ( StringEqual( p, "standalone", true, _encoding ) )
{ {
TiXmlAttribute attrib; TiXmlAttribute attrib;
p = attrib.Parse( p, data, _encoding ); p = attrib.Parse( p, data, _encoding );
standalone = attrib.Value(); standalone = attrib.Value();
} }
else else