view stru10.cpp @ 1:ac0fb48cd27a

Texture, hwl loading, video player
author Nomad
date Tue, 09 Oct 2012 13:09:08 +0200
parents 8b8875f5b359
children fde5c5acb66e
line wrap: on
line source

#include "stru10.h"
#include "Render.h"
#include "Indoor.h"
#include "Game.h"
#include "Party.h"

#include "mm7_data.h"




//----- (0049CE9E) --------------------------------------------------------
void stru10::_49CE9E(BLVFace *pFace, RenderVertexSoft *a2, signed int a3, RenderVertexSoft *a4)
{
  char *v5; // eax@1
  signed int v6; // edx@1
  unsigned int v7; // eax@3
  signed int v8; // ecx@11
  signed int v9; // esi@11
  RenderVertexSoft *v10; // edx@12
  double v11; // st6@14
  RenderVertexSoft *v12; // edx@19
  signed int v13; // ecx@19
  signed int v14; // esi@19
  RenderVertexSoft *v15; // edi@20
  double v16; // st6@22
  signed int v17; // ecx@27
  signed int v18; // edi@27
  char *v19; // esi@28
  double v20; // st6@30
  signed int v21; // ecx@35
  signed int v22; // edi@35
  char *v23; // esi@36
  double v24; // st7@38
  signed int v25; // ecx@45
  signed int v26; // esi@45
  RenderVertexSoft *v27; // edx@46
  double v28; // st6@48
  signed int v29; // ecx@53
  signed int v30; // esi@53
  RenderVertexSoft *v31; // edi@54
  double v32; // st6@56
  signed int v33; // ecx@61
  signed int v34; // edi@61
  char *v35; // esi@62
  double v36; // st6@64
  signed int v37; // edi@69
  char *v38; // esi@70
  double v39; // st7@72
  RenderVertexSoft *v40; // esi@77
  signed int v41; // ecx@79
  signed int v42; // esi@79
  char *v43; // edx@80
  double v44; // st6@82
  RenderVertexSoft *v45; // eax@87
  signed int v46; // ecx@87
  signed int v47; // edi@87
  char *v48; // esi@88
  double v49; // st6@90
  signed int v50; // ecx@96
  signed int v51; // edi@96
  char *v52; // esi@97
  double v53; // st6@99
  signed int v54; // ecx@105
  signed int v55; // edi@105
  char *v56; // esi@106
  double v57; // st7@108
  RenderVertexSoft a2a[64]; // [sp+0h] [bp-C18h]@1
  float v59; // [sp+C00h] [bp-18h]@4
  float v60; // [sp+C04h] [bp-14h]@9
  float v61; // [sp+C08h] [bp-10h]@4
  float v62; // [sp+C0Ch] [bp-Ch]@9
  float v63; // [sp+C10h] [bp-8h]@4
  float v64; // [sp+C14h] [bp-4h]@4
  float a1a; // [sp+C20h] [bp+8h]@11
  float a1b; // [sp+C20h] [bp+8h]@19
  float a1c; // [sp+C20h] [bp+8h]@27
  float a1d; // [sp+C20h] [bp+8h]@35
  float a1e; // [sp+C20h] [bp+8h]@45
  float a1f; // [sp+C20h] [bp+8h]@53
  float a1g; // [sp+C20h] [bp+8h]@61
  float a1h; // [sp+C20h] [bp+8h]@69
  float a1i; // [sp+C20h] [bp+8h]@79
  float a1j; // [sp+C20h] [bp+8h]@87
  float a1k; // [sp+C20h] [bp+8h]@96
  float a1l; // [sp+C20h] [bp+8h]@105

  v5 = (char *)&a2a[0].flt_2C;
  v6 = 64;
  do
  {
    *(float *)v5 = 0.0;
    v5 += 48;
    --v6;
  }
  while ( v6 );
  stru10::_49D379(pFace, a2a);
  v7 = pFace->uAttributes;
  if ( v7 & 0x100 )
  {
    v63 = a2a[0].vWorldPosition.x;
    v59 = a2a[2].vWorldPosition.x;
    v61 = a2a[1].vWorldPosition.y;
    v64 = a2a[3].vWorldPosition.y;
    goto LABEL_10;
  }
  if ( v7 & 0x200 )
  {
    v63 = a2a[0].vWorldPosition.x;
    v59 = a2a[2].vWorldPosition.x;
  }
  else
  {
    if ( !(v7 & 0x400) )
      goto LABEL_10;
    v61 = a2a[0].vWorldPosition.y;
    v64 = a2a[2].vWorldPosition.y;
  }
  v62 = a2a[1].vWorldPosition.z;
  v60 = a2a[3].vWorldPosition.z;
LABEL_10:
  if ( v7 & 0x100 )
  {
    v8 = -1;
    a1a = 3.4028235e38;
    v9 = 0;
    if ( a3 > 0 )
    {
      v10 = a2;
      do
      {
        if ( v10->vWorldPosition.x <= (double)v63 )
          v11 = v63 - v10->vWorldPosition.x;
        else
          v11 = v10->vWorldPosition.x - v63;
        if ( v11 < a1a )
        {
          a1a = v11;
          v8 = v9;
        }
        ++v9;
        ++v10;
      }
      while ( v9 < a3 );
    }
    v12 = a4;
    a1b = 3.4028235e38;
    memcpy(a4, &a2[v8], 0x30u);
    v13 = -1;
    v14 = 0;
    if ( a3 > 0 )
    {
      v15 = a2;
      do
      {
        if ( v15->vWorldPosition.x <= (double)v59 )
          v16 = v59 - v15->vWorldPosition.x;
        else
          v16 = v15->vWorldPosition.x - v59;
        if ( v16 < a1b )
        {
          a1b = v16;
          v13 = v14;
        }
        ++v14;
        ++v15;
      }
      while ( v14 < a3 );
    }
    a1c = 3.4028235e38;
    memcpy(&a4[2], &a2[v13], sizeof(a4[2]));
    v17 = -1;
    v18 = 0;
    if ( a3 > 0 )
    {
      v19 = (char *)&a2->vWorldPosition.y;
      do
      {
        if ( *(float *)v19 <= (double)v61 )
          v20 = v61 - *(float *)v19;
        else
          v20 = *(float *)v19 - v61;
        if ( v20 < a1c )
        {
          a1c = v20;
          v17 = v18;
        }
        ++v18;
        v19 += 48;
      }
      while ( v18 < a3 );
    }
    a1d = 3.4028235e38;
    memcpy(&a4[1], &a2[v17], sizeof(a4[1]));
    v21 = -1;
    v22 = 0;
    if ( a3 > 0 )
    {
      v23 = (char *)&a2->vWorldPosition.y;
      do
      {
        if ( *(float *)v23 <= (double)v64 )
          v24 = v64 - *(float *)v23;
        else
          v24 = *(float *)v23 - v64;
        if ( v24 < a1d )
        {
          a1d = v24;
          v21 = v22;
        }
        ++v22;
        v23 += 48;
      }
      while ( v22 < a3 );
    }
LABEL_77:
    v40 = &a2[v21];
    goto LABEL_115;
  }
  if ( v7 & 0x200 )
  {
    v25 = -1;
    a1e = 3.4028235e38;
    v26 = 0;
    if ( a3 > 0 )
    {
      v27 = a2;
      do
      {
        if ( v27->vWorldPosition.x <= (double)v63 )
          v28 = v63 - v27->vWorldPosition.x;
        else
          v28 = v27->vWorldPosition.x - v63;
        if ( v28 < a1e )
        {
          a1e = v28;
          v25 = v26;
        }
        ++v26;
        ++v27;
      }
      while ( v26 < a3 );
    }
    v12 = a4;
    a1f = 3.4028235e38;
    memcpy(a4, &a2[v25], 0x30u);
    v29 = -1;
    v30 = 0;
    if ( a3 > 0 )
    {
      v31 = a2;
      do
      {
        if ( v31->vWorldPosition.x <= (double)v59 )
          v32 = v59 - v31->vWorldPosition.x;
        else
          v32 = v31->vWorldPosition.x - v59;
        if ( v32 < a1f )
        {
          a1f = v32;
          v29 = v30;
        }
        ++v30;
        ++v31;
      }
      while ( v30 < a3 );
    }
    a1g = 3.4028235e38;
    memcpy(&a4[2], &a2[v29], sizeof(a4[2]));
    v33 = -1;
    v34 = 0;
    if ( a3 > 0 )
    {
      v35 = (char *)&a2->vWorldPosition.z;
      do
      {
        if ( *(float *)v35 <= (double)v62 )
          v36 = v62 - *(float *)v35;
        else
          v36 = *(float *)v35 - v62;
        if ( v36 < a1g )
        {
          a1g = v36;
          v33 = v34;
        }
        ++v34;
        v35 += 48;
      }
      while ( v34 < a3 );
    }
    a1h = 3.4028235e38;
    memcpy(&a4[1], &a2[v33], sizeof(a4[1]));
    v21 = -1;
    v37 = 0;
    if ( a3 > 0 )
    {
      v38 = (char *)&a2->vWorldPosition.z;
      do
      {
        if ( *(float *)v38 <= (double)v60 )
          v39 = v60 - *(float *)v38;
        else
          v39 = *(float *)v38 - v60;
        if ( v39 < a1h )
        {
          a1h = v39;
          v21 = v37;
        }
        ++v37;
        v38 += 48;
      }
      while ( v37 < a3 );
    }
    goto LABEL_77;
  }
  if ( !(v7 & 0x400) )
    return;
  v41 = -1;
  a1i = 3.4028235e38;
  v42 = 0;
  if ( a3 > 0 )
  {
    v43 = (char *)&a2->vWorldPosition.y;
    do
    {
      if ( *(float *)v43 <= (double)v61 )
        v44 = v61 - *(float *)v43;
      else
        v44 = *(float *)v43 - v61;
      if ( v44 < a1i )
      {
        a1i = v44;
        v41 = v42;
      }
      ++v42;
      v43 += 48;
    }
    while ( v42 < a3 );
  }
  v45 = a2;
  v12 = a4;
  a1j = 3.4028235e38;
  memcpy(a4, &a2[v41], 0x30u);
  v46 = -1;
  v47 = 0;
  if ( a3 > 0 )
  {
    v48 = (char *)&a2->vWorldPosition.y;
    do
    {
      if ( *(float *)v48 <= (double)v64 )
        v49 = v64 - *(float *)v48;
      else
        v49 = *(float *)v48 - v64;
      if ( v49 < a1j )
      {
        a1j = v49;
        v46 = v47;
      }
      ++v47;
      v48 += 48;
    }
    while ( v47 < a3 );
    v45 = a2;
  }
  a1k = 3.4028235e38;
  memcpy(&a4[2], &v45[v46], sizeof(a4[2]));
  v50 = -1;
  v51 = 0;
  if ( a3 > 0 )
  {
    v52 = (char *)&v45->vWorldPosition.z;
    do
    {
      if ( *(float *)v52 <= (double)v62 )
        v53 = v62 - *(float *)v52;
      else
        v53 = *(float *)v52 - v62;
      if ( v53 < a1k )
      {
        a1k = v53;
        v50 = v51;
      }
      ++v51;
      v52 += 48;
    }
    while ( v51 < a3 );
    v45 = a2;
  }
  a1l = 3.4028235e38;
  memcpy(&a4[1], &v45[v50], sizeof(a4[1]));
  v54 = -1;
  v55 = 0;
  if ( a3 > 0 )
  {
    v56 = (char *)&v45->vWorldPosition.z;
    do
    {
      if ( *(float *)v56 <= (double)v60 )
        v57 = v60 - *(float *)v56;
      else
        v57 = *(float *)v56 - v60;
      if ( v57 < a1l )
      {
        a1l = v57;
        v54 = v55;
      }
      ++v55;
      v56 += 48;
    }
    while ( v55 < a3 );
    v45 = a2;
  }
  v40 = &v45[v54];
LABEL_115:
  memcpy(&v12[3], v40, sizeof(v12[3]));
}

