From 1e32cd9ea031b2953922b34f2b4e570f3cd65c08 Mon Sep 17 00:00:00 2001 From: Eric Ohebshalom Date: Thu, 1 Oct 2026 21:51:13 -0400 Subject: [PATCH 1/3] Match MapdataJugemPoint::MapdataJugemPoint --- src/system/CourseMap.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ src/system/CourseMap.hpp | 12 +++++++---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/system/CourseMap.cpp b/src/system/CourseMap.cpp index 5785d969..e68be3a0 100644 --- a/src/system/CourseMap.cpp +++ b/src/system/CourseMap.cpp @@ -464,6 +464,50 @@ bool MapdataEnemyPoint::isNonPrivateBattle() { RaceConfig::Settings::GAMEMODE_PUBLIC_BATTLE); } +extern "C" void VEC3_fromNeg(EGG::Vector3f& out, const EGG::Vector3f& in); +void VEC3_fromQuaternionRotated(EGG::Vector3f& out, const EGG::Quatf& q, + const EGG::Vector3f& in); + +extern "C" EGG::Vector3f RKSystem_ex; +extern "C" EGG::Vector3f lbl_802A4148; + +MapdataJugemPoint::MapdataJugemPoint(const SData* data) { + mpData = data; + + f32 z = DEG2RAD(data->rotation.z); + f32 y = DEG2RAD(data->rotation.y); + f32 x = DEG2RAD(data->rotation.x); + mRotation.z = z; + mRotation.x = x; + mRotation.y = y; + + EGG::Quatf quat; + quat.setRPY(mRotation.x, mRotation.y, mRotation.z); + + EGG::Vector3f negZ; + VEC3_fromNeg(negZ, lbl_802A4148); + EGG::Vector3f forward; + VEC3_fromQuaternionRotated(forward, quat, negZ); + mForward = forward; + + EGG::Vector3f negX; + VEC3_fromNeg(negX, RKSystem_ex); + EGG::Vector3f tangent; + VEC3_fromQuaternionRotated(tangent, quat, negX); + mTangent = tangent; + + if (mpData->range < 0) { + _2a = -1; + _2c = 0; + } else { + _2a = mpData->range % 100; + if (_2a == 99) { + _2a = -1; + } + _2c = mpData->range / 100; + } +} + MapdataJugemPoint* CourseMap::getJugemPoint(u16 i) const { u16 count = mpJugemPoint ? mpJugemPoint->size() : 0; return i < count ? mpJugemPoint->get(i) : 0; diff --git a/src/system/CourseMap.hpp b/src/system/CourseMap.hpp index d02748fe..2bf5c8d2 100644 --- a/src/system/CourseMap.hpp +++ b/src/system/CourseMap.hpp @@ -316,11 +316,15 @@ class MapdataJugemPoint { }; MapdataJugemPoint(const SData* data); - virtual ~MapdataJugemPoint(); -private: - SData* mpData; - u8 _08[0x30 - 0x08]; + const SData* mpData; + EGG::Vector3f mRotation; + EGG::Vector3f mForward; + EGG::Vector3f mTangent; + u16 _28; + s16 _2a; + s16 _2c; + u8 _2e[2]; }; static_assert(sizeof(MapdataJugemPoint) == 0x30); From 04687e3a657cb8b22fb6c5877589c77aef3a3e6e Mon Sep 17 00:00:00 2001 From: Eric Ohebshalom Date: Fri, 2 Oct 2026 03:18:28 -0400 Subject: [PATCH 2/3] Use inline functions in MapdataJugemPoint::MapdataJugemPoint --- src/system/CourseMap.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/system/CourseMap.cpp b/src/system/CourseMap.cpp index e68be3a0..936c47f3 100644 --- a/src/system/CourseMap.cpp +++ b/src/system/CourseMap.cpp @@ -469,31 +469,33 @@ void VEC3_fromQuaternionRotated(EGG::Vector3f& out, const EGG::Quatf& q, const EGG::Vector3f& in); extern "C" EGG::Vector3f RKSystem_ex; -extern "C" EGG::Vector3f lbl_802A4148; +extern "C" EGG::Vector3f lbl_802A4148; // RKSystem_ez -MapdataJugemPoint::MapdataJugemPoint(const SData* data) { - mpData = data; +inline EGG::Vector3f operator-(const EGG::Vector3f& in) { + EGG::Vector3f out; + VEC3_fromNeg(out, in); + return out; +} - f32 z = DEG2RAD(data->rotation.z); - f32 y = DEG2RAD(data->rotation.y); - f32 x = DEG2RAD(data->rotation.x); - mRotation.z = z; - mRotation.x = x; - mRotation.y = y; +inline EGG::Vector3f rotateQuat(const EGG::Quatf& q, const EGG::Vector3f& v) { + EGG::Vector3f out; + VEC3_fromQuaternionRotated(out, q, v); + return out; +} +MapdataJugemPoint::MapdataJugemPoint(const SData* data) + : mpData(data), + mRotation(DEG2RAD(data->rotation.x), DEG2RAD(data->rotation.y), + DEG2RAD(data->rotation.z)) { EGG::Quatf quat; quat.setRPY(mRotation.x, mRotation.y, mRotation.z); - EGG::Vector3f negZ; - VEC3_fromNeg(negZ, lbl_802A4148); - EGG::Vector3f forward; - VEC3_fromQuaternionRotated(forward, quat, negZ); + EGG::Vector3f negZ = -lbl_802A4148; + EGG::Vector3f forward = rotateQuat(quat, negZ); mForward = forward; - EGG::Vector3f negX; - VEC3_fromNeg(negX, RKSystem_ex); - EGG::Vector3f tangent; - VEC3_fromQuaternionRotated(tangent, quat, negX); + EGG::Vector3f negX = -RKSystem_ex; + EGG::Vector3f tangent = rotateQuat(quat, negX); mTangent = tangent; if (mpData->range < 0) { From 95688b6b710c122cf50282db7e090ad9e042827e Mon Sep 17 00:00:00 2001 From: Eric Ohebshalom Date: Fri, 2 Oct 2026 04:26:55 -0400 Subject: [PATCH 3/3] Decompile MapdataJugemPoint::getPos and Vec3_fromScale --- config/RMCP01/module/symbols.txt | 2 +- src/system/CourseMap.cpp | 59 ++++++++++++++++++++++++++++++++ src/system/CourseMap.hpp | 4 ++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/config/RMCP01/module/symbols.txt b/config/RMCP01/module/symbols.txt index ec6212fa..48953556 100644 --- a/config/RMCP01/module/symbols.txt +++ b/config/RMCP01/module/symbols.txt @@ -141,7 +141,7 @@ fn_1_7F90 = .text:0x80518344; // type:function size:0x64 __ct__Q26System17MapdataJugemPointFPCQ36System17MapdataJugemPoint5SData = .text:0x805183A8; // type:function size:0x154 scope:global align:4 fn_1_8148 = .text:0x805184FC; // type:function size:0x424 getJugemPoint__Q26System9CourseMapCFUs = .text:0x80518920; // type:function size:0x4C scope:global align:4 -fn_1_85B8 = .text:0x8051896C; // type:function size:0x14C +getPos__Q26System17MapdataJugemPointCFPQ23EGG8Vector3fUl = .text:0x8051896C; // type:function size:0x14C scope:global align:4 Vec3_fromScale = .text:0x80518AB8; // type:function size:0x28 scope:global align:4 getCannonPoint__Q26System9CourseMapCFUs = .text:0x80518AE0; // type:function size:0x4C scope:global align:4 getMissionPoint__Q26System9CourseMapCFUs = .text:0x80518B2C; // type:function size:0x4C scope:global align:4 diff --git a/src/system/CourseMap.cpp b/src/system/CourseMap.cpp index 936c47f3..853f9721 100644 --- a/src/system/CourseMap.cpp +++ b/src/system/CourseMap.cpp @@ -467,6 +467,8 @@ bool MapdataEnemyPoint::isNonPrivateBattle() { extern "C" void VEC3_fromNeg(EGG::Vector3f& out, const EGG::Vector3f& in); void VEC3_fromQuaternionRotated(EGG::Vector3f& out, const EGG::Quatf& q, const EGG::Vector3f& in); +extern "C" void Vec3_add(EGG::Vector3f* out, const EGG::Vector3f* a, const EGG::Vector3f* b); +extern "C" void Vec3_fromScale(EGG::Vector3f* out, const EGG::Vector3f* in, f32 scale); extern "C" EGG::Vector3f RKSystem_ex; extern "C" EGG::Vector3f lbl_802A4148; // RKSystem_ez @@ -515,6 +517,63 @@ MapdataJugemPoint* CourseMap::getJugemPoint(u16 i) const { return i < count ? mpJugemPoint->get(i) : 0; } +void MapdataJugemPoint::getPos(EGG::Vector3f* pos, u32 playerIdx) const { + s32 gameMode = RaceConfig::spInstance->mRaceScenario.mSettings.mGameMode; + if (gameMode == RaceConfig::Settings::GAMEMODE_TIME_TRIAL || + gameMode == RaceConfig::Settings::GAMEMODE_GHOST_RACE) { + playerIdx = 0xff; + } + + if (playerIdx != 0xff) { + static const struct { + s8 tangent; + s8 forward; + } sOffsets[12] = { + {-1, 0}, { 1, 0}, {-3, 0}, { 3, 0}, + {-1, 1}, { 1, 1}, {-3, 1}, { 3, 1}, + {-1, 2}, { 1, 2}, {-3, 2}, { 3, 2}, + }; + + u8 idx = playerIdx; + EGG::Vector3f local_2c; + EGG::Vector3f t; + EGG::Vector3f f; + EGG::Vector3f offset; + Vec3_fromScale(&t, &mTangent, (f32)sOffsets[idx].tangent * 150.0f); + Vec3_fromScale(&f, &mForward, (f32)sOffsets[idx].forward * 300.0f); + Vec3_add(&offset, &t, &f); + local_2c = offset; + + f32 z = mpData->position.z + local_2c.z; + f32 y = mpData->position.y + local_2c.y; + f32 x = mpData->position.x + local_2c.x; + pos->x = x; + pos->y = y; + pos->z = z; + } else { + f32 x; + f32 y; + f32 z; + z = mpData->position.z; + y = mpData->position.y; + x = mpData->position.x; + pos->x = x; + pos->y = y; + pos->z = z; + } +} + +#pragma dont_inline on +extern "C" void Vec3_fromScale(EGG::Vector3f* out, const EGG::Vector3f* in, f32 scale) { + f32 z = in->z * scale; + f32 y = in->y * scale; + f32 x = in->x * scale; + out->z = z; + out->x = x; + out->y = y; +} +#pragma dont_inline off + MapdataCannonPoint* CourseMap::getCannonPoint(u16 i) const { u16 count = mpCannonPoint ? mpCannonPoint->size() : 0; return i < count ? mpCannonPoint->get(i) : 0; diff --git a/src/system/CourseMap.hpp b/src/system/CourseMap.hpp index 2bf5c8d2..a6d1f36f 100644 --- a/src/system/CourseMap.hpp +++ b/src/system/CourseMap.hpp @@ -316,12 +316,14 @@ class MapdataJugemPoint { }; MapdataJugemPoint(const SData* data); + void getPos(EGG::Vector3f* pos, u32 playerIdx) const; const SData* mpData; EGG::Vector3f mRotation; EGG::Vector3f mForward; EGG::Vector3f mTangent; - u16 _28; + u8 enemyPoint; + u8 itemPoint; s16 _2a; s16 _2c; u8 _2e[2];