Erwan
- fixed bugs introduced in revision 2034 (Giant Growth) - Extended Story mode xml: much easier to write basic thing, font selection, possibility to position answers, answers now in correct order - moved story in the menu because it is not major for now
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JLogger.h"
|
||||
#include "tinyxml/tinyxml.h"
|
||||
#include "unzip/unzip.h"
|
||||
|
||||
@@ -155,6 +156,8 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
{
|
||||
|
||||
string path = mResourceRoot + filename;
|
||||
JLOG("JFileSystem::OpenFile");
|
||||
JLOG(path.c_str());
|
||||
|
||||
if (mZipAvailable && mZipFile != NULL)
|
||||
{
|
||||
|
||||
+22
-85
@@ -19,6 +19,7 @@
|
||||
#include <pspdisplay.h>
|
||||
#include <png.h>
|
||||
#include "../include/vram.h"
|
||||
#include "../include/JLogger.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -39,58 +40,6 @@ static unsigned int __attribute__((aligned(16))) list[262144];
|
||||
|
||||
extern void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width);
|
||||
|
||||
/*
|
||||
//START PurpleScreen Debug
|
||||
int JRenderer::debugged = 0;
|
||||
typedef struct
|
||||
{
|
||||
unsigned int* start;
|
||||
unsigned int* current;
|
||||
int parent_context;
|
||||
} GuDisplayList;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GuDisplayList list;
|
||||
int scissor_enable;
|
||||
int scissor_start[2];
|
||||
int scissor_end[2];
|
||||
int near_plane;
|
||||
int far_plane;
|
||||
int depth_offset;
|
||||
int fragment_2x;
|
||||
int texture_function;
|
||||
int texture_proj_map_mode;
|
||||
int texture_map_mode;
|
||||
int sprite_mode[4];
|
||||
unsigned int clear_color;
|
||||
unsigned int clear_stencil;
|
||||
unsigned int clear_depth;
|
||||
int texture_mode;
|
||||
} GuContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pixel_size;
|
||||
int frame_width;
|
||||
void* frame_buffer;
|
||||
void* disp_buffer;
|
||||
void* depth_buffer;
|
||||
int depth_width;
|
||||
int width;
|
||||
int height;
|
||||
} GuDrawBuffer;
|
||||
|
||||
extern int gu_curr_context;
|
||||
extern GuDrawBuffer gu_draw_buffer;
|
||||
extern GuContext gu_contexts[3];
|
||||
extern GuDisplayList* gu_list;
|
||||
|
||||
|
||||
//END PurpleScreen Debug
|
||||
|
||||
*/
|
||||
|
||||
void Swap(float *a, float *b)
|
||||
{
|
||||
float n=*a;
|
||||
@@ -98,8 +47,6 @@ void Swap(float *a, float *b)
|
||||
*b = n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
|
||||
:mTex(tex), mX(x), mY(y), mWidth(width), mHeight(height)
|
||||
{
|
||||
@@ -402,30 +349,6 @@ void JRenderer::EndScene()
|
||||
|
||||
mCurrentTex = -1;
|
||||
mCurrentBlend = -1;
|
||||
|
||||
/*
|
||||
//START PurpleScreen Debug
|
||||
if (!debugged){
|
||||
debugged = 1;
|
||||
FILE * pFile;
|
||||
pFile = fopen ("graphiclog.txt","w");
|
||||
char temp[4096];
|
||||
sprintf(temp,"fbp0:%p\nfbp1:%p\nBuffer Format:%d\nFrame Buffer Width:%d\nScreen Width:%d\nScreen Height:%d\n",fbp0,fbp1,BUFFER_FORMAT,FRAME_BUFFER_WIDTH,SCREEN_WIDTH,SCREEN_HEIGHT);
|
||||
fputs(temp,pFile);
|
||||
sprintf(temp,"\nDRAW BUFFER:\npixel_size:%d\nframe_width:%d\nframe_buffer:%p\n",gu_draw_buffer.pixel_size,gu_draw_buffer.frame_width,gu_draw_buffer.frame_buffer);
|
||||
fputs(temp,pFile);
|
||||
sprintf(temp,"disp_buffer:%p\ndepth_buffer:%p\ndepth_width:%d\nwidth:%d\nheight:%d\n",gu_draw_buffer.disp_buffer,gu_draw_buffer.depth_buffer,gu_draw_buffer.depth_width,gu_draw_buffer.width,gu_draw_buffer.height);
|
||||
fputs(temp,pFile);
|
||||
|
||||
GuContext gc = gu_contexts[gu_curr_context];
|
||||
|
||||
sprintf(temp,"\nGU CONTEXT:\nscissor_enable:%d\ndepth_offset:%d\nfragment_2x:%d\ntexture_function:%d\ntexture_mode:%d\n",gc.scissor_enable,gc.depth_offset,gc.fragment_2x,gc.texture_function,gc.texture_mode);
|
||||
fputs(temp,pFile);
|
||||
fclose (pFile);
|
||||
}
|
||||
//END PurpleScreen Debug
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1039,6 +962,7 @@ int JRenderer::PixelSize(int textureMode){
|
||||
|
||||
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode, int textureMode)
|
||||
{
|
||||
JLOG("JRenderer::LoadJPG");
|
||||
textureInfo.mBits = NULL;
|
||||
char filenamenew[4096];
|
||||
#ifdef RESPATH
|
||||
@@ -1241,15 +1165,19 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
delete [] rawdata;
|
||||
JLOG("-- OK -- JRenderer::LoadJPG");
|
||||
}
|
||||
|
||||
|
||||
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode)
|
||||
{
|
||||
JLOG("JRenderer::LoadTexture");
|
||||
TextureInfo textureInfo;
|
||||
textureInfo.mVRAM = false;
|
||||
textureInfo.mBits = NULL;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
|
||||
LoadJPG(textureInfo, filename, mode, textureMode);
|
||||
else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL) {
|
||||
@@ -1258,7 +1186,12 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode
|
||||
}
|
||||
else if(strstr(filename, ".png")!=NULL || strstr(filename, ".PNG")!=NULL) {
|
||||
textureMode = TEXTURE_FORMAT; //textureMode not supported in PNG yet
|
||||
LoadPNG(textureInfo, filename, mode, textureMode);
|
||||
ret = LoadPNG(textureInfo, filename, mode, textureMode);
|
||||
if (ret < 0) {
|
||||
char buf[512];
|
||||
sprintf(buf, "--LoadPNG sent error code: %i for file %s", ret, filename);
|
||||
JLOG(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (textureInfo.mBits == NULL)
|
||||
@@ -1290,6 +1223,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode
|
||||
SAFE_DELETE(tex);
|
||||
}
|
||||
|
||||
JLOG("-- OK -- JRenderer::LoadTexture");
|
||||
return tex;
|
||||
|
||||
}
|
||||
@@ -1300,8 +1234,9 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode
|
||||
// http://svn.ps2dev.org/filedetails.php?repname=psp&path=/trunk/libpng/screenshot/main.c&rev=0&sc=0
|
||||
// Load PNG as texture
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode, int textureMode)
|
||||
int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode, int textureMode)
|
||||
{
|
||||
JLOG("JRenderer::LoadPNG");
|
||||
textureInfo.mBits = NULL;
|
||||
|
||||
bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);
|
||||
@@ -1317,19 +1252,19 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
u32* line;
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return;
|
||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL) {
|
||||
fileSystem->CloseFile();
|
||||
return;
|
||||
return JGE_ERR_PNG;
|
||||
}
|
||||
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL) {
|
||||
fileSystem->CloseFile();
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return;
|
||||
return JGE_ERR_PNG;
|
||||
}
|
||||
png_init_io(png_ptr, NULL);
|
||||
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
|
||||
@@ -1347,7 +1282,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
if (!line) {
|
||||
fileSystem->CloseFile();
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return;
|
||||
return JGE_ERR_MALLOC_FAILED;
|
||||
}
|
||||
|
||||
int texWidth = getNextPower2(width);
|
||||
@@ -1440,7 +1375,8 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
textureInfo.mTexWidth = texWidth;
|
||||
textureInfo.mTexHeight = texHeight;
|
||||
textureInfo.mVRAM = videoRAMUsed;
|
||||
|
||||
JLOG("-- OK -- JRenderer::LoadPNG");
|
||||
return 1;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1452,6 +1388,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
|
||||
vfree(bits);
|
||||
else
|
||||
free(bits);
|
||||
return JGE_ERR_GENERIC;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -361,6 +361,9 @@ void Run()
|
||||
// The main loop
|
||||
int main()
|
||||
{
|
||||
#ifdef DOJLOG
|
||||
remove(JGE_LOG_FILE);
|
||||
#endif
|
||||
JLOG("SetupCallbacks()");
|
||||
SetupCallbacks();
|
||||
#ifdef DEVHOOK
|
||||
|
||||
+7
-62
@@ -813,7 +813,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
||||
return tex;
|
||||
}
|
||||
|
||||
void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode __attribute__((unused)), int TextureFormat __attribute__((unused)))
|
||||
int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode __attribute__((unused)), int TextureFormat __attribute__((unused)))
|
||||
{
|
||||
//TextureInfo* textureInfo = new TextureInfo;
|
||||
|
||||
@@ -836,7 +836,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
//if ((fp = fopen(filename, "rb")) == NULL) return NULL;
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
if (!fileSystem->OpenFile(filename)) return;
|
||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL)
|
||||
@@ -844,7 +844,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
//fclose(fp);
|
||||
fileSystem->CloseFile();
|
||||
|
||||
return;
|
||||
return JGE_ERR_PNG;
|
||||
}
|
||||
|
||||
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
||||
@@ -856,7 +856,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
|
||||
return;
|
||||
return JGE_ERR_PNG;
|
||||
}
|
||||
png_init_io(png_ptr, NULL);
|
||||
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
|
||||
@@ -878,7 +878,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
fileSystem->CloseFile();
|
||||
|
||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||
return;
|
||||
return JGE_ERR_MALLOC_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -893,23 +893,9 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
// tex->mFilter = TEX_FILTER_LINEAR;
|
||||
// tex->mWidth = width;
|
||||
// tex->mHeight = height;
|
||||
// tex->mTexWidth = tw;
|
||||
// tex->mTexHeight = th;
|
||||
|
||||
// GLuint texid;
|
||||
// glGenTextures(1, &texid);
|
||||
// tex->mTexId = texid;
|
||||
|
||||
// if (texid != 0)
|
||||
{
|
||||
|
||||
// OpenGL texture has (0,0) at lower-left
|
||||
// Pay attention when doing texture mapping!!!
|
||||
|
||||
p32 = (DWORD*) buffer;// + (height-1)*width;
|
||||
p32 = (DWORD*) buffer;
|
||||
|
||||
for (y = 0; y < (int)height; y++)
|
||||
{
|
||||
@@ -917,7 +903,6 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
for (x = 0; x < (int)width; x++)
|
||||
{
|
||||
DWORD color32 = line[x];
|
||||
//u16 color16;
|
||||
int a = (color32 >> 24) & 0xff;
|
||||
int r = color32 & 0xff;
|
||||
int g = (color32 >> 8) & 0xff;
|
||||
@@ -931,40 +916,8 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
|
||||
}
|
||||
|
||||
|
||||
// glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
|
||||
//
|
||||
//
|
||||
// if (mode == TEX_TYPE_MIPMAP) // generate mipmaps
|
||||
// {
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
|
||||
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
|
||||
// gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, tw, th, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
// }
|
||||
// else if (mode == TEX_TYPE_SKYBOX) // for skybox
|
||||
// {
|
||||
// #define GL_CLAMP_TO_EDGE 0x812F
|
||||
//
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
// gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, tw, th, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
// }
|
||||
// else // single texture
|
||||
// {
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
// }
|
||||
|
||||
// ret = TRUE;
|
||||
|
||||
}
|
||||
|
||||
// delete buffer;
|
||||
|
||||
}
|
||||
|
||||
@@ -973,17 +926,8 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||
|
||||
//fclose(fp);
|
||||
fileSystem->CloseFile();
|
||||
|
||||
// if (!ret)
|
||||
// {
|
||||
// if (tex)
|
||||
// delete tex;
|
||||
// tex = NULL;
|
||||
// }
|
||||
//
|
||||
// return tex;
|
||||
|
||||
textureInfo.mBits = buffer;
|
||||
textureInfo.mWidth = width;
|
||||
@@ -991,6 +935,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
||||
textureInfo.mTexWidth = tw;
|
||||
textureInfo.mTexHeight = th;
|
||||
|
||||
return 1;
|
||||
//return textureInfo;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user