//
// ButtonSprite::init from 0x56fdf4 to 0x570178 (900 bytes)
//
// 2 xrefs:
// > ButtonSprite::create @ 0x570258
// > ??> @ 0xa5a20
//
// 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 ButtonSprite::init(
ButtonSprite *a1,
const char *a2,
int a3,
int a4,
float a5,
bool a6,
const char *a7,
const char *a8,
float a9)
{
bool v16; // w22
float v18; // s0
float v19; // s1
size_t v20; // x2
int v21; // w23
_DWORD *v22; // x4
char *v23; // x0
cocos2d::CCLabelBMFont *v24; // x0
cocos2d::extension::CCScale9Sprite *v25; // x23
void (__fastcall *setContentSize)(cocos2d::extension::CCScale9Sprite *__hidden, const cocos2d::CCSize *); // x24
float v27; // s0
float v28; // s1
unsigned int *v29; // x4
int v30; // w1
unsigned int *v31; // x5
int v32; // w1
unsigned __int64 v33; // [xsp+70h] [xbp+70h]
__int64 v34; // [xsp+78h] [xbp+78h]
_DWORD *v36; // [xsp+80h] [xbp+80h]
cocos2d::CCPoint origin; // [xsp+88h] [xbp+88h]
void *v39; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCRect v40; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCRect v41; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v16 = cocos2d::CCSprite::init(a1);
if ( v16 )
{
a1->m_mode = 1;
a1->m_absolute = a6;
a1->m_width = (float)a3;
a1->m_minWidth = (float)a4;
a1->m_scale = a5;
a1->m_height = a9;
cocos2d::CCPoint::CCPoint(&v40.origin, 0.0, 2.0);
cocos2d::CCPoint::operator=(&a1->m_textOffset, v18, v19);
sub_D153B8((int)&v39, (char *)a7);
sub_D153B8((int)&v40, "bigFont.fnt");
v36 = v39;
origin = v40.origin;
v33 = *((_QWORD *)v39 - 3);
if ( *(_QWORD *)(*(_QWORD *)&v40.origin - 24LL) > v33 )
v20 = *((_QWORD *)v39 - 3);
else
v20 = *(_QWORD *)(*(_QWORD *)&v40.origin - 24LL);
v34 = *(_QWORD *)(*(_QWORD *)&v40.origin - 24LL);
v21 = memcmp(v39, *(const void **)&v40.origin, v20);
v22 = v36;
if ( !v21 )
{
v21 = 0x7FFFFFFF;
if ( (__int64)(v33 - v34) <= 0x7FFFFFFF )
{
if ( (__int64)(v33 - v34) >= (__int64)0xFFFFFFFF80000000LL )
v21 = v33 - v34;
else
v21 = 0x80000000;
}
}
if ( (__int64 *)(*(_QWORD *)&origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(*(_QWORD *)&origin - 8LL);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *(_DWORD *)(*(_QWORD *)&origin - 8LL);
*(_DWORD *)(*(_QWORD *)&origin - 8LL) = v32 - 1;
}
if ( v32 <= 0 )
operator delete((void *)(*(_QWORD *)&origin - 24LL));
v22 = v39;
}
v23 = (char *)(v22 - 6);
if ( v22 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = v22 - 2;
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(v22 - 2);
*(v22 - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v23);
}
if ( !v21 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 0.0, 2.0);
cocos2d::CCPoint::CCPoint(&v40.origin, -1.0, *((float *)&v39 + 1));
cocos2d::CCPoint::operator=(&a1->m_textOffset, v27, v28);
}
v24 = cocos2d::CCLabelBMFont::create();
a1->m_label = v24;
a1->addChild_0(a1, v24, 1);
cocos2d::CCRect::CCRect(&v40, 0.0, 0.0, 40.0, 40.0);
v25 = (cocos2d::extension::CCScale9Sprite *)cocos2d::extension::CCScale9Sprite::create(
(cocos2d::extension::CCScale9Sprite *)a8,
(const char *)&v40,
v41);
a1->m_BGSprite = v25;
setContentSize = v25->setContentSize;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v40, 16.0, 16.0);
setContentSize(v25, (const cocos2d::CCSize *)&v40);
a1->addChild_0(a1, a1->m_BGSprite, 0);
ButtonSprite::setString(a1, a2);
}
return v16;
}