//
// GJRobotSprite::init from 0x5e6acc to 0x5e6ed0 (1028 bytes)
//
// 2 xrefs:
// > GJRobotSprite::init @ 0x5e6f06
// > GJSpiderSprite::init @ 0x5e7002
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:54:20 +0000
//
int __fastcall GJRobotSprite::init(int a1, const char *a2, int a3)
{
GameManager *v5; // r0
GameManager *IconRequestID; // r0
int **v7; // r0
cocos2d::CCTexture2D *Icon; // r0
const char *v9; // r1
cocos2d::CCSprite *v10; // r7
SpriteAnimationManager *v11; // r0
void (__fastcall *v12)(int, _BYTE *); // r5
int v13; // r5
int (__fastcall *v14)(int, _BYTE *); // r6
float v15; // s17
int v16; // r0
cocos2d::CCArray *v17; // r0
unsigned int v18; // r6
cocos2d::CCObject *v19; // r0
cocos2d::CCArray *v20; // r0
cocos2d::CCObject *v21; // r0
cocos2d::CCSprite *v22; // r0
int v23; // r0
int v24; // r3
bool v25; // zf
int v26; // r3
unsigned int v27; // r11
int v28; // r0
CCSpritePlus *v29; // r5
unsigned int v30; // r1
char *v31; // r2
unsigned int v32; // r3
unsigned int v33; // r2
std::logic_error *exception; // r4
char *v35; // r1
size_t v36; // r2
char *v37; // r1
char *v38; // r0
int v39; // r9
const cocos2d::CCRect *v40; // r2
cocos2d::CCObject *v41; // r8
float v42; // s17
int v43; // r0
const cocos2d::CCRect *v44; // r2
cocos2d::CCNode *v45; // r8
cocos2d::CCTexture2D *v46; // r1
int v47; // r0
int v48; // r1
int v49; // r0
int v50; // r8
void (__fastcall *v51)(int, _BYTE *); // r9
float v52; // s17
int v53; // r0
int v54; // r2
int v55; // r3
int v57; // [sp+4h] [bp-50h]
cocos2d::CCArray *v58; // [sp+8h] [bp-4Ch]
unsigned int v60; // [sp+14h] [bp-40h]
void (__fastcall *v61)(cocos2d::CCObject *, _BYTE *); // [sp+18h] [bp-3Ch]
_BYTE v62[8]; // [sp+2Ch] [bp-28h] BYREF
int v63; // [sp+34h] [bp-20h] BYREF
unsigned int v64; // [sp+38h] [bp-1Ch]
char *v65; // [sp+3Ch] [bp-18h]
int v66; // [sp+40h] [bp-14h] BYREF
int v67; // [sp+44h] [bp-10h]
char *v68; // [sp+48h] [bp-Ch]
v5 = (GameManager *)GameManager::sharedState((GameManager *)a1);
IconRequestID = (GameManager *)GameManager::getIconRequestID(v5);
*(_DWORD *)(a1 + 596) = IconRequestID;
v7 = (int **)GameManager::sharedState(IconRequestID);
Icon = (cocos2d::CCTexture2D *)GameManager::loadIcon(v7, (int)a2, *(_DWORD *)(a1 + 592), *(_DWORD *)(a1 + 596));
if ( (*(_BYTE *)a3 & 1) != 0 )
v9 = *(const char **)(a3 + 8);
else
v9 = (const char *)(a3 + 1);
v10 = Icon;
v57 = CCAnimatedSprite::initWithType((CCAnimatedSprite *)a1, v9, Icon, (cocos2d::CCTexture2D *)((char *)&dword_0 + 1));
if ( v57 )
{
v11 = *(SpriteAnimationManager **)(a1 + 532);
*(_BYTE *)(a1 + 471) = 1;
SpriteAnimationManager::stopAnimations(v11);
v12 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)a1 + 160);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v62, 30.0, 30.0);
v12(a1, v62);
v13 = *(_DWORD *)(a1 + 544);
v14 = *(int (__fastcall **)(int, _BYTE *))(*(_DWORD *)v13 + 92);
v15 = *(float *)(*(int (__fastcall **)(int))(*(_DWORD *)a1 + 164))(a1);
v16 = (*(int (__fastcall **)(int))(*(_DWORD *)a1 + 164))(a1);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v62, v15 * 0.5, *(float *)(v16 + 4) * 0.5);
v17 = (cocos2d::CCArray *)v14(v13, v62);
v18 = 0;
v19 = (cocos2d::CCObject *)cocos2d::CCArray::create(v17);
*(_DWORD *)(a1 + 580) = v19;
v20 = (cocos2d::CCArray *)cocos2d::CCObject::retain(v19);
v21 = (cocos2d::CCObject *)cocos2d::CCArray::create(v20);
*(_DWORD *)(a1 + 568) = v21;
v22 = (cocos2d::CCSprite *)cocos2d::CCObject::retain(v21);
v23 = cocos2d::CCSprite::create(v22);
*(_DWORD *)(a1 + 584) = v23;
(*(void (__fastcall **)(_DWORD, int, int))(**(_DWORD **)(a1 + 544) + 232))(*(_DWORD *)(a1 + 544), v23, -1);
(*(void (__fastcall **)(_DWORD, _DWORD))(**(_DWORD **)(a1 + 584) + 172))(*(_DWORD *)(a1 + 584), 0);
*(_BYTE *)(*(_DWORD *)(a1 + 584) + 471) = 1;
v24 = *(_DWORD *)(a1 + 592);
v25 = v24 == 6;
if ( v24 == 6 )
v26 = 12;
else
v26 = 11;
v60 = v26;
if ( v25 )
v27 = 10;
else
v27 = 9;
v58 = *(cocos2d::CCArray **)(*(_DWORD *)(a1 + 544) + 528);
while ( 1 )
{
if ( v18 >= cocos2d::CCArray::count(v58) )
{
GJRobotSprite::updateFrame((GJRobotSprite *)a1, a2);
v66 = 0;
v67 = 0;
v68 = nullptr;
std::string::__init(&v66, "idle", 4u);
CCAnimatedSprite::runAnimation(a1, (int)&v66, v54, v55);
std::string::~string((int)&v66);
return v57;
}
v28 = cocos2d::CCArray::objectAtIndex(v58, v18);
*(_BYTE *)(v28 + 518) = 1;
v63 = 0;
v29 = (CCSpritePlus *)v28;
v64 = 0;
v65 = nullptr;
if ( (*(_BYTE *)(v28 + 520) & 1) != 0 )
{
std::string::__init(&v63, *(const void **)(v28 + 528), *(_DWORD *)(v28 + 524));
}
else
{
v30 = *(_DWORD *)(v28 + 524);
v31 = *(char **)(v28 + 528);
v63 = *(_DWORD *)(v28 + 520);
v64 = v30;
v65 = v31;
}
if ( (v63 & 1) != 0 )
{
v32 = v64;
if ( !v64 )
goto LABEL_43;
}
else
{
v32 = (int)(unsigned __int8)v63 >> 1;
if ( !v32 )
goto LABEL_43;
}
if ( v32 < v60 )
{
v39 = -1;
}
else
{
v66 = 0;
v67 = 0;
v68 = nullptr;
if ( (v63 & 1) != 0 )
{
v33 = v64;
if ( v27 > v64 )
goto LABEL_25;
v35 = v65;
}
else
{
v33 = (int)(unsigned __int8)v63 >> 1;
if ( v27 > v33 )
{
LABEL_25:
exception = (std::logic_error *)_cxa_allocate_exception(8u);
std::logic_error::logic_error(exception, "basic_string");
*(_DWORD *)exception = &off_D1548C;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::out_of_range,
(void (*)(void *))std::length_error::~length_error);
}
v35 = (char *)&v63 + 1;
}
v36 = v33 - v27;
v37 = &v35[v27];
if ( v36 >= 2 )
v36 = 2;
std::string::__init(&v66, v37, v36);
if ( (v66 & 1) != 0 )
v38 = v68;
else
v38 = (char *)&v66 + 1;
v39 = atoi(v38);
std::string::~string((int)&v66);
}
(*(void (__fastcall **)(CCSpritePlus *, int))(*(_DWORD *)v29 + 36))(v29, v39);
v41 = (cocos2d::CCObject *)cocos2d::CCSprite::createWithTexture(v10, (cocos2d::CCTexture2D *)&unk_D2C510, v40);
(*(void (__fastcall **)(CCSpritePlus *, cocos2d::CCObject *, int))(*(_DWORD *)v29 + 232))(v29, v41, -1);
v61 = *(void (__fastcall **)(cocos2d::CCObject *, _BYTE *))(*(_DWORD *)v41 + 92);
v42 = *(float *)(*(int (__fastcall **)(CCSpritePlus *))(*(_DWORD *)v29 + 164))(v29);
v43 = (*(int (__fastcall **)(CCSpritePlus *))(*(_DWORD *)v29 + 164))(v29);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v62, v42 * 0.5, *(float *)(v43 + 4) * 0.5);
v61(v41, v62);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 580), v41);
v45 = (cocos2d::CCNode *)cocos2d::CCSprite::createWithTexture(v10, (cocos2d::CCTexture2D *)&unk_D2C510, v44);
(*(void (__fastcall **)(_DWORD, cocos2d::CCNode *, int))(**(_DWORD **)(a1 + 584) + 232))(
*(_DWORD *)(a1 + 584),
v45,
-1);
CCSpritePlus::addFollower(v29, v45);
*((_BYTE *)v29 + 517) = 1;
if ( *(_DWORD *)(a1 + 592) == 5 && v18 == 6 )
*(_DWORD *)(a1 + 604) = v29;
if ( v39 == 1 )
*(_DWORD *)(a1 + 600) = v29;
if ( v29 == *(CCSpritePlus **)(a1 + 600) && !*(_DWORD *)(a1 + 588) )
{
v47 = cocos2d::CCSprite::createWithTexture(v10, v46);
*(_DWORD *)(a1 + 588) = v47;
v48 = v47;
v49 = *(_DWORD *)(a1 + 600);
*(_BYTE *)(a1 + 572) = 0;
(*(void (__fastcall **)(int, int, int))(*(_DWORD *)v49 + 232))(v49, v48, 2);
v50 = *(_DWORD *)(a1 + 588);
v51 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v50 + 92);
v52 = *(float *)(*(int (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 600) + 164))(*(_DWORD *)(a1 + 600));
v53 = (*(int (__fastcall **)(_DWORD))(**(_DWORD **)(a1 + 600) + 164))(*(_DWORD *)(a1 + 600));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v62, v52 * 0.5, *(float *)(v53 + 4) * 0.5);
v51(v50, v62);
(*(void (__fastcall **)(_DWORD, _DWORD))(**(_DWORD **)(a1 + 588) + 172))(
*(_DWORD *)(a1 + 588),
*(unsigned __int8 *)(a1 + 572));
}
LABEL_43:
++v18;
std::string::~string((int)&v63);
}
}
return v57;
}