//
// cocos2d::CCTouchDispatcher::touches from 0x1001cde6c to 0x1001ce250 (996 bytes)
//
// 7 xrefs:
// > cocos2d::CCTouchDispatcher::touchesBegan @ 0x1001ce2d8
// > cocos2d::CCTouchDispatcher::touchesMoved @ 0x1001ce354
// > sub_1001CE35C @ 0x1001ce370
// > cocos2d::CCTouchDispatcher::touchesEnded @ 0x1001ce388
// > sub_1001CE390 @ 0x1001ce3a4
// > cocos2d::CCTouchDispatcher::touchesCancelled @ 0x1001ce3bc
// > sub_1001CE3C4 @ 0x1001ce3d8
//
// This function is hookable on this platform (idp: arm, 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:00:21 +0000
//
double __fastcall cocos2d::CCTouchDispatcher::touches(__int64 a1, _DWORD *a2, __int64 a3, unsigned int a4)
{
__int64 v8; // x0
int v9; // w25
__int64 *v10; // x26
int v11; // w0
double result; // d0
int v13; // w24
bool v14; // zf
int v15; // w27
__int64 v16; // x21
_DWORD *v17; // x28
unsigned int v18; // w21
_QWORD *v19; // x25
unsigned int *v20; // x9
__int64 v21; // x8
__int64 v22; // x26
__int64 *v23; // x24
unsigned __int64 v24; // x28
__int64 v25; // x27
__int64 v26; // x0
__int64 v27; // x0
__int64 v28; // x0
__int64 Delegate; // x0
__int64 ClaimedTouches; // x0
void (*v31)(void); // x8
__int64 v32; // x0
_QWORD *v33; // x8
_QWORD *v34; // x24
unsigned int *v35; // x9
__int64 v36; // x8
__int64 *v37; // x22
unsigned __int64 v38; // x23
_QWORD *v39; // x0
unsigned int *v40; // x0
unsigned __int64 v41; // x20
__int64 v42; // x0
unsigned int *v43; // x9
__int64 v44; // x8
const void **v45; // x23
unsigned __int64 v46; // x24
const void *v47; // x22
void *v48; // x0
__int64 *v49; // x8
int v50; // [xsp+Ch] [xbp-74h]
_DWORD *v51; // [xsp+18h] [xbp-68h]
int v52; // [xsp+24h] [xbp-5Ch]
__int64 v53; // [xsp+28h] [xbp-58h]
v8 = cocos2d::CCDirector::sharedDirector(a1);
sub_100207C5C(v8);
*(_BYTE *)(a1 + 80) = 1;
v53 = a1 + 64;
v9 = sub_1002E757C(*(_QWORD *)(a1 + 64));
v10 = (__int64 *)(a1 + 72);
v11 = sub_1002E757C(*(_QWORD *)(a1 + 72));
v13 = v11;
if ( v9 )
v14 = v11 == 0;
else
v14 = 1;
v15 = !v14;
v16 = a1 + 4LL * a4;
if ( v14 )
{
v18 = *(_DWORD *)(v16 + 108);
v17 = a2;
if ( !v9 )
{
v17 = a2;
if ( v11 )
goto LABEL_40;
goto LABEL_50;
}
}
else
{
v17 = (_DWORD *)cocos2d::CCSet::mutableCopy(a2);
v18 = *(_DWORD *)(v16 + 108);
}
v19 = (_QWORD *)cocos2d::CCSet::begin(a2);
if ( v19 == (_QWORD *)cocos2d::CCSet::end(a2) )
goto LABEL_39;
v50 = v13;
v51 = v17;
v52 = v15;
do
{
if ( *(_QWORD *)v53 )
{
v20 = *(unsigned int **)(*(_QWORD *)v53 + 56LL);
v21 = *v20;
if ( (_DWORD)v21 )
{
v22 = v19[4];
v23 = *((__int64 **)v20 + 2);
v24 = (unsigned __int64)&v23[v21 - 1];
while ( 1 )
{
v25 = *v23;
if ( !*v23 )
goto LABEL_32;
v26 = *v23;
if ( !a4 )
{
Delegate = cocos2d::CCTouchHandler::getDelegate(v26);
if ( !(*(unsigned int (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)Delegate + 16LL))(
Delegate,
v22,
a3) )
goto LABEL_28;
ClaimedTouches = cocos2d::CCTargetedTouchHandler::getClaimedTouches(v25);
cocos2d::CCSet::addObject(ClaimedTouches, v22);
goto LABEL_27;
}
v27 = cocos2d::CCTargetedTouchHandler::getClaimedTouches(v26);
if ( !(unsigned int)cocos2d::CCSet::containsObject(v27, v22) )
goto LABEL_28;
if ( v18 == 3 )
break;
if ( v18 == 2 )
{
v31 = *(void (**)(void))(*(_QWORD *)cocos2d::CCTouchHandler::getDelegate(v25) + 32LL);
LABEL_26:
v31();
v32 = cocos2d::CCTargetedTouchHandler::getClaimedTouches(v25);
cocos2d::CCSet::removeObject(v32, v22);
goto LABEL_27;
}
if ( v18 == 1 )
{
v28 = cocos2d::CCTouchHandler::getDelegate(v25);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v28 + 24LL))(v28, v22, a3);
}
LABEL_27:
if ( (unsigned int)cocos2d::CCTargetedTouchHandler::isSwallowsTouches(v25) )
{
if ( v52 )
cocos2d::CCSet::removeObject(v51, v22);
goto LABEL_32;
}
LABEL_28:
if ( (unsigned __int64)++v23 > v24 )
goto LABEL_32;
}
v31 = *(void (**)(void))(*(_QWORD *)cocos2d::CCTouchHandler::getDelegate(v25) + 40LL);
goto LABEL_26;
}
}
LABEL_32:
v33 = (_QWORD *)v19[1];
if ( v33 )
{
do
{
v34 = v33;
v33 = (_QWORD *)*v33;
}
while ( v33 );
}
else
{
do
{
v34 = (_QWORD *)v19[2];
v14 = *v34 == (_QWORD)v19;
v19 = v34;
}
while ( !v14 );
}
v19 = v34;
}
while ( v34 != (_QWORD *)cocos2d::CCSet::end(a2) );
v10 = (__int64 *)(a1 + 72);
v17 = v51;
v15 = v52;
v13 = v50;
LABEL_39:
if ( v13 )
{
LABEL_40:
if ( (int)cocos2d::CCSet::count(v17) >= 1 )
{
if ( *v10 )
{
v35 = *(unsigned int **)(*v10 + 56);
v36 = *v35;
if ( (_DWORD)v36 )
{
v37 = *((__int64 **)v35 + 2);
v38 = (unsigned __int64)&v37[v36 - 1];
do
{
if ( !*v37 )
break;
if ( v18 <= 3 )
{
v39 = (_QWORD *)cocos2d::CCTouchHandler::getDelegate(*v37);
(*(void (**)(void))(*v39 + 8 * v18 + 48LL))();
}
++v37;
}
while ( (unsigned __int64)v37 <= v38 );
}
}
}
}
LABEL_50:
if ( v15 )
cocos2d::CCObject::release(v17);
*(_BYTE *)(a1 + 80) = 0;
if ( *(_BYTE *)(a1 + 82) == 1 )
{
*(_BYTE *)(a1 + 82) = 0;
v40 = *(unsigned int **)(a1 + 96);
if ( *v40 )
{
v41 = 0;
do
{
cocos2d::CCTouchDispatcher::forceRemoveDelegate(a1, *(_QWORD *)(*((_QWORD *)v40 + 2) + 8 * v41++));
v40 = *(unsigned int **)(a1 + 96);
}
while ( v41 < *v40 );
}
sub_1003F34B0();
}
if ( *(_BYTE *)(a1 + 81) == 1 )
{
*(_BYTE *)(a1 + 81) = 0;
v42 = *(_QWORD *)(a1 + 88);
if ( v42 )
{
v43 = *(unsigned int **)(v42 + 56);
v44 = *v43;
if ( (_DWORD)v44 )
{
v45 = *((const void ***)v43 + 2);
v46 = (unsigned __int64)&v45[v44 - 1];
do
{
v47 = *v45;
if ( !*v45 )
break;
v48 = __dynamic_cast(
*v45,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTouchHandler,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTargetedTouchHandler,
0);
v49 = (__int64 *)(a1 + 64);
if ( !v48 )
v49 = v10;
cocos2d::CCTouchDispatcher::forceAddHandler((__int64)v48, (__int64)v47, *v49);
++v45;
}
while ( (unsigned __int64)v45 <= v46 );
v42 = *(_QWORD *)(a1 + 88);
}
}
*(_QWORD *)&result = sub_1002E7674(v42).n128_u64[0];
}
if ( *(_BYTE *)(a1 + 104) == 1 )
{
*(_BYTE *)(a1 + 104) = 0;
sub_1002E7674(*(_QWORD *)(a1 + 72));
*(_QWORD *)&result = sub_1002E7674(*(_QWORD *)(a1 + 64)).n128_u64[0];
}
return result;
}