//
// cocos2d::CCTMXLayer::setupTileSprite from 0x803f74 to 0x8040f4 (384 bytes)
//
// 4 xrefs:
// > cocos2d::CCTMXLayer::insertTileForGID @ 0x8041dc
// > cocos2d::CCTMXLayer::updateTileForGID @ 0x804310
// > cocos2d::CCTMXLayer::appendTileForGID @ 0x804426
// > cocos2d::CCTMXLayer::setTileGID @ 0x804cd2
//
// 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 12:01:22 +0000
//
int __fastcall cocos2d::CCTMXLayer::setupTileSprite(unsigned __int8 *a1, int a2, float *a3, int a4)
{
void (__fastcall *v8)(int, float *); // r10
void (__fastcall *v9)(int, float); // r10
int v10; // r0
int (__fastcall *v11)(int, float *); // r10
int result; // r0
unsigned int v13; // r5
void (__fastcall *v14)(int, float *); // r10
void (__fastcall *v15)(int, float *); // r10
float v16; // s16
float v17; // s15
float v18; // s18
float *v19; // r0
int (__fastcall *v20)(int, int); // r3
int v21; // r1
int v22; // r1
float v23[2]; // [sp+4h] [bp-1Ch] BYREF
_BYTE v24[4]; // [sp+Ch] [bp-14h] BYREF
float v25; // [sp+10h] [bp-10h]
float v26[2]; // [sp+14h] [bp-Ch] BYREF
v8 = *(void (__fastcall **)(int, float *))(*(_DWORD *)a2 + 92);
cocos2d::CCTMXLayer::positionAt((cocos2d::CCTMXLayer *)v26, (const cocos2d::CCPoint *)a1, a3);
v8(a2, v26);
v9 = *(void (__fastcall **)(int, float))(*(_DWORD *)a2 + 56);
v10 = cocos2d::CCTMXLayer::vertexZForPos((cocos2d::CCTMXLayer *)a1, (const cocos2d::CCPoint *)a3);
((void (__fastcall *)(_DWORD, _DWORD))v9)(a2, (float)v10);
(*(void (__fastcall **)(int, void *))(*(_DWORD *)a2 + 148))(a2, &unk_D31288);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)a2 + 456))(a2, a1[332]);
cocos2d::CCSprite::setFlipX(a2, 0);
cocos2d::CCSprite::setFlipY(a2, 0);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)a2 + 180))(a2, 0);
v11 = *(int (__fastcall **)(int, float *))(*(_DWORD *)a2 + 148);
cocos2d::CCPoint::CCPoint(v26, 0.0, 0.0);
result = v11(a2, v26);
if ( (a4 & 0x20000000) != 0 )
{
v13 = a4 & 0xC0000000;
v14 = *(void (__fastcall **)(int, float *))(*(_DWORD *)a2 + 148);
cocos2d::CCPoint::CCPoint(v26, 0.5, 0.5);
v14(a2, v26);
v15 = *(void (__fastcall **)(int, float *))(*(_DWORD *)a2 + 92);
cocos2d::CCTMXLayer::positionAt((cocos2d::CCTMXLayer *)v23, (const cocos2d::CCPoint *)a1, a3);
v16 = v23[0];
v17 = *(float *)((*(int (__fastcall **)(int))(*(_DWORD *)a2 + 164))(a2) + 4);
cocos2d::CCTMXLayer::positionAt((cocos2d::CCTMXLayer *)v24, (const cocos2d::CCPoint *)a1, a3);
v18 = v25;
v19 = (float *)(*(int (__fastcall **)(int))(*(_DWORD *)a2 + 164))(a2);
cocos2d::CCPoint::CCPoint(v26, v16 + (float)(v17 * 0.5), v18 + (float)(*v19 * 0.5));
v15(a2, v26);
v20 = *(int (__fastcall **)(int, int))(*(_DWORD *)a2 + 180);
switch ( v13 )
{
case 0x80000000:
v21 = 1119092736;
return v20(a2, v21);
case 0x40000000u:
v21 = 1132920832;
return v20(a2, v21);
case 0xC0000000:
v22 = 1119092736;
break;
default:
v22 = 1132920832;
break;
}
v20(a2, v22);
return cocos2d::CCSprite::setFlipX(a2, 1);
}
else
{
if ( a4 < 0 )
result = cocos2d::CCSprite::setFlipX(a2, 1);
if ( (a4 & 0x40000000) != 0 )
return cocos2d::CCSprite::setFlipY(a2, 1);
}
return result;
}