//
// LevelAreaLayer::addTorch from 0xa2eba0 to 0xa2f2c8 (1832 bytes)
//
// 5 xrefs:
// > LevelAreaLayer::init @ 0xa3016c
// > LevelAreaInnerLayer::init @ 0xa30ae4
// > LevelAreaInnerLayer::init @ 0xa3101c
// > SecretLayer5::init @ 0xa96728
// > ??> @ 0x9df38
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void LevelAreaLayer::addTorch(
cocos2d::CCNode *a1,
cocos2d::CCPoint a2,
int a3,
float a4,
int a5,
bool a6,
int a7,
cocos2d::CCArray *a8)
{
cocos2d::CCArray *v8; // x6
const cocos2d::CCPoint *v10; // x20
float x; // s8
char *v13; // x1
cocos2d::CCSprite *v14; // x21
cocos2d::CCSprite *v15; // x28
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // x20
float v17; // s0
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x20
__int64 v19; // x0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v21)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
cocos2d::CCArray *v22; // x0
unsigned int v23; // w20
cocos2d::CCArray *v24; // x26
cocos2d::CCArray *v25; // x25
unsigned int i; // w19
cocos2d::CCSpriteFrameCache *v27; // x22
cocos2d::CCString *v28; // x0
const char *CString; // x0
cocos2d::CCSpriteFrame *v30; // x0
cocos2d::CCSpriteFrameCache *v31; // x22
cocos2d::CCString *v32; // x0
const char *v33; // x0
cocos2d::CCSpriteFrame *v34; // x0
cocos2d::CCAnimation *v35; // x0
cocos2d::CCAnimate *v36; // x0
cocos2d::CCRepeatForever *v37; // x0
cocos2d::CCAnimation *v38; // x0
cocos2d::CCAnimate *v39; // x0
cocos2d::CCRepeatForever *v40; // x0
cocos2d::CCSprite *v41; // x22
void (__fastcall *v42)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
__int64 v43; // x19
float v44; // s8
void (__fastcall *v45)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
cocos2d::CCFadeTo *v46; // x0
cocos2d::CCEaseInOut *v47; // x19
cocos2d::CCFadeTo *v48; // x0
cocos2d::CCEaseInOut *v49; // x0
cocos2d::CCActionInterval *v50; // x0
cocos2d::CCRepeatForever *v51; // x0
cocos2d::CCScaleTo *v52; // x0
cocos2d::CCActionInterval *v53; // x0
cocos2d::CCEaseInOut *v54; // x19
cocos2d::CCActionInterval *v55; // x0
cocos2d::CCEaseInOut *v56; // x0
cocos2d::CCActionInterval *v57; // x0
cocos2d::CCRepeatForever *v58; // x0
cocos2d::CCSprite *v59; // x26
__int64 v60; // x19
cocos2d::CCSprite *v61; // x19
void (__fastcall *v62)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
__int64 v63; // x25
void (__fastcall *v64)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
char *p_m_fBrVertexMod; // x0
void (__fastcall *v66)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v67)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v68)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v69)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
unsigned int *p_m_fTextureTop; // x2
int m_fTextureTop_low; // w1
int v72; // [xsp+84h] [xbp+84h]
cocos2d::CCArray *v73; // [xsp+88h] [xbp+88h]
int v74; // [xsp+90h] [xbp+90h]
_BOOL4 v75; // [xsp+94h] [xbp+94h]
cocos2d::CCString *v76; // [xsp+98h] [xbp+98h]
cocos2d::CCSprite *v77; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v78; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v79; // [xsp+B0h] [xbp+B0h] BYREF
v10 = *(const cocos2d::CCPoint **)&a3;
v75 = a6;
v74 = (unsigned __int8)a7;
v72 = (int)a8;
v73 = v8;
x = a2.x;
if ( a5 == 2 )
v13 = "Fire_02_looped_001.png";
else
v13 = "Fire_01_looped_001.png";
sub_D153B8((int)&v77, v13);
v14 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v77);
a1->addChild_0(a1, v14, v75 - 2);
v14->setPosition(v14, v10);
v14->setScale(v14, x);
v15 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v77);
a1->addChild_0(a1, v15, v75 - 3);
setScale = v15->setScale;
v17 = v14->getScale(v14);
setScale(v15, v17 + v17);
setPosition = v15->setPosition;
v19 = (__int64)v14->getPosition(v14);
setPosition(v15, (const cocos2d::CCPoint *)v19);
setColor = v14->setColor;
LOBYTE(v79) = -1;
*(_WORD *)((char *)&v79 + 1) = 50;
setColor(v14, (const cocos2d::ccColor3B *)&v79);
v21 = v15->setColor;
LOWORD(v79) = -1;
BYTE2(v79) = 0;
v22 = (cocos2d::CCArray *)((__int64 (__fastcall *)(cocos2d::CCSprite *, __int64 *))v21)(v15, &v79);
if ( a5 == 2 )
v23 = 2;
else
v23 = 1;
v24 = (cocos2d::CCArray *)cocos2d::CCArray::create(v22);
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create(v24);
for ( i = 1; i != 10; ++i )
{
v27 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v28 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Fire_0%i_looped_%03i.png",
(const char *)v23,
i);
CString = cocos2d::CCString::getCString(v28);
v30 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v27, CString);
cocos2d::CCArray::addObject(v24, v30);
v31 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v32 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Fire_0%i_2_looped_%03i.png",
(const char *)v23,
i);
v33 = cocos2d::CCString::getCString(v32);
v34 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v31, v33);
cocos2d::CCArray::addObject(v25, v34);
}
v35 = cocos2d::CCAnimation::createWithSpriteFrames(v24, 0.08);
v36 = cocos2d::CCAnimate::create(v35);
v37 = cocos2d::CCRepeatForever::create(v36);
cocos2d::CCNode::runAction(v14, v37);
v38 = cocos2d::CCAnimation::createWithSpriteFrames(v25, 0.08);
v39 = cocos2d::CCAnimate::create(v38);
v40 = cocos2d::CCRepeatForever::create(v39);
cocos2d::CCNode::runAction(v15, v40);
v41 = cocos2d::CCSprite::createWithSpriteFrameName("towerShine.png");
v42 = v41->setPosition;
v43 = (__int64)v14->getPosition(v14);
cocos2d::CCPoint::CCPoint(&v78, 0.0, -10.0);
cocos2d::CCPoint::operator+(&v79, v43, &v78);
v42(v41, (const cocos2d::CCPoint *)&v79);
a1->addChild_0(a1, v41, v75 - 1);
v44 = x + x;
v41->setScale(v41, v44 * 1.2);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v41->setBlendFunc)(v41, 0x100000302LL);
v41->setOpacity(v41, 4294967180LL);
v45 = v41->setColor;
LOBYTE(v79) = -1;
*(_WORD *)((char *)&v79 + 1) = 200;
v45(v41, (const cocos2d::ccColor3B *)&v79);
v46 = cocos2d::CCFadeTo::create(1.6, (unsigned __int8)&qword_70);
v47 = cocos2d::CCEaseInOut::create(v46, 1.3);
v48 = cocos2d::CCFadeTo::create(1.6, 0x9Du);
v49 = cocos2d::CCEaseInOut::create(v48, 1.3);
v50 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v47, v49, 0);
v51 = cocos2d::CCRepeatForever::create(v50);
v52 = (cocos2d::CCScaleTo *)cocos2d::CCNode::runAction(v41, v51);
v53 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create(v52, 1.0, v44);
v54 = cocos2d::CCEaseInOut::create(v53, 1.5);
v55 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create((cocos2d::CCScaleTo *)v54, 1.0, v44 * 1.2);
v56 = cocos2d::CCEaseInOut::create(v55, 1.5);
v57 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v54, v56, 0);
v58 = cocos2d::CCRepeatForever::create(v57);
cocos2d::CCNode::runAction(v41, v58);
if ( !v74 )
{
v59 = cocos2d::CCSprite::createWithSpriteFrameName("towerTorch_001.png");
a1->addChild_0(a1, v59, v75);
v76 = (cocos2d::CCString *)v59->setPosition;
v60 = (__int64)v14->getPosition(v14);
cocos2d::CCPoint::CCPoint(&v78, 0.5, -18.0);
cocos2d::CCPoint::operator+(&v79, v60, &v78);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v76)(v59, &v79);
}
v61 = cocos2d::CCSprite::createWithSpriteFrameName("towerShine.png");
v62 = v61->setPosition;
v63 = (__int64)v14->getPosition(v14);
cocos2d::CCPoint::CCPoint(&v78, 0.0, -14.0);
cocos2d::CCPoint::operator+(&v79, v63, &v78);
v62(v61, (const cocos2d::CCPoint *)&v79);
a1->addChild_0(a1, v61, v75 + 1);
v61->setScale(v61, v44 * 0.6);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v61->setBlendFunc)(v61, 0x100000302LL);
v61->setOpacity(v61, 122);
v64 = v61->setColor;
LOBYTE(v79) = -1;
*(_WORD *)((char *)&v79 + 1) = 150;
v64(v61, (const cocos2d::ccColor3B *)&v79);
if ( v72 == 1 )
{
v66 = v14->setColor;
LOWORD(v79) = 50;
BYTE2(v79) = 127;
v66(v14, (const cocos2d::ccColor3B *)&v79);
v67 = v15->setColor;
LOWORD(v79) = 10837;
BYTE2(v79) = -40;
v67(v15, (const cocos2d::ccColor3B *)&v79);
v68 = v41->setColor;
LOWORD(v79) = 12950;
BYTE2(v79) = -1;
v68(v41, (const cocos2d::ccColor3B *)&v79);
v69 = v61->setColor;
LOWORD(v79) = 130;
BYTE2(v79) = -1;
v69(v61, (const cocos2d::ccColor3B *)&v79);
}
if ( v73 )
{
cocos2d::CCArray::addObject(v73, v14);
cocos2d::CCArray::addObject(v73, v15);
cocos2d::CCArray::addObject(v73, v41);
cocos2d::CCArray::addObject(v73, v61);
}
p_m_fBrVertexMod = (char *)&v77[-1].m_fBrVertexMod;
if ( (__int64 *)&v77[-1].m_fBrVertexMod != &qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_fTextureTop = (unsigned int *)&v77[-1].m_fTextureTop;
do
m_fTextureTop_low = __ldaxr(p_m_fTextureTop);
while ( __stlxr(m_fTextureTop_low - 1, p_m_fTextureTop) );
}
else
{
m_fTextureTop_low = LODWORD(v77[-1].m_fTextureTop);
LODWORD(v77[-1].m_fTextureTop) = m_fTextureTop_low - 1;
}
if ( m_fTextureTop_low <= 0 )
operator delete(p_m_fBrVertexMod);
}
}