diff --git a/Source/Core/Core/Src/Boot/Boot.cpp b/Source/Core/Core/Src/Boot/Boot.cpp index 01c773d74b..b11b237285 100644 --- a/Source/Core/Core/Src/Boot/Boot.cpp +++ b/Source/Core/Core/Src/Boot/Boot.cpp @@ -60,7 +60,6 @@ bool CBoot::Boot_BIN(const std::string& _rFilename) } delete pFile; - return true; } diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 428b50d8e1..7772f83ac9 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -186,9 +186,9 @@ void Stop() // - Hammertime! #endif delete g_pThread; //Wait for emuthread to close + g_pThread = 0; Core::StopTrace(); LogManager::Shutdown(); - g_pThread = 0; Host_SetWaitCursor(false); } @@ -360,6 +360,7 @@ THREAD_RETURN EmuThread(void *pArg) if( g_pUpdateFPSDisplay != NULL ) g_pUpdateFPSDisplay("Stopping..."); delete cpuThread; + cpuThread = NULL; // Returns after game exited g_bHwInit = false; diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index 41403a7db9..6a39363236 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -106,6 +106,7 @@ CEXIMemoryCard::~CEXIMemoryCard() { Flush(true); delete [] memory_card_content; + memory_card_content = NULL; } bool CEXIMemoryCard::IsPresent() diff --git a/Source/Core/DebuggerWX/src/CodeView.cpp b/Source/Core/DebuggerWX/src/CodeView.cpp index 81e20ab704..aabe51378d 100644 --- a/Source/Core/DebuggerWX/src/CodeView.cpp +++ b/Source/Core/DebuggerWX/src/CodeView.cpp @@ -354,7 +354,7 @@ void CCodeView::OnPaint(wxPaintEvent& event) wxBrush rowBrush(wxColor(col >> 16, col >> 8, col)); dc.SetBrush(nullBrush); dc.SetPen(nullPen); - dc.DrawRectangle(0, rowY1, 16, rowY2); + dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2); if (selecting && (address == selection)) { @@ -374,7 +374,7 @@ void CCodeView::OnPaint(wxPaintEvent& event) dc.SetBrush(rowBrush); } - dc.DrawRectangle(16, rowY1, width, rowY2 - 1); + dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1); dc.SetBrush(currentBrush); dc.SetTextForeground(_T("#600000")); dc.DrawText(temp, 17, rowY1); diff --git a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp index 0ca1e93389..5b540b729d 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderGC.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderGC.cpp @@ -55,7 +55,8 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem) CBannerLoaderGC::~CBannerLoaderGC() { - delete[] m_pBannerFile; + delete [] m_pBannerFile; + m_pBannerFile = NULL; } diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index 357c53639f..4744223d9a 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -70,7 +70,8 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem) CBannerLoaderWii::~CBannerLoaderWii() { - delete m_pBuffer; + delete [] m_pBuffer; + m_pBuffer = NULL; } diff --git a/Source/Core/DiscIO/Src/FileHandlerARC.cpp b/Source/Core/DiscIO/Src/FileHandlerARC.cpp index 4319cc001a..8d40df18ec 100644 --- a/Source/Core/DiscIO/Src/FileHandlerARC.cpp +++ b/Source/Core/DiscIO/Src/FileHandlerARC.cpp @@ -42,7 +42,7 @@ CARCFile::CARCFile(const u8* _pBuffer, size_t _BufferSize) CARCFile::~CARCFile() { - delete m_pBuffer; + delete [] m_pBuffer; } diff --git a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp index 51f0f862cb..bbab62c531 100644 --- a/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/Src/VolumeWiiCrypted.cpp @@ -36,7 +36,9 @@ CVolumeWiiCrypted::CVolumeWiiCrypted(IBlobReader* _pReader, u64 _VolumeOffset, c CVolumeWiiCrypted::~CVolumeWiiCrypted() { delete m_pReader; // is this really our responsibility? + m_pReader = NULL; delete[] m_pBuffer; + m_pBuffer = NULL; } diff --git a/Source/Core/DolphinWX/src/MemcardManager.cpp b/Source/Core/DolphinWX/src/MemcardManager.cpp index 94712114b9..b024268c34 100644 --- a/Source/Core/DolphinWX/src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/src/MemcardManager.cpp @@ -39,8 +39,14 @@ CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString CMemcardManager::~CMemcardManager() { - if(memoryCard[0]) delete memoryCard[0]; - if(memoryCard[1]) delete memoryCard[1]; + if (memoryCard[0]) { + delete memoryCard[0]; + memoryCard[0] = NULL; + } + if (memoryCard[1]) { + delete memoryCard[1]; + memoryCard[1] = NULL; + } } void CMemcardManager::CreateGUIControls() diff --git a/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.cpp b/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.cpp index 2baac40844..a0605282c8 100644 --- a/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.cpp +++ b/Source/Core/DolphinWX/src/MemoryCards/GCMemcard.cpp @@ -117,8 +117,8 @@ bool GCMemcard::RemoveFile(u32 index) //index in the directory array bat.LastAllocated[0] = u8(firstFree>>8); bat.LastAllocated[1] = u8(firstFree); - delete mc_data; - mc_data=mc_data2; + delete [] mc_data; + mc_data = mc_data2; //-- //update freespace counter @@ -366,7 +366,7 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index) if(!source.GetFileData(index,t)) return 0; u32 ret = ImportFile(d,t); - delete t; + delete[] t; return ret; } diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index a9ddd16c08..bcb87aed4d 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -78,6 +78,11 @@ u8 FAKE_ReadFifo8() return videoBuffer[readptr++]; } +int FAKE_GetPosition() +{ + return readptr; +} + u16 FAKE_ReadFifo16() { u16 val = Common::swap16(*(u16*)(videoBuffer+readptr)); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp index 9ecc07fba8..aabeedbaf1 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/PCHW/Mixer.cpp @@ -43,7 +43,7 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels) // silence memset(buffer, 0, numSamples * 2 * sizeof(short)); - // first get th DTK Music + // first get the DTK Music if (g_Config.m_EnableDTKMusic) { g_dspInitialize.pGetAudioStreaming(buffer, numSamples); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/RegSettings.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/RegSettings.cpp index eababe60a1..0bb29c1389 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/RegSettings.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/RegSettings.cpp @@ -111,6 +111,7 @@ CReBarSettings::~CReBarSettings() if (m_pBands != NULL) { delete[] m_pBands; + m_pBands = NULL; } } @@ -120,6 +121,7 @@ bool CReBarSettings::Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /* if (m_pBands != NULL) { delete[] m_pBands; + m_pBands = NULL; } m_pBands = NULL; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DecodedVArray.cpp b/Source/Plugins/Plugin_VideoDX9/Src/DecodedVArray.cpp index 7ee5d16634..4914d341bb 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DecodedVArray.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/DecodedVArray.cpp @@ -22,13 +22,13 @@ void DecodedVArray::Zero() posMtxInds = 0; for (int i=0; i<3; i++) normals[i] = 0; + for (int i=0; i<2; i++) + colors[i] = 0; for (int i=0; i<8; i++) { texMtxInds[i] = 0; uvs[i] = 0; } - for (int i=0; i<2; i++) - colors[i] = 0; } void DecodedVArray::Destroy() diff --git a/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp b/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp index e078a7b453..3565f80ca2 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/OpcodeDecoding.cpp @@ -97,9 +97,9 @@ bool FifoCommandRunnable(void) { u32 iBufferSize = FAKE_GetFifoSize(); if (iBufferSize == 0) - return false; + return false; // can't peek - u8 Cmd = PeekFifo8(0); + u8 Cmd = PeekFifo8(0); u32 iCommandSize = 0; switch(Cmd) @@ -362,12 +362,6 @@ void OpcodeDecoder_Shutdown() void OpcodeDecoder_Run() { - // just a small check - if (g_pDataReader != &g_fifoReader) - { - MessageBox(NULL, "very strange", "video-plugin", MB_OK); - } - DVSTARTPROFILE(); while (FifoCommandRunnable()) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.cpp index cfb1ca9f2a..674da64d73 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.cpp @@ -51,12 +51,7 @@ void VertexLoader::SetVArray(DecodedVArray *_varray) { varray = _varray; } -/* -inline u8 ReadBuffer8() { return fifo.Read8(); } -inline u16 ReadBuffer16() { return fifo.Read16(); } -inline u32 ReadBuffer32() { return fifo.Read32(); } -inline float ReadBuffer32F() { return fifo.Read32F(); } -*/ + inline u8 ReadBuffer8() { return g_pDataReader->Read8(); @@ -120,7 +115,7 @@ void VertexLoader::Setup() { m_PipelineStates[m_numPipelineStates++] = PosMtx_ReadDirect_UByte; m_VertexSize += 1; - m_components |= VB_HAS_POSMTXIDX; + m_components |= VB_HAS_POSMTXIDX; } // Texture matrix indices @@ -195,7 +190,7 @@ void VertexLoader::Setup() } WriteCall(pFunc); m_VertexSize += uSize; - int m_numNormals = (m_VtxAttr.NormalElements==1) ? NRM_THREE : NRM_ONE; + int m_numNormals = (m_VtxAttr.NormalElements == 1) ? NRM_THREE : NRM_ONE; m_components |= VB_HAS_NRM0; if (m_numNormals == NRM_THREE) m_components |= VB_HAS_NRM1 | VB_HAS_NRM2; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.h b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.h index cf8f6dbd59..63b844c2d6 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader.h @@ -135,7 +135,7 @@ public: void SetVAT_group0(u32 _group0) { - if (!m_AttrDirty && m_group0.Hex == _group0) + if (m_group0.Hex == _group0) return; m_AttrDirty = true; m_group0.Hex = _group0; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader_Color.h b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader_Color.h index 2a4b53f997..76cee866b9 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader_Color.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader_Color.h @@ -59,6 +59,7 @@ void _SetCol565(u16 val) col |= lut5to8[(val )&0x1f] << BSHIFT; _SetCol(col | (0xFF<Read16(); if (numVertices > 0) { g_VertexLoaders[Cmd & GX_VAT_MASK].RunVertices((Cmd & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, numVertices); @@ -301,11 +301,6 @@ void OpcodeDecoder_Shutdown() void OpcodeDecoder_Run() { - // just a small check - if (g_pDataReader != &g_fifoReader) { - SysMessage("very strange"); - } - DVSTARTPROFILE(); while (FifoCommandRunnable()) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h index 7a75b28c41..67c2082cff 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h @@ -43,7 +43,7 @@ class PixelShaderMngr memset(values, 0, (4+32+6+11) * 4); tevstages = indstages = 0; } - ~PIXELSHADERUID() { delete[] values; } + ~PIXELSHADERUID() { delete[] values; values = NULL;} PIXELSHADERUID(const PIXELSHADERUID& r) { values = new u32[4+32+6+11]; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index d1324df9d3..73fe9e9750 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -19,8 +19,10 @@ #include #include +#include "Common.h" #include "x64Emitter.h" #include "Profiler.h" +#include "StringUtil.h" #include "Render.h" #include "VertexLoader.h" @@ -82,6 +84,12 @@ inline float ReadBuffer32F() return *(float*)(&temp); } + +inline int GetBufferPosition() +{ + return g_pDataReader->GetPosition(); +} + // ============================================================================== // Direct // ============================================================================== @@ -143,7 +151,7 @@ VertexLoader::VertexLoader() { m_numPipelineStates = 0; m_VertexSize = 0; - m_AttrDirty = 2; + m_AttrDirty = 1; VertexLoader_Normal::Init(); m_compiledCode = (u8 *)AllocateExecutableMemory(COMPILED_CODE_SIZE, false); @@ -159,8 +167,7 @@ VertexLoader::~VertexLoader() int VertexLoader::ComputeVertexSize() { - if (m_AttrDirty < 2) { - + if (!m_AttrDirty) { if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 && (m_VtxDesc.Hex1&1)==(VertexManager::GetVtxDesc().Hex1&1)) return m_VertexSize; @@ -212,6 +219,7 @@ int VertexLoader::ComputeVertexSize() break; } + VertexLoader_Normal::index3 = m_VtxAttr.NormalIndex3; if (m_VtxDesc.Normal != NOT_PRESENT) m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements); @@ -297,7 +305,7 @@ void VertexLoader::ProcessFormat() //_assert_( VertexManager::s_pCurBufferPointer == s_pBaseBufferPointer ); - if (!m_AttrDirty ) { + if (!m_AttrDirty) { if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 && (m_VtxDesc.Hex1&1)==(VertexManager::GetVtxDesc().Hex1&1)) // same @@ -410,7 +418,7 @@ void VertexLoader::ProcessFormat() // Colors int col[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1}; for (int i = 0; i < 2; i++) { - SetupColor(i,col[i], m_VtxAttr.color[i].Comp, m_VtxAttr.color[i].Elements); + SetupColor(i, col[i], m_VtxAttr.color[i].Comp, m_VtxAttr.color[i].Elements); if (col[i] != NOT_PRESENT ) m_VBVertexStride+=4; @@ -504,8 +512,8 @@ void VertexLoader::ProcessFormat() case FORMAT_FLOAT: CallCdeclFunction3_I(glNormalPointer, GL_FLOAT, m_VBVertexStride, offset); offset += 12; if (m_VtxAttr.NormalElements) { - CallCdeclFunction6((void *)glVertexAttribPointer, SHADER_NORM1_ATTRIB,3,GL_FLOAT, GL_TRUE, m_VBVertexStride, offset); offset += 12; - CallCdeclFunction6((void *)glVertexAttribPointer, SHADER_NORM2_ATTRIB,3,GL_FLOAT, GL_TRUE, m_VBVertexStride, offset); offset += 12; + CallCdeclFunction6((void *)glVertexAttribPointer, SHADER_NORM1_ATTRIB, 3, GL_FLOAT, GL_TRUE, m_VBVertexStride, offset); offset += 12; + CallCdeclFunction6((void *)glVertexAttribPointer, SHADER_NORM2_ATTRIB, 3, GL_FLOAT, GL_TRUE, m_VBVertexStride, offset); offset += 12; } break; default: _assert_(0); break; @@ -513,7 +521,7 @@ void VertexLoader::ProcessFormat() } for (int i = 0; i < 2; i++) { - if (col[i] != NOT_PRESENT ) { + if (col[i] != NOT_PRESENT) { if (i) CallCdeclFunction4((void *)glSecondaryColorPointer, 4, GL_UNSIGNED_BYTE, m_VBVertexStride, offset); else @@ -570,7 +578,7 @@ void VertexLoader::ProcessFormat() _assert_(offset+m_VBStridePad == m_VBVertexStride); Util::EmitEpilogue(6); - if (Gen::GetCodePtr()-(u8*)m_compiledCode > COMPILED_CODE_SIZE) + if (Gen::GetCodePtr() - (u8*)m_compiledCode > COMPILED_CODE_SIZE) { assert(0); Crash(); @@ -689,12 +697,14 @@ void VertexLoader::SetupTexCoord(int num, int mode, int format, int elements, in void VertexLoader::WriteCall(void (LOADERDECL *func)(void *)) { - m_PipelineStates[m_numPipelineStates++] = func;; + m_PipelineStates[m_numPipelineStates++] = func; } void VertexLoader::RunVertices(int primitive, int count) { - if( count <= 0 ) + ComputeVertexSize(); + + if( count <= 0 ) return; if( fnSetupVertexPointers != NULL && fnSetupVertexPointers != (void (*)())(void*)m_compiledCode ) @@ -833,6 +843,7 @@ void VertexLoader::RunVertices(int primitive, int count) break; default: extraverts = 0; + break; } startv = v; @@ -842,8 +853,22 @@ void VertexLoader::RunVertices(int primitive, int count) tcIndex = 0; colIndex = 0; s_texmtxwrite = s_texmtxread = 0; + + int pred_size = m_VertexSize; + + //int start = GetBufferPosition(); + //if (!m_numPipelineStates) + // PanicAlert("trying to draw with no pipeline"); for (int i = 0; i < m_numPipelineStates; i++) m_PipelineStates[i](&m_VtxAttr); + //int end = GetBufferPosition(); + + //if (end - start != pred_size) { + // std::string vtx_summary; + // vtx_summary += StringFromFormat("Nrm d:%i f:%i e:%i 3:%i", m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); + // PanicAlert((vtx_summary + "\nWTF %i %i").c_str(), end - start, pred_size); + //} + VertexManager::s_pCurBufferPointer += m_VBStridePad; PRIM_LOG("\n"); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h index 85f7eba4f0..c43af7abe2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h @@ -224,5 +224,6 @@ u8 ReadBuffer8(); u16 ReadBuffer16(); u32 ReadBuffer32(); float ReadBuffer32F(); +int GetBufferPosition(); #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Normal.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Normal.cpp index f3484aba0d..350758f874 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Normal.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Normal.cpp @@ -106,7 +106,10 @@ void VertexLoader_Normal::Init(void) unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _format, unsigned int _elements) { - return m_sizeTable[_type][_format][_elements]; + if (!index3 && _elements == NRM_NBT3) + return m_sizeTable[_type][_format][_elements] / 3; + else + return m_sizeTable[_type][_format][_elements]; } TPipelineFunction VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements)