//
// cocos2d::extension::CCTableView::_indexFromOffset from 0x10042d570 to 0x10042d685 (277 bytes)
//
// 3 xrefs:
// > cocos2d::extension::CCTableView::scrollViewDidScroll @ 0x10042d7f6
// > cocos2d::extension::CCTableView::scrollViewDidScroll @ 0x10042d897
// > cocos2d::extension::CCTableView::ccTouchBegan @ 0x10042db96
//
// 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
//
unsigned int __fastcall cocos2d::extension::CCTableView::_indexFromOffset(
cocos2d::extension::CCTableView *a1,
cocos2d::CCPoint a2)
{
__int64 v2; // rax
__int64 v3; // rsi
int v4; // ebx
cocos2d::CCNode *Container; // rax
double v6; // xmm0_8
int v7; // eax
__int64 v8; // rcx
int v9; // eax
float v10; // xmm0_4
__int64 v11; // rdx
int v12; // ecx
int v13; // edi
int v14; // esi
float v15; // xmm1_4
unsigned int result; // eax
signed int v17; // ebx
signed int v18; // ecx
_QWORD v19[4]; // [rsp+0h] [rbp-20h] BYREF
v19[0] = v2;
v4 = (*(__int64 (__fastcall **)(_QWORD, cocos2d::extension::CCTableView *, double))(**(_QWORD **)&a1[1].m_fScaleX
+ 40LL))(
*(_QWORD *)&a1[1].m_fScaleX,
a1,
*(double *)&a2);
if ( !a1[1].m_uID )
{
Container = cocos2d::extension::CCScrollView::getContainer(a1);
*(float *)(v3 + 4) = *(float *)(((__int64 (__fastcall *)(cocos2d::CCNode *))Container->getContentSize)(Container) + 4)
- *(float *)(v3 + 4);
}
v6 = sub_10028CC60(v19, (double *)v3);
v7 = (*(__int64 (__fastcall **)(_QWORD, cocos2d::extension::CCTableView *, double))(**(_QWORD **)&a1[1].m_fScaleX
+ 40LL))(
*(_QWORD *)&a1[1].m_fScaleX,
a1,
v6);
v8 = 0;
v9 = v7 - 1;
if ( v9 < 0 )
{
v14 = 0;
}
else
{
LOBYTE(v8) = a1->m_eDirection != kCCScrollViewDirectionHorizontal;
v10 = *((float *)v19 + v8);
v11 = *(_QWORD *)&a1[1].m_uAutoReleaseCount;
v12 = 0;
while ( 1 )
{
v13 = (v9 - v12) / 2;
v14 = v13 + v12;
v15 = *(float *)(v11 + 4LL * (v13 + v12));
if ( v10 >= v15 && *(float *)(v11 + 4LL * v14 + 4) >= v10 )
break;
if ( v15 <= v10 )
{
v12 += v13 + 1;
if ( v9 < v12 )
goto LABEL_10;
}
else
{
v9 = v14 - 1;
if ( v14 - 1 < v12 )
{
LABEL_10:
v14 = -(v12 > 0);
break;
}
}
}
if ( v14 == -1 )
return -1;
}
v17 = v4 - 1;
v18 = 0;
if ( v14 > 0 )
v18 = v14;
result = -1;
if ( v18 <= v17 )
return v18;
return result;
}