//
// cocos2d::CCTMXLayer::tileAt from 0x1800ad3d0 to 0x1800ad613 (579 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b8280
//
// 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
//
// Hidden C++ exception states: #wind=1
struct cocos2d::CCSprite *__fastcall cocos2d::CCTMXLayer::tileAt(
cocos2d::CCTMXLayer *this,
struct cocos2d::CCPoint *a2)
{
struct cocos2d::CCSprite *v4; // rsi
float v5; // ebp
struct cocos2d::CCSprite *result; // rax
cocos2d::CCDirector *v7; // rax
float ContentScaleFactor; // xmm0_4
float v9; // xmm8_4
cocos2d::CCDirector *v10; // rax
float v11; // xmm0_4
float v12; // xmm7_4
cocos2d::CCDirector *v13; // rax
float v14; // xmm0_4
float v15; // xmm6_4
cocos2d::CCDirector *v16; // rax
float v17; // xmm0_4
cocos2d::CCRect *v18; // rax
cocos2d::CCSprite *v19; // rax
cocos2d::CCSprite_vtbl *v20; // rbx
__int64 v21; // rax
cocos2d::CCSprite_vtbl *v22; // rbx
struct cocos2d::CCPoint *v23; // rax
cocos2d::CCSprite_vtbl *v24; // rbx
void *v25; // rax
float v26[4]; // [rsp+30h] [rbp-68h] BYREF
cocos2d::CCRect v27; // [rsp+40h] [rbp-58h] BYREF
cocos2d::CCSprite *Key; // [rsp+A0h] [rbp+8h] BYREF
v4 = nullptr;
LODWORD(v5) = (int)(float)((float)(*((float *)this + 90) * a2->y) + a2->x);
if ( (*(_DWORD *)(*((_QWORD *)this + 47) + 4LL * SLODWORD(v5)) & 0x1FFFFFFF) != 0 )
{
result = (struct cocos2d::CCSprite *)((__int64 (__fastcall *)(cocos2d::CCTMXLayer *, _QWORD))this->getChildByTag)(
this,
LODWORD(v5));
if ( result )
return result;
cocos2d::CCTMXTilesetInfo::rectForGID(*((struct cocos2d::CCRect **)this + 48), (unsigned int)v26);
v7 = cocos2d::CCDirector::sharedDirector();
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v7);
v9 = v26[3] / ContentScaleFactor;
v10 = cocos2d::CCDirector::sharedDirector();
v11 = cocos2d::CCDirector::getContentScaleFactor(v10);
v12 = v26[2] / v11;
v13 = cocos2d::CCDirector::sharedDirector();
v14 = cocos2d::CCDirector::getContentScaleFactor(v13);
v15 = v26[1] / v14;
v16 = cocos2d::CCDirector::sharedDirector();
v17 = cocos2d::CCDirector::getContentScaleFactor(v16);
v18 = cocos2d::CCRect::CCRect(&v27, v26[0] / v17, v15, v12, v9);
cocos2d::CCRect::operator=(v26, (float *)&v18->origin);
v19 = (cocos2d::CCSprite *)operator new(0x258u);
Key = v19;
if ( v19 )
v4 = cocos2d::CCSprite::CCSprite(v19);
v20 = v4->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v21 = ((__int64 (__fastcall *)(cocos2d::CCTextureProtocol *))this->getTexture)(&this->cocos2d::CCTextureProtocol);
((void (__fastcall *)(struct cocos2d::CCSprite *, __int64, float *))v20->initWithTexture_0)(v4, v21, v26);
((void (__fastcall *)(struct cocos2d::CCSprite *, cocos2d::CCTMXLayer *))v4->setBatchNode)(v4, this);
v22 = v4->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v23 = cocos2d::CCTMXLayer::positionAt(this, (struct cocos2d::CCPoint *)&Key, (float *)a2);
((void (__fastcall *)(struct cocos2d::CCSprite *, struct cocos2d::CCPoint *))v22->setPosition_0)(v4, v23);
v24 = v4->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCTMXLayer::vertexZForPos(this, a2);
((void (__fastcall *)(struct cocos2d::CCSprite *))v24->setVertexZ)(v4);
((void (__fastcall *)(struct cocos2d::CCSprite *, struct cocos2d::CCSize *))v4->setAnchorPoint)(v4, &unk_1801A9AC8);
((void (__fastcall *)(cocos2d::CCRGBAProtocol *, _QWORD))v4->setOpacity)(
&v4->cocos2d::CCRGBAProtocol,
*((unsigned __int8 *)this + 440));
*(float *)&Key = v5;
v25 = bsearch(
&Key,
*(const void **)(*((_QWORD *)this + 59) + 16LL),
**((unsigned int **)this + 59),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)CompareFunction);
cocos2d::CCSpriteBatchNode::addSpriteWithoutQuad(
this,
v4,
((unsigned __int64)v25 - *(_QWORD *)(*((_QWORD *)this + 59) + 16LL)) >> 3,
SLODWORD(v5));
cocos2d::CCObject::release(v4);
}
return v4;
}