diff --git a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp index 739b070c35..f424efaa4b 100644 --- a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp +++ b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp @@ -154,7 +154,6 @@ void CBoot::EmulatedBIOS(bool _bDebug) } - bool CBoot::SetupWiiMemory(unsigned int _CountryCode) { INFO_LOG(BOOT, "Setup Wii Memory..."); diff --git a/Source/Core/Core/Src/HW/PixelEngine.cpp b/Source/Core/Core/Src/HW/PixelEngine.cpp index 6c2a49ca00..8aab4cd5f8 100644 --- a/Source/Core/Core/Src/HW/PixelEngine.cpp +++ b/Source/Core/Core/Src/HW/PixelEngine.cpp @@ -57,11 +57,11 @@ union UPECtrlReg // STATE_TO_SAVE static UPECtrlReg g_ctrlReg; -static bool g_bSignalTokenInterrupt; -static bool g_bSignalFinishInterrupt; +static bool g_bSignalTokenInterrupt; +static bool g_bSignalFinishInterrupt; -int et_SetTokenOnMainThread; -int et_SetFinishOnMainThread; +static int et_SetTokenOnMainThread; +static int et_SetFinishOnMainThread; void DoState(PointerWrap &p) { @@ -86,7 +86,7 @@ void Init() void Read16(u16& _uReturnValue, const u32 _iAddress) { - DEBUG_LOG(PIXELENGINE, "(r16): 0x%08x", _iAddress); + DEBUG_LOG(PIXELENGINE, "(r16): 0x%08x", _iAddress); switch (_iAddress & 0xFFF) { @@ -101,7 +101,7 @@ void Read16(u16& _uReturnValue, const u32 _iAddress) return; default: - WARN_LOG(PIXELENGINE,"(unknown)"); + WARN_LOG(PIXELENGINE, "(r16): unknown @ %08x", _iAddress); break; } @@ -110,14 +110,14 @@ void Read16(u16& _uReturnValue, const u32 _iAddress) void Write32(const u32 _iValue, const u32 _iAddress) { - INFO_LOG(PIXELENGINE, "(w32): 0x%08x @ 0x%08x",_iValue,_iAddress); + WARN_LOG(PIXELENGINE, "(w32): 0x%08x @ 0x%08x",_iValue,_iAddress); } void Write16(const u16 _iValue, const u32 _iAddress) { DEBUG_LOG(PIXELENGINE, "(w16): 0x%04x @ 0x%08x",_iValue,_iAddress); - switch(_iAddress & 0xFFF) + switch (_iAddress & 0xFFF) { case CTRL_REGISTER: { @@ -126,8 +126,8 @@ void Write16(const u16 _iValue, const u32 _iAddress) if (tmpCtrl.PEToken) g_bSignalTokenInterrupt = false; if (tmpCtrl.PEFinish) g_bSignalFinishInterrupt = false; - g_ctrlReg.PETokenEnable = tmpCtrl.PETokenEnable; - g_ctrlReg.PEFinishEnable = tmpCtrl.PEFinishEnable; + g_ctrlReg.PETokenEnable = tmpCtrl.PETokenEnable; + g_ctrlReg.PEFinishEnable = tmpCtrl.PEFinishEnable; g_ctrlReg.PEToken = 0; // this flag is write only g_ctrlReg.PEFinish = 0; // this flag is write only @@ -137,10 +137,14 @@ void Write16(const u16 _iValue, const u32 _iAddress) case TOKEN_REG: //LOG(PIXELENGINE,"WEIRD: program wrote token: %i",_iValue); - PanicAlert("PIXELENGINE : (w16) WTF? program wrote token: %i",_iValue); + PanicAlert("PIXELENGINE : (w16) WTF? PowerPC program wrote token: %i", _iValue); //only the gx pipeline is supposed to be able to write here //g_token = _iValue; break; + + default: + WARN_LOG(PIXELENGINE, "Write16: unknown %04x @ %08x", _iValue, _iAddress); + break; } } @@ -195,6 +199,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) // TODO?: set-token-value and set-token-INT could be merged since set-token-INT own the token value. if (_bSetTokenAcknowledge) // set token INT { + // This seems smelly... CommandProcessor::IncrementGPWDToken(); // for DC watchdog hack since PEToken seems to be a frame-finish too CoreTiming::ScheduleEvent_Threadsafe( 0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); @@ -202,7 +207,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) else // set token value { // we do it directly from videoThread because of - // Super Monkey Ball Advance + // Super Monkey Ball Common::SyncInterlockedExchange((LONG*)&CommandProcessor::fifo.PEToken, _token); } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 34e6e6343b..3236d8dd80 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -258,8 +258,12 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) if (Size > 0) { - memcpy(pDest, pSrc, Size); - rContent.m_Position += Size; + if (pDest) { + memcpy(pDest, pSrc, Size); + rContent.m_Position += Size; + } else { + PanicAlert("IOCTL_ES_READCONTENT - bad destination"); + } } INFO_LOG(WII_IPC_ES, "ES: IOCTL_ES_READCONTENT: CFD %x, Addr 0x%x, Size %i -> stream pos %i (Index %i)", CFD, Addr, Size, rContent.m_Position, rContent.m_pContent->m_Index); diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index eae62f0152..192726806c 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -26,6 +26,7 @@ namespace DiscIO { + CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem) : m_pBannerFile(NULL) , m_IsValid(false) @@ -34,7 +35,14 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem) char TitleID[4]; _rFileSystem.GetVolume()->Read(0, 4, (u8*)TitleID); - sprintf(Filename, FULL_WII_USER_DIR "title/00010000/%02x%02x%02x%02x/data/banner.bin", (u8)TitleID[0], (u8)TitleID[1], (u8)TitleID[2], (u8)TitleID[3]); + sprintf(Filename, FULL_WII_USER_DIR "title/00010000/%02x%02x%02x%02x/data/banner.bin", + (u8)TitleID[0], (u8)TitleID[1], (u8)TitleID[2], (u8)TitleID[3]); + + if (!File::Exists(Filename)) + { + m_IsValid = false; + return; + } // load the opening.bnr size_t FileSize = (size_t) File::GetSize(Filename); @@ -43,7 +51,7 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem) { m_pBannerFile = new u8[FileSize]; FILE* pFile = fopen(Filename, "rb"); - if ((pFile != NULL) && (m_pBannerFile != NULL)) + if (pFile) { fread(m_pBannerFile, FileSize, 1, pFile); fclose(pFile); @@ -61,38 +69,33 @@ CBannerLoaderWii::~CBannerLoaderWii() } } - -bool -CBannerLoaderWii::IsValid() +bool CBannerLoaderWii::IsValid() { - return (m_IsValid); + return m_IsValid; } - -bool -CBannerLoaderWii::GetBanner(u32* _pBannerImage) +bool CBannerLoaderWii::GetBanner(u32* _pBannerImage) { if (IsValid()) { SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; - static u32 Buffer[192 * 64]; + u32 Buffer[192 * 64]; decode5A3image(Buffer, (u16*)pBanner->m_BannerTexture, 192, 64); - // ugly scaling :) - for (int y=0; y<32; y++) + // ugly scaling :) TODO: at least a 2x2 box filter, preferably a 3x3 gaussian :) + for (int y = 0; y < 32; y++) { - for (int x=0; x<96; x++) + for (int x = 0; x < 96; x++) { - _pBannerImage[y*96+x] = Buffer[(y*192*2)+(x*2)]; + _pBannerImage[y*96+x] = Buffer[(y*192*2) + (x*2)]; } } } return true; } -bool -CBannerLoaderWii::GetName(std::string* _rName) +bool CBannerLoaderWii::GetName(std::string* _rName) { if (IsValid()) { @@ -112,17 +115,13 @@ CBannerLoaderWii::GetName(std::string* _rName) return false; } - -bool -CBannerLoaderWii::GetCompany(std::string& _rCompany) +bool CBannerLoaderWii::GetCompany(std::string& _rCompany) { _rCompany = "N/A"; return true; } - -bool -CBannerLoaderWii::GetDescription(std::string* _rDescription) +bool CBannerLoaderWii::GetDescription(std::string* _rDescription) { if (IsValid()) { @@ -142,8 +141,7 @@ CBannerLoaderWii::GetDescription(std::string* _rDescription) return false; } -void -CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) +void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) { for (int y = 0; y < height; y += 4) { @@ -162,4 +160,3 @@ CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) } } // namespace - diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 4dbfeee204..4ca645caaf 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -133,8 +133,8 @@ inline u32 decode565(u16 val) inline u32 decodeIA8(u16 val) { - int a=val>>8; - int i=val&0xFF; + int a = val >> 8; + int i = val & 0xFF; return (a<<24) | (i<<16) | (i<<8) | i; } @@ -158,8 +158,6 @@ inline u32 decode5A3(u16 val) return (a<<24) | (r<<16) | (g<<8) | b; } - - struct DXTBlock { u16 color1; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp index 0301869bd5..452e61c7b3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp @@ -237,7 +237,6 @@ void BPWritten(int addr, int changes, int newval) ((u32*)&bpmem)[addr] = newval; if (changes & 1) { - // dev->SetRenderState(D3DRS_ALPHABLENDENABLE,bpmem.blendmode.blendenable); Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable); } if (changes & 2) {} // Logic op blending. D3D can't do this but can fake some modes. @@ -250,39 +249,30 @@ void BPWritten(int addr, int changes, int newval) if (changes & 0x700) { - // dev->SetRenderState(D3DRS_SRCBLEND, src); Renderer::SetRenderState(D3DRS_SRCBLEND, src); } if (changes & 0xE0) { if (!bpmem.blendmode.subtract) { - // dev->SetRenderState(D3DRS_DESTBLEND, dst); Renderer::SetRenderState(D3DRS_DESTBLEND, dst); } else { - // dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); } } if (changes & 0x800) { if (bpmem.blendmode.subtract) { - // dev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - // dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); Renderer::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); } else { - // dev->SetRenderState(D3DRS_SRCBLEND, src); - // dev->SetRenderState(D3DRS_DESTBLEND, dst); - Renderer::SetRenderState(D3DRS_SRCBLEND, src); Renderer::SetRenderState(D3DRS_DESTBLEND, dst); } - // dev->SetRenderState(D3DRS_BLENDOP,bpmem.blendmode.subtract?D3DBLENDOP_SUBTRACT:D3DBLENDOP_ADD); Renderer::SetRenderState(D3DRS_BLENDOP, bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD); } //if (bpmem.blendmode.logicopenable) // && bpmem.blendmode.logicmode == 4) @@ -297,7 +287,6 @@ void BPWritten(int addr, int changes, int newval) if (bpmem.blendmode.colorupdate) write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE; - // dev->SetRenderState(D3DRS_COLORWRITEENABLE, write); Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write); } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp index 34381fd0fd..5d93903795 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp @@ -99,7 +99,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) // So, here we go. First position: int elem_idx = 0; - elems[elem_idx].Offset = 0; // Positions are always first, at position 0. + elems[elem_idx].Offset = 0; // Positions are always first, at position 0. Always float3. elems[elem_idx].Type = D3DDECLTYPE_FLOAT3; elems[elem_idx].Usage = D3DDECLUSAGE_POSITION; ++elem_idx; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 7dd66dc763..bef5996a08 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -181,7 +181,7 @@ void Flush() if (collection != C_NOTHING) { // setup the pointers - if(g_nativeVertexFmt) + if (g_nativeVertexFmt) g_nativeVertexFmt->SetupVertexPointers(); u32 usedtextures = 0;