Fix DynOS vertex offset writing

This commit is contained in:
MysterD 2022-04-11 22:54:36 -07:00
parent e037e3b65e
commit cdb1bbe92a
7 changed files with 8 additions and 11 deletions

View File

@ -670,14 +670,10 @@ DataNode<Collision>* DynOS_Col_LoadFromBinary(const SysPath &aPackFolder, const
SysPath _Filename = fstring("%s/%s.col", aPackFolder.begin(), aCollisionName); SysPath _Filename = fstring("%s/%s.col", aPackFolder.begin(), aCollisionName);
FILE *_File = fopen(_Filename.c_str(), "rb"); FILE *_File = fopen(_Filename.c_str(), "rb");
if (_File) { if (_File) {
// backwards compatibility
//long prevPos = ftell(_File);
u8 type = ReadBytes<u8>(_File); u8 type = ReadBytes<u8>(_File);
//if (type != DATA_TYPE_COLLISION) { fseek(_File, prevPos, SEEK_SET); }
if (type == DATA_TYPE_COLLISION) { if (type == DATA_TYPE_COLLISION) {
collisionNode = DynOS_Col_Load(_File, NULL); collisionNode = DynOS_Col_Load(_File, NULL);
} }
// DO NOT COMMIT - figure out wtf is going on
fclose(_File); fclose(_File);
} }

View File

@ -394,7 +394,7 @@ static s64 ParseGfxSymbolArg(GfxData* aGfxData, DataNode<Gfx>* aNode, u64* pToke
for (auto& _Node : aGfxData->mVertices) { for (auto& _Node : aGfxData->mVertices) {
if (_Arg == _Node->mName) { if (_Arg == _Node->mName) {
auto base = DynOS_Vtx_Parse(aGfxData, _Node)->mData; auto base = DynOS_Vtx_Parse(aGfxData, _Node)->mData;
auto data = base + _Offset; auto data = (u8*)base + _Offset;
if (_Offset != 0) { if (_Offset != 0) {
aGfxData->mPointerOffsetList.Add({ (const void*)data, (const void*)base }); aGfxData->mPointerOffsetList.Add({ (const void*)data, (const void*)base });
} }

View File

@ -1402,7 +1402,7 @@ static LevelScript ParseLevelScriptSymbolArgInternal(GfxData* aGfxData, DataNode
for (auto& _Node : aGfxData->mLevelScripts) { for (auto& _Node : aGfxData->mLevelScripts) {
if (_Arg == _Node->mName) { if (_Arg == _Node->mName) {
auto base = DynOS_Lvl_Parse(aGfxData, _Node, false)->mData; auto base = DynOS_Lvl_Parse(aGfxData, _Node, false)->mData;
auto data = base + _Offset; auto data = (u8*)base + _Offset;
if (_Offset != 0) { if (_Offset != 0) {
aGfxData->mPointerOffsetList.Add({ data, base }); aGfxData->mPointerOffsetList.Add({ data, base });
} }

View File

@ -16,6 +16,11 @@ extern "C" {
static Movtex* ParseMovtexQCSymbolArg(GfxData* aGfxData, DataNode<MovtexQC>* aNode, u64 aTokenIndex) { static Movtex* ParseMovtexQCSymbolArg(GfxData* aGfxData, DataNode<MovtexQC>* aNode, u64 aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex]; const String& _Arg = aNode->mTokens[aTokenIndex];
// Other constants
if (_Arg == "NULL") {
return (s64)0;
}
// Movtexs // Movtexs
for (auto& _Node : aGfxData->mMovtexs) { for (auto& _Node : aGfxData->mMovtexs) {
if (_Arg == _Node->mName) { if (_Arg == _Node->mName) {

View File

@ -154,7 +154,7 @@ static PointerData GetDataFromPointer(const void* aPtr, GfxData* aGfxData) {
s32 _Offset = 0; s32 _Offset = 0;
for (auto& pair : aGfxData->mPointerOffsetList) { for (auto& pair : aGfxData->mPointerOffsetList) {
if (pair.first == aPtr) { 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; aPtr = pair.second;
break; break;
} }

View File

@ -347,6 +347,5 @@ s64 DynOS_RecursiveDescent_Parse(const char* expr, bool* success, RDConstantFunc
s64 value = ParseExpression(); s64 value = ParseExpression();
sRdString = NULL; sRdString = NULL;
*success = !sRdError; *success = !sRdError;
//Print(">>> PARSING %s == %d :: %u", expr, value, *success);
return value; return value;
} }

View File

@ -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; }
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.pos[1] = m->pos[1] + m->curAnimOffset;
marioObj->header.gfx.node.flags |= GRAPH_RENDER_PLAYER; marioObj->header.gfx.node.flags |= GRAPH_RENDER_PLAYER;
} }