From cdb1bbe92afb303143c8f4dc769869e0a90e4387 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 11 Apr 2022 22:54:36 -0700 Subject: [PATCH] Fix DynOS vertex offset writing --- data/dynos_bin_col.cpp | 4 ---- data/dynos_bin_gfx.cpp | 2 +- data/dynos_bin_lvl.cpp | 2 +- data/dynos_bin_movtexqc.cpp | 5 +++++ data/dynos_bin_pointer.cpp | 2 +- data/dynos_bin_utils.cpp | 1 - src/game/characters.c | 3 --- 7 files changed, 8 insertions(+), 11 deletions(-) diff --git a/data/dynos_bin_col.cpp b/data/dynos_bin_col.cpp index 0aa948af..9264dd7e 100644 --- a/data/dynos_bin_col.cpp +++ b/data/dynos_bin_col.cpp @@ -670,14 +670,10 @@ DataNode* DynOS_Col_LoadFromBinary(const SysPath &aPackFolder, const SysPath _Filename = fstring("%s/%s.col", aPackFolder.begin(), aCollisionName); FILE *_File = fopen(_Filename.c_str(), "rb"); if (_File) { - // backwards compatibility - //long prevPos = ftell(_File); u8 type = ReadBytes(_File); - //if (type != DATA_TYPE_COLLISION) { fseek(_File, prevPos, SEEK_SET); } if (type == DATA_TYPE_COLLISION) { collisionNode = DynOS_Col_Load(_File, NULL); } - // DO NOT COMMIT - figure out wtf is going on fclose(_File); } diff --git a/data/dynos_bin_gfx.cpp b/data/dynos_bin_gfx.cpp index 87c044e0..f3c34c61 100644 --- a/data/dynos_bin_gfx.cpp +++ b/data/dynos_bin_gfx.cpp @@ -394,7 +394,7 @@ static s64 ParseGfxSymbolArg(GfxData* aGfxData, DataNode* aNode, u64* pToke for (auto& _Node : aGfxData->mVertices) { if (_Arg == _Node->mName) { auto base = DynOS_Vtx_Parse(aGfxData, _Node)->mData; - auto data = base + _Offset; + auto data = (u8*)base + _Offset; if (_Offset != 0) { aGfxData->mPointerOffsetList.Add({ (const void*)data, (const void*)base }); } diff --git a/data/dynos_bin_lvl.cpp b/data/dynos_bin_lvl.cpp index 7e679c3a..633a39ca 100644 --- a/data/dynos_bin_lvl.cpp +++ b/data/dynos_bin_lvl.cpp @@ -1402,7 +1402,7 @@ static LevelScript ParseLevelScriptSymbolArgInternal(GfxData* aGfxData, DataNode for (auto& _Node : aGfxData->mLevelScripts) { if (_Arg == _Node->mName) { auto base = DynOS_Lvl_Parse(aGfxData, _Node, false)->mData; - auto data = base + _Offset; + auto data = (u8*)base + _Offset; if (_Offset != 0) { aGfxData->mPointerOffsetList.Add({ data, base }); } diff --git a/data/dynos_bin_movtexqc.cpp b/data/dynos_bin_movtexqc.cpp index cb60268f..be729d1f 100644 --- a/data/dynos_bin_movtexqc.cpp +++ b/data/dynos_bin_movtexqc.cpp @@ -16,6 +16,11 @@ extern "C" { static Movtex* ParseMovtexQCSymbolArg(GfxData* aGfxData, DataNode* aNode, u64 aTokenIndex) { const String& _Arg = aNode->mTokens[aTokenIndex]; + // Other constants + if (_Arg == "NULL") { + return (s64)0; + } + // Movtexs for (auto& _Node : aGfxData->mMovtexs) { if (_Arg == _Node->mName) { diff --git a/data/dynos_bin_pointer.cpp b/data/dynos_bin_pointer.cpp index bb854788..62965209 100644 --- a/data/dynos_bin_pointer.cpp +++ b/data/dynos_bin_pointer.cpp @@ -154,7 +154,7 @@ static PointerData GetDataFromPointer(const void* aPtr, GfxData* aGfxData) { s32 _Offset = 0; for (auto& pair : aGfxData->mPointerOffsetList) { if (pair.first == aPtr) { - _Offset = (s32)((const LevelScript*)pair.first - (const LevelScript*)pair.second); + _Offset = (s32)((u8*)pair.first - (u8*)pair.second); aPtr = pair.second; break; } diff --git a/data/dynos_bin_utils.cpp b/data/dynos_bin_utils.cpp index e6ae4838..ee18784b 100644 --- a/data/dynos_bin_utils.cpp +++ b/data/dynos_bin_utils.cpp @@ -347,6 +347,5 @@ s64 DynOS_RecursiveDescent_Parse(const char* expr, bool* success, RDConstantFunc s64 value = ParseExpression(); sRdString = NULL; *success = !sRdError; - //Print(">>> PARSING %s == %d :: %u", expr, value, *success); return value; } diff --git a/src/game/characters.c b/src/game/characters.c index 91aefda0..7cc61ca6 100644 --- a/src/game/characters.c +++ b/src/game/characters.c @@ -515,9 +515,6 @@ void update_character_anim_offset(struct MarioState* m) { if (m->curAnimOffset > 40) { m->curAnimOffset = 40; } if (m->curAnimOffset < -40) { m->curAnimOffset = -40; } - //s32 animID = marioObj->header.gfx.animInfo.animID; - //LOG_INFO(">>> [%d] : %d :: %f, %f", animID, sAnimTypes[animID], m->curAnimOffset, m->minimumBoneY); - marioObj->header.gfx.pos[1] = m->pos[1] + m->curAnimOffset; marioObj->header.gfx.node.flags |= GRAPH_RENDER_PLAYER; } \ No newline at end of file