//
// TabbedPopupLayer::showTab from 0x10063fc00 to 0x10063fe98 (664 bytes)
//
// 2 xrefs:
// > GameSettingsLayer::showTab @ 0x1006035d9
// > ??> @ 0x100b80b08
//
// 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:34:42 +0000
//
char __fastcall TabbedPopupLayer::showTab(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v4; // rcx
__int64 v5; // r15
int v6; // edx
int v7; // edi
__int64 v8; // r12
unsigned __int64 v9; // r13
__int64 v10; // rcx
int v11; // esi
__int64 v12; // rax
__int64 v13; // rdx
__int64 v14; // rdi
__int64 v15; // rcx
__int64 v16; // rcx
__int64 v17; // r15
unsigned __int64 v18; // r12
__int64 v19; // rdi
__int64 v20; // rax
const char *v21; // rsi
__int64 v22; // rdx
__int64 v23; // rdi
unsigned int v24; // r14d
__int64 v25; // rdi
if ( a2 < 0 )
return v2;
v2 = *(_QWORD *)(a1 + 1016);
v4 = *(_QWORD *)(a1 + 1024);
if ( (int)(954437177 * ((unsigned __int64)(v4 - v2) >> 3)) <= a2 )
return v2;
v5 = v2 + 72LL * (unsigned int)a2;
v6 = *(_DWORD *)(v5 + 56);
if ( v6 <= 0 )
{
v7 = 0;
}
else
{
if ( *(_DWORD *)(v5 + 52) < v6 )
goto LABEL_8;
v7 = v6 - 1;
}
*(_DWORD *)(v5 + 52) = v7;
LABEL_8:
*(_DWORD *)(a1 + 1064) = a2;
if ( v4 != v2 )
{
v8 = 48;
v9 = 0;
do
{
(*(void (__fastcall **)(__int64, _QWORD, bool))(*(_QWORD *)a1 + 1352LL))(
a1,
*(unsigned int *)(v2 + v8),
v9++ == *(int *)(a1 + 1064));
v2 = *(_QWORD *)(a1 + 1016);
v8 += 72;
}
while ( v9 < 0x8E38E38E38E38E39LL * ((*(_QWORD *)(a1 + 1024) - v2) >> 3) );
v6 = *(_DWORD *)(v5 + 56);
}
if ( v6 <= 0 )
{
SetupTriggerPopup::hideAll(a1);
SetupTriggerPopup::refreshGroupVisibility(a1);
v2 = *(_QWORD *)(a1 + 1016);
v16 = *(_QWORD *)(a1 + 1024);
if ( v16 == v2 )
goto LABEL_28;
goto LABEL_21;
}
v10 = *(int *)(a1 + 1064);
v11 = 0;
if ( v10 >= 0 )
{
v12 = *(unsigned int *)(v5 + 52);
if ( (int)v12 >= 0 )
{
v13 = *(_QWORD *)(a1 + 1040);
if ( (int)v10 < (int)(-1431655765 * ((unsigned __int64)(*(_QWORD *)(a1 + 1048) - v13) >> 3)) )
{
v14 = 3 * v10;
v15 = *(_QWORD *)(v13 + 24 * v10);
if ( (int)v12 < (int)((unsigned __int64)(*(_QWORD *)(v13 + 8 * v14 + 8) - v15) >> 2) )
v11 = *(_DWORD *)(v15 + 4 * v12);
}
}
}
SetupTriggerPopup::goToPage(a1, v11, 0);
v2 = *(_QWORD *)(a1 + 1016);
v16 = *(_QWORD *)(a1 + 1024);
if ( v16 != v2 )
{
LABEL_21:
v17 = 64;
v18 = 0;
do
{
v19 = *(_QWORD *)(v2 + v17);
if ( v19 )
{
v20 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 1072LL))(v19);
if ( v20 )
{
v21 = "GJ_button_05.png";
if ( v18 == *(_DWORD *)(a1 + 1064) )
v21 = "GJ_button_02.png";
ButtonSprite::updateBGImage(v20, (__int64)v21);
}
}
++v18;
v2 = *(_QWORD *)(a1 + 1016);
v16 = *(_QWORD *)(a1 + 1024);
v17 += 72;
}
while ( v18 < 0x8E38E38E38E38E39LL * ((v16 - v2) >> 3) );
}
LABEL_28:
v22 = *(int *)(a1 + 1064);
if ( v22 < 0 || (int)v22 >= (int)(954437177 * ((unsigned __int64)(v16 - v2) >> 3)) )
{
LOBYTE(v2) = 0;
v23 = *(_QWORD *)(a1 + 1072);
v24 = 0;
if ( !v23 )
goto LABEL_34;
goto LABEL_33;
}
LOBYTE(v2) = *(_DWORD *)(v2 + 72 * v22 + 56) >= 2;
v23 = *(_QWORD *)(a1 + 1072);
v24 = (unsigned __int8)v2;
if ( v23 )
{
LABEL_33:
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v23 + 344LL))(v23, v24);
LOBYTE(v2) = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 1072) + 1056LL))(
*(_QWORD *)(a1 + 1072),
v24);
}
LABEL_34:
v25 = *(_QWORD *)(a1 + 1080);
if ( v25 )
{
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v25 + 344LL))(v25, v24);
LOBYTE(v2) = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 1080) + 1056LL))(
*(_QWORD *)(a1 + 1080),
v24);
}
return v2;
}