//
// GJBaseGameLayer::toggleDualMode from 0x5b9040 to 0x5b91fa (442 bytes)
//
// 6 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x4119c8
// > LevelEditorLayer::onStopPlaytest @ 0x462a24
// > GJBaseGameLayer::resetLevelVariables @ 0x5b9a30
// > GJBaseGameLayer::setupLevelStart @ 0x5b9e6a
// > GJBaseGameLayer::collisionCheckObjects @ 0x5ba830
// > GJBaseGameLayer::collisionCheckObjects @ 0x5ba894
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:53:40 +0000
//
int __fastcall GJBaseGameLayer::toggleDualMode(int this, GameObject *a2, int a3, PlayerObject *a4, bool a5)
{
int v6; // r4
bool *v8; // r0
int v9; // r1
int v10; // r1
int v11; // r2
int v12; // r1
int v13; // r2
int v14; // r1
int v15; // r2
bool v16; // r3
int v17; // r0
PlayerObject *v18; // r1
PlayerObject *v19; // r1
int ActiveMode; // r0
int v21; // r1
int v22; // r2
int v23; // r3
int v24; // r4
int (__fastcall *v25)(int, int); // r5
int v26; // r0
int v27; // [sp+Ch] [bp-8h]
v6 = this;
if ( *(unsigned __int8 *)(this + 866) == a3 )
return this;
*(_BYTE *)(this + 866) = a3;
v8 = *(bool **)(this + 11240);
if ( a3 )
v9 = *(unsigned __int8 *)(*(_DWORD *)(v6 + 2084) + 280);
else
v9 = 0;
UILayer::updateDualMode(v8, v9);
*(_BYTE *)(*(_DWORD *)(v6 + 2076) + 2121) = *(_BYTE *)(v6 + 866);
v11 = *(unsigned __int8 *)(v6 + 866);
*(_BYTE *)(*(_DWORD *)(v6 + 2080) + 2121) = v11;
if ( *(_BYTE *)(v6 + 866) )
{
(*(void (__fastcall **)(_DWORD))(**(_DWORD **)(v6 + 2080) + 644))(*(_DWORD *)(v6 + 2080));
GJBaseGameLayer::spawnPlayer2((GJBaseGameLayer *)v6);
if ( *(_BYTE *)(*(_DWORD *)(v6 + 2084) + 280) )
PlayerObject::releaseButton(*(_DWORD *)(v6 + 2080), 1, v13);
if ( !*(_BYTE *)(v6 + 10612) && !a5 )
{
PlayerObject::spawnDualCircle(*(_DWORD *)(v6 + 2076), v12, v13, 0);
PlayerObject::spawnDualCircle(*(_DWORD *)(v6 + 2080), v14, v15, v16);
}
if ( a2 )
*(_DWORD *)(v6 + 844) = a2;
return GJBaseGameLayer::playerWillSwitchMode(v6, a4, a2);
}
v17 = *(_DWORD *)(v6 + 2076);
if ( *(_BYTE *)(v17 + 1956) )
{
if ( !a4 || (v11 = *((_DWORD *)a4 + 195), v11 != *(_DWORD *)(v17 + 780)) )
PlayerObject::createFadeOutDartStreak((HardStreak **)v17, v10, v11);
}
if ( *(_BYTE *)(v6 + 10612) )
{
if ( a4 )
{
LABEL_23:
v19 = *(PlayerObject **)(v6 + 2080);
if ( *((_DWORD *)a4 + 195) == *((_DWORD *)v19 + 195) )
PlayerObject::copyAttributes(*(_DWORD *)(v6 + 2076), v19);
}
}
else if ( a4 )
{
v18 = *(PlayerObject **)(v6 + 2080);
if ( *((_DWORD *)a4 + 195) == *((_DWORD *)v18 + 195) )
v18 = *(PlayerObject **)(v6 + 2076);
GJBaseGameLayer::playExitDualEffect((GJBaseGameLayer *)v6, v18);
goto LABEL_23;
}
GJBaseGameLayer::removePlayer2((GJBaseGameLayer *)v6);
if ( !*(_BYTE *)(v6 + 10612) )
{
LOBYTE(v27) = 0;
*(_WORD *)((char *)&v27 + 1) = 25855;
PlayerObject::spawnPortalCircle(*(_DWORD *)(v6 + 2076), v27, (CCCircleWave *)0x42480000);
}
*(_DWORD *)(v6 + 844) = 0;
if ( a2 && *((_DWORD *)a2 + 271) == 1 )
GJBaseGameLayer::updateCameraMode((GJBaseGameLayer *)v6, a2, 0);
ActiveMode = PlayerObject::getActiveMode(*(PlayerObject **)(v6 + 2076));
GJBaseGameLayer::updateDualGround((GJBaseGameLayer *)v6, a4, ActiveMode, 0, 0.0);
this = *(_DWORD *)(v6 + 2076);
if ( *(_BYTE *)(this + 1956) && (!a4 || *((_DWORD *)a4 + 195) != *(_DWORD *)(this + 780)) )
{
PlayerObject::resetStreak((cocos2d::CCMotionStreak **)this);
PlayerObject::placeStreakPoint(*(PlayerObject **)(v6 + 2076), v21, v22, v23);
this = *(_DWORD *)(v6 + 2080);
if ( *(_BYTE *)(this + 1956) )
{
v24 = *(_DWORD *)(v6 + 2076);
v25 = *(int (__fastcall **)(int, int))(*(_DWORD *)v24 + 180);
v26 = (*(int (__fastcall **)(int))(*(_DWORD *)this + 184))(this);
return v25(v24, v26);
}
}
return this;
}