//
// cocos2d::CCTouchDispatcher::touches from 0x8081e4 to 0x808470 (652 bytes)
//
// 4 xrefs:
// > cocos2d::CCTouchDispatcher::touchesBegan @ 0x8084ec
// > cocos2d::CCTouchDispatcher::touchesMoved @ 0x808520
// > cocos2d::CCTouchDispatcher::touchesEnded @ 0x808536
// > cocos2d::CCTouchDispatcher::touchesCancelled @ 0x80854c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:01:26 +0000
//
cocos2d::CCTouchHandler *__fastcall cocos2d::CCTouchDispatcher::touches(int a1, cocos2d::CCSet *a2, int a3, int a4)
{
cocos2d::CCDirector *v7; // r0
int v8; // r5
cocos2d::CCTouchHandler *result; // r0
cocos2d::CCSet *v10; // r7
int v11; // r10
cocos2d::CCTouchHandler *v12; // r5
int v13; // r3
cocos2d::CCObject *v14; // r8
_DWORD *v15; // r3
cocos2d::CCTouchHandler *v16; // r6
cocos2d::CCTouchHandler *v17; // r3
cocos2d::CCTouchHandler *v18; // r3
int v19; // r3
_DWORD *v20; // r2
cocos2d::CCTouchHandler **v21; // r5
cocos2d::CCTouchHandler **v22; // r6
int v23; // r3
unsigned int v24; // r5
unsigned int *v25; // r0
cocos2d::CCTouchDelegate *v26; // r1
int v27; // r3
_DWORD *v28; // r2
const void **v29; // r6
const void **v30; // r5
cocos2d::CCTouchHandler *v31; // r7
cocos2d::CCTouchHandler *v32; // t1
int Delegate; // r0
cocos2d::CCSet *ClaimedTouches; // r0
cocos2d::CCSet *v35; // r0
int v36; // r0
void (*v37)(void); // r3
cocos2d::CCSet *v38; // r0
cocos2d::CCObject *v39; // r2
cocos2d::CCObject *v40; // r2
cocos2d::CCTouchHandler *v41; // t1
int (*v42)(void); // r3
cocos2d::CCTouchDispatcher *v43; // r0
cocos2d::CCTouchHandler *v44; // r1
cocos2d::CCArray *v45; // r2
int v46; // [sp+4h] [bp-18h]
cocos2d::CCTouchHandler **v47; // [sp+8h] [bp-14h]
cocos2d::CCTouchHandler *v48; // [sp+Ch] [bp-10h]
cocos2d::CCTouchHandler **v50; // [sp+14h] [bp-8h]
v7 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)a1);
cocos2d::CCDirector::noteInput(v7);
*(_BYTE *)(a1 + 64) = 1;
v8 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 56));
result = (cocos2d::CCTouchHandler *)cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 60));
v48 = result;
if ( v8 )
{
if ( result )
{
result = cocos2d::CCSet::mutableCopy(a2);
v46 = 1;
v10 = result;
}
else
{
v10 = a2;
v46 = 0;
}
}
else
{
v10 = a2;
v46 = 0;
}
v11 = *(_DWORD *)(a1 + 4 * (a4 + 20));
if ( v8 )
{
v12 = (cocos2d::CCTouchHandler *)cocos2d::CCSet::begin(a2);
while ( 1 )
{
result = (cocos2d::CCTouchHandler *)cocos2d::CCSet::end(a2);
if ( v12 == result )
goto LABEL_6;
v13 = *(_DWORD *)(a1 + 56);
v14 = *((cocos2d::CCObject **)v12 + 4);
if ( v13 )
{
v15 = *(_DWORD **)(v13 + 52);
if ( *v15 )
break;
}
LABEL_15:
v17 = *((cocos2d::CCTouchHandler **)v12 + 1);
if ( v17 )
{
do
{
v12 = v17;
v17 = *(cocos2d::CCTouchHandler **)v17;
}
while ( v17 );
}
else
{
do
{
v18 = v12;
v12 = *((cocos2d::CCTouchHandler **)v12 + 2);
}
while ( v18 != *(cocos2d::CCTouchHandler **)v12 );
}
}
v47 = (cocos2d::CCTouchHandler **)v15[3];
v50 = &v47[*v15] + 0x3FFFFFFF;
while ( 1 )
{
while ( 1 )
{
if ( v47 > v50 )
goto LABEL_15;
v16 = *v47++;
if ( !v16 )
goto LABEL_15;
if ( a4 )
break;
Delegate = cocos2d::CCTouchHandler::getDelegate(v16);
if ( (*(int (__fastcall **)(int, cocos2d::CCObject *, int))(*(_DWORD *)Delegate + 8))(Delegate, v14, a3) )
{
ClaimedTouches = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(v16);
cocos2d::CCSet::addObject(ClaimedTouches, v14);
goto LABEL_54;
}
}
v35 = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(v16);
if ( cocos2d::CCSet::containsObject(v35, v14) )
{
if ( v11 == 2 )
{
v37 = *(void (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(v16) + 16);
}
else
{
if ( v11 != 3 )
{
if ( v11 == 1 )
{
v36 = cocos2d::CCTouchHandler::getDelegate(v16);
(*(void (__fastcall **)(int, cocos2d::CCObject *, int))(*(_DWORD *)v36 + 12))(v36, v14, a3);
}
goto LABEL_54;
}
v37 = *(void (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(v16) + 20);
}
v37();
v38 = (cocos2d::CCSet *)cocos2d::CCTargetedTouchHandler::getClaimedTouches(v16);
cocos2d::CCSet::removeObject(v38, v14, v39);
LABEL_54:
if ( cocos2d::CCTargetedTouchHandler::isSwallowsTouches(v16) )
{
if ( v46 )
cocos2d::CCSet::removeObject(v10, v14, v40);
goto LABEL_15;
}
}
}
}
LABEL_6:
if ( v48 )
{
result = (cocos2d::CCTouchHandler *)cocos2d::CCSet::count(v10);
if ( (int)result > 0 )
{
v19 = *(_DWORD *)(a1 + 60);
if ( v19 )
{
v20 = *(_DWORD **)(v19 + 52);
if ( *v20 )
{
v21 = (cocos2d::CCTouchHandler **)v20[3];
v22 = &v21[*v20] + 0x3FFFFFFF;
while ( v21 <= v22 )
{
v41 = *v21++;
result = v41;
if ( !v41 )
break;
switch ( v11 )
{
case 0:
v42 = *(int (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(result) + 24);
goto LABEL_63;
case 1:
v42 = *(int (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(result) + 28);
goto LABEL_63;
case 2:
v42 = *(int (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(result) + 32);
goto LABEL_63;
case 3:
v42 = *(int (**)(void))(*(_DWORD *)cocos2d::CCTouchHandler::getDelegate(result) + 36);
LABEL_63:
result = (cocos2d::CCTouchHandler *)v42();
break;
default:
continue;
}
}
}
}
}
}
if ( v46 )
result = (cocos2d::CCTouchHandler *)cocos2d::CCObject::release(v10);
v23 = *(unsigned __int8 *)(a1 + 66);
v24 = 0;
*(_BYTE *)(a1 + 64) = 0;
if ( v23 )
{
*(_BYTE *)(a1 + 66) = 0;
while ( 1 )
{
v25 = *(unsigned int **)(a1 + 72);
if ( v24 >= *v25 )
break;
v26 = *(cocos2d::CCTouchDelegate **)(v25[3] + 4 * v24++);
cocos2d::CCTouchDispatcher::forceRemoveDelegate((cocos2d::CCTouchDelegate *)a1, v26);
}
result = (cocos2d::CCTouchHandler *)cocos2d::ccCArrayRemoveAllValues(v25);
}
if ( *(_BYTE *)(a1 + 65) )
{
*(_BYTE *)(a1 + 65) = 0;
v27 = *(_DWORD *)(a1 + 68);
if ( v27 )
{
v28 = *(_DWORD **)(v27 + 52);
if ( *v28 )
{
v29 = (const void **)v28[3];
v30 = &v29[*v28] + 0x3FFFFFFF;
while ( v29 <= v30 )
{
v32 = (cocos2d::CCTouchHandler *)*v29++;
v31 = v32;
if ( !v32 )
break;
if ( _dynamic_cast(
v31,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTouchHandler,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTargetedTouchHandler,
0) )
{
v43 = (cocos2d::CCTouchDispatcher *)a1;
v44 = v31;
v45 = *(cocos2d::CCArray **)(a1 + 56);
}
else
{
v45 = *(cocos2d::CCArray **)(a1 + 60);
v43 = (cocos2d::CCTouchDispatcher *)a1;
v44 = v31;
}
cocos2d::CCTouchDispatcher::forceAddHandler(v43, v44, v45);
}
}
}
result = (cocos2d::CCTouchHandler *)cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(a1 + 68));
}
if ( *(_BYTE *)(a1 + 76) )
{
*(_BYTE *)(a1 + 76) = 0;
return (cocos2d::CCTouchHandler *)cocos2d::CCTouchDispatcher::forceRemoveAllDelegates((cocos2d::CCArray **)a1);
}
return result;
}