diff --git a/include/Kyoto/Alloc/CMemory.hpp b/include/Kyoto/Alloc/CMemory.hpp index ba4a3b89..6f649688 100644 --- a/include/Kyoto/Alloc/CMemory.hpp +++ b/include/Kyoto/Alloc/CMemory.hpp @@ -24,18 +24,20 @@ public: static void OffsetFakeStatics(int); }; +#ifdef __MWERKS__ void* operator new(size_t sz, const char*, const char*); void* operator new[](size_t sz, const char*, const char*); // TODO remove -#ifdef __MWERKS__ + inline void* operator new(size_t sz) { return operator new(sz, "??(??)", nullptr); } inline void* operator new[](size_t sz) { return operator new[](sz, "??(??)", nullptr); } #else -__attribute__((weak)) void* operator new(size_t sz) { return operator new(sz, "??(??)", nullptr); } +/*__attribute__((weak)) void* operator new(size_t sz) { return operator new(sz, "??(??)", nullptr); } __attribute__((weak)) void* operator new[](size_t sz) { return operator new[](sz, "??(??)", nullptr); -} +}*/ #endif + // placement new inline void* operator new(size_t n, void* ptr) { return ptr; }; diff --git a/src/Kyoto/Alloc/CGameAllocator.cpp b/src/Kyoto/Alloc/CGameAllocator.cpp index a836dbe5..ab675aac 100644 --- a/src/Kyoto/Alloc/CGameAllocator.cpp +++ b/src/Kyoto/Alloc/CGameAllocator.cpp @@ -6,6 +6,8 @@ #include #include +#include + /* Here just to make sure the data section matches */ static const char* string_NULL = ""; static const char* string_SOURCE_MODULE_UNLOADED = ""; @@ -301,7 +303,7 @@ IAllocator::SMetrics CGameAllocator::GetMetrics() const { x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetAllocatedSize() : 0, x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetNumBlocksAvailable() : 0, mediumAllocNumAllocs, mediumAllocAllocatedSize, mediumAllocBlocksAvailable, - x80_ - xb0_, (uint)xb4_physicalAddr, xbc_, mediumAllocTotalAllocated, + x80_ - xb0_, (uintptr_t)xb4_physicalAddr, xbc_, mediumAllocTotalAllocated, xb8_fakeStatics); xb0_ = x80_; return ret; diff --git a/src/Kyoto/CARAMToken.cpp b/src/Kyoto/CARAMToken.cpp index 3125bc28..12c33565 100644 --- a/src/Kyoto/CARAMToken.cpp +++ b/src/Kyoto/CARAMToken.cpp @@ -5,7 +5,7 @@ #include "rstl/construct.hpp" -#include "dolphin/OS/OSCache.h" +#include "dolphin/os/OSCache.h" CARAMToken* CARAMToken::sLists[7]; CARAMToken::CARAMToken() { diff --git a/src/Kyoto/CToken.cpp b/src/Kyoto/CToken.cpp index eac5e369..9db836a6 100644 --- a/src/Kyoto/CToken.cpp +++ b/src/Kyoto/CToken.cpp @@ -6,7 +6,7 @@ CToken::CToken(CObjectReference* ref) : x0_objRef(ref), x4_lockHeld(false) { } CToken::CToken(IObj* obj) -: x0_objRef(new ("??(??)", nullptr) CObjectReference(obj)), x4_lockHeld(false) { +: x0_objRef(NEW CObjectReference(obj)), x4_lockHeld(false) { x0_objRef->AddReference(); Lock(); } diff --git a/src/Kyoto/Graphics/CTevCombiners.cpp b/src/Kyoto/Graphics/CTevCombiners.cpp index b50b2150..ac81a65e 100644 --- a/src/Kyoto/Graphics/CTevCombiners.cpp +++ b/src/Kyoto/Graphics/CTevCombiners.cpp @@ -10,12 +10,14 @@ const CTevCombiners::AlphaVar CTevCombiners::skAlphaOne(CTevCombiners::kAS_Konst const CTevCombiners::ColorVar CTevCombiners::skColorOne(CTevCombiners::kCS_One); const CTevCombiners::CTevPass CTevCombiners::kEnvPassthru( - CTevCombiners::ColorPass(CTevCombiners::ColorVar(kCS_Zero), CTevCombiners::ColorVar(kCS_Zero), - CTevCombiners::ColorVar(kCS_Zero), - CTevCombiners::ColorVar(kCS_RasterColor)), - CTevCombiners::AlphaPass(CTevCombiners::AlphaVar(kAS_Zero), CTevCombiners::AlphaVar(kAS_Zero), - CTevCombiners::AlphaVar(kAS_Zero), - CTevCombiners::AlphaVar(kAS_RasterAlpha))); + CTevCombiners::ColorPass((CTevCombiners::ColorVar(CTevCombiners::kCS_Zero)), + CTevCombiners::ColorVar(CTevCombiners::kCS_Zero), + CTevCombiners::ColorVar(CTevCombiners::kCS_Zero), + CTevCombiners::ColorVar(CTevCombiners::kCS_RasterColor)), + CTevCombiners::AlphaPass(CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero), + CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero), + CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero), + CTevCombiners::AlphaVar(CTevCombiners::kAS_RasterAlpha))); bool CTevCombiners::sValidPasses[2] = {false, false}; uint CTevCombiners::sNumEnabledPasses = -1; diff --git a/src/Kyoto/Streams/COutputStream.cpp b/src/Kyoto/Streams/COutputStream.cpp index 9a77887d..1b5d08f8 100644 --- a/src/Kyoto/Streams/COutputStream.cpp +++ b/src/Kyoto/Streams/COutputStream.cpp @@ -5,11 +5,13 @@ #include "Kyoto/Alloc/CMemory.hpp" #include +#include + COutputStream::COutputStream(int len) : mUnwrittenLen(0) , mBufLen(len) -, mBufPtr(len > 64 ? new uchar[len] : &mScratch[32 - (uint)(mScratch) % 31]) +, mBufPtr(len > 64 ? new uchar[len] : &mScratch[32 - (uintptr_t)(mScratch) % 31]) , mNumWrites(0) , mShiftRegister(0) , mShiftRegisterOffset(32) {} diff --git a/src/MetroidPrime/CWorldShadow.cpp b/src/MetroidPrime/CWorldShadow.cpp index 76359595..1f8b49ce 100644 --- a/src/MetroidPrime/CWorldShadow.cpp +++ b/src/MetroidPrime/CWorldShadow.cpp @@ -166,13 +166,13 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid void CWorldShadow::EnableModelProjectedShadow(const CTransform4f& pos, uint lightIdx, float f1) const { - static float M_SQRT2 = CMath::SqrtD(2.0); // TODO: should be an inlined function + static float sqrt2 = CMath::SqrtD(2.0); // TODO: should be an inlined function CTransform4f texTransform = CTransform4f::LookAt(CVector3f::Zero(), x74_lightPos - x68_objPos, CVector3f(0.0f, 0.0f, 1.0f)); CTransform4f posXf = pos; posXf.SetTranslation(CVector3f::Zero()); texTransform = posXf.GetInverse() * texTransform; - texTransform = texTransform * CTransform4f::Scale(float(M_SQRT2) * x64_objHalfExtent * f1); + texTransform = texTransform * CTransform4f::Scale(float(sqrt2) * x64_objHalfExtent * f1); texTransform = texTransform.GetInverse(); texTransform = CTransform4f::Translate(0.5f, 0.f, 0.5f) * texTransform; diff --git a/src/MetroidPrime/main.cpp b/src/MetroidPrime/main.cpp index a012a1ba..e42ea571 100644 --- a/src/MetroidPrime/main.cpp +++ b/src/MetroidPrime/main.cpp @@ -199,8 +199,11 @@ void CMain::ShutdownSubsystems() { break; } } +#ifdef __MWERKS__ + // TODO: assuming pointer is int-sized OSReport("Stack usage: %d bytes (%dk)\n", (int)(stackBase - ptr), ((uint)((int)stackBase - (int)ptr) / 1024)); +#endif } CGameGlobalObjects::CGameGlobalObjects(COsContext& osContext, CMemorySys& memorySys)