//
// CCTextInputNode::updateCursorPosition from 0x3e2078 to 0x3e2454 (988 bytes)
//
// 5 xrefs:
// > CCTextInputNode::moveCursorVertical @ 0x3e25ba
// > CCTextInputNode::ccTouchBegan @ 0x3e269e
// > CCTextInputNode::ccTouchEnded @ 0x3e273a
// > CCTextInputNode::holdTimerFired @ 0x3e27d6
// > CCTextInputNode::rightClick @ 0x3e28bc
//
// 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:47:02 +0000
//
float __fastcall CCTextInputNode::updateCursorPosition(int a1, float *a2)
{
float v2; // s0
const char *v5; // r0
const char *v6; // r6
size_t v7; // r0
int v8; // r6
int v9; // r1
float result; // r0
cocos2d::CCLabelBMFont *v11; // r4
int v12; // r8
int v13; // r0
int v14; // r3
cocos2d::CCArray *v15; // r7
float v16; // s16
unsigned int v17; // r8
signed int v18; // r10
int v19; // r1
cocos2d::CCLabelBMFont *v20; // r2
unsigned int v21; // r2
int v22; // r0
cocos2d::CCArray *v23; // r0
int v24; // r0
int v25; // r0
unsigned int v26; // r11
cocos2d::CCArray *v27; // r10
int v28; // r2
float v29; // s18
float v30; // s17
const cocos2d::CCPoint *v31; // r7
float v32; // s16
int i; // r7
int v34; // r0
cocos2d::CCSprite *v35; // r0
float v36; // s19
float v37; // s16
const char *v38; // r0
size_t v39; // r0
int v40; // r1
int v41; // r0
int v42; // r3
char *v43; // r3
int v44; // r3
signed int v45; // r9
float v46; // s19
signed int v47; // r3
int v48; // r4
int v49; // r0
int v50; // r2
int v51; // r3
int v52; // r0
signed int v53; // [sp+4h] [bp-48h]
const char *v54; // [sp+4h] [bp-48h]
int v55; // [sp+8h] [bp-44h]
unsigned int v56; // [sp+8h] [bp-44h]
int v57; // [sp+8h] [bp-44h]
int v58; // [sp+8h] [bp-44h]
cocos2d::CCSprite *v59; // [sp+14h] [bp-38h]
_BYTE v60[8]; // [sp+1Ch] [bp-30h] BYREF
float v61[2]; // [sp+24h] [bp-28h] BYREF
int v62[3]; // [sp+2Ch] [bp-20h] BYREF
int v63; // [sp+38h] [bp-14h] BYREF
int v64; // [sp+3Ch] [bp-10h]
char *v65; // [sp+40h] [bp-Ch]
*(_DWORD *)(a1 + 456) = -1082130432;
v5 = (const char *)(*(int (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 416) + 624))(*(_DWORD *)(a1 + 416));
memset(v62, 0, sizeof(v62));
v6 = v5;
v7 = strlen(v5);
std::string::__init(v62, v6, v7);
v63 = 0;
v64 = 0;
v65 = nullptr;
std::string::__init(&v63, &unk_B6B226, 0);
v8 = sub_3DC1CE((unsigned __int8 *)v62, (unsigned __int8 *)&v63);
std::string::~string((int)&v63);
std::string::~string((int)v62);
if ( v8 )
goto LABEL_25;
result = COERCE_FLOAT(cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v60));
v11 = *(cocos2d::CCLabelBMFont **)(a1 + 428);
if ( v11 )
{
v12 = 0;
v13 = (*(int (__fastcall **)(_DWORD))(*(_DWORD *)v11 + 96))(*(_DWORD *)(a1 + 428));
cocos2d::CCPoint::operator=(v60, v13);
}
else
{
v14 = *(_DWORD *)(a1 + 436);
if ( !v14 )
return result;
v15 = *(cocos2d::CCArray **)(*(_DWORD *)(v14 + 520) + 536);
if ( !cocos2d::CCArray::count(v15) )
goto LABEL_25;
if ( cocos2d::CCArray::count(v15) == 1 )
{
v12 = 0;
v11 = (cocos2d::CCLabelBMFont *)cocos2d::CCArray::objectAtIndex(v15, 0);
}
else
{
v16 = -1.0;
v17 = 0;
v18 = 0;
v8 = cocos2d::CCArray::count(v15);
while ( v17 < cocos2d::CCArray::count(v15) )
{
v55 = cocos2d::CCArray::objectAtIndex(v15, v17);
sub_3DC2FC(v55, v19);
v20 = (cocos2d::CCLabelBMFont *)v55;
v2 = fabsf(v2 - a2[1]);
if ( v2 < v16 )
{
v18 = v17;
}
else if ( v16 < 0.0 )
{
v18 = v17;
}
else
{
v2 = v16;
v20 = v11;
}
++v17;
v16 = v2;
v11 = v20;
}
if ( v18 )
{
v21 = 0;
v12 = 0;
do
{
v56 = v21;
v22 = cocos2d::CCArray::objectAtIndex(v15, v21);
v23 = (cocos2d::CCArray *)(*(int (__fastcall **)(int))(*(_DWORD *)v22 + 244))(v22);
v24 = cocos2d::CCArray::count(v23);
v21 = v56 + 1;
v12 += v24;
}
while ( (int)(v56 + 1) < v18 );
}
else
{
v12 = 0;
}
}
v25 = (*(int (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 96))(v11);
cocos2d::CCPoint::operator=(v60, v25);
}
v29 = *a2;
v30 = 1.0;
v31 = (const cocos2d::CCPoint *)(*(int (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 256))(v11);
(*(void (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 96))(v11);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)v61, v31);
v32 = v61[0];
for ( i = (*(int (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 256))(v11);
i;
i = (*(int (__fastcall **)(int))(*(_DWORD *)i + 256))(i) )
{
v30 = v30 * COERCE_FLOAT((*(int (__fastcall **)(int))(*(_DWORD *)i + 68))(i));
}
v26 = 0;
v27 = (cocos2d::CCArray *)(*(int (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 244))(v11);
while ( v26 < cocos2d::CCArray::count(v27) )
{
v34 = cocos2d::CCArray::objectAtIndex(v27, v26);
if ( (*(int (__fastcall **)(int))(*(_DWORD *)v34 + 176))(v34) )
++i;
++v26;
}
v53 = i;
if ( !i )
{
LABEL_25:
v28 = -1;
*(_DWORD *)(*(_DWORD *)(a1 + 416) + 608) = -1;
return COERCE_FLOAT(CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1, v9, v28));
}
v35 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v27, i - 1);
v36 = COERCE_FLOAT(cocos2d::CCLabelBMFont::getLetterPosXRight(v11, v35, 0.0)) * v30;
v37 = v32 - (float)(v36 * *(float *)(*(int (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_DWORD *)v11 + 152))(v11));
if ( v8 > 1 )
{
v38 = (const char *)(*(int (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 416) + 624))(*(_DWORD *)(a1 + 416));
v63 = 0;
v64 = 0;
v65 = nullptr;
v54 = v38;
v39 = strlen(v38);
std::string::__init(&v63, v54, v39);
v40 = v12 + i - 1;
if ( *(int *)(a1 + 372) > 0 )
v40 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v40);
v41 = sub_3DC656((unsigned __int8 *)&v63, v40);
if ( (v63 & 1) != 0 )
v42 = v64;
else
v42 = (int)(unsigned __int8)v63 >> 1;
if ( v41 >= v42 )
{
v53 = i - 1;
}
else
{
if ( (v63 & 1) != 0 )
v43 = v65;
else
v43 = (char *)&v63 + 1;
if ( v43[v41] == 10 )
v44 = i - 1;
else
v44 = i;
v53 = v44;
}
std::string::~string((int)&v63);
}
v45 = 0;
v57 = 0;
while ( 1 )
{
v59 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v27, v45);
result = COERCE_FLOAT((*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)v59 + 176))(v59));
if ( result != 0.0 )
break;
LABEL_68:
if ( ++v45 >= i )
goto LABEL_69;
}
result = COERCE_FLOAT(cocos2d::CCLabelBMFont::getLetterPosXRight(v11, v59, *(float *)(a1 + 352)));
v46 = v37 + (float)(result * v30);
if ( v29 > v46 )
{
if ( v45 == i - 1 && v8 > 1 )
{
v50 = *(_DWORD *)(a1 + 372);
v51 = *(_DWORD *)(a1 + 416);
if ( v50 <= 0 )
{
v52 = v53 + v12;
}
else
{
v58 = *(_DWORD *)(a1 + 416);
v52 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v53 + v12);
v51 = v58;
}
*(_DWORD *)(v51 + 608) = v52;
result = COERCE_FLOAT(CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1, v9, v50));
v57 = 1;
}
goto LABEL_68;
}
result = COERCE_FLOAT(cocos2d::CCLabelBMFont::getLetterPosXLeft(v11, v59));
v47 = v53;
if ( (float)(v46 - v29) < (float)(v29 - (float)(v37 + (float)(result * v30))) )
++v45;
if ( v53 >= v45 )
v47 = v45;
if ( v47 < i || v8 > 1 )
{
v28 = *(_DWORD *)(a1 + 372);
v9 = v47 + v12;
v48 = *(_DWORD *)(a1 + 416);
if ( v28 <= 0 )
v49 = v47 + v12;
else
v49 = CCTextInputNode::displayToRawIndex((CCTextInputNode *)a1, v9);
*(_DWORD *)(v48 + 608) = v49;
return COERCE_FLOAT(CCTextInputNode::updateBlinkLabel((CCTextInputNode *)a1, v9, v28));
}
LABEL_69:
if ( !v57 )
goto LABEL_25;
return result;
}