From 87621be8f6f600d450924006f738045fb531f9e1 Mon Sep 17 00:00:00 2001 From: SoapyMan Date: Mon, 21 Dec 2020 23:10:29 +0600 Subject: [PATCH] - giving some love and compilation fixes to linux build - [Psy-X] api improvements --- src_rebuild/GAME/REVERSING.H | 2 +- src_rebuild/PsyX/EMULATOR.C | 39 +++++++-------- src_rebuild/PsyX/EMULATOR.H | 1 + src_rebuild/PsyX/LIBGPU.C | 2 +- src_rebuild/PsyX/TYPES.H | 28 +---------- src_rebuild/PsyX/premake5.lua | 5 +- src_rebuild/premake5.lua | 5 +- .../utils/video_source/VideoPlayer.cpp | 47 ++++++++++++++----- 8 files changed, 66 insertions(+), 63 deletions(-) diff --git a/src_rebuild/GAME/REVERSING.H b/src_rebuild/GAME/REVERSING.H index 939696ac..6158ec41 100644 --- a/src_rebuild/GAME/REVERSING.H +++ b/src_rebuild/GAME/REVERSING.H @@ -51,7 +51,7 @@ template struct compile_time_assert_test {}; #endif #if defined(_DEBUG) -#define UNIMPLEMENTED() { static bool _stop = false; if(!_stop) printMsg("[GAME] " FUNCNAME " - unimplemented!\n"); _stop = true; } +#define UNIMPLEMENTED() { static bool _stop = false; if(!_stop) printMsg("[GAME] %s - unimplemented!\n", FUNCNAME); _stop = true; } #else #define UNIMPLEMENTED() #endif diff --git a/src_rebuild/PsyX/EMULATOR.C b/src_rebuild/PsyX/EMULATOR.C index a5977315..0e8326c2 100644 --- a/src_rebuild/PsyX/EMULATOR.C +++ b/src_rebuild/PsyX/EMULATOR.C @@ -1477,20 +1477,11 @@ void Emulator_SetupClipMode(const RECT16& rect) clipRectX += 0.5f; } - if(g_PreviousScissorState != enabled) - { - g_PreviousScissorState = enabled; -#if defined(RENDERER_OGL) || defined(OGLES) - if (!enabled) - { - glDisable(GL_SCISSOR_TEST); - return; - } - - glEnable(GL_SCISSOR_TEST); -#endif - } - + Emulator_SetScissorState(enabled); + + if(!enabled) + return; + #if defined(RENDERER_OGL) || defined(OGLES) float flipOffset = g_windowHeight - clipRectH * (float)g_windowHeight; @@ -1704,6 +1695,20 @@ void Emulator_ReadFramebufferDataToVRAM() // vram_need_update = true; } +void Emulator_SetScissorState(int enable) +{ + if(g_PreviousScissorState == enable) + return; + +#if defined(RENDERER_OGL) || defined(OGLES) + if (g_PreviousScissorState) + glDisable(GL_SCISSOR_TEST); + else + glEnable(GL_SCISSOR_TEST); +#endif + g_PreviousScissorState = enable; +} + void Emulator_StoreFrameBuffer(int x, int y, int w, int h) { #if defined(RENDERER_OGL) || defined(OGLES) @@ -1711,11 +1716,7 @@ void Emulator_StoreFrameBuffer(int x, int y, int w, int h) if (g_PreviousFramebuffer.w != w && g_PreviousFramebuffer.h != h) { - if (g_PreviousScissorState) - { - glDisable(GL_SCISSOR_TEST); - g_PreviousScissorState = 0; - } + Emulator_SetScissorState(0); glBindTexture(GL_TEXTURE_2D, g_fbTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); diff --git a/src_rebuild/PsyX/EMULATOR.H b/src_rebuild/PsyX/EMULATOR.H index 9f53977f..f40eb479 100644 --- a/src_rebuild/PsyX/EMULATOR.H +++ b/src_rebuild/PsyX/EMULATOR.H @@ -194,6 +194,7 @@ extern void Emulator_SetBlendMode(BlendMode blendMode); extern void Emulator_SetPolygonOffset(float ofs); extern void Emulator_SetStencilMode(int drawPrim); extern void Emulator_EnableDepth(int enable); +extern void Emulator_SetScissorState(int enable); extern void Emulator_LineSwapSourceVerts(VERTTYPE* &p0, VERTTYPE* &p1, unsigned char* &c0, unsigned char* &c1); extern void Emulator_GenerateLineArray(struct Vertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx); diff --git a/src_rebuild/PsyX/LIBGPU.C b/src_rebuild/PsyX/LIBGPU.C index 7051af4c..0ea9aeac 100644 --- a/src_rebuild/PsyX/LIBGPU.C +++ b/src_rebuild/PsyX/LIBGPU.C @@ -367,7 +367,7 @@ u_long* ClearOTagR(u_long* ot, int n) setlen(ot, 0); // initialize a linked list with it's previous items - for (int i = P_LEN; i < n * P_LEN; i += P_LEN) + for (int i = 1 * P_LEN; i < n * P_LEN; i += P_LEN) { setaddr(&ot[i], &ot[i - P_LEN]); setlen(&ot[i], 0); diff --git a/src_rebuild/PsyX/TYPES.H b/src_rebuild/PsyX/TYPES.H index 0eed6b17..e423880b 100644 --- a/src_rebuild/PsyX/TYPES.H +++ b/src_rebuild/PsyX/TYPES.H @@ -1,5 +1,5 @@ -#ifndef _SYS_TYPES_H -#define _SYS_TYPES_H +#ifndef TYPES_H +#define TYPES_H #include "PSYX_CONFIG.H" @@ -49,30 +49,6 @@ typedef unsigned long ulong; /* sys V compat */ #endif #endif /* ! __psx__ */ -#if !__APPLE__ -typedef struct _physadr { int r[1]; } *physadr; -typedef struct label_t { - int val[12]; -} label_t; - -#if !defined(__ANDROID__) -typedef struct _quad { long val[2]; } quad; -typedef long daddr_t; -typedef char * caddr_t; -typedef long * qaddr_t; -//typedef u_long ino_t; -typedef long swblk_t; -#endif - - -//typedef long time_t; -//typedef short dev_t; -//typedef long off_t; -//typedef u_short uid_t; -//typedef u_short gid_t; - -#endif - #define NBBY 8 #endif diff --git a/src_rebuild/PsyX/premake5.lua b/src_rebuild/PsyX/premake5.lua index 69bade2a..969bd29a 100644 --- a/src_rebuild/PsyX/premake5.lua +++ b/src_rebuild/PsyX/premake5.lua @@ -22,12 +22,11 @@ project "Psy-X" includedirs { SDL2_DIR.."/include", - OPENAL_DIR.."/include", - OPENAL_DIR.."/include", + OPENAL_DIR.."/include" } filter "system:Windows" - defines { "_WINDOWS" } + defines { "_WINDOWS" } links { "opengl32", "SDL2", diff --git a/src_rebuild/premake5.lua b/src_rebuild/premake5.lua index db86c993..9308d052 100644 --- a/src_rebuild/premake5.lua +++ b/src_rebuild/premake5.lua @@ -47,7 +47,8 @@ workspace "REDRIVER2" filter "configurations:Debug" defines { - "DEBUG", + "_DEBUG", + "DEBUG" } symbols "On" @@ -182,4 +183,4 @@ project "REDRIVER2" "COLLISION_DEBUG", "CUTSCENE_RECORDER" } - optimize "Speed" \ No newline at end of file + optimize "Speed" diff --git a/src_rebuild/utils/video_source/VideoPlayer.cpp b/src_rebuild/utils/video_source/VideoPlayer.cpp index 55593446..63d48948 100644 --- a/src_rebuild/utils/video_source/VideoPlayer.cpp +++ b/src_rebuild/utils/video_source/VideoPlayer.cpp @@ -158,7 +158,6 @@ void SetupMovieRectangle(int image_w, int image_h) int windowWidth, windowHeight; Emulator_GetScreenSize(windowWidth, windowHeight); - float psxScreenW = 320.0f; float psxScreenH = 200.0f; // FIXME: NTSC scaling @@ -183,16 +182,38 @@ void SetupMovieRectangle(int image_w, int image_h) u_char r = 1; u_char b = 1; +#ifdef USE_PGXP + Emulator_SetViewPort(0, 0, windowWidth, windowHeight); + Vertex blit_vertices[] = { - { clipRectX+ clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, - { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, - { clipRectX, clipRectY + clipRectH, 0, 0, l, t, 0, 0, 0, 0, 0, 0 }, + { clipRectX+ clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY + clipRectH, 0, 0, l, t, 0, 0, 0, 0, 0, 0 }, - { clipRectX + clipRectW, clipRectY, 0, 0, r, b, 0, 0, 0, 0, 0, 0 }, - { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, - { clipRectX + clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, + { clipRectX + clipRectW, clipRectY, 0, 0, r, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX + clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, }; +#else + Emulator_SetViewPort(0, 0, windowWidth, windowHeight); + + clipRectX *= 2; + clipRectY *= 2; + clipRectW *= 2; + clipRectH *= 2; + + Vertex blit_vertices[] = + { + { clipRectX+ clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY + clipRectH, 0, 0, l, t, 0, 0, 0, 0, 0, 0 }, + + { clipRectX + clipRectW, clipRectY, 0, 0, r, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX, clipRectY, 0, 0, l, b, 0, 0, 0, 0, 0, 0 }, + { clipRectX + clipRectW, clipRectY + clipRectH, 0, 0, r, t, 0, 0, 0, 0, 0, 0 }, + }; +#endif Emulator_UpdateVertexBuffer(blit_vertices, 6); } @@ -437,14 +458,18 @@ void DrawFrame(ReadAVI::stream_format_t& stream_format, int frame_number, int cr glBindTexture(GL_TEXTURE_2D, g_FMVTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, image_w, image_h, 0, GL_RGB, GL_UNSIGNED_BYTE, g_FMVDecodedImageBuffer); - - Emulator_SetViewPort(0, 0, windowWidth, windowHeight); - Emulator_SetTexture(g_FMVTexture, (TexFormat)-1); + glBindTexture(GL_TEXTURE_2D, 0); + Emulator_SetShader(g_FMVShader); + Emulator_SetTexture(g_FMVTexture, (TexFormat)-1); + + Emulator_SetScissorState(0); + Emulator_EnableDepth(0); + Emulator_SetStencilMode(0); + Emulator_SetBlendMode(BM_NONE); SetupMovieRectangle(stream_format.image_width, stream_format.image_height); - Emulator_SetBlendMode(BM_NONE); Emulator_DrawTriangles(0, 2); DisplaySubtitles(frame_number);