//
// cocos2d::CCTouchDispatcher::touches from 0x1004c8000 to 0x1004c865b (1627 bytes)
//
// 7 xrefs:
// > cocos2d::CCTouchDispatcher::touchesBegan @ 0x1004c86da
// > cocos2d::CCTouchDispatcher::touchesMoved @ 0x1004c8760
// > sub_1004C8770 @ 0x1004c8784
// > cocos2d::CCTouchDispatcher::touchesEnded @ 0x1004c87a0
// > sub_1004C87B0 @ 0x1004c87c4
// > cocos2d::CCTouchDispatcher::touchesCancelled @ 0x1004c87e0
// > sub_1004C87F0 @ 0x1004c8804
//
// 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:31:08 +0000
//
char __fastcall cocos2d::CCTouchDispatcher::touches(__int64 a1, _DWORD *a2, __int64 a3, unsigned int a4)
{
__int64 v5; // r12
__int64 v6; // rax
int v7; // r15d
unsigned int *v8; // rax
_DWORD *v9; // r13
_QWORD *v10; // r15
__int64 v11; // rax
unsigned int *v12; // rax
__int64 v13; // r13
__int64 *v14; // r14
unsigned __int64 v15; // rbx
__int64 v16; // r12
__int64 Delegate; // rax
__int64 ClaimedTouches; // rax
_QWORD *v19; // rax
_QWORD *v20; // rbx
bool v21; // zf
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // r12
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rax
__int64 *v28; // rbx
char v29; // kr00_1
unsigned __int64 v30; // r14
__int64 v31; // rax
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
unsigned int *v35; // rdi
unsigned __int64 v36; // rbx
__int64 v37; // rdi
unsigned int *v38; // rax
__int64 v39; // rcx
const void **v40; // rax
const void *v41; // rdi
__int64 v42; // rax
__int64 v43; // rdx
unsigned int *v44; // rax
__int64 *v45; // r12
__int64 v46; // r13
int Priority; // r15d
int v48; // ebx
__int64 v49; // r13
__int64 v50; // rax
unsigned int *v51; // rax
__int64 *v52; // r12
__int64 v53; // r13
int v54; // r15d
int v55; // ebx
__int64 v56; // r13
_DWORD *v59; // [rsp+10h] [rbp-60h]
unsigned int v60; // [rsp+18h] [rbp-58h]
const void **v61; // [rsp+18h] [rbp-58h]
unsigned __int64 v62; // [rsp+20h] [rbp-50h]
unsigned __int64 v63; // [rsp+20h] [rbp-50h]
int v64; // [rsp+28h] [rbp-48h]
unsigned __int64 v65; // [rsp+28h] [rbp-48h]
bool v66; // [rsp+30h] [rbp-40h]
__int64 v67; // [rsp+30h] [rbp-40h]
int v69; // [rsp+44h] [rbp-2Ch]
int v70; // [rsp+44h] [rbp-2Ch]
int v71; // [rsp+44h] [rbp-2Ch]
v5 = a1;
v6 = cocos2d::CCDirector::sharedDirector();
sub_1004794C0(v6);
*(_BYTE *)(a1 + 80) = 1;
v7 = sub_1007FEF90(*(_QWORD *)(a1 + 64));
LODWORD(v8) = sub_1007FEF90(*(_QWORD *)(a1 + 72));
v64 = (int)v8;
v66 = v7 != 0 && (_DWORD)v8 != 0;
if ( v66 )
{
v9 = (_DWORD *)cocos2d::CCSet::mutableCopy(a2);
v69 = *(_DWORD *)(a1 + 4LL * a4 + 108);
}
else
{
v69 = *(_DWORD *)(a1 + 4LL * a4 + 108);
v9 = a2;
if ( !v7 )
{
v9 = a2;
if ( !(_DWORD)v8 )
goto LABEL_52;
goto LABEL_35;
}
}
v10 = (_QWORD *)cocos2d::CCSet::begin(a2);
if ( v10 != (_QWORD *)cocos2d::CCSet::end(a2) )
{
v60 = a4;
v59 = v9;
while ( 1 )
{
v11 = *(_QWORD *)(v5 + 64);
if ( v11 )
{
v12 = *(unsigned int **)(v11 + 56);
if ( *v12 )
break;
}
LABEL_17:
v19 = (_QWORD *)v10[1];
if ( v19 )
{
do
{
v20 = v19;
v19 = (_QWORD *)*v19;
}
while ( v19 );
}
else
{
do
{
v20 = (_QWORD *)v10[2];
v21 = *v20 == (_QWORD)v10;
v10 = v20;
}
while ( !v21 );
}
v10 = v20;
v5 = a1;
if ( v20 == (_QWORD *)cocos2d::CCSet::end(a2) )
{
v9 = v59;
goto LABEL_34;
}
}
v13 = v10[4];
v14 = *((__int64 **)v12 + 2);
v15 = (unsigned __int64)&v14[*v12 - 1];
if ( !v60 )
{
while ( 1 )
{
v16 = *v14;
if ( !*v14 )
goto LABEL_17;
Delegate = cocos2d::CCTouchHandler::getDelegate(*v14);
if ( (*(unsigned __int8 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)Delegate + 16LL))(
Delegate,
v13,
a3) )
{
ClaimedTouches = cocos2d::CCTargetedTouchHandler::getClaimedTouches(v16);
cocos2d::CCSet::addObject(ClaimedTouches, v13);
if ( (unsigned __int8)cocos2d::CCTargetedTouchHandler::isSwallowsTouches(v16) )
goto LABEL_15;
}
if ( (unsigned __int64)++v14 > v15 )
goto LABEL_17;
}
}
while ( 1 )
{
v24 = *v14;
if ( !*v14 )
goto LABEL_17;
v25 = cocos2d::CCTargetedTouchHandler::getClaimedTouches(*v14);
if ( (unsigned __int8)cocos2d::CCSet::containsObject(v25, v13) )
break;
LABEL_25:
if ( (unsigned __int64)++v14 > v15 )
goto LABEL_17;
}
if ( v69 == 3 )
{
v27 = cocos2d::CCTouchHandler::getDelegate(v24);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v27 + 40LL))(v27, v13, a3);
}
else
{
if ( v69 != 2 )
{
if ( v69 == 1 )
{
v26 = cocos2d::CCTouchHandler::getDelegate(v24);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v26 + 24LL))(v26, v13, a3);
}
LABEL_24:
if ( (unsigned __int8)cocos2d::CCTargetedTouchHandler::isSwallowsTouches(v24) )
{
LABEL_15:
if ( v66 )
cocos2d::CCSet::removeObject(v59, v13);
goto LABEL_17;
}
goto LABEL_25;
}
v22 = cocos2d::CCTouchHandler::getDelegate(v24);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v22 + 32LL))(v22, v13, a3);
}
v23 = cocos2d::CCTargetedTouchHandler::getClaimedTouches(v24);
cocos2d::CCSet::removeObject(v23, v13);
goto LABEL_24;
}
LABEL_34:
LOBYTE(v8) = v64;
if ( !v64 )
goto LABEL_52;
LABEL_35:
LODWORD(v8) = cocos2d::CCSet::count(v9);
if ( (int)v8 > 0 )
{
v8 = *(unsigned int **)(v5 + 72);
if ( v8 )
{
v8 = *((unsigned int **)v8 + 7);
if ( *v8 )
{
v29 = (char)v8;
v28 = *((__int64 **)v8 + 2);
v30 = (unsigned __int64)&v28[*v8 - 1];
LOBYTE(v8) = v69;
switch ( v69 )
{
case 0:
do
{
if ( !*v28 )
break;
v31 = cocos2d::CCTouchHandler::getDelegate(*v28);
LOBYTE(v8) = (*(__int64 (__fastcall **)(__int64, _DWORD *, __int64))(*(_QWORD *)v31 + 48LL))(v31, v9, a3);
++v28;
}
while ( (unsigned __int64)v28 <= v30 );
break;
case 1:
do
{
if ( !*v28 )
break;
v34 = cocos2d::CCTouchHandler::getDelegate(*v28);
LOBYTE(v8) = (*(__int64 (__fastcall **)(__int64, _DWORD *, __int64))(*(_QWORD *)v34 + 56LL))(v34, v9, a3);
++v28;
}
while ( (unsigned __int64)v28 <= v30 );
break;
case 2:
do
{
if ( !*v28 )
break;
v32 = cocos2d::CCTouchHandler::getDelegate(*v28);
LOBYTE(v8) = (*(__int64 (__fastcall **)(__int64, _DWORD *, __int64))(*(_QWORD *)v32 + 64LL))(v32, v9, a3);
++v28;
}
while ( (unsigned __int64)v28 <= v30 );
break;
case 3:
do
{
if ( !*v28 )
break;
v33 = cocos2d::CCTouchHandler::getDelegate(*v28);
LOBYTE(v8) = (*(__int64 (__fastcall **)(__int64, _DWORD *, __int64))(*(_QWORD *)v33 + 72LL))(v33, v9, a3);
++v28;
}
while ( (unsigned __int64)v28 <= v30 );
break;
default:
LOBYTE(v8) = v29;
break;
}
}
}
}
LABEL_52:
if ( v66 )
{
LOBYTE(v8) = cocos2d::CCObject::release(v9);
*(_BYTE *)(v5 + 80) = 0;
if ( *(_BYTE *)(v5 + 82) != 1 )
{
LABEL_54:
if ( *(_BYTE *)(v5 + 81) != 1 )
goto LABEL_55;
goto LABEL_62;
}
}
else
{
*(_BYTE *)(v5 + 80) = 0;
if ( *(_BYTE *)(v5 + 82) != 1 )
goto LABEL_54;
}
*(_BYTE *)(v5 + 82) = 0;
v35 = *(unsigned int **)(v5 + 96);
if ( *v35 )
{
v36 = 0;
do
{
cocos2d::CCTouchDispatcher::forceRemoveDelegate(v5, *(unsigned int **)(*((_QWORD *)v35 + 2) + 8 * v36++));
v35 = *(unsigned int **)(v5 + 96);
}
while ( v36 < *v35 );
}
LOBYTE(v8) = sub_1007477D0();
if ( *(_BYTE *)(v5 + 81) != 1 )
{
LABEL_55:
if ( *(_BYTE *)(v5 + 104) != 1 )
return (char)v8;
goto LABEL_56;
}
LABEL_62:
*(_BYTE *)(v5 + 81) = 0;
v37 = *(_QWORD *)(v5 + 88);
if ( !v37 )
{
LOBYTE(v8) = sub_1007FF190(0);
if ( *(_BYTE *)(v5 + 104) != 1 )
return (char)v8;
goto LABEL_56;
}
v38 = *(unsigned int **)(v37 + 56);
v39 = *v38;
if ( *v38 )
{
v40 = *((const void ***)v38 + 2);
v65 = (unsigned __int64)&v40[v39 - 1];
do
{
v41 = *v40;
if ( !*v40 )
break;
v61 = v40;
if ( __dynamic_cast(
v41,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTouchHandler,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCTargetedTouchHandler,
0) )
{
v42 = *(_QWORD *)(v5 + 64);
v43 = 0;
v67 = v42;
if ( v42 )
{
v44 = *(unsigned int **)(v42 + 56);
if ( *v44 )
{
v45 = *((__int64 **)v44 + 2);
v62 = (unsigned __int64)&v45[*v44 - 1];
v43 = 0;
do
{
v46 = *v45;
if ( !*v45 )
break;
v70 = v43;
Priority = cocos2d::CCTouchHandler::getPriority(v46);
v48 = cocos2d::CCTouchHandler::getPriority((__int64)v41);
v49 = cocos2d::CCTouchHandler::getDelegate(v46);
if ( v49 == cocos2d::CCTouchHandler::getDelegate((__int64)v41) )
goto LABEL_66;
v43 = (unsigned int)(Priority < v48) + v70;
++v45;
}
while ( (unsigned __int64)v45 <= v62 );
}
}
}
else
{
v50 = *(_QWORD *)(v5 + 72);
v43 = 0;
v67 = v50;
if ( v50 )
{
v51 = *(unsigned int **)(v50 + 56);
if ( *v51 )
{
v52 = *((__int64 **)v51 + 2);
v63 = (unsigned __int64)&v52[*v51 - 1];
v43 = 0;
do
{
v53 = *v52;
if ( !*v52 )
break;
v71 = v43;
v54 = cocos2d::CCTouchHandler::getPriority(v53);
v55 = cocos2d::CCTouchHandler::getPriority((__int64)v41);
v56 = cocos2d::CCTouchHandler::getDelegate(v53);
if ( v56 == cocos2d::CCTouchHandler::getDelegate((__int64)v41) )
goto LABEL_66;
v43 = (unsigned int)(v54 < v55) + v71;
++v52;
}
while ( (unsigned __int64)v52 <= v63 );
}
}
}
sub_1007FF110(v67, v41, v43);
LABEL_66:
v40 = v61 + 1;
v5 = a1;
}
while ( (unsigned __int64)(v61 + 1) <= v65 );
v37 = *(_QWORD *)(v5 + 88);
}
LOBYTE(v8) = sub_1007FF190(v37);
if ( *(_BYTE *)(v5 + 104) == 1 )
{
LABEL_56:
*(_BYTE *)(v5 + 104) = 0;
sub_1007FF190(*(_QWORD *)(v5 + 72));
LOBYTE(v8) = sub_1007FF190(*(_QWORD *)(v5 + 64));
}
return (char)v8;
}