//----- (0049D379) --------------------------------------------------------
int stru10::_49D379(BLVFace *pFace, RenderVertexSoft *pVertices)
{
  BLVFace *v3; // edx@1
  Vec3_short_ *v4; // ecx@1
  int v5; // eax@2
  unsigned __int16 *v6; // esi@3
  char *v7; // eax@3
  int v8; // ebx@4
  int v9; // edi@4
  int v10; // ebx@4
  int v11; // edi@4
  double v12; // st7@4
  int v13; // edi@4
  unsigned __int16 *v14; // esi@7
  char *v15; // eax@7
  int v16; // ebx@8
  int v17; // edi@8
  int v18; // ebx@8
  int v19; // edi@8
  double v20; // st7@8
  int v21; // edi@8
  unsigned __int16 *v22; // esi@11
  char *v23; // eax@11
  int v24; // ebx@12
  int v25; // edi@12
  int v26; // ebx@12
  int v27; // edi@12
  double v28; // st7@12
  int v29; // edi@12
  int v30; // eax@13
  double v31; // st7@13
  char *v32; // esi@14
  int v33; // edi@14
  int v34; // eax@24
  Vec3_short_ *v35; // eax@24
  signed int v36; // ecx@24
  signed int v37; // eax@24
  Vec3_short_ *v38; // eax@24
  signed int v39; // ecx@24
  signed int v40; // eax@24
  Vec3_short_ *v41; // eax@24
  signed int v42; // ecx@24
  signed int v43; // eax@24
  Vec3_short_ *v44; // eax@24
  signed int v45; // ecx@24
  signed int result; // eax@24
  char v47; // [sp+10h] [bp-350h]@3
  RenderVertexSoft v48; // [sp+30Ch] [bp-54h]@24
  int v49; // [sp+33Ch] [bp-24h]@16
  int v50; // [sp+340h] [bp-20h]@20
  int v51; // [sp+344h] [bp-1Ch]@18
  int v52; // [sp+348h] [bp-18h]@22
  unsigned __int16 *v53; // [sp+34Ch] [bp-14h]@3
  Vec3_short_ *v54; // [sp+350h] [bp-10h]@3
  float v55; // [sp+354h] [bp-Ch]@1
  float v56; // [sp+358h] [bp-8h]@4
  Vec3_short_ *v57; // [sp+35Ch] [bp-4h]@4
  int pFacea; // [sp+368h] [bp+8h]@2
  int pFaceb; // [sp+368h] [bp+8h]@6
  int pFacec; // [sp+368h] [bp+8h]@10
  float pFaced; // [sp+368h] [bp+8h]@13
  signed int pFacee; // [sp+368h] [bp+8h]@24
  signed int pFacef; // [sp+368h] [bp+8h]@24
  signed int pFaceg; // [sp+368h] [bp+8h]@24
  signed int pFaceh; // [sp+368h] [bp+8h]@24

  v3 = pFace;
  v4 = pIndoor->pVertices;
  LODWORD(v55) = pFace->uAttributes;
  if ( BYTE1(v55) & 1 )
  {
    v5 = pFace->uNumVertices;
    pFacea = 0;
    if ( v5 > 0 )
    {
      v6 = v3->pVertexIDs;
      v7 = &v47;
      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v6);
      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v6);
      do
      {
        v8 = *(unsigned __int16 *)((char *)v53 + (int)v6);
        v57 = &v4[*v6];
        LODWORD(v56) = v57->x + v8;
        v9 = *(__int16 *)((char *)&v54->x + (int)v6);
        v10 = v57->y;
        *((float *)v7 - 1) = (double)SLODWORD(v56);
        v57 = (Vec3_short_ *)(v10 + v9);
        v11 = pFacea;
        v12 = (double)(signed int)v57;
        ++pFacea;
        *((int *)v7 + 1) = v11;
        v13 = v3->uNumVertices;
        *(float *)v7 = v12;
        v7 += 12;
        ++v6;
      }
      while ( pFacea < v13 );
    }
  }
  if ( BYTE1(v55) & 2 )
  {
    pFaceb = 0;
    if ( (signed int)v3->uNumVertices > 0 )
    {
      v14 = v3->pVertexIDs;
      v15 = &v47;
      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v14);
      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v14;
      do
      {
        v16 = *(unsigned __int16 *)((char *)v53 + (int)v14);
        v54 = &v4[*v14];
        v57 = (Vec3_short_ *)(v54->x + v16);
        v17 = *(signed __int16 *)((char *)v14 + LODWORD(v56));
        v18 = v54->z;
        *((float *)v15 - 1) = (double)(signed int)v57;
        v57 = (Vec3_short_ *)(v18 + v17);
        v19 = pFaceb;
        v20 = (double)(signed int)v57;
        ++pFaceb;
        *((int *)v15 + 1) = v19;
        v21 = v3->uNumVertices;
        *(float *)v15 = v20;
        v15 += 12;
        ++v14;
      }
      while ( pFaceb < v21 );
    }
  }
  if ( BYTE1(v55) & 4 )
  {
    pFacec = 0;
    if ( (signed int)v3->uNumVertices > 0 )
    {
      v22 = v3->pVertexIDs;
      v23 = &v47;
      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v22);
      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v22;
      do
      {
        v24 = *(__int16 *)((char *)&v54->x + (int)v22);
        LODWORD(v55) = (unsigned int)&v4[*v22];
        v57 = (Vec3_short_ *)(*(short *)(LODWORD(v55) + 2) + v24);
        v25 = *(signed __int16 *)((char *)v22 + LODWORD(v56));
        v26 = *(short *)(LODWORD(v55) + 4);
        *((float *)v23 - 1) = (double)(signed int)v57;
        v57 = (Vec3_short_ *)(v26 + v25);
        v27 = pFacec;
        v28 = (double)(signed int)v57;
        ++pFacec;
        *((int *)v23 + 1) = v27;
        v29 = v3->uNumVertices;
        *(float *)v23 = v28;
        v23 += 12;
        ++v22;
      }
      while ( pFacec < v29 );
    }
  }
  v30 = v3->uNumVertices;
  pFaced = 3.4028235e38;
  v56 = 3.4028235e38;
  v31 = -3.4028235e38;
  v55 = -3.4028235e38;
  if ( v30 > 0 )
  {
    v32 = &v47;
    v33 = v30;
    do
    {
      if ( *((float *)v32 - 1) < (double)pFaced )
      {
        LODWORD(pFaced) = *((int *)v32 - 1);
        v49 = *((int *)v32 + 1);
      }
      if ( *((float *)v32 - 1) > (double)v55 )
      {
        LODWORD(v55) = *((int *)v32 - 1);
        v51 = *((int *)v32 + 1);
      }
      if ( *(float *)v32 < (double)v56 )
      {
        LODWORD(v56) = *(int *)v32;
        v50 = *((int *)v32 + 1);
      }
      if ( v31 < *(float *)v32 )
      {
        v31 = *(float *)v32;
        v52 = *((int *)v32 + 1);
      }
      v32 += 12;
      --v33;
    }
    while ( v33 );
  }
  v34 = v3->pVertexIDs[v49];
  v48.flt_2C = 0.0;
  v35 = &v4[v34];
  pFacee = v35->x;
  v36 = v35->y;
  v37 = v35->z;
  v48.vWorldPosition.x = (double)pFacee;
  v48.vWorldPosition.y = (double)v36;
  v48.vWorldPosition.z = (double)v37;
  memcpy(pVertices, &v48, 0x30u);
  v48.flt_2C = 0.0;
  v38 = &pIndoor->pVertices[v3->pVertexIDs[v50]];
  pFacef = v38->x;
  v39 = v38->y;
  v40 = v38->z;
  v48.vWorldPosition.x = (double)pFacef;
  v48.vWorldPosition.y = (double)v39;
  v48.vWorldPosition.z = (double)v40;
  memcpy(&pVertices[1], &v48, sizeof(pVertices[1]));
  v48.flt_2C = 0.0;
  v41 = &pIndoor->pVertices[v3->pVertexIDs[v51]];
  pFaceg = v41->x;
  v42 = v41->y;
  v43 = v41->z;
  v48.vWorldPosition.x = (double)pFaceg;
  v48.vWorldPosition.y = (double)v42;
  v48.vWorldPosition.z = (double)v43;
  memcpy(&pVertices[2], &v48, sizeof(pVertices[2]));
  v48.flt_2C = 0.0;
  v44 = &pIndoor->pVertices[v3->pVertexIDs[v52]];
  pFaceh = v44->x;
  v45 = v44->y;
  result = v44->z;
  v48.vWorldPosition.x = (double)pFaceh;
  v48.vWorldPosition.y = (double)v45;
  v48.vWorldPosition.z = (double)result;
  memcpy(&pVertices[3], &v48, sizeof(pVertices[3]));
  return result;
}


