changeset 1446:8b4f4c723edd

Questbook_Draw
author Ritor1
date Mon, 05 Aug 2013 22:31:12 +0600
parents 6de9c1316852
children 0c462cc807a1
files Awards.h GUIWindow.cpp UI/Books/UIMapBook.cpp UI/Books/UINotesBooks.cpp UI/UICharacter.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 8 files changed, 379 insertions(+), 468 deletions(-) [+]
line wrap: on
line diff
--- a/Awards.h	Sat Aug 03 00:00:31 2013 +0600
+++ b/Awards.h	Mon Aug 05 22:31:12 2013 +0600
@@ -124,4 +124,4 @@
 };
 extern std::array<AwardType, 1000> achieved_awards;
 extern int       num_achieved_awards;
-extern int       num_achieved_awards_2;
\ No newline at end of file
+extern int       full_num_items_in_book;
\ No newline at end of file
--- a/GUIWindow.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/GUIWindow.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -433,9 +433,9 @@
   InitializeBookFonts();
   v1->CreateButton(475, 445, 158, 34, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close
   pCurrentScreen = SCREEN_BOOKS;
-  num_achieved_awards_2 = 0;
-  dword_506528 = 0;
-  dword_50651C = 0;
+  full_num_items_in_book = 0;
+  books_primary_item_per_page = 0;
+  books_page_number = 0;
   num_achieved_awards = 0; 
   switch (v1->par1C)
       {
@@ -511,7 +511,7 @@
                                      pTex_tab_an_7b__zoot_on, 0);
       num_achieved_awards = 0;
       memset(achieved_awards.data(), 0, 4000);
-      for ( i = dword_506528; i < 512; ++i )
+      for ( i = books_primary_item_per_page; i < 512; ++i )
           {
          // v14 = (char *)pQuestTable[i];//(&dword_722F10)[4 * i];
           if ( _449B57_test_bit(pParty->_quest_bits, i) && pQuestTable[i] )
@@ -522,7 +522,7 @@
           }
       v12 = num_achieved_awards;
       num_achieved_awards = 0;
-      num_achieved_awards_2 = v12;
+      full_num_items_in_book = v12;
       }
       break;
 
@@ -566,7 +566,7 @@
                                                     UIMSG_ClickBooksBtn,  7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors"
 
       num_achieved_awards = 0;
-      for ( i = dword_506528; i < 196; ++i )
+      for ( i = books_primary_item_per_page; i < 196; ++i )
             if ( _506568_autonote_type == pAutonoteTxt[i].eType)//dword_72371C[2 * v10] )
               {
               if ( i )
@@ -652,10 +652,10 @@
       v26.uFrameW = v26.uFrameHeight + 69;
       memset(&achieved_awards, 0, 4000);
       memset(byte_5C6D50.data(), 0, 0x64u);
-      if ( dword_506528 < 29 )
+      if ( books_primary_item_per_page < 29 )
           {
-          v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528];
-          for(int i=dword_506528+1;i<dword_506528+31;i++)
+          v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * books_primary_item_per_page];
+          for(int i = books_primary_item_per_page+1; i < books_primary_item_per_page + 31; i++)
               {
               v4 = pStorylineText->StoreLine[i].pText;
               if ( *v3 )
--- a/UI/Books/UIMapBook.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/UI/Books/UIMapBook.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -36,25 +36,20 @@
 //----- (00411150) --------------------------------------------------------
 void BookUI_DrawTownPortalMap()
 {
-  //signed int v0; // edi@1
-  //__int16 v1; // dx@8
-  //POINT *v2; // edi@17
   int v3; // edi@17
-  //__int16 v4; // dx@24
-  GUIWindow v6; // [sp+Ch] [bp-64h]@1
-  //POINT v7; // [sp+60h] [bp-10h]@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));
 
-  v6.uFrameX = game_viewport_x;
-  v6.uFrameY = game_viewport_y;
-  v6.uFrameWidth = game_viewport_width;
-  v6.uFrameHeight = game_viewport_height;
-  v6.uFrameZ = game_viewport_z;
-  v6.uFrameW = game_viewport_w;
+  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,
@@ -79,7 +74,7 @@
     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]);
   }
-  v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
+  TownPortalWindow.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3);
 }
 
 //----- (00410DEC) --------------------------------------------------------
