//
// cocos2d::CCLabelBMFont::initWithString from 0x5cdb6c to 0x5cdd8a (542 bytes)
//
// 4 xrefs:
// > CCCounterLabel::init @ 0x2e59d4
// > cocos2d::CCLabelBMFont::create @ 0x5cdde6
// > cocos2d::CCLabelBMFont::createBatched @ 0x5cdf50
// > cocos2d::CCLabelBMFont::init @ 0x5cdfb6
//
// 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
//
bool cocos2d::CCLabelBMFont::initWithString(
cocos2d::CCLabelBMFont *a1,
const char *a2,
const char *a3,
float a4,
cocos2d::CCTextAlignment a5,
cocos2d::CCPoint a6)
{
cocos2d::CCBMFontConfiguration *File; // r0
_BOOL4 v11; // r5
cocos2d::CCBMFontConfiguration *m_pConfiguration; // r0
cocos2d::CCTextureCache *v13; // r0
cocos2d::CCTexture2D *v14; // r7
_BOOL4 m_bIsBatched; // r10
__int16 v16; // r2
int v17; // r2
bool v18; // r3
int v19; // r2
bool v20; // r3
cocos2d::CCLabelBMFont_vtbl *v21; // r3
size_t v22; // r0
__int16 v23; // r2
cocos2d::CCTexture2D *v24; // r0
int v25; // r2
bool v26; // r3
int v27; // r2
bool v28; // r3
cocos2d::CCSprite *v29; // r9
cocos2d::CCSprite_vtbl *v30; // r3
cocos2d::CCTexture2D *v31; // r11
bool (__fastcall *initWithTexture_1)(cocos2d::CCSprite *__hidden, cocos2d::CCTexture2D *, const cocos2d::CCRect *, bool); // [sp+8h] [bp-24h]
cocos2d::CCRect v34; // [sp+14h] [bp-18h] BYREF
if ( a3 )
{
File = cocos2d::FNTConfigLoadFile(a3);
v11 = (_BOOL4)File;
if ( !File )
{
cocos2d::CCObject::release(a1);
return v11;
}
cocos2d::CCObject::retain(File);
m_pConfiguration = a1->m_pConfiguration;
if ( m_pConfiguration )
cocos2d::CCObject::release(m_pConfiguration);
a1->m_pConfiguration = (cocos2d::CCBMFontConfiguration *)v11;
sub_7753D4((int)&a1->m_sFntFile, (char *)a3);
v13 = cocos2d::CCTextureCache::sharedTextureCache();
v14 = cocos2d::CCTextureCache::addImage(v13, (const char *)a1->m_pConfiguration->m_sAtlasName.m_data.m_data, 0);
}
else
{
v14 = (cocos2d::CCTexture2D *)operator new(0x60u);
cocos2d::CCTexture2D::CCTexture2D(v14);
cocos2d::CCObject::autorelease(v14);
}
if ( !a2 )
a2 = (const char *)&unk_939830;
m_bIsBatched = a1->m_bIsBatched;
if ( a1->m_bIsBatched )
{
v11 = cocos2d::CCNode::init(a1);
if ( v11 )
{
a1->m_cRealOpacity = -1;
a1->m_cDisplayedOpacity = -1;
a1->m_fWidth = a4;
a1->m_bCascadeOpacityEnabled = 1;
a1->m_bCascadeColorEnabled = 1;
a1->m_pAlignment = a5;
*(_WORD *)&a1->m_tRealColor.r = -1;
v16 = *(_WORD *)&a1->m_tRealColor.r;
a1->m_tRealColor.b = -1;
a1->m_tDisplayedColor.b = -1;
*(_WORD *)&a1->m_tDisplayedColor.r = v16;
cocos2d::CCSize::operator=(&a1->m_obContentSize, &stru_AC8B78.width);
a1->m_bIsOpacityModifyRGB = 1;
cocos2d::CCPoint::CCPoint(&v34.origin, 0.5, 0.5);
cocos2d::CCPoint::operator=(&a1->m_obAnchorPoint, &v34.origin.x, v17, v18);
cocos2d::CCPoint::operator=(&a1->m_tImageOffset, (float *)LODWORD(a6.x), v19, v20);
v21 = a1->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_pSomeTexture = v14;
v21->setString_0(a1, (const unsigned __int8 *)a2, 0);
return v11;
}
}
else
{
v22 = strlen(a2);
v11 = cocos2d::CCSpriteBatchNode::initWithTexture(a1, v14, v22);
if ( v11 )
{
a1->m_cRealOpacity = -1;
a1->m_cDisplayedOpacity = -1;
a1->m_fWidth = a4;
a1->m_pAlignment = a5;
a1->m_bCascadeOpacityEnabled = 1;
a1->m_bCascadeColorEnabled = 1;
*(_WORD *)&a1->m_tRealColor.r = -1;
v23 = *(_WORD *)&a1->m_tRealColor.r;
a1->m_tRealColor.b = -1;
a1->m_tDisplayedColor.b = -1;
*(_WORD *)&a1->m_tDisplayedColor.r = v23;
cocos2d::CCSize::operator=(&a1->m_obContentSize, &stru_AC8B78.width);
v24 = a1->m_pobTextureAtlas->getTexture(a1->m_pobTextureAtlas);
a1->m_bIsOpacityModifyRGB = cocos2d::CCTexture2D::hasPremultipliedAlpha(v24);
cocos2d::CCPoint::CCPoint(&v34.origin, 0.5, 0.5);
cocos2d::CCPoint::operator=(&a1->m_obAnchorPoint, &v34.origin.x, v25, v26);
cocos2d::CCPoint::operator=(&a1->m_tImageOffset, (float *)LODWORD(a6.x), v27, v28);
v29 = (cocos2d::CCSprite *)operator new(0x1FCu);
cocos2d::CCSprite::CCSprite(v29);
v30 = v29->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_pReusedChar = v29;
initWithTexture_1 = v30->initWithTexture_1;
v31 = a1->m_pobTextureAtlas->getTexture(a1->m_pobTextureAtlas);
cocos2d::CCRect::CCRect(&v34, 0.0, 0.0, 0.0, 0.0);
initWithTexture_1(v29, v31, &v34, m_bIsBatched);
a1->m_pReusedChar->setBatchNode(a1->m_pReusedChar, a1);
a1->setString_0(a1, (const unsigned __int8 *)a2, 1);
return v11;
}
}
LOBYTE(v11) = 0;
return v11;
}