view UI/Books/UIMapBook.cpp @ 1446:8b4f4c723edd

Questbook_Draw
author Ritor1
date Mon, 05 Aug 2013 22:31:12 +0600
parents 6de9c1316852
children dfc9484ed94c
line wrap: on
line source

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <assert.h>

#include "..\..\MM7.h"
#include "..\..\Render.h"
#include "..\..\Mouse.h"
#include "..\UIBooks.h"
#include "..\..\MapInfo.h"
#include "..\..\GUIWindow.h"
#include "..\..\GUIFont.h"
#include "..\..\Party.h"
#include "..\..\AudioPlayer.h"
#include "..\..\Outdoor.h"
#include "..\..\LOD.h"
#include "..\..\Allocator.h"
#include "..\..\Viewport.h"
#include "..\..\Math.h"
#include "..\..\texts.h"
//
#include "..\..\mm7_data.h"

std::array<__int16, 6> pTownPortalBook_xs = {{260, 324, 147, 385, 390,  19}};
std::array<__int16, 6> pTownPortalBook_ys = {{206,  84, 182, 239,  17, 283}};

std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = {{61, 281,  61, 281, 171}}; // 004E249C
std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = {{84,  84, 228, 228, 155}};
std::array<unsigned int, 5> pLloydsBeacons_SomeXs = {{59, 279, 59, 279, 169}};
std::array<unsigned int, 5> pLloydsBeacons_SomeYs = {{82, 82, 226, 226, 153}};




//----- (00411150) --------------------------------------------------------
void BookUI_DrawTownPortalMap()
{
  int v3; // edi@17
  GUIWindow TownPortalWindow; // [sp+Ch] [bp-64h]@1
  POINT a2; // [sp+68h] [bp-8h]@17

  pRenderer->ClearZBuffer(0, 479);
  pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook);
  pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));

  TownPortalWindow.uFrameX = game_viewport_x;
  TownPortalWindow.uFrameY = game_viewport_y;
  TownPortalWindow.uFrameWidth = game_viewport_width;
  TownPortalWindow.uFrameHeight = game_viewport_height;
  TownPortalWindow.uFrameZ = game_viewport_z;
  TownPortalWindow.uFrameW = game_viewport_w;

  const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE,
                                    PARTY_QUEST_FOUNTAIN_PIERPONT,
                                    PARTY_QUEST_FOUNTAIN_NIGHON,
                                    PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE,
                                    PARTY_QUEST_FOUNTAIN_CELESTIA,
                                    PARTY_QUEST_FOUNTAIN_THE_PIT};
  for (uint i = 0; i < 6; ++i)
  {

    if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i]))
      pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i],
                                   pTownPortalBook_ys[i],
                                   pTexture_TownPortalIcons[i], i + 1);
  }

  pMouse->GetCursorPos(&a2);
  v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;

  if (v3)
  {
    if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1]))
      pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]);
  }
  TownPortalWindow.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3);
}

//----- (00410DEC) --------------------------------------------------------
unsigned int __cdecl DrawLloydBeaconsScreen()
{
  Player *pPlayer; // esi@1
  char *pText; // eax@1
  int pTextHeight; // eax@14
  int RemainingTime; // kr08_8@14
  unsigned int pHours; // esi@14
  unsigned int pDays; // eax@14
  char *pSelectionText; // eax@19
  Texture *v19; // [sp-4h] [bp-8Ch]@4
  GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
  char *Str; // [sp+74h] [bp-14h]@14
  int BeaconID; // [sp+78h] [bp-10h]@11
  int uNumMaxBeacons; // [sp+84h] [bp-4h]@6

  pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
  pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
  pText = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
  pWindow.uFrameX = game_viewport_x;
  pWindow.uFrameY = game_viewport_y;
  pWindow.uFrameWidth = 428;
  pWindow.uFrameHeight = game_viewport_height;
  pWindow.uFrameZ = 435;
  pWindow.uFrameW = game_viewport_w;
  if ( !bRecallingBeacon )
    pText = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
  sprintf(pTmpBuf.data(), "%s", pText);
  pWindow.DrawTitleText(pBook2Font, 0, 22, 0, pTmpBuf.data(), 3);
  if ( bRecallingBeacon )
  {
    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
    v19 = pTex_tab_an_6a__zoom_off;
  }
  else
  {
    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
    v19 = pTex_tab_an_6b__zoom_on;
  }
  pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
  uNumMaxBeacons = 1;
  if ( HIBYTE(pPlayer->pActiveSkills[14]) & 1 || (pPlayer->pActiveSkills[14] & 0x80u) != 0 )
  {
    uNumMaxBeacons = 5;
  }
  else
  {
    if ( pPlayer->pActiveSkills[14] & 0x40 )
      uNumMaxBeacons = 3;
  }
  if ( uNumMaxBeacons > 0 )
  {
    for ( BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++ )
    {
      pWindow.uFrameWidth = 92;
      pWindow.uFrameHeight = 68;
      pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID];
      pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID];
      pWindow.uFrameW = pWindow.uFrameY + 67;
      pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91;
      //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
      if ( pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0 )
      {
        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
        pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
        Str = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
        pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
        pWindow.uFrameY += -6 - pTextHeight;
        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3);
        RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed;
        pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60;
        pDays = pHours / 24;
        if ( pDays )
        {
          sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days
          pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
          pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
          continue;
        }
        else
        {
          if ( pHours + 1 <= 23 )
          {
            if ( pHours < 1 )
              pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour
            else
              pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours
            sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText);
            pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
            pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
            continue;
          }
        }
        sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day
        pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
        continue;
      }
      if ( !bRecallingBeacon )
      {
        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
        pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно
      }
    }
  }
  if ( byte_506360 )
    pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
  return BeaconID;
}

