//
// cocos2d::CCTextFieldTTF::deleteBackward from 0xb307c4 to 0xb30b28 (868 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'cocos2d::CCTextFieldTTF::deleteBackward @ 0xb30b2c
// > ??> @ 0x43998
// > ??> @ 0x121a080
//
// 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 cocos2d::CCTextFieldTTF::deleteBackward(cocos2d::CCTextFieldTTF *a1)
{
std::string *m_pInputText; // x20
stl::StringData::Internal *m_data; // x0
std::string *v4; // x25
unsigned __int64 v5; // x2
int v6; // w24
unsigned __int64 v7; // x19
int v8; // w26
unsigned __int64 v9; // x21
cocos2d::CCTextFieldDelegate *m_pDelegate; // x0
stl::StringData::Internal *v11; // x1
__int64 *v12; // x0
std::string *v13; // x0
std::string *m_pPlaceHolder; // x2
const char *v15; // x1
cocos2d::CCTextFieldDelegate *v16; // x0
int m_uCursorPos; // w0
unsigned __int8 *v18; // x0
unsigned int *v19; // x2
int v20; // w1
unsigned __int64 v21; // x3
unsigned __int64 v22; // x2
unsigned __int64 v23; // x3
unsigned __int64 v24; // x2
const unsigned __int8 *v25; // x1
void (__fastcall *setString)(cocos2d::CCTextFieldTTF *__hidden, const unsigned __int8 *); // x3
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
int v30; // w2
_BYTE v31[8]; // [xsp+58h] [xbp+58h] BYREF
const unsigned __int8 *v32; // [xsp+60h] [xbp+60h] BYREF
m_pInputText = a1->m_pInputText;
m_data = m_pInputText->m_data.m_data;
v4 = m_pInputText;
v5 = *((_QWORD *)m_pInputText->m_data.m_data - 3);
v6 = v5;
if ( !(_DWORD)v5 || !a1->m_uCursorPos )
return;
v7 = (int)v5 - 1;
if ( v7 >= v5 )
LABEL_42:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", v7, v5);
v8 = 1;
v9 = (int)v5 - 2LL - v7;
while ( 1 )
{
if ( (*((_DWORD *)m_data - 2) & 0x80000000) == 0 )
{
sub_D176A8(m_pInputText);
m_pInputText = a1->m_pInputText;
}
if ( (*((_BYTE *)v4->m_data.m_data + v7) & 0xC0) != 0x80 )
break;
m_data = m_pInputText->m_data.m_data;
v7 += v9;
++v8;
v4 = m_pInputText;
v5 = *((_QWORD *)m_pInputText->m_data.m_data - 3);
if ( v5 <= v7 )
goto LABEL_42;
}
m_pDelegate = a1->m_pDelegate;
if ( m_pDelegate )
{
if ( m_pDelegate->onTextFieldDeleteBackward(
m_pDelegate,
a1,
(const unsigned __int8 *)m_pInputText->m_data.m_data + v6 - (__int64)v8,
v8) )
{
return;
}
m_pInputText = a1->m_pInputText;
}
if ( v6 <= v8 )
{
if ( m_pInputText )
{
v11 = m_pInputText->m_data.m_data;
v12 = (__int64 *)((char *)m_pInputText->m_data.m_data - 24);
if ( v12 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)((char *)v11 - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v12);
}
operator delete(m_pInputText);
a1->m_pInputText = nullptr;
}
v13 = (std::string *)operator new(8u);
m_pPlaceHolder = a1->m_pPlaceHolder;
v13->m_data.m_data = (stl::StringData::Internal *)&byte_124B6C8;
a1->m_pInputText = v13;
v15 = (const char *)m_pPlaceHolder->m_data.m_data;
a1->m_nCharCount = 0;
cocos2d::CCLabelTTF::setString(a1, v15);
v16 = a1->m_pDelegate;
if ( v16 )
v16->textChanged(v16);
return;
}
m_uCursorPos = a1->m_uCursorPos;
if ( m_uCursorPos <= 0 || m_uCursorPos > a1->m_nCharCount )
{
sub_D1527C(&v32, m_pInputText->m_data.m_data, v7, v31);
a1->setString(a1, v32);
v18 = (unsigned __int8 *)(v32 - 24);
if ( v32 - 24 == (const unsigned __int8 *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v19 = (unsigned int *)(v32 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v32 - 2);
*((_DWORD *)v32 - 2) = v20 - 1;
}
if ( v20 > 0 )
return;
LABEL_26:
operator delete(v18);
return;
}
sub_D153B8((int)&v32, (char *)m_pInputText->m_data.m_data);
v21 = *((_QWORD *)v32 - 3);
v22 = a1->m_uCursorPos - 1;
if ( v22 > v21 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::erase", v22, v21);
v23 = v21 - v22;
if ( v8 > v23 )
v24 = v23;
else
v24 = v8;
sub_D174B8(&v32, a1->m_uCursorPos - 1, v24, 0);
v25 = v32;
setString = a1->setString;
--a1->m_uCursorPos;
setString(a1, v25);
v18 = (unsigned __int8 *)(v32 - 24);
if ( v32 - 24 != (const unsigned __int8 *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v32 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v32 - 2);
*((_DWORD *)v32 - 2) = v28 - 1;
}
if ( v28 <= 0 )
goto LABEL_26;
}
}