//
// CCTextInputNode::updateCursorPosition from 0x10016e2fc to 0x10016e754 (1112 bytes)
//
// 1 xrefs:
// > CCTextInputNode::ccTouchBegan @ 0x10016e8e0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
void __fastcall CCTextInputNode::updateCursorPosition(CCTextInputNode *a1, cocos2d::CCPoint a2, cocos2d::CCRect a3)
{
float *v3; // x1
float *v4; // x21
char *v6; // x0
_BOOL4 v7; // w20
cocos2d::CCLabelBMFont *m_textLabel; // x20
double *v9; // x0
__n128 v10; // q0
int v11; // w25
float v12; // s9
cocos2d::CCNode *v13; // x21
const cocos2d::CCPoint *v14; // x0
float v15; // s10
__int64 v16; // x21
__int64 v17; // x22
unsigned int v18; // w27
unsigned int v19; // w26
__int64 v20; // x0
int v21; // w24
cocos2d::CCSprite *v22; // x0
float LetterPosXRight; // s8
__int64 v24; // x22
char v25; // w28
float v26; // s8
int v27; // w26
cocos2d::CCSprite *v28; // x24
float v29; // s10
TextArea *m_textArea; // x8
cocos2d::CCArray *m_lines; // x23
int v32; // w22
float v33; // s0
unsigned int v34; // w9
int v35; // w1
CCTextInputNode *v36; // x0
int v37; // w27
__int64 v38; // x24
float v39; // s8
__int64 v40; // x25
cocos2d::CCNode *v41; // x26
const cocos2d::CCPoint *v42; // x0
__int64 v43; // x0
float v44; // s0
_BOOL4 v45; // w8
__int64 v46; // x24
__int64 v47; // x0
__int64 v48; // x0
double *v49; // x0
bool v50; // [xsp+Ch] [xbp-A4h]
void *__p[2]; // [xsp+10h] [xbp-A0h] BYREF
char v52; // [xsp+27h] [xbp-89h]
void *v53[2]; // [xsp+28h] [xbp-88h] BYREF
char v54; // [xsp+3Fh] [xbp-71h]
cocos2d::CCPoint v55; // 0:kr00_8.8
cocos2d::CCPoint v56; // 0:kr08_8.8
v4 = v3;
v6 = (char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, __n128, __n128, __n128, __n128, __n128, __n128))a1->m_textField->getString)(
a1->m_textField,
*(__n128 *)&a2.x,
*(__n128 *)&a2.y,
(__n128)a3,
*(__n128 *)((char *)&a3 + 4),
*(__n128 *)&a3.size.width,
*(__n128 *)&a3.size.height);
sub_100009900(v53, v6);
sub_100009900(__p, "");
v7 = sub_1000045BC(v53, __p);
if ( v52 < 0 )
operator delete(__p[0]);
if ( v54 < 0 )
{
operator delete(v53[0]);
if ( v7 )
goto LABEL_30;
}
else if ( v7 )
{
goto LABEL_30;
}
sub_1000229B0(v53);
m_textLabel = a1->m_textLabel;
if ( m_textLabel )
{
v9 = (double *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(a1->m_textLabel);
v10.n128_f64[0] = sub_1000229D0(v53, v9);
v50 = 0;
v11 = 0;
goto LABEL_9;
}
m_textArea = a1->m_textArea;
if ( !m_textArea )
return;
m_lines = m_textArea->m_label->m_lines;
if ( !(unsigned int)sub_10024A36C(m_lines) )
goto LABEL_30;
if ( (unsigned int)sub_10024A36C(m_lines) == 1 )
{
m_textLabel = (cocos2d::CCLabelBMFont *)sub_10024A388(m_lines, 0);
v32 = 0;
}
else
{
v32 = sub_10024A36C(m_lines);
sub_10024A36C(m_lines);
m_textLabel = nullptr;
v37 = 0;
v38 = 0;
v39 = -1.0;
do
{
v40 = sub_10024A388(m_lines, v38);
v41 = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v40 + 496LL))(v40);
v42 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v40 + 192LL))(v40);
v56 = cocos2d::CCNode::convertToWorldSpace(v41, v42);
v43 = (*(__int64 (__fastcall **)(__int64, float, float))(*(_QWORD *)v40 + 312LL))(v40, v56.x, v56.y);
v44 = vabds_f32(
*((float *)__p + 1)
+ (float)((float)(*(float *)(v43 + 4) * 0.5)
* (*(float (__fastcall **)(__int64))(*(_QWORD *)v40 + 168LL))(v40)),
v4[1]);
v45 = v39 < 0.0;
if ( v44 < v39 )
v45 = 1;
if ( v45 )
{
v37 = v38;
v39 = v44;
m_textLabel = (cocos2d::CCLabelBMFont *)v40;
}
v38 = (unsigned int)(v38 + 1);
}
while ( (unsigned int)v38 < (unsigned int)sub_10024A36C(m_lines) );
if ( v37 >= 1 )
{
v11 = 0;
v46 = 0;
do
{
v47 = sub_10024A388(m_lines, v46);
v48 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v47 + 472LL))(v47);
v11 += sub_10024A36C(v48);
v46 = (unsigned int)(v46 + 1);
}
while ( v37 != (_DWORD)v46 );
goto LABEL_44;
}
}
v11 = 0;
LABEL_44:
v49 = (double *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(m_textLabel);
v10.n128_f64[0] = sub_1000229D0(v53, v49);
v50 = v32 > 1;
LABEL_9:
v12 = *v4;
v13 = (cocos2d::CCNode *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))m_textLabel->getParent)(
m_textLabel,
v10);
v14 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(m_textLabel);
v55 = cocos2d::CCNode::convertToWorldSpace(v13, v14);
v15 = *(float *)__p;
v16 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, float, float))m_textLabel->getChildren)(
m_textLabel,
v55.x,
v55.y);
if ( !(unsigned int)sub_10024A36C(v16) )
goto LABEL_30;
v17 = 0;
v18 = 0;
do
{
v19 = v18;
v20 = sub_10024A388(v16, v17);
v21 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v20 + 336LL))(v20);
v18 += v21;
v17 = (unsigned int)(v17 + 1);
}
while ( (unsigned int)v17 < (unsigned int)sub_10024A36C(v16) );
if ( !v18 )
goto LABEL_30;
v22 = (cocos2d::CCSprite *)sub_10024A388(v16, v18 - 1);
LetterPosXRight = cocos2d::CCLabelBMFont::getLetterPosXRight(m_textLabel, v22, 0.0, 0);
v24 = 0;
v25 = 0;
v26 = v15
- (float)(LetterPosXRight
* *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getAnchorPoint)(m_textLabel));
v27 = -v19 - v21;
while ( 1 )
{
v28 = (cocos2d::CCSprite *)sub_10024A388(v16, v24);
if ( ((unsigned int (__fastcall *)(cocos2d::CCSprite *))v28->isVisible)(v28) )
break;
LABEL_18:
v24 = (unsigned int)(v24 + 1);
if ( !(v27 + (_DWORD)v24) )
goto LABEL_29;
}
v29 = v26 + cocos2d::CCLabelBMFont::getLetterPosXRight(m_textLabel, v28, a1->m_fontValue2, a1->m_isChatFont);
if ( v12 > v29 )
{
if ( v27 + (_DWORD)v24 == -1 && v50 )
{
a1->m_textField->m_uCursorPos = v11 + v18;
CCTextInputNode::updateBlinkLabelToChar(a1, v11 + v18);
v25 = 1;
}
goto LABEL_18;
}
v33 = v12
- (float)(v26 + cocos2d::CCLabelBMFont::getLetterPosXLeft(m_textLabel, v28, a1->m_fontValue2, a1->m_isChatFont));
if ( (float)(v29 - v12) >= v33 )
v34 = v24;
else
v34 = v24 + 1;
if ( v34 < v18 )
{
v35 = v11 + ((float)(v29 - v12) < v33) + v24;
a1->m_textField->m_uCursorPos = v35;
v36 = a1;
goto LABEL_31;
}
LABEL_29:
if ( (v25 & 1) == 0 )
{
LABEL_30:
a1->m_textField->m_uCursorPos = -1;
v36 = a1;
v35 = -1;
LABEL_31:
CCTextInputNode::updateBlinkLabelToChar(v36, v35);
}
}