From e3c741bb2a1724e2de91325b32f61e0f743a9cd6 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut" Date: Thu, 19 Apr 2012 21:22:08 +0000 Subject: [PATCH] zzogl: painfully merge the zzogl-dev branch * new memory management * asm was replaced by intrinsic * new GLSL backend (AMD only) Cmake is probably broken anyway with the 2 plugins... * and lots of others stuff that I forgot about it ;) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5166 96395faa-99c1-11dd-bbfe-3dabce05a288 --- cmake/BuildParameters.cmake | 8 + cmake/SearchForStuff.cmake | 4 +- cmake/SelectPcsx2Plugins.cmake | 14 +- pcsx2-codeblocks.workspace | 2 +- plugins/zzogl-pg/opengl/CMakeLists.txt | 43 +- plugins/zzogl-pg/opengl/GLWinX11.cpp | 11 + plugins/zzogl-pg/opengl/GS.h | 92 +- plugins/zzogl-pg/opengl/GSmain.cpp | 69 +- plugins/zzogl-pg/opengl/GifTransfer.cpp | 56 +- plugins/zzogl-pg/opengl/HostMemory.cpp | 238 +- plugins/zzogl-pg/opengl/HostMemory.h | 8 +- plugins/zzogl-pg/opengl/Linux/Linux.cpp | 8 +- .../opengl/Linux/zzogl-pg/zzogl-pg.cbp | 76 +- plugins/zzogl-pg/opengl/Mem.cpp | 68 +- plugins/zzogl-pg/opengl/Mem.h | 14 +- plugins/zzogl-pg/opengl/Mem_Swizzle.cpp | 30 +- plugins/zzogl-pg/opengl/Mem_Tables.cpp | 86 + plugins/zzogl-pg/opengl/Mem_Transmit.h | 47 +- plugins/zzogl-pg/opengl/NewRegs.cpp | 1144 -------- plugins/zzogl-pg/opengl/NewRegs.h | 973 ------- plugins/zzogl-pg/opengl/Regs.cpp | 228 +- plugins/zzogl-pg/opengl/Regs.h | 99 +- plugins/zzogl-pg/opengl/Util.h | 2 + plugins/zzogl-pg/opengl/ZZClut.cpp | 2 +- plugins/zzogl-pg/opengl/ZZDepthTargets.cpp | 314 +++ plugins/zzogl-pg/opengl/ZZGl.h | 241 +- plugins/zzogl-pg/opengl/ZZLog.cpp | 26 +- plugins/zzogl-pg/opengl/ZZMemoryTargets.cpp | 620 +++++ plugins/zzogl-pg/opengl/ZZRenderTargets.cpp | 1325 +++++++++ plugins/zzogl-pg/opengl/ZZoglCRTC.cpp | 236 +- plugins/zzogl-pg/opengl/ZZoglCRTC.h | 3 - plugins/zzogl-pg/opengl/ZZoglCreate.cpp | 100 +- plugins/zzogl-pg/opengl/ZZoglFlush.cpp | 670 ++--- plugins/zzogl-pg/opengl/ZZoglFlush.h | 123 + plugins/zzogl-pg/opengl/ZZoglMath.h | 2 +- plugins/zzogl-pg/opengl/ZZoglMem.cpp | 564 ++++ plugins/zzogl-pg/opengl/ZZoglMem.h | 790 ++++++ plugins/zzogl-pg/opengl/ZZoglSave.cpp | 5 +- plugins/zzogl-pg/opengl/ZZoglShaders.cpp | 124 +- plugins/zzogl-pg/opengl/ZZoglShaders.h | 101 +- plugins/zzogl-pg/opengl/ZZoglShadersGLSL.cpp | 979 +++++++ plugins/zzogl-pg/opengl/ps2hw.glsl | 812 ++++++ plugins/zzogl-pg/opengl/targets.cpp | 2403 +---------------- plugins/zzogl-pg/opengl/targets.h | 124 +- plugins/zzogl-pg/opengl/x86.cpp | 6 +- plugins/zzogl-pg/opengl/x86.h | 226 +- plugins/zzogl-pg/opengl/zerogs.cpp | 6 +- 47 files changed, 7412 insertions(+), 5710 deletions(-) delete mode 100644 plugins/zzogl-pg/opengl/NewRegs.cpp delete mode 100644 plugins/zzogl-pg/opengl/NewRegs.h create mode 100644 plugins/zzogl-pg/opengl/ZZDepthTargets.cpp create mode 100644 plugins/zzogl-pg/opengl/ZZMemoryTargets.cpp create mode 100644 plugins/zzogl-pg/opengl/ZZRenderTargets.cpp create mode 100644 plugins/zzogl-pg/opengl/ZZoglFlush.h create mode 100644 plugins/zzogl-pg/opengl/ZZoglMem.cpp create mode 100644 plugins/zzogl-pg/opengl/ZZoglMem.h create mode 100644 plugins/zzogl-pg/opengl/ZZoglShadersGLSL.cpp create mode 100644 plugins/zzogl-pg/opengl/ps2hw.glsl diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 542af6712f..52e33e63a1 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -8,6 +8,7 @@ # Use soundtouch internal lib: -DFORCE_INTERNAL_SOUNDTOUCH=TRUE # Use zlib internal lib: -DFORCE_INTERNAL_ZLIB=TRUE # Use sdl1.3 internal lib: -DFORCE_INTERNAL_SDL=TRUE # Not supported yet +# Use GLSL API(else NVIDIA_CG): -DGLSL_API=TRUE ### GCC optimization options # control C flags : -DUSER_CMAKE_C_FLAGS="cflags" @@ -183,3 +184,10 @@ if(PACKAGE_MODE) # Compile all source codes with these 2 defines add_definitions(-DPLUGIN_DIR_COMPILATION=${PLUGIN_DIR} -DGAMEINDEX_DIR_COMPILATION=${GAMEINDEX_DIR}) endif(PACKAGE_MODE) + +#------------------------------------------------------------------------------- +# Select nvidia cg shader api by default +#------------------------------------------------------------------------------- +if(NOT DEFINED FORCE_INTERNAL_SOUNDTOUCH) + set(GLSL_API FALSE) +endif(NOT DEFINED FORCE_INTERNAL_SOUNDTOUCH) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 6c776f100d..da39519c89 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -53,7 +53,9 @@ if(NOT FORCE_INTERNAL_ZLIB) endif(NOT FORCE_INTERNAL_ZLIB) ## Use pcsx2 package to find module -include(FindCg) +if(NOT GLSL_API) + include(FindCg) +endif(NOT GLSL_API) include(FindGlew) include(FindLibc) include(FindPortAudio) diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index 88bb76597e..4796a5344b 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -6,11 +6,15 @@ set(msg_dep_pcsx2 "check these libraries -> wxWidgets (>=2.8.10), gtk2 (>= set(msg_dep_cdvdiso "check these libraries -> bzip2 (>=1.0.5), gtk2 (>=2.16)") set(msg_dep_zerogs "check these libraries -> glew (>=1.5), opengl, X11, nvidia-cg-toolkit (>=2.1)") set(msg_dep_gsdx "check these libraries -> opengl, X11, pcsx2 SDL") -set(msg_dep_zzogl "check these libraries -> glew (>=1.5), jpeg (>=6.2), opengl, X11, nvidia-cg-toolkit (>=2.1), pcsx2 common libs") set(msg_dep_onepad "check these libraries -> sdl (>=1.2)") set(msg_dep_zeropad "check these libraries -> sdl (>=1.2)") set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), pcsx2 common libs") set(msg_dep_zerospu2 "check these libraries -> soundtouch (>=1.5), alsa") +if(GLSP_API) + set(msg_dep_zzogl "check these libraries -> glew (>=1.5), jpeg (>=6.2), opengl, X11, pcsx2 common libs") +else(GLSP_API) + set(msg_dep_zzogl "check these libraries -> glew (>=1.5), jpeg (>=6.2), opengl, X11, nvidia-cg-toolkit (>=2.1), pcsx2 common libs") +endif(GLSP_API) #------------------------------------------------------------------------------- # Pcsx2 core & common libs @@ -153,17 +157,17 @@ endif(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) # requires: -GLEW # -OpenGL # -X11 -# -CG +# -CG (only with cg build # -JPEG # -common_libs #--------------------------------------- -if(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND JPEG_FOUND AND common_libs) +if((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AND (CG_FOUND OR GLSL_API)) set(zzogl TRUE) -else(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND JPEG_FOUND AND common_libs) +else((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AND (CG_FOUND OR GLSL_API)) set(zzogl FALSE) message(STATUS "Skip build of zzogl: miss some dependencies") message(STATUS "${msg_dep_zzogl}") -endif(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND AND JPEG_FOUND AND common_libs) +endif((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AND (CG_FOUND OR GLSL_API)) #--------------------------------------- #--------------------------------------- diff --git a/pcsx2-codeblocks.workspace b/pcsx2-codeblocks.workspace index c5d3652b6f..9390014171 100644 --- a/pcsx2-codeblocks.workspace +++ b/pcsx2-codeblocks.workspace @@ -27,7 +27,7 @@ - + diff --git a/plugins/zzogl-pg/opengl/CMakeLists.txt b/plugins/zzogl-pg/opengl/CMakeLists.txt index c8bed7a170..5c40f84e65 100644 --- a/plugins/zzogl-pg/opengl/CMakeLists.txt +++ b/plugins/zzogl-pg/opengl/CMakeLists.txt @@ -45,6 +45,14 @@ if(CMAKE_BUILD_TYPE STREQUAL Release) add_definitions(${CommonFlags} ${OptimizationFlags} -W) endif(CMAKE_BUILD_TYPE STREQUAL Release) +# Select the shader API +if(GLSL_API) + add_definitions(-DGLSL_API) +else(GLSL_API) + add_definitions(-DNVIDIA_CG_API) +endif(GLSL_API) + + # zzogl sources set(zzoglSources GifTransfer.cpp @@ -54,17 +62,17 @@ set(zzoglSources GSmain.cpp HostMemory.cpp Mem.cpp - # memcpy_amd.cpp Mem_Swizzle.cpp Mem_Tables.cpp Profile.cpp rasterfont.cpp - NewRegs.cpp Regs.cpp targets.cpp - x86.cpp zerogs.cpp zpipe.cpp + ZZDepthTargets.cpp + ZZMemoryTargets.cpp + ZZRenderTargets.cpp ZZClut.cpp ZZHacks.cpp ZZKeyboard.cpp @@ -74,8 +82,10 @@ set(zzoglSources ZZoglCRTC.cpp ZZoglFlush.cpp ZZoglFlushHack.cpp + ZZoglMem.cpp ZZoglSave.cpp ZZoglShaders.cpp + ZZoglShadersGLSL.cpp ZZoglShoots.cpp ZZoglVB.cpp ) @@ -94,7 +104,6 @@ set(zzoglHeaders Mem_Transmit.h Profile.h rasterfont.h - NewRegs.h Regs.h targets.h Util.h @@ -102,21 +111,19 @@ set(zzoglHeaders zerogs.h zpipe.h ZZClut.h + ZZoglFlush.h ZZGl.h ZZHacks.h ZZoglDrawing.h ZZLog.h ZZoglCRTC.h ZZoglMath.h + ZZoglMem.h ZZoglShaders.h ZZoglShoots.h ZZoglVB.h ) -# zzogl S sources -set(zzoglSSources - x86-32.S) - # zzogl shader sources set(zzoglShaderSources ctx0/ps2hw_ctx.fx @@ -131,9 +138,6 @@ set(zzoglLinuxSources set(zzoglLinuxHeaders Linux/Linux.h) -# change language of .S-files to c++ -set_source_files_properties(${zzoglSSources} PROPERTIES LANGUAGE CXX) - # add additional include directories include_directories(. Linux) @@ -142,7 +146,6 @@ include_directories(. add_library(${Output} SHARED ${zzoglSources} ${zzoglHeaders} - ${zzoglSSources} ${zzoglShaderSources} ${zzoglLinuxSources} ${zzoglLinuxHeaders}) @@ -154,7 +157,9 @@ set_target_properties(${Output} PROPERTIES COMPILE_DEFINITIONS USE_GSOPEN2) target_link_libraries(${Output} Utilities) # link target with Cg -target_link_libraries(${Output} ${CG_LIBRARIES}) +if(NOT GLSP_API) + target_link_libraries(${Output} ${CG_LIBRARIES}) +endif(NOT GLSP_API) # link target with glew target_link_libraries(${Output} ${GLEW_LIBRARY}) @@ -183,10 +188,18 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "") if(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${PLUGIN_DIR}) + if(GLSL_API) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${PLUGIN_DIR}) + else(GLSL_API) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${PLUGIN_DIR}) + endif(GLSL_API) else(PACKAGE_MODE) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) - install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + if(GLSL_API) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + else(GLSL_API) + install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) + endif(GLSL_API) endif(PACKAGE_MODE) ################################### Replay Loader diff --git a/plugins/zzogl-pg/opengl/GLWinX11.cpp b/plugins/zzogl-pg/opengl/GLWinX11.cpp index 0730acc214..764cb9dfc3 100644 --- a/plugins/zzogl-pg/opengl/GLWinX11.cpp +++ b/plugins/zzogl-pg/opengl/GLWinX11.cpp @@ -198,13 +198,24 @@ void GLWindow::CreateContextGL() GLXFBConfig *framebuffer_config = glXChooseFBConfig(glDisplay, DefaultScreen(glDisplay), NULL, &fbcount); if (!framebuffer_config or !fbcount) return; +#if 1 // At least create a 3.0 context with compatibility profile int attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 0, + // GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; +#else + // Create a 3.2 core context without compatibility profile + int attribs[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 2, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; +#endif GLXContext context_temp = glXCreateContextAttribsARB(glDisplay, framebuffer_config[0], NULL, true, attribs); if (context_temp) { ZZLog::Error_Log("Create a 3.0 opengl context"); diff --git a/plugins/zzogl-pg/opengl/GS.h b/plugins/zzogl-pg/opengl/GS.h index 8bded3f4cc..04052bda1f 100644 --- a/plugins/zzogl-pg/opengl/GS.h +++ b/plugins/zzogl-pg/opengl/GS.h @@ -21,7 +21,7 @@ #define __GS_H__ -#define USE_OLD_REGS +#define ZZNORMAL_MEMORY #include "Util.h" #include "GifTransfer.h" @@ -39,6 +39,8 @@ extern float fFPS; extern int g_LastCRC; +#define VB_NUMBUFFERS 512 // number of vbo buffer allocated + struct Vector_16F { u16 x, y, z, w; @@ -132,21 +134,22 @@ extern GSconf conf; // PSM values // PSM types == Texture Storage Format -enum PSM_value -{ - PSMCT32 = 0, // 00 0000 - PSMCT24 = 1, // 00 0001 - PSMCT16 = 2, // 00 0010 - PSMCT16S = 10, // 00 1010 - PSMT8 = 19, // 01 0011 - PSMT4 = 20, // 01 0100 - PSMT8H = 27, // 01 1011 - PSMT4HL = 36, // 10 0100 - PSMT4HH = 44, // 10 1100 - PSMT32Z = 48, // 11 0000 - PSMT24Z = 49, // 11 0001 - PSMT16Z = 50, // 11 0010 - PSMT16SZ = 58, // 11 1010 +enum PSM_value{ + PSMCT32 = 0, // 000000 + PSMCT24 = 1, // 000001 + PSMCT16 = 2, // 000010 + PSMCT16S = 10, // 001010 + PSMT8 = 19, // 010011 + PSMT4 = 20, // 010100 + PSMT8H = 27, // 011011 + PSMT4HL = 36, // 100100 + PSMT4HH = 44, // 101100 + PSMT32Z = 48, // 110000 + PSMT24Z = 49, // 110001 + PSMT16Z = 50, // 110010 + PSMT16SZ = 58, // 111010 + + PSMT_BAD_PSM = 63 // for every unknown psm. }; // Check target bit mode. PSMCT32 and 32Z return 0, 24 and 24Z - 1 @@ -461,7 +464,6 @@ typedef struct { u16 aem; u8 ta[2]; - float fta[2]; } texaInfo; typedef struct @@ -503,6 +505,14 @@ typedef struct int fba; } fbaInfo; +enum transfer_types +{ + XFER_HOST_TO_LOCAL = 0, + XFER_LOCAL_TO_HOST = 1, + XFER_LOCAL_TO_LOCAL = 2, + XFER_DEACTIVATED = 3 +}; + typedef struct { Vertex gsvertex[4]; // circular buffer that contains the vertex @@ -537,15 +547,20 @@ typedef struct texaInfo texa; trxposInfo trxpos, trxposnew; - int imageWtemp, imageHtemp; - int imageTransfer; - int imageWnew, imageHnew, imageX, imageY, imageEndX, imageEndY; + bool transferring; + + Point image, imageEnd; + Size imageNew, imageTemp; pathInfo path[4]; GIFRegDIMX dimx; GSMemory mem; GSClut clut_buffer; + + // Subject to change. + int vsync, interlace; + int primNext(int inc = 1) { // Note: ArraySize(gsvertex) == 2^n => modulo is replaced by an and instruction @@ -615,7 +630,7 @@ static __forceinline u32 RGBA16to32(u16 c) (((c) & 0x8000) ? 0xff000000 : 0); } -#if 0 +#ifndef ZZNORMAL_MEMORY // converts float16 [0,1] to BYTE [0,255] (assumes value is in range, otherwise will take lower 8bits) // f is a u16 static __forceinline u16 Float16ToBYTE(u16 f) @@ -984,4 +999,39 @@ inline void CluttingForFlushedTex(tex0Info* tex0, u32 Data, int ictx) #define CPSM_CSA_BITMASK 0x1f780000 #define CPSM_CSA_NOTMASK 0xe0870000 +// I'll find a good place for these later. + +extern PSM_value PSM_value_Table[64]; +extern bool allowed_psm[256]; // in ZZoglMem.cpp.cpp +inline void FillAlowedPsnTable() { + + allowed_psm[PSMCT32] = true; + allowed_psm[PSMCT24] = true; + allowed_psm[PSMCT16] = true; + allowed_psm[PSMCT16S] = true; + allowed_psm[PSMT8] = true; + allowed_psm[PSMT4] = true; + allowed_psm[PSMT8H] = true; + allowed_psm[PSMT4HH] = true; + allowed_psm[PSMT4HL] = true; + allowed_psm[PSMT32Z] = true; + allowed_psm[PSMT24Z] = true; + allowed_psm[PSMT16Z] = true; + allowed_psm[PSMT16SZ] = true; + + PSM_value_Table[PSMCT32] = PSMCT32; + PSM_value_Table[PSMCT24] = PSMCT24; + PSM_value_Table[PSMCT16] = PSMCT16; + PSM_value_Table[PSMCT16S] = PSMCT16S; + PSM_value_Table[PSMT8] = PSMT8; + PSM_value_Table[PSMT4] = PSMT4; + PSM_value_Table[PSMT8H] = PSMT8H; + PSM_value_Table[PSMT4HH] = PSMT4HH; + PSM_value_Table[PSMT4HL] = PSMT4HL; + PSM_value_Table[PSMT32Z] = PSMT32Z; + PSM_value_Table[PSMT24Z] = PSMT24Z; + PSM_value_Table[PSMT16Z] = PSMT16Z; + PSM_value_Table[PSMT16SZ] = PSMT16SZ; +}; + #endif diff --git a/plugins/zzogl-pg/opengl/GSmain.cpp b/plugins/zzogl-pg/opengl/GSmain.cpp index af8a59173e..f92417edab 100644 --- a/plugins/zzogl-pg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg/opengl/GSmain.cpp @@ -22,6 +22,7 @@ #include "Profile.h" #include "GLWin.h" #include "ZZoglFlushHack.h" +#include "ZZoglShaders.h" using namespace std; @@ -82,7 +83,7 @@ extern int ZZSave(s8* pbydata); extern bool ZZLoad(s8* pbydata); // switches the render target to the real target, flushes the current render targets and renders the real image -extern void RenderCRTC(int interlace); +extern void RenderCRTC(); #if defined(_WIN32) && defined(_DEBUG) HANDLE g_hCurrentThread = NULL; @@ -91,37 +92,37 @@ HANDLE g_hCurrentThread = NULL; extern int VALIDATE_THRESH; extern u32 TEXDESTROY_THRESH; -u32 CALLBACK PS2EgetLibType() +EXPORT_C_(u32) PS2EgetLibType() { return PS2E_LT_GS; } -char* CALLBACK PS2EgetLibName() +EXPORT_C_(char*) PS2EgetLibName() { return libraryName; } -u32 CALLBACK PS2EgetLibVersion2(u32 type) +EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) { return (zgsversion << 16) | (zgsrevision << 8) | zgsbuild | (zgsminor << 24); } -void CALLBACK GSsetBaseMem(void* pmem) +EXPORT_C_(void) GSsetBaseMem(void* pmem) { g_pBasePS2Mem = (u8*)pmem; } -void CALLBACK GSsetSettingsDir(const char* dir) +EXPORT_C_(void) GSsetSettingsDir(const char* dir) { s_strIniPath = (dir == NULL) ? wxString(L"inis") : wxString(dir, wxConvFile); } -void CALLBACK GSsetLogDir(const char* dir) +EXPORT_C_(void) GSsetLogDir(const char* dir) { ZZLog::SetDir(dir); } -void CALLBACK GSsetGameCRC(int crc, int options) +EXPORT_C_(void) GSsetGameCRC(int crc, int options) { // build a list of function pointer for GetSkipCount (SkipDraw) static GetSkipCount GSC_list[NUMBER_OF_TITLES]; @@ -217,7 +218,7 @@ void CALLBACK GSsetGameCRC(int crc, int options) ListHacks(); } -void CALLBACK GSsetFrameSkip(int frameskip) +EXPORT_C_(void) GSsetFrameSkip(int frameskip) { FUNCLOG s_frameskipping |= frameskip; @@ -232,7 +233,7 @@ void CALLBACK GSsetFrameSkip(int frameskip) } } -void CALLBACK GSreset() +EXPORT_C_(void) GSreset() { FUNCLOG @@ -242,11 +243,11 @@ void CALLBACK GSreset() gs.prac = 1; prim = &gs._prim[0]; - gs.imageTransfer = -1; + gs.transferring = false; gs.q = 1; } -void CALLBACK GSgifSoftReset(u32 mask) +EXPORT_C_(void) GSgifSoftReset(u32 mask) { FUNCLOG @@ -254,11 +255,11 @@ void CALLBACK GSgifSoftReset(u32 mask) if (mask & 2) memset(&gs.path[1], 0, sizeof(gs.path[1])); if (mask & 4) memset(&gs.path[2], 0, sizeof(gs.path[2])); - gs.imageTransfer = -1; + gs.transferring = false; gs.q = 1; } -s32 CALLBACK GSinit() +EXPORT_C_(s32) GSinit() { FUNCLOG @@ -281,7 +282,7 @@ __forceinline void InitMisc() ResetRegs(); } -s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) +EXPORT_C_(s32) GSopen(void *pDsp, char *Title, int multithread) { FUNCLOG @@ -337,32 +338,34 @@ EXPORT_C_(s32) GSopen2( void* pDsp, u32 flags ) } #endif -void CALLBACK GSshutdown() +EXPORT_C_(void) GSshutdown() { FUNCLOG ZZLog::Close(); } -void CALLBACK GSclose() +EXPORT_C_(void) GSclose() { FUNCLOG ZZDestroy(); GLWin.CloseWindow(); + // Free alocated memory. We could close plugin without closing pcsx2, so we SHOULD free all allocated resources + ZZshExitCleaning(); SaveStateFile = NULL; SaveStateExists = true; // default value g_LastCRC = 0; } -void CALLBACK GSirqCallback(void (*callback)()) +EXPORT_C_(void) GSirqCallback(void (*callback)()) { FUNCLOG GSirq = callback; } -void CALLBACK GSwriteCSR(u32 write) +EXPORT_C_(void) GSwriteCSR(u32 write) { FUNCLOG @@ -373,7 +376,7 @@ void CALLBACK GSwriteCSR(u32 write) #define access _access #endif -void CALLBACK GSchangeSaveState(int newstate, const char* filename) +EXPORT_C_(void) GSchangeSaveState(int newstate, const char* filename) { FUNCLOG @@ -428,7 +431,7 @@ static bool get_snapshot_filename(char *filename, char* path, const char* extens return true; } -void CALLBACK GSmakeSnapshot(char *path) +EXPORT_C_(void) GSmakeSnapshot(char *path) { FUNCLOG @@ -474,7 +477,16 @@ static __forceinline void SetGSTitle() GLWin.SetTitle(strtitle); } -void CALLBACK GSvsync(int interlace) +// This isn't implemented for some reason? Adding a field for it for the moment, till I get a chance to look closer. +EXPORT_C_(void) GSsetVsync(int enabled) +{ + FUNCLOG + + ZZLog::Debug_Log("Setting VSync to 0x%x.", enabled); + gs.vsync = enabled; +} + +EXPORT_C_(void) GSvsync(int current_interlace) { FUNCLOG @@ -506,8 +518,9 @@ void CALLBACK GSvsync(int interlace) g_nRealFrame++; - // !interlace? Hmmm... Fixme. - RenderCRTC(!interlace); + // The value passed seems to either be 0 or 0x2000, and we want 0 or 1. Perhaps !! would be better... + gs.interlace = !current_interlace; + RenderCRTC(); GLWin.ProcessEvents(); @@ -559,7 +572,7 @@ void CALLBACK GSvsync(int interlace) } -void CALLBACK GSreadFIFO(u64 *pMem) +EXPORT_C_(void) GSreadFIFO(u64 *pMem) { FUNCLOG @@ -571,7 +584,7 @@ void CALLBACK GSreadFIFO(u64 *pMem) TransferLocalHost((u32*)pMem, 1); } -void CALLBACK GSreadFIFO2(u64 *pMem, int qwc) +EXPORT_C_(void) GSreadFIFO2(u64 *pMem, int qwc) { FUNCLOG @@ -583,7 +596,7 @@ void CALLBACK GSreadFIFO2(u64 *pMem, int qwc) TransferLocalHost((u32*)pMem, qwc); } -int CALLBACK GSsetupRecording(int start, void* pData) +EXPORT_C_(int) GSsetupRecording(int start, void* pData) { FUNCLOG @@ -595,7 +608,7 @@ int CALLBACK GSsetupRecording(int start, void* pData) return 1; } -s32 CALLBACK GSfreeze(int mode, freezeData *data) +EXPORT_C_(s32) GSfreeze(int mode, freezeData *data) { FUNCLOG diff --git a/plugins/zzogl-pg/opengl/GifTransfer.cpp b/plugins/zzogl-pg/opengl/GifTransfer.cpp index f8be40629b..7c42c9a48e 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg/opengl/GifTransfer.cpp @@ -27,7 +27,7 @@ static int path1_count = 0; static int nPath3Hack = 0; -void CALLBACK GSgetLastTag(u64* ptag) +EXPORT_C_(void) GSgetLastTag(u64* ptag) { FUNCLOG @@ -165,32 +165,36 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) { int len = min(size, path->nloop); //ZZLog::Error_Log("GIF_FLG_IMAGE(%d)=%d", gs.imageTransfer, len); - - switch (gs.imageTransfer) + + if (gs.transferring) { - case 0: - TransferHostLocal(pMem, len * 4); - break; + switch (gs.imageTransfer) + { + case XFER_HOST_TO_LOCAL: + TransferHostLocal(pMem, len * 4); + break; - case 1: - // This can't happen; downloads can not be started or performed as part of - // a GIFtag operation. They're an entirely separate process that can only be - // done through the ReverseFIFO transfer (aka ReadFIFO). --air - assert(0); - //TransferLocalHost(pMem, len); - break; + case XFER_LOCAL_TO_HOST: + // This can't happen; downloads can not be started or performed as part of + // a GIFtag operation. They're an entirely separate process that can only be + // done through the ReverseFIFO transfer (aka ReadFIFO). --air + assert(0); + //TransferLocalHost(pMem, len); + break; - case 2: - //TransferLocalLocal(); - break; + case XFER_LOCAL_TO_LOCAL: + //TransferLocalLocal(); + break; - case 3: - //assert(0); - break; + case XFER_DEACTIVATED: + //assert(0); + break; - default: - //assert(0); - break; + default: + //assert(0); + break; + } + } pMem += len * 4; @@ -236,7 +240,7 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) } } -void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr) +EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr) { FUNCLOG @@ -250,7 +254,7 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr) _GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16); } -void CALLBACK GSgifTransfer2(u32 *pMem, u32 size) +EXPORT_C_(void) GSgifTransfer2(u32 *pMem, u32 size) { FUNCLOG @@ -259,7 +263,7 @@ void CALLBACK GSgifTransfer2(u32 *pMem, u32 size) _GSgifTransfer<1>(const_cast(pMem), size); } -void CALLBACK GSgifTransfer3(u32 *pMem, u32 size) +EXPORT_C_(void) GSgifTransfer3(u32 *pMem, u32 size) { FUNCLOG @@ -268,7 +272,7 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size) _GSgifTransfer<2>(const_cast(pMem), size); } -void CALLBACK GSgifTransfer(const u32 *pMem, u32 size) +EXPORT_C_(void) GSgifTransfer(const u32 *pMem, u32 size) { FUNCLOG diff --git a/plugins/zzogl-pg/opengl/HostMemory.cpp b/plugins/zzogl-pg/opengl/HostMemory.cpp index 9b762e9437..78d6100730 100644 --- a/plugins/zzogl-pg/opengl/HostMemory.cpp +++ b/plugins/zzogl-pg/opengl/HostMemory.cpp @@ -18,8 +18,6 @@ */ #include "GS.h" -#include -#include #include #include "Mem.h" @@ -117,14 +115,14 @@ void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h if (PSMT_ISZTEX(psm)) { - // Somehow, I doubt this code is right. I'll have to look into it. For the moment, I'm keeping it the - // way it was. --arcum42 - + // This still needs an eye kept on it. const BLOCK& b = m_Blocks[psm]; - - bw = (bw + b.width - 1) / b.width; - start = bp * 256 + ((y / b.height) * bw + (x / b.width)) * 0x2000; - end = bp * 256 + (((y + h - 1) / b.height) * bw + (x + w + b.width - 1) / b.width) * 0x2000; + const int x2 = x + w + b.width - 1; + const int y2 = y + h - 1; + bw = bw / b.width; + + start = (bp + ((y / b.height) * bw + (x / b.width)) * 0x20) * 0x100; + end = (bp + ((y2 / b.height) * bw + (x2 / b.width)) * 0x20) * 0x100; return; } @@ -139,46 +137,101 @@ void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h } else { - // This is what it used to do, which doesn't seem right. - // Keeping it for reference, in case removing it breaks anything. + start /= 2; + end /= 2; + } +} + +// Same as GetRectMemAddress, except that we know x & y are zero, so it's simplified a bit. +void GetRectMemAddressZero(int& start, int& end, int psm, int w, int h, int bp, int bw) +{ + FUNCLOG + u32 bits = 0; + + if (m_Blocks[psm].bpp == 0) + { + ZZLog::Error_Log("ZeroGS: Bad psm 0x%x.", psm); + start = 0; + end = MEMORY_END; + return; + } + + if (PSMT_ISZTEX(psm)) + { + // This still needs an eye kept on it. + const BLOCK& b = m_Blocks[psm]; + const int x2 = w + b.width - 1; + const int y2 = h - 1; + bw = bw / b.width; + + start = bp * 0x100; + end = (bp + ((y2 / b.height) * bw + (x2 / b.width)) * 0x20) * 0x100; + return; + } - //int newx = ((x + w - 1 + 31) & ~31) - 1; - //int newy = ((y + h - 1 + 15) & ~15) - 1; - //start = getPixelAddress4(x, y, bp, bw) / 2; - //end = (getPixelAddress4(max(newx, x), max(newy, y), bp, bw) + 2) / 2; + bits = PSMT_BITS_NUM(psm); + start = getPixelFun[psm](0, 0, bp, bw); + end = getPixelFun[psm](w - 1, h - 1, bp, bw) + 1; + if (bits > 0) + { + start *= bits; + end *= bits; + } + else + { start /= 2; end /= 2; } } + +void GetRectMemAddress(int& start, int& end, int psm, Point p, Size s, int bp, int bw) +{ + GetRectMemAddress(start, end, psm, p.x, p.y, s.w, s.h, bp, bw); +} + +void GetRectMemAddress(int& start, int& end, int psm, int x, int y, Size s, int bp, int bw) +{ + GetRectMemAddress(start, end, psm, x, y, s.w, s.h, bp, bw); +} + +void GetRectMemAddressZero(int& start, int& end, int psm, Size s, int bp, int bw) +{ + GetRectMemAddressZero(start, end, psm, s.w, s.h, bp, bw); +} + void InitTransferHostLocal() { FUNCLOG #if defined(_DEBUG) // Xenosaga 1. - if (gs.trxpos.dx + gs.imageWnew > gs.dstbuf.bw) - ZZLog::Debug_Log("Transfer error, width exceeded. (0x%x > 0X%x)", gs.trxpos.dx + gs.imageWnew, gs.dstbuf.bw); + if (gs.trxpos.dx + gs.imageNew.w > gs.dstbuf.bw) + ZZLog::Debug_Log("Transfer error, width exceeded. (0x%x > 0X%x)", gs.trxpos.dx + gs.imageNew.w, gs.dstbuf.bw); #endif //bool bHasFlushed = false; - gs.imageX = gs.trxpos.dx; - gs.imageY = gs.trxpos.dy; + gs.image.x = gs.trxpos.dx; + gs.image.y = gs.trxpos.dy; - gs.imageEndX = gs.imageX + gs.imageWnew; - gs.imageEndY = gs.imageY + gs.imageHnew; + gs.imageEnd.x = gs.image.x + gs.imageNew.w; + gs.imageEnd.y = gs.image.y + gs.imageNew.h; - assert(gs.imageEndX < 2048 && gs.imageEndY < 2048); + assert(gs.imageEnd.x < 2048 && gs.imageEnd.y < 2048); // This needs to be looked in to, since psm should *not* be 63. // hack! viewful joe - if (gs.dstbuf.psm == 63) gs.dstbuf.psm = 0; + if (gs.dstbuf.psm == 63) + { + ZZLog::WriteLn("gs.dstbuf.psm set to 0!"); + gs.dstbuf.psm = 0; + } int start, end; - GetRectMemAddress(start, end, gs.dstbuf.psm, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw); + GetRectMemAddress(start, end, gs.dstbuf.psm, gs.trxpos.dx, gs.trxpos.dy, gs.imageNew, gs.dstbuf.bp, gs.dstbuf.bw); if (end > MEMORY_END) { @@ -189,7 +242,7 @@ void InitTransferHostLocal() // MEMORY_END is 0x400000... ZZLog::Warn_Log("Init host local out of bounds! (end == 0x%x)", end); - //gs.imageTransfer = -1; + //gs.transferring = false; end = MEMORY_END; } @@ -198,17 +251,18 @@ void InitTransferHostLocal() if (vb[0].nCount > 0) Flush(0); if (vb[1].nCount > 0) Flush(1); - //ZZLog::Prim_Log("trans: bp:%x x:%x y:%x w:%x h:%x\n", gs.dstbuf.bp, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew); + //ZZLog::Prim_Log("trans: bp:%x x:%x y:%x w:%x h:%x\n", gs.dstbuf.bp, gs.trxpos.dx, gs.trxpos.dy, gs.imageNew.w, gs.imageNew.h); } void TransferHostLocal(const void* pbyMem, u32 nQWordSize) { FUNCLOG - int start, end; - - GetRectMemAddress(start, end, gs.dstbuf.psm, gs.imageX, gs.imageY, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw); + int start = -1, end = -1; + GetRectMemAddress(start, end, gs.dstbuf.psm, gs.image, gs.imageNew, gs.dstbuf.bp, gs.dstbuf.bw); + + if ((start == -1) || (end == -1)) ZZLog::WriteLn("start == %d, end == %d", start, end); assert(start < gs_imageEnd); end = gs_imageEnd; @@ -272,8 +326,8 @@ void TransferHostLocal(const void* pbyMem, u32 nQWordSize) { tex0Info t; t.tbp0 = gs.dstbuf.bp; - t.tw = gs.imageWnew; - t.th = gs.imageHnew; + t.tw = gs.imageNew.w; + t.th = gs.imageNew.h; t.tbw = gs.dstbuf.bw; t.psm = gs.dstbuf.psm; SaveTex(&t, 0); @@ -285,24 +339,24 @@ void TransferHostLocal(const void* pbyMem, u32 nQWordSize) void InitTransferLocalHost() { FUNCLOG - assert(gs.trxpos.sx + gs.imageWnew <= 2048 && gs.trxpos.sy + gs.imageHnew <= 2048); + assert(gs.trxpos.sx + gs.imageNew.w <= 2048 && gs.trxpos.sy + gs.imageNew.h <= 2048); #if defined(_DEBUG) - if (gs.trxpos.sx + gs.imageWnew > gs.srcbuf.bw) - ZZLog::Debug_Log("Transfer error, width exceeded. (0x%x > 0x%x)", gs.trxpos.sx + gs.imageWnew, gs.srcbuf.bw); + if (gs.trxpos.sx + gs.imageNew.w > gs.srcbuf.bw) + ZZLog::Debug_Log("Transfer error, width exceeded. (0x%x > 0x%x)", gs.trxpos.sx + gs.imageNew.w, gs.srcbuf.bw); #endif - gs.imageX = gs.trxpos.sx; - gs.imageY = gs.trxpos.sy; + gs.image.x = gs.trxpos.sx; + gs.image.y = gs.trxpos.sy; - gs.imageEndX = gs.imageX + gs.imageWnew; - gs.imageEndY = gs.imageY + gs.imageHnew; + gs.imageEnd.x = gs.image.x + gs.imageNew.w; + gs.imageEnd.y = gs.image.y + gs.imageNew.h; s_vTransferCache.resize(0); int start, end; - GetRectMemAddress(start, end, gs.srcbuf.psm, gs.trxpos.sx, gs.trxpos.sy, gs.imageWnew, gs.imageHnew, gs.srcbuf.bp, gs.srcbuf.bw); + GetRectMemAddress(start, end, gs.srcbuf.psm, gs.trxpos.sx, gs.trxpos.sy, gs.imageNew, gs.srcbuf.bp, gs.srcbuf.bw); ResolveInRange(start, end); } @@ -316,16 +370,16 @@ void TransferLocalHost(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *pstart) T* pbuf = (T*)pbyMem; u32 nSize = nQWordSize * 16 / sizeof(T); - for (; i < gs.imageEndY; ++i) + for (; i < gs.imageEnd.y; ++i) { - for (; j < gs.imageEndX && nSize > 0; ++j, --nSize) + for (; j < gs.imageEnd.x && nSize > 0; ++j, --nSize) { *pbuf++ = rp(pstart, j % 2048, i % 2048, gs.srcbuf.bw); } - if (j >= gs.imageEndX) + if (j >= gs.imageEnd.x) { - assert(j == gs.imageEndX); + assert(j == gs.imageEnd.x); j = gs.trxpos.sx; } else @@ -344,9 +398,9 @@ void TransferLocalHost_24(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *psta u8* pbuf = (u8*)pbyMem; u32 nSize = nQWordSize * 16 / 3; - for (; i < gs.imageEndY; ++i) + for (; i < gs.imageEnd.y; ++i) { - for (; j < gs.imageEndX && nSize > 0; ++j, --nSize) + for (; j < gs.imageEnd.x && nSize > 0; ++j, --nSize) { u32 p = rp(pstart, j % 2048, i % 2048, gs.srcbuf.bw); pbuf[0] = (u8)p; @@ -355,9 +409,9 @@ void TransferLocalHost_24(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *psta pbuf += 3; } - if (j >= gs.imageEndX) + if (j >= gs.imageEnd.x) { - assert(j == gs.imageEndX); + assert(j == gs.imageEnd.x); j = gs.trxpos.sx; } else @@ -372,34 +426,34 @@ void TransferLocalHost_24(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *psta void TransferLocalHost(void* pbyMem, u32 nQWordSize) { FUNCLOG - assert(gs.imageTransfer == 1); + assert(gs.imageTransfer == XFER_LOCAL_TO_HOST); u8* pstart = g_pbyGSMemory + 256 * gs.srcbuf.bp; switch(PSMT_BITMODE(gs.srcbuf.psm)) { - case 0: - TransferLocalHost(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); - break; - case 1: - TransferLocalHost_24(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); - break; - case 2: - TransferLocalHost(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); - break; - case 3: - TransferLocalHost(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); - break; - default: - assert(0); - break; + case 0: + TransferLocalHost(pbyMem, nQWordSize, gs.image.y, gs.image.x, pstart); + break; + case 1: + TransferLocalHost_24(pbyMem, nQWordSize, gs.image.y, gs.image.x, pstart); + break; + case 2: + TransferLocalHost(pbyMem, nQWordSize, gs.image.y, gs.image.x, pstart); + break; + case 3: + TransferLocalHost(pbyMem, nQWordSize, gs.image.y, gs.image.x, pstart); + break; + default: + assert(0); + break; } - if (gs.imageY >= gs.imageEndY) + if (gs.image.y >= gs.imageEnd.y) { - ZZLog::Error_Log("gs.imageY >= gs.imageEndY!"); - assert(gs.imageY == gs.imageEndY); - gs.imageTransfer = -1; + ZZLog::Error_Log("gs.image.y >= gs.imageEnd.y!"); + assert(gs.image.y == gs.imageEnd.y); + gs.transferring = false; } } @@ -411,11 +465,11 @@ __forceinline void _TransferLocalLocal() u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256; u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256; u32 widthlimit = 4; - u32 maxX = gs.trxpos.sx + gs.imageWnew; - u32 maxY = gs.trxpos.sy + gs.imageHnew; + u32 maxX = gs.trxpos.sx + gs.imageNew.w; + u32 maxY = gs.trxpos.sy + gs.imageNew.h; if (PSMT_BITMODE(gs.srcbuf.psm) == 0) widthlimit = 2; - if ((gs.imageWnew & widthlimit) != 0) return; + if ((gs.imageNew.w & widthlimit) != 0) return; for(u32 i = gs.trxpos.sy, i2 = gs.trxpos.dy; i < maxY; i++, i2++) { @@ -447,10 +501,10 @@ __forceinline void _TransferLocalLocal_4() _getPixelAddress_0 gdp = getPixelFun_0[gs.dstbuf.psm]; u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256; u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256; - u32 maxX = gs.trxpos.sx + gs.imageWnew; - u32 maxY = gs.trxpos.sy + gs.imageHnew; + u32 maxX = gs.trxpos.sx + gs.imageNew.w; + u32 maxY = gs.trxpos.sy + gs.imageNew.h; - assert((gs.imageWnew % 8) == 0); + assert((gs.imageNew.w % 8) == 0); for(u32 i = gs.trxpos.sy, i2 = gs.trxpos.dy; i < maxY; ++i, ++i2) { @@ -498,21 +552,21 @@ void TransferLocalLocal() FUNCLOG //ZZLog::Error_Log("I'z in your code, transferring your memory..."); - assert(gs.imageTransfer == 2); - assert(gs.trxpos.sx + gs.imageWnew < 2048 && gs.trxpos.sy + gs.imageHnew < 2048); - assert(gs.trxpos.dx + gs.imageWnew < 2048 && gs.trxpos.dy + gs.imageHnew < 2048); + assert(gs.imageTransfer == XFER_LOCAL_TO_LOCAL); + assert(gs.trxpos.sx + gs.imageNew.w < 2048 && gs.trxpos.sy + gs.imageNew.h < 2048); + assert(gs.trxpos.dx + gs.imageNew.w < 2048 && gs.trxpos.dy + gs.imageNew.h < 2048); assert((gs.srcbuf.psm&0x7) == (gs.dstbuf.psm&0x7)); - if (gs.trxpos.sx + gs.imageWnew > gs.srcbuf.bw) - ZZLog::Debug_Log("Transfer error, src width exceeded.(0x%x > 0x%x)", gs.trxpos.sx + gs.imageWnew, gs.srcbuf.bw); + if (gs.trxpos.sx + gs.imageNew.w > gs.srcbuf.bw) + ZZLog::Debug_Log("Transfer error, src width exceeded.(0x%x > 0x%x)", gs.trxpos.sx + gs.imageNew.w, gs.srcbuf.bw); - if (gs.trxpos.dx + gs.imageWnew > gs.dstbuf.bw) - ZZLog::Debug_Log("Transfer error, dst width exceeded.(0x%x > 0x%x)", gs.trxpos.dx + gs.imageWnew, gs.dstbuf.bw); + if (gs.trxpos.dx + gs.imageNew.w > gs.dstbuf.bw) + ZZLog::Debug_Log("Transfer error, dst width exceeded.(0x%x > 0x%x)", gs.trxpos.dx + gs.imageNew.w, gs.dstbuf.bw); int srcstart, srcend, dststart, dstend; - GetRectMemAddress(srcstart, srcend, gs.srcbuf.psm, gs.trxpos.sx, gs.trxpos.sy, gs.imageWnew, gs.imageHnew, gs.srcbuf.bp, gs.srcbuf.bw); - GetRectMemAddress(dststart, dstend, gs.dstbuf.psm, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw); + GetRectMemAddress(srcstart, srcend, gs.srcbuf.psm, gs.trxpos.sx, gs.trxpos.sy, gs.imageNew, gs.srcbuf.bp, gs.srcbuf.bw); + GetRectMemAddress(dststart, dstend, gs.dstbuf.psm, gs.trxpos.dx, gs.trxpos.dy, gs.imageNew, gs.dstbuf.bp, gs.dstbuf.bw); // resolve the targs ResolveInRange(srcstart, srcend); @@ -547,15 +601,15 @@ void TransferLocalLocal() { tex0Info t; t.tbp0 = gs.dstbuf.bp; - t.tw = gs.imageWnew; - t.th = gs.imageHnew; + t.tw = gs.imageNew.w; + t.th = gs.imageNew.h; t.tbw = gs.dstbuf.bw; t.psm = gs.dstbuf.psm; SaveTex(&t, 0); t.tbp0 = gs.srcbuf.bp; - t.tw = gs.imageWnew; - t.th = gs.imageHnew; + t.tw = gs.imageNew.w; + t.th = gs.imageNew.h; t.tbw = gs.srcbuf.bw; t.psm = gs.srcbuf.psm; SaveTex(&t, 0); @@ -563,16 +617,4 @@ void TransferLocalLocal() #endif } - -__forceinline void TerminateLocalHost() -{ - FUNCLOG - //ZZLog::Error_Log("Terminate Local Host!"); -} - -__forceinline void TerminateHostLocal() -{ - FUNCLOG - gs.imageTransfer = -1; -} diff --git a/plugins/zzogl-pg/opengl/HostMemory.h b/plugins/zzogl-pg/opengl/HostMemory.h index e9217685d1..a49fe1eb81 100644 --- a/plugins/zzogl-pg/opengl/HostMemory.h +++ b/plugins/zzogl-pg/opengl/HostMemory.h @@ -96,7 +96,10 @@ inline u8* _MemoryAddress(int x) } extern void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h, int bp, int bw); - +extern void GetRectMemAddress(int& start, int& end, int psm, Point p, Size s, int bp, int bw); +extern void GetRectMemAddress(int& start, int& end, int psm, int x, int y, Size s, int bp, int bw); +extern void GetRectMemAddressZero(int& start, int& end, int psm, int w, int h, int bp, int bw); +extern void GetRectMemAddressZero(int& start, int& end, int psm, Size s, int bp, int bw); // called when trxdir is accessed. If host is involved, transfers memory to temp buffer byTransferBuf. // Otherwise performs the transfer. TODO: Perhaps divide the transfers into chunks? @@ -108,7 +111,4 @@ extern void TransferLocalHost(void* pbyMem, u32 nQWordSize); extern void TransferLocalLocal(); -extern void TerminateLocalHost(); -extern void TerminateHostLocal(); - #endif // HOSTMEMORY_H_INCLUDED diff --git a/plugins/zzogl-pg/opengl/Linux/Linux.cpp b/plugins/zzogl-pg/opengl/Linux/Linux.cpp index 3d5609f95f..4cf6ee9577 100644 --- a/plugins/zzogl-pg/opengl/Linux/Linux.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Linux.cpp @@ -35,7 +35,7 @@ extern bool THR_bCtrl; static map mapConfOpts; static gameHacks tempHacks; -void CALLBACK GSkeyEvent(keyEvent *ev) +EXPORT_C_(void) GSkeyEvent(keyEvent *ev) { static bool bAlt = false; @@ -450,7 +450,7 @@ void DisplayDialog() gtk_widget_destroy(dialog); } -void CALLBACK GSconfigure() +EXPORT_C_(void) GSconfigure() { char strcurdir[256]; getcwd(strcurdir, 256); @@ -484,12 +484,12 @@ void SysMessage(const char *fmt, ...) gtk_widget_destroy(dialog); } -void CALLBACK GSabout() +EXPORT_C_(void) GSabout() { SysMessage("ZZOgl PG: by Zeydlitz (PG version worked on by arcum42, gregory, and the pcsx2 development team). Based off of ZeroGS, by zerofrog."); } -s32 CALLBACK GStest() +EXPORT_C_(s32) GStest() { return 0; } diff --git a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp index b9bf0a2d48..33f009d059 100644 --- a/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp +++ b/plugins/zzogl-pg/opengl/Linux/zzogl-pg/zzogl-pg.cbp @@ -16,11 +16,14 @@ + + + @@ -33,12 +36,15 @@ + + + @@ -50,10 +56,69 @@ + + + + + +