Newer
Older
AMI-Aptio-BIOS-Reversed / PurleyPlatPkg / Platform / Pei / EarlyVideoPei / ImageRenderToOutput.c
@Ajax Dong Ajax Dong 2 days ago 1 KB Full restructure
int __fastcall ImageRenderToOutput(unsigned int *p_count, _DWORD *p_n26, int a3)
{
  unsigned int count_1; // ebx
  int v4; // edi
  int count_2; // edx
  int result; // eax
  signed int count; // edx
  int v8; // ebp
  unsigned int *p_count_3; // eax
  int v10; // esi
  void *v11; // edi
  int Pool; // ecx
  unsigned int *p_count_1; // esi
  unsigned int *p_count_2; // [esp+14h] [ebp+4h]

  count_1 = *p_count;
  v4 = *(_DWORD *)(28 * *p_n26 + a3 + 808) - *(_DWORD *)(a3 + 4 * (p_n26[1] + 7 * *p_n26) + 816);
  count_2 = 8 * v4;
  if ( 8 * v4 < (int)*p_count )
    return -1;
  if ( count_2 == count_1 )
    return 0;
  count = count_2 - count_1;
  if ( count <= 4 )
  {
    if ( count )
      return ImageRenderBits(p_count, (char *)count, 0);
    else
      return 0;
  }
  v8 = (int)(count_1 + 11) / 8;
  p_count_3 = ImageRenderAllocContext();
  p_count_2 = p_count_3;
  if ( !p_count_3 )
    return -1;
  v10 = 0;
  if ( 8 * v8 == count_1 || (result = ImageRenderBits(p_count_3, (char *)(8 * v8 - count_1), 0), result >= 0) )
  {
    v11 = (void *)(v4 - v8);
    if ( (int)v11 <= 0 )
    {
      p_count_1 = p_count_2;
      return ImageRenderSetPixel(p_count, p_count_1);
    }
    Pool = PeiAllocatePool(v11);
    if ( !Pool )
      return -1;
    do
    {
      *(_BYTE *)(v10 + Pool) = (v10 & 1) != 0 ? 17 : -20;
      ++v10;
    }
    while ( v10 < (int)v11 );
    p_count_1 = p_count_2;
    result = ImageRenderReadPixel(p_count_2, (int)v11, Pool);
    if ( result >= 0 )
      return ImageRenderSetPixel(p_count, p_count_1);
  }
  return result;
}