@@ -87,28 +82,15 @@
 {
   Player *pPlayer; // esi@1
   char *pText; // eax@1
-  //unsigned __int16 v2; // ax@6
-  //unsigned int result; // eax@11
-  //unsigned int v4; // esi@13
-  //unsigned int v5; // ecx@13
-  //char v6; // zf@13
-  //LloydBeacon *v7; // esi@14
   int pTextHeight; // eax@14
   int RemainingTime; // kr08_8@14
   unsigned int pHours; // esi@14
   unsigned int pDays; // eax@14
   char *pSelectionText; // eax@19
-  //char *v13; // ecx@22
-  //int v14; // eax@27
   Texture *v19; // [sp-4h] [bp-8Ch]@4
   GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
-  //unsigned int v23; // [sp+64h] [bp-24h]@14
-  //__int64 v24; // [sp+68h] [bp-20h]@14
-  //unsigned int v25; // [sp+70h] [bp-18h]@13
   char *Str; // [sp+74h] [bp-14h]@14
   int BeaconID; // [sp+78h] [bp-10h]@11
-  //LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
-  //RGBTexture *v29; // [sp+80h] [bp-8h]@12
   int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
 
   pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
@@ -123,7 +105,7 @@
   if ( !bRecallingBeacon )
     pText = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
   sprintf(pTmpBuf.data(), "%s", pText);
-  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3);
+  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);
@@ -335,10 +317,6 @@
 //----- (00442955) --------------------------------------------------------
 void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
 {
-  //unsigned int v11; // edx@11
-  //__int16 v12; // cx@12
-  //signed int v13; // eax@15
-  //int v14; // eax@16
   int v20; // eax@16
   signed int v21; // esi@18
   int v22; // ecx@21
@@ -372,7 +350,6 @@
   signed int v50; // edx@55
   unsigned int v51; // ecx@55
   int result; // eax@72
-  int v53; // eax@75
   int v54; // esi@75
   int v55; // eax@75
   __int16 v56; // si@85
@@ -415,7 +392,6 @@
   unsigned int v88; // [sp+4803Ch] [bp-28h]@16
   int black; // [sp+48040h] [bp-24h]@8
   int screenCenterY; // [sp+48044h] [bp-20h]@1
-  unsigned int i; // [sp+48048h] [bp-1Ch]@9
   unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
   unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
   signed int screenWidth; // [sp+48054h] [bp-10h]@8
@@ -620,134 +596,112 @@
     pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
   }
   result = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  v95 = 0;
   pCenterX = result;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
-    screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
-    do
+    for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
     {
-      if ( *(char *)(screenWidth - 2) & 8 )
+      if ( pLevelDecorations[i].field_2 & 8 )
       {
-        v53 = *(int *)(screenWidth + 4) - pCenterY;
-        v93 = (unsigned __int16 *)(*(int *)screenWidth - viewparams->sViewCenterX);
-              screenHeight = v53;
-              v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
-              v97 = (const void *)((unsigned __int64)(v53 * (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 )
-                  {
-                    v96 = v55 + 1;
-                    black = v55 - 1;
-                    pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, pCenterX);
-                    pRenderer->RasterLine2D(v54, black, v54, v96, pCenterX);
-                    ++v54;
-                    v72 = v96;
-                    v71 = v54;
-                    v70 = black;
-                  }
-                  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);
-                }
-              }
+        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;
             }
-            ++v95;
-            result = v95;
-            screenWidth += 32;
-            }
-            while ( (signed int)v95 < (signed int)uNumLevelDecorations );
-        }
-    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);
-        screenCenter_X = 0;
-        for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X )
+            else
             {
-            a5a = 0;
-            if ( screenCenterY > 0 )
-                {
-                v96 = (v63 - 80) / 4;
-                v64 = teal;
-                do
-                    {
-                    v81 = (v64 - 80) / 4;
-                    if ( !pOutdoor->_47F04C(v81, v96) )
-                        {
-                        if ( pOutdoor->_47F097(v81, v96) )
-                            {
-                            if ( !((a5a + screenCenter_X) % 2) )
-                                *a4a = i;
-                            }
-                        else
-                            {
-                            *a4a = 0;
-                            }
-                        }
-                    ++a4a;
-                    v97 = (char *)v97 + black;
-                    v64 = (signed int)v97 >> 16;
-                    ++a5a;
-                    }
-                    while ( a5a < screenCenterY );
-                }
-            v62 += black;
-            v97 = (const void *)v60;
-            a4a += screenCenterY - a5a;
-            v63 = v62 >> 16;
-            ++screenCenter_X;
-            teal = (unsigned int)pPalette_16;
+              v72 = screenCenterY - (int)v97;
+              v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
+              v70 = screenCenterY - (int)v97;
             }
-        v65 = v95;
-        v66 = map_texture_16;
-        if ( (signed int)v95 > 0 )
+            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) )
             {
-            v67 = v77;
-            result = 2 * (pRenderer->uTargetSurfacePitch - screenCenterY);
-            do
-                {
-                if ( screenCenterY > 0 )
-                    {
-                    v68 = screenCenterY;
-                    do
-                        {
-                        v69 = *(short *)v66;
-                        if ( !*(short *)v66 || v69 == (short)i )
-                            *v67 = v69;
-                        ++v66;
-                        ++v67;
-                        --v68;
-                        }
-                        while ( v68 );
-                    }
-                v67 = (unsigned __int16 *)((char *)v67 + result);
-                --v65;
-                }
-                while ( v65 );
+              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);
+      }
+    }
+  }
+}
--- a/UI/Books/UINotesBooks.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/UI/Books/UINotesBooks.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -42,272 +42,229 @@
         return pGlobalTXT_LocalizationStrings[56]; // "Day"
     }
 
