diff --git a/config/RSBE01_02/rels/sora_melee/symbols.txt b/config/RSBE01_02/rels/sora_melee/symbols.txt index 3360bda..403a927 100644 --- a/config/RSBE01_02/rels/sora_melee/symbols.txt +++ b/config/RSBE01_02/rels/sora_melee/symbols.txt @@ -19929,7 +19929,7 @@ entryLocalData__5StageFv = .text:0x0022259C; // type:function size:0x8 removeLocalData__5StageFv = .text:0x002225A4; // type:function size:0x4 createObj__5StageFv = .text:0x002225A8; // type:function size:0x4 initPosPokeTrainer__5StageFii = .text:0x002225AC; // type:function size:0xF0 -createObjPokeTrainer__5StageFP9gfArchiveiPCcP5Vec3fi = .text:0x0022269C; // type:function size:0xF8 +createObjPokeTrainer__5StageFP9gfArchiveiPCcP5Vec3fP5Vec3f = .text:0x0022269C; // type:function size:0xF8 setStageData__6GroundFPv = .text:0x00222794; // type:function size:0x8 fn_27_22279C = .text:0x0022279C; // type:function size:0x8 fn_27_2227A4 = .text:0x002227A4; // type:function size:0x8 @@ -19997,7 +19997,7 @@ isDevil__5StageFv = .text:0x002247D8; // type:function size:0x8 setDevilScrool__5StageFff = .text:0x002247E0; // type:function size:0x7C getLucarioFinalTechniquePosition__5StageFP5Vec3f = .text:0x0022485C; // type:function size:0x20 isEnd__5StageFv = .text:0x0022487C; // type:function size:0x8 -isEventEnd__5StageFv = .text:0x00224884; // type:function size:0x8 +isEventEnd__5StageFiPiPi = .text:0x00224884; // type:function size:0x8 getFinalTechniqColor__5StageFv = .text:0x0022488C; // type:function size:0xC setMotionRatio__5StageFff = .text:0x00224898; // type:function size:0x58 saveMotionRatio__5StageFi = .text:0x002248F0; // type:function size:0x24 diff --git a/config/RSBE01_02/splits.txt b/config/RSBE01_02/splits.txt index f1b8153..b593beb 100644 --- a/config/RSBE01_02/splits.txt +++ b/config/RSBE01_02/splits.txt @@ -203,12 +203,19 @@ sora/if/if_stgedit.cpp: .sdata start:0x8059E690 end:0x8059E6A0 .sdata2 start:0x805A28C8 end:0x805A28E8 +sora/gr/collision/gr_collision_shape.cpp: + .sdata2 start:0x805A2A20 end:0x805A2A2C + sora/gr/collision/gr_collision_data.cpp: .text start:0x80110720 end:0x80110748 sora/gr/collision/gr_collision_handle.cpp: .text start:0x801122E4 end:0x8011234C +sora/gr/collision/gr_collision_shape_rhombus.cpp: + .text start:0x80132B64 end:0x801330B8 + .data start:0x8045DA88 end:0x8045DAEC + sora/gr/gr_path.cpp: .text start:0x80139570 end:0x80139658 diff --git a/config/RSBE01_02/symbols.txt b/config/RSBE01_02/symbols.txt index 5d73338..fc26ec0 100644 --- a/config/RSBE01_02/symbols.txt +++ b/config/RSBE01_02/symbols.txt @@ -2965,7 +2965,7 @@ fn_800429C8 = .text:0x800429C8; // type:function size:0x2AC fn_80042C74 = .text:0x80042C74; // type:function size:0x340 fn_80042FB4 = .text:0x80042FB4; // type:function size:0x51C fn_800434D0 = .text:0x800434D0; // type:function size:0x3C -fn_8004350C = .text:0x8004350C; // type:function size:0xDC +move__11clRhombus2DFRC5Vec2f = .text:0x8004350C; // type:function size:0xDC fn_800435E8 = .text:0x800435E8; // type:function size:0x100 fn_800436E8 = .text:0x800436E8; // type:function size:0xF4 fn_800437DC = .text:0x800437DC; // type:function size:0xBC @@ -5827,29 +5827,29 @@ fn_80132240 = .text:0x80132240; // type:function size:0x224 fn_80132464 = .text:0x80132464; // type:function size:0x4 fn_80132468 = .text:0x80132468; // type:function size:0x4D0 fn_80132938 = .text:0x80132938; // type:function size:0x22C -fn_80132B64 = .text:0x80132B64; // type:function size:0x40 -fn_80132BA4 = .text:0x80132BA4; // type:function size:0x74 -fn_80132C18 = .text:0x80132C18; // type:function size:0x8 -fn_80132C20 = .text:0x80132C20; // type:function size:0x70 -fn_80132C90 = .text:0x80132C90; // type:function size:0x70 -fn_80132D00 = .text:0x80132D00; // type:function size:0x70 -fn_80132D70 = .text:0x80132D70; // type:function size:0x70 -fn_80132DE0 = .text:0x80132DE0; // type:function size:0x70 -fn_80132E50 = .text:0x80132E50; // type:function size:0x40 -fn_80132E90 = .text:0x80132E90; // type:function size:0x78 -fn_80132F08 = .text:0x80132F08; // type:function size:0x40 -fn_80132F48 = .text:0x80132F48; // type:function size:0x14 -fn_80132F5C = .text:0x80132F5C; // type:function size:0x4 -fn_80132F60 = .text:0x80132F60; // type:function size:0x70 -fn_80132FD0 = .text:0x80132FD0; // type:function size:0x10 -fn_80132FE0 = .text:0x80132FE0; // type:function size:0x10 -fn_80132FF0 = .text:0x80132FF0; // type:function size:0x10 -fn_80133000 = .text:0x80133000; // type:function size:0x10 -fn_80133010 = .text:0x80133010; // type:function size:0x10 -fn_80133020 = .text:0x80133020; // type:function size:0x10 -fn_80133030 = .text:0x80133030; // type:function size:0x10 -fn_80133040 = .text:0x80133040; // type:function size:0x70 -fn_801330B0 = .text:0x801330B0; // type:function size:0x8 +init__18grCollShapeRhombusFv = .text:0x80132B64; // type:function size:0x40 +set__18grCollShapeRhombusFR11grCollShape = .text:0x80132BA4; // type:function size:0x74 +move__18grCollShapeRhombusFRC5Vec2f = .text:0x80132C18; // type:function size:0x8 +setDownPos__18grCollShapeRhombusFRC5Vec2f = .text:0x80132C20; // type:function size:0x70 +setRightPos__18grCollShapeRhombusFRC5Vec2f = .text:0x80132C90; // type:function size:0x70 +setLeftPos__18grCollShapeRhombusFRC5Vec2f = .text:0x80132D00; // type:function size:0x70 +setCenterPos__18grCollShapeRhombusFRC5Vec2f = .text:0x80132D70; // type:function size:0x70 +setTopPos__18grCollShapeRhombusFRC5Vec2f = .text:0x80132DE0; // type:function size:0x70 +setLR__18grCollShapeRhombusFRC5Vec2fRC5Vec2fRC5Vec2f = .text:0x80132E50; // type:function size:0x40 +setLR__18grCollShapeRhombusFRC5Vec2fRC5Vec2f = .text:0x80132E90; // type:function size:0x78 +setUD__18grCollShapeRhombusFRC5Vec2fRC5Vec2fRC5Vec2f = .text:0x80132F08; // type:function size:0x40 +modifyDownY__18grCollShapeRhombusFf = .text:0x80132F48; // type:function size:0x14 +test__18grCollShapeRhombusFv = .text:0x80132F5C; // type:function size:0x4 +updateAABBox__18grCollShapeRhombusFv = .text:0x80132F60; // type:function size:0x70 +getWidth__18grCollShapeRhombusCFv = .text:0x80132FD0; // type:function size:0x10 +getHeight__18grCollShapeRhombusCFv = .text:0x80132FE0; // type:function size:0x10 +getTopPos__18grCollShapeRhombusCFv = .text:0x80132FF0; // type:function size:0x10 +getRightPos__18grCollShapeRhombusCFv = .text:0x80133000; // type:function size:0x10 +getLeftPos__18grCollShapeRhombusCFv = .text:0x80133010; // type:function size:0x10 +getDownPos__18grCollShapeRhombusCFv = .text:0x80133020; // type:function size:0x10 +getCenterPos__18grCollShapeRhombusCFv = .text:0x80133030; // type:function size:0x10 +getAABBox__18grCollShapeRhombusFR10clAABBox2D = .text:0x80133040; // type:function size:0x70 +getType__18grCollShapeRhombusCFv = .text:0x801330B0; // type:function size:0x8 fn_801330B8 = .text:0x801330B8; // type:function size:0x14 fn_801330CC = .text:0x801330CC; // type:function size:0x1C fn_801330E8 = .text:0x801330E8; // type:function size:0x34 @@ -26053,9 +26053,9 @@ lbl_8045D9D0 = .data:0x8045D9D0; // type:object size:0x10 lbl_8045D9E0 = .data:0x8045D9E0; // type:object size:0x38 lbl_8045DA18 = .data:0x8045DA18; // type:object size:0x38 lbl_8045DA50 = .data:0x8045DA50; // type:object size:0x38 -lbl_8045DA88 = .data:0x8045DA88; // type:object size:0x68 -lbl_8045DAF0 = .data:0x8045DAF0; // type:object size:0x68 -lbl_8045DB58 = .data:0x8045DB58; // type:object size:0x20 +__vt__18grCollShapeRhombus = .data:0x8045DA88; // type:object size:0x64 +lbl_8045DAF0 = .data:0x8045DAF0; // type:object size:0x64 align:8 +lbl_8045DB58 = .data:0x8045DB58; // type:object size:0x20 align:8 jumptable_8045DB78 = .data:0x8045DB78; // type:object size:0x20 scope:local jumptable_8045DB98 = .data:0x8045DB98; // type:object size:0x20 scope:local lbl_8045DBB8 = .data:0x8045DBB8; // type:object size:0x184 @@ -32883,9 +32883,9 @@ lbl_805A2A0C = .sdata2:0x805A2A0C; // type:object size:0x4 align:4 data:float lbl_805A2A10 = .sdata2:0x805A2A10; // type:object size:0x4 align:4 data:float lbl_805A2A14 = .sdata2:0x805A2A14; // type:object size:0x4 align:4 data:float lbl_805A2A18 = .sdata2:0x805A2A18; // type:object size:0x8 align:4 data:float -lbl_805A2A20 = .sdata2:0x805A2A20; // type:object size:0x4 align:4 data:float -lbl_805A2A24 = .sdata2:0x805A2A24; // type:object size:0x4 align:4 data:float -lbl_805A2A28 = .sdata2:0x805A2A28; // type:object size:0x8 align:4 data:float +gUnk805a2a20__11grCollShape = .sdata2:0x805A2A20; // type:object size:0x4 align:4 data:float +gUnk805a2a24__11grCollShape = .sdata2:0x805A2A24; // type:object size:0x4 align:4 data:float +gUnk805a2a28__11grCollShape = .sdata2:0x805A2A28; // type:object size:0x4 align:4 data:float lbl_805A2A30 = .sdata2:0x805A2A30; // type:object size:0x4 align:4 data:float lbl_805A2A34 = .sdata2:0x805A2A34; // type:object size:0x4 align:4 data:float lbl_805A2A38 = .sdata2:0x805A2A38; // type:object size:0x8 align:4 data:float diff --git a/configure.py b/configure.py index 6117f09..a638ef0 100755 --- a/configure.py +++ b/configure.py @@ -332,8 +332,10 @@ def MatchingFor(*versions): Object(Matching, "sora/if/if_wifipr_task.cpp"), Object(Matching, "sora/if/if_adv_task.cpp"), Object(Matching, "sora/if/if_stgedit.cpp"), + Object(Matching, "sora/gr/collision/gr_collision_shape.cpp"), Object(Matching, "sora/gr/collision/gr_collision_data.cpp"), Object(Matching, "sora/gr/collision/gr_collision_handle.cpp"), + Object(Matching, "sora/gr/collision/gr_collision_shape_rhombus.cpp", extra_cflags=["-RTTI off"]), Object(Matching, "sora/gr/gr_path.cpp"), Object(NonMatching, "sora/ac/ac_cmd_interpreter.cpp"), Object(Matching, "sora/ac/ac_anim_cmd_impl.cpp"), diff --git a/include/lib/BrawlHeaders b/include/lib/BrawlHeaders index 8675125..553b4d5 160000 --- a/include/lib/BrawlHeaders +++ b/include/lib/BrawlHeaders @@ -1 +1 @@ -Subproject commit 86751254e622c81382ccac62083d475e3a6f763e +Subproject commit 553b4d59735e082a9ff5602661bad0311782b066 diff --git a/src/sora/gr/collision/gr_collision_data.cpp b/src/sora/gr/collision/gr_collision_data.cpp index 47014a9..ded8062 100644 --- a/src/sora/gr/collision/gr_collision_data.cpp +++ b/src/sora/gr/collision/gr_collision_data.cpp @@ -1,8 +1,7 @@ #include const char* grCollData::getJointNodeName(u32 nodeIndex) { - if (nodeIndex >= m_vtxLen) { - return 0; - } + if (nodeIndex >= m_vtxLen) + return nullptr; return m_jointDatas[nodeIndex].m_name; } diff --git a/src/sora/gr/collision/gr_collision_shape.cpp b/src/sora/gr/collision/gr_collision_shape.cpp new file mode 100644 index 0000000..7e91b49 --- /dev/null +++ b/src/sora/gr/collision/gr_collision_shape.cpp @@ -0,0 +1,5 @@ +#include + +const float grCollShape::gUnk805a2a20 = 0.01f; +const float grCollShape::gUnk805a2a24 = 0.0f; +const float grCollShape::gUnk805a2a28 = 0.01f; diff --git a/src/sora/gr/collision/gr_collision_shape_rhombus.cpp b/src/sora/gr/collision/gr_collision_shape_rhombus.cpp new file mode 100644 index 0000000..6b8a52e --- /dev/null +++ b/src/sora/gr/collision/gr_collision_shape_rhombus.cpp @@ -0,0 +1,209 @@ +#include +#include +#include + +void grCollShapeRhombus::init() { + m_rhombus.m_centerPos.m_x = gUnk805a2a24; + m_rhombus.m_centerPos.m_y = gUnk805a2a24; + + m_rhombus.m_upPos.m_x = gUnk805a2a24; + m_rhombus.m_upPos.m_y = gUnk805a2a24; + + m_rhombus.m_downPos.m_x = gUnk805a2a24; + m_rhombus.m_downPos.m_y = gUnk805a2a24; + + m_rhombus.m_leftPos.m_x = gUnk805a2a24; + m_rhombus.m_leftPos.m_y = gUnk805a2a24; + + m_rhombus.m_rightPos.m_x = gUnk805a2a24; + m_rhombus.m_rightPos.m_y = gUnk805a2a24; + + m_rhombus.m_aabBox.m_unk1 = gUnk805a2a24; + m_rhombus.m_aabBox.m_unk2 = gUnk805a2a24; + m_rhombus.m_aabBox.m_unk3 = gUnk805a2a24; + m_rhombus.m_aabBox.m_unk4 = gUnk805a2a24; +} + +void grCollShapeRhombus::set(grCollShape& orig) { + m_rhombus = static_cast(orig).m_rhombus; +} + +void grCollShapeRhombus::move(const Vec2f& displacement) { + m_rhombus.move(displacement); +} + +void grCollShapeRhombus::setDownPos(const Vec2f& downPos) { + Vec2f newDownPos(downPos.m_x, gUnk805a2a28 + downPos.m_y); + Vec2f disp; + Vec2f::copy(disp, newDownPos - m_rhombus.m_downPos); + m_rhombus.move(disp); +} + +void grCollShapeRhombus::setRightPos(const Vec2f& rightPos) { + Vec2f newRightPos(rightPos.m_x - gUnk805a2a28, rightPos.m_y); + Vec2f disp; + Vec2f::copy(disp, newRightPos - m_rhombus.m_rightPos); + m_rhombus.move(disp); +} + +void grCollShapeRhombus::setLeftPos(const Vec2f& leftPos) { + Vec2f newLeftPos(gUnk805a2a28 + leftPos.m_x, leftPos.m_y); + Vec2f disp; + Vec2f::copy(disp, newLeftPos - m_rhombus.m_leftPos); + m_rhombus.move(disp); +} + +void grCollShapeRhombus::setCenterPos(const Vec2f& centerPos) { + Vec2f newCenterPos(centerPos.m_x, centerPos.m_y - gUnk805a2a28); + Vec2f disp; + Vec2f::copy(disp, newCenterPos - m_rhombus.m_centerPos); + m_rhombus.move(disp); +} + +void grCollShapeRhombus::setTopPos(const Vec2f& topPos) { + Vec2f newTopPos(topPos.m_x, topPos.m_y - gUnk805a2a28); + Vec2f disp; + Vec2f::copy(disp, newTopPos - m_rhombus.m_upPos); + m_rhombus.move(disp); +} + +void grCollShapeRhombus::setLR(const Vec2f& centerPos, const Vec2f& left, const Vec2f& right) { + m_rhombus.m_centerPos.m_x = centerPos.m_x; + m_rhombus.m_centerPos.m_y = centerPos.m_y; + + m_rhombus.m_leftPos.m_x = gUnk805a2a28 + left.m_x; + m_rhombus.m_leftPos.m_y = centerPos.m_y; + + m_rhombus.m_rightPos.m_x = right.m_x - gUnk805a2a28; + m_rhombus.m_rightPos.m_y = centerPos.m_y; + + m_rhombus.m_upPos.m_x = centerPos.m_x; + m_rhombus.m_downPos.m_x = centerPos.m_x; +} + +void grCollShapeRhombus::setLR(const Vec2f& left, const Vec2f& right) { + const float dx = m_rhombus.m_rightPos.m_x - m_rhombus.m_leftPos.m_x; + float frac = fabs(m_rhombus.m_centerPos.m_x - m_rhombus.m_leftPos.m_x); + frac /= dx; + const float f0 = frac * (right.m_x - left.m_x); + + Vec2f center; + center.m_x = left.m_x + f0; + center.m_y = m_rhombus.m_centerPos.m_y; + setLR(center, left, right); +} + +void grCollShapeRhombus::setUD(const Vec2f& centerPos, const Vec2f& up, const Vec2f& down) { + m_rhombus.m_centerPos.m_x = centerPos.m_x; + m_rhombus.m_centerPos.m_y = centerPos.m_y; + + m_rhombus.m_upPos.m_x = centerPos.m_x; + m_rhombus.m_upPos.m_y = up.m_y - gUnk805a2a28; + + m_rhombus.m_downPos.m_x = centerPos.m_x; + m_rhombus.m_downPos.m_y = gUnk805a2a28 + down.m_y; + + m_rhombus.m_rightPos.m_y = centerPos.m_y; + m_rhombus.m_leftPos.m_y = centerPos.m_y; +} + +void grCollShapeRhombus::modifyDownY(float downY) { + if (m_rhombus.m_centerPos.m_y > downY) + m_rhombus.m_downPos.m_y = downY; +} + +void grCollShapeRhombus::test() { } + +#ifdef MATCHING +// These functions may have had some debugging purpose at one point, +// but they amount to no-ops in the release build and are only included +// to match the binary. +static inline int isFinite(float f) { + int res = 1; + u32 i; + __memcpy(&i, &f, 4); + if ((i >> 23 & 0xFF) == 0xFF) + res = 0; + return res; +} + +static inline void checkFinite(float lx, const clAABBox2D& aabBox) { + if (isFinite((lx))) { + // The argument passed here (and below) doesn't matter + static_cast(isFinite(0)); + } + if (isFinite((aabBox.m_unk3))) { + static_cast(isFinite(0)); + } +} +#endif + +void grCollShapeRhombus::updateAABBox() { + float upY, rightX, downY, leftX; + + leftX = m_rhombus.m_leftPos.m_x; + downY = m_rhombus.m_downPos.m_y; + upY = m_rhombus.m_upPos.m_y; + rightX = m_rhombus.m_rightPos.m_x; + + m_rhombus.m_aabBox.m_unk1 = leftX; + m_rhombus.m_aabBox.m_unk2 = downY; + m_rhombus.m_aabBox.m_unk3 = rightX; + m_rhombus.m_aabBox.m_unk4 = upY; + +#ifdef MATCHING + // Effectively dead code + checkFinite(m_rhombus.m_leftPos.m_x, m_rhombus.m_aabBox); +#endif +} + +float grCollShapeRhombus::getWidth() const { + return m_rhombus.m_rightPos.m_x - m_rhombus.m_leftPos.m_x; +} + +float grCollShapeRhombus::getHeight() const { + return m_rhombus.m_upPos.m_y - m_rhombus.m_downPos.m_y; +} + +Vec2f grCollShapeRhombus::getTopPos() const { + return m_rhombus.m_upPos; +} + +Vec2f grCollShapeRhombus::getRightPos() const { + return m_rhombus.m_rightPos; +} + +Vec2f grCollShapeRhombus::getLeftPos() const { + return m_rhombus.m_leftPos; +} + +Vec2f grCollShapeRhombus::getDownPos() const { + return m_rhombus.m_downPos; +} + +Vec2f grCollShapeRhombus::getCenterPos() const { + return m_rhombus.m_centerPos; +} + +void grCollShapeRhombus::getAABBox(clAABBox2D& aabBox) { + float downY, leftX, upY, rightX; + + leftX = m_rhombus.m_leftPos.m_x; + downY = m_rhombus.m_downPos.m_y; + aabBox.m_unk1 = leftX; + aabBox.m_unk2 = downY; + + upY = m_rhombus.m_upPos.m_y; + rightX = m_rhombus.m_rightPos.m_x; + aabBox.m_unk3 = rightX; + aabBox.m_unk4 = upY; + +#ifdef MATCHING + // Effectively dead code + checkFinite(leftX, aabBox); +#endif +} + +int grCollShapeRhombus::getType() const { + return 2; +}