//
// GJTransformControl::snapToNearestVertex from 0x6ecd18 to 0x6ece50 (312 bytes)
//
// 2 xrefs:
// > GJTransformControl::ccTouchBegan @ 0x6ed130
// > GJTransformControl::ccTouchMoved @ 0x6ed46c
//
// 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 11:57:33 +0000
//
cocos2d::CCPoint *__fastcall GJTransformControl::snapToNearestVertex(
cocos2d::CCPoint *a1,
int a2,
const cocos2d::CCPoint *a3)
{
int v6; // r4
cocos2d::CCPoint *v7; // r0
int i; // r4
int v9; // r0
int v10; // r1
_BYTE *v11; // r0
int v12; // r6
float v13; // r1
float v14; // s16
int v15; // r0
float v16; // r0
int v17; // r3
float v18; // s16
const cocos2d::CCPoint *v19; // r2
float v20; // r0
float v21; // s17
int v23; // [sp+4h] [bp-14h]
int v24; // [sp+4h] [bp-14h]
_BYTE v25[8]; // [sp+8h] [bp-10h] BYREF
_BYTE v26[8]; // [sp+10h] [bp-8h] BYREF
_DWORD v27[9]; // [sp+18h] [bp+0h]
_BYTE v28[24]; // [sp+3Ch] [bp+24h] BYREF
_BYTE v29[40]; // [sp+54h] [bp+3Ch] BYREF
_BYTE v30[8]; // [sp+7Ch] [bp+64h] BYREF
v27[0] = 6;
v27[1] = 7;
v27[2] = 8;
v27[3] = 9;
v27[4] = 2;
v27[5] = 3;
v27[6] = 4;
v27[7] = 5;
v6 = 0;
v27[8] = 1;
do
{
v7 = (cocos2d::CCPoint *)&v28[v6];
v6 += 8;
cocos2d::CCPoint::CCPoint(v7);
}
while ( v6 != 72 );
for ( i = 0; i != 8; ++i )
{
v9 = GJTransformControl::spriteByTag((cocos2d::CCArray **)a2, v27[i]);
v10 = (*(int (__fastcall **)(int))(*(_DWORD *)v9 + 96))(v9);
v11 = &v28[8 * i];
cocos2d::CCPoint::operator=(v11, v10);
}
cocos2d::CCPoint::operator+(v26, v28, v29);
cocos2d::CCPoint::operator/(v25, v26, 0x40000000);
v12 = 0;
cocos2d::CCPoint::operator=(v30, v25);
cocos2d::CCPoint::CCPoint(a1, a3);
v14 = COERCE_FLOAT(GameToolbox::touchUnitsForMM((GameToolbox *)0x40400000, v13));
v15 = GameManager::sharedState((GameManager *)LODWORD(v14));
v16 = (*(float (__fastcall **)(_DWORD))(**(_DWORD **)(*(_DWORD *)(v15 + 408) + 2436) + 84))(*(_DWORD *)(*(_DWORD *)(v15 + 408) + 2436));
v17 = 0;
v18 = v14 / v16;
do
{
v23 = v17;
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)v26, *(const cocos2d::CCPoint **)(a2 + 316));
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v25, (const cocos2d::CCPoint *)a2);
v20 = COERCE_FLOAT(cocos2d::ccpDistance(a3, (const cocos2d::CCPoint *)v25, v19));
v17 = v23;
v21 = v20;
if ( v27[v12] == *(_DWORD *)(a2 + 488) )
v21 = v20 / 1.5;
if ( v21 < v18 )
{
v24 = v27[v12];
v18 = v21;
cocos2d::CCPoint::operator=(a1, v25);
v17 = v24;
}
++v12;
}
while ( v12 != 9 );
*(_DWORD *)(a2 + 488) = v17;
return a1;
}