-
-
-
-
 //----- (00413D6F) --------------------------------------------------------
 void BookUI_Calendar_Draw()
-    {
-    unsigned int v0; // esi@1
-    //char *v1; // eax@5
-    int v2; // ecx@5
-    char *v3; // eax@6
-    GUIWindow a1; // [sp+Ch] [bp-60h]@5
-    unsigned int v6; // [sp+60h] [bp-Ch]@1
-    //int v7; // [sp+64h] [bp-8h]@1
-    //int a5; // [sp+68h] [bp-4h]@1
-
+{
+  int am; // ecx@5
+  char *pMapName; // eax@6
+  GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5
+  unsigned int pMapID; // [sp+60h] [bp-Ch]@1
+  unsigned int pHour;
 
-    static unsigned int pDayMoonPhase[28] = // 4E1B18
-        {
-        0, 0, 0,
-        1, 1, 1, 1,
-        2, 2, 2,
-        3, 3, 3, 3,
-        4, 4, 4,
-        3, 3, 3, 3,
-        2, 2, 2,
-        1, 1, 1, 1
-        };
-
+  static unsigned int pDayMoonPhase[28] = // 4E1B18
+  {
+    0, 0, 0,
+    1, 1, 1, 1,
+    2, 2, 2,
+    3, 3, 3, 3,
+    4, 4, 4,
+    3, 3, 3, 3,
+    2, 2, 2,
+    1, 1, 1, 1
+  };
 
-    v0 = pParty->uCurrentHour;
-    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
-    if ( (signed int)v0 <= 12 )
-        {
-        if ( !v0 )
-            v0 = 12;
-        }
-    else
-        {
-        v0 -= 12;
-        }
-    a1.uFrameX = game_viewport_x;
-    a1.uFrameY = game_viewport_y;
-    a1.uFrameWidth = game_viewport_width;
-    a1.uFrameHeight = game_viewport_height;
-    a1.uFrameZ = game_viewport_z;
-    a1.uFrameW = game_viewport_w;
-    a1.DrawTitleText(pBook2Font, 0, 0x16u, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia"
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
+  pHour = pParty->uCurrentHour;
+  if ( (signed int)pHour >= 12 )
+  {
+    pHour -= 12;
+    if ( !pHour )
+      pHour = 12;
+    am = 1;
+  }
+  else
+    am = 0;
 
-    v2 = 0;
-    if ( pParty->uCurrentHour >= 12 )
-        {
-        if ( pParty->uCurrentHour >= 24 )
-            v2=0;
-        else
-            v2=1;
-        }
+  calendar_window.uFrameX = game_viewport_x;
+  calendar_window.uFrameY = game_viewport_y;
+  calendar_window.uFrameWidth = game_viewport_width;
+  calendar_window.uFrameHeight = game_viewport_height;
+  calendar_window.uFrameZ = game_viewport_z;
+  calendar_window.uFrameW = game_viewport_w;
+  calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia"
 
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s",
-        pGlobalTXT_LocalizationStrings[526], // "Time"
-        v0,
-        pParty->uCurrentMinute,
-        aAMPMNames[v2],
-        GetDayPart());
-    a1.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0);
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", pGlobalTXT_LocalizationStrings[526], // "Time"
+     pHour, pParty->uCurrentMinute, aAMPMNames[am], GetDayPart());
+  calendar_window.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0);
 
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s",
-        pGlobalTXT_LocalizationStrings[56], // "Day"
-        pParty->uDaysPlayed + 1,
-        aDayNames[pParty->uDaysPlayed % 7]);
-    a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0);
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[56], // "Day"
+     pParty->uDaysPlayed + 1, aDayNames[pParty->uDaysPlayed % 7]);
+  calendar_window.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0);
 
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s",
-        pGlobalTXT_LocalizationStrings[146], // "Month"
-        pParty->uCurrentMonth + 1,
-        aMonthNames[pParty->uCurrentMonth]);
-    a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0);
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", pGlobalTXT_LocalizationStrings[146], // "Month"
+        pParty->uCurrentMonth + 1, aMonthNames[pParty->uCurrentMonth]);
+  calendar_window.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0);
 
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year"
-    a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0);
-
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon"
-    a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0);
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year"
+  calendar_window.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0);
 
-    v6 = pMapStats->GetMapInfo(pCurrentMapName.data());
-    if ( v6 )
-        v3 = pMapStats->pInfos[v6].pName;
-    else
-        v3 = "Unknown";
-    sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3); // "Location"
-    a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0);
-    }
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon"
+  calendar_window.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0);
 
-
-
-
+  pMapID = pMapStats->GetMapInfo(pCurrentMapName.data());
+  if ( pMapID )
+    pMapName = pMapStats->pInfos[pMapID].pName;
+  else
+    pMapName = "Unknown";
+  sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], pMapName); // "Location"
+  calendar_window.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0);
+}
 
 //----- (00413126) --------------------------------------------------------
 void BookUI_Questbook_Draw()
