//
// CCTextInputNode::updateBlinkLabelToChar from 0x10009eea0 to 0x10009f2f0 (1104 bytes)
//
// 7 xrefs:
// > CCTextInputNode::updateLabel @ 0x10009e8a4
// > CCTextInputNode::updateBlinkLabel @ 0x10009edf2
// > CCTextInputNode::onTextFieldInsertText @ 0x10009f768
// > CCTextInputNode::onTextFieldAttachWithIME @ 0x10009ff64
// > CCTextInputNode::updateCursorPosition @ 0x1000a0a57
// > CCTextInputNode::updateCursorPosition @ 0x1000a0aad
// > CCTextInputNode::updateCursorPosition @ 0x1000a0d74
//
// 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
//
void __fastcall CCTextInputNode::updateBlinkLabelToChar(CCTextInputNode *a1, int a2)
{
int v2; // r14d
CCTextInputNode *v3; // r15
cocos2d::CCLabelBMFont *m_textLabel; // rbx
cocos2d::CCLabelBMFont **p_m_cursor; // r13
float v6; // xmm0_4
TextArea *m_textArea; // rax
cocos2d::CCArray *m_lines; // r12
unsigned int v9; // r13d
int v10; // r15d
__int64 v11; // rax
int v12; // eax
bool v13; // cc
const cocos2d::CCPoint *v14; // r12
const cocos2d::CCPoint *v15; // rsi
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // r12
cocos2d::CCSprite *v19; // rsi
double v20; // xmm0_8
_DWORD *v21; // rax
const char *v22; // r15
size_t v23; // rax
size_t v24; // r14
char *v25; // r12
size_t v26; // r13
cocos2d::CCLabelBMFont *v27; // r14
float *v28; // rax
float v29; // xmm0_4
cocos2d::CCLabelBMFont *v30; // r14
__int64 v31; // rax
size_t v32; // r14
_BYTE v33[4]; // [rsp+0h] [rbp-70h] BYREF
float v34; // [rsp+4h] [rbp-6Ch]
float v35; // [rsp+8h] [rbp-68h]
float v36; // [rsp+Ch] [rbp-64h]
size_t __dst; // [rsp+10h] [rbp-60h] BYREF
size_t v38; // [rsp+18h] [rbp-58h]
void *__p; // [rsp+20h] [rbp-50h]
float v40; // [rsp+2Ch] [rbp-44h]
__int64 v41; // [rsp+30h] [rbp-40h]
CCTextInputNode *v42; // [rsp+38h] [rbp-38h]
float v43; // [rsp+44h] [rbp-2Ch]
v2 = a2;
v3 = a1;
m_textLabel = a1->m_textLabel;
if ( m_textLabel )
{
if ( !a1->m_cursor )
return;
p_m_cursor = &a1->m_cursor;
v6 = -1.0;
LABEL_14:
v43 = v6;
v17 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getChildren)(m_textLabel);
if ( v2 < 0 || (v18 = v17, (unsigned int)sub_100720070(v17) <= v2) )
{
v21 = (_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getContentSize)(m_textLabel);
*(_QWORD *)&v20 = (unsigned int)*v21;
LODWORD(v41) = *v21;
LODWORD(v42) = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getScale)(m_textLabel);
*(float *)&v20 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getScaleX)(m_textLabel);
*(float *)&v20 = *(float *)&v20 + *(float *)&v20;
*(float *)&v42 = (float)(*(float *)&v42 * *(float *)&v41) + *(float *)&v20;
}
else
{
v19 = (cocos2d::CCSprite *)sub_1007200C0(v18, (unsigned int)v2);
LODWORD(v42) = cocos2d::CCLabelBMFont::getLetterPosXLeft(m_textLabel, v19, v3->m_fontValue2, v3->m_isChatFont);
*(_QWORD *)&v20 = LODWORD(v3->m_fontValue1);
*(float *)&v41 = v3->m_fontValue1;
*(float *)&v20 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getScaleX)(m_textLabel);
*(float *)&v20 = (float)(*(float *)&v20 * *(float *)&v41) + *(float *)&v42;
LODWORD(v42) = LODWORD(v20);
}
v22 = (const char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *))v3->m_textField->getString)(v3->m_textField);
v23 = strlen(v22);
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v20);
v24 = v23;
if ( v23 >= 0x17 )
{
v41 = (__int64)p_m_cursor;
v26 = 26;
if ( (v23 | 7) != 0x17 )
v26 = (v23 | 7) + 1;
v25 = (char *)operator new(v26);
__p = v25;
__dst = v26 + 1;
p_m_cursor = (cocos2d::CCLabelBMFont **)v41;
v38 = v24;
}
else
{
LOBYTE(__dst) = 2 * v23;
v25 = (char *)&__dst + 1;
if ( !v23 )
{
LABEL_26:
v25[v24] = 0;
if ( (__dst & 1) != 0 )
{
v32 = v38;
operator delete(__p);
if ( v32 )
goto LABEL_29;
}
else if ( (unsigned __int8)__dst >> 1 )
{
LABEL_29:
v27 = *p_m_cursor;
v41 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(m_textLabel);
v40 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getContentSize)(m_textLabel);
v28 = (float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getAnchorPoint)(m_textLabel);
v40 = (float)(1.0 - *v28) * v40;
v35 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getScale)(m_textLabel);
v36 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getContentSize)(m_textLabel);
v29 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getScale)(m_textLabel);
sub_10028CBE0(v33, (float)((float)(v35 * v40) - (float)(v29 * v36)) + *(float *)&v42, v43);
sub_10028CCE0(&__dst, v41);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, size_t *))v27->setPosition)(v27, &__dst);
v30 = *p_m_cursor;
v31 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getAnchorPoint)(m_textLabel);
sub_10028CBE0(&__dst, 0.5, *(float *)(v31 + 4));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, size_t *))v30->setAnchorPoint)(v30, &__dst);
return;
}
LODWORD(v42) = 0x40000000;
goto LABEL_29;
}
}
memmove(v25, v22, v24);
goto LABEL_26;
}
m_textArea = a1->m_textArea;
if ( m_textArea && a1->m_cursor )
{
if ( a2 >= 0 )
{
v42 = a1;
m_lines = m_textArea->m_label->m_lines;
if ( (unsigned int)sub_100720070(m_lines) )
{
v9 = 0;
v10 = a2;
while ( 1 )
{
m_textLabel = (cocos2d::CCLabelBMFont *)sub_1007200C0(m_lines, v9);
v11 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getChildren)(m_textLabel);
v12 = sub_100720070(v11);
v13 = v10 <= v12;
v10 -= v12;
if ( v13 )
break;
++v9;
v2 = v10;
if ( v9 >= (unsigned int)sub_100720070(m_lines) )
goto LABEL_11;
}
v3 = v42;
goto LABEL_13;
}
LABEL_11:
v3 = v42;
m_textArea = v42->m_textArea;
}
m_textLabel = (cocos2d::CCLabelBMFont *)sub_1007200E0(m_textArea->m_label->m_lines);
v3->m_textField->m_uCursorPos = -1;
v2 = -1;
LABEL_13:
p_m_cursor = &v3->m_cursor;
v14 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getParent)(m_textLabel);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(m_textLabel);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)&__dst, v14);
v43 = *((float *)&__dst + 1);
v15 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(TextArea *))v3->m_textArea->getParent)(v3->m_textArea);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)v33, v15);
v43 = v43 - v34;
v16 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))m_textLabel->getPosition)(m_textLabel);
v6 = (float)(v43 - *(float *)(v16 + 4)) + -1.0;
goto LABEL_14;
}
}