//
// EditorUI::toggleWindow from 0x10000b780 to 0x10000b9a2 (546 bytes)
//
// 4 xrefs:
// > EditorUI::onEditorCommands @ 0x100009365
// > EditorUI::onGridSizeIndicator @ 0x10000937a
// > EditorUI::onFindObject @ 0x100010875
// > EditorUI::onDpadStep @ 0x10063af8d
//
// 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 12:18:50 +0000
//
void __fastcall EditorUI::toggleWindow(__int64 a1, int a2)
{
_QWORD *v2; // rbx
unsigned __int64 v3; // r9
unsigned __int64 v4; // rdx
unsigned __int64 v5; // r11
unsigned __int64 v6; // r8
__int64 **v7; // rax
__int64 *v8; // r10
__int64 v9; // rax
unsigned __int64 v10; // rax
__int64 v11; // r14
int *v12; // [rsp+0h] [rbp-20h] BYREF
int v13; // [rsp+8h] [rbp-18h] BYREF
_BYTE v14[17]; // [rsp+Fh] [rbp-11h] BYREF
v13 = a2;
v2 = (_QWORD *)(a1 + 576);
v3 = *(_QWORD *)(a1 + 584);
if ( v3 )
{
v4 = ((v3 - ((v3 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v3 - ((v3 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v3 - ((v3 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v3 - ((v3 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4);
v5 = (0x101010101010101LL * (v4 & 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v5 <= 1 )
{
v6 = a2 & (v3 - 1);
v7 = *(__int64 ***)(*v2 + 8 * v6);
if ( !v7 )
goto LABEL_29;
goto LABEL_9;
}
v6 = a2;
if ( v3 <= a2 )
{
if ( !((v3 | a2) >> 32) )
{
v4 = a2 % (unsigned int)v3;
v6 = v4;
v7 = *(__int64 ***)(*v2 + 8 * v4);
if ( !v7 )
goto LABEL_29;
goto LABEL_9;
}
v4 = a2 % v3;
v6 = v4;
}
v7 = *(__int64 ***)(*v2 + 8 * v6);
if ( !v7 )
goto LABEL_29;
LABEL_9:
v8 = *v7;
if ( !*v7 )
goto LABEL_29;
if ( (unsigned int)v5 < 2 )
{
--v3;
while ( 1 )
{
v9 = v8[1];
if ( v9 == a2 )
{
if ( *((_DWORD *)v8 + 4) == a2 )
goto LABEL_27;
}
else if ( (v3 & v9) != v6 )
{
goto LABEL_29;
}
v8 = (__int64 *)*v8;
if ( !v8 )
goto LABEL_29;
}
}
do
{
v10 = v8[1];
if ( v10 == a2 )
{
if ( *((_DWORD *)v8 + 4) == a2 )
{
LABEL_27:
(*(void (__fastcall **)(__int64, _QWORD, unsigned __int64, _QWORD, unsigned __int64, unsigned __int64))(*(_QWORD *)v8[3] + 1368LL))(
v8[3],
0,
v4,
a2,
v6,
v3);
return;
}
}
else
{
if ( v10 < v3 )
goto LABEL_23;
if ( (v3 | v10) >> 32 )
{
v4 = v10 % v3;
v10 %= v3;
LABEL_23:
if ( v10 != v6 )
break;
goto LABEL_18;
}
v4 = (unsigned int)v10 % (unsigned int)v3;
if ( v4 != v6 )
break;
}
LABEL_18:
v8 = (__int64 *)*v8;
}
while ( v8 );
}
LABEL_29:
switch ( a2 )
{
case 1:
v11 = EditorCommandsPopup::create();
if ( v11 )
goto LABEL_35;
break;
case 3:
v11 = sub_100905EB0();
if ( v11 )
goto LABEL_35;
break;
case 4:
v11 = sub_1009081F0();
if ( v11 )
goto LABEL_35;
break;
case 5:
v11 = MoveStepPopup::create();
if ( v11 )
{
LABEL_35:
v12 = &v13;
*(_QWORD *)(((__int64 (__fastcall *)(__int64, int *, void *, int **, _BYTE *))sub_10001B030)(
a1 + 576,
&v13,
&unk_100A0394C,
&v12,
v14)
+ 24) = v11;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v11 + 1312LL))(v11);
}
break;
default:
return;
}
}