-    {
-    unsigned int v0; // eax@3
-    unsigned int v1; // eax@7
-    int v2; // ecx@11
-    int v3; // ebx@16
-    int v4; // eax@19
-    const char *v5; // edi@19
-    int v6; // eax@19
-    unsigned int v7; // edi@19
-    unsigned int v8; // [sp-8h] [bp-68h]@3
-    unsigned int v9; // [sp-8h] [bp-68h]@7
-    Texture *v10; // [sp-4h] [bp-64h]@3
-    Texture *v11; // [sp-4h] [bp-64h]@7
-    GUIWindow a1; // [sp+Ch] [bp-54h]@9
+{
+  unsigned int pBookmarkX; // eax@3
+  int pTextHeight; // eax@19
+  unsigned int pBookmarkY; // [sp-8h] [bp-68h]@3
+  Texture *pBookmarkTexture; // [sp-4h] [bp-64h]@3
+  GUIWindow questbook_window; // [sp+Ch] [bp-54h]@9
 
-    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook);
-    if ( BtnUp_flag || !dword_506528 )
-        {
-        v10 = pTex_tab_an_6a__zoom_off;
-        v8 = pViewport->uViewportTL_Y + 2;
-        v0 = pViewport->uViewportTL_X + 407;
-        }
-    else
-        {
-        v10 = pTex_tab_an_6b__zoom_on;
-        v8 = pViewport->uViewportTL_Y + 1;
-        v0 = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(v0, v8, v10);
-    if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
-        {
-        v11 = pTex_tab_an_7a__zoot_off;
-        v9 = pViewport->uViewportTL_Y + 38;
-        v1 = pViewport->uViewportTL_X + 407;
-        }
-    else
-        {
-        v11 = pTex_tab_an_7b__zoot_on;
-        v9 = pViewport->uViewportTL_Y + 38;
-        v1 = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(v1, v9, v11);
-    a1.uFrameWidth = game_viewport_width;
-    a1.uFrameHeight = game_viewport_height;
-    a1.uFrameX = game_viewport_x;
-    a1.uFrameY = game_viewport_y;
-    a1.uFrameZ = game_viewport_z;
-    a1.uFrameW = game_viewport_w;
-    a1.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests"
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook);
+  if ( BtnUp_flag || !books_primary_item_per_page )
+  {
+    pBookmarkTexture = pTex_tab_an_6a__zoom_off;
+    pBookmarkY = pViewport->uViewportTL_Y + 2;
+    pBookmarkX = pViewport->uViewportTL_X + 407;
+  }
+  else
+  {
+    pBookmarkTexture = pTex_tab_an_6b__zoom_on;
+    pBookmarkY = pViewport->uViewportTL_Y + 1;
+    pBookmarkX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(pBookmarkX, pBookmarkY, pBookmarkTexture);//Bookmark Up(Закладка вверх)
+  if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
+  {
+    pBookmarkTexture = pTex_tab_an_7a__zoot_off;
+    pBookmarkY = pViewport->uViewportTL_Y + 38;
+    pBookmarkX = pViewport->uViewportTL_X + 407;
+  }
+  else
+  {
+    pBookmarkTexture = pTex_tab_an_7b__zoot_on;
+    pBookmarkY = pViewport->uViewportTL_Y + 38;
+    pBookmarkX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(pBookmarkX, pBookmarkY, pBookmarkTexture);//Bookmark Down(Закладка вниз)
+  questbook_window.uFrameWidth = game_viewport_width;
+  questbook_window.uFrameHeight = game_viewport_height;
+  questbook_window.uFrameX = game_viewport_x;
+  questbook_window.uFrameY = game_viewport_y;
+  questbook_window.uFrameZ = game_viewport_z;
+  questbook_window.uFrameW = game_viewport_w;
+  questbook_window.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests"
 
-    a1.uFrameX = 48;
-    a1.uFrameY = 70;
-    a1.uFrameWidth = 360;
-    a1.uFrameHeight = 264;
-    a1.uFrameZ = 407;
-    a1.uFrameW = 333;
-    if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
-        {
-        pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
-        v2 = dword_50651C++;
-        dword_506528 += num_achieved_awards;
-        byte_506130[v2] = num_achieved_awards;
-        }
-    if ( BtnUp_flag && dword_50651C )
-        {
-        pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
-        --dword_50651C;
-        dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
-        }
-    if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) )
-        {
-        v3 = 0;
-        dword_50651C = 0;
-        dword_506528 = 0;
-        }
-    BtnDown_flag = 0;
-    BtnUp_flag = 0;
-    num_achieved_awards = 0;
-    while ( v3 < num_achieved_awards_2 )
-        {
-        v4 = achieved_awards[v3];
-        ++num_achieved_awards;
-        v5 = pQuestTable[v4];//(&dword_722F10)[4 * v4];
-        a1.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[v4], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0);
-        v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
-        v7 = a1.uFrameY + v6;
-        if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight )
-            break;
-        pRenderer->DrawTextureTransparent(100, v7 + 12, pSpellBookPagesTextr_10);
-        ++v3;
-        a1.uFrameY = v7 + 24;
-        }
-    }
-
+  questbook_window.uFrameX = 48;
+  questbook_window.uFrameY = 70;
+  questbook_window.uFrameWidth = 360;
+  questbook_window.uFrameHeight = 264;
+  questbook_window.uFrameZ = 407;
+  questbook_window.uFrameW = 333;
+  if ( BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book )//Click Bookmark Down
+  {
+    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
+    books_primary_item_per_page += num_achieved_awards;
+    books_num_items_per_page[books_page_number++] = num_achieved_awards;
+  }
+  if ( BtnUp_flag && books_page_number )//Click Bookmark Up
+  {
+    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
+    --books_page_number;
+    books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
+  }
+  if ( !num_achieved_awards || !books_primary_item_per_page )
+  {
+    books_page_number = 0;
+    books_primary_item_per_page = 0;
+  }
+  BtnDown_flag = 0;
+  BtnUp_flag = 0;
+  num_achieved_awards = 0;
+  for ( uint i = books_primary_item_per_page; i < full_num_items_in_book; ++i )
+  {
+    ++num_achieved_awards;
+    //v5 = pQuestTable[achieved_awards[v3]];//(&dword_722F10)[4 * v4];
+    questbook_window.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[achieved_awards[i]], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0);
+    pTextHeight = pAutonoteFont->CalcTextHeight(pQuestTable[achieved_awards[i]], &questbook_window, 1, 0);
+    if ( (signed int)(questbook_window.uFrameY + pTextHeight) > (signed int)questbook_window.uFrameHeight )
+      break;
+    pRenderer->DrawTextureTransparent(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
+    questbook_window.uFrameY = (questbook_window.uFrameY + pTextHeight) + 24;
+  }
+}
 
 //----- (0041338E) --------------------------------------------------------
 void BookUI_Autonotes_Draw()
