//
// ShaderLayer::prepareTargetContainer from 0x54da6c to 0x54dcc8 (604 bytes)
//
// 1 xrefs:
// > ShaderLayer::visit @ 0x54f0e0
//
// 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(cocos2d::CCPoint *__return_ptr retstr, ShaderLayer *a2)
{
cocos2d::CCPoint *v2; // r9
GJBaseGameLayer *m_gameLayer; // r2
const cocos2d::CCPoint *v5; // r1
const cocos2d::CCPoint *v6; // r0
GJBaseGameLayer *v7; // r3
cocos2d::CCNode *m_objectParent; // r5
int v9; // r2
bool m_pixelateSnapGrid; // r3
float m_scaleFactor; // s16
GJBaseGameLayer *v12; // r3
float v13; // s15
float v14; // s15
float v15; // s14
float v16; // s17
float v17; // s16
float v18; // s18
float v19; // r0
int v20; // r2
bool v21; // r3
float v22; // r0
int v23; // r2
bool v24; // r3
cocos2d::CCSprite *m_sprite; // r10
void (__fastcall *setTextureRect)(cocos2d::CCSprite *__hidden, const cocos2d::CCRect *); // r11
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
float v28; // s15
float x; // s12
float y; // s13
cocos2d::CCPoint v32; // [sp+Ch] [bp-30h] BYREF
cocos2d::CCPoint v33; // [sp+14h] [bp-28h] BYREF
cocos2d::CCPoint v34; // [sp+1Ch] [bp-20h] BYREF
cocos2d::CCRect v35; // [sp+24h] [bp-18h] BYREF
v2 = retstr;
m_gameLayer = a2->m_gameLayer;
if ( m_gameLayer )
{
v6 = m_gameLayer->m_objectLayer->getPosition(m_gameLayer->m_objectLayer);
cocos2d::CCPoint::CCPoint(&v32, v6);
v7 = a2->m_gameLayer;
if ( a2->m_state.m_minBlendingLayer <= 1 )
m_objectParent = v7->m_objectParent;
else
m_objectParent = v7->m_inShaderParent;
cocos2d::CCPoint::CCPoint(&v33, &stru_AC7974);
m_pixelateSnapGrid = a2->m_state.m_pixelateSnapGrid;
if ( m_pixelateSnapGrid )
{
m_pixelateSnapGrid = a2->m_state.m_pixelatePixelating;
if ( m_pixelateSnapGrid )
{
m_scaleFactor = a2->m_scaleFactor;
if ( a2->m_state.m_pixelateRelative && (v12 = a2->m_gameLayer) != nullptr )
v13 = fabsf(v12->m_objectLayer->getScale(v12->m_objectLayer));
else
v13 = 1.0;
if ( a2->m_state.m_pixelatePixelating )
v14 = v13 * m_scaleFactor;
else
v14 = 1.0;
v15 = a2->m_scaleFactor;
v16 = (float)(v14 * a2->m_state.m_pixelateTargetX) / v15;
v17 = (float)(v14 * a2->m_state.m_pixelateTargetY) / v15;
v18 = floorf(v32.x / v16);
v19 = floorf(v32.y / v17);
cocos2d::CCPoint::CCPoint(&v34, v16 * v18, v17 * v19);
cocos2d::CCPoint::operator-(&v35, &v32, &v34);
cocos2d::CCPoint::operator=((PlayerObject *)&v33, COERCE_FLOAT(&v35), v20, v21);
}
}
cocos2d::CCPoint::operator=((PlayerObject *)&pixelOffset, COERCE_FLOAT(&v33), v9, m_pixelateSnapGrid);
v22 = ((float (__fastcall *)(cocos2d::CCNode *))m_objectParent->getPosition)(m_objectParent);
cocos2d::CCPoint::operator=((PlayerObject *)&a2->m_savedCameraPosition, v22, v23, v24);
((void (__fastcall *)(cocos2d::CCNode *, _DWORD))m_objectParent->setScaleX)(
m_objectParent,
LODWORD(a2->m_state.m_textureScaleX));
((void (__fastcall *)(cocos2d::CCNode *, _DWORD))m_objectParent->setScaleY)(
m_objectParent,
LODWORD(a2->m_state.m_textureScaleY));
LODWORD(a2->m_savedCameraRotation) = ((int (__fastcall *)(cocos2d::CCNode *))m_objectParent->getRotation)(m_objectParent);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v34, &a2->m_screenSize);
m_sprite = a2->m_sprite;
setTextureRect = m_sprite->setTextureRect;
cocos2d::CCRect::CCRect(&v35, -1.0, -1.0, v34.x + 2.0, v34.y + 2.0);
setTextureRect(m_sprite, &v35);
cocos2d::CCSize::CCSize(
(cocos2d::CCSize *)&v35,
a2->m_targetTextureSize.width - v34.x,
a2->m_targetTextureSize.height - v34.y);
cocos2d::CCSize::operator=(&a2->m_targetTextureSizeExtra, &v35);
setPosition = m_objectParent->setPosition;
v28 = v33.y - (float)(a2->m_targetTextureSizeExtra.height * 0.5);
x = a2->m_savedCameraPosition.x;
y = a2->m_savedCameraPosition.y;
v33.x = v33.x - (float)(a2->m_targetTextureSizeExtra.width * 0.5);
v33.y = v28;
cocos2d::CCPoint::CCPoint(
&v35.origin,
(float)(x - v33.x) * a2->m_state.m_textureScaleX,
(float)(y - v28) * a2->m_state.m_textureScaleY);
setPosition(m_objectParent, &v35.origin);
retstr = v2;
v5 = &v33;
}
else
{
v5 = &stru_AC7974;
}
cocos2d::CCPoint::CCPoint(retstr, v5);
return v2;
}