//
// cocos2d::CCTexture2D::initPremultipliedATextureWithImage from 0x7ff910 to 0x7ffb06 (502 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexture2D::initWithImage @ 0x7ffb3a
//
// 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:19 +0000
//
int __fastcall cocos2d::CCTexture2D::initPremultipliedATextureWithImage(
cocos2d::CCTexture2D *this,
cocos2d::CCImage *a2,
GLsizei a3,
GLsizei a4)
{
_WORD *v5; // r11
int v7; // r10
signed int v9; // r6
unsigned int v10; // r4
unsigned int v11; // r0
_WORD *v12; // r0
int v13; // r3
int v14; // r0
_WORD *v15; // r0
int v16; // r1
int v17; // r3
int v18; // r10
int i; // r0
int v20; // r10
int j; // r0
int v22; // r10
_WORD *v23; // r0
int v24; // r3
_WORD *v25; // r0
int *v26; // r3
char *v27; // r4
char *k; // r2
int v29; // t1
int *v32; // [sp+Ch] [bp-18h]
float v33[2]; // [sp+14h] [bp-10h] BYREF
v5 = *((_WORD **)a2 + 15);
v7 = *((unsigned __int8 *)a2 + 64);
cocos2d::CCSize::CCSize(v33, (float)*((unsigned __int16 *)a2 + 26), (float)*((unsigned __int16 *)a2 + 27));
if ( v7 )
{
v9 = *((_DWORD *)a2 + 17);
if ( v9 <= 0 )
v9 = dword_D3111C;
}
else if ( *((_DWORD *)a2 + 14) <= 7u )
{
v9 = 2;
}
else
{
v9 = 1;
}
v10 = a4 * a3;
switch ( v9 )
{
case 2:
v11 = 2 * v10;
if ( v7 )
{
v12 = (_WORD *)operator new[](v11);
v13 = 0;
v5 = v12;
v14 = *((_DWORD *)a2 + 15);
while ( v13 != v10 )
{
v5[v13] = (*(_DWORD *)(v14 + 4 * v13) >> 19) & 0x1F
| ((unsigned __int8)*(_DWORD *)(v14 + 4 * v13) >> 3 << 11)
| (32 * ((unsigned __int16)*(_DWORD *)(v14 + 4 * v13) >> 10));
++v13;
}
}
else
{
v15 = (_WORD *)operator new[](v11);
v16 = *((_DWORD *)a2 + 15);
v17 = 0;
v5 = v15;
while ( 1 )
{
v16 += 3;
if ( v17 == v10 )
break;
v15[v17++] = (32 * ((int)*(unsigned __int8 *)(v16 - 2) >> 2))
| ((int)*(unsigned __int8 *)(v16 - 3) >> 3 << 11)
| (*(unsigned __int8 *)(v16 - 1) >> 3);
}
}
break;
case 6:
v18 = *((_DWORD *)a2 + 15);
v5 = (_WORD *)operator new[](2 * v10);
for ( i = 0; i != v10; ++i )
v5[i] = HIWORD(*(_DWORD *)(v18 + 4 * i)) & 0xF0
| (*(_DWORD *)(v18 + 4 * i) >> 28)
| ((unsigned __int8)*(_DWORD *)(v18 + 4 * i) >> 4 << 12)
| ((unsigned __int16)*(_DWORD *)(v18 + 4 * i) >> 12 << 8);
break;
case 7:
v20 = *((_DWORD *)a2 + 15);
v5 = (_WORD *)operator new[](2 * v10);
for ( j = 0; j != v10; ++j )
v5[j] = (*(_DWORD *)(v20 + 4 * j) >> 31)
| ((unsigned __int8)*(_DWORD *)(v20 + 4 * j) >> 3 << 11)
| ((unsigned __int16)*(_DWORD *)(v20 + 4 * j) >> 11 << 6)
| (2 * ((*(_DWORD *)(v20 + 4 * j) >> 19) & 0x1F));
break;
case 3:
v22 = *((_DWORD *)a2 + 15);
v23 = (_WORD *)operator new[](a4 * a3);
v24 = 0;
v5 = v23;
while ( v24 != v10 )
{
*((_BYTE *)v23 + v24) = HIBYTE(*(_DWORD *)(v22 + 4 * v24));
++v24;
}
break;
default:
if ( v7 && v9 == 1 )
{
v32 = *((int **)a2 + 15);
v25 = (_WORD *)operator new[](3 * v10);
v26 = v32;
v27 = (char *)v25 + 3 * v10 + 3;
v5 = v25;
for ( k = (char *)v25; ; *(k - 1) = BYTE2(v29) )
{
k += 3;
if ( k == v27 )
break;
*(_WORD *)(k - 3) = *v26;
v29 = *v26++;
}
}
break;
}
cocos2d::CCTexture2D::initWithData((int)this, v5, v9, a3, a4, v33);
if ( v5 != *((_WORD **)a2 + 15) && v5 )
operator delete[](v5);
*((_BYTE *)this + 88) = *((_BYTE *)a2 + 65);
return 1;
}