//
// PlayerObject::flipGravity from 0x100403880 to 0x100403bf1 (881 bytes)
//
// 29 xrefs:
// > GJBaseGameLayer::teleportPlayer @ 0x100120d03
// > GJBaseGameLayer::setupLevelStart @ 0x1001237a8
// > GJBaseGameLayer::setupLevelStart @ 0x100123848
// > GJBaseGameLayer::flipGravity @ 0x1001248cc
// > GJBaseGameLayer::flipGravity @ 0x100124990
// > GJBaseGameLayer::playerWillSwitchMode @ 0x100124c3f
// > GJBaseGameLayer::gravBumpPlayer @ 0x100128510
// > GJBaseGameLayer::gravBumpPlayer @ 0x1001285c6
// > PlayerObject::updateJump @ 0x1003fe446
// > PlayerObject::updateJump @ 0x1003ffc92
// > PlayerObject::collidedWithObjectInternal @ 0x10040a0b8
// > PlayerObject::collidedWithObjectInternal @ 0x10040a57d
// > PlayerObject::didHitHead @ 0x10040d3b5
// > PlayerObject::hardFlipGravity @ 0x10040d5f8
// > PlayerObject::spiderTestJumpInternal @ 0x10040e25d
// > PlayerObject::spiderTestJumpX @ 0x10040f3c4
// > PlayerObject::spiderTestJumpY @ 0x100410265
// > PlayerObject::resetObject @ 0x1004123de
// > PlayerObject::rotateGameplay @ 0x10041254f
// > PlayerObject::ringJump @ 0x1004147a0
// > PlayerObject::ringJump @ 0x1004149c8
// > PlayerObject::ringJump @ 0x100414e69
// > PlayerObject::ringJump @ 0x10041505e
// > PlayerObject::bumpPlayer @ 0x10041ab65
// > PlayerObject::copyAttributes @ 0x10041b602
// > PlayerObject::spawnFromPlayer @ 0x10041b7b7
// > PlayerObject::spawnFromPlayer @ 0x10041b7ea
// > PlayerObject::loadFromCheckpoint @ 0x10041cd7a
// > MenuGameLayer::resetPlayer @ 0x1004fa4ff
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall PlayerObject::flipGravity(PlayerObject *a1, bool a2, bool a3)
{
__int64 v3; // rax
GameManager *v7; // rax
HardStreak *m_waveTrail; // r12
double *v9; // rax
cocos2d::CCPoint v10; // xmm0_8
GJBaseGameLayer *m_gameLayer; // rdi
int v12; // esi
__m128 v13; // rt1
float v14; // xmm0_4
float m_playerSpeed; // xmm1_4
double v16; // xmm1_8
int v17; // ecx
int v18; // eax
float v19; // xmm0_4
_QWORD v20[6]; // [rsp+0h] [rbp-30h] BYREF
v20[0] = v3;
if ( a1->m_isUpsideDown != a2 )
{
if ( !a1->m_maybeReducedEffects && a1->m_isDart && !a1->m_isLocked && a1->m_fadeOutStreak )
{
if ( !a1->m_playEffects || (v7 = GameManager::sharedState(), !GJBaseGameLayer::isFlipping(v7->m_playLayer)) )
{
m_waveTrail = a1->m_waveTrail;
v9 = (double *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
*(double *)&v10 = sub_10028CC60(v20, v9);
HardStreak::addPoint(m_waveTrail, v10);
}
}
a1->m_justPlacedStreak = 0;
a1->m_isUpsideDown = a2;
m_gameLayer = a1->m_gameLayer;
if ( m_gameLayer )
GJBaseGameLayer::gameEventTriggered(m_gameLayer, (GJGameEvent)(a2 ^ 0xB), 0, a1->m_uniqueID);
a1->m_lastFlipTime = a1->m_totalTime;
a1->m_unkA29 = 0;
*(_OWORD *)&a1->m_collidedTopMinY = 0;
if ( a1->m_wasOnSlope || a1->m_isOnSlope )
a1->m_slopeFlipGravityRelated ^= 1u;
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogTop);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogBottom);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogLeft);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogRight);
*(_OWORD *)&a1->m_lastCollisionBottom = -1;
*(_QWORD *)&a1->m_unk50C = -1;
if ( !a1->m_maybeReducedEffects )
{
a1->m_yVelocity = a1->m_yVelocity * 0.5;
if ( !a3 )
{
v12 = -27136;
if ( a2 )
v12 = 51455;
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B)v12, 45.0);
}
}
GJActionManager::stopInternalAction(a1->m_actionManager, 6);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleX)(a1, a1->m_vehicleSize);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleY)(a1, a1->m_vehicleSize);
PlayerObject::updatePlayerArt(a1);
if ( !a1->m_isBall
&& GameManager::sharedState()->m_playLayer
&& !GameManager::sharedState()->m_playLayer->m_freezeStartCamera
&& !a1->m_isDart
&& !a1->m_maybeReducedEffects )
{
a1->m_shouldTryPlacingCheckpoint = 1;
PlayerObject::activateStreak(a1);
}
sub_10028CC90(&a1->m_lastGroundedPos, (double *)&a1->m_lastPortalPos);
a1->m_isOnGround = 0;
if ( a1->m_isBall )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
if ( !a1->m_isDashing )
{
v13.i32[0] = LODWORD(a1->m_vehicleSize);
v14 = flt_10081B668[_mm_cvtsi128_si32((__m128i)_mm_cmpeq_ss((__m128)0x3F800000u, v13)) & 1];
m_playerSpeed = a1->m_playerSpeed;
if ( m_playerSpeed == 0.69999999 )
{
v16 = 1.240563750267029;
}
else if ( m_playerSpeed == 1.1 )
{
v16 = 0.8042434453964233;
}
else if ( m_playerSpeed == 1.3 )
{
v16 = 0.6657692790031433;
}
else if ( m_playerSpeed == 1.6 )
{
v16 = 0.5409374833106995;
}
else
{
v16 = 1.0;
}
v17 = -340;
if ( a1->m_isUpsideDown )
v17 = 340;
v18 = -v17;
if ( !a1->m_isGoingLeft )
v18 = v17;
v19 = (float)((float)v18 * a1->m_gravityMod) / (v14 * 0.8 * v16);
a1->m_rotationSpeed = v19;
a1->m_isBallRotating2 = 1;
}
}
else if ( a1->m_isSwing )
{
PlayerObject::updateSwingFire(a1);
}
}
}