//
// CCTextInputNode::updateCursorPosition from 0x5a5038 to 0x5a55d0 (1432 bytes)
//
// 2 xrefs:
// > CCTextInputNode::ccTouchBegan @ 0x5a5798
// > ??> @ 0x78108
//
// 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 CCTextInputNode::updateCursorPosition(CCTextInputNode *a1, cocos2d::CCPoint a2, cocos2d::CCRect a3)
{
float *v3; // x1
float *v4; // x27
char *v6; // x0
_DWORD *v7; // x22
_DWORD *v8; // x25
unsigned __int64 v9; // x20
unsigned __int64 v10; // x28
size_t v11; // x2
int v12; // w19
__int64 v13; // x20
__int64 *v14; // x0
char *v15; // x0
cocos2d::CCLabelBMFont *m_textLabel; // x22
cocos2d::CCLabelBMFont_vtbl *v17; // x1
cocos2d::CCLabelBMFont *v18; // x0
int v19; // w25
signed int v20; // w20
float v21; // s0
unsigned int v22; // w24
float v23; // s1
float v24; // s10
cocos2d::CCNode *v25; // x19
const cocos2d::CCPoint *v26; // x0
float v27; // s8
cocos2d::CCArray *v28; // x19
unsigned int v29; // w1
__int64 v30; // x0
unsigned int v31; // w28
cocos2d::CCSprite *v32; // x0
float LetterPosXRight; // s0
float v34; // s9
cocos2d::CCSprite *v35; // x27
float v36; // s8
float LetterPosXLeft; // s0
signed int v38; // w3
unsigned int *v39; // x25
int v40; // w1
unsigned int *v41; // x22
int v42; // w1
TextArea *m_textArea; // x0
cocos2d::CCArray *m_lines; // x19
unsigned int v45; // w28
float v46; // s9
__int64 v47; // x25
cocos2d::CCNode *v48; // x20
const cocos2d::CCPoint *v49; // x0
float v50; // s8
float v51; // s0
signed int v52; // w28
unsigned int v53; // w1
__int64 v54; // x0
cocos2d::CCArray *v55; // x0
int v56; // [xsp+88h] [xbp+88h]
int v57; // [xsp+8Ch] [xbp+8Ch]
signed int v58; // [xsp+90h] [xbp+90h]
void *v59; // [xsp+B8h] [xbp+B8h] BYREF
void *v60; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCPoint v61; // 0:kr00_8.8
cocos2d::CCPoint v62; // 0:kr08_8.8
v4 = v3;
v6 = (char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *, long double, long double, long double, long double, long double, long double))a1->m_textField->getString)(
a1->m_textField,
*(long double *)&a2.x,
*(long double *)&a2.y,
*(long double *)&a3,
*(long double *)((char *)&a3 + 4),
*(long double *)&a3.size.width,
*(long double *)&a3.size.height);
sub_D153B8((int)&v59, v6);
sub_D153B8((int)&v60, &byte_F288A0);
v7 = v59;
v8 = v60;
v9 = *((_QWORD *)v59 - 3);
v10 = *((_QWORD *)v60 - 3);
if ( v10 > v9 )
v11 = *((_QWORD *)v59 - 3);
else
v11 = *((_QWORD *)v60 - 3);
v12 = memcmp(v59, v60, v11);
if ( v12 || (v12 = 0x7FFFFFFF, v13 = v9 - v10, v13 > 0x7FFFFFFF) )
{
v14 = (__int64 *)(v8 - 6);
if ( v8 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
LABEL_33:
if ( &pthread_create )
{
v39 = v8 - 2;
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *(v8 - 2);
*(v8 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v14);
v7 = v59;
v15 = (char *)v59 - 24;
if ( (char *)v59 - 24 == (char *)&qword_124B6B0 )
goto LABEL_8;
goto LABEL_39;
}
v14 = (__int64 *)(v8 - 6);
if ( v13 >= (__int64)0xFFFFFFFF80000000LL )
v12 = v13;
else
v12 = 0x80000000;
if ( v14 != &qword_124B6B0 )
goto LABEL_33;
LABEL_7:
v15 = (char *)(v7 - 6);
if ( v7 - 6 != (_DWORD *)&qword_124B6B0 )
{
LABEL_39:
if ( &pthread_create )
{
v41 = v7 - 2;
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(v7 - 2);
*(v7 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v15);
}
LABEL_8:
if ( !v12 )
goto LABEL_27;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59);
m_textLabel = a1->m_textLabel;
if ( m_textLabel )
{
v17 = m_textLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v18 = a1->m_textLabel;
v56 = 0;
v19 = 0;
}
else
{
m_textArea = a1->m_textArea;
if ( !m_textArea )
return;
m_lines = m_textArea->m_label->m_lines;
if ( !(unsigned int)cocos2d::CCArray::count(m_lines) )
goto LABEL_27;
if ( (unsigned int)cocos2d::CCArray::count(m_lines) == 1 )
{
v56 = 0;
v19 = 0;
m_textLabel = (cocos2d::CCLabelBMFont *)cocos2d::CCArray::objectAtIndex(m_lines, 0);
}
else
{
v58 = 0;
v45 = 0;
v56 = cocos2d::CCArray::count(m_lines);
v46 = -1.0;
while ( v45 < (unsigned int)cocos2d::CCArray::count(m_lines) )
{
v47 = cocos2d::CCArray::objectAtIndex(m_lines, v45);
v48 = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v47 + 496LL))(v47);
v49 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v47 + 192LL))(v47);
v62 = cocos2d::CCNode::convertToWorldSpace(v48, v49);
v50 = *(float *)((*(__int64 (__fastcall **)(__int64, float, float))(*(_QWORD *)v47 + 312LL))(v47, v62.x, v62.y)
+ 4);
v51 = vabds_f32(
*((float *)&v60 + 1)
+ (float)((float)(v50 * 0.5) * (*(float (__fastcall **)(__int64))(*(_QWORD *)v47 + 168LL))(v47)),
v4[1]);
if ( v46 > v51 )
{
v58 = v45;
m_textLabel = (cocos2d::CCLabelBMFont *)v47;
v46 = v51;
++v45;
}
else
{
if ( v46 < 0.0 )
{
v58 = v45;
m_textLabel = (cocos2d::CCLabelBMFont *)v47;
v46 = v51;
}
++v45;
}
}
if ( v58 )
{
v52 = 0;
v19 = 0;
do
{
v53 = v52++;
v54 = cocos2d::CCArray::objectAtIndex(m_lines, v53);
v55 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v54 + 472LL))(v54);
v19 += cocos2d::CCArray::count(v55);
}
while ( v52 < v58 );
}
else
{
v19 = 0;
}
}
v17 = m_textLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v18 = m_textLabel;
}
v20 = 0;
v21 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v17->getPosition)(v18);
v22 = 0;
cocos2d::CCPoint::operator=(&v59, v21, v23);
v24 = *v4;
v25 = m_textLabel->getParent(m_textLabel);
v26 = m_textLabel->getPosition(m_textLabel);
v61 = cocos2d::CCNode::convertToWorldSpace(v25, v26);
v27 = *(float *)&v60;
v28 = (cocos2d::CCArray *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, float, float))m_textLabel->getChildren)(
m_textLabel,
v61.x,
v61.y);
while ( v22 < (unsigned int)cocos2d::CCArray::count(v28) )
{
v29 = v22++;
v30 = cocos2d::CCArray::objectAtIndex(v28, v29);
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v30 + 336LL))(v30) )
++v20;
}
if ( !v20 )
goto LABEL_27;
v31 = 0;
v57 = 0;
v32 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v28, v20 - 1);
LetterPosXRight = cocos2d::CCLabelBMFont::getLetterPosXRight(m_textLabel, v32, 0.0, 0);
v34 = v27 - (float)(LetterPosXRight * m_textLabel->getAnchorPoint(m_textLabel)->x);
while ( 1 )
{
v35 = (cocos2d::CCSprite *)cocos2d::CCArray::objectAtIndex(v28, v31);
if ( v35->isVisible(v35) )
break;
LABEL_17:
if ( v20 <= (int)++v31 )
goto LABEL_26;
}
v36 = v34 + cocos2d::CCLabelBMFont::getLetterPosXRight(m_textLabel, v35, a1->m_fontValue2, a1->m_isChatFont);
if ( v24 > v36 )
{
if ( v20 - 1 == v31 && v56 > 1 )
{
v57 = 1;
a1->m_textField->m_uCursorPos = v31 + v19 + 1;
CCTextInputNode::updateBlinkLabel(a1);
}
goto LABEL_17;
}
LetterPosXLeft = cocos2d::CCLabelBMFont::getLetterPosXLeft(m_textLabel, v35, a1->m_fontValue2, a1->m_isChatFont);
v38 = v31 + 1;
if ( (float)(v36 - v24) >= (float)(v24 - (float)(v34 + LetterPosXLeft)) )
v38 = v31;
if ( v38 < v20 )
{
a1->m_textField->m_uCursorPos = v38 + v19;
CCTextInputNode::updateBlinkLabel(a1);
return;
}
LABEL_26:
if ( v57 )
return;
LABEL_27:
a1->m_textField->m_uCursorPos = -1;
CCTextInputNode::updateBlinkLabel(a1);
}