2010-07-10 08:20:50 +00:00
|
|
|
/* ZZ Open GL graphics plugin
|
|
|
|
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
|
|
|
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
2010-04-06 02:43:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2010-04-06 02:43:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UTIL_H_INCLUDED
|
|
|
|
#define UTIL_H_INCLUDED
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2010-11-14 01:38:10 +00:00
|
|
|
|
2010-11-09 12:04:07 +00:00
|
|
|
#include <io.h>
|
2010-11-07 09:14:48 +00:00
|
|
|
#include "Utilities/RedtapeWindows.h"
|
2010-11-14 01:38:10 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
2010-11-14 01:38:10 +00:00
|
|
|
|
2010-06-20 07:33:47 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#include "glprocs.h"
|
2010-04-06 02:43:22 +00:00
|
|
|
|
|
|
|
#else // linux basic definitions
|
|
|
|
|
2010-11-14 01:38:10 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2010-06-20 09:38:35 +00:00
|
|
|
#include <GL/glew.h>
|
2010-04-06 02:43:22 +00:00
|
|
|
#include <GL/gl.h>
|
2010-06-20 07:33:47 +00:00
|
|
|
#include <GL/glext.h>
|
2010-04-06 02:43:22 +00:00
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GSdefs
|
2010-11-07 05:51:54 +00:00
|
|
|
|
|
|
|
//Pcsx2Defs is included in Dependencies.h.
|
|
|
|
#include "Utilities/Dependencies.h"
|
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
#include "CRC.h"
|
2010-07-02 09:32:04 +00:00
|
|
|
#include "ZZLog.h"
|
2010-04-06 02:43:22 +00:00
|
|
|
|
|
|
|
// need C definitions -- no mangling please!
|
|
|
|
extern "C" u32 CALLBACK PS2EgetLibType(void);
|
|
|
|
extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
|
|
|
|
extern "C" char* CALLBACK PS2EgetLibName(void);
|
|
|
|
|
2010-09-19 08:01:48 +00:00
|
|
|
#include "ZZoglMath.h"
|
2010-11-06 06:05:00 +00:00
|
|
|
#include "Profile.h"
|
2010-04-06 02:43:22 +00:00
|
|
|
|
2010-11-06 06:41:56 +00:00
|
|
|
#include "Utilities/MemcpyFast.h"
|
|
|
|
#define memcpy_amd memcpy_fast
|
|
|
|
|
2010-11-07 05:51:54 +00:00
|
|
|
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
|
2010-04-06 02:43:22 +00:00
|
|
|
|
2010-05-01 22:54:23 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-04-06 02:43:22 +00:00
|
|
|
int x, y, w, h;
|
|
|
|
} Rect;
|
|
|
|
|
2010-05-01 22:54:23 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-04-06 02:43:22 +00:00
|
|
|
int x, y;
|
|
|
|
} Point;
|
|
|
|
|
2010-11-14 01:38:10 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
} Size;
|
|
|
|
|
2010-05-01 22:54:23 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-04-06 02:43:22 +00:00
|
|
|
int x0, y0;
|
|
|
|
int x1, y1;
|
|
|
|
} Rect2;
|
|
|
|
|
2010-05-01 22:54:23 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-04-06 02:43:22 +00:00
|
|
|
int x, y, c;
|
|
|
|
} PointC;
|
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
enum GSWindowDim
|
2010-05-02 03:09:20 +00:00
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
|
|
|
|
GSDim_640 = 0,
|
|
|
|
GSDim_800,
|
|
|
|
GSDim_1024,
|
|
|
|
GSDim_1280,
|
2010-05-02 03:09:20 +00:00
|
|
|
};
|
2010-09-18 16:53:32 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 fullscreen : 1;
|
|
|
|
u32 tga_snap : 1;
|
|
|
|
u32 capture_avi : 1;
|
|
|
|
u32 widescreen : 1;
|
|
|
|
u32 wireframe : 1;
|
|
|
|
u32 loaded : 1;
|
|
|
|
u32 dimensions : 2;
|
|
|
|
};
|
|
|
|
u32 _u32;
|
|
|
|
|
|
|
|
void ZZOptions(u32 value) { _u32 = value; }
|
|
|
|
} ZZOptions;
|
2010-05-01 22:54:23 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
typedef struct
|
2010-04-06 02:43:22 +00:00
|
|
|
{
|
|
|
|
u8 mrtdepth; // write color in render target
|
|
|
|
u8 interlace; // intelacing mode 0, 1, 3-off
|
|
|
|
u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x, 3 - 8x, 4 - 16x
|
|
|
|
u8 bilinear; // set to enable bilinear support. 0 - off, 1 -- on, 2 -- force (use for textures that usually need it)
|
2010-06-19 08:46:40 +00:00
|
|
|
ZZOptions zz_options;
|
|
|
|
gameHacks hacks; // game options -- different hacks.
|
|
|
|
gameHacks def_hacks;// default game settings
|
2010-04-06 02:43:22 +00:00
|
|
|
int width, height; // View target size, has no impact towards speed
|
2010-04-28 02:56:40 +00:00
|
|
|
int x, y; // Lets try for a persistant window position.
|
2010-04-06 02:43:22 +00:00
|
|
|
bool isWideScreen; // Widescreen support
|
2010-08-18 13:15:43 +00:00
|
|
|
u32 SkipDraw;
|
2010-04-06 02:43:22 +00:00
|
|
|
u32 log;
|
2010-10-15 09:32:41 +00:00
|
|
|
u32 disableHacks;
|
2010-06-19 06:23:40 +00:00
|
|
|
|
2010-06-21 12:03:14 +00:00
|
|
|
void incAA() { aa++; if (aa > 4) aa = 0; }
|
|
|
|
void decAA() { aa--; if (aa > 4) aa = 4; } // u8 is unsigned, so negative value is 255.
|
2010-06-19 08:46:40 +00:00
|
|
|
|
|
|
|
gameHacks settings()
|
|
|
|
{
|
2010-10-15 09:32:41 +00:00
|
|
|
if (disableHacks)
|
|
|
|
{
|
|
|
|
return hacks;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gameHacks tempHack;
|
|
|
|
tempHack._u32 = (hacks._u32 | def_hacks._u32);
|
|
|
|
return tempHack;
|
|
|
|
}
|
2010-06-19 08:46:40 +00:00
|
|
|
}
|
2010-10-15 09:32:41 +00:00
|
|
|
|
2010-06-19 08:46:40 +00:00
|
|
|
bool fullscreen() { return !!(zz_options.fullscreen); }
|
|
|
|
bool wireframe() { return !!(zz_options.wireframe); }
|
|
|
|
bool widescreen() { return !!(zz_options.widescreen); }
|
|
|
|
bool captureAvi() { return !!(zz_options.capture_avi); }
|
|
|
|
bool loaded() { return !!(zz_options.loaded); }
|
2010-06-19 06:23:40 +00:00
|
|
|
|
|
|
|
void setFullscreen(bool flag)
|
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
zz_options.fullscreen = (flag) ? 1 : 0;
|
2010-06-19 06:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setWireframe(bool flag)
|
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
zz_options.wireframe = (flag) ? 1 : 0;
|
2010-06-19 06:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setCaptureAvi(bool flag)
|
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
zz_options.capture_avi = (flag) ? 1 : 0;
|
2010-06-19 06:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setLoaded(bool flag)
|
|
|
|
{
|
2010-06-19 08:46:40 +00:00
|
|
|
zz_options.loaded = (flag) ? 1 : 0;
|
2010-06-19 06:23:40 +00:00
|
|
|
}
|
2010-07-30 09:52:34 +00:00
|
|
|
void set_dimensions(u32 dim)
|
|
|
|
{
|
|
|
|
switch (dim)
|
|
|
|
{
|
|
|
|
|
|
|
|
case GSDim_640:
|
|
|
|
width = 640;
|
|
|
|
height = isWideScreen ? 360 : 480;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSDim_800:
|
|
|
|
width = 800;
|
|
|
|
height = isWideScreen ? 450 : 600;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSDim_1024:
|
|
|
|
width = 1024;
|
|
|
|
height = isWideScreen ? 576 : 768;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GSDim_1280:
|
|
|
|
width = 1280;
|
|
|
|
height = isWideScreen ? 720 : 960;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-09-08 12:03:49 +00:00
|
|
|
width = 800;
|
|
|
|
height = 600;
|
2010-07-30 09:52:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-19 06:23:40 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
} GSconf;
|
2010-07-02 12:10:40 +00:00
|
|
|
extern GSconf conf;
|
2010-04-06 02:43:22 +00:00
|
|
|
|
2010-07-03 06:34:27 +00:00
|
|
|
// ----------------------- Defines
|
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#define REG64(name) \
|
|
|
|
union name \
|
|
|
|
{ \
|
|
|
|
u64 i64; \
|
|
|
|
u32 ai32[2]; \
|
|
|
|
struct { \
|
2010-05-01 22:54:23 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#define REG128(name)\
|
|
|
|
union name \
|
|
|
|
{ \
|
|
|
|
u64 ai64[2]; \
|
|
|
|
u32 ai32[4]; \
|
|
|
|
struct { \
|
2010-05-01 22:54:23 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#define REG64_(prefix, name) REG64(prefix##name)
|
|
|
|
#define REG128_(prefix, name) REG128(prefix##name)
|
|
|
|
|
|
|
|
#define REG_END }; };
|
|
|
|
#define REG_END2 };
|
|
|
|
|
|
|
|
#define REG64_SET(name) \
|
|
|
|
union name \
|
|
|
|
{ \
|
|
|
|
u64 i64; \
|
|
|
|
u32 ai32[2]; \
|
2010-05-01 22:54:23 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#define REG128_SET(name)\
|
|
|
|
union name \
|
|
|
|
{ \
|
|
|
|
u64 ai64[2]; \
|
|
|
|
u32 ai32[4]; \
|
2010-05-01 22:54:23 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#define REG_SET_END };
|
|
|
|
|
2010-07-03 06:34:27 +00:00
|
|
|
#define FORIT(it, v) for(it = (v).begin(); it != (v).end(); ++(it))
|
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
extern void LoadConfig();
|
|
|
|
extern void SaveConfig();
|
|
|
|
|
|
|
|
extern void (*GSirq)();
|
|
|
|
|
|
|
|
extern void *SysLoadLibrary(char *lib); // Loads Library
|
|
|
|
extern void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library
|
|
|
|
extern char *SysLibError(); // Gets previous error loading sysbols
|
|
|
|
extern void SysCloseLibrary(void *lib); // Closes Library
|
|
|
|
extern void SysMessage(const char *fmt, ...);
|
|
|
|
|
2010-10-18 11:24:40 +00:00
|
|
|
#ifdef ZEROGS_DEVBUILD
|
|
|
|
extern char* EFFECT_NAME;
|
|
|
|
extern char* EFFECT_DIR;
|
|
|
|
extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve;
|
|
|
|
extern bool g_bSaveTrans, g_bUpdateEffect, g_bSaveTex, g_bSaveResolved;
|
|
|
|
#endif
|
|
|
|
|
2010-09-15 16:54:19 +00:00
|
|
|
extern bool g_bDisplayFPS; // should we display FPS on screen?
|
2010-07-02 12:10:40 +00:00
|
|
|
|
2010-04-06 02:43:22 +00:00
|
|
|
#endif // UTIL_H_INCLUDED
|