//
// GJBaseGameLayer::toggleDualMode from 0x14031de10 to 0x14031e42d (1565 bytes)
//
// 9 xrefs:
// > GJBaseGameLayer::setupLevelStart @ 0x14031941c
// > GJBaseGameLayer::collisionCheckObjects @ 0x14031cb99
// > GJBaseGameLayer::collisionCheckObjects @ 0x14031cc32
// > GJBaseGameLayer::resetLevelVariables @ 0x140345a4a
// > LevelEditorLayer::onStopPlaytest @ 0x140400219
// > PlayLayer::loadFromCheckpoint @ 0x140516ab5
// > ??> @ 0x1408b5364
// > ??> @ 0x1408b53bc
// > ??> @ 0x14091ec8c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:30:21 +0000
//
void __fastcall GJBaseGameLayer::toggleDualMode(__int64 a1, __int64 a2, char a3, __int64 a4, char a5)
{
__int64 v6; // rbp
char v8; // al
__int64 v9; // rcx
__int64 v10; // rdx
_QWORD *v11; // rsi
__int64 v12; // rdx
__int64 v13; // rax
_BYTE *v14; // rsi
char v15; // bl
__int64 v16; // r15
__int64 v17; // rdx
__int64 v18; // rdx
__int64 v19; // rdx
const struct cocos2d::CCPoint *v20; // rax
__int64 v21; // rax
__int64 v22; // rbx
const struct cocos2d::CCPoint *v23; // rax
__int64 v24; // rax
bool v25; // zf
__int64 v26; // rcx
__int64 v27; // r8
_BYTE *v28; // rbx
_QWORD *v29; // r15
__int64 v30; // rdx
_BYTE *v31; // r12
_QWORD *v32; // r13
__int64 v33; // r13
unsigned int v34; // esi
cocos2d::CCParticleSystem *v35; // rbx
__int64 v36; // rsi
__int64 v37; // rcx
float v38; // xmm0_4
float v39; // xmm1_4
float v40; // xmm1_4
_BYTE *v41; // rax
int v42; // r8d
__int64 v43; // rcx
__int64 v44; // rbx
const struct cocos2d::CCPoint *v45; // rax
__int64 v46; // rax
_BYTE *v47; // rcx
__int64 *v48; // rdi
__int64 v49; // rbx
char v50; // [rsp+70h] [rbp+8h] BYREF
int v51; // [rsp+80h] [rbp+18h] BYREF
v6 = a2;
if ( *(_BYTE *)(a1 + 1058) == a3 )
return;
*(_BYTE *)(a1 + 1058) = a3;
v8 = a3 && *(_BYTE *)(*(_QWORD *)(a1 + 3528) + 340LL);
v9 = *(_QWORD *)(a1 + 13888);
if ( *(_BYTE *)(v9 + 624) != v8 )
{
v10 = *(unsigned __int8 *)(v9 + 596);
*(_BYTE *)(v9 + 624) = v8;
UILayer::togglePlatformerMode(v9, v10);
}
v11 = (_QWORD *)(a1 + 3520);
*(_BYTE *)(*(_QWORD *)(a1 + 3512) + 2721LL) = *(_BYTE *)(a1 + 1058);
*(_BYTE *)(*(_QWORD *)(a1 + 3520) + 2721LL) = *(_BYTE *)(a1 + 1058);
if ( *(_BYTE *)(a1 + 1058) )
{
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)*v11 + 1136LL))(*v11);
if ( !(*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)*v11 + 504LL))(*v11) )
{
v13 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 3512) + 504LL))(*(_QWORD *)(a1 + 3512));
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v13 + 456LL))(v13, *v11, 59);
if ( !*(_BYTE *)(a1 + 12668) )
PlayerObject::addAllParticles(*v11);
}
v14 = (_BYTE *)*v11;
LOBYTE(v12) = 1;
v15 = *(_BYTE *)(a1 + 2144);
v16 = *(_QWORD *)(a1 + 3512);
(*(void (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)v14 + 336LL))(v14, v12);
LOBYTE(v17) = -1;
(*(void (__fastcall **)(_BYTE *, __int64))(*((_QWORD *)v14 + 40) + 40LL))(v14 + 320, v17);
PlayerObject::copyAttributes(v14);
v18 = *(unsigned __int8 *)(v16 + 2503);
if ( !v15 )
LOBYTE(v18) = (_BYTE)v18 == 0;
PlayerObject::flipGravity(v14, v18);
PlayerObject::setYVelocity(v14);
v14[2505] = 0;
v14[2580] = 0;
LOBYTE(v19) = *(_BYTE *)(v16 + 1843) == 0;
PlayerObject::toggleVisibility(v14, v19);
if ( v14[2500] )
{
v20 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_BYTE *))(*(_QWORD *)v14 + 200LL))(v14);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, v20);
PlayerObject::placeStreakPoint(v14, v21);
}
if ( *(_BYTE *)(*(_QWORD *)(a1 + 3528) + 340LL) )
{
v22 = *(_QWORD *)(a1 + 3520);
if ( !*(_BYTE *)(v22 + 3024) )
{
v51 = 1;
*(_BYTE *)sub_14016EE40((__int64 *)(v22 + 3008), &v51) = 0;
}
if ( !*(_BYTE *)(v22 + 2611) )
{
if ( *(_BYTE *)(v22 + 2445) )
{
v23 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v22 + 200LL))(v22);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, v23);
PlayerObject::placeStreakPoint(v22, v24);
}
v25 = *(_BYTE *)(v22 + 2540) == 0;
*(_WORD *)(v22 + 2445) = 0;
*(_BYTE *)(v22 + 2468) = 1;
if ( !v25 )
PlayerObject::stopDashing(v22);
}
}
if ( !*(_BYTE *)(a1 + 12668) && !a5 )
{
PlayerObject::spawnDualCircle(*(_QWORD *)(a1 + 3512));
PlayerObject::spawnDualCircle(*(_QWORD *)(a1 + 3520));
}
if ( v6 )
*(_QWORD *)(a1 + 1032) = v6;
GJBaseGameLayer::playerWillSwitchMode(a1, a4, v6);
return;
}
v26 = *(_QWORD *)(a1 + 3512);
v27 = v26;
if ( *(_BYTE *)(v26 + 2500) )
{
if ( a4 )
{
if ( *(_DWORD *)(a4 + 924) == *(_DWORD *)(v26 + 924) )
goto LABEL_35;
v11 = (_QWORD *)(a1 + 3520);
}
PlayerObject::createFadeOutDartStreak(v26, a2, v26);
v27 = *(_QWORD *)(a1 + 3512);
}
LABEL_35:
v28 = (_BYTE *)(a1 + 12668);
v29 = v11;
if ( *(_BYTE *)(a1 + 12668) )
{
v31 = (_BYTE *)(a1 + 12668);
v32 = v11;
if ( a4 )
{
LABEL_41:
a2 = *v11;
v29 = v32;
v28 = v31;
if ( *(_DWORD *)(a4 + 924) == *(_DWORD *)(*v11 + 924LL) )
PlayerObject::copyAttributes(v27);
}
}
else if ( a4 )
{
v30 = *v11;
if ( *(_DWORD *)(a4 + 924) == *(_DWORD *)(*v11 + 924LL) )
v30 = v27;
GJBaseGameLayer::playExitDualEffect(a1, v30, v27);
v27 = *(_QWORD *)(a1 + 3512);
v31 = (_BYTE *)(a1 + 12668);
v32 = (_QWORD *)(a1 + 3520);
goto LABEL_41;
}
LOBYTE(a2) = 1;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(*(_QWORD *)*v29 + 520LL))(*v29, a2, v27);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)(*v29 + 320LL) + 40LL))(*v29 + 320LL, 0);
PlayerObject::releaseAllButtons(*v29);
v33 = *v29;
v34 = 0;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(*v29 + 1688LL)) )
{
do
{
v35 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v33 + 1688), v34);
cocos2d::CCParticleSystem::resetSystem(v35);
cocos2d::CCParticleSystem::stopSystem(v35);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, _QWORD))(*(_QWORD *)v35 + 520LL))(v35, 0);
++v34;
}
while ( v34 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(v33 + 1688)) );
v29 = (_QWORD *)(a1 + 3520);
v28 = (_BYTE *)(a1 + 12668);
}
v36 = *v29;
cocos2d::CCMotionStreak::stopStroke(*(cocos2d::CCMotionStreak **)(*v29 + 1960LL));
if ( *(_BYTE *)(v36 + 2432) )
{
*(_BYTE *)(v36 + 2432) = 0;
PlayerObject::fadeOutStreak2(v36);
}
if ( !*v28 )
{
v37 = *(_QWORD *)(a1 + 3512);
LOWORD(v51) = -256;
BYTE2(v51) = 100;
PlayerObject::spawnPortalCircle(v37, &v51);
}
*(_QWORD *)(a1 + 1032) = 0;
if ( v6 )
{
if ( *(_DWORD *)(v6 + 1256) == 1 )
{
*(_BYTE *)(a1 + 785) = *(_BYTE *)(v6 + 1764);
*(_BYTE *)(a1 + 786) = *(_BYTE *)(v6 + 1776);
if ( *(_BYTE *)(v6 + 1765) )
{
v38 = *(float *)(v6 + 1768);
*(float *)(a1 + 720) = v38;
v39 = *(float *)(v6 + 1772);
if ( v38 <= 1.0 )
v38 = 1.0;
if ( v38 >= 40.0 )
v38 = 40.0;
*(float *)(a1 + 720) = v38;
v40 = fmaxf(v39, 0.0);
if ( v40 >= 1.0 )
v40 = 1.0;
*(float *)(a1 + 716) = v40;
}
}
}
v41 = *(_BYTE **)(a1 + 3512);
v42 = 6;
if ( v41[2497] || v41[2498] || v41[2500] || v41[2508] )
{
v42 = 5;
}
else if ( v41[2499] )
{
v42 = 16;
}
else if ( v41[2502] )
{
v42 = 33;
}
GJBaseGameLayer::updateDualGround(a1, a4, v42);
v43 = *(_QWORD *)(a1 + 3512);
if ( *(_BYTE *)(v43 + 2500) && (!a4 || *(_DWORD *)(a4 + 924) != *(_DWORD *)(v43 + 924)) )
{
PlayerObject::resetStreak(v43);
v44 = *(_QWORD *)(a1 + 3512);
v45 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v44 + 200LL))(v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, v45);
PlayerObject::placeStreakPoint(v44, v46);
v47 = *(_BYTE **)(a1 + 3520);
if ( v47[2500] )
{
v48 = *(__int64 **)(a1 + 3512);
v49 = *v48;
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)v47 + 360LL))(v47);
(*(void (__fastcall **)(__int64 *))(v49 + 352))(v48);
}
}
}