//
// GJRobotSprite::init from 0x1403ac7f0 to 0x1403acfbe (1998 bytes)
//
// 3 xrefs:
// > GJRobotSprite::create @ 0x1403ac7b3
// > GJSpiderSprite::create @ 0x1403adcc5
// > ??> @ 0x140923ae0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:31:21 +0000
//
// Hidden C++ exception states: #wind=8
char __fastcall GJRobotSprite::init(__int64 *a1, unsigned int a2, _QWORD *a3)
{
int v6; // r15d
__int64 v7; // rcx
unsigned int v8; // r9d
struct cocos2d::CCTexture2D *Icon; // rax
_BYTE *v10; // r14
struct cocos2d::CCTexture2D *v11; // rbx
__int64 v12; // rax
__int64 Definition; // rax
cocos2d::CCString *v14; // rax
const char *CString; // rax
size_t v16; // r8
void *v17; // rcx
const char *v18; // rbx
cocos2d::CCTextureCache *v19; // rax
char *v20; // r8
const struct cocos2d::CCRect *v21; // rax
__int64 v23; // rbx
cocos2d::CCNode *v24; // rcx
cocos2d::CCNode *v25; // rcx
__int64 v26; // rbx
__int64 v27; // rax
__int64 v28; // rdi
float v29; // xmm6_4
float *v30; // rax
__int64 v31; // rbx
__int64 v32; // rax
__int64 v33; // rcx
cocos2d::CCObject *v34; // rax
__int64 v35; // rcx
cocos2d::CCObject *v36; // rax
__int64 v37; // rax
int v38; // ebx
cocos2d::CCArray *v39; // r14
unsigned int i; // r12d
struct cocos2d::CCObject *v41; // r14
__int64 v42; // rdx
__int64 v43; // r8
__int64 v44; // r9
unsigned int v45; // r13d
unsigned __int64 v46; // rcx
size_t v47; // r8
_QWORD *v48; // rdx
const char *v49; // rcx
struct cocos2d::CCSprite *v50; // rdi
__int64 v51; // rbx
float v52; // xmm6_4
float *v53; // rax
__int64 v54; // rax
struct cocos2d::CCTexture2D *v55; // rdi
struct cocos2d::CCObject *v56; // rbx
__int64 v57; // rcx
cocos2d::CCObject *v58; // rax
struct cocos2d::CCSprite *v59; // rax
__int64 v60; // rdi
float v61; // xmm6_4
float *v62; // rax
__int64 v63; // rbx
__int64 v64; // rax
_QWORD *v65; // rax
int v66; // [rsp+38h] [rbp-99h]
cocos2d::CCArray *v67; // [rsp+40h] [rbp-91h] BYREF
__int64 v68; // [rsp+48h] [rbp-89h]
struct cocos2d::CCTexture2D *v69; // [rsp+50h] [rbp-81h]
_QWORD *v70; // [rsp+58h] [rbp-79h]
_BYTE v71[8]; // [rsp+60h] [rbp-71h] BYREF
_QWORD *v72; // [rsp+68h] [rbp-69h]
char *String[2]; // [rsp+70h] [rbp-61h] BYREF
__int64 v74; // [rsp+80h] [rbp-51h]
unsigned __int64 v75; // [rsp+88h] [rbp-49h]
void *Block[2]; // [rsp+90h] [rbp-41h] BYREF
__int64 v77; // [rsp+A0h] [rbp-31h]
unsigned __int64 v78; // [rsp+A8h] [rbp-29h]
_QWORD v79[2]; // [rsp+B0h] [rbp-21h] BYREF
unsigned __int64 v80; // [rsp+C0h] [rbp-11h]
unsigned __int64 v81; // [rsp+C8h] [rbp-9h]
v70 = a3;
LODWORD(v68) = a2;
v72 = a3;
v6 = 0;
v7 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v67 = (cocos2d::CCArray *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v67);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v7 = qword_14090BFD0;
}
v8 = *(_DWORD *)(v7 + 1272);
*(_DWORD *)(v7 + 1272) = v8 + 1;
*((_DWORD *)a1 + 197) = v8;
Icon = GameManager::loadIcon((__int64 *)v7, a2, *((_DWORD *)a1 + 196), v8);
v69 = Icon;
v10 = a3;
if ( a3[3] > 0xFu )
v10 = (_BYTE *)*a3;
v11 = Icon;
if ( !Icon )
{
v12 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v12, v10);
HIDWORD(Block[1]) = 0;
v77 = 11;
v78 = 15;
strcpy((char *)Block, "spriteSheet");
v14 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, Block);
CString = cocos2d::CCString::getCString(v14);
*(_OWORD *)String = 0;
v74 = 0;
v75 = 0;
v16 = -1;
do
++v16;
while ( CString[v16] );
sub_14003D230(String, CString, v16);
if ( v78 > 0xF )
{
v17 = Block[0];
if ( v78 + 1 >= 0x1000 )
{
v17 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v17 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v17);
}
v77 = 0;
v78 = 15;
LOBYTE(Block[0]) = 0;
sub_140044D80(String, ".png", 4u);
v18 = (const char *)String;
if ( v75 > 0xF )
v18 = String[0];
v19 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
v11 = cocos2d::CCTextureCache::addImage(v19, v18, 0);
if ( v75 > 0xF )
{
v20 = String[0];
if ( v75 + 1 >= 0x1000 )
{
v20 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v20 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v20);
}
v74 = 0;
v75 = 15;
LOBYTE(String[0]) = 0;
}
cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 0.0, 0.0);
if ( cocos2d::CCSprite::initWithTexture((cocos2d::CCSprite *)a1, v11, v21) )
{
*((_BYTE *)a1 + 559) = 1;
sub_1400405A0((void **)a1 + 75, &byte_1406ED6E0, 0);
CCAnimatedSprite::loadType(a1, v10, v11, 1u);
*((_BYTE *)a1 + 559) = 1;
v23 = a1[83];
SpriteAnimationManager::overridePrio(v23);
v24 = *(cocos2d::CCNode **)(*(_QWORD *)(v23 + 320) + 688LL);
if ( v24 )
cocos2d::CCNode::stopAllActions(v24);
v25 = *(cocos2d::CCNode **)(*(_QWORD *)(v23 + 320) + 680LL);
if ( v25 )
cocos2d::CCNode::stopAllActions(v25);
v26 = *a1;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v67, 30.0, 30.0);
(*(void (__fastcall **)(__int64 *, __int64))(v26 + 312))(a1, v27);
v28 = *(_QWORD *)a1[86];
v29 = *(float *)((*(__int64 (__fastcall **)(__int64 *))(*a1 + 320))(a1) + 4) * 0.5;
v30 = (float *)(*(__int64 (__fastcall **)(__int64 *))(*a1 + 320))(a1);
v31 = a1[86];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v67, *v30 * 0.5, v29);
(*(void (__fastcall **)(__int64, __int64))(v28 + 184))(v31, v32);
v34 = (cocos2d::CCObject *)cocos2d::CCArray::create(v33);
a1[95] = (__int64)v34;
cocos2d::CCObject::retain(v34);
v36 = (cocos2d::CCObject *)cocos2d::CCArray::create(v35);
a1[93] = (__int64)v36;
cocos2d::CCObject::retain(v36);
v37 = cocos2d::CCSprite::create();
a1[96] = v37;
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1[86] + 456LL))(a1[86], v37, 0xFFFFFFFFLL);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1[96] + 336LL))(a1[96], 0);
*(_BYTE *)(a1[96] + 559) = 1;
v38 = *((_DWORD *)a1 + 196);
v66 = v38;
v39 = *(cocos2d::CCArray **)(a1[86] + 632);
v67 = v39;
for ( i = 0; i < cocos2d::CCArray::count(v67); v39 = v67 )
{
v41 = cocos2d::CCArray::objectAtIndex(v39, i);
*((_BYTE *)v41 + 618) = 1;
sub_14003F4F0((__int64)v79, (__int64)v41 + 632);
v6 |= 2u;
if ( v80 )
{
if ( v80 >= (unsigned __int64)(v38 == 6) + 11 )
{
v46 = (v38 == 6) + 9LL;
*(_OWORD *)String = 0;
v74 = 0;
v75 = 0;
if ( v80 < v46 )
sub_14003F4D0(v46, v42, v43, v44);
v47 = 2;
if ( v80 - v46 < 2 )
v47 = v80 - v46;
v48 = v79;
if ( v81 > 0xF )
v48 = (_QWORD *)v79[0];
sub_14003D230(String, (char *)v48 + v46, v47);
v6 |= 5u;
v49 = (const char *)String;
if ( v75 > 0xF )
v49 = String[0];
v45 = atoi(v49);
}
else
{
v45 = -1;
}
if ( (v6 & 1) != 0 )
{
v6 &= ~1u;
sub_14003D310((__int64)String);
}
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v41 + 64LL))(v41, v45);
v50 = cocos2d::CCSprite::createWithTexture(v69, (const struct cocos2d::CCRect *)&unk_14090ACB8);
(*(void (__fastcall **)(struct cocos2d::CCObject *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)v41 + 456LL))(
v41,
v50,
0xFFFFFFFFLL);
v51 = *(_QWORD *)v50;
v52 = *(float *)((*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v41 + 320LL))(v41) + 4)
* 0.5;
v53 = (float *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v41 + 320LL))(v41);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v71, *v53 * 0.5, v52);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v51 + 184))(v50, v54);
cocos2d::CCArray::addObject((cocos2d::CCArray *)a1[95], v50);
v55 = v69;
v56 = cocos2d::CCSprite::createWithTexture(v69, (const struct cocos2d::CCRect *)&unk_14090ACB8);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)a1[96] + 456LL))(
a1[96],
v56,
0xFFFFFFFFLL);
*((_BYTE *)v41 + 616) = 1;
if ( !*((_QWORD *)v41 + 75) )
{
v58 = (cocos2d::CCObject *)cocos2d::CCArray::create(v57);
*((_QWORD *)v41 + 75) = v58;
cocos2d::CCObject::retain(v58);
}
cocos2d::CCArray::addObject(*((cocos2d::CCArray **)v41 + 75), v56);
*((_BYTE *)v41 + 617) = 1;
if ( *((_DWORD *)a1 + 196) == 5 && i == 6 )
a1[100] = (__int64)v41;
if ( v45 == 1 )
a1[99] = (__int64)v41;
if ( v41 == (struct cocos2d::CCObject *)a1[99] && !a1[97] )
{
v59 = cocos2d::CCSprite::createWithTexture(v55);
a1[97] = (__int64)v59;
*((_BYTE *)a1 + 752) = 0;
(*(void (__fastcall **)(__int64, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1[99] + 456LL))(
a1[99],
v59,
2);
v60 = *(_QWORD *)a1[97];
v61 = *(float *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1[99] + 320LL))(a1[99]) + 4) * 0.5;
v62 = (float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1[99] + 320LL))(a1[99]);
v63 = a1[97];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, *v62 * 0.5, v61);
(*(void (__fastcall **)(__int64, __int64))(v60 + 184))(v63, v64);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1[97] + 336LL))(a1[97], *((unsigned __int8 *)a1 + 752));
}
v38 = v66;
}
sub_14003D310((__int64)v79);
++i;
}
GJRobotSprite::updateFrame(a1, (unsigned int)v68);
*(_OWORD *)String = 0;
v74 = 4;
v75 = 15;
strcpy((char *)String, "idle");
Block[0] = String;
v65 = (_QWORD *)sub_14003F4F0((__int64)v79, (__int64)String);
SpriteAnimationManager::runAnimation(a1[83], v65);
sub_14003D310((__int64)String);
sub_14003D310((__int64)v70);
return 1;
}
else
{
sub_14003D310((__int64)a3);
return 0;
}
}