//
// GJTransformControl::snapToNearestVertex from 0xbd1be0 to 0xbd1e00 (544 bytes)
//
// 3 xrefs:
// > GJTransformControl::ccTouchBegan @ 0xbd21cc
// > GJTransformControl::ccTouchMoved @ 0xbd2c6c
// > ??> @ 0xae1c0
//
// 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 13:03:37 +0000
//
cocos2d::CCPoint *__usercall GJTransformControl::snapToNearestVertex@(
__int64 a1@,
const cocos2d::CCPoint *a2@,
cocos2d::CCPoint *a3@)
{
const cocos2d::CCPoint *v6; // x21
cocos2d::CCPoint *v7; // x19
cocos2d::CCPoint *v8; // x0
__int64 i; // x19
__int64 v10; // x0
__int64 v11; // x1
_WORD *v12; // x0
__int64 v13; // x27
int v14; // w28
GameToolbox *v15; // x0
float v16; // s8
GameManager *v17; // x0
__int64 v18; // x0
float v19; // s8
const cocos2d::CCPoint *v20; // x2
float v21; // s0
__int64 v23; // [xsp+78h] [xbp+78h] BYREF
__int64 v24; // [xsp+80h] [xbp+80h] BYREF
_DWORD v25[10]; // [xsp+88h] [xbp+88h]
_WORD v26[32]; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v27; // [xsp+F0h] [xbp+F0h] BYREF
__int64 v28; // [xsp+F8h] [xbp+F8h] BYREF
v25[0] = 6;
v25[1] = 7;
v25[2] = 8;
v25[3] = 9;
v25[4] = 2;
v25[5] = 3;
v25[6] = 4;
v25[7] = 5;
v6 = (const cocos2d::CCPoint *)v26;
v7 = (cocos2d::CCPoint *)v26;
v25[8] = 1;
do
{
v8 = v7;
v7 = (cocos2d::CCPoint *)((char *)v7 + 8);
cocos2d::CCPoint::CCPoint(v8);
}
while ( v7 != (cocos2d::CCPoint *)&v28 );
for ( i = 0; i != 8; ++i )
{
v10 = GJTransformControl::spriteByTag((cocos2d::CCArray **)a1, v25[i]);
v11 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v10 + 192LL))(v10);
v12 = &v26[i * 4];
cocos2d::CCPoint::operator=(v12, v11);
}
v13 = 0;
cocos2d::CCPoint::operator+(&v24, v26);
v14 = 0;
cocos2d::CCPoint::operator/(&v23, &v24, 2.0);
cocos2d::CCPoint::operator=(&v27, &v23);
v15 = (GameToolbox *)cocos2d::CCPoint::CCPoint(a3, a2);
v16 = GameToolbox::touchUnitsForMM(v15, 3.0);
v18 = GameManager::sharedState(v17);
v19 = v16
/ (*(float (__fastcall **)(_QWORD))(**(_QWORD **)(*(_QWORD *)(v18 + 552) + 3920LL) + 168LL))(*(_QWORD *)(*(_QWORD *)(v18 + 552) + 3920LL));
do
{
while ( 1 )
{
cocos2d::CCNode::convertToWorldSpace(&v24, *(cocos2d::CCNode **)(a1 + 408), v6);
cocos2d::CCNode::convertToNodeSpace(&v23, (cocos2d::CCNode *)a1, (const cocos2d::CCPoint *)&v24);
cocos2d::ccpDistance(a2, (const cocos2d::CCPoint *)&v23, v20);
if ( v25[v13] == *(_DWORD *)(a1 + 632) )
v21 = v21 / 1.5;
if ( v21 < v19 )
break;
++v13;
v6 = (const cocos2d::CCPoint *)((char *)v6 + 8);
if ( v13 == 9 )
goto LABEL_11;
}
v19 = v21;
v14 = v25[v13++];
v6 = (const cocos2d::CCPoint *)((char *)v6 + 8);
cocos2d::CCPoint::operator=(a3, &v23);
}
while ( v13 != 9 );
LABEL_11:
*(_DWORD *)(a1 + 632) = v14;
return a3;
}