//
// GJBaseGameLayer::toggleDualMode from 0x88a348 to 0x88a5d0 (648 bytes)
//
// 7 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x5e501c
// > LevelEditorLayer::onStopPlaytest @ 0x6628a8
// > GJBaseGameLayer::setupLevelStart @ 0x88a7b8
// > GJBaseGameLayer::resetLevelVariables @ 0x88b1b8
// > GJBaseGameLayer::collisionCheckObjects @ 0x88c048
// > GJBaseGameLayer::collisionCheckObjects @ 0x88c0ec
// > ??> @ 0x788e8
//
// 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 GJBaseGameLayer::toggleDualMode(GJBaseGameLayer *a1, GameObject *a2, bool a3, PlayerObject *a4, bool a5)
{
_BOOL4 v6; // w22
bool m_twoPlayerMode; // w4
PlayerObject *m_player1; // x0
PlayerObject *m_player2; // x1
int m_uniqueID; // w2
float *v13; // x22
GameObjectType ActiveMode; // w0
PlayerObject *v15; // x0
PlayerObject *v16; // x1
PlayerObject *v17; // x19
void (__fastcall *setRotation)(PlayerObject *__hidden, float); // x20
cocos2d::ccColor3B v19; // [xsp+38h] [xbp+38h]
v6 = a5;
if ( a1->m_gameState.m_isDualMode == a3 )
return;
a1->m_gameState.m_isDualMode = a3;
m_twoPlayerMode = 0;
if ( a3 )
m_twoPlayerMode = a1->m_levelSettings->m_twoPlayerMode;
UILayer::updateDualMode(a1->m_uiLayer, m_twoPlayerMode);
m_player1 = a1->m_player1;
m_player2 = a1->m_player2;
m_player1->m_unkA99 = a1->m_gameState.m_isDualMode;
m_player2->m_unkA99 = a1->m_gameState.m_isDualMode;
if ( !a1->m_gameState.m_isDualMode )
{
if ( m_player1->m_isDart )
{
if ( a4 )
{
m_uniqueID = a4->m_uniqueID;
if ( m_uniqueID == m_player1->m_uniqueID )
{
v13 = &a1->m_varianceValues.__elems_[1975];
if ( a1->m_isEditor )
goto LABEL_12;
goto LABEL_25;
}
}
PlayerObject::createFadeOutDartStreak(m_player1);
}
v13 = &a1->m_varianceValues.__elems_[1975];
if ( a1->m_isEditor )
{
if ( !a4 )
goto LABEL_13;
m_player2 = a1->m_player2;
m_uniqueID = a4->m_uniqueID;
LABEL_12:
if ( m_uniqueID != m_player2->m_uniqueID )
goto LABEL_13;
LABEL_28:
PlayerObject::copyAttributes(a1->m_player1);
GJBaseGameLayer::removePlayer2(a1);
if ( *((_BYTE *)v13 + 268) )
goto LABEL_14;
goto LABEL_29;
}
if ( !a4 )
{
LABEL_13:
GJBaseGameLayer::removePlayer2(a1);
if ( *((_BYTE *)v13 + 268) )
goto LABEL_14;
LABEL_29:
*(_WORD *)&v19.r = -256;
v19.b = 100;
PlayerObject::spawnPortalCircle(a1->m_player1, v19, 50.0);
LABEL_14:
a1->m_gameState.m_lastActivatedPortal2 = nullptr;
if ( a2 && a2->m_classType == Effect )
GJBaseGameLayer::updateCameraMode(a1, (EffectGameObject *)a2, 0);
ActiveMode = PlayerObject::getActiveMode(a1->m_player1);
GJBaseGameLayer::updateDualGround(a1, a4, ActiveMode, 0, 0.0);
v15 = a1->m_player1;
if ( v15->m_isDart && (!a4 || a4->m_uniqueID != v15->m_uniqueID) )
{
PlayerObject::resetStreak(v15);
PlayerObject::placeStreakPoint(a1->m_player1);
v16 = a1->m_player2;
if ( v16->m_isDart )
{
v17 = a1->m_player1;
setRotation = v17->setRotation;
v16->getRotation(v16);
((void (__fastcall *)(PlayerObject *))setRotation)(v17);
}
}
return;
}
m_uniqueID = a4->m_uniqueID;
m_player2 = a1->m_player2;
LABEL_25:
if ( m_player2->m_uniqueID == m_uniqueID )
m_player2 = a1->m_player1;
GJBaseGameLayer::playExitDualEffect(a1, m_player2);
if ( a4->m_uniqueID == a1->m_player2->m_uniqueID )
goto LABEL_28;
goto LABEL_13;
}
m_player2->resetObject(m_player2);
GJBaseGameLayer::spawnPlayer2(a1);
if ( a1->m_levelSettings->m_twoPlayerMode )
{
PlayerObject::releaseButton(a1->m_player2, Jump);
if ( !v6 )
{
LABEL_32:
if ( !a1->m_isEditor )
{
PlayerObject::spawnDualCircle(a1->m_player1);
PlayerObject::spawnDualCircle(a1->m_player2);
}
}
}
else if ( !v6 )
{
goto LABEL_32;
}
if ( a2 )
a1->m_gameState.m_lastActivatedPortal2 = a2;
GJBaseGameLayer::playerWillSwitchMode(a1, a4, a2);
}