mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 10:22:48 +01:00
- [Psy-X] full PSX C API compliance (hopefully)
- [Psy-X] fix getScratchAddr BUG
This commit is contained in:
parent
a89245346e
commit
5261b0516b
@ -28,9 +28,11 @@ inline void UpdateCarDrawMatrix(CAR_DATA* cp)
|
||||
cp->hd.drawCarMat.m[0][0] = -cp->hd.where.m[0][0];
|
||||
cp->hd.drawCarMat.m[0][1] = -cp->hd.where.m[0][1];
|
||||
cp->hd.drawCarMat.m[0][2] = -cp->hd.where.m[0][2];
|
||||
|
||||
cp->hd.drawCarMat.m[1][0] = cp->hd.where.m[1][0];
|
||||
cp->hd.drawCarMat.m[1][1] = cp->hd.where.m[1][1];
|
||||
cp->hd.drawCarMat.m[1][2] = cp->hd.where.m[1][2];
|
||||
|
||||
cp->hd.drawCarMat.m[2][0] = -cp->hd.where.m[2][0];
|
||||
cp->hd.drawCarMat.m[2][1] = -cp->hd.where.m[2][1];
|
||||
cp->hd.drawCarMat.m[2][2] = -cp->hd.where.m[2][2];
|
||||
|
@ -2307,7 +2307,7 @@ void RenderGame2(int view)
|
||||
|
||||
#ifndef PSX
|
||||
int screenW, screenH;
|
||||
PsyX_GetScreenSize(screenW, screenH);
|
||||
PsyX_GetScreenSize(&screenW, &screenH);
|
||||
|
||||
float aspectVar = float(screenH) / float(screenW);
|
||||
|
||||
|
@ -611,8 +611,8 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP
|
||||
if (!bDoingShadow) // [A] Psy-X is currently incorrectly offsets the offscreen PGXP geometry. We don't need it anyway.
|
||||
{
|
||||
PGXPVData vdata1, vdata2;
|
||||
PGXP_GetCacheData(vdata1, PGXP_LOOKUP_VALUE(v1[0], v1[1]), 0);
|
||||
PGXP_GetCacheData(vdata2, PGXP_LOOKUP_VALUE(v2[0], v2[1]), 0);
|
||||
PGXP_GetCacheData(&vdata1, PGXP_LOOKUP_VALUE(v1[0].sh, v1[1].sh), 0);
|
||||
PGXP_GetCacheData(&vdata2, PGXP_LOOKUP_VALUE(v2[0].sh, v2[1].sh), 0);
|
||||
|
||||
{
|
||||
float len;
|
||||
@ -664,33 +664,33 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP
|
||||
}
|
||||
}
|
||||
|
||||
PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0, prims->y0),
|
||||
PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0.sh, prims->y0.sh),
|
||||
vdata1.px + (FIXEDH(sn) - dx1) * 0.01f,
|
||||
vdata1.py + (FIXEDH(cs) + dy1) * 0.01f,
|
||||
vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy };
|
||||
|
||||
|
||||
PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1, prims->y1),
|
||||
PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1.sh, prims->y1.sh),
|
||||
vdata1.px - (FIXEDH(sn) - dx1) * 0.01f,
|
||||
vdata1.py - (FIXEDH(cs) - dy1) * 0.01f,
|
||||
vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy };
|
||||
|
||||
|
||||
PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2, prims->y2),
|
||||
PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2.sh, prims->y2.sh),
|
||||
vdata2.px + (FIXEDH(sn) + dx2) * 0.01f,
|
||||
vdata2.py + (FIXEDH(cs) - dy2) * 0.01f,
|
||||
vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy };
|
||||
|
||||
|
||||
PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3, prims->y3),
|
||||
PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3.sh, prims->y3.sh),
|
||||
vdata2.px - (FIXEDH(sn) + dx2) * 0.01f,
|
||||
vdata2.py - (FIXEDH(cs) + dy2) * 0.01f,
|
||||
vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy };
|
||||
|
||||
PGXP_EmitCacheData(v0data);
|
||||
PGXP_EmitCacheData(v1data);
|
||||
PGXP_EmitCacheData(v2data);
|
||||
PGXP_EmitCacheData(v3data);
|
||||
PGXP_EmitCacheData(&v0data);
|
||||
PGXP_EmitCacheData(&v1data);
|
||||
PGXP_EmitCacheData(&v2data);
|
||||
PGXP_EmitCacheData(&v3data);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3,9 +3,17 @@
|
||||
|
||||
#include <abs.h>
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Driver 2 math definitions
|
||||
extern short rcossin_tbl[8192];
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ONE 4096
|
||||
#define ONE_BITS 12
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef EMULATOR_GLOBALS_H
|
||||
#define EMULATOR_GLOBALS_H
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int g_windowWidth;
|
||||
extern int g_windowHeight;
|
||||
extern int g_wireframeMode;
|
||||
@ -8,6 +12,7 @@ extern int g_texturelessMode;
|
||||
extern int g_enableSwapInterval;
|
||||
extern int g_pgxpZBuffer;
|
||||
extern int g_bilinearFiltering;
|
||||
extern int g_swapInterval;
|
||||
|
||||
extern float g_pgxpZNear;
|
||||
extern float g_pgxpZFar;
|
||||
@ -26,4 +31,8 @@ extern void PsyX_Log_Warning(const char* fmt, ...);
|
||||
extern void PsyX_Log_Error(const char* fmt, ...);
|
||||
extern void PsyX_Log_Success(const char* fmt, ...);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,7 +4,7 @@
|
||||
#define CONTROLLER_MAP_FLAG_AXIS 0x4000
|
||||
#define CONTROLLER_MAP_FLAG_INVERSE 0x8000
|
||||
|
||||
struct PsyXKeyboardMapping
|
||||
typedef struct
|
||||
{
|
||||
int id;
|
||||
|
||||
@ -28,9 +28,9 @@ struct PsyXKeyboardMapping
|
||||
int kc_dpad_right;
|
||||
int kc_dpad_up;
|
||||
int kc_dpad_down;
|
||||
};
|
||||
} PsyXKeyboardMapping;
|
||||
|
||||
struct PsyXControllerMapping
|
||||
typedef struct
|
||||
{
|
||||
int id;
|
||||
|
||||
@ -61,39 +61,47 @@ struct PsyXControllerMapping
|
||||
|
||||
int gc_axis_right_x;
|
||||
int gc_axis_right_y;
|
||||
};
|
||||
|
||||
typedef void(*GameDebugKeysHandlerFunc)(int nKey, bool down);
|
||||
extern GameDebugKeysHandlerFunc gameDebugKeys;
|
||||
} PsyXControllerMapping;
|
||||
|
||||
typedef void(*GameDebugKeysHandlerFunc)(int nKey, char down);
|
||||
typedef void(*GameDebugMouseHandlerFunc)(int x, int y);
|
||||
extern GameDebugMouseHandlerFunc gameDebugMouse;
|
||||
|
||||
typedef void(*GameOnTextInputHandler)(const char* buf);
|
||||
extern GameOnTextInputHandler gameOnTextInput;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Mapped inputs */
|
||||
extern PsyXControllerMapping g_controller_mapping;
|
||||
extern PsyXKeyboardMapping g_keyboard_mapping;
|
||||
|
||||
/* Game and debug inputs */
|
||||
extern GameDebugKeysHandlerFunc gameDebugKeys;
|
||||
extern GameDebugMouseHandlerFunc gameDebugMouse;
|
||||
extern GameOnTextInputHandler gameOnTextInput;
|
||||
|
||||
/* Usually called at the beginning of main function */
|
||||
extern void PsyX_Initialise(char* windowName, int screenWidth, int screenHeight, int fullscreen);
|
||||
|
||||
/* Cleans all resources and closes open instances */
|
||||
extern void PsyX_Shutdown();
|
||||
extern void PsyX_Shutdown(void);
|
||||
|
||||
/* Returns the screen size dimensions */
|
||||
extern void PsyX_GetScreenSize(int& screenWidth, int& screenHeight);
|
||||
extern void PsyX_GetScreenSize(int* screenWidth, int* screenHeight);
|
||||
|
||||
/* Sets mouse cursor position */
|
||||
extern void PsyX_SetCursorPosition(int x, int y);
|
||||
|
||||
/* Usually called after ClearOTag/ClearOTagR */
|
||||
extern bool PsyX_BeginScene();
|
||||
extern char PsyX_BeginScene(void);
|
||||
|
||||
/* Usually called after DrawOTag/DrawOTagEnv */
|
||||
extern void PsyX_EndScene();
|
||||
extern void PsyX_EndScene(void);
|
||||
|
||||
/* Explicitly updates emulator input loop */
|
||||
extern void PsyX_UpdateInput();
|
||||
extern void PsyX_UpdateInput(void);
|
||||
|
||||
/* Returns keyboard mapping index */
|
||||
extern int PsyX_LookupKeyboardMapping(const char* str, int default_value);
|
||||
@ -113,6 +121,10 @@ extern void PsyX_EnableSwapInterval(int enable);
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* Initializes CD filesystem */
|
||||
extern void PsyX_CDFS_Init(const char* imageFileName, int track = 0, int sectorSize = 0);
|
||||
extern void PsyX_CDFS_Init(const char* imageFileName, int track /*= 0*/, int sectorSize /*= 0*/);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -102,7 +102,7 @@
|
||||
#define TPAGE_HEIGHT (256)
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct GrVertex
|
||||
typedef struct
|
||||
{
|
||||
#if defined(USE_PGXP)
|
||||
float x, y, page, clut;
|
||||
@ -115,33 +115,33 @@ struct GrVertex
|
||||
u_char r, g, b, a;
|
||||
|
||||
char tcx, tcy, _p0, _p1;
|
||||
};
|
||||
} GrVertex;
|
||||
#pragma pack(pop)
|
||||
|
||||
enum ShaderAttrib
|
||||
typedef enum
|
||||
{
|
||||
a_position,
|
||||
a_zw,
|
||||
a_texcoord,
|
||||
a_color,
|
||||
a_extra,
|
||||
};
|
||||
} ShaderAttrib;
|
||||
|
||||
enum BlendMode
|
||||
typedef enum
|
||||
{
|
||||
BM_NONE,
|
||||
BM_AVERAGE,
|
||||
BM_ADD,
|
||||
BM_SUBTRACT,
|
||||
BM_ADD_QUATER_SOURCE
|
||||
};
|
||||
} BlendMode;
|
||||
|
||||
enum TexFormat
|
||||
typedef enum
|
||||
{
|
||||
TF_4_BIT,
|
||||
TF_8_BIT,
|
||||
TF_16_BIT
|
||||
};
|
||||
} TexFormat;
|
||||
|
||||
#define MAX_NUM_POLY_BUFFER_VERTICES (32768)
|
||||
#define MAX_NUM_INDEX_BUFFERS (4096)
|
||||
@ -153,6 +153,10 @@ typedef uint ShaderID;
|
||||
#error
|
||||
#endif
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern TextureID g_whiteTexture;
|
||||
extern TextureID g_vramTexture;
|
||||
|
||||
@ -166,9 +170,10 @@ extern void GR_ReadVRAM(unsigned short* dst, int x, int y, int dst_w, int dst_
|
||||
extern void GR_StoreFrameBuffer(int x, int y, int w, int h);
|
||||
extern void GR_UpdateVRAM();
|
||||
|
||||
extern TextureID GR_CreateRGBATexture(int width, int height, u_char* data = nullptr);
|
||||
extern TextureID GR_CreateRGBATexture(int width, int height, u_char* data /*= nullptr*/);
|
||||
extern ShaderID GR_Shader_Compile(const char* source);
|
||||
|
||||
extern void GR_SetShader(const ShaderID& shader);
|
||||
extern void GR_SetShader(const ShaderID shader);
|
||||
extern void GR_Perspective3D(const float fov, const float width, const float height, const float zNear, const float zFar);
|
||||
extern void GR_Ortho2D(float left, float right, float bottom, float top, float znear, float zfar);
|
||||
|
||||
@ -177,15 +182,19 @@ extern void GR_SetPolygonOffset(float ofs);
|
||||
extern void GR_SetStencilMode(int drawPrim);
|
||||
extern void GR_EnableDepth(int enable);
|
||||
extern void GR_SetScissorState(int enable);
|
||||
extern void GR_SetOffscreenState(const RECT16& offscreenRect, int enable);
|
||||
extern void GR_SetupClipMode(const RECT16& clipRect, int enable);
|
||||
extern void GR_SetOffscreenState(const RECT16* offscreenRect, int enable);
|
||||
extern void GR_SetupClipMode(const RECT16* clipRect, int enable);
|
||||
extern void GR_SetViewPort(int x, int y, int width, int height);
|
||||
extern void GR_SetTexture(TextureID texture, TexFormat texFormat);
|
||||
extern void GR_SetWireframe(bool enable);
|
||||
extern void GR_SetWireframe(int enable);
|
||||
|
||||
extern void GR_DestroyTexture(TextureID texture);
|
||||
extern void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
|
||||
extern void GR_UpdateVertexBuffer(const GrVertex* vertices, int count);
|
||||
extern void GR_DrawTriangles(int start_vertex, int triangles);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,7 +1,8 @@
|
||||
#ifndef HALF_FLOAT
|
||||
#define HALF_FLOAT
|
||||
|
||||
struct half
|
||||
|
||||
typedef struct half
|
||||
{
|
||||
unsigned short sh;
|
||||
|
||||
@ -17,7 +18,9 @@ struct half
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} half;
|
||||
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
|
@ -4,20 +4,25 @@
|
||||
#ifdef USE_PGXP
|
||||
#include "PsyX/common/half_float.h"
|
||||
|
||||
typedef half VERTTYPE;
|
||||
#define PGXP_LOOKUP_VALUE(x, y) (x.sh | (y.sh << 16))
|
||||
// Helpful macro
|
||||
#define PGXP_LOOKUP_VALUE(x, y) (x | (y << 16))
|
||||
|
||||
struct PGXPVector3D
|
||||
//-------------------------------------
|
||||
|
||||
// in C++, VERTTYPE can be declared as half
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
typedef half VERTTYPE;
|
||||
#else
|
||||
typedef short VERTTYPE;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float px, py, pz; // 32 bit values
|
||||
VERTTYPE x, y, z; // 16 bit values (for lookup and backwards compat if not found in cache)
|
||||
};
|
||||
} PGXPVector3D;
|
||||
|
||||
extern PGXPVector3D g_FP_SXYZ0; // direct access PGXP without table lookup
|
||||
extern PGXPVector3D g_FP_SXYZ1;
|
||||
extern PGXPVector3D g_FP_SXYZ2;
|
||||
|
||||
struct PGXPVData
|
||||
typedef struct
|
||||
{
|
||||
uint lookup;
|
||||
float px;
|
||||
@ -27,18 +32,37 @@ struct PGXPVData
|
||||
float scr_h;
|
||||
float ofx;
|
||||
float ofy;
|
||||
};
|
||||
} PGXPVData;
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern PGXPVector3D g_FP_SXYZ0; // direct access PGXP without table lookup
|
||||
extern PGXPVector3D g_FP_SXYZ1;
|
||||
extern PGXPVector3D g_FP_SXYZ2;
|
||||
|
||||
extern int g_pgxpVertexIndex;
|
||||
|
||||
/* clears PGXP vertex buffer */
|
||||
void PGXP_ClearCache();
|
||||
|
||||
ushort PGXP_EmitCacheData(PGXPVData& newData);
|
||||
/* emits new PGXP vertex */
|
||||
ushort PGXP_EmitCacheData(PGXPVData* newData);
|
||||
|
||||
/* sets Z offset (works like Z bias) */
|
||||
void PGXP_SetZOffsetScale(float offset, float scale);
|
||||
|
||||
bool PGXP_GetCacheData(PGXPVData& out, uint lookup, ushort indexhint);
|
||||
/* searches for vertex with given lookup value */
|
||||
int PGXP_GetCacheData(PGXPVData* out, uint lookup, ushort indexhint /* = 0xFFFF */);
|
||||
|
||||
/* used by primitive setup */
|
||||
ushort PGXP_GetIndex();
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// special PGXP type
|
||||
typedef struct { /* 2D short vector */
|
||||
half vx, vy;
|
||||
@ -49,4 +73,5 @@ typedef struct { /* 2D short vector */
|
||||
typedef short VERTTYPE;
|
||||
#endif
|
||||
|
||||
|
||||
#endif // PGXP_DEFS
|
@ -7,16 +7,24 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
struct timerCtx_t
|
||||
typedef struct
|
||||
{
|
||||
#ifdef _WIN32
|
||||
uint64_t clockStart;
|
||||
#else
|
||||
timeval timeStart;
|
||||
#endif // _WIN32
|
||||
};
|
||||
} timerCtx_t;
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void Util_InitHPCTimer(timerCtx_t* timer);
|
||||
extern double Util_GetHPCTime(timerCtx_t* timer, int reset = 0);
|
||||
extern double Util_GetHPCTime(timerCtx_t* timer, int reset /*= 0*/);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -99,11 +99,19 @@ typedef struct
|
||||
psxCP2Ctrl CP2C; /* Cop2 control registers */
|
||||
} GTERegisters;
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern GTERegisters gteRegs;
|
||||
|
||||
//Externals
|
||||
extern int GTE_operator(int);
|
||||
extern int LIM(int value, int max, int min, unsigned int flag);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Data Registers mtc2 mfc2 */
|
||||
#define C2_VX0 (gteRegs.CP2D.p[ 0 ].sw.l)
|
||||
#define C2_VY0 (gteRegs.CP2D.p[ 0 ].sw.h)
|
||||
|
@ -33,7 +33,7 @@ extern int PadIdentifier;
|
||||
|
||||
#define _PAD(x,y) ((y)<<((x)<<4))
|
||||
|
||||
#define getScratchAddr(offset) ((u_long *)(&scratchData+(offset)*4))
|
||||
#define getScratchAddr(offset) ((u_long *)(scratchData+(offset)*4))
|
||||
|
||||
#define MODE_NTSC 0
|
||||
#define MODE_PAL 1
|
||||
|
@ -14,14 +14,14 @@ typedef struct { /* long word type 3D vector */
|
||||
long vz, pad;
|
||||
} VECTOR;
|
||||
|
||||
struct SVECTOR { /* short word type 3D vector */
|
||||
typedef struct { /* short word type 3D vector */
|
||||
short vx, vy;
|
||||
short vz, pad;
|
||||
};
|
||||
} SVECTOR;
|
||||
|
||||
struct CVECTOR { /* color type vector */
|
||||
typedef struct { /* color type vector */
|
||||
unsigned char r, g, b, cd;
|
||||
};
|
||||
} CVECTOR;
|
||||
|
||||
typedef struct { /* 2D short vector */
|
||||
short vx, vy;
|
||||
@ -46,26 +46,26 @@ VECTOR *ApplyRotMatrix(SVECTOR *v0, VECTOR *v1);
|
||||
VECTOR *ApplyRotMatrixLV(VECTOR *v0, VECTOR *v1);
|
||||
SVECTOR *ApplyMatrixSV(MATRIX *m, SVECTOR *v0, SVECTOR *v1);
|
||||
VECTOR *ApplyMatrixLV(MATRIX *m, VECTOR *v0, VECTOR *v1);
|
||||
extern void RotTrans(struct SVECTOR* v0, VECTOR* v1, long* flag);
|
||||
extern void RotTrans(SVECTOR* v0, VECTOR* v1, long* flag);
|
||||
extern void RotTransSV(SVECTOR* v0, SVECTOR* v1, long* flag);
|
||||
extern long RotTransPers(struct SVECTOR* v0, long* sxy, long* p, long* flag);
|
||||
extern long RotTransPers(SVECTOR* v0, long* sxy, long* p, long* flag);
|
||||
extern long RotTransPers3(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, long* sxy0, long* sxy1, long* sxy2, long* p, long* flag);
|
||||
extern long RotTransPers4(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, SVECTOR* v3, long* sxy0, long* sxy1, long* sxy2, long* sxy3, long* p, long* flag);
|
||||
extern void NormalColor(SVECTOR* v0, CVECTOR* v1);
|
||||
extern void NormalColor3(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, CVECTOR* v3, CVECTOR* v4, CVECTOR* v5);
|
||||
extern void NormalColorDpq(struct SVECTOR* v0, struct CVECTOR* v1, long p, struct CVECTOR* v2);
|
||||
extern void NormalColorCol(struct SVECTOR* v0, struct CVECTOR* v1, struct CVECTOR* v2);
|
||||
extern void NormalColorDpq(SVECTOR* v0, CVECTOR* v1, long p, CVECTOR* v2);
|
||||
extern void NormalColorCol(SVECTOR* v0, CVECTOR* v1, CVECTOR* v2);
|
||||
extern void NormalColorCol3(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, CVECTOR* v3, CVECTOR* v4, CVECTOR* v5, CVECTOR* v6);
|
||||
extern void LocalLight(SVECTOR* v0, VECTOR* v1);
|
||||
extern long RotAverageNclip4(struct SVECTOR* v0, struct SVECTOR* v1, struct SVECTOR* v2, struct SVECTOR* v3, long* sxy0/*arg_10*/, long* sxy1/*arg_14*/, long* sxy2/*arg_18*/, long* sxy3/*arg_1C*/, long* p/*arg_20*/, long* otz/*arg_24*/, long* flag/*arg_28*/);
|
||||
extern long RotAverageNclip4(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, SVECTOR* v3, long* sxy0/*arg_10*/, long* sxy1/*arg_14*/, long* sxy2/*arg_18*/, long* sxy3/*arg_1C*/, long* p/*arg_20*/, long* otz/*arg_24*/, long* flag/*arg_28*/);
|
||||
extern MATRIX* MulMatrix0(MATRIX* m0, MATRIX* m1, MATRIX* m2);
|
||||
extern MATRIX* MulMatrix(MATRIX* m0, MATRIX* m1);
|
||||
extern MATRIX* MulMatrix2(MATRIX* m0, MATRIX* m1);
|
||||
extern void SetBackColor(long rbk, long gbk, long bbk);
|
||||
extern void SetFarColor(long rfc, long gfc, long bfc);
|
||||
extern MATRIX* RotMatrix(struct SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrixYXZ(struct SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrixZYX_gte(struct SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrix(SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrixYXZ(SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrixZYX_gte(SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* RotMatrixX(long r, MATRIX *m);
|
||||
extern MATRIX* RotMatrixY(long r, MATRIX *m);
|
||||
extern MATRIX* RotMatrixZ(long r, MATRIX *m);
|
||||
|
@ -62,5 +62,5 @@ project "Psy-X"
|
||||
filter "configurations:Release_dev"
|
||||
optimize "Speed"
|
||||
|
||||
filter { "files:**.c", "files:**.C" }
|
||||
compileas "C++"
|
||||
--filter { "files:**.c", "files:**.C" }
|
||||
-- compileas "C++"
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "PsyX_setup.h"
|
||||
#include "PsyX_main.h"
|
||||
|
||||
#include "PsyX/PsyX_version.h"
|
||||
#include "PsyX/PsyX_globals.h"
|
||||
#include "PsyX/PsyX_public.h"
|
||||
#include "PsyX/util/timer.h"
|
||||
|
||||
#include "gpu/PsyX_GPU.h"
|
||||
|
||||
#include "util/crash_handler.h"
|
||||
|
||||
#include "psx/libetc.h"
|
||||
@ -21,9 +24,6 @@
|
||||
|
||||
#include "PsyX/PsyX_render.h"
|
||||
|
||||
extern DISPENV activeDispEnv;
|
||||
extern DRAWENV activeDrawEnv;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
int strcasecmp(const char* _l, const char* _r)
|
||||
{
|
||||
@ -58,9 +58,29 @@ volatile int g_psxSysCounters[PsxCounter_Num];
|
||||
|
||||
SDL_Thread* g_intrThread = NULL;
|
||||
SDL_mutex* g_intrMutex = NULL;
|
||||
volatile bool g_stopIntrThread = false;
|
||||
volatile char g_stopIntrThread = 0;
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void(*vsync_callback)(void);
|
||||
extern void PsyX_ShutdownSound();
|
||||
|
||||
extern void PsyX_Pad_Event_ControllerRemoved(Sint32 deviceId);
|
||||
extern void PsyX_Pad_Event_ControllerAdded(Sint32 deviceId);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int GR_InitialisePSX();
|
||||
extern int GR_InitialiseRender(char* windowName, int width, int height, int fullscreen);
|
||||
|
||||
extern void GR_ResetDevice();
|
||||
extern void GR_Shutdown();
|
||||
extern void GR_BeginScene();
|
||||
extern void GR_EndScene();
|
||||
|
||||
long g_vmode = -1;
|
||||
int g_frameSkip = 0;
|
||||
@ -106,11 +126,11 @@ long PsyX_Sys_SetVMode(long mode)
|
||||
{
|
||||
//if(g_emIntrInterval != -1)
|
||||
// emscripten_clear_interval(g_emIntrInterval);
|
||||
g_stopIntrThread = true;
|
||||
g_stopIntrThread = 1;
|
||||
|
||||
emscripten_sleep(100);
|
||||
|
||||
g_stopIntrThread = false;
|
||||
g_stopIntrThread = 0;
|
||||
emscripten_set_timeout_loop(emIntrCallback2, 1.0, NULL);
|
||||
}
|
||||
#endif
|
||||
@ -334,12 +354,6 @@ int PsyX_LookupGameControllerMapping(const char* str, int default_value)
|
||||
return default_value;
|
||||
}
|
||||
|
||||
extern int GR_InitialisePSX();
|
||||
extern int GR_InitialiseRender(char* windowName, int width, int height, int fullscreen);
|
||||
extern void GR_Shutdown();
|
||||
extern void GR_BeginScene();
|
||||
extern void GR_EndScene();
|
||||
|
||||
char* g_appNameStr = NULL;
|
||||
|
||||
void PsyX_GetWindowName(char* buffer)
|
||||
@ -397,7 +411,7 @@ static unsigned short g_LastColor = 0xFFFF;
|
||||
static unsigned short g_BadColor = 0xFFFF;
|
||||
static WORD g_BackgroundFlags = 0xFFFF;
|
||||
CRITICAL_SECTION g_SpewCS;
|
||||
bool g_bSpewCSInitted = false;
|
||||
char g_bSpewCSInitted = 0;
|
||||
|
||||
static void Spew_GetInitialColors()
|
||||
{
|
||||
@ -449,7 +463,7 @@ void Spew_ConDebugSpew(SpewType_t type, char* text)
|
||||
{
|
||||
Spew_GetInitialColors();
|
||||
InitializeCriticalSection(&g_SpewCS);
|
||||
g_bSpewCSInitted = true;
|
||||
g_bSpewCSInitted = 1;
|
||||
}
|
||||
|
||||
WORD old;
|
||||
@ -613,9 +627,9 @@ void PsyX_Initialise(char* appName, int width, int height, int fullscreen)
|
||||
SDL_ShowCursor(0);
|
||||
}
|
||||
|
||||
void PsyX_GetScreenSize(int& screenWidth, int& screenHeight)
|
||||
void PsyX_GetScreenSize(int* screenWidth, int* screenHeight)
|
||||
{
|
||||
SDL_GetWindowSize(g_window, &screenWidth, &screenHeight);
|
||||
SDL_GetWindowSize(g_window, screenWidth, screenHeight);
|
||||
}
|
||||
|
||||
void PsyX_SetCursorPosition(int x, int y)
|
||||
@ -623,12 +637,8 @@ void PsyX_SetCursorPosition(int x, int y)
|
||||
SDL_WarpMouseInWindow(g_window, x, y);
|
||||
}
|
||||
|
||||
void PsyX_Sys_DoDebugKeys(int nKey, bool down); // forward decl
|
||||
void PsyX_Sys_DoDebugKeys(int nKey, char down); // forward decl
|
||||
void PsyX_Sys_DoDebugMouseMotion(int x, int y);
|
||||
void GR_ResetDevice();
|
||||
|
||||
extern void PsyX_Pad_Event_ControllerRemoved(Sint32 deviceId);
|
||||
extern void PsyX_Pad_Event_ControllerAdded(Sint32 deviceId);
|
||||
|
||||
void PsyX_Exit();
|
||||
|
||||
@ -685,9 +695,9 @@ void PsyX_Sys_DoPollEvent()
|
||||
{
|
||||
if (g_altKeyState && event.type == SDL_KEYDOWN)
|
||||
{
|
||||
bool IsFullscreen = SDL_GetWindowFlags(g_window) & SDL_WINDOW_FULLSCREEN;
|
||||
int fullscreen = SDL_GetWindowFlags(g_window) & SDL_WINDOW_FULLSCREEN > 0;
|
||||
|
||||
SDL_SetWindowFullscreen(g_window, IsFullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
SDL_SetWindowFullscreen(g_window, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
|
||||
SDL_GetWindowSize(g_window, &g_windowWidth, &g_windowHeight);
|
||||
GR_ResetDevice();
|
||||
@ -708,7 +718,7 @@ void PsyX_Sys_DoPollEvent()
|
||||
(gameOnTextInput)(NULL);
|
||||
}
|
||||
|
||||
PsyX_Sys_DoDebugKeys(nKey, (event.type == SDL_KEYUP) ? false : true);
|
||||
PsyX_Sys_DoDebugKeys(nKey, (event.type == SDL_KEYUP) ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
@ -721,24 +731,24 @@ void PsyX_Sys_DoPollEvent()
|
||||
}
|
||||
}
|
||||
|
||||
bool begin_scene_flag = false;
|
||||
char begin_scene_flag = 0;
|
||||
|
||||
bool PsyX_BeginScene()
|
||||
char PsyX_BeginScene()
|
||||
{
|
||||
PsyX_Sys_DoPollEvent();
|
||||
|
||||
if (begin_scene_flag)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
assert(!begin_scene_flag);
|
||||
|
||||
GR_BeginScene();
|
||||
|
||||
begin_scene_flag = true;
|
||||
begin_scene_flag = 1;
|
||||
|
||||
PsyX_Log_Flush();
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint PsyX_CalcFPS();
|
||||
@ -749,7 +759,7 @@ void PsyX_EndScene()
|
||||
return;
|
||||
|
||||
assert(begin_scene_flag);
|
||||
begin_scene_flag = false;
|
||||
begin_scene_flag = 0;
|
||||
|
||||
GR_EndScene();
|
||||
|
||||
@ -761,7 +771,7 @@ void PsyX_EndScene()
|
||||
#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__)
|
||||
void PsyX_TakeScreenshot()
|
||||
{
|
||||
unsigned char* pixels = new unsigned char[g_windowWidth * g_windowHeight * 4];
|
||||
u_char* pixels = (u_char*)malloc(g_windowWidth * g_windowHeight * 4);
|
||||
|
||||
#if defined(RENDERER_OGL)
|
||||
glReadPixels(0, 0, g_windowWidth, g_windowHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||
@ -774,7 +784,7 @@ void PsyX_TakeScreenshot()
|
||||
SDL_SaveBMP(surface, "SCREENSHOT.BMP");
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
delete[] pixels;
|
||||
free(pixels);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -784,7 +794,7 @@ void PsyX_Sys_DoDebugMouseMotion(int x, int y)
|
||||
gameDebugMouse(x, y);
|
||||
}
|
||||
|
||||
void PsyX_Sys_DoDebugKeys(int nKey, bool down)
|
||||
void PsyX_Sys_DoDebugKeys(int nKey, char down)
|
||||
{
|
||||
if (gameDebugKeys)
|
||||
gameDebugKeys(nKey, down);
|
||||
@ -878,10 +888,12 @@ uint PsyX_CalcFPS()
|
||||
{
|
||||
#define FPS_INTERVAL 1.0
|
||||
|
||||
static unsigned int lastTime = SDL_GetTicks();
|
||||
static unsigned int lastTime = 0;
|
||||
static unsigned int currentFps = 0;
|
||||
static unsigned int passedFrames = 0;
|
||||
|
||||
lastTime = SDL_GetTicks();
|
||||
|
||||
passedFrames++;
|
||||
if (lastTime < SDL_GetTicks() - FPS_INTERVAL * 1000)
|
||||
{
|
||||
@ -918,8 +930,6 @@ void PsyX_WaitForTimestep(int count)
|
||||
}
|
||||
}
|
||||
|
||||
void PsyX_ShutdownSound();
|
||||
|
||||
void PsyX_Exit()
|
||||
{
|
||||
exit(0);
|
||||
@ -933,7 +943,7 @@ void PsyX_Shutdown()
|
||||
// quit vblank thread
|
||||
if (g_intrThread)
|
||||
{
|
||||
g_stopIntrThread = true;
|
||||
g_stopIntrThread = 1;
|
||||
|
||||
int returnValue;
|
||||
SDL_WaitThread(g_intrThread, &returnValue);
|
24
src_rebuild/PsyX/src/PsyX_main.h
Normal file
24
src_rebuild/PsyX/src/PsyX_main.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef EMULATOR_SETUP_H
|
||||
#define EMULATOR_SETUP_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
//Disc image filename to load for disc image builds
|
||||
#define DISC_CUE_FILENAME "IMAGE.CUE"
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned int g_swapTime;
|
||||
extern long g_vmode;
|
||||
extern int g_activeKeyboardControllers;
|
||||
|
||||
extern int PsyX_Sys_GetVBlankCount();
|
||||
extern long PsyX_Sys_SetVMode(long mode);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,9 +0,0 @@
|
||||
#ifndef EMULATOR_SETUP_H
|
||||
#define EMULATOR_SETUP_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
//Disc image filename to load for disc image builds
|
||||
#define DISC_CUE_FILENAME "IMAGE.CUE"
|
||||
|
||||
#endif
|
@ -4,7 +4,7 @@
|
||||
#include "PsyX/PsyX_globals.h"
|
||||
#include "PsyX/PsyX_render.h"
|
||||
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@ -46,8 +46,8 @@ struct GPUDrawSplit
|
||||
u_short numVerts;
|
||||
};
|
||||
|
||||
struct GrVertex g_vertexBuffer[MAX_NUM_POLY_BUFFER_VERTICES];
|
||||
struct GPUDrawSplit g_splits[MAX_NUM_INDEX_BUFFERS];
|
||||
GrVertex g_vertexBuffer[MAX_NUM_POLY_BUFFER_VERTICES];
|
||||
GPUDrawSplit g_splits[MAX_NUM_INDEX_BUFFERS];
|
||||
|
||||
int g_vertexIndex = 0;
|
||||
int g_splitIndex = 0;
|
||||
@ -107,7 +107,7 @@ void LineSwapSourceVerts(VERTTYPE*& p0, VERTTYPE*& p1, unsigned char*& c0, unsig
|
||||
}
|
||||
}
|
||||
|
||||
void MakeLineArray(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx)
|
||||
void MakeLineArray(GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx)
|
||||
{
|
||||
VERTTYPE dx = p1[0] - p0[0];
|
||||
VERTTYPE dy = p1[1] - p0[1];
|
||||
@ -165,9 +165,9 @@ void MakeLineArray(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort g
|
||||
inline void ApplyVertexPGXP(GrVertex* v, VERTTYPE* p, float ofsX, float ofsY, ushort gteidx)
|
||||
{
|
||||
#ifdef USE_PGXP
|
||||
uint lookup = PGXP_LOOKUP_VALUE(p[0], p[1]);
|
||||
uint lookup = PGXP_LOOKUP_VALUE(p[0].sh, p[1].sh);
|
||||
PGXPVData vd;
|
||||
if (g_pgxpTextureCorrection && PGXP_GetCacheData(vd, lookup, gteidx))
|
||||
if (g_pgxpTextureCorrection && PGXP_GetCacheData(&vd, lookup, gteidx))
|
||||
{
|
||||
float gteOfsX = vd.ofx;
|
||||
float gteOfsY = vd.ofy;
|
||||
@ -198,7 +198,7 @@ inline void ApplyVertexPGXP(GrVertex* v, VERTTYPE* p, float ofsX, float ofsY, us
|
||||
#endif
|
||||
}
|
||||
|
||||
void MakeVertexTriangle(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VERTTYPE* p2, ushort gteidx)
|
||||
void MakeVertexTriangle(GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VERTTYPE* p2, ushort gteidx)
|
||||
{
|
||||
assert(p0);
|
||||
assert(p1);
|
||||
@ -236,7 +236,7 @@ void MakeVertexTriangle(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VER
|
||||
ScreenCoordsToEmulator(vertex, 3);
|
||||
}
|
||||
|
||||
void MakeVertexQuad(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VERTTYPE* p2, VERTTYPE* p3, ushort gteidx)
|
||||
void MakeVertexQuad(GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VERTTYPE* p2, VERTTYPE* p3, ushort gteidx)
|
||||
{
|
||||
assert(p0);
|
||||
assert(p1);
|
||||
@ -279,7 +279,7 @@ void MakeVertexQuad(struct GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, VERTTYP
|
||||
ScreenCoordsToEmulator(vertex, 4);
|
||||
}
|
||||
|
||||
void MakeVertexRect(struct GrVertex* vertex, VERTTYPE* p0, short w, short h, ushort gteidx)
|
||||
void MakeVertexRect(GrVertex* vertex, VERTTYPE* p0, short w, short h, ushort gteidx)
|
||||
{
|
||||
assert(p0);
|
||||
|
||||
@ -318,7 +318,7 @@ void MakeVertexRect(struct GrVertex* vertex, VERTTYPE* p0, short w, short h, ush
|
||||
ScreenCoordsToEmulator(vertex, 4);
|
||||
}
|
||||
|
||||
void MakeTexcoordQuad(struct GrVertex* vertex, unsigned char* uv0, unsigned char* uv1, unsigned char* uv2, unsigned char* uv3, short page, short clut, unsigned char dither)
|
||||
void MakeTexcoordQuad(GrVertex* vertex, unsigned char* uv0, unsigned char* uv1, unsigned char* uv2, unsigned char* uv3, short page, short clut, unsigned char dither)
|
||||
{
|
||||
assert(uv0);
|
||||
assert(uv1);
|
||||
@ -371,7 +371,7 @@ void MakeTexcoordQuad(struct GrVertex* vertex, unsigned char* uv0, unsigned char
|
||||
}*/
|
||||
}
|
||||
|
||||
void MakeTexcoordTriangle(struct GrVertex* vertex, unsigned char* uv0, unsigned char* uv1, unsigned char* uv2, short page, short clut, unsigned char dither)
|
||||
void MakeTexcoordTriangle(GrVertex* vertex, unsigned char* uv0, unsigned char* uv1, unsigned char* uv2, short page, short clut, unsigned char dither)
|
||||
{
|
||||
assert(uv0);
|
||||
assert(uv1);
|
||||
@ -416,7 +416,7 @@ void MakeTexcoordTriangle(struct GrVertex* vertex, unsigned char* uv0, unsigned
|
||||
}*/
|
||||
}
|
||||
|
||||
void MakeTexcoordRect(struct GrVertex* vertex, unsigned char* uv, short page, short clut, short w, short h)
|
||||
void MakeTexcoordRect(GrVertex* vertex, unsigned char* uv, short page, short clut, short w, short h)
|
||||
{
|
||||
assert(uv);
|
||||
|
||||
@ -471,7 +471,7 @@ void MakeTexcoordRect(struct GrVertex* vertex, unsigned char* uv, short page, sh
|
||||
}
|
||||
}
|
||||
|
||||
void MakeTexcoordLineZero(struct GrVertex* vertex, unsigned char dither)
|
||||
void MakeTexcoordLineZero(GrVertex* vertex, unsigned char dither)
|
||||
{
|
||||
const unsigned char bright = 1;
|
||||
|
||||
@ -504,7 +504,7 @@ void MakeTexcoordLineZero(struct GrVertex* vertex, unsigned char dither)
|
||||
vertex[3].clut = 0;
|
||||
}
|
||||
|
||||
void MakeTexcoordTriangleZero(struct GrVertex* vertex, unsigned char dither)
|
||||
void MakeTexcoordTriangleZero(GrVertex* vertex, unsigned char dither)
|
||||
{
|
||||
const unsigned char bright = 1;
|
||||
|
||||
@ -531,7 +531,7 @@ void MakeTexcoordTriangleZero(struct GrVertex* vertex, unsigned char dither)
|
||||
|
||||
}
|
||||
|
||||
void MakeTexcoordQuadZero(struct GrVertex* vertex, unsigned char dither)
|
||||
void MakeTexcoordQuadZero(GrVertex* vertex, unsigned char dither)
|
||||
{
|
||||
const unsigned char bright = 1;
|
||||
|
||||
@ -564,7 +564,7 @@ void MakeTexcoordQuadZero(struct GrVertex* vertex, unsigned char dither)
|
||||
vertex[3].clut = 0;
|
||||
}
|
||||
|
||||
void MakeColourLine(struct GrVertex* vertex, unsigned char* col0, unsigned char* col1)
|
||||
void MakeColourLine(GrVertex* vertex, unsigned char* col0, unsigned char* col1)
|
||||
{
|
||||
assert(col0);
|
||||
assert(col1);
|
||||
@ -590,7 +590,7 @@ void MakeColourLine(struct GrVertex* vertex, unsigned char* col0, unsigned char*
|
||||
vertex[3].a = 255;
|
||||
}
|
||||
|
||||
void MakeColourTriangle(struct GrVertex* vertex, unsigned char* col0, unsigned char* col1, unsigned char* col2)
|
||||
void MakeColourTriangle(GrVertex* vertex, unsigned char* col0, unsigned char* col1, unsigned char* col2)
|
||||
{
|
||||
assert(col0);
|
||||
assert(col1);
|
||||
@ -612,7 +612,7 @@ void MakeColourTriangle(struct GrVertex* vertex, unsigned char* col0, unsigned c
|
||||
vertex[2].a = 255;
|
||||
}
|
||||
|
||||
void MakeColourQuad(struct GrVertex* vertex, unsigned char* col0, unsigned char* col1, unsigned char* col2, unsigned char* col3)
|
||||
void MakeColourQuad(GrVertex* vertex, unsigned char* col0, unsigned char* col1, unsigned char* col2, unsigned char* col3)
|
||||
{
|
||||
assert(col0);
|
||||
assert(col1);
|
||||
@ -701,8 +701,8 @@ void DrawSplit(const GPUDrawSplit& split)
|
||||
{
|
||||
GR_SetTexture(split.textureId, split.texFormat);
|
||||
|
||||
GR_SetupClipMode(split.drawenv.clip, split.drawenv.dfe);
|
||||
GR_SetOffscreenState(split.drawenv.clip, !split.drawenv.dfe);
|
||||
GR_SetupClipMode(&split.drawenv.clip, split.drawenv.dfe);
|
||||
GR_SetOffscreenState(&split.drawenv.clip, !split.drawenv.dfe);
|
||||
|
||||
GR_SetBlendMode(split.blendMode);
|
||||
|
||||
@ -718,7 +718,7 @@ void DrawAllSplits()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
struct GrVertex* vert = &g_vertexBuffer[g_polygonSelected + i];
|
||||
GrVertex* vert = &g_vertexBuffer[g_polygonSelected + i];
|
||||
vert->r = 255;
|
||||
vert->g = 0;
|
||||
vert->b = 0;
|
||||
@ -758,7 +758,7 @@ void DrawAllSplits()
|
||||
int ParsePrimitive(uintptr_t primPtr);
|
||||
int ParseLinkedPrimitiveList(uintptr_t packetStart, uintptr_t packetEnd);
|
||||
|
||||
void ParsePrimitivesToSplits(u_long* p, bool singlePrimitive)
|
||||
void ParsePrimitivesToSplits(u_long* p, int singlePrimitive)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
@ -7,6 +7,10 @@
|
||||
|
||||
#include "PsyX/common/pgxp_defs.h"
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern OT_TAG prim_terminator; // P_TAG with zero length
|
||||
|
||||
extern int g_splitIndex;
|
||||
@ -15,7 +19,11 @@ extern DRAWENV activeDrawEnv;
|
||||
extern int g_GPUDisabledState;
|
||||
|
||||
void ClearSplits();
|
||||
void ParsePrimitivesToSplits(u_long* p, bool singlePrimitive);
|
||||
void ParsePrimitivesToSplits(u_long* p, int singlePrimitive);
|
||||
void DrawAllSplits();
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -302,9 +302,9 @@ ushort PGXP_GetIndex()
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
ushort PGXP_EmitCacheData(PGXPVData& newData)
|
||||
ushort PGXP_EmitCacheData(PGXPVData* newData)
|
||||
{
|
||||
g_pgxpCache[g_pgxpVertexIndex++] = newData;
|
||||
g_pgxpCache[g_pgxpVertexIndex++] = *newData;
|
||||
g_pgxpTransformed = 1;
|
||||
return g_pgxpVertexIndex;
|
||||
}
|
||||
@ -316,17 +316,17 @@ void PGXP_SetZOffsetScale(float offset, float scale)
|
||||
}
|
||||
|
||||
// sets copy of cached vertex data to out
|
||||
bool PGXP_GetCacheData(PGXPVData& out, uint lookup, ushort indexhint)
|
||||
int PGXP_GetCacheData(PGXPVData* out, uint lookup, ushort indexhint)
|
||||
{
|
||||
if (indexhint == 0xFFFF)
|
||||
{
|
||||
out.px = 0.0f;
|
||||
out.py = 0.0f;
|
||||
out.pz = 1.0f;
|
||||
out.scr_h = 0.0f;
|
||||
out.ofx = 0.0f;
|
||||
out.ofx = 0.0f;
|
||||
return false;
|
||||
out->px = 0.0f;
|
||||
out->py = 0.0f;
|
||||
out->pz = 1.0f;
|
||||
out->scr_h = 0.0f;
|
||||
out->ofx = 0.0f;
|
||||
out->ofx = 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// index hint allows us to start from specific index
|
||||
@ -337,19 +337,19 @@ bool PGXP_GetCacheData(PGXPVData& out, uint lookup, ushort indexhint)
|
||||
{
|
||||
if (g_pgxpCache[i].lookup == lookup)
|
||||
{
|
||||
out = g_pgxpCache[i];
|
||||
return true;
|
||||
*out = g_pgxpCache[i];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
out.px = 0.0f;
|
||||
out.py = 0.0f;
|
||||
out.pz = 1.0f;
|
||||
out.scr_h = 0.0f;
|
||||
out.ofx = 0.0f;
|
||||
out.ofx = 0.0f;
|
||||
out->px = 0.0f;
|
||||
out->py = 0.0f;
|
||||
out->pz = 1.0f;
|
||||
out->scr_h = 0.0f;
|
||||
out->ofx = 0.0f;
|
||||
out->ofx = 0.0f;
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // USE_PGXP
|
||||
@ -401,7 +401,7 @@ int GTE_RotTransPers(int idx, int lm)
|
||||
// do not perform perspective multiplication so it stays in object space
|
||||
// perspective is performed exclusively in shader
|
||||
PGXPVData vdata;
|
||||
vdata.lookup = PGXP_LOOKUP_VALUE(temp.x, temp.y); // hash short values
|
||||
vdata.lookup = PGXP_LOOKUP_VALUE(temp.x.sh, temp.y.sh); // hash short values
|
||||
|
||||
// FIXME: actually we scaling here entire geometry, is that correct?
|
||||
vdata.px = fMAC1 * one_by_v * g_pgxpZScale + g_pgxpZOffset;
|
@ -3,6 +3,14 @@
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned int gte_leadingzerocount(unsigned int lzcs);
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -60,7 +60,7 @@
|
||||
#define CD_SECTOR_SIZE_MODE2 2352 // MODE2/2352
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct TOC
|
||||
typedef struct
|
||||
{
|
||||
u_char tocEntryLength;
|
||||
u_char extEntryLength;
|
||||
@ -72,9 +72,9 @@ struct TOC
|
||||
u_char interleaveGapSize;
|
||||
u_short volSeqNum[2];
|
||||
u_char nameLength;
|
||||
};
|
||||
} TOC;
|
||||
|
||||
struct Sector
|
||||
typedef struct
|
||||
{
|
||||
u_char sync[12]; /// Sync pattern (usually 00 FF FF FF FF FF FF FF FF FF FF 00)
|
||||
u_char addr[3]; /// Sector address (see below for encoding details)
|
||||
@ -83,15 +83,15 @@ struct Sector
|
||||
u_char data[2048]; /// Data (form 1)
|
||||
u_char edc[4]; /// Error-detection code (CRC32 of data area)
|
||||
u_char ecc[276]; /// Error-correction code (uses Reed-Solomon ECC algorithm)
|
||||
};
|
||||
} Sector;
|
||||
|
||||
struct AudioSector
|
||||
typedef struct
|
||||
{
|
||||
u_char sync[12]; /// Sync pattern (usually 00 FF FF FF FF FF FF FF FF FF FF 00)
|
||||
u_char addr[3]; /// Sector address (a 24-bit big-endian integer. starts at 200, 201 an onwards)
|
||||
u_char mode; /// Mode (usually 2 for Mode 2 Form 1/2 sectors)
|
||||
u_char data[2336]; /// 8 bytes Subheader, 2324 bytes Data (form 2), and 4 bytes ECC
|
||||
};
|
||||
} AudioSector;
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
@ -180,8 +180,6 @@ int CFC2_S(int reg)
|
||||
return gteRegs.CP2C.p[reg].sd;
|
||||
}
|
||||
|
||||
extern int GTE_operator(int);
|
||||
|
||||
int doCOP2(int op)
|
||||
{
|
||||
return GTE_operator(op);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "psx/libapi.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
|
||||
int sp = 0;
|
||||
|
||||
@ -137,13 +137,13 @@ long StopRCnt(long spec)//TODO
|
||||
return 0;
|
||||
}
|
||||
#undef OpenEvent
|
||||
long OpenEvent(unsigned long unk00, long unk01, long unk02, long(*func)())
|
||||
long OpenEvent(unsigned long event, long unk01, long unk02, long(*func)())
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long CloseEvent(long unk00)
|
||||
long CloseEvent(unsigned long event)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
@ -161,36 +161,24 @@ long DisableEvent(unsigned long event)
|
||||
return 0;
|
||||
}
|
||||
|
||||
long WaitEvent(long unk00)
|
||||
long WaitEvent(unsigned long event)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long TestEvent(long unk00)
|
||||
long TestEvent(unsigned long event)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long EnableEvent(long unk00)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long DisableEvent(long unk00)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DeliverEvent(unsigned long unk00, unsigned long unk01)
|
||||
void DeliverEvent(unsigned long ev1, long ev2)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void UnDeliverEvent(unsigned long unk00, unsigned long unk01)
|
||||
void UnDeliverEvent(unsigned long ev1, long ev2)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
}
|
||||
@ -213,6 +201,7 @@ int ChangeTh(long unk00)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
long open(char* unk00, unsigned long unk01)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
@ -289,6 +278,7 @@ long cd(char* unk00)
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
long LoadTest(char* unk00, struct EXEC* unk01)
|
||||
{
|
||||
@ -424,6 +414,7 @@ void GetConf(unsigned long* unk00, unsigned long* unk01, unsigned long* unk02)
|
||||
PSYX_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
/*
|
||||
long _get_errno(void)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
@ -435,7 +426,7 @@ long _get_error(long unk00)
|
||||
PSYX_UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
void SystemError(char unk00, long unk01)
|
||||
{
|
||||
PSYX_UNIMPLEMENTED();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "psx/libcd.h"
|
||||
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
#include "../iso9660.h"
|
||||
|
||||
#include <assert.h>
|
||||
@ -55,12 +55,12 @@ int g_cdCurrentTrack = 1; // default
|
||||
int g_cdNumFrames = 0;
|
||||
int g_CD_com = 0;
|
||||
|
||||
bool g_cdReadDoneFlag = true;
|
||||
int g_cdReadDoneFlag = 1;
|
||||
|
||||
char g_cdImageBinaryFileName[2048] = { 0 };
|
||||
int g_UseCDImage = 0;
|
||||
|
||||
void PsyX_CDFS_Init(const char* imageFileName, int track = 0, int sectorSize = 0)
|
||||
void PsyX_CDFS_Init(const char* imageFileName, int track /*= 0*/, int sectorSize /*= 0*/)
|
||||
{
|
||||
g_UseCDImage = 1;
|
||||
|
||||
@ -199,7 +199,7 @@ CdlFILE* CdSearchFile(CdlFILE* fp, char* name)
|
||||
fp->size = toc->fileSize[0];
|
||||
|
||||
fseek(g_imageFp, toc->sectorPosition[0] * g_cdSectorSize, SEEK_SET);
|
||||
fread(§or, sizeof(struct Sector), 1, g_imageFp);
|
||||
fread(§or, sizeof(Sector), 1, g_imageFp);
|
||||
|
||||
fp->pos.minute = sector.addr[0];
|
||||
fp->pos.second = sector.addr[1];
|
||||
@ -477,7 +477,9 @@ int CdSetDebug(int level)
|
||||
|
||||
int CdSync(int mode, u_char * result)
|
||||
{
|
||||
CdlLOC locP;
|
||||
CdlLOC* loc = (CdlLOC*)result;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
@ -489,7 +491,7 @@ int CdSync(int mode, u_char * result)
|
||||
switch (CdLastCom())
|
||||
{
|
||||
case CdlGetlocP:
|
||||
CdlLOC locP;
|
||||
|
||||
CdIntToPos(g_cdCurrentSector+=20, &locP);
|
||||
result[0] = g_cdCurrentTrack;
|
||||
result[1] = 1;//index, usually 1
|
||||
@ -838,7 +840,7 @@ CdlCB g_readyCallback = NULL;
|
||||
|
||||
Sector g_cdSectorData;
|
||||
|
||||
bool g_isCdSectorDataRead = false;
|
||||
int g_isCdSectorDataRead = 0;
|
||||
|
||||
SDL_Thread* g_cdSpoolerPCThread = NULL;
|
||||
SDL_mutex* g_cdSpoolerMutex = NULL;
|
||||
@ -855,7 +857,7 @@ void _eCdGetSector(char* dest, int count)
|
||||
assert(dest);
|
||||
|
||||
memcpy(dest, g_cdSectorData.data, count);
|
||||
g_isCdSectorDataRead = true;
|
||||
g_isCdSectorDataRead = 1;
|
||||
}
|
||||
|
||||
CdlDataCB _eCdDataCallback(CdlDataCB cb)
|
||||
@ -881,11 +883,13 @@ CdlCB _eCdReadyCallback(CdlCB cb)
|
||||
// Main spooler thread function
|
||||
int _eCdSpoolerThreadFunc(void* data)
|
||||
{
|
||||
u_char zero_bytes[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
||||
|
||||
//Print incoming data
|
||||
eprintwarn("Running CD thread...\n");
|
||||
|
||||
g_cdReadDoneFlag = false;
|
||||
g_isCdSectorDataRead = false;
|
||||
g_cdReadDoneFlag = 0;
|
||||
g_isCdSectorDataRead = 0;
|
||||
|
||||
CdlCB readyCb = g_readyCallback;
|
||||
CdlDataCB dataCb = g_dataCallback;
|
||||
@ -903,7 +907,7 @@ int _eCdSpoolerThreadFunc(void* data)
|
||||
eprintinfo("CD: 'CdlPause'\n", sector);
|
||||
|
||||
g_cdSpoolerSeekCmd = 0;
|
||||
g_cdReadDoneFlag = true;
|
||||
g_cdReadDoneFlag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -924,11 +928,11 @@ int _eCdSpoolerThreadFunc(void* data)
|
||||
memset(&g_cdSectorData, 0, sizeof(g_cdSectorData));
|
||||
fread(&g_cdSectorData, sizeof(Sector), 1, g_imageFp);
|
||||
|
||||
g_isCdSectorDataRead = false;
|
||||
g_isCdSectorDataRead = 0;
|
||||
|
||||
if (readyCb)
|
||||
{
|
||||
readyCb(1, { 0x0 });
|
||||
readyCb(1, zero_bytes);
|
||||
|
||||
if (g_isCdSectorDataRead && dataCb)
|
||||
dataCb();
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include "psx/libetc.h"
|
||||
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
#include "PsyX/PsyX_public.h"
|
||||
|
||||
#include <SDL_timer.h>
|
||||
|
||||
char scratchData[1024];
|
||||
void(*vsync_callback)(void) = NULL;
|
||||
|
||||
int StopCallback(void)
|
||||
@ -20,13 +21,6 @@ int ResetCallback(void)
|
||||
return old;
|
||||
}
|
||||
|
||||
char scratchData[1024];
|
||||
|
||||
extern unsigned int g_swapTime;
|
||||
extern int PsyX_Sys_GetVBlankCount();
|
||||
extern long PsyX_Sys_SetVMode(long mode);
|
||||
extern long g_vmode;
|
||||
|
||||
int VSync(int mode)
|
||||
{
|
||||
if (mode < 0)
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "PsyX/PsyX_globals.h"
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
//#include "../gpu/font.h"
|
||||
|
||||
//#define DEBUG_POLY_COUNT
|
||||
@ -414,7 +414,7 @@ void DrawOTag(u_long* p)
|
||||
if (activeDrawEnv.isbg)
|
||||
ClearImage(&activeDrawEnv.clip, activeDrawEnv.r0, activeDrawEnv.g0, activeDrawEnv.b0);
|
||||
|
||||
ParsePrimitivesToSplits(p, false);
|
||||
ParsePrimitivesToSplits(p, 0);
|
||||
|
||||
GR_SetStencilMode(0);
|
||||
DrawAllSplits();
|
||||
@ -446,7 +446,7 @@ void DrawPrim(void* p)
|
||||
if (activeDrawEnv.isbg)
|
||||
ClearImage(&activeDrawEnv.clip, activeDrawEnv.r0, activeDrawEnv.g0, activeDrawEnv.b0);
|
||||
|
||||
ParsePrimitivesToSplits((u_long*)p, true);
|
||||
ParsePrimitivesToSplits((u_long*)p, 1);
|
||||
|
||||
// draw with mask 0x16
|
||||
GR_SetStencilMode(1);
|
||||
|
@ -121,7 +121,7 @@ void PopMatrix()
|
||||
}
|
||||
}
|
||||
|
||||
void RotTrans(struct SVECTOR* v0, VECTOR* v1, long* flag)
|
||||
void RotTrans(SVECTOR* v0, VECTOR* v1, long* flag)
|
||||
{
|
||||
gte_RotTrans(v0, v1, flag);
|
||||
}
|
||||
@ -134,7 +134,7 @@ void RotTransSV(SVECTOR* v0, SVECTOR* v1, long* flag)
|
||||
gte_stflg(flag);
|
||||
}
|
||||
|
||||
long RotTransPers(struct SVECTOR* v0, long* sxy, long* p, long* flag)
|
||||
long RotTransPers(SVECTOR* v0, long* sxy, long* p, long* flag)
|
||||
{
|
||||
int sz;
|
||||
gte_RotTransPers(v0, sxy, p, flag, &sz);
|
||||
@ -185,12 +185,12 @@ void NormalColor3(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, CVECTOR* v3, CVECTOR* v
|
||||
gte_NormalColor3(v0, v1, v2, v3, v4, v5);
|
||||
}
|
||||
|
||||
void NormalColorDpq(struct SVECTOR* v0, struct CVECTOR* v1, long p, struct CVECTOR* v2)
|
||||
void NormalColorDpq(SVECTOR* v0, CVECTOR* v1, long p, CVECTOR* v2)
|
||||
{
|
||||
gte_NormalColorDpq(v0, v1, p, v2);
|
||||
}
|
||||
|
||||
void NormalColorCol(struct SVECTOR* v0, struct CVECTOR* v1, struct CVECTOR* v2)
|
||||
void NormalColorCol(SVECTOR* v0, CVECTOR* v1, CVECTOR* v2)
|
||||
{
|
||||
gte_NormalColorCol(v0, v1, v2);
|
||||
}
|
||||
@ -229,7 +229,7 @@ void LocalLight(SVECTOR* v0, VECTOR* v1)
|
||||
gte_LocalLight(v0, v1);
|
||||
}
|
||||
|
||||
long RotAverageNclip4(struct SVECTOR* v0, struct SVECTOR* v1, struct SVECTOR* v2, struct SVECTOR* v3, long* sxy0/*arg_10*/, long* sxy1/*arg_14*/, long* sxy2/*arg_18*/, long* sxy3/*arg_1C*/, long* p/*arg_20*/, long* otz/*arg_24*/, long* flag/*arg_28*/)
|
||||
long RotAverageNclip4(SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, SVECTOR* v3, long* sxy0/*arg_10*/, long* sxy1/*arg_14*/, long* sxy2/*arg_18*/, long* sxy3/*arg_1C*/, long* p/*arg_20*/, long* otz/*arg_24*/, long* flag/*arg_28*/)
|
||||
{
|
||||
gte_ldv3(v0, v1, v2);
|
||||
gte_rtpt();
|
||||
@ -608,7 +608,7 @@ VECTOR* ApplyMatrixLV(MATRIX* m, VECTOR* v0, VECTOR* v1)
|
||||
return v1;
|
||||
}
|
||||
|
||||
MATRIX* RotMatrix(struct SVECTOR* r, MATRIX* m)
|
||||
MATRIX* RotMatrix(SVECTOR* r, MATRIX* m)
|
||||
{
|
||||
// correct Psy-Q implementation
|
||||
int c0, c1, c2;
|
||||
@ -644,7 +644,7 @@ MATRIX* RotMatrix(struct SVECTOR* r, MATRIX* m)
|
||||
return m;
|
||||
}
|
||||
|
||||
MATRIX* RotMatrixYXZ(struct SVECTOR* r, MATRIX* m)
|
||||
MATRIX* RotMatrixYXZ(SVECTOR* r, MATRIX* m)
|
||||
{
|
||||
// correct Psy-Q implementation
|
||||
int c0, c1, c2;
|
||||
@ -947,9 +947,10 @@ long ratan2(long y, long x)
|
||||
// correct Psy-Q implementation
|
||||
long v;
|
||||
ulong ang;
|
||||
int xlt0, ylt0;
|
||||
|
||||
bool xlt0 = x < 0;
|
||||
bool ylt0 = y < 0;
|
||||
xlt0 = x < 0;
|
||||
ylt0 = y < 0;
|
||||
|
||||
if (x == 0 && y == 0)
|
||||
return 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
#include "psx/libmcrd.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -1,20 +1,19 @@
|
||||
#include "psx/libpad.h"
|
||||
#include "psx/libetc.h"
|
||||
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
#include "PsyX/PsyX_public.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
struct PsyXController
|
||||
typedef struct
|
||||
{
|
||||
Sint32 deviceId; // linked device Id
|
||||
SDL_GameController* gc;
|
||||
SDL_Haptic* haptic;
|
||||
|
||||
u_char* padData;
|
||||
};
|
||||
} PsyXController;
|
||||
|
||||
PsyXController g_controllers[MAX_CONTROLLERS];
|
||||
int g_controllerToSlotMapping[MAX_CONTROLLERS] = { -1, -1 };
|
||||
@ -58,30 +57,30 @@ void PsyX_Pad_Debug_ListControllers()
|
||||
|
||||
void PsyX_Pad_OpenController(Sint32 deviceId, int slot)
|
||||
{
|
||||
PsyXController& controller = g_controllers[slot];
|
||||
PsyXController* controller = &g_controllers[slot];
|
||||
|
||||
if(controller.gc)
|
||||
if(controller->gc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
controller.gc = SDL_GameControllerOpen(deviceId);
|
||||
controller->gc = SDL_GameControllerOpen(deviceId);
|
||||
|
||||
if(controller.gc)
|
||||
if(controller->gc)
|
||||
{
|
||||
// assign device id automatically
|
||||
if (controller.deviceId == -1)
|
||||
controller.deviceId = deviceId;
|
||||
if (controller->deviceId == -1)
|
||||
controller->deviceId = deviceId;
|
||||
|
||||
SDL_Joystick* joy = SDL_GameControllerGetJoystick(controller.gc);
|
||||
SDL_Joystick* joy = SDL_GameControllerGetJoystick(controller->gc);
|
||||
|
||||
// try open haptics
|
||||
if(SDL_JoystickIsHaptic(joy))
|
||||
controller.haptic = SDL_HapticOpenFromJoystick(joy);
|
||||
controller->haptic = SDL_HapticOpenFromJoystick(joy);
|
||||
else // try open using device ID
|
||||
controller.haptic = SDL_HapticOpen(controller.deviceId);
|
||||
controller->haptic = SDL_HapticOpen(controller->deviceId);
|
||||
|
||||
if(!controller.haptic)
|
||||
if(!controller->haptic)
|
||||
{
|
||||
eprintwarn("No haptic for '%s'\n", SDL_GameControllerNameForIndex(deviceId));
|
||||
}
|
||||
@ -90,26 +89,27 @@ void PsyX_Pad_OpenController(Sint32 deviceId, int slot)
|
||||
|
||||
void PsyX_Pad_CloseController(int slot)
|
||||
{
|
||||
PsyXController& controller = g_controllers[slot];
|
||||
PsyXController* controller = &g_controllers[slot];
|
||||
|
||||
SDL_HapticClose(controller.haptic);
|
||||
SDL_GameControllerClose(controller.gc);
|
||||
SDL_HapticClose(controller->haptic);
|
||||
SDL_GameControllerClose(controller->gc);
|
||||
|
||||
//controller.deviceId = -1;
|
||||
controller.gc = NULL;
|
||||
controller.haptic = NULL;
|
||||
//controller->deviceId = -1;
|
||||
controller->gc = NULL;
|
||||
controller->haptic = NULL;
|
||||
}
|
||||
|
||||
void PsyX_Pad_InitPad(int slot, u_char* padData)
|
||||
{
|
||||
PsyXController& controller = g_controllers[slot];
|
||||
LPPADRAW pad;
|
||||
PsyXController* controller = &g_controllers[slot];
|
||||
|
||||
controller.padData = padData;
|
||||
controller.deviceId = g_controllerToSlotMapping[slot];
|
||||
controller->padData = padData;
|
||||
controller->deviceId = g_controllerToSlotMapping[slot];
|
||||
|
||||
if(padData)
|
||||
{
|
||||
PADRAW* pad = (PADRAW*)padData;
|
||||
pad = (LPPADRAW)padData;
|
||||
pad->id = slot == 0 ? 0x41 : 0xFF; // since keyboard is a main controller - it's always on
|
||||
pad->buttons[0] = 0xFF;
|
||||
pad->buttons[1] = 0xFF;
|
||||
@ -123,6 +123,9 @@ void PsyX_Pad_InitPad(int slot, u_char* padData)
|
||||
// called from Psy-X SDL events
|
||||
void PsyX_Pad_Event_ControllerAdded(Sint32 deviceId)
|
||||
{
|
||||
int i;
|
||||
PsyXController* controller;
|
||||
|
||||
// reinitialize haptics (why we still here?)
|
||||
SDL_QuitSubSystem(SDL_INIT_HAPTIC); // FIXME: this will crash if you already have haptics
|
||||
SDL_InitSubSystem(SDL_INIT_HAPTIC);
|
||||
@ -130,11 +133,11 @@ void PsyX_Pad_Event_ControllerAdded(Sint32 deviceId)
|
||||
PsyX_Pad_Debug_ListControllers();
|
||||
|
||||
// find mapping and open
|
||||
for(int i = 0; i < MAX_CONTROLLERS; i++)
|
||||
for(i = 0; i < MAX_CONTROLLERS; i++)
|
||||
{
|
||||
PsyXController& controller = g_controllers[i];
|
||||
controller = &g_controllers[i];
|
||||
|
||||
if(controller.deviceId == -1 || controller.deviceId == deviceId)
|
||||
if(controller->deviceId == -1 || controller->deviceId == deviceId)
|
||||
{
|
||||
PsyX_Pad_OpenController(deviceId, i);
|
||||
break;
|
||||
@ -145,14 +148,17 @@ void PsyX_Pad_Event_ControllerAdded(Sint32 deviceId)
|
||||
// called from Psy-X SDL events
|
||||
void PsyX_Pad_Event_ControllerRemoved(Sint32 deviceId)
|
||||
{
|
||||
int i;
|
||||
PsyXController* controller;
|
||||
|
||||
PsyX_Pad_Debug_ListControllers();
|
||||
|
||||
// find mapping and close
|
||||
for (int i = 0; i < MAX_CONTROLLERS; i++)
|
||||
{
|
||||
PsyXController& controller = g_controllers[i];
|
||||
controller = &g_controllers[i];
|
||||
|
||||
if (controller.deviceId == deviceId)
|
||||
if (controller->deviceId == deviceId)
|
||||
{
|
||||
PsyX_Pad_CloseController(i);
|
||||
}
|
||||
@ -227,15 +233,18 @@ void PadRemoveGun()
|
||||
|
||||
int PadGetState(int port)
|
||||
{
|
||||
int mtap = port & 3;
|
||||
int slot = (mtap * 2) + (port >> 4) & 1;
|
||||
PsyXController* controller;
|
||||
int mtap, slot;
|
||||
|
||||
mtap = port & 3;
|
||||
slot = (mtap * 2) + (port >> 4) & 1;
|
||||
|
||||
if(slot == 0)
|
||||
return PadStateStable; // keyboard always here
|
||||
|
||||
PsyXController& controller = g_controllers[slot];
|
||||
controller = &g_controllers[slot];
|
||||
|
||||
if(controller.gc && SDL_GameControllerGetAttached(controller.gc))
|
||||
if(controller->gc && SDL_GameControllerGetAttached(controller->gc))
|
||||
return PadStateStable;
|
||||
|
||||
return PadStateDiscon;
|
||||
@ -273,12 +282,15 @@ int hapticEffects[MAX_CONTROLLERS] = { -1, -1 };
|
||||
|
||||
void PadSetAct(int port, unsigned char* table, int len)
|
||||
{
|
||||
int mtap = port & 3;
|
||||
int slot = (mtap * 2) + (port >> 4) & 1;
|
||||
PsyXController* controller;
|
||||
int mtap, slot;
|
||||
|
||||
PsyXController& controller = g_controllers[slot];
|
||||
mtap = port & 3;
|
||||
slot = (mtap * 2) + (port >> 4) & 1;
|
||||
|
||||
controller = &g_controllers[slot];
|
||||
|
||||
if (!controller.haptic)
|
||||
if (!controller->haptic)
|
||||
return;
|
||||
|
||||
if (len == 0)
|
||||
@ -296,21 +308,21 @@ void PadSetAct(int port, unsigned char* table, int len)
|
||||
|
||||
eff.leftright.length = 400;
|
||||
|
||||
if (SDL_HapticEffectSupported(controller.haptic, &eff) != SDL_TRUE)
|
||||
if (SDL_HapticEffectSupported(controller->haptic, &eff) != SDL_TRUE)
|
||||
return;
|
||||
|
||||
if(hapticEffects[slot] == -1)
|
||||
{
|
||||
hapticEffects[slot] = SDL_HapticNewEffect(controller.haptic, &eff);
|
||||
hapticEffects[slot] = SDL_HapticNewEffect(controller->haptic, &eff);
|
||||
if(hapticEffects[slot] == -1)
|
||||
{
|
||||
eprintwarn("Warning: Unable to create haptic effect! %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
else
|
||||
SDL_HapticUpdateEffect(controller.haptic, hapticEffects[slot], &eff);
|
||||
SDL_HapticUpdateEffect(controller->haptic, hapticEffects[slot], &eff);
|
||||
|
||||
if (SDL_HapticRunEffect(controller.haptic, hapticEffects[slot], 1) != 0)
|
||||
if (SDL_HapticRunEffect(controller->haptic, hapticEffects[slot], 1) != 0)
|
||||
{
|
||||
eprintwarn("Warning: Unable to run haptic effect! %s\n", SDL_GetError());
|
||||
}
|
||||
@ -331,7 +343,7 @@ int GetControllerButtonState(SDL_GameController* cont, int buttonOrAxis)
|
||||
return SDL_GameControllerGetButton(cont, (SDL_GameControllerButton)buttonOrAxis) * 32767;
|
||||
}
|
||||
|
||||
void PsyX_Pad_UpdateGameControllerInput(SDL_GameController* cont, PADRAW* pad)
|
||||
void PsyX_Pad_UpdateGameControllerInput(SDL_GameController* cont, LPPADRAW pad)
|
||||
{
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
@ -473,24 +485,26 @@ unsigned short UpdateKeyboardInput()
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int g_activeKeyboardControllers;
|
||||
|
||||
void PsyX_Pad_InternalPadUpdates()
|
||||
{
|
||||
PsyXController* controller;
|
||||
LPPADRAW pad;
|
||||
u_short kbInputs;
|
||||
|
||||
if (g_padCommEnable == 0)
|
||||
return;
|
||||
|
||||
unsigned short kbInputs = UpdateKeyboardInput();
|
||||
kbInputs = UpdateKeyboardInput();
|
||||
|
||||
for (int i = 0; i < MAX_CONTROLLERS; i++)
|
||||
{
|
||||
PsyXController& controller = g_controllers[i];
|
||||
controller = &g_controllers[i];
|
||||
|
||||
if (controller.padData)
|
||||
if (controller->padData)
|
||||
{
|
||||
PADRAW* pad = (PADRAW*)controller.padData;
|
||||
pad = (LPPADRAW*)controller->padData;
|
||||
|
||||
PsyX_Pad_UpdateGameControllerInput(controller.gc, pad);
|
||||
PsyX_Pad_UpdateGameControllerInput(controller->gc, pad);
|
||||
|
||||
if (i == 0) // Update keyboard for PAD 1
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../PsyX_setup.h"
|
||||
#include "../PsyX_main.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -68,16 +68,16 @@ const char* getALErrorString(int err)
|
||||
#define SPU_MEMSIZE (2048*1024) // SPU_REALMEMSIZE
|
||||
#define SPU_VOICES 24
|
||||
|
||||
struct SPUMemory
|
||||
typedef struct
|
||||
{
|
||||
unsigned char samplemem[SPU_MEMSIZE];
|
||||
unsigned char* writeptr;
|
||||
};
|
||||
} SPUMemory;
|
||||
|
||||
static SPUMemory s_SpuMemory;
|
||||
SDL_mutex* g_SpuMutex = NULL;
|
||||
|
||||
struct SPUVoice
|
||||
typedef struct
|
||||
{
|
||||
SpuVoiceAttr attr; // .voice is Id of this channel
|
||||
|
||||
@ -85,7 +85,7 @@ struct SPUVoice
|
||||
ALuint alSource;
|
||||
ushort sampledirty;
|
||||
ushort reverb;
|
||||
};
|
||||
} SPUVoice;
|
||||
|
||||
SPUVoice g_SpuVoices[SPU_VOICES];
|
||||
ALCdevice* g_ALCdevice = NULL;
|
||||
@ -153,18 +153,29 @@ void InitOpenAlEffects()
|
||||
alAuxiliaryEffectSloti(g_ALEffectSlots[g_currEffectSlotIdx], AL_EFFECTSLOT_EFFECT, g_nAlReverbEffect);
|
||||
}
|
||||
|
||||
bool PsyX_InitSound()
|
||||
int PsyX_InitSound()
|
||||
{
|
||||
if (g_ALCdevice)
|
||||
return true;
|
||||
int numDevices, alErr, i;
|
||||
const char* devices;
|
||||
const char* devStrptr;
|
||||
|
||||
int numDevices = 0;
|
||||
// out_channel_formats snd_outputchannels
|
||||
static int al_context_params[] =
|
||||
{
|
||||
ALC_FREQUENCY, 44100,
|
||||
ALC_MAX_AUXILIARY_SENDS, 2,
|
||||
0
|
||||
};
|
||||
|
||||
if (g_ALCdevice)
|
||||
return 1;
|
||||
|
||||
numDevices = 0;
|
||||
|
||||
// Init openAL
|
||||
// check devices list
|
||||
const char* devices;
|
||||
|
||||
const char* devStrptr = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
|
||||
devStrptr = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
||||
devices = devStrptr;
|
||||
|
||||
// go through device list (each device terminated with a single NULL, list terminated with double NULL)
|
||||
@ -176,27 +187,20 @@ bool PsyX_InitSound()
|
||||
}
|
||||
|
||||
if(numDevices == 0)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
g_ALCdevice = alcOpenDevice(NULL);
|
||||
|
||||
int alErr = AL_NO_ERROR;
|
||||
alErr = AL_NO_ERROR;
|
||||
|
||||
if (!g_ALCdevice)
|
||||
{
|
||||
alErr = alcGetError(nullptr);
|
||||
alErr = alcGetError(NULL);
|
||||
eprinterr("alcOpenDevice: NULL DEVICE error: %s\n", getALCErrorString(alErr));
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// out_channel_formats snd_outputchannels
|
||||
int al_context_params[] =
|
||||
{
|
||||
ALC_FREQUENCY, 44100,
|
||||
ALC_MAX_AUXILIARY_SENDS, 2,
|
||||
0
|
||||
};
|
||||
g_ALCcontext = alcCreateContext(g_ALCdevice, al_context_params);
|
||||
#else
|
||||
g_ALCcontext = alcCreateContext(g_ALCdevice, NULL);
|
||||
@ -206,7 +210,7 @@ bool PsyX_InitSound()
|
||||
if (alErr != AL_NO_ERROR)
|
||||
{
|
||||
eprinterr("alcCreateContext error: %s\n", getALCErrorString(alErr));
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
alcMakeContextCurrent(g_ALCcontext);
|
||||
@ -215,7 +219,7 @@ bool PsyX_InitSound()
|
||||
if (alErr != AL_NO_ERROR)
|
||||
{
|
||||
eprinterr("alcMakeContextCurrent error: %s\n", getALCErrorString(alErr));
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Setup defaults
|
||||
@ -223,16 +227,16 @@ bool PsyX_InitSound()
|
||||
alDistanceModel(AL_NONE);
|
||||
|
||||
// create channels
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
for (i = 0; i < SPU_VOICES; i++)
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
memset(&voice, 0, sizeof(SPUVoice));
|
||||
SPUVoice* voice = &g_SpuVoices[i];
|
||||
memset(voice, 0, sizeof(SPUVoice));
|
||||
|
||||
alGenSources(1, &voice.alSource);
|
||||
alGenBuffers(1, &voice.alBuffer);
|
||||
alGenSources(1, &voice->alSource);
|
||||
alGenBuffers(1, &voice->alBuffer);
|
||||
|
||||
alSourcei(voice.alSource, AL_SOURCE_RESAMPLER_SOFT, 2); // Use cubic resampler
|
||||
alSourcei(voice.alSource, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSourcei(voice->alSource, AL_SOURCE_RESAMPLER_SOFT, 2); // Use cubic resampler
|
||||
alSourcei(voice->alSource, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
}
|
||||
|
||||
memset(&s_SpuMemory, 0, sizeof(s_SpuMemory));
|
||||
@ -241,7 +245,7 @@ bool PsyX_InitSound()
|
||||
|
||||
g_SpuMutex = SDL_CreateMutex();
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void PsyX_ShutdownSound()
|
||||
@ -251,9 +255,9 @@ void PsyX_ShutdownSound()
|
||||
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
alDeleteSources(1, &voice.alSource);
|
||||
alDeleteBuffers(1, &voice.alBuffer);
|
||||
SPUVoice* voice = &g_SpuVoices[i];
|
||||
alDeleteSources(1, &voice->alSource);
|
||||
alDeleteBuffers(1, &voice->alBuffer);
|
||||
}
|
||||
|
||||
if (g_ALEffectsSupported)
|
||||
@ -308,7 +312,7 @@ short vagToPcm(unsigned char soundParameter, int soundData, float* vagPrev1, flo
|
||||
return (short)resultInt;
|
||||
}
|
||||
|
||||
enum ADPCM_FLAGS
|
||||
typedef enum
|
||||
{
|
||||
LoopEnd = 1 << 0, // Jump to repeat address after this block
|
||||
// 1 - Copy repeatAddress to currentAddress AFTER this block
|
||||
@ -322,11 +326,11 @@ enum ADPCM_FLAGS
|
||||
LoopStart = 1 << 2, // Mark current address as the beginning of repeat
|
||||
// 1 - Load currentAddress to repeatAddress
|
||||
// 0 - Nothing
|
||||
};
|
||||
} ADPCM_FLAGS;
|
||||
|
||||
|
||||
// Main decoding routine - Takes PSX ADPCM formatted audio data and converts it to PCM. It also extracts the looping information if used.
|
||||
int decodeSound(unsigned char* iData, int soundSize, short* oData, int* loopStart, int* loopLength, bool breakOnEnd = false)
|
||||
int decodeSound(unsigned char* iData, int soundSize, short* oData, int* loopStart, int* loopLength, int breakOnEnd /*= 0*/)
|
||||
{
|
||||
unsigned char sp;
|
||||
unsigned char flag;
|
||||
@ -359,16 +363,16 @@ int decodeSound(unsigned char* iData, int soundSize, short* oData, int* loopStar
|
||||
if (breakOn == -1)
|
||||
{
|
||||
// flags parsed
|
||||
if (flag & ADPCM_FLAGS::LoopStart)
|
||||
if (flag & LoopStart)
|
||||
{
|
||||
loopStrt = k + 26; // FIXME: is that correct?
|
||||
}
|
||||
|
||||
if (flag & ADPCM_FLAGS::LoopEnd)
|
||||
if (flag & LoopEnd)
|
||||
{
|
||||
loopEnd = k + 26;
|
||||
|
||||
if (flag & ADPCM_FLAGS::Repeat)
|
||||
if (flag & Repeat)
|
||||
{
|
||||
*loopStart = loopStrt;
|
||||
*loopLength = loopEnd - loopStrt;
|
||||
@ -497,23 +501,27 @@ void SpuQuit(void)
|
||||
// do nothing!
|
||||
}
|
||||
|
||||
void UpdateVoiceSample(SPUVoice& voice)
|
||||
void UpdateVoiceSample(SPUVoice* voice)
|
||||
{
|
||||
//if (!voice.sampledirty)
|
||||
static short waveBuffer[SPU_REALMEMSIZE];
|
||||
int loopStart, loopLen, count;
|
||||
ALuint alSource, alBuffer;
|
||||
|
||||
//if (!voice->sampledirty)
|
||||
// return;
|
||||
|
||||
voice.sampledirty = 0;
|
||||
voice->sampledirty = 0;
|
||||
|
||||
static short waveBuffer[SPU_REALMEMSIZE];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
ALuint alBuffer = voice.alBuffer;
|
||||
alSource = voice->alSource;
|
||||
alBuffer = voice->alBuffer;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
return;
|
||||
|
||||
int loopStart = 0, loopLen = 0;
|
||||
int count = decodeSound(s_SpuMemory.samplemem + voice.attr.addr, SPU_REALMEMSIZE - voice.attr.addr, waveBuffer, &loopStart, &loopLen, true);
|
||||
loopStart = 0;
|
||||
loopLen = 0;
|
||||
|
||||
count = decodeSound(s_SpuMemory.samplemem + voice->attr.addr, SPU_REALMEMSIZE - voice->attr.addr, waveBuffer, &loopStart, &loopLen, 1);
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
@ -553,7 +561,7 @@ void UpdateVoiceSample(SPUVoice& voice)
|
||||
|
||||
if (loopLen > 0)
|
||||
{
|
||||
loopStart += voice.attr.loop_addr - voice.attr.addr;
|
||||
loopStart += voice->attr.loop_addr - voice->attr.addr;
|
||||
|
||||
if (loopStart-54 > 0 && loopStart + loopLen <= count)
|
||||
{
|
||||
@ -576,6 +584,11 @@ void UpdateVoiceSample(SPUVoice& voice)
|
||||
|
||||
void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
{
|
||||
const float STEREO_FACTOR = 3.0f;
|
||||
SPUVoice* voice;
|
||||
ALuint alSource;
|
||||
float pitch, left_gain, right_gain, pan;
|
||||
|
||||
SDL_LockMutex(g_SpuMutex);
|
||||
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
@ -583,9 +596,9 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
if (!(arg->voice & SPU_VOICECH(i)))
|
||||
continue;
|
||||
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
voice = &g_SpuVoices[i];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
ALuint alSource = voice->alSource;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
continue;
|
||||
@ -593,25 +606,25 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
// update sample
|
||||
if ((arg->mask & SPU_VOICE_WDSA) || (arg->mask & SPU_VOICE_LSAX))
|
||||
{
|
||||
//ALuint tmp = voice.alSource[1];
|
||||
//voice.alSource[1] = voice.alSource[0];
|
||||
//voice.alSource[1] = tmp;
|
||||
//alSource = voice.alSource[0];
|
||||
//ALuint tmp = voice->alSource[1];
|
||||
//voice->alSource[1] = voice->alSource[0];
|
||||
//voice->alSource[1] = tmp;
|
||||
//alSource = voice->alSource[0];
|
||||
|
||||
if (arg->mask & SPU_VOICE_WDSA)
|
||||
{
|
||||
if (voice.attr.addr != arg->addr)
|
||||
voice.sampledirty++;
|
||||
if (voice->attr.addr != arg->addr)
|
||||
voice->sampledirty++;
|
||||
|
||||
voice.attr.addr = arg->addr;
|
||||
voice->attr.addr = arg->addr;
|
||||
}
|
||||
|
||||
if (arg->mask & SPU_VOICE_LSAX)
|
||||
{
|
||||
if(voice.attr.loop_addr != arg->loop_addr)
|
||||
voice.sampledirty++;
|
||||
if(voice->attr.loop_addr != arg->loop_addr)
|
||||
voice->sampledirty++;
|
||||
|
||||
voice.attr.loop_addr = arg->loop_addr;
|
||||
voice->attr.loop_addr = arg->loop_addr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,13 +632,13 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
if ((arg->mask & SPU_VOICE_VOLL) || (arg->mask & SPU_VOICE_VOLR))
|
||||
{
|
||||
if (arg->mask & SPU_VOICE_VOLL)
|
||||
voice.attr.volume.left = arg->volume.left;
|
||||
voice->attr.volume.left = arg->volume.left;
|
||||
|
||||
if (arg->mask & SPU_VOICE_VOLR)
|
||||
voice.attr.volume.right = arg->volume.right;
|
||||
voice->attr.volume.right = arg->volume.right;
|
||||
|
||||
float left_gain = float(voice.attr.volume.left) / float(16384);
|
||||
float right_gain = float(voice.attr.volume.right) / float(16384);
|
||||
left_gain = (float)(voice->attr.volume.left) / (float)(16384);
|
||||
right_gain = (float)(voice->attr.volume.right) / (float)(16384);
|
||||
|
||||
if(left_gain > 1.0f)
|
||||
left_gain = 1.0f;
|
||||
@ -633,9 +646,7 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
if(right_gain > 1.0f)
|
||||
right_gain = 1.0f;
|
||||
|
||||
const float STEREO_FACTOR = 3.0f;
|
||||
|
||||
float pan = (acosf(left_gain) + asinf(right_gain)) / (float(M_PI)); // average angle in [0,1]
|
||||
pan = (acosf(left_gain) + asinf(right_gain)) / ((float)(M_PI)); // average angle in [0,1]
|
||||
pan = 2.0f * pan - 1.0f; // convert to [-1, 1]
|
||||
pan = pan * 0.5f; // 0.5 = sin(30') for a +/- 30 degree arc
|
||||
alSource3f(alSource, AL_POSITION, pan * STEREO_FACTOR, 0, -sqrtf(1.0f - pan * pan));
|
||||
@ -646,9 +657,9 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
// update pitch
|
||||
if (arg->mask & SPU_VOICE_PITCH)
|
||||
{
|
||||
voice.attr.pitch = arg->pitch;
|
||||
voice->attr.pitch = arg->pitch;
|
||||
|
||||
float pitch = float(voice.attr.pitch) / 4096.0f;
|
||||
pitch = (float)(voice->attr.pitch) / 4096.0f;
|
||||
|
||||
alSourcef(alSource, AL_PITCH, pitch);
|
||||
}
|
||||
@ -660,14 +671,17 @@ void SpuSetVoiceAttr(SpuVoiceAttr *arg)
|
||||
|
||||
void SpuSetKey(long on_off, unsigned long voice_bit)
|
||||
{
|
||||
SPUVoice* voice;
|
||||
ALuint alSource;
|
||||
|
||||
SDL_LockMutex(g_SpuMutex);
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
{
|
||||
if (voice_bit & SPU_VOICECH(i))
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
voice = &g_SpuVoices[i];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
alSource = voice->alSource;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
continue;
|
||||
@ -690,6 +704,8 @@ void SpuSetKey(long on_off, unsigned long voice_bit)
|
||||
|
||||
long SpuGetKeyStatus(unsigned long voice_bit)
|
||||
{
|
||||
SPUVoice* voice;
|
||||
ALuint alSource;
|
||||
int state = AL_STOPPED;
|
||||
|
||||
SDL_LockMutex(g_SpuMutex);
|
||||
@ -699,9 +715,9 @@ long SpuGetKeyStatus(unsigned long voice_bit)
|
||||
if (voice_bit != SPU_VOICECH(i))
|
||||
continue;
|
||||
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
voice = &g_SpuVoices[i];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
alSource = voice->alSource;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
break; // SpuOff?
|
||||
@ -717,13 +733,16 @@ long SpuGetKeyStatus(unsigned long voice_bit)
|
||||
|
||||
void SpuGetAllKeysStatus(char* status)
|
||||
{
|
||||
SPUVoice* voice;
|
||||
ALuint alSource;
|
||||
|
||||
SDL_LockMutex(g_SpuMutex);
|
||||
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
voice = &g_SpuVoices[i];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
alSource = voice->alSource;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
{
|
||||
@ -823,6 +842,9 @@ long SpuIsReverbWorkAreaReserved(long on_off)
|
||||
|
||||
unsigned long SpuSetReverbVoice(long on_off, unsigned long voice_bit)
|
||||
{
|
||||
SPUVoice* voice;
|
||||
ALuint alSource;
|
||||
|
||||
if(!g_ALEffectsSupported)
|
||||
return 0;
|
||||
|
||||
@ -832,14 +854,14 @@ unsigned long SpuSetReverbVoice(long on_off, unsigned long voice_bit)
|
||||
{
|
||||
if (voice_bit & SPU_VOICECH(i))
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
voice = &g_SpuVoices[i];
|
||||
|
||||
ALuint alSource = voice.alSource;
|
||||
alSource = voice->alSource;
|
||||
|
||||
if (alSource == AL_NONE)
|
||||
continue;
|
||||
|
||||
voice.reverb = on_off > 0;
|
||||
voice->reverb = on_off > 0;
|
||||
|
||||
if (on_off)
|
||||
{
|
||||
@ -859,11 +881,14 @@ unsigned long SpuSetReverbVoice(long on_off, unsigned long voice_bit)
|
||||
|
||||
unsigned long SpuGetReverbVoice(void)
|
||||
{
|
||||
SPUVoice* voice;
|
||||
|
||||
unsigned long bits = 0;
|
||||
|
||||
for (int i = 0; i < SPU_VOICES; i++)
|
||||
{
|
||||
SPUVoice& voice = g_SpuVoices[i];
|
||||
if (voice.reverb)
|
||||
voice = &g_SpuVoices[i];
|
||||
if (voice->reverb)
|
||||
bits |= SPU_KEYCH(i);
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,31 @@
|
||||
#include "PsyX/PsyX_public.h"
|
||||
|
||||
#include "../platform.h"
|
||||
#include "../gpu/PsyX_GPU.h"
|
||||
|
||||
#include "PsyX/PsyX_render.h"
|
||||
#include "PsyX/PsyX_globals.h"
|
||||
#include "PsyX/util/timer.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
extern "C"
|
||||
{
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
|
||||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
}
|
||||
#endif //def WIN32
|
||||
|
||||
extern DISPENV activeDispEnv;
|
||||
extern DRAWENV activeDrawEnv;
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //def WIN32
|
||||
|
||||
#if defined(RENDERER_OGL)
|
||||
|
||||
@ -39,7 +43,6 @@ extern DRAWENV activeDrawEnv;
|
||||
#endif
|
||||
|
||||
extern SDL_Window* g_window;
|
||||
extern int g_swapInterval;
|
||||
|
||||
#define PSX_SCREEN_ASPECT (240.0f / 320.0f) // PSX screen is mapped always to this aspect
|
||||
|
||||
@ -79,8 +82,8 @@ int g_bilinearFiltering = 0;
|
||||
float g_pgxpZNear = 0.25f;
|
||||
float g_pgxpZFar = 1000.0f;
|
||||
|
||||
bool vram_need_update = true;
|
||||
bool framebuffer_need_update = false;
|
||||
int vram_need_update = 1;
|
||||
int framebuffer_need_update = 0;
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#if defined(RENDERER_OGL)
|
||||
@ -91,7 +94,7 @@ bool framebuffer_need_update = false;
|
||||
|
||||
|
||||
#if defined(USE_OPENGL)
|
||||
struct GrPBO
|
||||
typedef struct
|
||||
{
|
||||
GLenum fmt;
|
||||
GLuint* pbos;
|
||||
@ -103,12 +106,11 @@ struct GrPBO
|
||||
int height;
|
||||
int nbytes; /* number of bytes in the pbo buffer. */
|
||||
unsigned char* pixels; /* the downloaded pixels. */
|
||||
};
|
||||
} GrPBO;
|
||||
|
||||
int PBO_Init(GrPBO& pbo, GLenum format, int w, int h, int num)
|
||||
int PBO_Init(GrPBO* pbo, GLenum format, int w, int h, int num)
|
||||
{
|
||||
|
||||
if (pbo.pbos)
|
||||
if (pbo->pbos)
|
||||
{
|
||||
eprinterr("Already initialized. Not necessary to initialize again; or shutdown first.");
|
||||
return -1;
|
||||
@ -120,21 +122,21 @@ int PBO_Init(GrPBO& pbo, GLenum format, int w, int h, int num)
|
||||
return -2;
|
||||
}
|
||||
|
||||
pbo.fmt = format;
|
||||
pbo.width = w;
|
||||
pbo.height = h;
|
||||
pbo.num_pbos = num;
|
||||
pbo->fmt = format;
|
||||
pbo->width = w;
|
||||
pbo->height = h;
|
||||
pbo->num_pbos = num;
|
||||
|
||||
#if USE_PBO
|
||||
if (GL_RED == pbo.fmt || GL_GREEN == pbo.fmt || GL_BLUE == pbo.fmt) {
|
||||
pbo.nbytes = pbo.width * pbo.height;
|
||||
if (GL_RED == pbo->fmt || GL_GREEN == pbo->fmt || GL_BLUE == pbo->fmt) {
|
||||
pbo->nbytes = pbo->width * pbo->height;
|
||||
}
|
||||
else if (GL_RGB == pbo.fmt || GL_BGR == pbo.fmt)
|
||||
else if (GL_RGB == pbo->fmt || GL_BGR == pbo->fmt)
|
||||
{
|
||||
pbo.nbytes = pbo.width * pbo.height * 3;
|
||||
pbo->nbytes = pbo->width * pbo->height * 3;
|
||||
}
|
||||
else if (GL_RGBA == pbo.fmt || GL_BGRA == pbo.fmt) {
|
||||
pbo.nbytes = pbo.width * pbo.height * 4;
|
||||
else if (GL_RGBA == pbo->fmt || GL_BGRA == pbo->fmt) {
|
||||
pbo->nbytes = pbo->width * pbo->height * 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -142,20 +144,20 @@ int PBO_Init(GrPBO& pbo, GLenum format, int w, int h, int num)
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (pbo.nbytes == 0)
|
||||
if (pbo->nbytes == 0)
|
||||
{
|
||||
eprinterr("Invalid width or height given: %d x %d", pbo.width, pbo.height);
|
||||
eprinterr("Invalid width or height given: %d x %d", pbo->width, pbo->height);
|
||||
return -4;
|
||||
}
|
||||
|
||||
pbo.pbos = (GLuint*)malloc(sizeof(GLuint) * num);
|
||||
pbo.pixels = (u_char*)malloc(pbo.nbytes);
|
||||
pbo->pbos = (GLuint*)malloc(sizeof(GLuint) * num);
|
||||
pbo->pixels = (u_char*)malloc(pbo->nbytes);
|
||||
|
||||
glGenBuffers(num, pbo.pbos);
|
||||
glGenBuffers(num, pbo->pbos);
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo.pbos[i]);
|
||||
glBufferData(GL_PIXEL_PACK_BUFFER, pbo.nbytes, NULL, GL_STREAM_READ);
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo->pbos[i]);
|
||||
glBufferData(GL_PIXEL_PACK_BUFFER, pbo->nbytes, NULL, GL_STREAM_READ);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
@ -163,79 +165,79 @@ int PBO_Init(GrPBO& pbo, GLenum format, int w, int h, int num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PBO_Destroy(GrPBO& pbo)
|
||||
void PBO_Destroy(GrPBO* pbo)
|
||||
{
|
||||
#if USE_PBO
|
||||
if(pbo.pbos)
|
||||
if(pbo->pbos)
|
||||
{
|
||||
glDeleteBuffers(pbo.num_pbos, pbo.pbos);
|
||||
glDeleteBuffers(pbo->num_pbos, pbo->pbos);
|
||||
|
||||
free(pbo.pbos);
|
||||
pbo.num_pbos = 0;
|
||||
pbo.pbos = NULL;
|
||||
free(pbo->pbos);
|
||||
pbo->num_pbos = 0;
|
||||
pbo->pbos = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (pbo.pixels)
|
||||
if (pbo->pixels)
|
||||
{
|
||||
free(pbo.pixels);
|
||||
pbo.pixels = NULL;
|
||||
free(pbo->pixels);
|
||||
pbo->pixels = NULL;
|
||||
}
|
||||
|
||||
pbo.num_downloads = 0;
|
||||
pbo.dx = 0;
|
||||
pbo.fmt = 0;
|
||||
pbo.nbytes = 0;
|
||||
pbo->num_downloads = 0;
|
||||
pbo->dx = 0;
|
||||
pbo->fmt = 0;
|
||||
pbo->nbytes = 0;
|
||||
}
|
||||
|
||||
void PBO_Download(GrPBO& pbo)
|
||||
void PBO_Download(GrPBO* pbo)
|
||||
{
|
||||
unsigned char* ptr;
|
||||
|
||||
#if USE_PBO
|
||||
if (pbo.num_downloads < pbo.num_pbos)
|
||||
if (pbo->num_downloads < pbo->num_pbos)
|
||||
{
|
||||
/*
|
||||
First we need to make sure all our pbos are bound, so glMap/Unmap will
|
||||
read from the oldest bound buffer first.
|
||||
*/
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo.pbos[pbo.dx]);
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo->pbos[pbo->dx]);
|
||||
|
||||
#if defined(RENDERER_OGL)
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, pbo.fmt, GL_UNSIGNED_BYTE, 0);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, pbo->fmt, GL_UNSIGNED_BYTE, 0);
|
||||
#else
|
||||
glReadPixels(0, 0, pbo.width, pbo.height, pbo.fmt, GL_UNSIGNED_BYTE, 0); /* When a GL_PIXEL_PACK_BUFFER is bound, the last 0 is used as offset into the buffer to read into. */
|
||||
glReadPixels(0, 0, pbo->width, pbo->height, pbo->fmt, GL_UNSIGNED_BYTE, 0); /* When a GL_PIXEL_PACK_BUFFER is bound, the last 0 is used as offset into the buffer to read into. */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read from the oldest bound pbo. */
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo.pbos[pbo.dx]);
|
||||
/* Read from the oldest bound pbo */
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo->pbos[pbo->dx]);
|
||||
|
||||
#if defined(RENDERER_OGL)
|
||||
ptr = (unsigned char*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
if (NULL != ptr)
|
||||
{
|
||||
memcpy(pbo.pixels, ptr, pbo.nbytes);
|
||||
memcpy(pbo->pixels, ptr, pbo->nbytes);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
}
|
||||
else
|
||||
eprintwarn("Failed to map the buffer\n");
|
||||
|
||||
/* Trigger the next read. */
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, pbo.fmt, GL_UNSIGNED_BYTE, 0);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, pbo->fmt, GL_UNSIGNED_BYTE, 0);
|
||||
#else
|
||||
glReadPixels(0, 0, pbo.width, pbo.height, GL_RGBA, GL_UNSIGNED_BYTE, pbo.pixels);
|
||||
glReadPixels(0, 0, pbo->width, pbo->height, GL_RGBA, GL_UNSIGNED_BYTE, pbo->pixels);
|
||||
#endif
|
||||
}
|
||||
|
||||
++pbo.dx;
|
||||
pbo.dx = pbo.dx % pbo.num_pbos;
|
||||
++pbo->dx;
|
||||
pbo->dx = pbo->dx % pbo->num_pbos;
|
||||
|
||||
pbo.num_downloads++;
|
||||
pbo->num_downloads++;
|
||||
|
||||
if (pbo.num_downloads == UINT64_MAX)
|
||||
pbo.num_downloads = pbo.num_pbos;
|
||||
if (pbo->num_downloads == UINT64_MAX)
|
||||
pbo->num_downloads = pbo->num_pbos;
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
#else
|
||||
@ -243,7 +245,7 @@ void PBO_Download(GrPBO& pbo)
|
||||
// Do not use at all
|
||||
|
||||
// glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); /* just make sure we're not accidentilly using a PBO. */
|
||||
// glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pbo.pixels);
|
||||
// glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pbo->pixels);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -493,8 +495,8 @@ void GR_Shutdown()
|
||||
glDeleteVertexArrays(2, g_glVertexArray);
|
||||
glDeleteBuffers(2, g_glVertexBuffer);
|
||||
|
||||
PBO_Destroy(g_glFramebufferPBO);
|
||||
PBO_Destroy(g_glOffscreenPBO);
|
||||
PBO_Destroy(&g_glFramebufferPBO);
|
||||
PBO_Destroy(&g_glOffscreenPBO);
|
||||
|
||||
glDeleteFramebuffers(1, &g_glBlitFramebuffer);
|
||||
glDeleteFramebuffers(1, &g_glOffscreenFramebuffer);
|
||||
@ -524,7 +526,7 @@ void GR_BeginScene()
|
||||
|
||||
if (g_wireframeMode)
|
||||
{
|
||||
GR_SetWireframe(true);
|
||||
GR_SetWireframe(1);
|
||||
|
||||
#if defined(USE_OPENGL)
|
||||
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
@ -535,7 +537,7 @@ void GR_BeginScene()
|
||||
|
||||
void GR_EndScene()
|
||||
{
|
||||
framebuffer_need_update = true;
|
||||
framebuffer_need_update = 1;
|
||||
|
||||
if (g_wireframeMode)
|
||||
GR_SetWireframe(0);
|
||||
@ -554,7 +556,7 @@ void GR_ResetDevice()
|
||||
PsyX_EnableSwapInterval(g_enableSwapInterval);
|
||||
}
|
||||
|
||||
struct GTEShader
|
||||
typedef struct
|
||||
{
|
||||
// shader itself
|
||||
ShaderID shader;
|
||||
@ -564,7 +566,7 @@ struct GTEShader
|
||||
GLint projection3DLoc;
|
||||
GLint bilinearFilterLoc;
|
||||
#endif
|
||||
};
|
||||
} GTEShader;
|
||||
|
||||
GTEShader g_gte_shader_4;
|
||||
GTEShader g_gte_shader_8;
|
||||
@ -964,16 +966,16 @@ TextureID GR_CreateRGBATexture(int width, int height, u_char* data /*= nullptr*/
|
||||
return newTexture;
|
||||
}
|
||||
|
||||
void GR_CompilePSXShader(GTEShader& sh, const char* source)
|
||||
void GR_CompilePSXShader(GTEShader* sh, const char* source)
|
||||
{
|
||||
sh.shader = GR_Shader_Compile(source);
|
||||
sh->shader = GR_Shader_Compile(source);
|
||||
|
||||
#if defined(USE_OPENGL)
|
||||
|
||||
sh.bilinearFilterLoc = glGetUniformLocation(sh.shader, "bilinearFilter");
|
||||
sh.projectionLoc = glGetUniformLocation(sh.shader, "Projection");
|
||||
sh->bilinearFilterLoc = glGetUniformLocation(sh->shader, "bilinearFilter");
|
||||
sh->projectionLoc = glGetUniformLocation(sh->shader, "Projection");
|
||||
#ifdef USE_PGXP
|
||||
sh.projection3DLoc = glGetUniformLocation(sh.shader, "Projection3D");
|
||||
sh->projection3DLoc = glGetUniformLocation(sh->shader, "Projection3D");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -981,9 +983,9 @@ void GR_CompilePSXShader(GTEShader& sh, const char* source)
|
||||
|
||||
void GR_InitialisePSXShaders()
|
||||
{
|
||||
GR_CompilePSXShader(g_gte_shader_4, gte_shader_4);
|
||||
GR_CompilePSXShader(g_gte_shader_8, gte_shader_8);
|
||||
GR_CompilePSXShader(g_gte_shader_16, gte_shader_16);
|
||||
GR_CompilePSXShader(&g_gte_shader_4, gte_shader_4);
|
||||
GR_CompilePSXShader(&g_gte_shader_8, gte_shader_8);
|
||||
GR_CompilePSXShader(&g_gte_shader_16, gte_shader_16);
|
||||
}
|
||||
|
||||
int GR_InitialisePSX()
|
||||
@ -1000,7 +1002,7 @@ int GR_InitialisePSX()
|
||||
// gen framebuffer
|
||||
{
|
||||
memset(&g_glFramebufferPBO, 0, sizeof(g_glFramebufferPBO));
|
||||
PBO_Init(g_glFramebufferPBO, GL_RGBA, VRAM_WIDTH, VRAM_HEIGHT, 2);
|
||||
PBO_Init(&g_glFramebufferPBO, GL_RGBA, VRAM_WIDTH, VRAM_HEIGHT, 2);
|
||||
|
||||
// make a special texture
|
||||
// it will be resized later
|
||||
@ -1032,7 +1034,7 @@ int GR_InitialisePSX()
|
||||
// gen offscreen RT
|
||||
{
|
||||
memset(&g_glOffscreenPBO, 0, sizeof(g_glOffscreenPBO));
|
||||
PBO_Init(g_glOffscreenPBO, GL_RGBA, VRAM_WIDTH, VRAM_HEIGHT, 2);
|
||||
PBO_Init(&g_glOffscreenPBO, GL_RGBA, VRAM_WIDTH, VRAM_HEIGHT, 2);
|
||||
|
||||
// offscreen texture render target
|
||||
glGenTextures(1, &g_offscreenRTTexture);
|
||||
@ -1176,36 +1178,41 @@ void GR_Perspective3D(const float fov, const float width, const float height, co
|
||||
#endif
|
||||
}
|
||||
|
||||
void GR_SetupClipMode(const RECT16& rect, int enable)
|
||||
void GR_SetupClipMode(const RECT16* rect, int enable)
|
||||
{
|
||||
float emuScreenAspect, flipOffset;
|
||||
float psxScreenW, psxScreenH;
|
||||
float clipRectX, clipRectY, clipRectW, clipRectH;
|
||||
int scissorOn;
|
||||
|
||||
// [A] isinterlaced dirty hack for widescreen
|
||||
bool scissorOn = enable && (activeDispEnv.isinter ||
|
||||
(rect.x - activeDispEnv.disp.x > 0 ||
|
||||
rect.y - activeDispEnv.disp.y > 0 ||
|
||||
rect.w < activeDispEnv.disp.w - 1 ||
|
||||
rect.h < activeDispEnv.disp.h - 1));
|
||||
scissorOn = enable && (activeDispEnv.isinter ||
|
||||
( rect->x - activeDispEnv.disp.x > 0 ||
|
||||
rect->y - activeDispEnv.disp.y > 0 ||
|
||||
rect->w < activeDispEnv.disp.w - 1 ||
|
||||
rect->h < activeDispEnv.disp.h - 1));
|
||||
|
||||
GR_SetScissorState(scissorOn);
|
||||
|
||||
if (!scissorOn)
|
||||
return;
|
||||
|
||||
float psxScreenW = activeDispEnv.disp.w;
|
||||
float psxScreenH = activeDispEnv.disp.h;
|
||||
psxScreenW = activeDispEnv.disp.w;
|
||||
psxScreenH = activeDispEnv.disp.h;
|
||||
|
||||
// first map to 0..1
|
||||
float clipRectX = (float)(rect.x - activeDispEnv.disp.x) / psxScreenW;
|
||||
float clipRectY = (float)(rect.y - activeDispEnv.disp.y) / psxScreenH;
|
||||
float clipRectW = (float)(rect.w) / psxScreenW;
|
||||
float clipRectH = (float)(rect.h) / psxScreenH;
|
||||
clipRectX = (float)(rect->x - activeDispEnv.disp.x) / psxScreenW;
|
||||
clipRectY = (float)(rect->y - activeDispEnv.disp.y) / psxScreenH;
|
||||
clipRectW = (float)(rect->w) / psxScreenW;
|
||||
clipRectH = (float)(rect->h) / psxScreenH;
|
||||
|
||||
// then map to screen
|
||||
{
|
||||
clipRectX -= 0.5f;
|
||||
#ifdef USE_PGXP
|
||||
float emuScreenAspect = float(g_windowWidth) / float(g_windowHeight);
|
||||
emuScreenAspect = (float)(g_windowWidth) / (float)(g_windowHeight);
|
||||
#else
|
||||
float emuScreenAspect = (320.0f / 240.0f);
|
||||
emuScreenAspect = (320.0f / 240.0f);
|
||||
#endif
|
||||
|
||||
clipRectX /= PSX_SCREEN_ASPECT * emuScreenAspect;
|
||||
@ -1215,7 +1222,7 @@ void GR_SetupClipMode(const RECT16& rect, int enable)
|
||||
}
|
||||
|
||||
#if defined(USE_OPENGL)
|
||||
float flipOffset = g_windowHeight - clipRectH * (float)g_windowHeight;
|
||||
flipOffset = g_windowHeight - clipRectH * (float)g_windowHeight;
|
||||
|
||||
glScissor(clipRectX * (float)g_windowWidth,
|
||||
flipOffset - clipRectY * (float)g_windowHeight,
|
||||
@ -1227,10 +1234,13 @@ void GR_SetupClipMode(const RECT16& rect, int enable)
|
||||
void PsyX_GetPSXWidescreenMappedViewport(struct _RECT16* rect)
|
||||
{
|
||||
#ifdef USE_PGXP
|
||||
float emuScreenAspect = float(g_windowWidth) / float(g_windowHeight);
|
||||
float psxScreenW, psxScreenH;
|
||||
float emuScreenAspect;
|
||||
|
||||
float psxScreenW = activeDispEnv.disp.w;
|
||||
float psxScreenH = activeDispEnv.disp.h;
|
||||
emuScreenAspect = (float)(g_windowWidth) / (float)(g_windowHeight);
|
||||
|
||||
psxScreenW = activeDispEnv.disp.w;
|
||||
psxScreenH = activeDispEnv.disp.h;
|
||||
|
||||
rect->x = activeDispEnv.screen.x;
|
||||
rect->y = activeDispEnv.screen.y;
|
||||
@ -1249,7 +1259,7 @@ void PsyX_GetPSXWidescreenMappedViewport(struct _RECT16* rect)
|
||||
#endif
|
||||
}
|
||||
|
||||
void GR_SetShader(const ShaderID& shader)
|
||||
void GR_SetShader(const ShaderID shader)
|
||||
{
|
||||
if (g_PreviousShader != shader)
|
||||
{
|
||||
@ -1407,7 +1417,7 @@ void GR_CopyRGBAFramebufferToVRAM(u_int* src, int x, int y, int w, int h, int up
|
||||
free(fb);
|
||||
|
||||
if (update_vram)
|
||||
vram_need_update = true;
|
||||
vram_need_update = 1;
|
||||
}
|
||||
|
||||
void GR_ReadFramebufferDataToVRAM()
|
||||
@ -1416,7 +1426,7 @@ void GR_ReadFramebufferDataToVRAM()
|
||||
if (!framebuffer_need_update)
|
||||
return;
|
||||
|
||||
framebuffer_need_update = false;
|
||||
framebuffer_need_update = 0;
|
||||
|
||||
x = g_PreviousFramebuffer.x;
|
||||
y = g_PreviousFramebuffer.y;
|
||||
@ -1428,7 +1438,7 @@ void GR_ReadFramebufferDataToVRAM()
|
||||
#if defined(USE_OPENGL)
|
||||
// reat the texture
|
||||
glBindTexture(GL_TEXTURE_2D, g_fbTexture);
|
||||
PBO_Download(g_glFramebufferPBO);
|
||||
PBO_Download(&g_glFramebufferPBO);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
GR_CopyRGBAFramebufferToVRAM((u_int*)g_glFramebufferPBO.pixels, x, y, w, h, 0, 0);
|
||||
#endif
|
||||
@ -1449,7 +1459,7 @@ void GR_SetScissorState(int enable)
|
||||
g_PreviousScissorState = enable;
|
||||
}
|
||||
|
||||
void GR_SetOffscreenState(const RECT16& offscreenRect, int enable)
|
||||
void GR_SetOffscreenState(const RECT16* offscreenRect, int enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
@ -1467,7 +1477,7 @@ void GR_SetOffscreenState(const RECT16& offscreenRect, int enable)
|
||||
|
||||
#define PGXP_FOV_FACTOR 0.9265f
|
||||
|
||||
const float emuScreenAspect = float(g_windowWidth) / float(g_windowHeight);
|
||||
const float emuScreenAspect = (float)(g_windowWidth) / (float)(g_windowHeight);
|
||||
|
||||
GR_Ortho2D(-0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f * emuScreenAspect * PSX_SCREEN_ASPECT, 0.5f, -0.5f, -1.0f, 1.0f);
|
||||
GR_Perspective3D(PGXP_FOV_FACTOR, 1.0f, 1.0f / (emuScreenAspect * PSX_SCREEN_ASPECT), g_pgxpZNear, g_pgxpZFar);
|
||||
@ -1485,17 +1495,17 @@ void GR_SetOffscreenState(const RECT16& offscreenRect, int enable)
|
||||
if (enable)
|
||||
{
|
||||
// set storage size first
|
||||
if (g_PreviousOffscreen.w != offscreenRect.w &&
|
||||
g_PreviousOffscreen.h != offscreenRect.h)
|
||||
if (g_PreviousOffscreen.w != offscreenRect->w &&
|
||||
g_PreviousOffscreen.h != offscreenRect->h)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, g_offscreenRTTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, offscreenRect.w, offscreenRect.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, offscreenRect->w, offscreenRect->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
g_PreviousOffscreen = offscreenRect;
|
||||
g_PreviousOffscreen = *offscreenRect;
|
||||
|
||||
GR_SetViewPort(0, 0, offscreenRect.w, offscreenRect.h);
|
||||
GR_SetViewPort(0, 0, offscreenRect->w, offscreenRect->h);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, g_glOffscreenFramebuffer);
|
||||
|
||||
// clear it out
|
||||
@ -1534,7 +1544,7 @@ void GR_SetOffscreenState(const RECT16& offscreenRect, int enable)
|
||||
// reat the texture
|
||||
glBindTexture(GL_TEXTURE_2D, g_offscreenRTTexture);
|
||||
//glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
PBO_Download(g_glOffscreenPBO);
|
||||
PBO_Download(&g_glOffscreenPBO);
|
||||
glBindTexture(GL_TEXTURE_2D, g_lastBoundTexture);
|
||||
|
||||
// Don't forcely update VRAM
|
||||
@ -1611,13 +1621,13 @@ void GR_StoreFrameBuffer(int x, int y, int w, int h)
|
||||
|
||||
void GR_CopyVRAM(unsigned short* src, int x, int y, int w, int h, int dst_x, int dst_y)
|
||||
{
|
||||
vram_need_update = true;
|
||||
vram_need_update = 1;
|
||||
|
||||
int stride = w;
|
||||
|
||||
if (!src)
|
||||
{
|
||||
framebuffer_need_update = true;
|
||||
framebuffer_need_update = 1;
|
||||
|
||||
src = vram;
|
||||
stride = VRAM_WIDTH;
|
||||
@ -1650,7 +1660,7 @@ void GR_UpdateVRAM()
|
||||
if (!vram_need_update)
|
||||
return;
|
||||
|
||||
vram_need_update = false;
|
||||
vram_need_update = 0;
|
||||
|
||||
#if defined(USE_OPENGL)
|
||||
g_vramTexture = g_vramTexturesDouble[g_vramTextureIdx];
|
||||
@ -1778,7 +1788,7 @@ void GR_SetViewPort(int x, int y, int width, int height)
|
||||
#endif
|
||||
}
|
||||
|
||||
void GR_SetWireframe(bool enable)
|
||||
void GR_SetWireframe(int enable)
|
||||
{
|
||||
#if defined(RENDERER_OGL)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, enable ? GL_LINE : GL_FILL);
|
@ -17,6 +17,7 @@ void Util_InitHPCTimer(timerCtx_t* timer)
|
||||
|
||||
double Util_GetHPCTime(timerCtx_t* timer, int reset)
|
||||
{
|
||||
double value;
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER curr;
|
||||
LARGE_INTEGER performanceFrequency;
|
||||
@ -24,7 +25,7 @@ double Util_GetHPCTime(timerCtx_t* timer, int reset)
|
||||
QueryPerformanceFrequency(&performanceFrequency);
|
||||
QueryPerformanceCounter(&curr);
|
||||
|
||||
double value = double(curr.QuadPart - timer->clockStart) / double(performanceFrequency.QuadPart);
|
||||
value = (double)(curr.QuadPart - timer->clockStart) / (double)(performanceFrequency.QuadPart);
|
||||
|
||||
if (reset)
|
||||
timer->clockStart = curr.QuadPart;
|
||||
@ -33,7 +34,7 @@ double Util_GetHPCTime(timerCtx_t* timer, int reset)
|
||||
|
||||
gettimeofday(&curr, NULL);
|
||||
|
||||
double value = (double(curr.tv_sec - timer->timeStart.tv_sec) + double(curr.tv_usec - timer->timeStart.tv_usec) * 0.000001);
|
||||
value = ((double)(curr.tv_sec - timer->timeStart.tv_sec) + (double)(curr.tv_usec - timer->timeStart.tv_usec) * 0.000001);
|
||||
|
||||
if (reset)
|
||||
timer->timeStart = curr;
|
||||
|
@ -61,7 +61,7 @@ void FreeCameraMouseHandler(int x, int y)
|
||||
extern SVECTOR g_FreeCameraRotation;
|
||||
|
||||
int width, height;
|
||||
PsyX_GetScreenSize(width, height);
|
||||
PsyX_GetScreenSize(&width, &height);
|
||||
|
||||
cursorX = x;
|
||||
cursorY = y;
|
||||
@ -79,7 +79,7 @@ void FreeCameraMouseHandler(int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void FreeCameraKeyboardHandler(int nKey, bool down)
|
||||
void FreeCameraKeyboardHandler(int nKey, char down)
|
||||
{
|
||||
if (g_FreeCameraEnabled)
|
||||
{
|
||||
@ -638,7 +638,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// configure Psy-X CD image reader
|
||||
if (cdImageFileName)
|
||||
PsyX_CDFS_Init(cdImageFileName);
|
||||
PsyX_CDFS_Init(cdImageFileName, 0, 0);
|
||||
|
||||
if (config)
|
||||
{
|
||||
|
@ -150,13 +150,10 @@ int UnpackJPEG(unsigned char* src_buf, unsigned src_length, unsigned bpp, unsign
|
||||
return 0;
|
||||
}
|
||||
|
||||
// emulator window TODO: interface
|
||||
extern int g_swapInterval;
|
||||
|
||||
void SetupMovieRectangle(int image_w, int image_h)
|
||||
{
|
||||
int windowWidth, windowHeight;
|
||||
PsyX_GetScreenSize(windowWidth, windowHeight);
|
||||
PsyX_GetScreenSize(&windowWidth, &windowHeight);
|
||||
|
||||
float psxScreenW = 320.0f;
|
||||
float psxScreenH = 200.0f; // FIXME: NTSC scaling
|
||||
@ -256,12 +253,6 @@ const char* fmv_shader =
|
||||
TextureID g_FMVTexture = 0;
|
||||
ShaderID g_FMVShader = 0;
|
||||
|
||||
extern int GR_Shader_CheckShaderStatus(GLuint shader);
|
||||
extern int GR_Shader_CheckProgramStatus(GLuint program);
|
||||
|
||||
extern ShaderID GR_Shader_Compile(const char* source);
|
||||
extern void GR_SetShader(const ShaderID& shader);
|
||||
|
||||
#define DECODE_BUFFER_ALLOC (3840 * 2160 * 3) // RGB in 4K frame
|
||||
|
||||
u_char* g_FMVDecodedImageBuffer = NULL;
|
||||
@ -451,7 +442,7 @@ extern void GR_Ortho2D(float left, float right, float bottom, float top, float z
|
||||
void DrawFrame(ReadAVI::stream_format_t& stream_format, int frame_number, int credits, int image_w, int image_h)
|
||||
{
|
||||
int windowWidth, windowHeight;
|
||||
PsyX_GetScreenSize(windowWidth, windowHeight);
|
||||
PsyX_GetScreenSize(&windowWidth, &windowHeight);
|
||||
|
||||
PsyX_BeginScene();
|
||||
|
||||
@ -690,7 +681,7 @@ int FMV_main(RENDER_ARGS* args)
|
||||
PutDrawEnv(&draw);
|
||||
PutDispEnv(&disp);
|
||||
|
||||
GR_SetupClipMode(draw.clip, draw.dfe);
|
||||
GR_SetupClipMode(&draw.clip, draw.dfe);
|
||||
|
||||
for (int i = 0; i < args->nRenders; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user