//----- (0049C9E3) --------------------------------------------------------
bool stru10::_49C9E3(BLVFace *a3, RenderVertexSoft *arg4, unsigned int uNumVertices, RenderVertexSoft *arg0)
{
  __debugbreak();
  return 0;
  /*IndoorCameraD3D *v6; // edi@1
  PolygonType v7; // al@1
  unsigned int v8; // edx@7
  char v10; // zf@10
  float v13; // ST14_4@20
  stru10 *v15; // ecx@21
  RenderVertexSoft *v16; // ST0C_4@21
  bool result; // eax@21
  float v18; // ST14_4@24
  stru10 *v19; // edi@29
  float v20; // ST14_4@30
  float v21; // ST14_4@30
  float v22; // ST14_4@30
  float v23; // ST14_4@30
  float v24; // ST14_4@31
  RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
  RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
  IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
  stru10 *v31; // [sp+84h] [bp-1Ch]@1
  float v32; // [sp+88h] [bp-18h]@8
  Vec3_float_ a1; // [sp+8Ch] [bp-14h]@1
  float v35; // [sp+9Ch] [bp-4h]@8

  _ESI = a3;
  v31 = this;
  __asm
  {
    fld     dword ptr [esi]
    fld     dword ptr [esi+4]
    fldz
  }
  v6 = pGame->pIndoorCameraD3D;
  v7 = a3->uPolygonType;
  __asm
  {
    fstp    [ebp+var_28]
    fldz
  }
  thisa = v6;
  __asm
  {
    fstp    [ebp+var_24]
    fldz
    fstp    [ebp+a1.x]
    fldz
    fstp    [ebp+a1.y]
    fldz
    fstp    [ebp+a1.z]
  }
  if ( v7 == 1 )
  {
    __asm
    {
      fchs
      fstp    [ebp+a1.x]
      fstp    [ebp+a1.y]
      fldz
      fstp    [ebp+a1.z]
    }
    a1.Normalize();
    __asm
    {
      fldz
      fstp    [ebp+var_28]
      fld1
    }
LABEL_6:
    __asm { fstp    [ebp+var_24] }
    goto LABEL_7;
  }
  __asm
  {
    fstp    st
    fstp    st
  }
  if ( v7 == 3 || v7 == 5 )
  {
    __asm
    {
      fld1
      fstp    [ebp+a1.x]
      fldz
      fstp    [ebp+a1.y]
      fldz
      fstp    [ebp+a1.z]
      fld1
      fstp    [ebp+var_28]
      fldz
    }
    goto LABEL_6;
  }
LABEL_7:
  v8 = _ESI->uAttributes;
  _ECX = arg4;
  __asm { fld     ds:flt_4D84F0 }
  if ( BYTE1(v8) & 1 )
  {
    __asm
    {
      fld     dword ptr [ecx+60h]
      fadd    dword ptr [ecx]
      fmul    st, st(1)
      fstp    [ebp+arg4]
      fld     dword ptr [ecx+94h]
      fadd    dword ptr [ecx+34h]
      fmul    st, st(1)
      fstp    [ebp+var_18]
      fld     dword ptr [ecx+68h]
      fadd    dword ptr [ecx+8]
      fmul    st, st(1)
      fstp    [ebp+var_4]
      fld     [ebp+arg4]
      fsub    dword ptr [ecx]
      fstp    [ebp+a3]
      fld     [ebp+var_18]
      fsub    dword ptr [ecx+34h]
      fstp    [ebp+var_8]
    }
  }
  if ( BYTE1(v8) & 2 )
  {
    __asm
    {
      fld     dword ptr [ecx+60h]
      fadd    dword ptr [ecx]
    }
    v10 = _ESI->uPolygonType == 1;
    __asm
    {
      fmul    st, st(1)
      fstp    [ebp+arg4]
      fld     dword ptr [ecx+64h]
      fadd    dword ptr [ecx+4]
      fmul    st, st(1)
      fstp    [ebp+var_18]
      fld     dword ptr [ecx+98h]
      fadd    dword ptr [ecx+38h]
      fmul    st, st(1)
      fstp    [ebp+var_4]
      fld     [ebp+arg4]
      fsub    dword ptr [ecx]
      fstp    [ebp+a3]
      fld     [ebp+var_4]
      fsub    dword ptr [ecx+38h]
      fstp    [ebp+var_8]
    }
    if ( v10 )
    {
      __asm
      {
        fld     [ebp+a1.x]
        fcomp   ds:dword_4D84A8
        fnstsw  ax
      }
      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
      {
        __asm
        {
          fld     [ebp+a3]
          fdiv    [ebp+a1.x]
          fstp    [ebp+a3]
        }
      }
    }
  }
  if ( BYTE1(v8) & 4 )
  {
    __asm
    {
      fld     dword ptr [ecx+60h]
      fadd    dword ptr [ecx]
    }
    v10 = _ESI->uPolygonType == 1;
    __asm
    {
      fmul    st, st(1)
      fstp    [ebp+arg4]
      fld     dword ptr [ecx+64h]
      fadd    dword ptr [ecx+4]
      fmul    st, st(1)
      fstp    [ebp+var_18]
      fld     dword ptr [ecx+98h]
      fadd    dword ptr [ecx+38h]
      fmul    st, st(1)
      fstp    [ebp+var_4]
      fstp    st
      fld     [ebp+var_18]
      fsub    dword ptr [ecx+4]
      fstp    [ebp+a3]
      fld     [ebp+var_4]
      fsub    dword ptr [ecx+38h]
      fstp    [ebp+var_8]
    }
    if ( v10 )
    {
      __asm
      {
        fld     [ebp+a1.x]
        fcomp   ds:dword_4D84A8
        fnstsw  ax
      }
      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
      {
        __asm
        {
          fld     [ebp+a3]
          fdiv    [ebp+a1.y]
          fstp    [ebp+a3]
        }
      }
    }
  }
  else
  {
    __asm { fstp    st }
  }
  if ( byte_4D864C && pGame->uFlags & 8 )
  {
    __asm { fldz }
    LODWORD(v26.vWorldPosition.x) = arg4;
    __asm { fstp    [ebp+var_60.flt_2C] }
    v26.vWorldPosition.y = v32;
    __asm { fldz }
    v26.vWorldPosition.z = v35;
    __asm { fstp    [esp+0A0h+var_A0] }
    v6->do_draw_debug_line_sw(_ECX, 0xFF00u, &v26, 0xFF0000u, 0, v13);
  }
  __asm
  {
    fld     [ebp+var_8]
    fmul    ds:flt_4D84E8
    fld     [ebp+var_8]
    fmul    [ebp+var_28]
    fld     [ebp+var_8]
    fmul    [ebp+var_24]
  }
  _EBX = arg0;
  v15 = v31;
  __asm
  {
    fst     [ebp+var_20]
    fld     [ebp+a3]
    fmul    [ebp+a1.x]
    fld     [ebp+a3]
    fmul    [ebp+a1.y]
    fld     [ebp+a3]
    fmul    [ebp+a1.z]
  }
  v16 = arg0;
  __asm
  {
    fstp    [ebp+var_8]
    fld     [ebp+arg4]
    fsub    st, st(2)
    fld     st
    fadd    st, st(6)
    fstp    dword ptr [ebx]
    fld     [ebp+var_18]
    fsub    st, st(2)
    fld     st
    fadd    st, st(6)
    fstp    dword ptr [ebx+4]
    fld     [ebp+var_4]
    fsub    [ebp+var_8]
    fst     [ebp+a3]
    fadd    st, st(5)
    fstp    dword ptr [ebx+8]
    fld     st(1)
    fsub    st, st(7)
    fstp    dword ptr [ebx+30h]
    fsub    st, st(5)
    fstp    dword ptr [ebx+34h]
    fstp    st
    fld     [ebp+a3]
    fsub    st, st(3)
    fstp    dword ptr [ebx+38h]
    fld     st(1)
    fadd    [ebp+arg4]
    fst     [ebp+a3]
    fsub    st, st(5)
    fstp    dword ptr [ebx+60h]
    fadd    [ebp+var_18]
    fstp    st(2)
    fstp    st
    fld     st
    fsub    st, st(2)
    fstp    dword ptr [ebx+64h]
    fld     [ebp+var_8]
    fadd    [ebp+var_4]
    fst     [ebp+arg0]
    fsub    [ebp+var_20]
    fstp    dword ptr [ebx+68h]
    fld     [ebp+a3]
    fadd    st, st(3)
    fstp    dword ptr [ebx+90h]
    fadd    st, st(1)
    fstp    dword ptr [ebx+94h]
    fstp    st
    fstp    st
    fld     [ebp+arg0]
    fadd    [ebp+var_20]
    fstp    dword ptr [ebx+98h]
    fldz
    fstp    [ebp+a1.x]
    fldz
    fstp    [ebp+a1.y]
    fldz
    fstp    [ebp+a1.z]
  }
  result = this->_49C8DC(v16, &a1, (float *)&a3);
  if ( result )
  {
    if ( byte_4D864C )
    {
      HIWORD(result) = HIWORD(pGame);
      if ( pGame->uFlags & 8 )
      {
        __asm
        {
          fldz
          fstp    [ebp+var_60.flt_2C]
          fld     ds:flt_4D8770
          fld     [ebp+a1.x]
          fmul    st, st(1)
        }
        LODWORD(v25.vWorldPosition.x) = (uint)arg4;
        v25.vWorldPosition.y = v32;
        __asm
        {
          fstp    [ebp+var_60.vWorldPosition.x]
          fld     [ebp+a1.y]
          fmul    st, st(1)
        }
        v25.vWorldPosition.z = v35;
        __asm
        {
          fstp    [ebp+var_60.vWorldPosition.y]
          fld     [ebp+a1.z]
          fmul    st, st(1)
          fstp    [ebp+var_60.vWorldPosition.z]
          fstp    st
          fldz
          fstp    [ebp+var_90.flt_2C]
          fldz
          fstp    [esp+0A0h+var_A0]
        }
        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, v18);
      }
    }
    __asm { fild    pBLVRenderParams->vPartyPos.z }
    memcpy(&v25, _EBX, sizeof(v25));
    __asm
    {
      fsubr   [ebp+var_90.vWorldPosition.z]
      fmul    [ebp+a1.z]
      fild    pBLVRenderParams->vPartyPos.y
      fsubr   [ebp+var_90.vWorldPosition.y]
      fmul    [ebp+a1.y]
      faddp   st(1), st
      fild    pBLVRenderParams->vPartyPos.x
      fsubr   [ebp+var_90.vWorldPosition.x]
      fmul    [ebp+a1.x]
      faddp   st(1), st
      fcomp   ds:flt_4D84E8
      fnstsw  ax
    }
    if ( !__SETP__(BYTE1(result) & 5, 0) )
    {
      result = (bool)&_EBX[1];
      memcpy(&v25, &_EBX[1], sizeof(v25));
      memcpy(&_EBX[1], &_EBX[3], sizeof(_EBX[1]));
      memcpy(&_EBX[3], &v25, sizeof(_EBX[3]));
    }
    if ( byte_4D864C && pGame->uFlags & 8 )
    {
      v19 = v31;
      if ( !LOBYTE(v31->field_4) )
      {
        __asm
        {
          fldz
          fstp    [ebp+var_60.flt_2C]
          fild    pParty->vPosition.x
        }
        a3 = (BLVFace *)(pParty->vPosition.y + pParty->sEyelevel);
        __asm
        {
          fstp    [ebp+var_60.vWorldPosition.x]
          fild    pParty->vPosition.z
          fstp    [ebp+var_60.vWorldPosition.y]
          fild    [ebp+a3]
          fstp    [ebp+var_60.vWorldPosition.z]
          fldz
          fstp    [esp+0A0h+var_A0]
        }
        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF0000u, _EBX, 0xFF0000u, 0, v20);
        __asm
        {
          fldz
          fstp    [esp+0A0h+var_A0]
        }
        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF00u, _EBX + 1, 0xFF00u, 0, v21);
        __asm
        {
          fldz
          fstp    [esp+0A0h+var_A0]
        }
        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFu, _EBX + 2, 0xFFu, 0, v22);
        __asm
        {
          fldz
          fstp    [esp+0A0h+var_A0]
        }
        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFFFFFu, _EBX + 3, 0xFFFFFFu, 0, v23);
        LOBYTE(v19->field_4) = 1;
      }
      __asm
      {
        fld     ds:flt_4D86E8
        fstp    [esp+0A0h+var_A0]
      }
      IndoorCameraD3D::debug_outline_sw(thisa, _EBX, uNumVertices, 0x1EFF1Eu, v24);
    }
    LOBYTE(result) = 1;
  }
  return result;*/
}



