From e9e12ff100b0f92e6a6acb39d9d8574b75658428 Mon Sep 17 00:00:00 2001 From: luisr142004 Date: Tue, 6 Jul 2010 13:14:51 +0000 Subject: [PATCH] cleanup + some eolz git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5842 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/OpenCL.cpp | 10 +- Source/Core/InputCommon/Src/UDPWiimote.cpp | 40 +- Source/Core/InputCommon/Src/UDPWrapper.cpp | 2 +- Source/Core/InputUICommon/Src/ConfigDiag.cpp | 22 +- Source/Core/VideoCommon/Src/BPStructs.cpp | 8 +- .../Src/OpenCL/OCLTextureDecoder.cpp | 82 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 955 +++++++++--------- .../Core/VideoCommon/Src/VertexShaderGen.cpp | 587 +++++------ .../Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp | 8 +- .../Plugins/Plugin_VideoDX11/Src/GfxState.cpp | 2 +- .../Plugin_VideoDX11/Src/VertexManager.cpp | 14 +- Source/Plugins/Plugin_VideoDX11/Src/main.cpp | 49 +- .../Plugin_VideoDX9/Src/DlgSettings.cpp | 49 +- .../Plugins/Plugin_VideoDX9/Src/DlgSettings.h | 2 - Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 240 +++-- .../Plugin_VideoOGL/Src/Debugger/Debugger.h | 6 +- .../Src/WiimoteEmu/Attachment/UDPNunchuk.cpp | 52 +- .../Src/WiimoteEmu/Attachment/UDPNunchuk.h | 24 +- .../Src/WiimoteEmu/UDPTLayer.h | 106 +- 19 files changed, 1117 insertions(+), 1141 deletions(-) diff --git a/Source/Core/Common/Src/OpenCL.cpp b/Source/Core/Common/Src/OpenCL.cpp index 3291820780..8fad808f18 100644 --- a/Source/Core/Common/Src/OpenCL.cpp +++ b/Source/Core/Common/Src/OpenCL.cpp @@ -66,7 +66,7 @@ bool Initialize() return false; } - if (0 < numPlatforms) + if (0 < numPlatforms) { cl_platform_id* platforms = new cl_platform_id[numPlatforms]; err = clGetPlatformIDs(numPlatforms, platforms, NULL); @@ -106,7 +106,7 @@ bool Initialize() return false; } - // Create a compute context + // Create a compute context g_context = clCreateContext(cprops, 1, &device_id, NULL, NULL, &err); if (!g_context) { @@ -176,8 +176,8 @@ cl_kernel CompileKernel(cl_program program, const char *Function) cl_kernel kernel = clCreateKernel(program, Function, &err); if (!kernel || err != CL_SUCCESS) { - char buffer[1024]; - sprintf(buffer, "Failed to create compute kernel '%s' !", Function); + char buffer[1024]; + sprintf(buffer, "Failed to create compute kernel '%s' !", Function); HandleCLError(err, buffer); return NULL; } @@ -191,7 +191,7 @@ void Destroy() #if defined(HAVE_OPENCL) && HAVE_OPENCL if(!g_context) return; - clReleaseCommandQueue(g_cmdq); + clReleaseCommandQueue(g_cmdq); clReleaseContext(g_context); g_context = NULL; g_cmdq = NULL; diff --git a/Source/Core/InputCommon/Src/UDPWiimote.cpp b/Source/Core/InputCommon/Src/UDPWiimote.cpp index 5b59e4ed5c..d48a58fdcb 100644 --- a/Source/Core/InputCommon/Src/UDPWiimote.cpp +++ b/Source/Core/InputCommon/Src/UDPWiimote.cpp @@ -72,8 +72,8 @@ UDPWiimote::UDPWiimote(const char *_port) : #ifdef _WIN32 u_long iMode = 1; #endif - struct addrinfo hints, *servinfo, *p; - int rv; + struct addrinfo hints, *servinfo, *p; + int rv; d->thread=NULL; #ifdef _WIN32 @@ -89,41 +89,41 @@ UDPWiimote::UDPWiimote(const char *_port) : noinst++; //PanicAlert("UDPWii instantiated"); - memset(&hints, 0, sizeof hints); + memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; // use my IP + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_PASSIVE; // use my IP - if ((rv = getaddrinfo(NULL, _port, &hints, &servinfo)) != 0) { + if ((rv = getaddrinfo(NULL, _port, &hints, &servinfo)) != 0) { cleanup; - err=-1; + err=-1; return; - } + } - // loop through all the results and bind to everything we can - for(p = servinfo; p != NULL; p = p->ai_next) { + // loop through all the results and bind to everything we can + for(p = servinfo; p != NULL; p = p->ai_next) { sock_t sock; - if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) { + if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) { continue; - } + } - if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) { - close(sock); + if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) { + close(sock); continue; - } + } //NOTICE_LOG(WIIMOTE,"UDPWii new listening sock"); d->sockfds.push_back(sock); - } + } - if (d->sockfds.empty()) { + if (d->sockfds.empty()) { cleanup; err=-2; - return; - } + return; + } - freeaddrinfo(servinfo); + freeaddrinfo(servinfo); err=0; d->exit=false; // NOTICE_LOG(WIIMOTE,"UDPWii thread starting"); diff --git a/Source/Core/InputCommon/Src/UDPWrapper.cpp b/Source/Core/InputCommon/Src/UDPWrapper.cpp index 641bc085e4..70a3d9ddf8 100644 --- a/Source/Core/InputCommon/Src/UDPWrapper.cpp +++ b/Source/Core/InputCommon/Src/UDPWrapper.cpp @@ -103,7 +103,7 @@ public: UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) : wxDialog(parent, -1, wxT("UDP Wiimote"), wxDefaultPosition, wxDefaultSize), - wrp(_wrp) + wrp(_wrp) { wxBoxSizer * outer_sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer * sizer1 = new wxBoxSizer(wxVERTICAL); diff --git a/Source/Core/InputUICommon/Src/ConfigDiag.cpp b/Source/Core/InputUICommon/Src/ConfigDiag.cpp index bb00b57f93..32e81d7d38 100644 --- a/Source/Core/InputUICommon/Src/ConfigDiag.cpp +++ b/Source/Core/InputUICommon/Src/ConfigDiag.cpp @@ -204,7 +204,7 @@ void ControlDialog::UpdateListContents() { // for inputs std::vector::const_iterator - i = dev->Inputs().begin(), + i = dev->Inputs().begin(), e = dev->Inputs().end(); for (; i!=e; ++i) control_lbox->Append(WXSTR_FROM_STR((*i)->GetName())); @@ -213,7 +213,7 @@ void ControlDialog::UpdateListContents() { // for outputs std::vector::const_iterator - i = dev->Outputs().begin(), + i = dev->Outputs().begin(), e = dev->Outputs().end(); for (; i!=e; ++i) control_lbox->Append(WXSTR_FROM_STR((*i)->GetName())); @@ -702,10 +702,10 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi switch ( group->type ) { - case GROUP_TYPE_STICK : - case GROUP_TYPE_TILT : - case GROUP_TYPE_CURSOR : - case GROUP_TYPE_FORCE : + case GROUP_TYPE_STICK: + case GROUP_TYPE_TILT: + case GROUP_TYPE_CURSOR: + case GROUP_TYPE_FORCE: { wxBitmap bitmap(64, 64); dc.SelectObject(bitmap); @@ -733,7 +733,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi Add( h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3 ); } break; - case GROUP_TYPE_BUTTONS : + case GROUP_TYPE_BUTTONS: { wxBitmap bitmap(int(12*group->controls.size()+1), 12); dc.SelectObject(bitmap); @@ -755,8 +755,8 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi Add(static_bitmap, 0, wxALL|wxCENTER, 3); } break; - case GROUP_TYPE_MIXED_TRIGGERS : - case GROUP_TYPE_TRIGGERS : + case GROUP_TYPE_MIXED_TRIGGERS: + case GROUP_TYPE_TRIGGERS: { int height = (int)(6 * group->controls.size()); int width = 64+12+1; @@ -787,7 +787,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi Add( static_bitmap, 0, wxALL|wxCENTER, 3 ); } break; - case GROUP_TYPE_EXTENSION : + case GROUP_TYPE_EXTENSION: { PadSettingExtension* const attachments = new PadSettingExtension( parent, (ControllerEmu::Extension*)group ); wxButton* const configure_btn = new ExtensionButton( parent, (ControllerEmu::Extension*)group ); @@ -808,7 +808,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi Add(btn, 0, wxALL|wxEXPAND, 3); } break; - default : + default: { //options diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index e620f80b43..827e182f77 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -357,8 +357,8 @@ void BPWritten(const BPCmd& bp) // Bounding Box Control // ------------------------- case BPMEM_CLEARBBOX1: - case BPMEM_CLEARBBOX2: { - + case BPMEM_CLEARBBOX2: + { #ifdef BBOX_SUPPORT // which is which? these are GUESSES! if (bp.address == BPMEM_CLEARBBOX1) { @@ -381,8 +381,8 @@ void BPWritten(const BPCmd& bp) // WARN_LOG(VIDEO, "ClearBBox TB: %i, %08x - %i, %i", bp.address, bp.newvalue, top, bottom); } #endif + } break; - } case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue); case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format @@ -583,7 +583,7 @@ void BPWritten(const BPCmd& bp) default: WARN_LOG(VIDEO, "Unknown BP opcode: address = 0x%08x value = 0x%08x", bp.address, bp.newvalue); break; - } + } } // FIXME: Hangs load-state, but should fix graphic-heavy games state loading diff --git a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp index b38a2b8f56..b7827f430f 100644 --- a/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/OpenCL/OCLTextureDecoder.cpp @@ -35,55 +35,56 @@ cl_program g_program; struct sDecoderParameter { - const char *name; - cl_kernel kernel; - float sizeOfSrc; + const char *name; + cl_kernel kernel; + float sizeOfSrc; float sizeOfDst; - int xSkip; - int ySkip; + int xSkip; + int ySkip; PC_TexFormat format; }; sDecoderParameter g_DecodeParametersNative[] = { - /* GX_TF_I4 */ { "DecodeI4", NULL, 0.5f, 1, 8, 8, PC_TEX_FMT_I4_AS_I8 }, - /* GX_TF_I8 */ { "DecodeI8", NULL, 1, 1, 8, 4, PC_TEX_FMT_I8 }, - /* GX_TF_IA4 */ { "DecodeIA4", NULL, 1, 2, 8, 4, PC_TEX_FMT_IA4_AS_IA8 }, - /* GX_TF_IA8 */ { "DecodeIA8", NULL, 2, 2, 4, 4, PC_TEX_FMT_IA8 }, - /* GX_TF_RGB565 */ { "DecodeRGB565", NULL, 2, 2, 4, 4, PC_TEX_FMT_RGB565 }, - /* GX_TF_RGB5A3 */ { "DecodeRGB5A3", NULL, 2, 4, 4, 4, PC_TEX_FMT_BGRA32 }, - /* GX_TF_RGBA8 */ { "DecodeRGBA8", NULL, 4, 4, 4, 4, PC_TEX_FMT_BGRA32 }, - /* 7 */ { NULL }, - /* GX_TF_C4 */ { NULL }, - /* GX_TF_C8 */ { NULL }, - /* GX_TF_C14X2 */ { NULL }, - /* B */ { NULL }, - /* C */ { NULL }, - /* D */ { NULL }, - /* GX_TF_CMPR */ { "DecodeCMPR", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_BGRA32 }, + /* GX_TF_I4 */ { "DecodeI4", NULL, 0.5f, 1, 8, 8, PC_TEX_FMT_I4_AS_I8 }, + /* GX_TF_I8 */ { "DecodeI8", NULL, 1, 1, 8, 4, PC_TEX_FMT_I8 }, + /* GX_TF_IA4 */ { "DecodeIA4", NULL, 1, 2, 8, 4, PC_TEX_FMT_IA4_AS_IA8 }, + /* GX_TF_IA8 */ { "DecodeIA8", NULL, 2, 2, 4, 4, PC_TEX_FMT_IA8 }, + /* GX_TF_RGB565 */ { "DecodeRGB565", NULL, 2, 2, 4, 4, PC_TEX_FMT_RGB565 }, + /* GX_TF_RGB5A3 */ { "DecodeRGB5A3", NULL, 2, 4, 4, 4, PC_TEX_FMT_BGRA32 }, + /* GX_TF_RGBA8 */ { "DecodeRGBA8", NULL, 4, 4, 4, 4, PC_TEX_FMT_BGRA32 }, + /* 7 */ { NULL }, + /* GX_TF_C4 */ { NULL }, + /* GX_TF_C8 */ { NULL }, + /* GX_TF_C14X2 */ { NULL }, + /* B */ { NULL }, + /* C */ { NULL }, + /* D */ { NULL }, + /* GX_TF_CMPR */ { "DecodeCMPR", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_BGRA32 }, }; sDecoderParameter g_DecodeParametersRGBA[] = { - /* GX_TF_I4 */ { "DecodeI4_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, - /* GX_TF_I8 */ { "DecodeI8_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_IA4 */ { "DecodeIA4_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_IA8 */ { "DecodeIA8_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGB565 */ { "DecodeRGB565_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGB5A3 */ { "DecodeRGB5A3_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* GX_TF_RGBA8 */ { "DecodeRGBA8_RGBA", NULL, 4, 4, 4, 4, PC_TEX_FMT_RGBA32 }, - /* 7 */ { NULL }, - /* GX_TF_C4 */ { NULL }, - /* GX_TF_C8 */ { NULL }, - /* GX_TF_C14X2 */ { NULL }, - /* B */ { NULL }, - /* C */ { NULL }, - /* D */ { NULL }, - /* GX_TF_CMPR */ { "DecodeCMPR_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, + /* GX_TF_I4 */ { "DecodeI4_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, + /* GX_TF_I8 */ { "DecodeI8_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, + /* GX_TF_IA4 */ { "DecodeIA4_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 }, + /* GX_TF_IA8 */ { "DecodeIA8_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, + /* GX_TF_RGB565 */ { "DecodeRGB565_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, + /* GX_TF_RGB5A3 */ { "DecodeRGB5A3_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 }, + /* GX_TF_RGBA8 */ { "DecodeRGBA8_RGBA", NULL, 4, 4, 4, 4, PC_TEX_FMT_RGBA32 }, + /* 7 */ { NULL }, + /* GX_TF_C4 */ { NULL }, + /* GX_TF_C8 */ { NULL }, + /* GX_TF_C14X2 */ { NULL }, + /* B */ { NULL }, + /* C */ { NULL }, + /* D */ { NULL }, + /* GX_TF_CMPR */ { "DecodeCMPR_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 }, }; bool g_Inited = false; cl_mem g_clsrc, g_cldst; // texture buffer memory objects -void TexDecoder_OpenCL_Initialize() { +void TexDecoder_OpenCL_Initialize() +{ #if defined(HAVE_OPENCL) && HAVE_OPENCL if(!g_Inited) { @@ -124,7 +125,8 @@ void TexDecoder_OpenCL_Initialize() { #endif } -void TexDecoder_OpenCL_Shutdown() { +void TexDecoder_OpenCL_Shutdown() +{ #if defined(HAVE_OPENCL) && HAVE_OPENCL && !defined(DEBUG_OPENCL) clReleaseProgram(g_program); @@ -151,9 +153,9 @@ PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int hei { #if defined(HAVE_OPENCL) && HAVE_OPENCL cl_int err; - sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat]; - if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE) - return PC_TEX_FMT_NONE; + sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat]; + if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE) + return PC_TEX_FMT_NONE; #ifdef DEBUG_OPENCL g_clsrc = clCreateBuffer(OpenCL::GetContext(), CL_MEM_READ_ONLY , 1024 * 1024 * sizeof(u32), NULL, NULL); diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 5a2bdba390..dac6e2a8a5 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -34,9 +34,9 @@ PIXELSHADERUID last_pixel_shader_uid; void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) { u32 projtexcoords = 0; - for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) + for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) { - if (bpmem.tevorders[i/2].getEnable(i & 1)) + if (bpmem.tevorders[i/2].getEnable(i & 1)) { int texcoord = bpmem.tevorders[i / 2].getTexCoord(i & 1); if (xfregs.texcoords[texcoord].texmtxinfo.projection) @@ -58,15 +58,15 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) uid->values[2] = texturemask; - u32 enableZTexture = (!bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable)?1:0; + u32 enableZTexture = (!bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable)?1:0; - uid->values[3] = (u32)bpmem.fog.c_proj_fsel.fsel | - ((u32)bpmem.fog.c_proj_fsel.proj << 3) | - ((u32)enableZTexture << 4); + uid->values[3] = (u32)bpmem.fog.c_proj_fsel.fsel | + ((u32)bpmem.fog.c_proj_fsel.proj << 3) | + ((u32)enableZTexture << 4); int hdr = 4; u32 *pcurvalue = &uid->values[hdr]; - for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) + for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) { TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC; TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC; @@ -80,7 +80,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) pcurvalue += 2; } - for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1) / 2; ++i) + for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1) / 2; ++i) { u32 val0, val1; if (bpmem.tevorders[i].hex & 0x40) @@ -96,7 +96,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) case 0: pcurvalue[0] = val0|(val1<<10); break; case 1: pcurvalue[0] |= val0<<20; pcurvalue[1] = val1; pcurvalue++; break; case 2: pcurvalue[1] |= (val0<<10)|(val1<<20); pcurvalue++; break; - default: PanicAlert("Uknown case for Tev Stages / 2: %08x", (i % 3)); + default: PanicAlert("Unknown case for Tev Stages / 2: %08x", (i % 3)); } } @@ -107,12 +107,12 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) else val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x380; - switch (bpmem.genMode.numtevstages % 3) + switch (bpmem.genMode.numtevstages % 3) { case 0: pcurvalue[0] = val0; break; case 1: pcurvalue[0] |= val0 << 20; break; case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break; - default: PanicAlert("Uknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3); + default: PanicAlert("Unknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3); } } @@ -121,15 +121,15 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) uid->tevstages = (u32)(pcurvalue - &uid->values[0] - hdr); - for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) + for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) { u32 val = bpmem.tevind[i].hex & 0x1fffff; // 21 bits - switch (i % 3) + switch (i % 3) { case 0: pcurvalue[0] = val; break; case 1: pcurvalue[0] |= val << 21; pcurvalue[1] = val >> 11; ++pcurvalue; break; case 2: pcurvalue[0] |= val << 10; ++pcurvalue; break; - default: PanicAlert("Uknown case for Ind Stages: %08x", (i % 3)); + default: PanicAlert("Unknown case for Ind Stages: %08x", (i % 3)); } } @@ -140,7 +140,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) // old tev->pixelshader notes // // color for this stage (alpha, color) is given by bpmem.tevorders[0].colorchan0 -// konstant for this stage (alpha, color) is given by bpmem.tevksel +// konstant for this stage (alpha, color) is given by bpmem.tevksel // inputs are given by bpmem.combiners[0].colorC.a/b/c/d << could be current chan color // according to GXTevColorArg table above // output is given by .outreg @@ -154,174 +154,174 @@ static void WriteFog(char *&p); static const char *tevKSelTableC[] = // KCSEL { - "1.0f,1.0f,1.0f", // 1 = 0x00 - "0.875f,0.875f,0.875f", // 7_8 = 0x01 - "0.75f,0.75f,0.75f", // 3_4 = 0x02 - "0.625f,0.625f,0.625f", // 5_8 = 0x03 - "0.5f,0.5f,0.5f", // 1_2 = 0x04 - "0.375f,0.375f,0.375f", // 3_8 = 0x05 - "0.25f,0.25f,0.25f", // 1_4 = 0x06 - "0.125f,0.125f,0.125f", // 1_8 = 0x07 - "ERROR", // 0x08 - "ERROR", // 0x09 - "ERROR", // 0x0a - "ERROR", // 0x0b - I_KCOLORS"[0].rgb", // K0 = 0x0C - I_KCOLORS"[1].rgb", // K1 = 0x0D - I_KCOLORS"[2].rgb", // K2 = 0x0E - I_KCOLORS"[3].rgb", // K3 = 0x0F - I_KCOLORS"[0].rrr", // K0_R = 0x10 - I_KCOLORS"[1].rrr", // K1_R = 0x11 - I_KCOLORS"[2].rrr", // K2_R = 0x12 - I_KCOLORS"[3].rrr", // K3_R = 0x13 - I_KCOLORS"[0].ggg", // K0_G = 0x14 - I_KCOLORS"[1].ggg", // K1_G = 0x15 - I_KCOLORS"[2].ggg", // K2_G = 0x16 - I_KCOLORS"[3].ggg", // K3_G = 0x17 - I_KCOLORS"[0].bbb", // K0_B = 0x18 - I_KCOLORS"[1].bbb", // K1_B = 0x19 - I_KCOLORS"[2].bbb", // K2_B = 0x1A - I_KCOLORS"[3].bbb", // K3_B = 0x1B - I_KCOLORS"[0].aaa", // K0_A = 0x1C - I_KCOLORS"[1].aaa", // K1_A = 0x1D - I_KCOLORS"[2].aaa", // K2_A = 0x1E - I_KCOLORS"[3].aaa", // K3_A = 0x1F + "1.0f,1.0f,1.0f", // 1 = 0x00 + "0.875f,0.875f,0.875f", // 7_8 = 0x01 + "0.75f,0.75f,0.75f", // 3_4 = 0x02 + "0.625f,0.625f,0.625f", // 5_8 = 0x03 + "0.5f,0.5f,0.5f", // 1_2 = 0x04 + "0.375f,0.375f,0.375f", // 3_8 = 0x05 + "0.25f,0.25f,0.25f", // 1_4 = 0x06 + "0.125f,0.125f,0.125f", // 1_8 = 0x07 + "ERROR", // 0x08 + "ERROR", // 0x09 + "ERROR", // 0x0a + "ERROR", // 0x0b + I_KCOLORS"[0].rgb", // K0 = 0x0C + I_KCOLORS"[1].rgb", // K1 = 0x0D + I_KCOLORS"[2].rgb", // K2 = 0x0E + I_KCOLORS"[3].rgb", // K3 = 0x0F + I_KCOLORS"[0].rrr", // K0_R = 0x10 + I_KCOLORS"[1].rrr", // K1_R = 0x11 + I_KCOLORS"[2].rrr", // K2_R = 0x12 + I_KCOLORS"[3].rrr", // K3_R = 0x13 + I_KCOLORS"[0].ggg", // K0_G = 0x14 + I_KCOLORS"[1].ggg", // K1_G = 0x15 + I_KCOLORS"[2].ggg", // K2_G = 0x16 + I_KCOLORS"[3].ggg", // K3_G = 0x17 + I_KCOLORS"[0].bbb", // K0_B = 0x18 + I_KCOLORS"[1].bbb", // K1_B = 0x19 + I_KCOLORS"[2].bbb", // K2_B = 0x1A + I_KCOLORS"[3].bbb", // K3_B = 0x1B + I_KCOLORS"[0].aaa", // K0_A = 0x1C + I_KCOLORS"[1].aaa", // K1_A = 0x1D + I_KCOLORS"[2].aaa", // K2_A = 0x1E + I_KCOLORS"[3].aaa", // K3_A = 0x1F }; static const char *tevKSelTableA[] = // KASEL { - "1.0f", // 1 = 0x00 - "0.875f",// 7_8 = 0x01 - "0.75f", // 3_4 = 0x02 - "0.625f",// 5_8 = 0x03 - "0.5f", // 1_2 = 0x04 - "0.375f",// 3_8 = 0x05 - "0.25f", // 1_4 = 0x06 - "0.125f",// 1_8 = 0x07 - "ERROR", // 0x08 - "ERROR", // 0x09 - "ERROR", // 0x0a - "ERROR", // 0x0b - "ERROR", // 0x0c - "ERROR", // 0x0d - "ERROR", // 0x0e - "ERROR", // 0x0f - I_KCOLORS"[0].r", // K0_R = 0x10 - I_KCOLORS"[1].r", // K1_R = 0x11 - I_KCOLORS"[2].r", // K2_R = 0x12 - I_KCOLORS"[3].r", // K3_R = 0x13 - I_KCOLORS"[0].g", // K0_G = 0x14 - I_KCOLORS"[1].g", // K1_G = 0x15 - I_KCOLORS"[2].g", // K2_G = 0x16 - I_KCOLORS"[3].g", // K3_G = 0x17 - I_KCOLORS"[0].b", // K0_B = 0x18 - I_KCOLORS"[1].b", // K1_B = 0x19 - I_KCOLORS"[2].b", // K2_B = 0x1A - I_KCOLORS"[3].b", // K3_B = 0x1B - I_KCOLORS"[0].a", // K0_A = 0x1C - I_KCOLORS"[1].a", // K1_A = 0x1D - I_KCOLORS"[2].a", // K2_A = 0x1E - I_KCOLORS"[3].a", // K3_A = 0x1F + "1.0f", // 1 = 0x00 + "0.875f",// 7_8 = 0x01 + "0.75f", // 3_4 = 0x02 + "0.625f",// 5_8 = 0x03 + "0.5f", // 1_2 = 0x04 + "0.375f",// 3_8 = 0x05 + "0.25f", // 1_4 = 0x06 + "0.125f",// 1_8 = 0x07 + "ERROR", // 0x08 + "ERROR", // 0x09 + "ERROR", // 0x0a + "ERROR", // 0x0b + "ERROR", // 0x0c + "ERROR", // 0x0d + "ERROR", // 0x0e + "ERROR", // 0x0f + I_KCOLORS"[0].r", // K0_R = 0x10 + I_KCOLORS"[1].r", // K1_R = 0x11 + I_KCOLORS"[2].r", // K2_R = 0x12 + I_KCOLORS"[3].r", // K3_R = 0x13 + I_KCOLORS"[0].g", // K0_G = 0x14 + I_KCOLORS"[1].g", // K1_G = 0x15 + I_KCOLORS"[2].g", // K2_G = 0x16 + I_KCOLORS"[3].g", // K3_G = 0x17 + I_KCOLORS"[0].b", // K0_B = 0x18 + I_KCOLORS"[1].b", // K1_B = 0x19 + I_KCOLORS"[2].b", // K2_B = 0x1A + I_KCOLORS"[3].b", // K3_B = 0x1B + I_KCOLORS"[0].a", // K0_A = 0x1C + I_KCOLORS"[1].a", // K1_A = 0x1D + I_KCOLORS"[2].a", // K2_A = 0x1E + I_KCOLORS"[3].a", // K3_A = 0x1F }; static const char *tevScaleTable[] = // CS { - "1.0f", // SCALE_1 - "2.0f", // SCALE_2 - "4.0f", // SCALE_4 - "0.5f", // DIVIDE_2 + "1.0f", // SCALE_1 + "2.0f", // SCALE_2 + "4.0f", // SCALE_4 + "0.5f", // DIVIDE_2 }; static const char *tevBiasTable[] = // TB { - "", // ZERO, - "+0.5f", // ADDHALF, - "-0.5f", // SUBHALF, - "", + "", // ZERO, + "+0.5f", // ADDHALF, + "-0.5f", // SUBHALF, + "", }; static const char *tevOpTable[] = { // TEV - "+", // TEVOP_ADD = 0, - "-", // TEVOP_SUB = 1, + "+", // TEVOP_ADD = 0, + "-", // TEVOP_SUB = 1, }; static const char *tevCInputTable[] = // CC { - "(prev.rgb)", // CPREV, - "(prev.aaa)", // APREV, - "(c0.rgb)", // C0, - "(c0.aaa)", // A0, - "(c1.rgb)", // C1, - "(c1.aaa)", // A1, - "(c2.rgb)", // C2, - "(c2.aaa)", // A2, - "(textemp.rgb)", // TEXC, - "(textemp.aaa)", // TEXA, - "(rastemp.rgb)", // RASC, - "(rastemp.aaa)", // RASA, - "float3(1.0f,1.0f,1.0f)", // ONE - "float3(0.5f,0.5f,0.5f)", // HALF - "(konsttemp.rgb)", //"konsttemp.rgb", // KONST - "float3(0.0f,0.0f,0.0f)", // ZERO + "(prev.rgb)", // CPREV, + "(prev.aaa)", // APREV, + "(c0.rgb)", // C0, + "(c0.aaa)", // A0, + "(c1.rgb)", // C1, + "(c1.aaa)", // A1, + "(c2.rgb)", // C2, + "(c2.aaa)", // A2, + "(textemp.rgb)", // TEXC, + "(textemp.aaa)", // TEXA, + "(rastemp.rgb)", // RASC, + "(rastemp.aaa)", // RASA, + "float3(1.0f, 1.0f, 1.0f)", // ONE + "float3(0.5f, 0.5f, 0.5f)", // HALF + "(konsttemp.rgb)", //"konsttemp.rgb", // KONST + "float3(0.0f, 0.0f, 0.0f)", // ZERO ///aded extra values to map clamped values "(cprev.rgb)", // CPREV, - "(cprev.aaa)", // APREV, - "(cc0.rgb)", // C0, - "(cc0.aaa)", // A0, - "(cc1.rgb)", // C1, - "(cc1.aaa)", // A1, - "(cc2.rgb)", // C2, - "(cc2.aaa)", // A2, - "(textemp.rgb)", // TEXC, - "(textemp.aaa)", // TEXA, - "(rastemp.rgb)", // RASC, - "(rastemp.aaa)", // RASA, - "float3(1.0f,1.0f,1.0f)", // ONE - "float3(0.5f,0.5f,0.5f)", // HALF - "(konsttemp.rgb)", //"konsttemp.rgb", // KONST - "float3(0.0f,0.0f,0.0f)", // ZERO - "PADERROR", "PADERROR", "PADERROR", "PADERROR", + "(cprev.aaa)", // APREV, + "(cc0.rgb)", // C0, + "(cc0.aaa)", // A0, + "(cc1.rgb)", // C1, + "(cc1.aaa)", // A1, + "(cc2.rgb)", // C2, + "(cc2.aaa)", // A2, + "(textemp.rgb)", // TEXC, + "(textemp.aaa)", // TEXA, + "(rastemp.rgb)", // RASC, + "(rastemp.aaa)", // RASA, + "float3(1.0f, 1.0f, 1.0f)", // ONE + "float3(0.5f, 0.5f, 0.5f)", // HALF + "(konsttemp.rgb)", //"konsttemp.rgb", // KONST + "float3(0.0f, 0.0f, 0.0f)", // ZERO + "PADERROR", "PADERROR", "PADERROR", "PADERROR" }; static const char *tevAInputTable[] = // CA { - "prev", // APREV, - "c0", // A0, - "c1", // A1, - "c2", // A2, - "textemp", // TEXA, - "rastemp", // RASA, - "konsttemp", // KONST, (hw1 had quarter) - "float4(0.0f,0.0f,0.0f,0.0f)", // ZERO - ///aded extra values to map clamped values + "prev", // APREV, + "c0", // A0, + "c1", // A1, + "c2", // A2, + "textemp", // TEXA, + "rastemp", // RASA, + "konsttemp", // KONST, (hw1 had quarter) + "float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO + ///aded extra values to map clamped values "cprev", // APREV, - "cc0", // A0, - "cc1", // A1, - "cc2", // A2, - "textemp", // TEXA, - "rastemp", // RASA, - "konsttemp", // KONST, (hw1 had quarter) - "float4(0.0f,0.0f,0.0f,0.0f)", // ZERO - "PADERROR", "PADERROR", "PADERROR", "PADERROR", - "PADERROR", "PADERROR", "PADERROR", "PADERROR", -}; + "cc0", // A0, + "cc1", // A1, + "cc2", // A2, + "textemp", // TEXA, + "rastemp", // RASA, + "konsttemp", // KONST, (hw1 had quarter) + "float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO + "PADERROR", "PADERROR", "PADERROR", "PADERROR", + "PADERROR", "PADERROR", "PADERROR", "PADERROR", +}; static const char *tevRasTable[] = { - "colors_0", - "colors_1", - "ERROR", //2 - "ERROR", //3 - "ERROR", //4 - "alphabump", // use bump alpha - "(alphabump*(255.0f/248.0f))", //normalized - "float4(0.0f,0.0f,0.0f,0.0f)", // zero + "colors_0", + "colors_1", + "ERROR", //2 + "ERROR", //3 + "ERROR", //4 + "alphabump", // use bump alpha + "(alphabump*(255.0f/248.0f))", //normalized + "float4(0.0f, 0.0f, 0.0f, 0.0f)", // zero }; static const char *alphaRef[2] = { - I_ALPHA"[0].r", - I_ALPHA"[0].g" + I_ALPHA"[0].r", + I_ALPHA"[0].g" }; //static const char *tevTexFunc[] = { "tex2D", "texRECT" }; @@ -329,8 +329,8 @@ static const char *alphaRef[2] = static const char *tevCOutputTable[] = { "prev.rgb", "c0.rgb", "c1.rgb", "c2.rgb" }; static const char *tevAOutputTable[] = { "prev.a", "c0.a", "c1.a", "c2.a" }; static const char *tevIndAlphaSel[] = {"", "x", "y", "z"}; -//static const char *tevIndAlphaScale[] = {"", "*32","*16","*8"}; -static const char *tevIndAlphaScale[] = {"*(248.0f/255.0f)", "*(224.0f/255.0f)","*(240.0f/255.0f)","*(248.0f/255.0f)"}; +//static const char *tevIndAlphaScale[] = {"", "*32", "*16", "*8"}; +static const char *tevIndAlphaScale[] = {"*(248.0f/255.0f)", "*(224.0f/255.0f)", "*(240.0f/255.0f)", "*(248.0f/255.0f)"}; static const char *tevIndBiasField[] = {"", "x", "y", "xy", "z", "xz", "yz", "xyz"}; // indexed by bias static const char *tevIndBiasAdd[] = {"-128.0f", "1.0f", "1.0f", "1.0f" }; // indexed by fmt static const char *tevIndWrapStart[] = {"0.0f", "256.0f", "128.0f", "64.0f", "32.0f", "16.0f", "0.001f" }; @@ -354,58 +354,58 @@ static RegisterState RegisterStates[4]; static void BuildSwapModeTable() { - for (int i = 0; i < 4; i++) - { - swapModeTable[i][0] = swapColors[bpmem.tevksel[i*2].swap1]; - swapModeTable[i][1] = swapColors[bpmem.tevksel[i*2].swap2]; - swapModeTable[i][2] = swapColors[bpmem.tevksel[i*2+1].swap1]; - swapModeTable[i][3] = swapColors[bpmem.tevksel[i*2+1].swap2]; - swapModeTable[i][4] = 0; - } + for (int i = 0; i < 4; i++) + { + swapModeTable[i][0] = swapColors[bpmem.tevksel[i*2].swap1]; + swapModeTable[i][1] = swapColors[bpmem.tevksel[i*2].swap2]; + swapModeTable[i][2] = swapColors[bpmem.tevksel[i*2+1].swap1]; + swapModeTable[i][3] = swapColors[bpmem.tevksel[i*2+1].swap2]; + swapModeTable[i][4] = 0; + } } -const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_TYPE ApiType) +const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_TYPE ApiType) { setlocale(LC_NUMERIC, "C"); // Reset locale for compilation text[sizeof(text) - 1] = 0x7C; // canary - DVSTARTPROFILE(); + DVSTARTPROFILE(); - BuildSwapModeTable(); - int numStages = bpmem.genMode.numtevstages + 1; - int numTexgen = bpmem.genMode.numtexgens; + BuildSwapModeTable(); + int numStages = bpmem.genMode.numtevstages + 1; + int numTexgen = bpmem.genMode.numtexgens; - char *p = text; - WRITE(p, "//Pixel Shader for TEV stages\n"); - WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n", + char *p = text; + WRITE(p, "//Pixel Shader for TEV stages\n"); + WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n", numStages, numTexgen, bpmem.genMode.numindstages); - int nIndirectStagesUsed = 0; - if (bpmem.genMode.numindstages > 0) + int nIndirectStagesUsed = 0; + if (bpmem.genMode.numindstages > 0) { - for (int i = 0; i < numStages; ++i) + for (int i = 0; i < numStages; ++i) { - if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) - nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; - } - } + if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) + nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; + } + } - // Declare samplers - if (texture_mask && ApiType == API_OPENGL) + // Declare samplers + if (texture_mask && ApiType == API_OPENGL) { WRITE(p, "uniform samplerRECT "); bool bfirst = true; for (int i = 0; i < 8; ++i) { - if (texture_mask & (1<= 7) WRITE(p, "float4 clipPos = float4(uv0.w, uv1.w, uv2.w, uv3.w);\n"); @@ -596,25 +587,22 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ WRITE(p, "zCoord = frac(zCoord);\n"); WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n"); } - WRITE(p, "depth = zCoord;\n"); - if (dstAlphaEnable) - WRITE(p, " ocol0 = float4(prev.rgb,"I_ALPHA"[0].a);\n"); + if (dstAlphaEnable) + WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n"); else { - WriteFog(p); - WRITE(p, " ocol0 = prev;\n"); - } - } - - WRITE(p, "}\n"); + WriteFog(p); + WRITE(p, " ocol0 = prev;\n"); + } + } if (text[sizeof(text) - 1] != 0x7C) PanicAlert("PixelShader generator - buffer too small, canary has been eaten!"); setlocale(LC_NUMERIC, ""); // restore locale - return text; + return text; } @@ -622,22 +610,22 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ //table with the color compare operations static const char *TEVCMPColorOPTable[16] = { - "float3(0.0f,0.0f,0.0f)",//0 - "float3(0.0f,0.0f,0.0f)",//1 - "float3(0.0f,0.0f,0.0f)",//2 - "float3(0.0f,0.0f,0.0f)",//3 - "float3(0.0f,0.0f,0.0f)",//4 - "float3(0.0f,0.0f,0.0f)",//5 - "float3(0.0f,0.0f,0.0f)",//6 - "float3(0.0f,0.0f,0.0f)",//7 - " %s + ((%s.r >= %s.r + (0.25f/255.0f)) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_R8_GT 8 - " %s + ((abs(%s.r - %s.r) < (0.5f/255.0f)) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_R8_EQ 9 - " %s + (( dot(%s.rgb, comp16) >= (dot(%s.rgb, comp16) + (0.25f/255.0f))) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_GR16_GT 10 - " %s + (abs(dot(%s.rgb, comp16) - dot(%s.rgb, comp16)) < (0.5f/255.0f) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_GR16_EQ 11 - " %s + (( dot(%s.rgb, comp24) >= (dot(%s.rgb, comp24) + (0.25f/255.0f))) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_BGR24_GT 12 - " %s + (abs(dot(%s.rgb, comp24) - dot(%s.rgb, comp24)) < (0.5f/255.0f) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_BGR24_EQ 13 - " %s + (max(sign(%s.rgb - %s.rgb - (0.25f/255.0f)),float3(0.0f,0.0f,0.0f)) * %s)",//#define TEVCMP_RGB8_GT 14 - " %s + ((float3(1.0f,1.0f,1.0f) - max(sign(abs(%s.rgb - %s.rgb) - (0.5f/255.0f)),float3(0.0f,0.0f,0.0f))) * %s)"//#define TEVCMP_RGB8_EQ 15 + "float3(0.0f, 0.0f, 0.0f)",//0 + "float3(0.0f, 0.0f, 0.0f)",//1 + "float3(0.0f, 0.0f, 0.0f)",//2 + "float3(0.0f, 0.0f, 0.0f)",//3 + "float3(0.0f, 0.0f, 0.0f)",//4 + "float3(0.0f, 0.0f, 0.0f)",//5 + "float3(0.0f, 0.0f, 0.0f)",//6 + "float3(0.0f, 0.0f, 0.0f)",//7 + " %s + ((%s.r >= %s.r + (0.25f/255.0f)) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_R8_GT 8 + " %s + ((abs(%s.r - %s.r) < (0.5f/255.0f)) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_R8_EQ 9 + " %s + (( dot(%s.rgb, comp16) >= (dot(%s.rgb, comp16) + (0.25f/255.0f))) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_GR16_GT 10 + " %s + (abs(dot(%s.rgb, comp16) - dot(%s.rgb, comp16)) < (0.5f/255.0f) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_GR16_EQ 11 + " %s + (( dot(%s.rgb, comp24) >= (dot(%s.rgb, comp24) + (0.25f/255.0f))) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_BGR24_GT 12 + " %s + (abs(dot(%s.rgb, comp24) - dot(%s.rgb, comp24)) < (0.5f/255.0f) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_BGR24_EQ 13 + " %s + (max(sign(%s.rgb - %s.rgb - (0.25f/255.0f)), float3(0.0f, 0.0f, 0.0f)) * %s)",//#define TEVCMP_RGB8_GT 14 + " %s + ((float3(1.0f, 1.0f, 1.0f) - max(sign(abs(%s.rgb - %s.rgb) - (0.5f/255.0f)), float3(0.0f, 0.0f, 0.0f))) * %s)"//#define TEVCMP_RGB8_EQ 15 }; //table with the alpha compare operations @@ -665,115 +653,115 @@ static const char *TEVCMPAlphaOPTable[16] = static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) { - char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap]; - char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap]; + char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap]; + char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap]; - int texcoord = bpmem.tevorders[n/2].getTexCoord(n&1); - bool bHasTexCoord = (u32)texcoord < bpmem.genMode.numtexgens; - bool bHasIndStage = bpmem.tevind[n].IsActive() && bpmem.tevind[n].bt < bpmem.genMode.numindstages; + int texcoord = bpmem.tevorders[n/2].getTexCoord(n&1); + bool bHasTexCoord = (u32)texcoord < bpmem.genMode.numtexgens; + bool bHasIndStage = bpmem.tevind[n].IsActive() && bpmem.tevind[n].bt < bpmem.genMode.numindstages; - // HACK to handle cases where the tex gen is not enabled - if (!bHasTexCoord) - texcoord = 0; + // HACK to handle cases where the tex gen is not enabled + if (!bHasTexCoord) + texcoord = 0; - if (bHasIndStage) + if (bHasIndStage) { - // perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords - if (bpmem.tevind[n].bs != ITBA_OFF) + // perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords + if (bpmem.tevind[n].bs != ITBA_OFF) { WRITE(p, "alphabump = indtex%d.%s %s;\n", bpmem.tevind[n].bt, tevIndAlphaSel[bpmem.tevind[n].bs], - tevIndAlphaScale[bpmem.tevind[n].fmt]); - } - // format - WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, bpmem.tevind[n].bt, tevIndFmtScale[bpmem.tevind[n].fmt]); + tevIndAlphaScale[bpmem.tevind[n].fmt]); + } + // format + WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, bpmem.tevind[n].bt, tevIndFmtScale[bpmem.tevind[n].fmt]); - // bias - if (bpmem.tevind[n].bias != ITB_NONE ) - WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[bpmem.tevind[n].bias], tevIndBiasAdd[bpmem.tevind[n].fmt]); + // bias + if (bpmem.tevind[n].bias != ITB_NONE ) + WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[bpmem.tevind[n].bias], tevIndBiasAdd[bpmem.tevind[n].fmt]); - // multiply by offset matrix and scale - if (bpmem.tevind[n].mid != 0) + // multiply by offset matrix and scale + if (bpmem.tevind[n].mid != 0) { - if (bpmem.tevind[n].mid <= 3) + if (bpmem.tevind[n].mid <= 3) { - int mtxidx = 2*(bpmem.tevind[n].mid-1); - WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n", - n, mtxidx, n, mtxidx+1, n); - } - else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord) + int mtxidx = 2*(bpmem.tevind[n].mid-1); + WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n", + n, mtxidx, n, mtxidx+1, n); + } + else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord) { // s matrix - int mtxidx = 2*(bpmem.tevind[n].mid-5); - WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n); - } - else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord) + int mtxidx = 2*(bpmem.tevind[n].mid-5); + WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n); + } + else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord) { // t matrix - int mtxidx = 2*(bpmem.tevind[n].mid-9); - WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n); - } - else - WRITE(p, "float2 indtevtrans%d = 0;\n", n); - } - else - WRITE(p, "float2 indtevtrans%d = 0;\n", n); + int mtxidx = 2*(bpmem.tevind[n].mid-9); + WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n); + } + else + WRITE(p, "float2 indtevtrans%d = 0;\n", n); + } + else + WRITE(p, "float2 indtevtrans%d = 0;\n", n); - // --------- + // --------- // Wrapping // --------- - // wrap S - if (bpmem.tevind[n].sw == ITW_OFF) - WRITE(p, "wrappedcoord.x = uv%d.x;\n", texcoord); - else if (bpmem.tevind[n].sw == ITW_0) - WRITE(p, "wrappedcoord.x = 0.0f;\n"); - else - WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]); + // wrap S + if (bpmem.tevind[n].sw == ITW_OFF) + WRITE(p, "wrappedcoord.x = uv%d.x;\n", texcoord); + else if (bpmem.tevind[n].sw == ITW_0) + WRITE(p, "wrappedcoord.x = 0.0f;\n"); + else + WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]); - // wrap T - if (bpmem.tevind[n].tw == ITW_OFF) - WRITE(p, "wrappedcoord.y = uv%d.y;\n", texcoord); - else if (bpmem.tevind[n].tw == ITW_0) - WRITE(p, "wrappedcoord.y = 0.0f;\n"); - else - WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]); + // wrap T + if (bpmem.tevind[n].tw == ITW_OFF) + WRITE(p, "wrappedcoord.y = uv%d.y;\n", texcoord); + else if (bpmem.tevind[n].tw == ITW_0) + WRITE(p, "wrappedcoord.y = 0.0f;\n"); + else + WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]); - if (bpmem.tevind[n].fb_addprev) // add previous tevcoord - WRITE(p, "tevcoord.xy += wrappedcoord + indtevtrans%d;\n", n); - else - WRITE(p, "tevcoord.xy = wrappedcoord + indtevtrans%d;\n", n); - } + if (bpmem.tevind[n].fb_addprev) // add previous tevcoord + WRITE(p, "tevcoord.xy += wrappedcoord + indtevtrans%d;\n", n); + else + WRITE(p, "tevcoord.xy = wrappedcoord + indtevtrans%d;\n", n); + } - WRITE(p, "rastemp=%s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)],rasswap); + WRITE(p, "rastemp = %s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)], rasswap); - if (bpmem.tevorders[n/2].getEnable(n&1)) + if (bpmem.tevorders[n/2].getEnable(n&1)) { - int texmap = bpmem.tevorders[n/2].getTexMap(n&1); - if(!bHasIndStage) + int texmap = bpmem.tevorders[n/2].getTexMap(n&1); + if(!bHasIndStage) { - // calc tevcord - if(bHasTexCoord) - WRITE(p, "tevcoord.xy = uv%d.xy;\n", texcoord); - else - WRITE(p, "tevcoord.xy = float2(0.0f,0.0f);\n"); - } + // calc tevcord + if(bHasTexCoord) + WRITE(p, "tevcoord.xy = uv%d.xy;\n", texcoord); + else + WRITE(p, "tevcoord.xy = float2(0.0f, 0.0f);\n"); + } - SampleTexture(p, "textemp", "tevcoord", texswap, texmap, texture_mask, ApiType); - } - else - WRITE(p, "textemp=float4(1.0f,1.0f,1.0f,1.0f);\n"); + SampleTexture(p, "textemp", "tevcoord", texswap, texmap, texture_mask, ApiType); + } + else + WRITE(p, "textemp = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); - int kc = bpmem.tevksel[n / 2].getKC(n & 1); - int ka = bpmem.tevksel[n / 2].getKA(n & 1); + int kc = bpmem.tevksel[n / 2].getKC(n & 1); + int ka = bpmem.tevksel[n / 2].getKA(n & 1); - TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC; - TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC; + TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC; + TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC; - bool bCKonst = cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST; - bool bAKonst = ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST; - if (bCKonst || bAKonst ) - WRITE(p, "konsttemp=float4(%s,%s);\n",tevKSelTableC[kc],tevKSelTableA[ka]); + bool bCKonst = cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST; + bool bAKonst = ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST; + if (bCKonst || bAKonst ) + WRITE(p, "konsttemp = float4(%s, %s);\n", tevKSelTableC[kc], tevKSelTableA[ka]); if(cc.a == TEVCOLORARG_CPREV || cc.a == TEVCOLORARG_APREV @@ -787,13 +775,13 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) { if(RegisterStates[0].AlphaNeedOverflowControl || RegisterStates[0].ColorNeedOverflowControl) { - WRITE(p, "cprev = frac(4.0f + prev * (255.0f/256.0f)) * (256.0f/255.0f);\n"); + WRITE(p, "cprev = frac(4.0f + prev * (255.0f/256.0f)) * (256.0f/255.0f);\n"); RegisterStates[0].AlphaNeedOverflowControl = false; - RegisterStates[0].ColorNeedOverflowControl = false; + RegisterStates[0].ColorNeedOverflowControl = false; } else { - WRITE(p, "cprev = prev;\n"); + WRITE(p, "cprev = prev;\n"); } RegisterStates[0].AuxStored = true; } @@ -820,7 +808,6 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) } RegisterStates[1].AuxStored = true; } - if(cc.a == TEVCOLORARG_C1 || cc.a == TEVCOLORARG_A1 @@ -870,149 +857,151 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType) RegisterStates[cc.dest].ColorNeedOverflowControl = (cc.clamp == 0); RegisterStates[cc.dest].AuxStored = false; - if (cc.clamp) - WRITE(p, "%s=saturate(", tevCOutputTable[cc.dest]); + if (cc.clamp) + WRITE(p, "%s = saturate(", tevCOutputTable[cc.dest]); else - WRITE(p, "%s=", tevCOutputTable[cc.dest]); + WRITE(p, "%s = ", tevCOutputTable[cc.dest]); - // combine the color channel + // combine the color channel if (cc.bias != TevBias_COMPARE) // if not compare { - //normal color combiner goes here + //normal color combiner goes here if (cc.shift > TEVSCALE_1) - WRITE(p, "%s*(",tevScaleTable[cc.shift]); + WRITE(p, "%s*(", tevScaleTable[cc.shift]); if(!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD)) - WRITE(p, "%s%s",tevCInputTable[cc.d],tevOpTable[cc.op]); + WRITE(p, "%s%s", tevCInputTable[cc.d], tevOpTable[cc.op]); if (cc.a == cc.b) - WRITE(p,"%s",tevCInputTable[cc.a + 16]); + WRITE(p, "%s", tevCInputTable[cc.a + 16]); else if (cc.c == TEVCOLORARG_ZERO) - WRITE(p,"%s",tevCInputTable[cc.a + 16]); + WRITE(p, "%s", tevCInputTable[cc.a + 16]); else if (cc.c == TEVCOLORARG_ONE) - WRITE(p,"%s",tevCInputTable[cc.b + 16]); + WRITE(p, "%s", tevCInputTable[cc.b + 16]); else if (cc.a == TEVCOLORARG_ZERO) - WRITE(p,"%s*%s",tevCInputTable[cc.b + 16],tevCInputTable[cc.c + 16]); + WRITE(p, "%s*%s", tevCInputTable[cc.b + 16], tevCInputTable[cc.c + 16]); else if (cc.b == TEVCOLORARG_ZERO) - WRITE(p,"%s*(float3(1.0f,1.0f,1.0f)-%s)",tevCInputTable[cc.a + 16],tevCInputTable[cc.c + 16]); + WRITE(p, "%s*(float3(1.0f, 1.0f, 1.0f)-%s)", tevCInputTable[cc.a + 16], tevCInputTable[cc.c + 16]); else - WRITE(p, "lerp(%s,%s,%s)",tevCInputTable[cc.a + 16], tevCInputTable[cc.b + 16],tevCInputTable[cc.c + 16]); + WRITE(p, "lerp(%s, %s, %s)", tevCInputTable[cc.a + 16], tevCInputTable[cc.b + 16], tevCInputTable[cc.c + 16]); - WRITE(p, "%s",tevBiasTable[cc.bias]); + WRITE(p, "%s", tevBiasTable[cc.bias]); - if(cc.shift>0) + if (cc.shift > 0) WRITE(p, ")"); - } - else + } + else { - int cmp = (cc.shift<<1)|cc.op|8; // comparemode stored here + int cmp = (cc.shift<<1)|cc.op|8; // comparemode stored here WRITE(p, TEVCMPColorOPTable[cmp],//lookup the function from the op table - tevCInputTable[cc.d], + tevCInputTable[cc.d], tevCInputTable[cc.a + 16], tevCInputTable[cc.b + 16], - tevCInputTable[cc.c + 16]); - } + tevCInputTable[cc.c + 16]); + } if (cc.clamp) - WRITE(p,")"); - WRITE(p,";\n"); - + WRITE(p, ")"); + WRITE(p,";\n"); + RegisterStates[ac.dest].AlphaNeedOverflowControl = (ac.clamp == 0); RegisterStates[ac.dest].AuxStored = false; - // combine the alpha channel - if (ac.clamp) - WRITE(p, "%s=saturate(", tevAOutputTable[ac.dest]); + // combine the alpha channel + if (ac.clamp) + WRITE(p, "%s = saturate(", tevAOutputTable[ac.dest]); else - WRITE(p, "%s=", tevAOutputTable[ac.dest]); + WRITE(p, "%s = ", tevAOutputTable[ac.dest]); - if (ac.bias != TevBias_COMPARE) // if not compare + if (ac.bias != TevBias_COMPARE) // if not compare { - //normal alpha combiner goes here + //normal alpha combiner goes here if (ac.shift > TEVSCALE_1) - WRITE(p, "%s*(",tevScaleTable[ac.shift]); + WRITE(p, "%s*(", tevScaleTable[ac.shift]); if(!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD)) - WRITE(p, "%s.a%s",tevAInputTable[ac.d],tevOpTable[ac.op]); + WRITE(p, "%s.a%s", tevAInputTable[ac.d], tevOpTable[ac.op]); if (ac.a == ac.b) - WRITE(p,"%s.a",tevAInputTable[ac.a + 8]); + WRITE(p, "%s.a", tevAInputTable[ac.a + 8]); else if (ac.c == TEVALPHAARG_ZERO) - WRITE(p,"%s.a",tevAInputTable[ac.a + 8]); + WRITE(p, "%s.a", tevAInputTable[ac.a + 8]); else if (ac.a == TEVALPHAARG_ZERO) - WRITE(p,"%s.a*%s.a",tevAInputTable[ac.b + 8],tevAInputTable[ac.c + 8]); + WRITE(p, "%s.a*%s.a", tevAInputTable[ac.b + 8], tevAInputTable[ac.c + 8]); else if (ac.b == TEVALPHAARG_ZERO) - WRITE(p,"%s.a*(1.0f-%s.a)",tevAInputTable[ac.a + 8],tevAInputTable[ac.c + 8]); + WRITE(p, "%s.a*(1.0f-%s.a)", tevAInputTable[ac.a + 8], tevAInputTable[ac.c + 8]); else - WRITE(p, "lerp(%s.a,%s.a,%s.a)",tevAInputTable[ac.a + 8],tevAInputTable[ac.b + 8],tevAInputTable[ac.c + 8]); + WRITE(p, "lerp(%s.a, %s.a, %s.a)", tevAInputTable[ac.a + 8], tevAInputTable[ac.b + 8], tevAInputTable[ac.c + 8]); WRITE(p, "%s",tevBiasTable[ac.bias]); if (ac.shift>0) WRITE(p, ")"); - } - else + } + else { - //compare alpha combiner goes here - int cmp = (ac.shift<<1)|ac.op|8; // comparemode stored here - WRITE(p, TEVCMPAlphaOPTable[cmp], - tevAInputTable[ac.d], - tevAInputTable[ac.a + 8], - tevAInputTable[ac.b + 8], - tevAInputTable[ac.c + 8]); - } + //compare alpha combiner goes here + int cmp = (ac.shift<<1)|ac.op|8; // comparemode stored here + WRITE(p, TEVCMPAlphaOPTable[cmp], + tevAInputTable[ac.d], + tevAInputTable[ac.a + 8], + tevAInputTable[ac.b + 8], + tevAInputTable[ac.c + 8]); + } if (ac.clamp) WRITE(p, ")"); - WRITE(p, ";\n\n"); + WRITE(p, ";\n\n"); } void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, u32 texture_mask, API_TYPE ApiType) { - if (texture_mask & (1< 0) + u32 lightMask = 0; + if (xfregs.nNumChans > 0) lightMask |= xfregs.colChans[0].color.GetFullLightMask() | xfregs.colChans[0].alpha.GetFullLightMask(); - if (xfregs.nNumChans > 1) - lightMask |= xfregs.colChans[1].color.GetFullLightMask() | xfregs.colChans[1].alpha.GetFullLightMask(); + if (xfregs.nNumChans > 1) + lightMask |= xfregs.colChans[1].color.GetFullLightMask() | xfregs.colChans[1].alpha.GetFullLightMask(); - char *p = text; - WRITE(p, "//Vertex Shader: comp:%x, \n", components); - WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_"I_POSNORMALMATRIX";\n" - "typedef struct { float4 t; } FLT4;\n" - "typedef struct { FLT4 T[24]; } s_"I_TEXMATRICES";\n" - "typedef struct { FLT4 T[64]; } s_"I_TRANSFORMMATRICES";\n" - "typedef struct { FLT4 T[32]; } s_"I_NORMALMATRICES";\n" - "typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n" - "typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n" - "typedef struct { Light lights[8]; } s_"I_LIGHTS";\n" - "typedef struct { float4 C0,C1,C2,C3; } s_"I_MATERIALS";\n" - "typedef struct { float4 T0,T1,T2,T3; } s_"I_PROJECTION";\n" - ); + char *p = text; + WRITE(p, "//Vertex Shader: comp:%x, \n", components); + WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_"I_POSNORMALMATRIX";\n" + "typedef struct { float4 t; } FLT4;\n" + "typedef struct { FLT4 T[24]; } s_"I_TEXMATRICES";\n" + "typedef struct { FLT4 T[64]; } s_"I_TRANSFORMMATRICES";\n" + "typedef struct { FLT4 T[32]; } s_"I_NORMALMATRICES";\n" + "typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n" + "typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n" + "typedef struct { Light lights[8]; } s_"I_LIGHTS";\n" + "typedef struct { float4 C0, C1, C2, C3; } s_"I_MATERIALS";\n" + "typedef struct { float4 T0, T1, T2, T3; } s_"I_PROJECTION";\n" + ); - WRITE(p, "struct VS_OUTPUT {\n"); - WRITE(p, " float4 pos : POSITION;\n"); - WRITE(p, " float4 colors[2] : COLOR0;\n"); + WRITE(p, "struct VS_OUTPUT {\n"); + WRITE(p, " float4 pos : POSITION;\n"); + WRITE(p, " float4 colors[2] : COLOR0;\n"); if (xfregs.numTexGens < 7) { for (int i = 0; i < xfregs.numTexGens; ++i) @@ -123,46 +123,46 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) for (int i = 0; i < xfregs.numTexGens; ++i) WRITE(p, " float%d tex%d : TEXCOORD%d;\n", i<4?4:3, i, i); } - WRITE(p, "};\n"); + WRITE(p, "};\n"); - // uniforms + // uniforms WRITE(p, "uniform s_"I_TRANSFORMMATRICES" "I_TRANSFORMMATRICES" : register(c%d);\n", C_TRANSFORMMATRICES); - WRITE(p, "uniform s_"I_TEXMATRICES" "I_TEXMATRICES" : register(c%d);\n", C_TEXMATRICES); // also using tex matrices - WRITE(p, "uniform s_"I_NORMALMATRICES" "I_NORMALMATRICES" : register(c%d);\n", C_NORMALMATRICES); - WRITE(p, "uniform s_"I_POSNORMALMATRIX" "I_POSNORMALMATRIX" : register(c%d);\n", C_POSNORMALMATRIX); - WRITE(p, "uniform s_"I_POSTTRANSFORMMATRICES" "I_POSTTRANSFORMMATRICES" : register(c%d);\n", C_POSTTRANSFORMMATRICES); - WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS); - WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS); - WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION); + WRITE(p, "uniform s_"I_TEXMATRICES" "I_TEXMATRICES" : register(c%d);\n", C_TEXMATRICES); // also using tex matrices + WRITE(p, "uniform s_"I_NORMALMATRICES" "I_NORMALMATRICES" : register(c%d);\n", C_NORMALMATRICES); + WRITE(p, "uniform s_"I_POSNORMALMATRIX" "I_POSNORMALMATRIX" : register(c%d);\n", C_POSNORMALMATRIX); + WRITE(p, "uniform s_"I_POSTTRANSFORMMATRICES" "I_POSTTRANSFORMMATRICES" : register(c%d);\n", C_POSTTRANSFORMMATRICES); + WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS); + WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS); + WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION); - WRITE(p, "VS_OUTPUT main(\n"); - - // inputs - if (components & VB_HAS_NRM0) - WRITE(p, " float3 rawnorm0 : NORMAL0,\n"); - if (components & VB_HAS_NRM1) { + WRITE(p, "VS_OUTPUT main(\n"); + + // inputs + if (components & VB_HAS_NRM0) + WRITE(p, " float3 rawnorm0 : NORMAL0,\n"); + if (components & VB_HAS_NRM1) { if (is_d3d) WRITE(p, " float3 rawnorm1 : NORMAL1,\n"); else WRITE(p, " float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB); } - if (components & VB_HAS_NRM2) { - if (is_d3d) + if (components & VB_HAS_NRM2) { + if (is_d3d) WRITE(p, " float3 rawnorm2 : NORMAL2,\n"); else WRITE(p, " float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB); } - if (components & VB_HAS_COL0) - WRITE(p, " float4 color0 : COLOR0,\n"); - if (components & VB_HAS_COL1) - WRITE(p, " float4 color1 : COLOR1,\n"); - for (int i = 0; i < 8; ++i) { - u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<= 32 ? (posmtx-32) : posmtx;\n"); - WRITE(p, "float3 N0 = "I_NORMALMATRICES".T[normidx].t.xyz, N1 = "I_NORMALMATRICES".T[normidx+1].t.xyz, N2 = "I_NORMALMATRICES".T[normidx+2].t.xyz;\n"); - } + WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos), 1);\n"); + + if (components & VB_HAS_NRMALL) { + WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n"); + WRITE(p, "float3 N0 = "I_NORMALMATRICES".T[normidx].t.xyz, N1 = "I_NORMALMATRICES".T[normidx+1].t.xyz, N2 = "I_NORMALMATRICES".T[normidx+2].t.xyz;\n"); + } - if (components & VB_HAS_NRM0) - WRITE(p, "float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n"); - if (components & VB_HAS_NRM1) - WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n"); - if (components & VB_HAS_NRM2) - WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n"); - - } - else { - WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n"); - if (components & VB_HAS_NRM0) - WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n"); - if (components & VB_HAS_NRM1) - WRITE(p, "float3 _norm1 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm1));\n"); - if (components & VB_HAS_NRM2) - WRITE(p, "float3 _norm2 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm2));\n"); - } + if (components & VB_HAS_NRM0) + WRITE(p, "float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n"); + if (components & VB_HAS_NRM1) + WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n"); + if (components & VB_HAS_NRM2) + WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n"); + } + else + { + WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n"); + if (components & VB_HAS_NRM0) + WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n"); + if (components & VB_HAS_NRM1) + WRITE(p, "float3 _norm1 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm1));\n"); + if (components & VB_HAS_NRM2) + WRITE(p, "float3 _norm2 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm2));\n"); + } - if (!(components & VB_HAS_NRM0)) - WRITE(p, "float3 _norm0 = float3(0.0f,0.0f,0.0f);\n"); + if (!(components & VB_HAS_NRM0)) + WRITE(p, "float3 _norm0 = float3(0.0f, 0.0f, 0.0f);\n"); - WRITE(p, "o.pos = float4(dot("I_PROJECTION".T0, pos), dot("I_PROJECTION".T1, pos), dot("I_PROJECTION".T2, pos), dot("I_PROJECTION".T3, pos));\n"); + WRITE(p, "o.pos = float4(dot("I_PROJECTION".T0, pos), dot("I_PROJECTION".T1, pos), dot("I_PROJECTION".T2, pos), dot("I_PROJECTION".T3, pos));\n"); - WRITE(p, "float4 mat,lacc;\n" // = half4(1,1,1,1), lacc = half4(0,0,0,0);\n" - "float3 ldir, h;\n" - "float dist, dist2, attn;\n"); + WRITE(p, "float4 mat, lacc;\n" // = half4(1, 1, 1, 1), lacc = half4(0, 0, 0, 0);\n" + "float3 ldir, h;\n" + "float dist, dist2, attn;\n"); - // lights/colors - for (int j = 0; j < xfregs.nNumChans; j++) { + // lights/colors + for (int j = 0; j < xfregs.nNumChans; j++) + { - // bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused - const LitChannel& color = xfregs.colChans[j].color; - const LitChannel& alpha = xfregs.colChans[j].alpha; + // bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused + const LitChannel& color = xfregs.colChans[j].color; + const LitChannel& alpha = xfregs.colChans[j].alpha; - WRITE(p, "{\n"); - - WRITE(p, "lacc = float4(1.0f,1.0f,1.0f,1.0f);\n"); - if (color.matsource) {// from vertex - if (components & (VB_HAS_COL0 << j)) - WRITE(p, "mat = color%d;\n", j); - else - WRITE(p, "mat = float4(1.0f,1.0f,1.0f,1.0f);\n"); - } - else // from color - WRITE(p, "mat = "I_MATERIALS".C%d;\n", j+2); + WRITE(p, "{\n"); + + WRITE(p, "lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); + if (color.matsource) {// from vertex + if (components & (VB_HAS_COL0 << j)) + WRITE(p, "mat = color%d;\n", j); + else + WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n"); + } + else // from color + WRITE(p, "mat = "I_MATERIALS".C%d;\n", j+2); - if (color.enablelighting) { - if (color.ambsource) { // from vertex - if (components & (VB_HAS_COL0< 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index); - WRITE(p, "ldir = float3(1,attn,attn*attn);\n"); - WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index); - } + if (chan.attnfunc == 3) { // spot + WRITE(p, "dist2 = dot(ldir, ldir);\n" + "dist = sqrt(dist2);\n" + "ldir = ldir / dist;\n" + "attn = max(0.0f, dot(ldir, "I_LIGHTS".lights[%d].dir.xyz));\n",index); + WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, float3(1.0f, attn, attn*attn))) / dot("I_LIGHTS".lights[%d].distatt.xyz, float3(1.0f,dist,dist2));\n", index, index); + } + else if (chan.attnfunc == 1) { // specular + WRITE(p, "attn = (dot(_norm0, "I_LIGHTS".lights[%d].pos.xyz) > 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index); + WRITE(p, "ldir = float3(1,attn,attn*attn);\n"); + WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index); + } - switch (chan.diffusefunc) { - case LIGHTDIF_NONE: - WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle); - break; - case LIGHTDIF_SIGN: - case LIGHTDIF_CLAMP: - WRITE(p, "%s.%s += attn * %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n", - dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle); - break; - default: _assert_(0); - } - } - WRITE(p, "\n"); + switch (chan.diffusefunc) + { + case LIGHTDIF_NONE: + WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle); + break; + case LIGHTDIF_SIGN: + case LIGHTDIF_CLAMP: + WRITE(p, "%s.%s += attn * %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n", + dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle); + break; + default: _assert_(0); + } + } + WRITE(p, "\n"); setlocale(LC_NUMERIC, ""); // restore locale - return p; + return p; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index b85cd2c662..b11be884f0 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -284,7 +284,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw float sizeratio = size / (float)m_LineHeight; // translate starting positions - float sx = x * scalex - 1.f; + float sx = x * scalex - 1.f; float sy = 1.f - y * scaley; char c; @@ -355,7 +355,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw v[4] = v[2]; v[5] = v[1]; - memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX)); + memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX)); pVertices+=6; dwNumTriangles += 2; @@ -416,7 +416,7 @@ ID3D11Buffer* clearvb = NULL; typedef struct { float x,y,z,u,v; } STQVertex; typedef struct { float x,y,z,u,v; } STSQVertex; -typedef struct { float x,y,z; u32 col;} ClearVertex; +typedef struct { float x,y,z; u32 col; } ClearVertex; void InitUtils() { @@ -496,7 +496,7 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture, D3D::context->IASetInputLayout(layout); D3D::context->IASetVertexBuffers(0, 1, &stqvb, &stride, &offset); D3D::context->PSSetSamplers(0, 1, &stqsamplerstate); - D3D::context->PSSetShader(PShader, NULL, 0); + D3D::context->PSSetShader(PShader, NULL, 0); D3D::context->PSSetShaderResources(0, 1, &texture); D3D::context->VSSetShader(Vshader, NULL, 0); D3D::stateman->Apply(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp index 9d30d2d80a..218afd6c9f 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp @@ -361,4 +361,4 @@ void StateManager::Apply() else ERROR_LOG(VIDEO, "Tried to apply without rasterizer state!"); } -} // namespace \ No newline at end of file +} // namespace diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp index ad67bbcb90..5c587aa573 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp @@ -140,13 +140,13 @@ bool Init() CreateDeviceObjects(); - IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer); + IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer); return true; } void ResetBuffer() { - s_pCurBufferPointer = LocalVBuffer; + s_pCurBufferPointer = LocalVBuffer; } void Shutdown() @@ -163,12 +163,12 @@ void AddIndices(int _primitive, int _numVertices) { switch (_primitive) { - case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break; + case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break; case GX_DRAW_TRIANGLES: IndexGenerator::AddList(_numVertices); break; case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break; case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break; case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break; - case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break; + case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break; case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break; } } @@ -225,7 +225,7 @@ void AddVertices(int _primitive, int _numVertices) IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer); Flushed=false; } - lastPrimitive = _primitive; + lastPrimitive = _primitive; ADDSTAT(stats.thisFrame.numPrims, _numVertices); INCSTAT(stats.thisFrame.numPrimitiveJoins); AddIndices(_primitive, _numVertices); @@ -244,7 +244,7 @@ inline void Draw(unsigned int stride, bool alphapass) } UINT bufoffset = 0; - UINT bufstride = (UINT)stride; + UINT bufstride = stride; if (!alphapass) gfxstate->ApplyState(); else gfxstate->AlphaPass(); @@ -361,7 +361,7 @@ void Flush() Draw(stride, false); - if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate) + if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate) { DWORD write = 0; if (!PixelShaderCache::SetShader(true)) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 7ace253277..77d631bf93 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -92,16 +92,6 @@ bool IsD3D() return true; } -bool IsD3D9() -{ - return false; -} - -bool IsD3D11() -{ - return true; -} - // This is used for the functions right below here which use wxwidgets #if defined(HAVE_WX) && HAVE_WX WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); @@ -128,7 +118,7 @@ void DllDebugger(HWND _hParent, bool Show) return true; } }; - IMPLEMENT_APP_NO_MAIN(wxDLLApp) + IMPLEMENT_APP_NO_MAIN(wxDLLApp) WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); #endif @@ -173,7 +163,7 @@ void UpdateFPSDisplay(const char* text) { char temp[512]; sprintf_s(temp, 512, "SVN R%i: DX11: %s", SVN_REV, text); - SetWindowTextA(EmuWindow::GetWnd(), temp); + SetWindowTextA(EmuWindow::GetWnd(), temp); } void GetDllInfo(PLUGIN_INFO* _PluginInfo) @@ -220,9 +210,9 @@ void Initialize(void* init) g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; - _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; - _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; - _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; + _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; + _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; + _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; OSD::AddMessage("Dolphin Direct3D 11 Video Plugin.", 5000); s_PluginInitialized = true; @@ -244,8 +234,8 @@ void Video_Prepare() VertexShaderManager::Init(); PixelShaderCache::Init(); PixelShaderManager::Init(); - CommandProcessor::Init(); - PixelEngine::Init(); + CommandProcessor::Init(); + PixelEngine::Init(); D3D::InitUtils(); // tell the host that the window is ready @@ -339,14 +329,14 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) if (addrRangesOverlap(aLower, aUpper, bLower, bUpper)) VideoFifo_CheckSwapRequest(); } - } + } } // Run from the CPU thread (from VideoInterface.cpp) void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { if (s_PluginInitialized && g_ActiveConfig.bUseXFB) - { + { if (g_VideoInitialize.bOnThread) { while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown) @@ -354,7 +344,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) Common::YieldCPU(); } else - VideoFifo_CheckSwapRequest(); + VideoFifo_CheckSwapRequest(); s_beginFieldArgs.xfbAddr = xfbAddr; s_beginFieldArgs.field = field; s_beginFieldArgs.fbWidth = fbWidth; @@ -373,11 +363,6 @@ void Video_AddMessage(const char* pstr, u32 milliseconds) OSD::AddMessage(pstr, milliseconds); } -HRESULT ScreenShot(const char* filename) -{ - return S_OK; -} - void Video_Screenshot(const char* _szFilename) { Renderer::SetScreenshot(_szFilename); @@ -430,37 +415,37 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address) { - CommandProcessor::Read16(_rReturnValue, _Address); + CommandProcessor::Read16(_rReturnValue, _Address); } void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address) { - CommandProcessor::Write16(_Data, _Address); + CommandProcessor::Write16(_Data, _Address); } void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address) { - PixelEngine::Read16(_rReturnValue, _Address); + PixelEngine::Read16(_rReturnValue, _Address); } void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address) { - PixelEngine::Write16(_Data, _Address); + PixelEngine::Write16(_Data, _Address); } void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address) { - PixelEngine::Write32(_Data, _Address); + PixelEngine::Write32(_Data, _Address); } inline void Video_GatherPipeBursted(void) { - CommandProcessor::GatherPipeBursted(); + CommandProcessor::GatherPipeBursted(); } void Video_WaitForFrameFinish(void) { - CommandProcessor::WaitForFrameFinish(); + CommandProcessor::WaitForFrameFinish(); } bool Video_IsFifoBusy(void) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp index 2b94247d23..9c3a26420b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp @@ -33,10 +33,10 @@ #include "TextureCache.h" BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog) - + EVT_CLOSE(GFXConfigDialogDX::OnClose) EVT_BUTTON(ID_CLOSE, GFXConfigDialogDX::CloseClick) - + //Direct3D Tab EVT_CHECKBOX(ID_VSYNC, GFXConfigDialogDX::DirectXSettingsChanged) EVT_CHECKBOX(ID_WIDESCREEN_HACK, GFXConfigDialogDX::DirectXSettingsChanged) @@ -48,13 +48,13 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog) EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_SAFE, GFXConfigDialogDX::DirectXSettingsChanged) EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_NORMAL, GFXConfigDialogDX::DirectXSettingsChanged) EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_FAST, GFXConfigDialogDX::DirectXSettingsChanged) - + //Enhancements tab EVT_CHECKBOX(ID_FORCEFILTERING, GFXConfigDialogDX::EnhancementsSettingsChanged) EVT_CHECKBOX(ID_FORCEANISOTROPY, GFXConfigDialogDX::EnhancementsSettingsChanged) EVT_CHECKBOX(ID_LOADHIRESTEXTURES, GFXConfigDialogDX::EnhancementsSettingsChanged) EVT_CHECKBOX(ID_EFBSCALEDCOPY, GFXConfigDialogDX::EnhancementsSettingsChanged) - + //Advanced Tab EVT_CHECKBOX(ID_DISABLEFOG, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged) @@ -71,11 +71,11 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog) EVT_CHECKBOX(ID_OVERLAYSTATS, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_PROJSTATS, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_SHADERERRORS, GFXConfigDialogDX::AdvancedSettingsChanged) - EVT_CHECKBOX(ID_TEXFMT_OVERLAY, GFXConfigDialogDX::AdvancedSettingsChanged) + EVT_CHECKBOX(ID_TEXFMT_OVERLAY, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_TEXFMT_CENTER, GFXConfigDialogDX::AdvancedSettingsChanged) - + END_EVENT_TABLE() - + GFXConfigDialogDX::GFXConfigDialogDX(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) { @@ -86,16 +86,19 @@ GFXConfigDialogDX::~GFXConfigDialogDX() { INFO_LOG(CONSOLE, "GFXConfigDialogDX Closed"); } + void GFXConfigDialogDX::OnClose(wxCloseEvent& event) { //INFO_LOG(CONSOLE, "OnClose"); CloseWindow(); } + void GFXConfigDialogDX::CloseClick(wxCommandEvent& WXUNUSED (event)) { //INFO_LOG(CONSOLE, "CloseClick"); CloseWindow(); } + void GFXConfigDialogDX::InitializeGUIValues() { // General Display Settings @@ -115,7 +118,7 @@ void GFXConfigDialogDX::InitializeGUIValues() m_Radio_SafeTextureCache_Normal->SetValue(true); else m_Radio_SafeTextureCache_Fast->SetValue(true); - + // Enhancements if(g_Config.iMaxAnisotropy == 1) m_MaxAnisotropy->SetValue(false); @@ -128,11 +131,11 @@ void GFXConfigDialogDX::InitializeGUIValues() m_HiresTextures->SetValue(g_Config.bHiresTextures); m_MSAAModeCB->SetSelection(g_Config.iMultisampleMode); m_EFBScaledCopy->SetValue(g_Config.bCopyEFBScaled); - + //Advance m_DisableFog->SetValue(g_Config.bDisableFog); m_OverlayFPS->SetValue(g_Config.bShowFPS); - + m_CopyEFB->SetValue(!g_Config.bEFBCopyDisable); g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true); @@ -151,8 +154,9 @@ void GFXConfigDialogDX::InitializeGUIValues() m_TexfmtCenter->SetValue(g_Config.bTexFmtOverlayCenter); m_TexfmtCenter->Enable(m_TexfmtOverlay->IsChecked()); } + void GFXConfigDialogDX::CreateGUIControls() - { +{ this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); @@ -163,19 +167,19 @@ void GFXConfigDialogDX::CreateGUIControls() m_PageDirect3D = new wxPanel( m_Notebook, ID_DIRERCT3D, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_PageEnhancements = new wxPanel( m_Notebook, ID_PAGEENHANCEMENTS, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_PageAdvanced = new wxPanel( m_Notebook, ID_PAGEADVANCED, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - - //D3D Tab + + //D3D Tab wxStaticBoxSizer* sbBasic; sbBasic = new wxStaticBoxSizer( new wxStaticBox( m_PageDirect3D, wxID_ANY, wxT("Basic") ), wxVERTICAL ); m_AdapterText = new wxStaticText( m_PageDirect3D, wxID_ANY, wxT("Adapter:"), wxDefaultPosition, wxDefaultSize, 0 ); m_AdapterText->Wrap( -1 ); - wxArrayString arrayStringFor_AdapterCB; + wxArrayString arrayStringFor_AdapterCB; for (int i = 0; i < D3D::GetNumAdapters(); ++i) { const D3D::Adapter &adapter = D3D::GetAdapter(i); arrayStringFor_AdapterCB.Add(wxString::FromAscii(adapter.ident.Description)); - } + } const D3D::Adapter &adapter = D3D::GetAdapter(g_Config.iAdapter); m_AdapterCB = new wxChoice( m_PageDirect3D, ID_ADAPTER, wxDefaultPosition, wxDefaultSize, arrayStringFor_AdapterCB, 0); @@ -201,21 +205,21 @@ void GFXConfigDialogDX::CreateGUIControls() m_EFBScaleText->Wrap( -1 ); wxString m_EFBScaleModeChoices[] = { wxT("Auto (Fractional)"), wxT("Auto (Integral)"), wxT("1x"), wxT("2x"), wxT("3x") }; int m_EFBScaleModeNChoices = sizeof( m_EFBScaleModeChoices ) / sizeof( wxString ); - m_EFBScaleMode = new wxChoice( m_PageDirect3D, ID_EFBSCALEMODE, wxDefaultPosition, wxDefaultSize, m_EFBScaleModeNChoices, m_EFBScaleModeChoices, 0 ); + m_EFBScaleMode = new wxChoice( m_PageDirect3D, ID_EFBSCALEMODE, wxDefaultPosition, wxDefaultSize, m_EFBScaleModeNChoices, m_EFBScaleModeChoices, 0 ); m_EnableEFBAccess = new wxCheckBox( m_PageDirect3D, ID_EFB_ACCESS_ENABLE, wxT("Enable CPU->EFB access"), wxDefaultPosition, wxDefaultSize, 0 ); - + wxStaticBoxSizer* sbSTC; sbSTC = new wxStaticBoxSizer( new wxStaticBox( m_PageDirect3D, wxID_ANY, wxT("Safe Texture Cache") ), wxVERTICAL ); m_SafeTextureCache = new wxCheckBox( m_PageDirect3D, ID_SAFETEXTURECACHE, wxT("Use Safe Texture Cache"), wxDefaultPosition, wxDefaultSize, 0 ); m_Radio_SafeTextureCache_Safe = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_SAFE, wxT("Safe"), wxDefaultPosition, wxDefaultSize, 0 ); m_Radio_SafeTextureCache_Normal = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_NORMAL, wxT("Normal"), wxDefaultPosition, wxDefaultSize, 0 ); m_Radio_SafeTextureCache_Fast = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_FAST, wxT("Fast"), wxDefaultPosition, wxDefaultSize, 0 ); - + // Sizers wxGridBagSizer* sBasic; wxBoxSizer* sGeneral; - + sGeneral = new wxBoxSizer( wxVERTICAL ); sBasic = new wxGridBagSizer( 0, 0 ); sBasic->SetFlexibleDirection( wxBOTH ); @@ -257,7 +261,7 @@ void GFXConfigDialogDX::CreateGUIControls() m_ForceFiltering = new wxCheckBox( m_PageEnhancements, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering (Breaks video in several Wii games )"), wxDefaultPosition, wxDefaultSize, 0 ); m_MaxAnisotropy = new wxCheckBox( m_PageEnhancements, ID_FORCEANISOTROPY, wxT("Enable 16x Anisotropy filtering"), wxDefaultPosition, wxDefaultSize, 0 ); m_HiresTextures = new wxCheckBox( m_PageEnhancements, ID_LOADHIRESTEXTURES, wxT("Enable hires Texture loading"), wxDefaultPosition, wxDefaultSize, 0 ); - + wxStaticBoxSizer* sbEFBHacks; sbEFBHacks = new wxStaticBoxSizer( new wxStaticBox( m_PageEnhancements, wxID_ANY, wxT("EFB Hacks") ), wxVERTICAL ); m_EFBScaledCopy = new wxCheckBox( m_PageEnhancements, ID_EFBSCALEDCOPY, wxT("EFB Scaled Copy"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -348,10 +352,10 @@ void GFXConfigDialogDX::CreateGUIControls() wxGridBagSizer* sDebuggingTools; sDebuggingTools = new wxGridBagSizer( 0, 0 ); sDebuggingTools->SetFlexibleDirection( wxBOTH ); - sDebuggingTools->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + sDebuggingTools->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); sDebuggingTools->Add( m_OverlayStats, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sDebuggingTools->Add( m_ShaderErrors, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); - sDebuggingTools->Add( m_TexfmtOverlay, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + sDebuggingTools->Add( m_TexfmtOverlay, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sDebuggingTools->Add( m_TexfmtCenter, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sDebuggingTools->Add( m_ProjStats, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sbDebuggingTools->Add( sDebuggingTools, 0, wxEXPAND, 5 ); @@ -380,6 +384,7 @@ void GFXConfigDialogDX::CreateGUIControls() Center(); UpdateGUI(); } + void GFXConfigDialogDX::DirectXSettingsChanged(wxCommandEvent& event) { switch (event.GetId()) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.h b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.h index 3e9d65ca94..dba28f09bf 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.h @@ -162,8 +162,6 @@ class GFXConfigDialogDX : public wxDialog ID_SHADERERRORS, ID_TEXFMT_OVERLAY, ID_TEXFMT_CENTER, - ID_CHECK1, - ID_LIST1, ID_DEBUGSTEP, ID_REGISTERS, ID_ENABLEDEBUGGING, diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 7eee57410e..7cab18f0d0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -182,7 +182,7 @@ static const D3DBLEND d3dLogicOpDestFactors[16] = D3DBLEND_ONE }; -static const D3DCULL d3dCullModes[4] = +static const D3DCULL d3dCullModes[4] = { D3DCULL_NONE, D3DCULL_CCW, @@ -190,7 +190,7 @@ static const D3DCULL d3dCullModes[4] = D3DCULL_CCW }; -static const D3DCMPFUNC d3dCmpFuncs[8] = +static const D3DCMPFUNC d3dCmpFuncs[8] = { D3DCMP_NEVER, D3DCMP_LESS, @@ -202,7 +202,7 @@ static const D3DCMPFUNC d3dCmpFuncs[8] = D3DCMP_ALWAYS }; -static const D3DTEXTUREFILTERTYPE d3dMipFilters[4] = +static const D3DTEXTUREFILTERTYPE d3dMipFilters[4] = { D3DTEXF_NONE, D3DTEXF_POINT, @@ -231,7 +231,6 @@ void SetupDeviceObjects() // To avoid shader compilation stutters, read back all shaders from cache. VertexShaderCache::Init(); PixelShaderCache::Init(); - // Texture cache will recreate themselves over time. } @@ -272,7 +271,7 @@ bool Renderer::Init() if (fullScreenRes == D3D::GetAdapter(g_ActiveConfig.iAdapter).resolutions.size()) fullScreenRes = 0; - D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), + D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), fullScreenRes, backbuffer_ms_mode, false); IS_AMD = D3D::IsATIDevice(); @@ -297,14 +296,14 @@ bool Renderer::Init() s_LastAA = g_ActiveConfig.iMultisampleMode; s_LastEFBScale = g_ActiveConfig.iEFBScale; - float SupersampleCoeficient = s_LastAA + 1; + float SupersampleCoeficient = s_LastAA + 1; switch(s_LastEFBScale) { - case 0: + case 0: EFBxScale = xScale; EFByScale = yScale; break; - case 1: + case 1: EFBxScale = ceilf(xScale); EFByScale = ceilf(yScale); break; @@ -443,7 +442,7 @@ void Renderer::DrawDebugText() T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str())); T0.push_back(StringFromFormat("5: Copy EFB: %s\n", OSDM3.c_str())); T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled")); - T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled")); + T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled")); // The latest changed setting in yellow T1 += (OSDChoice == -1) ? T0.at(0) : "\n"; @@ -516,7 +515,7 @@ void CheckForResize() int width = rcParentWindow.right - rcParentWindow.left; int height = rcParentWindow.bottom - rcParentWindow.top; if (width != s_backbuffer_width || height != s_backbuffer_height) - ::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE); + MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE); } RECT rcWindow; GetClientRect(EmuWindow::GetWnd(), &rcWindow); @@ -529,7 +528,7 @@ void CheckForResize() { TeardownDeviceObjects(); - D3D::Reset(); + D3D::Reset(); s_backbuffer_width = D3D::GetBackBufferWidth(); s_backbuffer_height = D3D::GetBackBufferHeight(); WindowResized = true; @@ -540,7 +539,7 @@ void CheckForResize() void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc) { - if(!fbWidth || !fbHeight) + if (!fbWidth || !fbHeight) return; VideoFifo_CheckEFBAccess(); VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight); @@ -596,7 +595,7 @@ bool Renderer::SetScissorRect() rc.left = (int)(rc.left * EFBxScale) + Xstride; rc.top = (int)(rc.top * EFByScale) + Ystride; rc.right = (int)(rc.right * EFBxScale) + Xstride; - rc.bottom = (int)(rc.bottom * EFByScale) + Ystride; + rc.bottom = (int)(rc.bottom * EFByScale) + Ystride; if (rc.right != rc.left && rc.bottom != rc.top) { @@ -611,7 +610,6 @@ bool Renderer::SetScissorRect() rc.right = Xstride + s_target_width; rc.bottom = Ystride + s_target_height; D3D::dev->SetScissorRect(&rc); - return false; } return false; } @@ -619,9 +617,9 @@ bool Renderer::SetScissorRect() void Renderer::SetColorMask() { DWORD color_mask = 0; - if (bpmem.blendmode.alphaupdate) + if (bpmem.blendmode.alphaupdate) color_mask = D3DCOLORWRITEENABLE_ALPHA; - if (bpmem.blendmode.colorupdate) + if (bpmem.blendmode.colorupdate) color_mask |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE; D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask); } @@ -631,16 +629,16 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) if (!g_ActiveConfig.bEFBAccessEnable) return 0; - //Get the working buffer + // Get the working buffer LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ? FBManager.GetEFBDepthRTSurface() : FBManager.GetEFBColorRTSurface(); - //get the temporal buffer to move 1pixel data + // Get the temporal buffer to move 1pixel data LPDIRECT3DSURFACE9 RBuffer = (type == PEEK_Z || type == POKE_Z) ? FBManager.GetEFBDepthReadSurface() : FBManager.GetEFBColorReadSurface(); - //get the memory buffer that can be locked + // Get the memory buffer that can be locked LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ? FBManager.GetEFBDepthOffScreenRTSurface() : FBManager.GetEFBColorOffScreenRTSurface(); - //get the buffer format + // Get the buffer format D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ? FBManager.GetEFBDepthRTSurfaceFormat() : FBManager.GetEFBColorRTSurfaceFormat(); D3DFORMAT ReadBufferFormat = (type == PEEK_Z || type == POKE_Z) ? @@ -651,7 +649,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) D3DLOCKED_RECT drect; - //Buffer not found alert + // Buffer not found alert if (!pBuffer) { PanicAlert("No %s!", (type == PEEK_Z || type == POKE_Z) ? "Z-Buffer" : "Color EFB"); return 0; @@ -689,8 +687,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) RectToLock.bottom--; if ((RectToLock.right - RectToLock.left) > 4) RectToLock.left++; - ResetAPIState(); // reset any game specific settings - hr =D3D::dev->SetDepthStencilSurface(NULL); + ResetAPIState(); // Reset any game specific settings + hr = D3D::dev->SetDepthStencilSurface(NULL); hr = D3D::dev->SetRenderTarget(0, RBuffer); if (FAILED(hr)) { @@ -711,22 +709,22 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) PanicAlert("unable to set pixel viewport"); return 0; } - float colmat[16]= {0.0f}; + float colmat[16] = {0.0f}; float fConstAdd[4] = {0.0f}; colmat[0] = colmat[5] = colmat[10] = 1.0f; PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation EFBRectangle source_rect; LPDIRECT3DTEXTURE9 read_texture = FBManager.GetEFBDepthTexture(source_rect); - D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); + D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); D3D::drawShadedTexQuad( - read_texture, + read_texture, &RectToLock, - Renderer::GetFullTargetWidth() , - Renderer::GetFullTargetHeight(), - 4,4, - (BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram(0):PixelShaderCache::GetDepthMatrixProgram(0), + Renderer::GetFullTargetWidth(), + Renderer::GetFullTargetHeight(), + 4, 4, + (BufferFormat == FOURCC_RAWZ) ? PixelShaderCache::GetColorMatrixProgram(0) : PixelShaderCache::GetDepthMatrixProgram(0), VertexShaderCache::GetSimpleVertexShader(0)); D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); @@ -738,11 +736,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) RectToLock.left = 0; RectToLock.right = 4; RectToLock.top = 0; - } else { - hr = D3D::dev->StretchRect(pBuffer,&RectToLock,RBuffer,NULL, D3DTEXF_NONE); + hr = D3D::dev->StretchRect(pBuffer, &RectToLock, RBuffer, NULL, D3DTEXF_NONE); //change the rect to lock the entire one pixel buffer RectToLock.bottom = 1; RectToLock.left = 0; @@ -754,36 +751,34 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) PanicAlert("Unable to stretch data to buffer"); return 0; } - //retriebe the pixel data to the local memory buffer - D3D::dev->GetRenderTargetData(RBuffer,pOffScreenBuffer); + // Retrieve the pixel data to the local memory buffer + D3D::dev->GetRenderTargetData(RBuffer, pOffScreenBuffer); if (FAILED(hr)) { PanicAlert("Unable to copy data to mem buffer"); return 0; } - - - //the surface is good.. lock it + + // The surface is good.. lock it if ((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK) { - PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : - hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t"); + PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t"); return 0; } - switch(type) { + switch (type) { case PEEK_Z: { switch (ReadBufferFormat) { case D3DFMT_R32F: - val = ((float *)drect.pBits)[6]; + val = ((float*)drect.pBits)[6]; break; default: float ffrac = 1.0f/255.0f; - z = ((u32 *)drect.pBits)[6]; + z = ((u32*)drect.pBits)[6]; val = ((float)((z>>16) & 0xFF)) * ffrac; ffrac*= 1 / 255.0f; val += ((float)((z>>8) & 0xFF)) * ffrac; @@ -805,16 +800,14 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y) break; case POKE_COLOR: // TODO: Get that ARGB value to poke from somewhere - //((float *)drect.pBits)[0] = val; + //((float*)drect.pBits)[0] = val; PanicAlert("Poke color EFB not implemented"); break; } - - pOffScreenBuffer->UnlockRect(); + pOffScreenBuffer->UnlockRect(); // TODO: in RE0 this value is often off by one, which causes lighting to disappear return z; - } // Called from VertexShaderManager @@ -854,32 +847,32 @@ void UpdateViewport() Height *= -1; } bool sizeChanged = false; - if(X < 0) + if (X < 0) { s_Fulltarget_width -= 2 * X; X = 0; sizeChanged=true; } - if(Y < 0) + if (Y < 0) { s_Fulltarget_height -= 2 * Y; Y = 0; - sizeChanged=true; + sizeChanged = true; } - if(!IS_AMD) + if (!IS_AMD) { if(X + Width > s_Fulltarget_width) { s_Fulltarget_width += (X + Width - s_Fulltarget_width) * 2; - sizeChanged=true; + sizeChanged = true; } if(Y + Height > s_Fulltarget_height) { s_Fulltarget_height += (Y + Height - s_Fulltarget_height) * 2; - sizeChanged=true; + sizeChanged = true; } } - if(sizeChanged) + if (sizeChanged) { D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface()); @@ -887,42 +880,42 @@ void UpdateViewport() FBManager.Create(); D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface()); D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface()); - } + } vp.X = X; vp.Y = Y; vp.Width = Width; vp.Height = Height; - //some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work - vp.MinZ = 0.0f;//(xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; - vp.MaxZ =1.0f;// xfregs.rawViewport[5] / 16777216.0f; + // Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work + vp.MinZ = 0.0f; // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; + vp.MaxZ =1.0f; // xfregs.rawViewport[5] / 16777216.0f; D3D::dev->SetViewport(&vp); } void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) -{ +{ // Update the view port for clearing the picture TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc); D3DVIEWPORT9 vp; vp.X = targetRc.left; - vp.Y = targetRc.top; + vp.Y = targetRc.top; vp.Width = targetRc.GetWidth(); vp.Height = targetRc.GetHeight(); vp.MinZ = 0.0; vp.MaxZ = 1.0; - D3D::dev->SetViewport(&vp); + D3D::dev->SetViewport(&vp); // Always set the scissor in case it was set by the game and has not been reset - RECT sirc; - sirc.left = targetRc.left; - sirc.top = targetRc.top; - sirc.right = targetRc.right; - sirc.bottom = targetRc.bottom; - D3D::dev->SetScissorRect(&sirc); + RECT sicr; + sicr.left = targetRc.left; + sicr.top = targetRc.top; + sicr.right = targetRc.right; + sicr.bottom = targetRc.bottom; + D3D::dev->SetScissorRect(&sicr); D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false); if (zEnable) D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); - D3D::drawClearQuad(color ,(z & 0xFFFFFF) / float(0xFFFFFF),PixelShaderCache::GetClearProgram(),VertexShaderCache::GetClearVertexShader()); + D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader()); if (zEnable) D3D::RefreshRenderState(D3DRS_ZFUNC); D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE); @@ -931,27 +924,27 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE } void Renderer::SetBlendMode(bool forceUpdate) -{ +{ if (bpmem.blendmode.logicopenable) return; - if (bpmem.blendmode.subtract && bpmem.blendmode.blendenable) + if (bpmem.blendmode.subtract && bpmem.blendmode.blendenable) { D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true); D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT); D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[1]); D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[1]); - } - else + } + else { D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0))); - if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0))) + if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0))) { D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[bpmem.blendmode.srcfactor]); D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[bpmem.blendmode.dstfactor]); - } - } + } + } } @@ -972,9 +965,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons const XFBSource** xfbSourceList = FBManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) { - g_VideoInitialize.pCopiedToXFB(false); + g_VideoInitialize.pCopiedToXFB(false); return; - } + } Renderer::ResetAPIState(); // Set the backbuffer as the rendering target @@ -991,7 +984,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons vp.MinZ = 0.0f; vp.MaxZ = 1.0f; D3D::dev->SetViewport(&vp); - D3D::dev->Clear(0,NULL, D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0); + D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); int X = dst_rect.left; int Y = dst_rect.top; @@ -1078,7 +1071,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons D3D::drawShadedTexQuad(read_texture,targetRc.AsRECT(),Renderer::GetFullTargetWidth(),Renderer::GetFullTargetHeight(),Width,Height,PixelShaderCache::GetColorCopyProgram(g_Config.iMultisampleMode),VertexShaderCache::GetSimpleVertexShader(g_Config.iMultisampleMode)); } D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); - D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER); + D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER); vp.X = 0; vp.Y = 0; vp.Width = s_backbuffer_width; @@ -1104,68 +1097,67 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons s_bScreenshot = false; s_criticalScreenshot.Leave(); } - if (g_ActiveConfig.bDumpFrames) + if (g_ActiveConfig.bDumpFrames) { - D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface); - if (!s_LastFrameDumped) + D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(), ScreenShootMEMSurface); + if (!s_LastFrameDumped) { s_recordWidth = s_backbuffer_width; s_recordHeight = s_backbuffer_height; s_AVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight); - if (!s_AVIDumping) + if (!s_AVIDumping) { PanicAlert("Error dumping frames to AVI."); - } - else + } + else { char msg [255]; sprintf_s(msg,255, "Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", File::GetUserPath(D_DUMPFRAMES_IDX), s_recordWidth, s_recordHeight); OSD::AddMessage(msg, 2000); } } - if (s_AVIDumping) + if (s_AVIDumping) { D3DLOCKED_RECT rect; - if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY))) + if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY))) { - char *data = (char *)malloc(3 * s_recordWidth * s_recordHeight); - formatBufferDump((const char *)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch); + char* data = (char*)malloc(3 * s_recordWidth * s_recordHeight); + formatBufferDump((const char*)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch); AVIDump::AddFrame(data); free(data); ScreenShootMEMSurface->UnlockRect(); } } s_LastFrameDumped = true; - } - else + } + else { - if (s_LastFrameDumped && s_AVIDumping) + if (s_LastFrameDumped && s_AVIDumping) { AVIDump::Stop(); s_AVIDumping = false; } s_LastFrameDumped = false; } - // Finish up the current frame, print some stats if (g_ActiveConfig.bShowFPS) { char fps[20]; StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps); - D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,fps,false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, fps, false); } Renderer::DrawDebugText(); if (g_ActiveConfig.bOverlayStats) { Statistics::ToString(st); - D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false); } else if (g_ActiveConfig.bOverlayProjStats) { Statistics::ToStringProj(st); - D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); + D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false); } @@ -1177,28 +1169,27 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons TextureCache::Cleanup(); // Make any new configuration settings active. - UpdateActiveConfig(); + UpdateActiveConfig(); WindowResized = false; CheckForResize(); bool xfbchanged = false; - if(s_XFB_width != fbWidth || s_XFB_height != fbHeight) + if (s_XFB_width != fbWidth || s_XFB_height != fbHeight) { xfbchanged = true; s_XFB_width = fbWidth; s_XFB_height = fbHeight; - if(s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH; - if(s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH; - if(s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT; - if(s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT; - + if (s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH; + if (s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH; + if (s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT; + if (s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT; } u32 newAA = g_ActiveConfig.iMultisampleMode; u32 newEFBScale = g_ActiveConfig.iEFBScale; - if(newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized) - { + if (newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized) + { s_LastAA = newAA; s_LastEFBScale = newEFBScale; @@ -1217,11 +1208,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons float SupersampleCoeficient = s_LastAA + 1; switch(s_LastEFBScale) { - case 0: + case 0: EFBxScale = xScale; EFByScale = yScale; break; - case 1: + case 1: EFBxScale = ceilf(xScale); EFByScale = ceilf(yScale); break; @@ -1237,7 +1228,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons s_target_height = EFB_HEIGHT * EFByScale; D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface()); - if(WindowResized) + if (WindowResized) { SetupDeviceObjects(); } @@ -1248,7 +1239,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons } D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface()); D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface()); - } // --------------------------------------------------------------------- @@ -1256,9 +1246,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons // ------------- static int fpscount = 1; static unsigned long lasttime; - if(XFBWrited) + if (XFBWrited) ++fpscount; - if (Common::Timer::GetTimeMs() - lasttime > 1000) + if (Common::Timer::GetTimeMs() - lasttime > 1000) { lasttime = Common::Timer::GetTimeMs(); s_fps = fpscount - 1; @@ -1288,7 +1278,7 @@ void Renderer::ResetAPIState() D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); D3D::SetRenderState(D3DRS_ZENABLE, FALSE); D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE); - DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE; + DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE; D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask); } @@ -1298,8 +1288,10 @@ void Renderer::RestoreAPIState() D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); UpdateViewport(); SetScissorRect(); - if (bpmem.zmode.testenable) D3D::SetRenderState(D3DRS_ZENABLE, TRUE); - if (bpmem.zmode.updateenable) D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE); + if (bpmem.zmode.testenable) + D3D::SetRenderState(D3DRS_ZENABLE, TRUE); + if (bpmem.zmode.updateenable) + D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE); SetColorMask(); SetLogicOpMode(); } @@ -1326,7 +1318,7 @@ void Renderer::SetDepthMode() void Renderer::SetLogicOpMode() { - if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3) + if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3) { D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true); D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]); @@ -1341,7 +1333,7 @@ void Renderer::SetLogicOpMode() void Renderer::SetDitherMode() { - D3D::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither); + D3D::SetRenderState(D3DRS_DITHERENABLE, bpmem.blendmode.dither); } void Renderer::SetLineWidth() @@ -1354,7 +1346,7 @@ void Renderer::SetLineWidth() void Renderer::SetSamplerState(int stage, int texindex) { - const FourTexUnits &tex = bpmem.tex[texindex]; + const FourTexUnits &tex = bpmem.tex[texindex]; const TexMode0 &tm0 = tex.texMode0[stage]; const TexMode1 &tm1 = tex.texMode1[stage]; @@ -1367,14 +1359,14 @@ void Renderer::SetSamplerState(int stage, int texindex) { min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT; mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT; - mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3]; - if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE; + mip = (tm0.min_filter == 8) ? D3DTEXF_NONE : d3dMipFilters[tm0.min_filter & 3]; + if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) + mip = D3DTEXF_NONE; } if (texindex) - stage += 4; + stage += 4; - if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR && - g_ActiveConfig.iMaxAnisotropy > 1) + if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR && g_ActiveConfig.iMaxAnisotropy > 1) { min = D3DTEXF_ANISOTROPIC; } @@ -1386,8 +1378,8 @@ void Renderer::SetSamplerState(int stage, int texindex) D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]); //float SuperSampleCoeficient = (s_LastAA < 3)? s_LastAA + 1 : s_LastAA - 1;// uncoment this changes to conserve detail when incresing ssaa level float lodbias = (tm0.lod_bias / 32.0f);// + (s_LastAA)?(log(SuperSampleCoeficient) / log(2.0f)):0; - D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias); - D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>4); + D3D::SetSamplerState(stage, D3DSAMP_MIPMAPLODBIAS, *(DWORD*)&lodbias); + D3D::SetSamplerState(stage, D3DSAMP_MAXMIPLEVEL, tm1.min_lod >> 4); } void Renderer::SetInterlacingMode() @@ -1399,7 +1391,7 @@ void Renderer::SetInterlacingMode() void Renderer::SetScreenshot(const char *filename) { s_criticalScreenshot.Enter(); - strcpy_s(s_sScreenshotName,filename); + strcpy_s(s_sScreenshotName, filename); s_bScreenshot = true; s_criticalScreenshot.Leave(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h index b7a0f8ea79..638554c113 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.h @@ -53,9 +53,9 @@ public: private: DECLARE_EVENT_TABLE(); - wxPanel *m_MainPanel; + wxPanel* m_MainPanel; - wxCheckBox *m_Check[6]; + wxCheckBox* m_Check[6]; // WARNING: Make sure these are not also elsewhere enum @@ -70,7 +70,7 @@ private: NUM_OPTIONS }; - void OnClose(wxCloseEvent& event); + void OnClose(wxCloseEvent& event); void CreateGUIControls(); void GeneralSettings(wxCommandEvent& event); diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp index e47af54e69..c44b5bc20a 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.cpp @@ -1,29 +1,29 @@ -#include "UDPNunchuk.h" -#include "UDPWrapper.h" -#include "UDPWiimote.h" - +#include "UDPNunchuk.h" +#include "UDPWrapper.h" +#include "UDPWiimote.h" + #define NUNCHUK_C 0x02 -#define NUNCHUK_Z 0x01 - +#define NUNCHUK_Z 0x01 + namespace WiimoteEmu -{ - -void UDPNunchuk::GetState( u8* const data, const bool focus ) -{ - Nunchuk::GetState(data,focus); - if (!(wrp->inst)) return; - - wm_extension* const ncdata = (wm_extension*)data; - u8 mask; - float x,y; - wrp->inst->getNunchuck(x,y,mask); - if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C; - if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z; - if ((ncdata->jx==0x80)&&(ncdata->jy==0x80)) - { - ncdata->jx=u8(0x80+x*127); - ncdata->jy=u8(0x80+y*127); - } -} - +{ + +void UDPNunchuk::GetState( u8* const data, const bool focus ) +{ + Nunchuk::GetState(data, focus); + if (!(wrp->inst)) return; + + wm_extension* const ncdata = (wm_extension*)data; + u8 mask; + float x, y; + wrp->inst->getNunchuck(x, y, mask); + if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C; + if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z; + if ((ncdata->jx==0x80)&&(ncdata->jy==0x80)) + { + ncdata->jx=u8(0x80+x*127); + ncdata->jy=u8(0x80+y*127); + } +} + } \ No newline at end of file diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h index e3b951cea5..f230cce409 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/UDPNunchuk.h @@ -1,7 +1,7 @@ -#ifndef UDPNUNCHUCK_H -#define UDPNUNCHUCK_H - -#include "Nunchuk.h" +#ifndef UDPNUNCHUCK_H +#define UDPNUNCHUCK_H + +#include "Nunchuk.h" class UDPWrapper; @@ -11,11 +11,11 @@ namespace WiimoteEmu class UDPNunchuk : public Nunchuk { public: - UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp ) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p - virtual void GetState( u8* const data, const bool focus ); -private: - UDPWrapper * wrp; -}; - -} -#endif \ No newline at end of file + UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p + virtual void GetState( u8* const data, const bool focus ); +private: + UDPWrapper * wrp; +}; + +} +#endif diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h index 7754240a95..f4c79a6d28 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h @@ -1,53 +1,53 @@ -//UDP Wiimote Translation Layer - -#ifndef UDPTLAYER_H -#define UDPTLAYER_H - -#include "UDPWiimote.h" - -namespace UDPTLayer -{ - void GetButtons(UDPWrapper * m , wm_core * butt) - { - if (!(m->inst)) return; - if (!(m->updButt)) return; - u32 mask=m->inst->getButtons(); - *butt|=(mask&UDPWM_BA)?WIIMOTE_A:0; - *butt|=(mask&UDPWM_BB)?WIIMOTE_B:0; - *butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0; - *butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0; - *butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0; - *butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0; - *butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0; - *butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0; - *butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0; - *butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0; - *butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0; - } - - void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib) - { - if (!(m->inst)) return; - if (!(m->updAccel)) return; - float x,y,z; - m->inst->getAccel(x,y,z); - data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x); - data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y); - data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z); - } - - void GetIR( UDPWrapper * m, float * x, float * y, float * z) - { - if (!(m->inst)) return; - if (!(m->updIR)) return; - if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen - float _x,_y; - m->inst->getIR(_x,_y); - *x=_x*2-1; - *y=-(_y*2-1); - *z=0; - } - -} - -#endif \ No newline at end of file +//UDP Wiimote Translation Layer + +#ifndef UDPTLAYER_H +#define UDPTLAYER_H + +#include "UDPWiimote.h" + +namespace UDPTLayer +{ + void GetButtons(UDPWrapper * m , wm_core * butt) + { + if (!(m->inst)) return; + if (!(m->updButt)) return; + u32 mask=m->inst->getButtons(); + *butt|=(mask&UDPWM_BA)?WIIMOTE_A:0; + *butt|=(mask&UDPWM_BB)?WIIMOTE_B:0; + *butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0; + *butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0; + *butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0; + *butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0; + *butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0; + *butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0; + *butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0; + *butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0; + *butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0; + } + + void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib) + { + if (!(m->inst)) return; + if (!(m->updAccel)) return; + float x,y,z; + m->inst->getAccel(x,y,z); + data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x); + data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y); + data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z); + } + + void GetIR( UDPWrapper * m, float * x, float * y, float * z) + { + if (!(m->inst)) return; + if (!(m->updIR)) return; + if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen + float _x,_y; + m->inst->getIR(_x,_y); + *x=_x*2-1; + *y=-(_y*2-1); + *z=0; + } + +} + +#endif