//
// sub_8F0F14 from 0x8f0f14 to 0x8f120c (760 bytes)
//
// 9 xrefs:
// > TIFFInitPackBits @ 0x8f1244
// > TIFFInitPackBits @ 0x8f1248
// > TIFFInitPackBits @ 0x8f1254
// > TIFFInitPackBits @ 0x8f1258
// > TIFFInitPackBits @ 0x8f1264
// > TIFFInitPackBits @ 0x8f1268
// > ??> @ 0x8f12d4
// > ??> @ 0x8f12d8
// > ??> @ 0x8f12dc
//
// 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:04:13 +0000
//
int __fastcall sub_8F0F14(_DWORD *a1, _BYTE *a2, int a3)
{
char *v9; // [sp+10h] [bp-14h]
int v10; // [sp+14h] [bp-10h]
int v11; // [sp+18h] [bp-Ch]
int v12; // [sp+18h] [bp-Ch]
int v13; // [sp+18h] [bp-Ch]
char v14; // [sp+1Ch] [bp-8h]
v9 = (char *)a1[151];
v10 = a1[152];
while ( v10 > 0 && a3 > 0 )
{
v11 = (unsigned __int8)*v9++;
--v10;
if ( v11 > 127 )
v11 -= 256;
if ( v11 >= 0 )
{
if ( v11 + 1 > a3 )
{
TIFFWarningExt(a1[157], "PackBitsDecode", "Discarding %lu bytes to avoid buffer overrun", v11 - a3 + 1);
v11 = a3 - 1;
}
if ( v11 + 1 > v10 )
{
TIFFWarningExt(a1[157], "PackBitsDecode", "Terminating PackBitsDecode due to lack of data.");
break;
}
v13 = v11 + 1;
TIFFmemcpy(a2, v9, v13);
a2 += v13;
a3 -= v13;
v9 += v13;
v10 -= v13;
}
else if ( v11 != -128 )
{
v12 = 1 - v11;
if ( a3 < v12 )
{
TIFFWarningExt(a1[157], "PackBitsDecode", "Discarding %lu bytes to avoid buffer overrun", v12 - a3);
v12 = a3;
}
a3 -= v12;
v14 = *v9++;
--v10;
while ( v12-- > 0 )
*a2++ = v14;
}
}
a1[151] = v9;
a1[152] = v10;
if ( a3 <= 0 )
return 1;
TIFFErrorExt(a1[157], (int)"PackBitsDecode", "Not enough data for scanline %lu", a1[111]);
return 0;
}