Link CStringTable.cpp

This commit is contained in:
Luke Street 2022-07-18 09:51:34 -04:00
parent 1bc93e4dbc
commit f511aba228
6 changed files with 14 additions and 11 deletions

View File

@ -95,13 +95,13 @@ ASM_INCLUDES := -I include/
ASFLAGS := -mgekko $(ASM_INCLUDES) --defsym version=$(VERSION) ASFLAGS := -mgekko $(ASM_INCLUDES) --defsym version=$(VERSION)
ifeq ($(VERBOSE),1) ifeq ($(VERBOSE),1)
# this set of LDFLAGS outputs warnings. # this set of LDFLAGS outputs warnings.
LDFLAGS := $(MAPGEN) -fp hard -nodefaults LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults
endif endif
ifeq ($(VERBOSE),0) ifeq ($(VERBOSE),0)
# this set of LDFLAGS generates no warnings. # this set of LDFLAGS generates no warnings.
LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults -w off
endif 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 CFLAGS = $(CFLAGS_1.2) -gccinc
ifeq ($(VERBOSE),0) ifeq ($(VERBOSE),0)

View File

@ -8,7 +8,7 @@
#include "CInputStream.hpp" #include "CInputStream.hpp"
class CStringTable { class CStringTable {
u32 x0_stringCount; s32 x0_stringCount;
rstl::single_ptr< u8 > x4_data; rstl::single_ptr< u8 > x4_data;
public: public:

View File

@ -19,7 +19,7 @@ typedef u32 CAssetId;
// bool operator==(const CAssetId& other) { return id == other.id; } // bool operator==(const CAssetId& other) { return id == other.id; }
// }; // };
#define FourCC unsigned long #define FourCC u32
struct SObjectTag { struct SObjectTag {
FourCC type; FourCC type;

View File

@ -599,7 +599,7 @@ KYOTO :=\
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinRules.o\ $(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinRules.o\
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCVirtualBone.o\ $(BUILD_DIR)/asm/Kyoto/Animation/DolphinCVirtualBone.o\
$(BUILD_DIR)/asm/Kyoto/Graphics/DolphinCModel.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/CEmitterElement.o\
$(BUILD_DIR)/asm/Kyoto/Particles/CEffectComponent.o\ $(BUILD_DIR)/asm/Kyoto/Particles/CEffectComponent.o\
$(BUILD_DIR)/asm/Kyoto/Particles/CParticleData.o\ $(BUILD_DIR)/asm/Kyoto/Particles/CParticleData.o\

View File

@ -13,9 +13,10 @@ CFactoryFnReturn FStringTableFactory(const SObjectTag& tag, CInputStream& in, co
template <> template <>
CFactoryFnReturn::CFactoryFnReturn(CStringTable* ptr) : obj(TToken< CStringTable >::GetIObjObjectFor(ptr).release()) {} 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 { const wchar_t* CStringTable::GetString(s32 idx) const {
if (idx < 0 || idx > x0_stringCount) { if (idx < 0 || idx >= x0_stringCount) {
return L"Invalid"; return skInvalidString;
} }
s32 offset = *(reinterpret_cast< const s32* >(x4_data.get()) + idx); s32 offset = *(reinterpret_cast< const s32* >(x4_data.get()) + idx);
return reinterpret_cast< const wchar_t* >(x4_data.get() + offset); 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(); in.ReadLong();
size_t langCount = in.Get< size_t >(); size_t langCount = in.Get< size_t >();
x0_stringCount = in.Get< u32 >(); 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) { 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; size_t offset = langOffsets.front().second;

View File

@ -1,7 +1,9 @@
#!/bin/bash -e #!/bin/bash -e
OBJDUMP="$DEVKITPPC/bin/powerpc-eabi-objdump -D -bbinary -EB -mpowerpc -M gekko" 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 baserom.dol > baserom.dump
$OBJDUMP $OPTIONS build/mp1.0/main.dol > main.dump $OBJDUMP $OPTIONS build/mp1.0/main.dol > main.dump
diff -u --color=always baserom.dump main.dump diff -u --color=always baserom.dump main.dump