Fix compiling with host compiler

This commit is contained in:
Henrique Gemignani Passos Lima 2022-12-23 21:33:49 -03:00
parent 8cd4e80bb0
commit f7623bd219
8 changed files with 26 additions and 15 deletions

View File

@ -24,18 +24,20 @@ public:
static void OffsetFakeStatics(int); 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*);
void* operator new[](size_t sz, const char*, const char*); void* operator new[](size_t sz, const char*, const char*);
// TODO remove // 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); }
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 #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) { __attribute__((weak)) void* operator new[](size_t sz) {
return operator new[](sz, "??(??)", nullptr); return operator new[](sz, "??(??)", nullptr);
} }*/
#endif #endif
// placement new // placement new
inline void* operator new(size_t n, void* ptr) { return ptr; }; inline void* operator new(size_t n, void* ptr) { return ptr; };

View File

@ -6,6 +6,8 @@
#include <Kyoto/Basics/COsContext.hpp> #include <Kyoto/Basics/COsContext.hpp>
#include <Kyoto/Basics/CStopwatch.hpp> #include <Kyoto/Basics/CStopwatch.hpp>
#include <stdint.h>
/* Here just to make sure the data section matches */ /* Here just to make sure the data section matches */
static const char* string_NULL = "<NULL>"; static const char* string_NULL = "<NULL>";
static const char* string_SOURCE_MODULE_UNLOADED = "<SOURCE MODULE UNLOADED>"; static const char* string_SOURCE_MODULE_UNLOADED = "<SOURCE MODULE UNLOADED>";
@ -301,7 +303,7 @@ IAllocator::SMetrics CGameAllocator::GetMetrics() const {
x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetAllocatedSize() : 0, x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetAllocatedSize() : 0,
x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetNumBlocksAvailable() : 0, x60_smallAllocPool != nullptr ? x60_smallAllocPool->GetNumBlocksAvailable() : 0,
mediumAllocNumAllocs, mediumAllocAllocatedSize, mediumAllocBlocksAvailable, mediumAllocNumAllocs, mediumAllocAllocatedSize, mediumAllocBlocksAvailable,
x80_ - xb0_, (uint)xb4_physicalAddr, xbc_, mediumAllocTotalAllocated, x80_ - xb0_, (uintptr_t)xb4_physicalAddr, xbc_, mediumAllocTotalAllocated,
xb8_fakeStatics); xb8_fakeStatics);
xb0_ = x80_; xb0_ = x80_;
return ret; return ret;

View File

@ -5,7 +5,7 @@
#include "rstl/construct.hpp" #include "rstl/construct.hpp"
#include "dolphin/OS/OSCache.h" #include "dolphin/os/OSCache.h"
CARAMToken* CARAMToken::sLists[7]; CARAMToken* CARAMToken::sLists[7];
CARAMToken::CARAMToken() { CARAMToken::CARAMToken() {

View File

@ -6,7 +6,7 @@ CToken::CToken(CObjectReference* ref) : x0_objRef(ref), x4_lockHeld(false) {
} }
CToken::CToken(IObj* obj) CToken::CToken(IObj* obj)
: x0_objRef(new ("??(??)", nullptr) CObjectReference(obj)), x4_lockHeld(false) { : x0_objRef(NEW CObjectReference(obj)), x4_lockHeld(false) {
x0_objRef->AddReference(); x0_objRef->AddReference();
Lock(); Lock();
} }

View File

@ -10,12 +10,14 @@ const CTevCombiners::AlphaVar CTevCombiners::skAlphaOne(CTevCombiners::kAS_Konst
const CTevCombiners::ColorVar CTevCombiners::skColorOne(CTevCombiners::kCS_One); const CTevCombiners::ColorVar CTevCombiners::skColorOne(CTevCombiners::kCS_One);
const CTevCombiners::CTevPass CTevCombiners::kEnvPassthru( const CTevCombiners::CTevPass CTevCombiners::kEnvPassthru(
CTevCombiners::ColorPass(CTevCombiners::ColorVar(kCS_Zero), CTevCombiners::ColorVar(kCS_Zero), CTevCombiners::ColorPass((CTevCombiners::ColorVar(CTevCombiners::kCS_Zero)),
CTevCombiners::ColorVar(kCS_Zero), CTevCombiners::ColorVar(CTevCombiners::kCS_Zero),
CTevCombiners::ColorVar(kCS_RasterColor)), CTevCombiners::ColorVar(CTevCombiners::kCS_Zero),
CTevCombiners::AlphaPass(CTevCombiners::AlphaVar(kAS_Zero), CTevCombiners::AlphaVar(kAS_Zero), CTevCombiners::ColorVar(CTevCombiners::kCS_RasterColor)),
CTevCombiners::AlphaVar(kAS_Zero), CTevCombiners::AlphaPass(CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero),
CTevCombiners::AlphaVar(kAS_RasterAlpha))); CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero),
CTevCombiners::AlphaVar(CTevCombiners::kAS_Zero),
CTevCombiners::AlphaVar(CTevCombiners::kAS_RasterAlpha)));
bool CTevCombiners::sValidPasses[2] = {false, false}; bool CTevCombiners::sValidPasses[2] = {false, false};
uint CTevCombiners::sNumEnabledPasses = -1; uint CTevCombiners::sNumEnabledPasses = -1;

View File

@ -5,11 +5,13 @@
#include "Kyoto/Alloc/CMemory.hpp" #include "Kyoto/Alloc/CMemory.hpp"
#include <string.h> #include <string.h>
#include <stdint.h>
COutputStream::COutputStream(int len) COutputStream::COutputStream(int len)
: mUnwrittenLen(0) : mUnwrittenLen(0)
, mBufLen(len) , 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) , mNumWrites(0)
, mShiftRegister(0) , mShiftRegister(0)
, mShiftRegisterOffset(32) {} , mShiftRegisterOffset(32) {}

View File

@ -166,13 +166,13 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
void CWorldShadow::EnableModelProjectedShadow(const CTransform4f& pos, uint lightIdx, void CWorldShadow::EnableModelProjectedShadow(const CTransform4f& pos, uint lightIdx,
float f1) const { 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, CTransform4f texTransform = CTransform4f::LookAt(CVector3f::Zero(), x74_lightPos - x68_objPos,
CVector3f(0.0f, 0.0f, 1.0f)); CVector3f(0.0f, 0.0f, 1.0f));
CTransform4f posXf = pos; CTransform4f posXf = pos;
posXf.SetTranslation(CVector3f::Zero()); posXf.SetTranslation(CVector3f::Zero());
texTransform = posXf.GetInverse() * texTransform; 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 = texTransform.GetInverse();
texTransform = CTransform4f::Translate(0.5f, 0.f, 0.5f) * texTransform; texTransform = CTransform4f::Translate(0.5f, 0.f, 0.5f) * texTransform;

View File

@ -199,8 +199,11 @@ void CMain::ShutdownSubsystems() {
break; break;
} }
} }
#ifdef __MWERKS__
// TODO: assuming pointer is int-sized
OSReport("Stack usage: %d bytes (%dk)\n", (int)(stackBase - ptr), OSReport("Stack usage: %d bytes (%dk)\n", (int)(stackBase - ptr),
((uint)((int)stackBase - (int)ptr) / 1024)); ((uint)((int)stackBase - (int)ptr) / 1024));
#endif
} }
CGameGlobalObjects::CGameGlobalObjects(COsContext& osContext, CMemorySys& memorySys) CGameGlobalObjects::CGameGlobalObjects(COsContext& osContext, CMemorySys& memorySys)