+{
+  unsigned int v0; // eax@3
+  unsigned int v1; // eax@7
+  signed int v2; // ebp@11
+  unsigned int v3; // eax@18
+  unsigned int v4; // eax@24
+  unsigned int v5; // eax@30
+  unsigned int v6; // eax@36
+  unsigned int v7; // eax@42
+  signed int v8; // ebp@47
+  int v9; // eax@52
+  int v10; // eax@56
+  int v11; // edx@57
+  int v12; // ebp@64
+  int v13; // eax@65
+  const char *v14; // edi@65
+  int v15; // eax@65
+  unsigned int v16; // edi@65
+  unsigned int v17; // [sp-8h] [bp-70h]@3
+  unsigned int v18; // [sp-8h] [bp-70h]@7
+  unsigned int v19; // [sp-8h] [bp-70h]@18
+  unsigned int v20; // [sp-8h] [bp-70h]@24
+  unsigned int v21; // [sp-8h] [bp-70h]@30
+  unsigned int v22; // [sp-8h] [bp-70h]@36
+  unsigned int v23; // [sp-8h] [bp-70h]@42
+  Texture *v24; // [sp-4h] [bp-6Ch]@3
+  Texture *v25; // [sp-4h] [bp-6Ch]@7
+  Texture *v26; // [sp-4h] [bp-6Ch]@18
+  Texture *v27; // [sp-4h] [bp-6Ch]@24
+  Texture *v28; // [sp-4h] [bp-6Ch]@30
+  Texture *v29; // [sp-4h] [bp-6Ch]@36
+  Texture *v30; // [sp-4h] [bp-6Ch]@42
+  signed __int16 v31; // [sp+10h] [bp-58h]@1
+  char *v32; // [sp+10h] [bp-58h]@49
+  GUIWindow a1; // [sp+14h] [bp-54h]@46
+
+  v31 = 0;
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook);
+  if ( BtnUp_flag || !books_primary_item_per_page )
+  {
+    v24 = pTex_tab_an_6a__zoom_off;
+    v17 = pViewport->uViewportTL_Y + 2;
+    v0 = pViewport->uViewportTL_X + 407;
+  }
+  else
+  {
+    v24 = pTex_tab_an_6b__zoom_on;
+    v17 = pViewport->uViewportTL_Y + 1;
+    v0 = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(v0, v17, v24);
+  if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
+  {
+    v25 = pTex_tab_an_7a__zoot_off;
+    v18 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 407;
+  }
+  else
+  {
+    v25 = pTex_tab_an_7b__zoot_on;
+    v18 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(v1, v18, v25);
+  if ( !Book_PageBtn3_flag )//Potions_page_flag
+  {
+    if (_506568_autonote_type != AUTONOTE_POTION_RECEPIE)
     {
-    unsigned int v0; // eax@3
-    unsigned int v1; // eax@7
-    signed int v2; // ebp@11
-    unsigned int v3; // eax@18
-    unsigned int v4; // eax@24
-    unsigned int v5; // eax@30
-    unsigned int v6; // eax@36
-    unsigned int v7; // eax@42
-    signed int v8; // ebp@47
-    int v9; // eax@52
-    int v10; // eax@56
-    int v11; // edx@57
-    int v12; // ebp@64
-    int v13; // eax@65
-    const char *v14; // edi@65
-    int v15; // eax@65
-    unsigned int v16; // edi@65
-    unsigned int v17; // [sp-8h] [bp-70h]@3
-    unsigned int v18; // [sp-8h] [bp-70h]@7
-    unsigned int v19; // [sp-8h] [bp-70h]@18
-    unsigned int v20; // [sp-8h] [bp-70h]@24
-    unsigned int v21; // [sp-8h] [bp-70h]@30
-    unsigned int v22; // [sp-8h] [bp-70h]@36
-    unsigned int v23; // [sp-8h] [bp-70h]@42
-    Texture *v24; // [sp-4h] [bp-6Ch]@3
-    Texture *v25; // [sp-4h] [bp-6Ch]@7
-    Texture *v26; // [sp-4h] [bp-6Ch]@18
-    Texture *v27; // [sp-4h] [bp-6Ch]@24
-    Texture *v28; // [sp-4h] [bp-6Ch]@30
-    Texture *v29; // [sp-4h] [bp-6Ch]@36
-    Texture *v30; // [sp-4h] [bp-6Ch]@42
-    signed __int16 v31; // [sp+10h] [bp-58h]@1
-    char *v32; // [sp+10h] [bp-58h]@49
-    GUIWindow a1; // [sp+14h] [bp-54h]@46
-
-    v31 = 0;
-    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook);
-    if ( BtnUp_flag || !dword_506528 )
-        {
-        v24 = pTex_tab_an_6a__zoom_off;
-        v17 = pViewport->uViewportTL_Y + 2;
-        v0 = pViewport->uViewportTL_X + 407;
-        }
-    else
-        {
-        v24 = pTex_tab_an_6b__zoom_on;
-        v17 = pViewport->uViewportTL_Y + 1;
-        v0 = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(v0, v17, v24);
-    if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
-        {
-        v25 = pTex_tab_an_7a__zoot_off;
-        v18 = pViewport->uViewportTL_Y + 38;
-        v1 = pViewport->uViewportTL_X + 407;
-        }
-    else
-        {
-        v25 = pTex_tab_an_7b__zoot_on;
-        v18 = pViewport->uViewportTL_Y + 38;
-        v1 = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(v1, v18, v25);
-    if ( !Book_PageBtn3_flag )//Potions_page_flag
-        {
-        if (_506568_autonote_type != AUTONOTE_POTION_RECEPIE)
-            {
-            pRenderer->DrawTextureTransparent(
-                pViewport->uViewportTL_X + 408,
+      pRenderer->DrawTextureTransparent(
+              pViewport->uViewportTL_X + 408,
                 pViewport->uViewportTL_Y + 113,
                 pTexture_506390);
             v2 = 1;
@@ -464,9 +421,9 @@
     a1.uFrameW = 333;
     if ( v31 )
         {
-        num_achieved_awards_2 = 0;
-        dword_506528 = 0;
-        dword_50651C = 0;
+        full_num_items_in_book = 0;
+        books_primary_item_per_page = 0;
+        books_page_number = 0;
         num_achieved_awards = 0;
         v8 = 0;
         do
@@ -488,34 +445,34 @@
             ++v8;
             }
             while ( v8 < 196 );
-            num_achieved_awards_2 = num_achieved_awards;
+            full_num_items_in_book = num_achieved_awards;
         }
     else
         {
         if ( BtnDown_flag )
             {
-            v10 = num_achieved_awards + dword_506528;
-            if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 )
+            v10 = num_achieved_awards + books_primary_item_per_page;
+            if ( num_achieved_awards + books_primary_item_per_page < full_num_items_in_book )
                 {
-                v11 = dword_50651C++;
-                byte_506130[v11] = num_achieved_awards;
-                dword_506528 = v10;
+                v11 = books_page_number++;
+                books_num_items_per_page[v11] = num_achieved_awards;
+                books_primary_item_per_page = v10;
                 pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
                 }
             }
-        if ( BtnUp_flag && dword_50651C )
+        if ( BtnUp_flag && books_page_number )
             {
-            --dword_50651C;
-            dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
+            --books_page_number;
+            books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
             pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
             }
-        if ( !num_achieved_awards || dword_506528 < 1 )
+        if ( !num_achieved_awards || books_primary_item_per_page < 1 )
             {
-            dword_506528 = 0;
-            dword_50651C = 0;
+            books_primary_item_per_page = 0;
+            books_page_number = 0;
             }
         }
-    v12 = dword_506528;
+    v12 = books_primary_item_per_page;
     Autonotes_Instructors_page_flag = 0;
     BtnDown_flag = 0;
     BtnUp_flag = 0;
@@ -525,7 +482,7 @@
     Book_PageBtn5_flag = 0;//Autonotes_Obelisks_page_flag
     Book_PageBtn4_flag = 0;//Fontains_page_flag
     Book_PageBtn3_flag = 0;//Potions_page_flag
-    while ( v12 < num_achieved_awards_2 )
+    while ( v12 < full_num_items_in_book )
         {
         v13 = achieved_awards[v12];
         ++num_achieved_awards;
@@ -563,7 +520,7 @@
   GUIWindow a1; // [sp+8h] [bp-54h]@10
 
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11);
-  if ( BtnUp_flag || !dword_506528 )
+  if ( BtnUp_flag || !books_primary_item_per_page )
   {
     v13 = pTex_tab_an_6a__zoom_off;
     v11 = pViewport->uViewportTL_Y + 2;
@@ -577,7 +534,7 @@
   }
   pRenderer->DrawTextureTransparent(v0, v11, v13);
 
-  if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
+  if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
   {
     v14 = pTex_tab_an_7a__zoot_off;
     v12 = pViewport->uViewportTL_Y + 38;
@@ -591,9 +548,9 @@
   }
   pRenderer->DrawTextureTransparent(v1, v12, v14);
 
-  if ( !byte_5C6D50[dword_506528] )
+  if ( !byte_5C6D50[books_primary_item_per_page] )
   {
-    v2 = achieved_awards[dword_506528];
+    v2 = achieved_awards[books_primary_item_per_page];
     a1.uFrameWidth = game_viewport_width;
     a1.uFrameX = game_viewport_x;
     a1.uFrameY = game_viewport_y;
@@ -613,26 +570,26 @@
   a1.uFrameZ = 407;
   a1.uFrameHeight = v4 * 264 / v4;
   a1.uFrameW = a1.uFrameHeight + 69;
-  if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
+  if ( BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book )
   {
     pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
-    v5 = dword_50651C++;
-    dword_506528 += num_achieved_awards;
-    byte_506130[v5] = num_achieved_awards;
+    v5 = books_page_number++;
+    books_primary_item_per_page += num_achieved_awards;
+    books_num_items_per_page[v5] = num_achieved_awards;
   }
-  if ( BtnUp_flag && dword_50651C )
+  if ( BtnUp_flag && books_page_number )
   {
     pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
-    --dword_50651C;
-    dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
+    --books_page_number;
+    books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
   }
-  if ( !num_achieved_awards || dword_506528 < 1 )
+  if ( !num_achieved_awards || books_primary_item_per_page < 1 )
   {
-    dword_506528 = 0;
-    dword_50651C = 0;
+    books_primary_item_per_page = 0;
+    books_page_number = 0;
   }
   BtnDown_flag = 0;
-  v6 = achieved_awards[dword_506528];
+  v6 = achieved_awards[books_primary_item_per_page];
   BtnUp_flag = 0;
   num_achieved_awards = 0;
   //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
@@ -640,7 +597,7 @@
   v8 = BuildDialogueString(pStorylineText->StoreLine[v6].pText, uActiveCharacter - 1, 0, 0, 0, (__int64 *)&pParty->field_3C._s_times[ v6 + 21]);
   if ( v7 )
   {
-    v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
+    v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[books_primary_item_per_page]);
     a1.DrawText(pAutonoteFont, 1, 0, ui_book_journal_text_color, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, ui_book_journal_text_shadow);
     ++num_achieved_awards;
   }
--- a/UI/UICharacter.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/UI/UICharacter.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -627,49 +627,49 @@
   strcat(pTmpBuf.data(), "\f00000");
 
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf.data(), 0, 0, 0);
-  result = dword_506528;
+  result = books_primary_item_per_page;
   a1.uFrameX = 12;
   a1.uFrameY = 48;
   a1.uFrameWidth = 424;
   a1.uFrameHeight = 290;
   a1.uFrameZ = 435;
   a1.uFrameW = 337;
-  if (BtnDown_flag && num_achieved_awards + dword_506528 < num_achieved_awards_2)
-    result = dword_506528++ + 1;
+  if (BtnDown_flag && num_achieved_awards + books_primary_item_per_page < full_num_items_in_book)
+    result = books_primary_item_per_page++ + 1;
   if (BtnUp_flag && result)
   {
     --result;
-    dword_506528 = result;
+    books_primary_item_per_page = result;
   }
 
-    if ( dword_50651C < 0 )
+    if ( books_page_number < 0 )
         {
         result += num_achieved_awards;
-        dword_506528 = result;
-        if ( (signed int)(num_achieved_awards + result) > num_achieved_awards_2 )
+        books_primary_item_per_page = result;
+        if ( (signed int)(num_achieved_awards + result) > full_num_items_in_book )
             {
-            result = num_achieved_awards_2 - num_achieved_awards;
-            dword_506528 = result;
+            result = full_num_items_in_book - num_achieved_awards;
+            books_primary_item_per_page = result;
             }
         }
-    else if ( dword_50651C > 0 )
+    else if ( books_page_number > 0 )
         {
         result -= num_achieved_awards;
-        dword_506528 = result;
+        books_primary_item_per_page = result;
         if ( (result & 0x80000000u) != 0 )
             {
             result = 0;
-            dword_506528 = result;
+            books_primary_item_per_page = result;
             }
         }
     //LABEL_14:
     BtnDown_flag = 0;
     BtnUp_flag = 0;
     num_achieved_awards = 0;
-    dword_50651C = 0;
+    books_page_number = 0;
 
 
-    for (uint i = result; i < num_achieved_awards_2; ++i)
+    for (uint i = result; i < full_num_items_in_book; ++i)
     {
       v5 = achieved_awards[i];
       v6 = (char *)pAwards[v5].pText;//(char *)dword_723E80_award_related[v20 / 4];
@@ -2582,8 +2582,8 @@
         memset(pTmpBuf2.data(), 0, 0x7D0u);
         BtnDown_flag = 0;
         BtnUp_flag = 0;
-        dword_50651C = 0;
-        dword_506528 = 0;
+        books_page_number = 0;
+        books_primary_item_per_page = 0;
         for (int i = 0; i < 105; ++i)
         {
             if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
@@ -2591,11 +2591,11 @@
                 achieved_awards[num_achieved_awards++] = (AwardType)i;
             }
         }
-        num_achieved_awards_2 = num_achieved_awards;
+        full_num_items_in_book = num_achieved_awards;
         num_achieved_awards = 0;
 
         //sort awards index 
-        if (num_achieved_awards_2 > 0)
+        if (full_num_items_in_book > 0)
         {
             std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort);
         }
--- a/mm7_5.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/mm7_5.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -2843,9 +2843,9 @@
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
           continue;
         case UIMSG_ClickAwardScrollBar:
-          dword_50651C = 1;
+          books_page_number = 1;
           if ( pMouse->GetCursorPos(&v211)->y > 178 )
-            dword_50651C = -1;
+            books_page_number = -1;
           continue;
         case UIMSG_ClickAwardsUpBtn:
           GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0);
--- a/mm7_data.cpp	Sat Aug 03 00:00:31 2013 +0600
+++ b/mm7_data.cpp	Mon Aug 05 22:31:12 2013 +0600
@@ -58,7 +58,7 @@
 std::array<Award, 105> pAwards;
 std::array<AwardType, 1000> achieved_awards;
 int num_achieved_awards;
-int num_achieved_awards_2;
+int full_num_items_in_book;
 
 #include "stru160.h"
 std::array<stru160, 66> array_4EB8B8 =
@@ -886,7 +886,7 @@
 int dword_505890; // weak
 std::array<unsigned int, 480> pSRZBufferLineOffsets;
 int areWeLoadingTexture; // weak
-std::array<char, 777> byte_506130; // weak
+std::array<char, 777> books_num_items_per_page; // weak
 int dword_506338; // weak
 int dword_50633C; // idb
 signed int sRecoveryTime; // idb
@@ -898,8 +898,8 @@
 //Texture *dword_506404[12]; // weak
 //Texture *dword_50640C[12]; // weak
 unsigned int uExitCancelTextureId;
-int dword_50651C; // weak
-int dword_506528; // weak
+int books_page_number; // weak
+int books_primary_item_per_page; // weak
 int Autonotes_Instructors_page_flag; // dword_50652C
 int Autonotes_Misc_page_flag; //dword_506530
 int Book_PageBtn6_flag; //dword_506534
--- a/mm7_data.h	Sat Aug 03 00:00:31 2013 +0600
+++ b/mm7_data.h	Mon Aug 05 22:31:12 2013 +0600
@@ -532,7 +532,7 @@
 extern int dword_505890; // weak
 extern std::array<unsigned int, 480> pSRZBufferLineOffsets;
 extern int areWeLoadingTexture; // weak
-extern std::array<char, 777> byte_506130; // weak
+extern std::array<char, 777> books_num_items_per_page; // weak
 extern int dword_506338; // weak
 extern int dword_50633C; // idb
 extern signed int sRecoveryTime; // idb
@@ -543,8 +543,8 @@
 extern int dword_506364; // weak
 //extern Texture *dword_50640C[]; // weak
 extern unsigned int uExitCancelTextureId;
-extern int dword_50651C; // weak
-extern int dword_506528; // weak
+extern int books_page_number; // number for page in books(номер страницы в книгах)
+extern int books_primary_item_per_page; // number primary item in book page(номер начальной записи на странице)
 extern int Autonotes_Instructors_page_flag; // dword_50652C
 extern int Autonotes_Misc_page_flag; //dword_506530
 extern int Book_PageBtn6_flag; //dword_506534