From 863cf71312a4d5952ea653813c7afb4c9883b6a2 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 28 Jul 2022 09:19:26 -0400 Subject: [PATCH] Migrate to inline=deferred,noauto --- Makefile | 12 +- asm/MetroidPrime/CGameCubeDoll.s | 3 +- include/Weapons/IWeaponRenderer.hpp | 3 +- src/Kyoto/Alloc/IAllocator.cpp | 16 +- src/Kyoto/Basics/CSWDataDolphin.cpp | 14 +- src/Kyoto/Streams/CInputStream.cpp | 209 +++++++++++++------------- src/Kyoto/Streams/CMemoryInStream.cpp | 13 +- src/Kyoto/Text/CStringTable.cpp | 26 ++-- src/MetroidPrime/main.cpp | 2 +- src/Weapons/IWeaponRenderer.cpp | 2 +- 10 files changed, 150 insertions(+), 150 deletions(-) diff --git a/Makefile b/Makefile index 9bdd7d7e..90cf3be2 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,7 @@ LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults -w off endif CFLAGS_1.2 = -proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp fmadd -str reuse,pool,readonly -O4,p -maxerrors 1 -use_lmw_stmw on -enum int -inline auto -MMD $(INCLUDES) CFLAGS_MUSYX = -proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp fmadd -str reuse,pool,readonly -O4,p -maxerrors 1 -enum int -inline auto -MMD $(INCLUDES) -CFLAGS = $(CFLAGS_1.2) -gccinc +CFLAGS = $(CFLAGS_1.2) -gccinc -inline deferred,noauto ifeq ($(VERBOSE),0) # this set of ASFLAGS generates no warnings. @@ -113,13 +113,23 @@ endif $(BUILD_DIR)/src/os/__start.o: MWCC_VERSION := 1.2.5 $(BUILD_DIR)/src/os/__start.o: CFLAGS := $(CFLAGS_1.2) +$(BUILD_DIR)/src/MetroTRK/mslsupp.o: MWCC_VERSION := 1.2.5 +$(BUILD_DIR)/src/MetroTRK/mslsupp.o: CFLAGS := $(CFLAGS_1.2) $(BUILD_DIR)/src/Dolphin/PPCArch.o: MWCC_VERSION := 1.2.5 $(BUILD_DIR)/src/Dolphin/PPCArch.o: CFLAGS := $(CFLAGS_1.2) $(BUILD_DIR)/src/Dolphin/os/OSAudioSystem.o: MWCC_VERSION := 1.2.5 $(BUILD_DIR)/src/Dolphin/os/OSAudioSystem.o: CFLAGS := $(CFLAGS_1.2) +$(BUILD_DIR)/src/Dolphin/os/OSReset.o: MWCC_VERSION := 1.2.5 +$(BUILD_DIR)/src/Dolphin/os/OSReset.o: CFLAGS := $(CFLAGS_1.2) $(BUILD_DIR)/src/Dolphin/dsp/dsp.o: MWCC_VERSION := 1.2.5 $(BUILD_DIR)/src/Dolphin/dsp/dsp.o: CFLAGS := $(CFLAGS_1.2) +$(BUILD_DIR)/src/musyx/seq_api.o: CFLAGS := $(CFLAGS_MUSYX) +$(BUILD_DIR)/src/musyx/synth_dbtab.o: CFLAGS := $(CFLAGS_MUSYX) $(BUILD_DIR)/src/musyx/snd_service.o: CFLAGS := $(CFLAGS_MUSYX) +$(BUILD_DIR)/src/musyx/snd_init.o: CFLAGS := $(CFLAGS_MUSYX) +$(BUILD_DIR)/src/musyx/dsp_import.o: CFLAGS := $(CFLAGS_MUSYX) +$(BUILD_DIR)/src/musyx/hw_memory.o: CFLAGS := $(CFLAGS_MUSYX) +$(BUILD_DIR)/src/musyx/reverb_fx.o: CFLAGS := $(CFLAGS_MUSYX) #------------------------------------------------------------------------------- # Recipes diff --git a/asm/MetroidPrime/CGameCubeDoll.s b/asm/MetroidPrime/CGameCubeDoll.s index 4a8a7c1e..6077c5e4 100644 --- a/asm/MetroidPrime/CGameCubeDoll.s +++ b/asm/MetroidPrime/CGameCubeDoll.s @@ -529,7 +529,6 @@ lbl_805ADE04: lbl_803D5E98: # ROM: 0x3D2E98 .asciz "CMDL_GameCube" - .byte 0x3F, 0x3F - .asciz "(??)" + .asciz "??(??)" .balign 4 diff --git a/include/Weapons/IWeaponRenderer.hpp b/include/Weapons/IWeaponRenderer.hpp index 66f2b840..4b60badb 100644 --- a/include/Weapons/IWeaponRenderer.hpp +++ b/include/Weapons/IWeaponRenderer.hpp @@ -3,6 +3,7 @@ class CParticleGen; class IWeaponRenderer { +public: virtual ~IWeaponRenderer() {} virtual void AddParticleGen(const CParticleGen& gen) = 0; @@ -18,6 +19,4 @@ public: void AddParticleGen(const CParticleGen& gen); }; -static CDefaultRenderer sDefaultRenderer = CDefaultRenderer();; - #endif //__IWEAPONRENDERER_HPP__ diff --git a/src/Kyoto/Alloc/IAllocator.cpp b/src/Kyoto/Alloc/IAllocator.cpp index c12e09ec..3b7ac192 100644 --- a/src/Kyoto/Alloc/IAllocator.cpp +++ b/src/Kyoto/Alloc/IAllocator.cpp @@ -2,16 +2,10 @@ #include "Kyoto/Basics/COsContext.hpp" - -IAllocator::~IAllocator() { - -} - -IAllocator::SMetrics::SMetrics(u32 heapSize, u32 unk1, u32 unk2, u32 unk3, u32 unk4, u32 heapSize2, u32 unk5, u32 unk6, - u32 unk7, u32 unk8, u32 unk9, u32 smallAllocNumAllocs, u32 smallAllocAllocatedSize, - u32 smallAllocRemainingSize, u32 mediumAllocNumAllocs, u32 mediumAllocAllocatedSize, - u32 mediumAllocBlocksAvailable, u32 unk10, u32 unk11, u32 unk12, - u32 mediumAllocTotalAllocated, u32 fakeStatics) +IAllocator::SMetrics::SMetrics(u32 heapSize, u32 unk1, u32 unk2, u32 unk3, u32 unk4, u32 heapSize2, u32 unk5, u32 unk6, u32 unk7, u32 unk8, + u32 unk9, u32 smallAllocNumAllocs, u32 smallAllocAllocatedSize, u32 smallAllocRemainingSize, + u32 mediumAllocNumAllocs, u32 mediumAllocAllocatedSize, u32 mediumAllocBlocksAvailable, u32 unk10, u32 unk11, + u32 unk12, u32 mediumAllocTotalAllocated, u32 fakeStatics) : x0_heapSize(heapSize) , x4_(unk1) , x8_(unk2) @@ -34,3 +28,5 @@ IAllocator::SMetrics::SMetrics(u32 heapSize, u32 unk1, u32 unk2, u32 unk3, u32 u , x4c_(unk12) , x50_mediumTotalAllocated(mediumAllocTotalAllocated) , x54_fakeStatics(fakeStatics) {} + +IAllocator::~IAllocator() {} diff --git a/src/Kyoto/Basics/CSWDataDolphin.cpp b/src/Kyoto/Basics/CSWDataDolphin.cpp index b30ccc83..0f988d49 100644 --- a/src/Kyoto/Basics/CSWDataDolphin.cpp +++ b/src/Kyoto/Basics/CSWDataDolphin.cpp @@ -2,13 +2,6 @@ #include "Dolphin/os.h" -bool CStopwatch::CSWData::Initialize() { - x0_timerFreq = OS_TIMER_CLOCK; - x8_timerFreqO1M = x0_timerFreq / 1000000ll; - x10_timerPeriod = 1.f / static_cast(x0_timerFreq); - return true; -} - void CStopwatch::CSWData::Wait(f32 v) const { OSTime duration = OSSecondsToTicks(v); OSTime end = OSGetTime() + duration; @@ -19,3 +12,10 @@ void CStopwatch::CSWData::Wait(f32 v) const { diff = current - end; } while (diff < 0); } + +bool CStopwatch::CSWData::Initialize() { + x0_timerFreq = OS_TIMER_CLOCK; + x8_timerFreqO1M = x0_timerFreq / 1000000ll; + x10_timerPeriod = 1.f / static_cast(x0_timerFreq); + return true; +} diff --git a/src/Kyoto/Streams/CInputStream.cpp b/src/Kyoto/Streams/CInputStream.cpp index ee76ee0d..12eac857 100644 --- a/src/Kyoto/Streams/CInputStream.cpp +++ b/src/Kyoto/Streams/CInputStream.cpp @@ -4,37 +4,97 @@ #include "Kyoto/Alloc/CMemory.hpp" -static u8 c; -static u16 s; -static u32 l; -static u64 ll; -static f32 f; +CInputStream::CInputStream(size_t len) +: x4_blockOffset(0) +, x8_blockLen(0) +, xc_len(len) +, x10_ptr(new u8[len]) +, x14_owned(true) +, x18_readPosition(0) +, x1c_bitWord(0) +, x20_bitOffset(0) {} -f32 CInputStream::ReadFloat() { - Get(&f, sizeof(f32)); - return f; +CInputStream::CInputStream(const void* ptr, size_t len, bool owned) +: x4_blockOffset(0) +, x8_blockLen(len) +, xc_len(len) +, x10_ptr(const_cast< u8* >(reinterpret_cast< const u8* >(ptr))) +, x14_owned(owned) +, x18_readPosition(0) +, x1c_bitWord(0) +, x20_bitOffset(0) {} + +CInputStream::~CInputStream() { + if (x14_owned) { + delete x10_ptr; + } } -u64 CInputStream::ReadLongLong() { - Get(&ll, sizeof(u64)); - return ll; +bool CInputStream::InternalReadNext() { + x8_blockLen = Read(x10_ptr, xc_len); + x4_blockOffset = 0; + return x8_blockLen != 0; } -u32 CInputStream::ReadLong() { - Get(&l, sizeof(u32)); - return l; +bool CInputStream::GrabAnotherBlock() { return InternalReadNext(); } + +void CInputStream::Get(void* dest, unsigned long len) { + u32 remain = len; + u32 readCount = 0; + x20_bitOffset = 0; + + while (remain != 0) { + u32 blockLen = x8_blockLen - x4_blockOffset; + blockLen = remain < blockLen ? remain : blockLen; + + if (blockLen != 0) { + memcpy(reinterpret_cast< u8* >(dest) + readCount, x10_ptr + x4_blockOffset, blockLen); + remain -= blockLen; + readCount += blockLen; + x4_blockOffset += blockLen; + } else if (remain > 256) { + u32 readLen = Read(reinterpret_cast< u8* >(dest) + readCount, remain); + remain -= readLen; + readCount += readLen; + } else { + GrabAnotherBlock(); + } + } + + x18_readPosition += readCount; } -u16 CInputStream::ReadShort() { - Get(&s, sizeof(u16)); - return s; -} +u32 CInputStream::ReadBytes(void* dest, unsigned long len) { + if (len == 0) { + return 0; + } -bool CInputStream::ReadBool() { return static_cast< bool >(ReadChar()); } + if (x4_blockOffset == x8_blockLen) { + GrabAnotherBlock(); + } -u8 CInputStream::ReadChar() { - Get(&c, sizeof(u8)); - return c; + u32 curLen = len; + u32 curReadLen = 0; + + while (curReadLen < len) { + u32 remain = x8_blockLen - x4_blockOffset; + if (remain == 0) { + if (InternalReadNext()) { + continue; + } else { + return curReadLen; + } + } + + u32 sz = curLen < remain ? curLen : remain; + memcpy(reinterpret_cast< u8* >(dest) + curReadLen, x10_ptr + x4_blockOffset, sz); + curReadLen += sz; + curLen -= sz; + x4_blockOffset += sz; + } + + x18_readPosition += curReadLen; + return curReadLen; } static inline u32 BitsToBytes(u32 bits) { return (bits / 8) + ((bits % 8) ? 1 : 0); } @@ -84,95 +144,34 @@ u32 CInputStream::ReadBits(u32 bitCount) { return ret; } -u32 CInputStream::ReadBytes(void* dest, unsigned long len) { - if (len == 0) { - return 0; - } - - if (x4_blockOffset == x8_blockLen) { - GrabAnotherBlock(); - } - - u32 curLen = len; - u32 curReadLen = 0; - - while (curReadLen < len) { - u32 remain = x8_blockLen - x4_blockOffset; - if (remain == 0) { - if (InternalReadNext()) { - continue; - } else { - return curReadLen; - } - } - - u32 sz = curLen < remain ? curLen : remain; - memcpy(reinterpret_cast< u8* >(dest) + curReadLen, x10_ptr + x4_blockOffset, sz); - curReadLen += sz; - curLen -= sz; - x4_blockOffset += sz; - } - - x18_readPosition += curReadLen; - return curReadLen; +u8 CInputStream::ReadChar() { + static u8 c; + Get(&c, sizeof(u8)); + return c; } -void CInputStream::Get(void* dest, unsigned long len) { - u32 remain = len; - u32 readCount = 0; - x20_bitOffset = 0; +bool CInputStream::ReadBool() { return static_cast< bool >(ReadChar()); } - while (remain != 0) { - u32 blockLen = x8_blockLen - x4_blockOffset; - blockLen = remain < blockLen ? remain : blockLen; - - if (blockLen != 0) { - memcpy(reinterpret_cast< u8* >(dest) + readCount, x10_ptr + x4_blockOffset, blockLen); - remain -= blockLen; - readCount += blockLen; - x4_blockOffset += blockLen; - } else if (remain > 256) { - u32 readLen = Read(reinterpret_cast< u8* >(dest) + readCount, remain); - remain -= readLen; - readCount += readLen; - } else { - GrabAnotherBlock(); - } - } - - x18_readPosition += readCount; +u16 CInputStream::ReadShort() { + static u16 s; + Get(&s, sizeof(u16)); + return s; } -bool CInputStream::GrabAnotherBlock() { return InternalReadNext(); } - -bool CInputStream::InternalReadNext() { - x8_blockLen = Read(x10_ptr, xc_len); - x4_blockOffset = 0; - return x8_blockLen != 0; +u32 CInputStream::ReadLong() { + static u32 l; + Get(&l, sizeof(u32)); + return l; } -CInputStream::~CInputStream() { - if (x14_owned) { - delete x10_ptr; - } +u64 CInputStream::ReadLongLong() { + static u64 ll; + Get(&ll, sizeof(u64)); + return ll; } -CInputStream::CInputStream(const void* ptr, size_t len, bool owned) -: x4_blockOffset(0) -, x8_blockLen(len) -, xc_len(len) -, x10_ptr(const_cast< u8* >(reinterpret_cast< const u8* >(ptr))) -, x14_owned(owned) -, x18_readPosition(0) -, x1c_bitWord(0) -, x20_bitOffset(0) {} - -CInputStream::CInputStream(size_t len) -: x4_blockOffset(0) -, x8_blockLen(0) -, xc_len(len) -, x10_ptr(new u8[len]) -, x14_owned(true) -, x18_readPosition(0) -, x1c_bitWord(0) -, x20_bitOffset(0) {} +f32 CInputStream::ReadFloat() { + static f32 f; + Get(&f, sizeof(f32)); + return f; +} diff --git a/src/Kyoto/Streams/CMemoryInStream.cpp b/src/Kyoto/Streams/CMemoryInStream.cpp index 499220a1..56c5afe1 100644 --- a/src/Kyoto/Streams/CMemoryInStream.cpp +++ b/src/Kyoto/Streams/CMemoryInStream.cpp @@ -1,11 +1,8 @@ #include "Kyoto/Streams/CMemoryInStream.hpp" -u32 CMemoryInStream::Read(void* dest, u32 len) { - return 0; -} - -CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len) -: CInputStream(ptr, len, false) {} - -CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len, EOwnerShip ownership) +CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len, EOwnerShip ownership) : CInputStream(ptr, len, ownership == kOS_Owned) {} + +CMemoryInStream::CMemoryInStream(const void* ptr, unsigned long len) : CInputStream(ptr, len, false) {} + +u32 CMemoryInStream::Read(void* dest, u32 len) { return 0; } diff --git a/src/Kyoto/Text/CStringTable.cpp b/src/Kyoto/Text/CStringTable.cpp index caaf596b..c2bd9a3d 100644 --- a/src/Kyoto/Text/CStringTable.cpp +++ b/src/Kyoto/Text/CStringTable.cpp @@ -6,20 +6,7 @@ #include "Kyoto/CFactoryMgr.hpp" static FourCC mCurrentLanguage = 'ENGL'; - -CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& xfer) { return new CStringTable(in); } - -template <> -CFactoryFnReturn::CFactoryFnReturn(CStringTable* ptr) : obj(TToken< CStringTable >::GetIObjObjectFor(ptr).release()) {} - static const wchar_t skInvalidString[] = L"Invalid"; -const wchar_t* CStringTable::GetString(s32 idx) const { - if (idx < 0 || idx >= x0_stringCount) { - return skInvalidString; - } - s32 offset = *(reinterpret_cast< const s32* >(x4_data.get()) + idx); - return reinterpret_cast< const wchar_t* >(x4_data.get() + offset); -} CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) { in.ReadLong(); @@ -46,3 +33,16 @@ CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) x4_data = new u8[dataLen]; in.ReadBytes(x4_data.get(), dataLen); } + +const wchar_t* CStringTable::GetString(s32 idx) const { + if (idx < 0 || idx >= x0_stringCount) { + return skInvalidString; + } + s32 offset = *(reinterpret_cast< const s32* >(x4_data.get()) + idx); + return reinterpret_cast< const wchar_t* >(x4_data.get() + offset); +} + +template <> +CFactoryFnReturn::CFactoryFnReturn(CStringTable* ptr) : obj(TToken< CStringTable >::GetIObjObjectFor(ptr).release()) {} + +CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& xfer) { return new CStringTable(in); } diff --git a/src/MetroidPrime/main.cpp b/src/MetroidPrime/main.cpp index 54a24d1b..9ffe57d5 100644 --- a/src/MetroidPrime/main.cpp +++ b/src/MetroidPrime/main.cpp @@ -97,7 +97,7 @@ void CMain::RefreshGameState() { x128_gameGlobalObjects->GameState() = nullptr; gpGameState = nullptr; { - CMemoryInStream stream(backupBuf.data(), backupBuf.size(), CMemoryInStream::Owned); + CMemoryInStream stream(backupBuf.data(), backupBuf.size(), CMemoryInStream::kOS_Owned); x128_gameGlobalObjects->GameState() = new CGameState(stream, saveIdx); } gpGameState = x128_gameGlobalObjects->GameState().get(); diff --git a/src/Weapons/IWeaponRenderer.cpp b/src/Weapons/IWeaponRenderer.cpp index 9f5331cb..c7808b38 100644 --- a/src/Weapons/IWeaponRenderer.cpp +++ b/src/Weapons/IWeaponRenderer.cpp @@ -3,7 +3,7 @@ #include "Kyoto/Particles/CParticleGen.hpp" #include "Kyoto/Alloc/CMemory.hpp" -//CDefaultRenderer sDefaultRenderer = CDefaultRenderer(); +static CDefaultRenderer sDefaultRenderer = CDefaultRenderer(); IWeaponRenderer* IWeaponRenderer::sWeaponRenderer = &sDefaultRenderer;