//
// ShaderLayer::prepareTargetContainer from 0x1002718f4 to 0x100271b88 (660 bytes)
//
// 1 xrefs:
// > ShaderLayer::visit @ 0x1002731fc
//
// 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 __fastcall ShaderLayer::prepareTargetContainer(ShaderLayer *a1)
{
__int64 *v1; // x8
__int64 *v2; // x20
GJBaseGameLayer *m_gameLayer; // x8
__int64 *v5; // x0
__int64 v6; // x8
__int64 v7; // x21
__n128 v8; // q0
__n128 v9; // q1
float m_scaleFactor; // s8
GJBaseGameLayer *v11; // x8
float v12; // s2
double v15; // d0
double *v16; // x0
cocos2d::CCSprite *m_sprite; // x22
__n128 v18; // q0
__n128 v19; // q1
float32x2_t v20[2]; // [xsp+0h] [xbp-50h] BYREF
float32x2_t v21; // [xsp+10h] [xbp-40h] BYREF
float32x2_t v22; // [xsp+18h] [xbp-38h] BYREF
cocos2d::CCPoint result; // 0:s0.4,4:s1.4
v2 = v1;
m_gameLayer = a1->m_gameLayer;
if ( !m_gameLayer )
{
result.x = sub_1000229B8(v2, (__int64 *)&dbl_10086D7C0);
return result;
}
v5 = (__int64 *)((__int64 (__fastcall *)(cocos2d::CCLayer *))m_gameLayer->m_objectLayer->getPosition)(m_gameLayer->m_objectLayer);
sub_1000229B8((__int64 *)&v22, v5);
v6 = 3784;
if ( a1->m_state.m_minBlendingLayer > 1 )
v6 = 3792;
v7 = *(__int64 *)((char *)&a1->m_gameLayer->__vftable + v6);
v8.n128_f32[0] = sub_1000229B8(v2, (__int64 *)&dbl_10086D7C0);
if ( a1->m_state.m_pixelateSnapGrid && a1->m_state.m_pixelatePixelating )
{
m_scaleFactor = a1->m_scaleFactor;
if ( a1->m_state.m_pixelateRelative && (v11 = a1->m_gameLayer) != nullptr )
{
((void (__fastcall *)(cocos2d::CCLayer *, float))v11->m_objectLayer->getScale)(v11->m_objectLayer, v8.n128_f32[0]);
v9.n128_u32[0] = LODWORD(a1->m_scaleFactor);
v12 = 1.0;
if ( !a1->m_state.m_pixelatePixelating )
{
LABEL_13:
v8.n128_f32[0] = (float)((float)(a1->m_state.m_pixelateTargetX * v12) / v9.n128_f32[0])
* floorf(v22.f32[0] / (float)((float)(a1->m_state.m_pixelateTargetX * v12) / v9.n128_f32[0]));
v9.n128_f32[0] = (float)((float)(a1->m_state.m_pixelateTargetY * v12) / v9.n128_f32[0])
* floorf(v22.f32[1] / (float)((float)(a1->m_state.m_pixelateTargetY * v12) / v9.n128_f32[0]));
sub_100022980(v8, v9, v20);
sub_1000229F0(&v22, v20, &v21);
sub_1000229D0(v2, (double *)&v21);
goto LABEL_14;
}
m_scaleFactor = m_scaleFactor * fabsf(v8.n128_f32[0]);
}
else
{
v9.n128_u32[0] = LODWORD(a1->m_scaleFactor);
}
v12 = m_scaleFactor;
goto LABEL_13;
}
LABEL_14:
v15 = sub_1000229D0(&dword_100886D84, (double *)v2);
v16 = (double *)(*(__int64 (__fastcall **)(__int64, double))(*(_QWORD *)v7 + 192LL))(v7, v15);
sub_1000229D0(&a1->m_savedCameraPosition, v16);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v7 + 128LL))(v7, a1->m_state.m_textureScaleX);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v7 + 144LL))(v7, a1->m_state.m_textureScaleY);
a1->m_savedCameraRotation = (*(float (__fastcall **)(__int64))(*(_QWORD *)v7 + 352LL))(v7);
sub_100022AFC(&v21, (double *)&a1->m_screenSize);
m_sprite = a1->m_sprite;
sub_100022990((float *)v20, -1.0, -1.0, v21.f32[0] + 2.0, v21.f32[1] + 2.0);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))m_sprite->setTextureRect)(m_sprite, v20);
sub_100022988((float *)v20, a1->m_targetTextureSize.width - v21.f32[0], a1->m_targetTextureSize.height - v21.f32[1]);
sub_100022B14(&a1->m_targetTextureSizeExtra, (double *)v20);
v18.n128_u64[0] = (unsigned __int64)vmul_f32(
(float32x2_t)a1->m_targetTextureSizeExtra,
(float32x2_t)0xBF000000BF000000LL);
v19.n128_u64[0] = (unsigned __int64)vadd_f32(*(float32x2_t *)v2, (float32x2_t)v18.n128_u64[0]);
*v2 = v19.n128_u64[0];
v18.n128_f32[0] = (float)(a1->m_savedCameraPosition.x - v19.n128_f32[0]) * a1->m_state.m_textureScaleX;
v19.n128_f32[0] = (float)(a1->m_savedCameraPosition.y - v19.n128_f32[1]) * a1->m_state.m_textureScaleY;
sub_100022980(v18, v19, v20);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v7 + 184LL))(v7, v20);
return result;
}