From f511aba22850cf38b565ec44f5012b997f832808 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 18 Jul 2022 09:51:34 -0400 Subject: [PATCH] Link CStringTable.cpp --- Makefile | 6 +++--- include/Kyoto_CWD/CStringTable.hpp | 2 +- include/Kyoto_CWD/TGameTypes.hpp | 2 +- obj_files.mk | 2 +- src/Kyoto/Text/CStringTable.cpp | 9 +++++---- tools/asmdiff.sh | 4 +++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index d5bb8538..b4878587 100644 --- a/Makefile +++ b/Makefile @@ -95,13 +95,13 @@ ASM_INCLUDES := -I include/ ASFLAGS := -mgekko $(ASM_INCLUDES) --defsym version=$(VERSION) ifeq ($(VERBOSE),1) # this set of LDFLAGS outputs warnings. -LDFLAGS := $(MAPGEN) -fp hard -nodefaults +LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults endif ifeq ($(VERBOSE),0) # this set of LDFLAGS generates no warnings. -LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off +LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults -w off endif -CFLAGS_1.2 = -proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp hard -fp_contract on -str reuse,pool,readonly -rostr -O4,p -maxerrors 1 -use_lmw_stmw on -enum int -inline auto -MMD $(INCLUDES) +CFLAGS_1.2 = -proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp fmadd -str reuse,pool,readonly -rostr -O4,p -maxerrors 1 -use_lmw_stmw on -enum int -inline auto -MMD $(INCLUDES) CFLAGS = $(CFLAGS_1.2) -gccinc ifeq ($(VERBOSE),0) diff --git a/include/Kyoto_CWD/CStringTable.hpp b/include/Kyoto_CWD/CStringTable.hpp index 71fab076..c7f67257 100644 --- a/include/Kyoto_CWD/CStringTable.hpp +++ b/include/Kyoto_CWD/CStringTable.hpp @@ -8,7 +8,7 @@ #include "CInputStream.hpp" class CStringTable { - u32 x0_stringCount; + s32 x0_stringCount; rstl::single_ptr< u8 > x4_data; public: diff --git a/include/Kyoto_CWD/TGameTypes.hpp b/include/Kyoto_CWD/TGameTypes.hpp index 8171d329..18c7692d 100644 --- a/include/Kyoto_CWD/TGameTypes.hpp +++ b/include/Kyoto_CWD/TGameTypes.hpp @@ -19,7 +19,7 @@ typedef u32 CAssetId; // bool operator==(const CAssetId& other) { return id == other.id; } // }; -#define FourCC unsigned long +#define FourCC u32 struct SObjectTag { FourCC type; diff --git a/obj_files.mk b/obj_files.mk index 94a38bf2..90bb0400 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -599,7 +599,7 @@ KYOTO :=\ $(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinRules.o\ $(BUILD_DIR)/asm/Kyoto/Animation/DolphinCVirtualBone.o\ $(BUILD_DIR)/asm/Kyoto/Graphics/DolphinCModel.o\ - $(BUILD_DIR)/asm/Kyoto/Text/CStringTable.o\ + $(BUILD_DIR)/src/Kyoto/Text/CStringTable.o\ $(BUILD_DIR)/asm/Kyoto/Particles/CEmitterElement.o\ $(BUILD_DIR)/asm/Kyoto/Particles/CEffectComponent.o\ $(BUILD_DIR)/asm/Kyoto/Particles/CParticleData.o\ diff --git a/src/Kyoto/Text/CStringTable.cpp b/src/Kyoto/Text/CStringTable.cpp index 897b4696..96b5b02a 100644 --- a/src/Kyoto/Text/CStringTable.cpp +++ b/src/Kyoto/Text/CStringTable.cpp @@ -13,9 +13,10 @@ CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, co 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 L"Invalid"; + 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); @@ -26,9 +27,9 @@ CStringTable::CStringTable(CInputStream& in) : x0_stringCount(0), x4_data(NULL) in.ReadLong(); size_t langCount = in.Get< size_t >(); x0_stringCount = in.Get< u32 >(); - rstl::vector< rstl::pair< FourCC, unsigned long > > langOffsets(langCount); + rstl::vector< rstl::pair< FourCC, u32 > > langOffsets(langCount); for (size_t i = 0; i < langCount; ++i) { - langOffsets.push_back(in.Get< rstl::pair< FourCC, unsigned long > >()); + langOffsets.push_back(in.Get< rstl::pair< FourCC, u32 > >()); } size_t offset = langOffsets.front().second; diff --git a/tools/asmdiff.sh b/tools/asmdiff.sh index 476f4fba..da97a3b4 100755 --- a/tools/asmdiff.sh +++ b/tools/asmdiff.sh @@ -1,7 +1,9 @@ #!/bin/bash -e OBJDUMP="$DEVKITPPC/bin/powerpc-eabi-objdump -D -bbinary -EB -mpowerpc -M gekko" -OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" +if [ ! -z "$1" ]; then +OPTIONS="--start-address=$(($1)) --stop-address=$(($2))" +fi $OBJDUMP $OPTIONS baserom.dol > baserom.dump $OBJDUMP $OPTIONS build/mp1.0/main.dol > main.dump diff -u --color=always baserom.dump main.dump