//
// ShaderLayer::prepareTargetContainer from 0x140486250 to 0x1404865bd (877 bytes)
//
// 5 xrefs:
// > ShaderLayer::visit @ 0x140488abe
// > ??> @ 0x1406a6644
// > ??> @ 0x1406a6654
// > ??> @ 0x1406dbd14
// > ??> @ 0x1406dbd20
//
// 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
//
cocos2d::CCPoint ShaderLayer::prepareTargetContainer(ShaderLayer *a1)
{
cocos2d::CCPoint *v1; // rdx
cocos2d::CCPoint *v3; // r14
GJBaseGameLayer *m_gameLayer; // rcx
GJBaseGameLayer *v6; // rax
cocos2d::CCNode *m_objectParent; // r15
float m_scaleFactor; // xmm7_4
GJBaseGameLayer *v9; // rcx
double v10; // xmm0_8
float v11; // xmm8_4
float v12; // xmm0_4
float v13; // xmm8_4
float v14; // xmm8_4
float v15; // xmm7_4
float v16; // xmm0_4
__int64 v17; // rax
cocos2d::CCSprite_vtbl *v18; // rbx
const cocos2d::CCRect *v19; // rax
__int64 v20; // rax
float v21; // xmm0_4
float x; // xmm1_4
float v23; // xmm1_4
cocos2d::CCNode_vtbl *v24; // rbx
const cocos2d::CCPoint *v25; // rax
char v26[8]; // [rsp+30h] [rbp-19h] BYREF
cocos2d::CCRect v27; // [rsp+38h] [rbp-11h] BYREF
cocos2d::CCPoint v28; // [rsp+B0h] [rbp+67h] BYREF
cocos2d::CCSize v29; // [rsp+C0h] [rbp+77h] BYREF
cocos2d::CCPoint v30; // [rsp+C8h] [rbp+7Fh] BYREF
v3 = v1;
m_gameLayer = a1->m_gameLayer;
if ( m_gameLayer )
{
m_gameLayer->m_objectLayer->getPosition_0(m_gameLayer->m_objectLayer);
cocos2d::CCPoint::CCPoint(&v30);
v6 = a1->m_gameLayer;
if ( a1->m_state.m_minBlendingLayer <= 1 )
m_objectParent = v6->m_objectParent;
else
m_objectParent = v6->m_inShaderParent;
cocos2d::CCPoint::CCPoint(&v28);
if ( a1->m_state.m_pixelateSnapGrid && a1->m_state.m_pixelatePixelating )
{
m_scaleFactor = a1->m_scaleFactor;
if ( a1->m_state.m_pixelateRelative && (v9 = a1->m_gameLayer) != nullptr )
{
v10 = ((double (__fastcall *)(cocos2d::CCLayer *))v9->m_objectLayer->getScale)(v9->m_objectLayer);
v11 = *(float *)&v10;
v12 = a1->m_scaleFactor;
v13 = fabs(v11);
}
else
{
v13 = 1.0;
v12 = a1->m_scaleFactor;
}
if ( a1->m_state.m_pixelatePixelating )
v14 = v13 * m_scaleFactor;
else
v14 = 1.0;
v15 = (float)(v14 * a1->m_state.m_pixelateTargetX) / v12;
floorf(v30.y / (float)((float)(v14 * a1->m_state.m_pixelateTargetY) / v12));
v16 = floorf(v30.x / v15) * v15;
cocos2d::CCPoint::CCPoint(v16, v16);
cocos2d::CCPoint::operator-(&v30, &v27, v26);
cocos2d::CCPoint::operator=(&v28, &v27);
}
cocos2d::CCPoint::operator=(&dword_1406C2C78, &v28);
v17 = (__int64)m_objectParent->getPosition_0(m_objectParent);
cocos2d::CCPoint::operator=(&a1->m_savedCameraPosition, v17);
((void (__fastcall *)(cocos2d::CCNode *))m_objectParent->setScaleX)(m_objectParent);
((void (__fastcall *)(cocos2d::CCNode *))m_objectParent->setScaleY)(m_objectParent);
a1->m_savedCameraRotation = m_objectParent->getRotation(m_objectParent);
cocos2d::CCSize::CCSize(&v29, &a1->m_screenSize);
v18 = a1->m_sprite->__vftable;
cocos2d::CCRect::CCRect(&v27, -1.0, -1.0, v29.width + 2.0, v29.height + 2.0);
v18->setTextureRect_0(a1->m_sprite, v19);
cocos2d::CCSize::CCSize(
(cocos2d::CCSize *)&v27,
a1->m_targetTextureSize.width - v29.width,
a1->m_targetTextureSize.height - v29.height);
cocos2d::CCSize::operator=(&a1->m_targetTextureSizeExtra, v20);
v21 = a1->m_targetTextureSizeExtra.height * 0.5;
x = a1->m_savedCameraPosition.x;
v28.x = v28.x - (float)(a1->m_targetTextureSizeExtra.width * 0.5);
v23 = (float)(x - v28.x) * a1->m_state.m_textureScaleX;
v28.y = v28.y - v21;
v24 = m_objectParent->__vftable;
cocos2d::CCPoint::CCPoint(v21, v23);
v24->setPosition_0(m_objectParent, v25);
cocos2d::CCPoint::CCPoint(v3);
return (cocos2d::CCPoint)v3;
}
else
{
cocos2d::CCPoint::CCPoint(v1);
return (cocos2d::CCPoint)v3;
}
}