//----- (0049C5B0) --------------------------------------------------------
stru10::stru10()
{
  LOBYTE(this->field_4) = 0;
}

//----- (0049C5BD) --------------------------------------------------------
stru10::~stru10()
{
}

//----- (0049C5DA) --------------------------------------------------------
char stru10::_49C5DA(BLVFace *a2, RenderVertexSoft *a3, int *a4, IndoorCameraD3D_Vec4 *a5, RenderVertexSoft *a6)
{
  stru10 *v6; // edi@1
  char *v7; // eax@1
  signed int v8; // ecx@1
  IndoorCameraD3D *v9; // esi@3
  char result; // al@6
  RenderVertexSoft a4a[4]; // [sp+Ch] [bp-C0h]@1

  v6 = this;
  v7 = (char *)&a4a[0].flt_2C;
  v8 = 4;
  do
  {
    *(float *)v7 = 0.0;
    v7 += 48;
    --v8;
  }
  while ( v8 );
  v9 = pGame->pIndoorCameraD3D;
  _49CE9E(a2, a3, *a4, a4a);
  if ( byte_4D864C && pGame->uFlags & 8 )
    pGame->pIndoorCameraD3D->debug_outline_sw(a4a, 4u, 0xFF1E1Eu, 0.000099999997);
  result = _49C9E3(a2, a4a, 4u, a6);
  if ( result )
    result = _49C720(a6, a5);
  return result;
}
// 4D864C: using guessed type char byte_4D864C;