//----- (00413980) --------------------------------------------------------
void BookUI_Map_Draw()
{
  unsigned int map_id; // eax@35
  Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
  char party_coord[120]; // [sp+Ch] [bp-CCh]@37
  GUIWindow map_window; // [sp+84h] [bp-54h]@35
  unsigned int textrX, textrY;

  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
  if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
  {
    buttnTxtr = pTex_tab_an_6a__zoom_off;
    textrY = pViewport->uViewportTL_Y + 2;
    textrX = pViewport->uViewportTL_X + 408;
  }
  else
  {
    buttnTxtr = pTex_tab_an_6b__zoom_on;
    textrY = pViewport->uViewportTL_Y + 1;
    textrX = pViewport->uViewportTL_X + 398;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
  {
    buttnTxtr = pTex_tab_an_7a__zoot_off;
    textrY = pViewport->uViewportTL_Y + 38;
    textrX = pViewport->uViewportTL_X + 408;
  }
  else
  {
    buttnTxtr = pTex_tab_an_7b__zoot_on;
    textrY = pViewport->uViewportTL_Y + 38;
    textrX = pViewport->uViewportTL_X + 398;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( Book_PageBtn3_flag )
  {
    buttnTxtr = pTexture_506390;
    textrY = pViewport->uViewportTL_Y + 113;
    textrX = pViewport->uViewportTL_X + 408;
  }
  else
  {
    buttnTxtr = pTexture_506394;
    textrY = pViewport->uViewportTL_Y + 113;
    textrX = pViewport->uViewportTL_X + 398;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( Book_PageBtn4_flag )
  {
    buttnTxtr = pTexture_506388;
    textrY = pViewport->uViewportTL_X + 150;
    textrX = pViewport->uViewportTL_Y + 408;
  }
  else
  {
    buttnTxtr = pTexture_50638C;
    textrY = pViewport->uViewportTL_X + 150;
    textrX = pViewport->uViewportTL_Y + 399;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( Book_PageBtn5_flag )
  {
    buttnTxtr = pTexture_506380;
    textrY = pViewport->uViewportTL_Y + 188;
    textrX = pViewport->uViewportTL_X + 408;
  }
  else
  {
    buttnTxtr = pTexture_506384;
    textrY = pViewport->uViewportTL_Y + 188;
    textrX = pViewport->uViewportTL_X + 397;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( Book_PageBtn6_flag )
  {
    buttnTxtr = pTexture_506378;
    textrY = pViewport->uViewportTL_Y + 226;
    textrX = pViewport->uViewportTL_X + 408;
  }
  else
  {
    buttnTxtr = pTexture_50637C;
    textrY = pViewport->uViewportTL_Y + 226;
    textrX = pViewport->uViewportTL_X + 397;
  }
  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
  if ( BtnDown_flag )
    viewparams->CenterOnParty2();
  if ( BtnUp_flag )
    viewparams->CenterOnParty();
  if ( Book_PageBtn3_flag )
    viewparams->_443219();
  if ( Book_PageBtn4_flag )
    viewparams->_443231();
  if ( Book_PageBtn5_flag )
    viewparams->_44323D();
  if ( Book_PageBtn6_flag )
    viewparams->_443225();

  if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
    pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
  BtnUp_flag = 0;
  BtnDown_flag = 0;
  Book_PageBtn6_flag = 0;
  Book_PageBtn5_flag = 0;
  Book_PageBtn4_flag = 0;
  Book_PageBtn3_flag = 0;
  DrawBook_Map_sub(97, 49, 361, 313, 0);
  pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
  map_window.uFrameWidth = game_viewport_width;
  map_window.uFrameHeight = game_viewport_height;
  map_window.uFrameX = game_viewport_x;
  map_window.uFrameY = game_viewport_y;
  map_window.uFrameZ = game_viewport_z;
  map_window.uFrameW = game_viewport_w;
  map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
  if ( map_id )
    map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);

  map_window.uFrameX = 0;
  sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d  y: %d"
  map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
}

//----- (00442955) --------------------------------------------------------
void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
{
  int v20; // eax@16
  signed int v21; // esi@18
  int v22; // ecx@21
  BLVMapOutline *v23; // ecx@21
  Vec3_short_ *v24; // edx@21
  Vec3_short_ *v25; // eax@21
  int v26; // ecx@21
  unsigned __int16 *v27; // edi@21
  int v28; // edx@21
  int v29; // eax@21
  double v30; // st7@23
  signed __int64 v31; // qax@23
  unsigned short *v32; // edx@23
  int textr_width; // esi@23
  signed int v34; // eax@23
  signed int v35; // ecx@23
  int v36; // esi@27
  int v37; // ecx@27
  int v38; // edx@31
  unsigned int v39; // eax@33
  short *v40; // esi@33
  short *v41; // edi@33
  unsigned __int8 v42; // cf@33
  unsigned int v43; // ecx@33
  short *v44; // edi@33
  short *v45; // esi@33
  int v46; // ecx@33
  signed int v47; // esi@38
  signed int v48; // ecx@38
  int v49; // eax@38
  signed int v50; // edx@55
  unsigned int v51; // ecx@55
  int result; // eax@72
  int v54; // esi@75
  int v55; // eax@75
  __int16 v56; // si@85
  double v57; // st7@85
  int v58; // ebx@85
  signed __int64 v59; // qax@85
  signed int v60; // edi@85
  signed __int64 v61; // qax@85
  signed int v62; // ebx@85
  signed int v63; // esi@85
  int v64; // eax@87
  unsigned int v65; // ebx@95
  unsigned short *v66; // edx@95
  unsigned __int16 *v67; // esi@96
  int v68; // edi@98
  unsigned __int16 v69; // cx@99
  unsigned int v70; // [sp-10h] [bp-48074h]@80
  unsigned int v71; // [sp-Ch] [bp-48070h]@80
  unsigned int v72; // [sp-8h] [bp-4806Ch]@80
  signed int v73; // [sp-4h] [bp-48068h]@59
  unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
  unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
  int v76; // [sp+4800Ch] [bp-58h]@23
  unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
  unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
  int v81; // [sp+48020h] [bp-44h]@23
  unsigned __int16* render16_data;
  unsigned char* texture8_data;
  unsigned char* curr_line;
  int scale_increment;
  int scaled_posX;
  int scaled_posY;
  int stepX_r;
  int stepY_r;
  unsigned int teal; // [sp+48028h] [bp-3Ch]@8
  int pCenterY; // [sp+4802Ch] [bp-38h]@1
  int screenCenter_X; // [sp+48030h] [bp-34h]@1
  int pCenterX; // [sp+48034h] [bp-30h]@1
  int v87; // [sp+48038h] [bp-2Ch]@16
  unsigned int v88; // [sp+4803Ch] [bp-28h]@16
  int black; // [sp+48040h] [bp-24h]@8
  int screenCenterY; // [sp+48044h] [bp-20h]@1
  unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
  unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
  signed int screenWidth; // [sp+48054h] [bp-10h]@8
  unsigned int v95; // [sp+48058h] [bp-Ch]@16
  int v96; // [sp+4805Ch] [bp-8h]@10
  const void *v97; // [sp+48060h] [bp-4h]@16
  unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
  int a5a; // [sp+48070h] [bp+Ch]@86

  screenCenter_X = (signed int)(tl_x + br_x) / 2;
  screenCenterY = (signed int)(tl_y + br_y) / 2;
  pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
  pCenterX = viewparams->sViewCenterX;
  pCenterY = viewparams->sViewCenterY;
  if ( viewparams->field_2C != 384 )
  {
    if ( viewparams->field_2C == 768 )
    {
      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
        viewparams->field_2C = 680;
    }
  }
  else
  {
    viewparams->sViewCenterX = viewparams->indoor_center_x;
    pCenterX = viewparams->indoor_center_x;
    pCenterY = viewparams->indoor_center_y;
    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
      viewparams->field_2C = viewparams->field_2C - 34;
  }
  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
  {
    screenWidth = br_x - tl_x + 1;
    screenHeight = br_y - tl_y + 1;
    render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
    texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
    pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
    scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->field_2C;

    v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));

    teal = (unsigned int)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30) << 16;
    //  v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);

    //   v32 = map_texture_16;
    textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
    stepY_r =            (int)(signed __int64)((double)(- pCenterY - 22528 / (viewparams->field_2C / 384)+ 32768) / v30) << 16;
    //   v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
    black = (signed __int16)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30);

    //  v76 = textr_width;
    scaled_posY = stepY_r >> 16;
    //nearest neiborhood scaling
    if ( texture8_data)  
    {
      for( uint i = 0; i < screenHeight; ++i )
      {
        curr_line=&texture8_data[scaled_posY*textr_width];
        stepX_r=teal;
        for( uint j = 0; j < screenWidth; ++j )
        {
          scaled_posX=stepX_r>>16;
          map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
          stepX_r+=scale_increment;      
        }
        stepY_r+=scale_increment;
        scaled_posY=stepY_r>>16;
      }
    }
    //move visible square to render
    for( uint i = 0; i < screenHeight; ++i )
    {
      if ( screenWidth > 0 )
        memcpy((void*)&render16_data[pRenderer->uTargetSurfacePitch * i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
    }
  }
  else
  {
    black = TargetColor(0, 0, 0);
    teal = TargetColor(0, 0xFFu, 0xFFu);
    uNumBlueFacesInBLVMinimap = 0;
    if ( pIndoor->pMapOutlines->uNumOutlines )
    {
     for ( uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i )
      {
        if ( !(BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes) & 0x20 
           || (BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes) & 0x20) ))
        {
          if ( !(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) )
          {
            if ( !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
                && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
            {
              pIndoor->pMapOutlines->pOutlines[i].uFlags = pIndoor->pMapOutlines->pOutlines[i].uFlags | 1;
              pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
            }
          }
          if ( (!(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) 
            && !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
            && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
            || pIndoor->pMapOutlines->pOutlines[i].uFlags & 1)
          {
            v93 = (unsigned __int16 *)(pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX);
            screenHeight = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].y - pCenterY;
            v20 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].y - pCenterY;
            v95 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX;
            v97 = (const void *)v20;
            v88 = (unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16;
            v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)viewparams->field_2C) >> 16;
            v93 = (unsigned __int16 *)((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16);
            screenHeight = (unsigned __int64)(v20 * (signed __int64)viewparams->field_2C) >> 16;
            pRenderer->RasterLine2D(screenCenter_X + v88, screenCenterY - v87,
            screenCenter_X + ((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - screenHeight, black);
          }
        }
      }
    }
    v21 = 0;
    if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
    {
      while ( 1 )
      {
        v22 = pBlueFacesInBLVMinimapIDs[v21];
        v87 = viewparams->field_2C;
        v23 = &pIndoor->pMapOutlines->pOutlines[v22];
        v24 = &pIndoor->pVertices[v23->uVertex1ID];
        v25 = &pIndoor->pVertices[v23->uVertex2ID];
        v26 = v25->x;
        v27 = (unsigned __int16 *)(v24->x - pCenterX);
        v28 = v24->y - pCenterY;
        v29 = v25->y - pCenterY;
        v93 = v27;
        screenHeight = v28;
        v97 = (const void *)v29;
        v87 = (unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16;
        v88 = (unsigned __int64)(v28 * (signed __int64)viewparams->field_2C) >> 16;
        uint i = (unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16;
        v95 = (unsigned __int64)(v29 * (signed __int64)viewparams->field_2C) >> 16;
        pRenderer->RasterLine2D(screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16),
        screenCenterY - v88, screenCenter_X + ((unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - v95, teal);
        ++v21;
        if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
          break;
      }
      viewparams->sViewCenterX = pCenterX;
    }
  }
  v47 = ((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 3;
  v81 = pParty->vPosition.y - pCenterY;
  v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - pCenterY) * (signed __int64)viewparams->field_2C) >> 16);
  v48 = 1;
  v49 = screenCenterY - (int)v97 - 3;
  if ( v47 >= (signed int)tl_x )
  {
    if ( v47 > (signed int)br_x )
    {
      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 6) > (signed int)br_x )
        v48 = 0;
      v47 = br_x;
    }
  }
  else
  {
    if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X) < (signed int)tl_x )
      v48 = 0;
    v47 = tl_x;
  }
  if ( v49 >= (signed int)tl_y )
  {
    if ( v49 > br_y )
    {
      if ( screenCenterY - (signed int)v97 - 6 > br_y )
        v48 = 0;
      v49 = br_y;
    }
  }
  else
  {
    if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
      v48 = 0;
    v49 = tl_y;
  }
  if ( v48 == 1 )
  {
    v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
    if ( (signed int)v51 <= 1920 )
      v50 = 7;
    if ( (signed int)v51 < 1664 )
      v50 = 6;
    if ( (signed int)v51 <= 1408 )
      v50 = 5;
    if ( (signed int)v51 < 1152 )
      v50 = 4;
    if ( (signed int)v51 <= 896 )
      v50 = 3;
    if ( (signed int)v51 < 640 )
      v50 = 2;
    if ( (signed int)v51 <= 384 )
      v50 = 1;
    if ( (signed int)v51 < 128 )
      v50 = 0;
    pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
  }
  result = TargetColor(0xFFu, 0xFFu, 0xFFu);
  pCenterX = result;
  if ( (signed int)uNumLevelDecorations > 0 )
  {
    for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
    {
      if ( pLevelDecorations[i].field_2 & 8 )
      {
        screenHeight = pLevelDecorations[i].vPosition.y - pCenterY;
        v93 = (unsigned __int16 *)(pLevelDecorations[i].vPosition.x - viewparams->sViewCenterX);
        v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
        v97 = (const void *)((unsigned __int64)(screenHeight * (signed __int64)viewparams->field_2C) >> 16);
        v55 = screenCenterY - (int)v97;
        if ( v54 >= pRenderer->raster_clip_x )
        {
          if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
          {
            if ( viewparams->field_2C > 512 )
            {
              pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, pCenterX);
              pRenderer->RasterLine2D(v54, v55 - 1, v54, v55 + 1, pCenterX);
              ++v54;
              v72 = v55 + 1;
              v71 = v54;
              v70 = v55 - 1;
            }
            else
            {
              v72 = screenCenterY - (int)v97;
              v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
              v70 = screenCenterY - (int)v97;
            }
            pRenderer->RasterLine2D(v54, v70, v71, v72, pCenterX);
          }
        }
      }
    }
  }
  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
  {
    screenCenterY = br_x - tl_x + 1;
    v95 = br_y - tl_y + 1;
    v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
    v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
    black = (1 << (v56 + 16)) / viewparams->field_2C;
    v57 = (double)(1 << (16 - v56));
    v58 = 22528 / (viewparams->field_2C / 384);
    v59 = (signed __int64)((double)(viewparams->sViewCenterX - v58 + 32768) / v57);
    v60 = (int)v59 << 16;
    v97 = (const void *)((int)v59 << 16);
    v61 = (signed __int64)((double)(32768 - v58 - pCenterY) / v57);
    pPalette_16 = (unsigned __int16 *)(v60 >> 16);
    v62 = (int)v61 << 16;
    teal = v60 >> 16;
    v63 = (signed __int16)v61;
    a4a = map_texture_16;
    result = TargetColor(0xCu, 0xCu, 0xCu);
    for ( screenCenter_X = 0; screenCenter_X < (signed int)v95; ++screenCenter_X )
    {
      if ( screenCenterY > 0 )
      {
        v96 = (v63 - 80) / 4;
        v64 = teal;
        for ( a5a = 0; a5a < screenCenterY; ++a5a )
        {
          v81 = (v64 - 80) / 4;
          if ( !pOutdoor->_47F04C(v81, v96) )
          {
            if ( pOutdoor->_47F097(v81, v96) )
            {
              if ( !((a5a + screenCenter_X) % 2) )
                *a4a = result;
            }
            else
              *a4a = 0;
          }
          ++a4a;
          v97 = (char *)v97 + black;
          v64 = (signed int)v97 >> 16;
        }
      }
      v62 += black;
      v97 = (const void *)v60;
      a4a += screenCenterY - a5a;
      v63 = v62 >> 16;
      teal = (unsigned int)pPalette_16;
    }
    v66 = map_texture_16;
    if ( (signed int)v95 > 0 )
    {
      v67 = v77;
      result = 2 * (pRenderer->uTargetSurfacePitch - screenCenterY);
      for ( v65 = v95; v65; --v65 )
      {
        if ( screenCenterY > 0 )
        {
          for ( v68 = screenCenterY; v68; --v68 )
          {
            v69 = *(short *)v66;
            if ( !*(short *)v66 || v69 == (short)result )
              *v67 = v69;
            ++v66;
            ++v67;
          }
        }
        v67 = (unsigned __int16 *)((char *)v67 + result);
      }
    }
  }
}