//
// CCTextInputNode::addTextArea from 0x10009e4a0 to 0x10009e696 (502 bytes)
//
// 4 xrefs:
// > EditLevelLayer::init @ 0x1001fb138
// > GJWriteMessagePopup::init @ 0x1002a94b6
// > GJWriteMessagePopup::init @ 0x1002a9835
// > ShareCommentLayer::init @ 0x1005e082a
//
// 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::addTextArea(CCTextInputNode *a1, TextArea *a2)
{
TextArea *m_textArea; // r14
const char *v4; // r15
size_t v5; // rax
size_t v6; // r14
char *v7; // r12
size_t v8; // r13
TextArea *v9; // rax
std::string *p_m_fontFile; // rax
char v11; // r15
size_t v12; // rax
char *v13; // rdi
void *v14; // r14
size_t v15; // rdx
int v16; // eax
char v17; // [rsp+8h] [rbp-78h] BYREF
_BYTE __s2[12]; // [rsp+9h] [rbp-77h] BYREF
char v19; // [rsp+15h] [rbp-6Bh]
size_t __n[2]; // [rsp+20h] [rbp-60h] BYREF
void *__s1; // [rsp+30h] [rbp-50h]
_QWORD __dst[2]; // [rsp+40h] [rbp-40h] BYREF
void *__p; // [rsp+50h] [rbp-30h]
if ( a1->m_textArea )
return;
a1->m_textArea = a2;
((void (__fastcall *)(CCTextInputNode *))a1->addChild)(a1);
m_textArea = a1->m_textArea;
sub_10028CBE0(&v17, 0.0, 0.0);
((void (__fastcall *)(TextArea *, char *))m_textArea->setPosition)(m_textArea, &v17);
((void (__fastcall *)(cocos2d::CCTextFieldTTF *, _QWORD))a1->m_textField->setVisible)(a1->m_textField, 0);
v4 = (const char *)((__int64 (__fastcall *)(cocos2d::CCTextFieldTTF *))a1->m_textField->getString)(a1->m_textField);
v5 = strlen(v4);
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v6 = v5;
if ( v5 >= 0x17 )
{
v8 = 26;
if ( (v5 | 7) != 0x17 )
v8 = (v5 | 7) + 1;
v7 = (char *)operator new(v8);
__p = v7;
__dst[0] = v8 + 1;
__dst[1] = v6;
}
else
{
LOBYTE(__dst[0]) = 2 * v5;
v7 = (char *)__dst + 1;
if ( !v5 )
goto LABEL_10;
}
memmove(v7, v4, v6);
LABEL_10:
v7[v6] = 0;
CCTextInputNode::updateLabel(a1, __dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
v9 = a1->m_textArea;
if ( (v9->m_fontFile.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(__n, v9->m_fontFile.m_data.m_long.longStorage, v9->m_fontFile.m_data.m_long.size, 0.0);
}
else
{
p_m_fontFile = &v9->m_fontFile;
__s1 = p_m_fontFile->m_data.m_long.longStorage;
*(_OWORD *)__n = *(_OWORD *)&p_m_fontFile->m_data.m_short.sizex2;
}
qmemcpy(__s2, "chatFont.fnt", sizeof(__s2));
v11 = __n[0];
v12 = LOBYTE(__n[0]) >> 1;
v13 = (char *)__n + 1;
v14 = __s1;
if ( (__n[0] & 1) != 0 )
v13 = (char *)__s1;
v19 = 0;
if ( (__n[0] & 1) != 0 )
v12 = __n[1];
v15 = 12;
if ( v12 < 0xC )
v15 = v12;
v16 = (v12 == 12) & (memcmp(v13, __s2, v15) == 0);
_mm_storel_ps(
(double *)&a1->m_fontValue1,
_mm_blendv_ps(
(__m128)0x41A000003FC00000uLL,
(__m128)xmmword_100815C80,
(__m128)_mm_slli_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v16), 80), 0x1Fu)));
a1->m_isChatFont = v16;
if ( (v11 & 1) != 0 )
operator delete(v14);
}