//
// cocos2d::tgaRGBtogreyscale from 0xb22148 to 0xb22218 (208 bytes)
//
// 1 xrefs:
// > ??> @ 0x654a8
//
// 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
//
unsigned __int8 *__fastcall cocos2d::tgaRGBtogreyscale(unsigned __int8 *result)
{
unsigned int v1; // w1
unsigned __int8 *v2; // x22
unsigned int v3; // w19
int v4; // w20
unsigned __int8 *v5; // x21
unsigned __int8 *v6; // x0
unsigned __int8 *v7; // x4
__int64 v8; // x5
int v9; // w3
int v10; // w2
int v11; // w1
v1 = result[5];
if ( v1 != 8 )
{
v2 = result;
v3 = v1 >> 3;
v4 = *((__int16 *)result + 4) * *((__int16 *)result + 3);
result = (unsigned __int8 *)malloc(v4);
v5 = result;
if ( result )
{
if ( v4 <= 0 )
{
v6 = *((unsigned __int8 **)v2 + 2);
}
else
{
v6 = *((unsigned __int8 **)v2 + 2);
v7 = v6;
v8 = 0;
do
{
v9 = v7[1];
v10 = *v7;
v11 = v7[2];
v7 += (unsigned __int8)v3;
v5[v8++] = (unsigned int)((double)v9 * 0.59 + (double)v10 * 0.3 + (double)v11 * 0.11);
}
while ( v4 > (int)v8 );
}
free(v6);
*((_QWORD *)v2 + 2) = v5;
v2[5] = 8;
result = (_BYTE *)(&dword_0 + 3);
v2[4] = 3;
}
}
return result;
}