//
// CCTextInputNode::updateCursorPosition from 0x1400583a0 to 0x140058a77 (1751 bytes)
//
// 6 xrefs:
// > CCTextInputNode::moveCursorVertical @ 0x14005836b
// > CCTextInputNode::ccTouchBegan @ 0x140058d16
// > CCTextInputNode::ccTouchEnded @ 0x140058df5
// > CCTextInputNode::holdTimerFired @ 0x1400590d1
// > CCTextInputNode::rightClick @ 0x1400592f6
// > ??> @ 0x14091049c
//
// 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 11:25:41 +0000
//
// Hidden C++ exception states: #wind=2
void __fastcall CCTextInputNode::updateCursorPosition(__int64 a1, float *a2)
{
__int64 v2; // rsi
signed int v3; // r14d
_BYTE *v4; // rax
size_t v5; // r8
void **v6; // rcx
char *v7; // rbx
unsigned __int64 v8; // r15
size_t v9; // r12
size_t v10; // r8
int v11; // edi
char *v12; // rax
int v13; // r12d
struct cocos2d::CCObject *v14; // r13
cocos2d::CCLabelBMFont *v15; // r15
__int64 v16; // rax
__int64 v17; // rax
cocos2d::CCArray *v18; // rdi
float v19; // xmm7_4
int v20; // r12d
unsigned int v21; // ebx
unsigned __int32 v22; // xmm8_4
struct cocos2d::CCObject *v23; // r15
float v24; // xmm6_4
float v25; // xmm0_4
signed int v26; // ebx
int v27; // r15d
struct cocos2d::CCObject *v28; // rax
cocos2d::CCArray *v29; // rax
__int64 v30; // rax
float v31; // xmm8_4
__int64 (__fastcall *v32)(cocos2d::CCLabelBMFont *); // rdi
__int64 v33; // rbx
__int64 v34; // rax
float v35; // xmm10_4
float v36; // xmm7_4
__int64 i; // rbx
cocos2d::CCArray *v38; // rdi
int v39; // r13d
unsigned int v40; // ebx
struct cocos2d::CCObject *v41; // rax
char v42; // al
int v43; // ecx
float *v44; // rbx
struct cocos2d::CCSprite *v45; // rax
float v46; // xmm10_4
signed int v47; // edi
_BYTE *v48; // rax
size_t v49; // r8
int v50; // r10d
__int128 *v51; // r11
__int128 *v52; // rdx
int v53; // r9d
int v54; // r8d
__int64 v55; // rdx
unsigned __int8 v56; // cl
__int64 v57; // rax
int v58; // eax
__int128 *v59; // rcx
struct cocos2d::CCSprite *v60; // rbx
float v61; // xmm6_4
int v62; // ecx
int v63; // ecx
char v64; // [rsp+38h] [rbp-D0h]
int v65; // [rsp+3Ch] [rbp-CCh]
int v66; // [rsp+40h] [rbp-C8h]
cocos2d::CCArray *v68; // [rsp+48h] [rbp-C0h]
__int64 v69; // [rsp+50h] [rbp-B8h] BYREF
_QWORD Buf2[5]; // [rsp+58h] [rbp-B0h] BYREF
__int128 v71; // [rsp+80h] [rbp-88h] BYREF
__int128 v72; // [rsp+90h] [rbp-78h]
void *Buf1[2]; // [rsp+A0h] [rbp-68h] BYREF
size_t v74; // [rsp+B0h] [rbp-58h]
unsigned __int64 v75; // [rsp+B8h] [rbp-50h]
v2 = a1;
v69 = a1;
*(_DWORD *)(a1 + 664) = -1082130432;
memset(&Buf2[1], 0, 24);
v3 = 0;
Buf2[4] = 15;
LOBYTE(Buf2[1]) = 0;
v4 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(*(_QWORD *)(a1 + 592) + 600LL) + 8LL))(*(_QWORD *)(a1 + 592) + 600LL);
*(_OWORD *)Buf1 = 0;
v74 = 0;
v75 = 0;
v5 = -1;
do
++v5;
while ( v4[v5] );
sub_14003D230(Buf1, v4, v5);
v6 = Buf1;
v7 = (char *)Buf1[0];
v8 = v75;
if ( v75 > 0xF )
v6 = (void **)Buf1[0];
v9 = v74;
v10 = v74;
if ( v74 )
v10 = 0;
v11 = memcmp(v6, &Buf2[1], v10);
if ( !v11 )
v11 = v9 != 0;
if ( v8 > 0xF )
{
v12 = v7;
if ( v8 + 1 >= 0x1000 )
{
v7 = *((char **)v7 - 1);
if ( (unsigned __int64)(v12 - v7 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v7);
}
if ( !v11 )
goto LABEL_77;
v13 = 0;
v65 = 0;
v66 = 0;
v14 = nullptr;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Buf2);
v15 = *(cocos2d::CCLabelBMFont **)(v2 + 616);
if ( v15 )
{
v16 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)v15 + 200LL))(*(_QWORD *)(v2 + 616));
cocos2d::CCPoint::operator=(Buf2, v16);
LABEL_34:
v31 = *a2;
v32 = *(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v15 + 504LL);
v33 = (*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v15 + 200LL))(v15);
v34 = v32(v15);
cocos2d::CCNode::convertToWorldSpace(v34, &v69, v33);
v35 = *(float *)&v69;
v36 = 1.0;
for ( i = (*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v15 + 504LL))(v15);
i;
i = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)i + 504LL))(i) )
{
v36 = v36 * (*(float (__fastcall **)(__int64))(*(_QWORD *)i + 128LL))(i);
}
v64 = 0;
v38 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v15 + 480LL))(v15);
v68 = v38;
v39 = 0;
v40 = 0;
if ( !cocos2d::CCArray::count(v38) )
goto LABEL_77;
do
{
v41 = cocos2d::CCArray::objectAtIndex(v38, v40);
v42 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v41 + 344LL))(v41);
v43 = v39 + 1;
if ( !v42 )
v43 = v39;
v39 = v43;
++v40;
}
while ( v40 < cocos2d::CCArray::count(v38) );
if ( v39 <= 0 )
goto LABEL_77;
v44 = (float *)(*(__int64 (__fastcall **)(cocos2d::CCLabelBMFont *))(*(_QWORD *)v15 + 296LL))(v15);
v45 = cocos2d::CCArray::objectAtIndex(v38, v39 - 1);
v46 = v35 - (float)((float)(cocos2d::CCLabelBMFont::getLetterPosXRight(v15, v45, 0.0) * v36) * *v44);
v47 = v39;
if ( v66 <= 1 )
goto LABEL_68;
v48 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(*(_QWORD *)(v2 + 592) + 600LL) + 8LL))(*(_QWORD *)(v2 + 592) + 600LL);
v71 = 0;
v72 = 0;
v49 = -1;
do
++v49;
while ( v48[v49] );
sub_14003D230(&v71, v48, v49);
v50 = v39 + v13 - 1;
if ( *(int *)(v2 + 520) > 0 )
v50 = CCTextInputNode::displayToRawIndex((_QWORD *)v2, v50);
v51 = &v71;
v52 = (__int128 *)v71;
if ( *((_QWORD *)&v72 + 1) > 0xFu )
v51 = (__int128 *)v71;
v53 = 0;
v54 = 0;
if ( v50 <= 0 )
goto LABEL_60;
v55 = 0;
while ( 1 )
{
if ( v55 >= (int)v72 )
{
LABEL_59:
v13 = v65;
v52 = (__int128 *)v71;
LABEL_60:
v58 = v72;
if ( v53 < (int)v72 )
v58 = v53;
if ( v58 >= (int)v72 )
goto LABEL_66;
v59 = &v71;
if ( *((_QWORD *)&v72 + 1) > 0xFu )
v59 = v52;
if ( *((_BYTE *)v59 + v58) == 10 )
LABEL_66:
v47 = v39 - 1;
sub_14003D310((__int64)&v71);
while ( 1 )
{
LABEL_68:
v60 = cocos2d::CCArray::objectAtIndex(v68, v3);
if ( (*(unsigned __int8 (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v60 + 344LL))(v60) )
{
v61 = (float)(cocos2d::CCLabelBMFont::getLetterPosXRight(v15, v60, *(float *)(v2 + 476)) * v36) + v46;
if ( v61 >= v31 )
{
if ( (float)(v31 - (float)((float)(cocos2d::CCLabelBMFont::getLetterPosXLeft(v15, v60) * v36) + v46)) > (float)(v61 - v31) )
++v3;
if ( v3 <= v47 )
v47 = v3;
if ( v47 < v39 || v66 > 1 )
{
v63 = v47 + v13;
if ( *(int *)(v2 + 520) > 0 )
v63 = CCTextInputNode::displayToRawIndex((_QWORD *)v2, v63);
*(_DWORD *)(*(_QWORD *)(v2 + 592) + 760LL) = v63;
goto LABEL_78;
}
LABEL_76:
if ( v64 )
return;
LABEL_77:
*(_DWORD *)(*(_QWORD *)(v2 + 592) + 760LL) = -1;
LABEL_78:
CCTextInputNode::updateBlinkLabelToChar(v2, *(_DWORD *)(*(_QWORD *)(v2 + 592) + 760LL));
return;
}
if ( v3 == v39 - 1 && v66 > 1 )
{
v62 = v47 + v13;
if ( *(int *)(v2 + 520) > 0 )
v62 = CCTextInputNode::displayToRawIndex((_QWORD *)v2, v62);
*(_DWORD *)(*(_QWORD *)(v2 + 592) + 760LL) = v62;
CCTextInputNode::updateBlinkLabelToChar(v2, *(_DWORD *)(*(_QWORD *)(v2 + 592) + 760LL));
v64 = 1;
}
}
if ( ++v3 >= v39 )
goto LABEL_76;
}
}
v56 = *((_BYTE *)v51 + v55);
if ( v56 < 0x80u )
break;
if ( (v56 & 0xE0) == 0xC0 )
{
v57 = 2;
}
else if ( (v56 & 0xF0) == 0xE0 )
{
v57 = 3;
}
else
{
v57 = 4;
if ( (v56 & 0xF8) != 0xF0 )
break;
}
LABEL_58:
v53 += v57;
v55 += v57;
if ( ++v54 >= v50 )
goto LABEL_59;
}
v57 = 1;
goto LABEL_58;
}
v17 = *(_QWORD *)(v2 + 632);
if ( v17 )
{
v18 = *(cocos2d::CCArray **)(*(_QWORD *)(v17 + 616) + 648LL);
if ( !cocos2d::CCArray::count(v18) )
goto LABEL_77;
if ( cocos2d::CCArray::count(v18) == 1 )
{
v14 = cocos2d::CCArray::objectAtIndex(v18, 0);
}
else
{
v19 = -1.0;
v20 = 0;
v66 = cocos2d::CCArray::count(v18);
v21 = 0;
if ( cocos2d::CCArray::count(v18) )
{
v22 = _mm_load_si128((const __m128i *)&xmmword_140836C90).m128i_u32[0];
do
{
v23 = cocos2d::CCArray::objectAtIndex(v18, v21);
v24 = a2[1];
LODWORD(v25) = COERCE_UNSIGNED_INT(sub_140058050((__int64)v23).m128_f32[0] - v24) & v22;
if ( v19 > v25 || v19 < 0.0 )
{
v19 = v25;
v14 = v23;
v20 = v21;
}
++v21;
}
while ( v21 < cocos2d::CCArray::count(v18) );
v2 = v69;
if ( v20 <= 0 )
{
v13 = 0;
}
else
{
v26 = 0;
v27 = 0;
do
{
v28 = cocos2d::CCArray::objectAtIndex(v18, v26);
v29 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v28 + 480LL))(v28);
v27 += cocos2d::CCArray::count(v29);
++v26;
}
while ( v26 < v20 );
v65 = v27;
v13 = v27;
}
}
else
{
v13 = 0;
}
}
v15 = v14;
v30 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v14 + 200LL))(v14);
cocos2d::CCPoint::operator=(Buf2, v30);
if ( v14 )
goto LABEL_34;
}
}