//
// GameManager::loadIcon from 0x1003b47b8 to 0x1003b4a4c (660 bytes)
//
// 13 xrefs:
// > PlayerObject::init @ 0x1002b4348
// > PlayerObject::init @ 0x1002b435c
// > PlayerObject::updatePlayerShipFrame @ 0x1002c6634
// > PlayerObject::updatePlayerJetpackFrame @ 0x1002c67e8
// > PlayerObject::updatePlayerBirdFrame @ 0x1002c6dc4
// > PlayerObject::updatePlayerSwingFrame @ 0x1002c7208
// > PlayerObject::updatePlayerFrame @ 0x1002c7450
// > PlayerObject::updatePlayerDartFrame @ 0x1002c796c
// > PlayerObject::updatePlayerRollFrame @ 0x1002c7c60
// > GJRobotSprite::init @ 0x1002dc490
// > GJRobotSprite::updateFrame @ 0x1002dc948
// > SimplePlayer::updatePlayerFrame @ 0x1003a0388
// > SimplePlayer::init @ 0x1003a3ed8
//
// This function is hookable on this platform (idp: arm, 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:03:56 +0000
//
__int64 __fastcall GameManager::loadIcon(__int64 a1, __int64 a2, signed int a3, unsigned int a4)
{
int v5; // w19
std::string::size_type size; // x9
__int64 v8; // x21
void *v9; // x0
std::string *v10; // x1
void *v11; // x0
std::string *p_dst; // x1
__int64 v13; // x0
std::string *p_p; // x1
_DWORD *v15; // x0
__int64 v16; // x22
_QWORD *v17; // x0
_DWORD *v18; // x0
std::string __p; // [xsp+0h] [xbp-90h] BYREF
std::string __dst; // [xsp+20h] [xbp-70h] BYREF
int v22; // [xsp+44h] [xbp-4Ch] BYREF
std::string __src; // [xsp+48h] [xbp-48h] BYREF
unsigned int v24; // [xsp+64h] [xbp-2Ch] BYREF
unsigned int v25; // [xsp+68h] [xbp-28h] BYREF
v5 = a2;
v24 = a4;
v25 = a3;
GameManager::sheetNameForIcon(a2, a3, &__src);
size = HIBYTE(__src.__r_.__value_.__r.__words[2]);
if ( (__src.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __src.__r_.__value_.__l.__size_;
if ( size )
{
v22 = v5 + *(_DWORD *)(*(_QWORD *)(a1 + 1232) + 4LL * a3) - 1;
if ( SHIBYTE(__src.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, __src.__r_.__value_.__l.__data_, __src.__r_.__value_.__l.__size_);
else
__dst = __src;
std::string::append(&__dst, ".png");
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v22;
if ( *((int *)sub_1001E71D0(a1 + 1160, &v22, (__int64)&unk_10076DF2D, (unsigned int **)&__p) + 8) <= 0 )
{
if ( SHIBYTE(__src.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, __src.__r_.__value_.__l.__data_, __src.__r_.__value_.__l.__size_);
else
__p = __src;
std::string::append(&__p, ".plist");
v11 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
v8 = (__int64)cocos2d::CCTextureCache::addImage((__int64)v11, (char *)p_dst);
v13 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v8);
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = &__p;
else
p_p = (std::string *)__p.__r_.__value_.__r.__words[0];
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v13, p_p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
else
{
v9 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v10 = &__dst;
else
v10 = (std::string *)__dst.__r_.__value_.__r.__words[0];
v8 = cocos2d::CCTextureCache::textureForKey((__int64)v9, (char *)v10);
}
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v24;
v15 = sub_10018E25C(a1 + 1184, (int *)&v24, (__int64)&unk_10076DF2D, &__p);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v25;
v16 = *((unsigned int *)sub_1001E71D0(
(__int64)(v15 + 10),
(int *)&v25,
(__int64)&unk_10076DF2D,
(unsigned int **)&__p)
+ 8);
if ( (_DWORD)v16 != v5 )
{
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v22;
v17 = sub_1001E71D0(a1 + 1160, &v22, (__int64)&unk_10076DF2D, (unsigned int **)&__p);
++*((_DWORD *)v17 + 8);
if ( (int)v16 >= 1 )
GameManager::unloadIcon(a1, v16, v25, v24);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v24;
v18 = sub_10018E25C(a1 + 1184, (int *)&v24, (__int64)&unk_10076DF2D, &__p);
__p.__r_.__value_.__r.__words[0] = (std::string::size_type)&v25;
*((_DWORD *)sub_1001E71D0((__int64)(v18 + 10), (int *)&v25, (__int64)&unk_10076DF2D, (unsigned int **)&__p) + 8) = v5;
}
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( (*((_BYTE *)&__src.__r_.__value_.__s + 23) & 0x80) != 0 )
goto LABEL_32;
}
else
{
v8 = 0;
if ( (*((_BYTE *)&__src.__r_.__value_.__s + 23) & 0x80) != 0 )
LABEL_32:
operator delete(__src.__r_.__value_.__l.__data_);
}
return v8;
}