//----- (0049C681) --------------------------------------------------------
char stru10::_49C681(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
{
  stru10 *v4; // edi@1
  char *v5; // eax@1
  signed int v6; // ecx@1
  IndoorCameraD3D *v7; // esi@3
  char result; // al@6
  RenderVertexSoft a2a[4]; // [sp+Ch] [bp-C0h]@1

  v4 = this;
  v5 = (char *)&a2a[0].flt_2C;
  v6 = 4;
  do
  {
    *(float *)v5 = 0.0;
    v5 += 48;
    --v6;
  }
  while ( v6 );
  v7 = pGame->pIndoorCameraD3D;
  _49D379(pFace, a2a);
  if ( byte_4D864C && pGame->uFlags & 8 )
    pGame->pIndoorCameraD3D->debug_outline_sw(a2a, 4u, 0xFF1E1Eu, 0.000099999997);
  result = _49C9E3(pFace, a2a, 4u, pArrayOf4);
  if ( result )
    result = _49C720(pArrayOf4, a3);
  return result;
}
// 4D864C: using guessed type char byte_4D864C;

//----- (0049C720) --------------------------------------------------------
char stru10::_49C720(RenderVertexSoft *a2, IndoorCameraD3D_Vec4 *a4)
{
  char result; // al@2
  Vec3_float_ a3; // [sp+4h] [bp-34h]@1
  float v5; // [sp+30h] [bp-8h]@1
  stru10 *thisa; // [sp+34h] [bp-4h]@1

  v5 = 0.0;
  a3.x = (double)pBLVRenderParams->vPartyPos.x;
  a3.y = (double)pBLVRenderParams->vPartyPos.y;
  thisa = this;
  a3.z = (double)pBLVRenderParams->vPartyPos.z;
  if ( _49C7C5(a2, a2 + 1, &a3, a4)
    && _49C7C5(a2 + 1, a2 + 2, &a3, a4 + 1)
    && _49C7C5(a2 + 2, a2 + 3, &a3, a4 + 2) )
    result = _49C7C5(a2 + 3, a2, &a3, a4 + 3) != 0;
  else
    result = 0;
  return result;
}

//----- (0049C7C5) --------------------------------------------------------
bool stru10::_49C7C5(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4)
{
  double v5; // st7@1
  double v6; // st6@1
  double v7; // st5@1
  Vec3_float_ *result; // eax@1
  __int16 v9; // fps@3
  char v10; // c0@3
  char v11; // c2@3
  char v12; // c3@3
  float v13; // ecx@5
  double v14; // st7@5
  double v15; // st6@5
  Vec3_float_ v1; // [sp+4h] [bp-48h]@1
  Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1
  float v18; // [sp+20h] [bp-2Ch]@1
  float v19; // [sp+24h] [bp-28h]@1
  Vec3_float_ v20; // [sp+28h] [bp-24h]@1
  Vec3_float_ v21; // [sp+34h] [bp-18h]@1
  Vec3_float_ a1a; // [sp+40h] [bp-Ch]@1

  a1a.x = 0.0;
  a1a.y = 0.0;
  a1a.z = 0.0;
  v21.x = a3->x;
  v21.y = a3->y;
  v21.z = a3->z;
  v5 = a1->vWorldPosition.x;
  v6 = a1->vWorldPosition.y;
  v2.z = a1->vWorldPosition.z;
  v7 = a2->vWorldPosition.x;
  v18 = a2->vWorldPosition.y;
  v19 = a2->vWorldPosition.z;
  v20.x = v5 - v21.x;
  v20.y = v6 - v21.y;
  v20.z = v2.z - v21.z;
  LODWORD(v1.x) = (int)v20.x;
  v1.y = v20.y;
  v1.z = v20.z;
  v20.x = v7 - v5;
  v20.y = v18 - v6;
  v20.z = v19 - v2.z;
  result = Vec3_float_::Cross(&v1, &v2, v20.x, v20.y, v20.z);
  a1a.x = result->x;
  a1a.y = result->y;
  a1a.z = result->z;
  if ( a1a.x != 0.0
    || a1a.y != 0.0
    || (/*UNDEF(v9),*/ v10 = a1a.z < 0.0, v11 = 0, v12 = a1a.z == 0.0, BYTE1(result) = HIBYTE(v9), a1a.z != 0.0) )
  {
    a1a.Normalize();
    result = (Vec3_float_ *)a4;
    v13 = a1a.y;
    a4->x = a1a.x;
    v14 = v21.z * a1a.z;
    v15 = v21.y * a1a.y;
    a4->y = v13;
    a4->z = a1a.z;
    a4->dot = v14 + v15 + v21.x * a1a.x;
    LOBYTE(result) = 1;
  }
  else
  {
    LOBYTE(result) = 0;
  }
  return (bool)result;
}

//----- (0049C8DC) --------------------------------------------------------
bool stru10::_49C8DC(RenderVertexSoft *arg0, Vec3_float_ *a2, float *a3)
{
  double v4; // st7@1
  double v5; // st6@1
  double v6; // st5@1
  Vec3_float_ *result; // eax@1
  __int16 v8; // fps@3
  char v9; // c0@3
  char v10; // c2@3
  char v11; // c3@3
  float v12; // ecx@5
  double v13; // st7@5
  double v14; // st6@5
  Vec3_float_ v1; // [sp+8h] [bp-3Ch]@1
  Vec3_float_ v2; // [sp+14h] [bp-30h]@1
  float v17; // [sp+24h] [bp-20h]@1
  float v18; // [sp+28h] [bp-1Ch]@1
  float v19; // [sp+2Ch] [bp-18h]@1
  float v20; // [sp+30h] [bp-14h]@1
  float v21; // [sp+34h] [bp-10h]@1
  Vec3_float_ a1; // [sp+38h] [bp-Ch]@1

  v19 = arg0->vWorldPosition.x;
  v20 = arg0->vWorldPosition.y;
  v21 = arg0->vWorldPosition.z;
  v4 = arg0[1].vWorldPosition.x;
  v5 = arg0[1].vWorldPosition.y;
  v2.z = arg0[1].vWorldPosition.z;
  v6 = arg0[2].vWorldPosition.x;
  v17 = arg0[2].vWorldPosition.y;
  v18 = arg0[2].vWorldPosition.z;
  a1.x = v4 - v19;
  a1.y = v5 - v20;
  a1.z = v2.z - v21;
  LODWORD(v1.x) = (int)a1.x;
  v1.y = a1.y;
  v1.z = a1.z;
  a1.x = v6 - v4;
  a1.y = v17 - v5;
  a1.z = v18 - v2.z;
  result = Vec3_float_::Cross(&v1, &v2, a1.x, a1.y, a1.z);
  a1.x = result->x;
  a1.y = result->y;
  a1.z = result->z;
  if ( a1.x != 0.0
    || a1.y != 0.0
    || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, BYTE1(result) = HIBYTE(v8), a1.z != 0.0) )
  {
    a1.Normalize();
    v12 = a1.y;
    a2->x = a1.x;
    v13 = v21 * a1.z;
    v14 = v20 * a1.y;
    a2->y = v12;
    a2->z = a1.z;
    result = (Vec3_float_ *)a3;
    *a3 = -(v13 + v14 + v19 * a1.x);
    LOBYTE(result) = 1;
  }
  else
  {
    LOBYTE(result) = 0;
  }
  return (bool)result;
}