changeset 688:c0bfb386b15f

some ui cleanup
author Gloval
date Sat, 16 Mar 2013 01:11:39 +0400
parents 35a97ce58790
children c89e0b2d8ea6
files GUIFont.cpp GUIFont.h GUIWindow.cpp GUIWindow.h Render.cpp Render.h Texture.cpp Texture.h Viewport.h mm7_3.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 13 files changed, 490 insertions(+), 539 deletions(-) [+]
line wrap: on
line diff
--- a/GUIFont.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/GUIFont.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -700,8 +700,8 @@
 }
 
 //----- (0044C768) --------------------------------------------------------
-char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5)
-	{
+char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 )
+    {
 	unsigned char c;
 	unsigned int uInStrLen;
 	char digits[4];
--- a/GUIFont.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/GUIFont.h	Sat Mar 16 01:11:39 2013 +0400
@@ -44,7 +44,7 @@
 #pragma pack(pop)
 
 GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...);
-char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5);
+char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5);
 
 
 extern struct GUIFont *pAutonoteFont;
--- a/GUIWindow.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/GUIWindow.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -147,8 +147,8 @@
 
 
 //----- (0041D3B7) --------------------------------------------------------
-char GUIWindow::DrawQuickCharRecord()
-{
+void GUIWindow::DrawQuickCharRecord()
+    {
   Player *pPlayer; // esi@1
   int v6; // eax@5
   int v7; // ebx@5
@@ -217,20 +217,20 @@
 
   pRenderer->DrawTextureTransparent(uFrameX + 24, uFrameY + 24, v13);
   v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf, "\xC%05d", v16);
+  sprintf(pTmpBuf, "\f%05d", v16);
   sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);
   strcat(pTmpBuf, pTmpBuf2);
-  strcat(pTmpBuf, "\xC" "00000\n");
+  strcat(pTmpBuf, "\f00000\n");
   v20 = UI_GetHealthManaStringColor(pPlayer->sHealth, pPlayer->GetMaxHealth());
-  sprintf(pTmpBuf2, "%s : \x0C" "%05u%d\x0C" "00000 / %d\n", pGlobalTXT_LocalizationStrings[108],
+  sprintf(pTmpBuf2, "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[108],
           v20, pPlayer->sHealth, pPlayer->GetMaxHealth());
   strcat(pTmpBuf, pTmpBuf2);
   v24 = UI_GetHealthManaStringColor(pPlayer->sMana, pPlayer->GetMaxMana());
-  sprintf(pTmpBuf2, "%s : \x0C" "%05u%d\x0C" "00000 / %d\n", pGlobalTXT_LocalizationStrings[212],
+  sprintf(pTmpBuf2, "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[212],
           v24, pPlayer->sMana, pPlayer->GetMaxMana());
   strcat(pTmpBuf, pTmpBuf2);
   v25 = pPlayer->GetMajorConditionIdx();
-  sprintf(pTmpBuf2, "%s: \x0C" "%05d%s\x0C" "00000\n", pGlobalTXT_LocalizationStrings[47],
+  sprintf(pTmpBuf2, "%s: \f%05d%s\f00000\n", pGlobalTXT_LocalizationStrings[47],
           GetConditionDrawColor(v25), aCharacterConditionNames[v25]);
   strcat(pTmpBuf, pTmpBuf2);
   v28 = pPlayer->uQuickSpell;
@@ -263,7 +263,7 @@
   if ( uFramesetIDa == 0 )
     v39 = pGlobalTXT_LocalizationStrings[153];
   sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39);
-  return DrawText(pFontArrus, 14, 114, 0, pTmpBuf, 0, 0, 0);
+  DrawText(pFontArrus, 14, 114, 0, pTmpBuf, 0, 0, 0);
 }
 
 //----- (0041D08F) --------------------------------------------------------
@@ -474,56 +474,56 @@
   awards_count2 = 0;
   dword_506528 = 0;
   dword_50651C = 0;
-  awards_count = 0;  
-  if ( v1->ptr_1C == (void *)177 )
-  {
-    byte_506360 = 0;
-    pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
-    pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-    pTexture_50635C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-    pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-    pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-    pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, 0xB2u, 0, 0, pGlobalTXT_LocalizationStrings[375], 0);
-    pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, 0xB2u, 1, 0, pGlobalTXT_LocalizationStrings[523], 0);
-    v17 = &pParty->pPlayers[_506348_current_lloyd_playerid];
-    v23 = 1;
-    v18 = v17->pActiveSkills[14];
-    if ( HIBYTE(v18) & 1 || (v18 & 0x80u) != 0 )
-    {
-      v23 = 5;
-    }
-    else
-    {
-      if ( v18 & 0x40 )
-        v23 = 3;
-    }
-    v19 = 0;
-    if ( v23 > 0 )
-    {
+  awards_count = 0; 
+  switch (v1->par1C)
+      {
+  case 177:{
+      byte_506360 = 0;
+      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
+      pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
+      pTexture_50635C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
+      pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, 0xB2u, 0, 0, pGlobalTXT_LocalizationStrings[375], 0);
+      pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, 0xB2u, 1, 0, pGlobalTXT_LocalizationStrings[523], 0);
+      v17 = &pParty->pPlayers[_506348_current_lloyd_playerid];
+      v23 = 1;
+      v18 = v17->pActiveSkills[14];
+      if ( HIBYTE(v18) & 1 || (v18 & 0x80u) != 0 )
+          {
+          v23 = 5;
+          }
+      else
+          {
+          if ( v18 & 0x40 )
+              v23 = 3;
+          }
+      v19 = 0;
+      if ( v23 > 0 )
+          {
+          do
+              {
+              v1->CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], 0x5Cu, 0x44u, 1, 180, 0xB3u, v19, 0, "", 0);
+              ++v19;
+              }
+              while ( (signed int)v19 < v23 );
+          }
+      v20 = 0;
+      v21 = v17->pInstalledBeacons;
       do
-      {
-        v1->CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], 0x5Cu, 0x44u, 1, 180, 0xB3u, v19, 0, "", 0);
-        ++v19;
+          {
+          if ( *(_QWORD *)v21 >= (signed __int64)pParty->uTimePlayed )
+              LoadThumbnailLloydTexture(v20, _506348_current_lloyd_playerid + 1);
+          else
+              memset(v21, 0, 0x1Cu);
+          ++v20;
+          v21 = (char *)v21 + 28;
+          }
+          while ( (signed int)v20 < 5 );
       }
-      while ( (signed int)v19 < v23 );
-    }
-    v20 = 0;
-    v21 = v17->pInstalledBeacons;
-    do
-    {
-      if ( *(_QWORD *)v21 >= (signed __int64)pParty->uTimePlayed )
-        LoadThumbnailLloydTexture(v20, _506348_current_lloyd_playerid + 1);
-      else
-        memset(v21, 0, 0x1Cu);
-      ++v20;
-      v21 = (char *)v21 + 28;
-    }
-    while ( (signed int)v20 < 5 );
-  }
-  else
-  {
-    if ( v1->ptr_1C == (void *)195 )
-    {
+      break;
+  case 195:
+      {
       pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("townport", TEXTURE_16BIT_PALETTE)];
       pTexture_TownPortalHarmn = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpharmndy", TEXTURE_16BIT_PALETTE)];
       pTexture_TownPortalElf = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tpelf", TEXTURE_16BIT_PALETTE)];
@@ -533,223 +533,220 @@
       v16 = 0;
       pTexture_TownPortalHell = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "tphell", TEXTURE_16BIT_PALETTE)];
       do
-      {
-        v1->CreateButton(pTownPortalBook_xs[v16], pTownPortalBook_ys[v16], pTownPortalBook_ws[v16], pTownPortalBook_hs[v16], 1, 182, 0xB7u, v16, 0, "", 0);
-        ++v16;
+          {
+          v1->CreateButton(pTownPortalBook_xs[v16], pTownPortalBook_ys[v16], pTownPortalBook_ws[v16], pTownPortalBook_hs[v16], 1, 182, 0xB7u, v16, 0, "", 0);
+          ++v16;
+          }
+          while ( (signed int)v16 < 6 );
       }
-      while ( (signed int)v16 < 6 );
-    }
-    else
-    {
-      if ( v1->ptr_1C == (void *)200 )
+      break;
+  case 200:
       {
-        pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
-        pTextures_5064A0[10] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
-        pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-        pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-        pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-        pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-        pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, pTex_tab_an_6b__zoom_on->uTextureWidth,
-                        pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, 0x47u, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
-                        pTex_tab_an_6b__zoom_on, 0);
-        pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
-                        pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, 0x47u, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
-                        pTex_tab_an_7b__zoot_on, 0);
-        awards_count = 0;
-        memset(&achievedAwardsIndex, 0, 4000);
-        for ( i = dword_506528; i < 512; ++i )
-        {
+      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
+      pSpellBookPagesTextr_10 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, pTex_tab_an_6b__zoom_on->uTextureWidth,
+          pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, 0x47u, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
+          pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
+          pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, 0x47u, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
+          pTex_tab_an_7b__zoot_on, 0);
+      awards_count = 0;
+      memset(&achievedAwardsIndex, 0, 4000);
+      for ( i = dword_506528; i < 512; ++i )
+          {
           v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i];
           if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 )
-          {
-            v15 = awards_count++;
-            achievedAwardsIndex[v15] = i;
-          }
-        }
-      }
-      else
-      {
-        if ( v1->ptr_1C == (void *)201 )
-        {
-          pTexture_AutonotesBook   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
-          pTextures_5064A0[10]     = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_7b__zoot_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-          pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1a", TEXTURE_16BIT_PALETTE)];
-          pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2a", TEXTURE_16BIT_PALETTE)];
-          pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3a", TEXTURE_16BIT_PALETTE)];
-          pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5a", TEXTURE_16BIT_PALETTE)];
-          pTexture_506374 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
-          pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
-          pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
-          pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0xBu, 0,
-                          pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
-          pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 0xAu, 0,
-                          pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
-          pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2u, 0,
-                          pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0);// "Potion Notes"
-          pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 399, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3u, 0,
-                          pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0);// "Fountain Notes"
-          pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4u, 0,
-                          pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0);// "Obelisk Notes"
-          pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5u, 0,
-                          pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0);// "Seer Notes"
-          pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 264, 0x32u, 0x22u, 1, 0, 0x47u, 6u, 0,
-                                  pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0);// "Miscellaneous Notes"
-          v9 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 302, 0x32u, 0x22u, 1, 0, 0x47u, 7u, 0,
-                 pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
-          v10 = dword_506528;
-          pBtn_Autonotes_Instructors = v9;
-          awards_count = 0;
-          while ( v10 < 196 )
-          {
-			if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
-            {
-              //v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10];
-			  v25 = (char *)pAutonoteTxt[v10-1].pText;
-              if ( (short)v10 )
               {
-                if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
-                {
-                  v11 = awards_count++;
-                  achievedAwardsIndex[v11] = (signed __int16)v10;
-                }
+              v15 = awards_count++;
+              achievedAwardsIndex[v15] = i;
               }
-            }
-            ++v10;
           }
-        }
-        else
-        {
-          if ( v1->ptr_1C == (void *)202 )
-          {
-            dword_506364 = 1;
-            pTextures_5064A0[12] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-            pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-on", TEXTURE_16BIT_PALETTE)];
-            pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-on", TEXTURE_16BIT_PALETTE)];
-            pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-off", TEXTURE_16BIT_PALETTE)];
-            pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-off", TEXTURE_16BIT_PALETTE)];
-            pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNon", TEXTURE_16BIT_PALETTE)];
-            pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNoff", TEXTURE_16BIT_PALETTE)];
-            pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSon", TEXTURE_16BIT_PALETTE)];
-            pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSoff", TEXTURE_16BIT_PALETTE)];
-            pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEon", TEXTURE_16BIT_PALETTE)];
-            pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
-            pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
-            pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
-            pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0, 0,
-                            pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
-            pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 1, 0,
-                            pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
-            pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2, 0,
-                            pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
-            pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3, 0,
-                            pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
-            pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4, 0,
-                            pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
-            pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5, 0,
-                            pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
-            return;
-          }
-          if ( v1->ptr_1C == (void *)203 )
-          {
-            pTextures_5064A0[13] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
-            pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
-            pTex_moon_4   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
-            pTex_moon_2   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-            pTex_moon_2_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-            pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
-            return;
-          }
-          if ( v1->ptr_1C != (void *)224 )
-            return;
-          pTextures_5064A0[11] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-          pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-          pBtn_Book_1 = v1->CreateButton(
-                          pViewport->uViewportX + 398,
-                          pViewport->uViewportY + 1,
-                          pTex_tab_an_6b__zoom_on->uTextureWidth,
-                          pTex_tab_an_6b__zoom_on->uTextureHeight,
-                          1,
-                          0,
-                          0x47u,
-                          0xBu,
-                          0,
-                          pGlobalTXT_LocalizationStrings[192],
-                          pTex_tab_an_6b__zoom_on,
-                          0);
-          pBtn_Book_2 = v1->CreateButton(
-                          pViewport->uViewportX + 398,
-                          pViewport->uViewportY + 38,
-                          pTex_tab_an_7b__zoot_on->uTextureHeight,
-                          pTex_tab_an_7b__zoot_on->uTextureHeight,
-                          1,
-                          0,
-                          0x47u,
-                          0xAu,
-                          0,
-                          pGlobalTXT_LocalizationStrings[193],
-                          pTex_tab_an_7b__zoot_on,
-                          0);
-          awards_count = 0;
-          v26.uFrameX = 48;
-          v26.uFrameY = 70;
-          v26.uFrameWidth = 360;
-          v26.uFrameHeight = 264;
-          v2 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
-          v26.uFrameZ = 407;
-          v26.uFrameHeight = v2 * 264 / v2;
-          v26.uFrameW = v26.uFrameHeight + 69;
-          memset(&achievedAwardsIndex, 0, 4000);
-          memset(byte_5C6D50, 0, 0x64u);
-          if ( dword_506528 < 29 )
-          {
-            v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528];
-			for(int i=dword_506528+1;i<dword_506528+31;i++)
-            {
-			  v4 = pStorylineText->StoreLine[i].pText;
-              if ( *v3 )
-              {
-                if ( v4 )
-                {
-                  v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3);
-                  v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0);
-                  v7 = (v6 - 3) / (signed int)v26.uFrameHeight;
-                  v8 = v7 + 1;
-                  if ( (signed int)v7 + 1 > 0 )
-                  {
-                    memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8);
-                    do
-                    {
-                      LODWORD(v7) = awards_count++;
-                      byte_5C6D50[(int)v7] = BYTE4(v7);
-                      ++HIDWORD(v7);
-                    }
-                    while ( SHIDWORD(v7) < (signed int)v8 );
-                  }
-                }
-              }
-              ++i;
-              ++v3;
-            }
-          }
-        }
-      }
       v12 = awards_count;
       awards_count = 0;
       awards_count2 = v12;
-    }
-  }
+      }
+      break;
+  case 201:
+      {
+      pTexture_AutonotesBook   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
+      pSpellBookPagesTextr_10     = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7b__zoot_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
+      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1a", TEXTURE_16BIT_PALETTE)];
+      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2a", TEXTURE_16BIT_PALETTE)];
+      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3a", TEXTURE_16BIT_PALETTE)];
+      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5a", TEXTURE_16BIT_PALETTE)];
+      pTexture_506374 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
+      pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
+      pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0xBu, 0,
+          pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 0xAu, 0,
+          pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2u, 0,
+          pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0);// "Potion Notes"
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 399, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3u, 0,
+          pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0);// "Fountain Notes"
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4u, 0,
+          pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0);// "Obelisk Notes"
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5u, 0,
+          pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0);// "Seer Notes"
+      pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 264, 0x32u, 0x22u, 1, 0, 0x47u, 6u, 0,
+          pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0);// "Miscellaneous Notes"
+      v9 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 302, 0x32u, 0x22u, 1, 0, 0x47u, 7u, 0,
+          pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
+      v10 = dword_506528;
+      pBtn_Autonotes_Instructors = v9;
+      awards_count = 0;
+      while ( v10 < 196 )
+          {
+          if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
+              {
+              //v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10];
+              v25 = (char *)pAutonoteTxt[v10-1].pText;
+              if ( (short)v10 )
+                  {
+                  if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
+                      {
+                      v11 = awards_count++;
+                      achievedAwardsIndex[v11] = (signed __int16)v10;
+                      }
+                  }
+              }
+          ++v10;
+          }
+      }
+      break;
+  case 202:
+      {
+      dword_506364 = 1;
+      pSpellBookPagesTextr_12 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-on", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-on", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-off", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-off", TEXTURE_16BIT_PALETTE)];
+      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNon", TEXTURE_16BIT_PALETTE)];
+      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNoff", TEXTURE_16BIT_PALETTE)];
+      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSon", TEXTURE_16BIT_PALETTE)];
+      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSoff", TEXTURE_16BIT_PALETTE)];
+      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEon", TEXTURE_16BIT_PALETTE)];
+      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
+      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
+      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0, 0,
+          pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 1, 0,
+          pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2, 0,
+          pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3, 0,
+          pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4, 0,
+          pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5, 0,
+          pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
+      }
+      break;
+  case 203: {
+      pSpellBookPagesTextr_13 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
+      pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
+      pTex_moon_4   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
+      pTex_moon_2   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
+      pTex_moon_2_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
+      pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
+      }
+      break;
+  case 224:
+      {
+      pSpellBookPagesTextr_11 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
+      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
+      pBtn_Book_1 = v1->CreateButton(
+          pViewport->uViewportX + 398,
+          pViewport->uViewportY + 1,
+          pTex_tab_an_6b__zoom_on->uTextureWidth,
+          pTex_tab_an_6b__zoom_on->uTextureHeight,
+          1,
+          0,
+          0x47u,
+          0xBu,
+          0,
+          pGlobalTXT_LocalizationStrings[192],
+          pTex_tab_an_6b__zoom_on,
+          0);
+      pBtn_Book_2 = v1->CreateButton(
+          pViewport->uViewportX + 398,
+          pViewport->uViewportY + 38,
+          pTex_tab_an_7b__zoot_on->uTextureHeight,
+          pTex_tab_an_7b__zoot_on->uTextureHeight,
+          1,
+          0,
+          0x47u,
+          0xAu,
+          0,
+          pGlobalTXT_LocalizationStrings[193],
+          pTex_tab_an_7b__zoot_on,
+          0);
+      awards_count = 0;
+      v26.uFrameX = 48;
+      v26.uFrameY = 70;
+      v26.uFrameWidth = 360;
+      v26.uFrameHeight = 264;
+      v2 = LOBYTE(pAutonoteFont->uFontHeight) - 3;
+      v26.uFrameZ = 407;
+      v26.uFrameHeight = v2 * 264 / v2;
+      v26.uFrameW = v26.uFrameHeight + 69;
+      memset(&achievedAwardsIndex, 0, 4000);
+      memset(byte_5C6D50, 0, 0x64u);
+      if ( dword_506528 < 29 )
+          {
+          v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528];
+          for(int i=dword_506528+1;i<dword_506528+31;i++)
+              {
+              v4 = pStorylineText->StoreLine[i].pText;
+              if ( *v3 )
+                  {
+                  if ( v4 )
+                      {
+                      v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3);
+                      v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0);
+                      v7 = (v6 - 3) / (signed int)v26.uFrameHeight;
+                      v8 = v7 + 1;
+                      if ( (signed int)v7 + 1 > 0 )
+                          {
+                          memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8);
+                          do
+                              {
+                              LODWORD(v7) = awards_count++;
+                              byte_5C6D50[(int)v7] = BYTE4(v7);
+                              ++HIDWORD(v7);
+                              }
+                              while ( SHIDWORD(v7) < (signed int)v8 );
+                          }
+                      }
+                  }
+              ++i;
+              ++v3;
+              }
+          }
+      
+      }
+      break;
+      }
+  
 }
 
 
@@ -879,7 +876,7 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
-  pTextures_5064A0[9] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("book", TEXTURE_16BIT_PALETTE)];
+  pSpellBookPagesTextr_9 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("book", TEXTURE_16BIT_PALETTE)];
   pTexture_pagemask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("pagemask", TEXTURE_16BIT_PALETTE)];
   pTexture_506448   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-u", TEXTURE_16BIT_PALETTE)];
   ptr_506440        = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-d", TEXTURE_16BIT_PALETTE)];
@@ -895,7 +892,7 @@
   pTexture_506444 = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE);
   for (uint i = 0; i < 8; ++i)
   {
-    pTextures_5064A0[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
+    pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
 
     sprintf(pTmpBuf, "tab%da", i+1);
     pTextures_tabs[i][0] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
@@ -1288,9 +1285,8 @@
 
 
 //----- (0044D406) --------------------------------------------------------
-char *GUIWindow::DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, 
-	        unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing)
-{
+char * GUIWindow::DrawTitleText( GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing )
+    {
   GUIWindow *pWindow; // esi@1
   unsigned int v8; // ebx@1
   char *v9; // eax@1
--- a/GUIWindow.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/GUIWindow.h	Sat Mar 16 01:11:39 2013 +0400
@@ -112,8 +112,7 @@
   void DrawFlashingInputCursor(signed int a3, int a4, struct GUIFont *a2);
   int DrawTextInRect(GUIFont *a2, unsigned int uX, unsigned int uY, unsigned int uColor, const char *Str1, int Source, int a8);
   char DrawText(GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, unsigned int uFontShadowColor);
-  char *DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, 
-	            unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
+  char *DrawTitleText(GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
   void DrawCurrentTime(__int64 a2);
   void HouseDialogManager();
   void OpenSpellBook();
@@ -122,7 +121,7 @@
   GUIButton *GetControl(unsigned int uID);
   void Release();
   void _41D08F(int a2, int a3, int a4, int a5);
-  char DrawQuickCharRecord();
+  void DrawQuickCharRecord();
   char _41D73D_draw_buff_tooltip();
 
   static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eType, int a4, int a5);
--- a/Render.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/Render.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -4751,8 +4751,8 @@
   v1->pDefaultZBuffer = 0;
   v1->field_20_clipy = 0;
   v1->field_1C_clipx = 0;
-  v1->field_24_clipz = 639;
-  v1->field_28_clipw = 479;
+  v1->field_24_width = 639;
+  v1->field_28_height = 479;
   v1->field_4003C = (int)&unk_4EED80;
   v1->field_40040 = dword_4EED78;
   v1->uClipZ = 640;
@@ -6337,14 +6337,14 @@
   v35 = this;
   if ( (signed int)uX < v6 )
     HIDWORD(v36) = 8;
-  v34 = this->field_24_clipz;
-  if ( (signed int)uX > this->field_24_clipz )
+  v34 = this->field_24_width;
+  if ( (signed int)uX > this->field_24_width )
     HIDWORD(v36) |= 4u;
   v7 = this->field_20_clipy;
   v8 = uY;
   if ( (signed int)uY < v7 )
     HIDWORD(v36) |= 2u;
-  v9 = this->field_28_clipw;
+  v9 = this->field_28_height;
   if ( (signed int)uY > v9 )
     HIDWORD(v36) |= 1u;
   v10 = uZ;
@@ -6457,17 +6457,17 @@
 LABEL_24:
   if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
   {
-    v15 = v14->field_24_clipz;
+    v15 = v14->field_24_width;
     if ( BYTE4(v36) & 4 )
     {
       v14 = v35;
       v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX);
-      uX = v35->field_24_clipz;
+      uX = v35->field_24_width;
     }
     else
     {
       v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10);
-      v10 = v14->field_24_clipz;
+      v10 = v14->field_24_width;
       v11 += v16;
     }
   }
@@ -6476,7 +6476,7 @@
   uYa = v14->field_20_clipy;
   if ( (signed int)v8 < v17 )
     v37 = 2;
-  v18 = v14->field_28_clipw;
+  v18 = v14->field_28_height;
   if ( (signed int)v8 > v18 )
     v37 |= 1u;
   if ( (signed int)v11 >= v17 )
@@ -6510,14 +6510,14 @@
     {
       if ( v37 & 1 )
       {
-        uX += (signed int)((v10 - uX) * (v35->field_28_clipw - v8)) / (signed int)(v11 - v8);
+        uX += (signed int)((v10 - uX) * (v35->field_28_height - v8)) / (signed int)(v11 - v8);
         LOBYTE(v12) = (char)v35;
-        v8 = v35->field_28_clipw;
+        v8 = v35->field_28_height;
       }
       else
       {
-        v12 = (signed int)((uX - v10) * (v35->field_28_clipw - v11)) / (signed int)(v8 - v11);
-        v11 = v35->field_28_clipw;
+        v12 = (signed int)((uX - v10) * (v35->field_28_height - v11)) / (signed int)(v8 - v11);
+        v11 = v35->field_28_height;
         v10 += v12;
       }
     }
@@ -6541,8 +6541,8 @@
 {
   this->field_1C_clipx = uX;
   this->field_20_clipy = uY;
-  this->field_24_clipz = uZ;
-  this->field_28_clipw = uW;
+  this->field_24_width = uZ;
+  this->field_28_height = uW;
 }
 
 
@@ -11074,7 +11074,7 @@
     v6->Load(v8, v9);
 LABEL_38:
     viewparams->bRedrawGameUI = 1;
-    viewparams->_443343();
+    viewparams->InitGrayPalette();
     pMouse->SetCurrentCursorBitmap();
     if ( pRenderer->bWindowMode )
     {
--- a/Render.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/Render.h	Sat Mar 16 01:11:39 2013 +0400
@@ -382,8 +382,8 @@
   int field_18_locked_pitch;
   int field_1C_clipx;
   int field_20_clipy;
-  int field_24_clipz;
-  int field_28_clipw;
+  int field_24_width;
+  int field_28_height;
   __int16 field_2C[65536];
   __int16 field_2002C[65536];
   int field_4002C;
--- a/Texture.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/Texture.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -57,7 +57,12 @@
 Texture *pTextures_tabs[9][2];
 Texture *pTexture_mapbordr; // idb
 Texture *pTexture_pagemask; // idb
-Texture *pTextures_5064A0[14];
+Texture *pSpellBookPagesTextr[8];
+Texture *pSpellBookPagesTextr_9;
+Texture *pSpellBookPagesTextr_10;
+Texture *pSpellBookPagesTextr_11;
+Texture *pSpellBookPagesTextr_12;
+Texture *pSpellBookPagesTextr_13;
 Texture *pTexture_AutonotesBook;
 Texture *pTexture_CurrentBook;
 Texture *pTex_moon_new;
--- a/Texture.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/Texture.h	Sat Mar 16 01:11:39 2013 +0400
@@ -159,7 +159,12 @@
 extern Texture *pTextures_tabs[9][2];
 extern Texture *pTexture_mapbordr; // idb
 extern Texture *pTexture_pagemask; // idb
-extern Texture *pTextures_5064A0[14];
+extern Texture *pSpellBookPagesTextr[8];
+extern Texture *pSpellBookPagesTextr_9;
+extern Texture *pSpellBookPagesTextr_10;
+extern Texture *pSpellBookPagesTextr_11;
+extern Texture *pSpellBookPagesTextr_12;
+extern Texture *pSpellBookPagesTextr_13;
 extern Texture *pTexture_AutonotesBook;
 extern Texture *pTexture_CurrentBook;
 extern Texture *pTex_moon_new;
--- a/Viewport.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/Viewport.h	Sat Mar 16 01:11:39 2013 +0400
@@ -31,14 +31,6 @@
 
 
 
-
-
-
-
-
-
-
-
 /*  201 */
 #pragma pack(push, 1)
 struct ViewingParams
@@ -49,14 +41,14 @@
     draw_d3d_outlines = false;
   }
 
-  int _443291();
-  unsigned int _443343();
-  int _443219();
-  int _443225();
-  int _443231();
-  int _44323D();
-  int _443249();
-  int _4432E7();
+  void _443291();
+  void  InitGrayPalette();
+  void _443219();
+  void  _443225();
+  void  _443231();
+  void _44323D();
+  void _443249();
+  void  _4432E7();
   int _443365();
 
 
--- a/mm7_3.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/mm7_3.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -12140,9 +12140,9 @@
               v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16,
               v38 = uCenterY - v79,
               v37 < pRenderer->field_1C_clipx)
-          || v37 > pRenderer->field_24_clipz
+          || v37 > pRenderer->field_24_width
           || v38 < pRenderer->field_20_clipy
-          || v38 > pRenderer->field_28_clipw )
+          || v38 > pRenderer->field_28_height )
           goto LABEL_83;
         if ( pObjectList->pObjects[*(short *)a2c].uFlags & 0x10 )
           break;
@@ -12200,7 +12200,7 @@
           v41 = uCenterY - v76;
           if ( v40 >= pRenderer->field_1C_clipx )
           {
-            if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
+            if ( v40 <= pRenderer->field_24_width && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_height )
             {
               uWd = v61;
 			  if ( BYTE3(flagsc->uAttributes) & 1 )
@@ -12256,7 +12256,7 @@
         v47 = uCenterY - v77;
         if ( v46 >= pRenderer->field_1C_clipx )
         {
-          if ( v46 <= pRenderer->field_24_clipz && v47 >= pRenderer->field_20_clipy && v47 <= pRenderer->field_28_clipw )
+          if ( v46 <= pRenderer->field_24_width && v47 >= pRenderer->field_20_clipy && v47 <= pRenderer->field_28_height )
           {
             if ( (signed int)uZoom > 512 )
             {
@@ -12290,8 +12290,8 @@
 
 
 //----- (00442955) --------------------------------------------------------
-int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074)
-{
+void DrawBook_Map_sub( unsigned int x, unsigned int y, unsigned int width, int height, int _48074 )
+    {
   int v5; // ebx@1
   int v6; // edi@1
   BLVMapOutlines *v7; // eax@8
@@ -12390,10 +12390,10 @@
 
   x_ = x;
   y_ = y;
-  v85 = (signed int)(x + a4) >> 1;
-  v90 = (signed int)(y + a5) >> 1;
+  v85 = (signed int)(x + width) >> 1;
+  v90 = (signed int)(y + height) >> 1;
   v79 = pRenderer->uTargetSurfacePitch;
-  pRenderer->Clip_v2(x, y, a4, a5);
+  pRenderer->Clip_v2(x, y, width, height);
   v5 = viewparams->field_2C;
   v6 = viewparams->sPartyPosX;
   v86 = viewparams->sPartyPosX;
@@ -12416,8 +12416,8 @@
   }
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
-    v94 = a4 - x_ + 1;
-    v92 = a5 - y_ + 1;
+    v94 = width - x_ + 1;
+    v92 = height - y_ + 1;
     v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
     v95 = (unsigned int)pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
     v78 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
@@ -12606,11 +12606,11 @@
   v49 = v90 - (int)v97 - 3;
   if ( v47 >= (signed int)x_ )
   {
-    if ( v47 > (signed int)a4 )
-    {
-      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 6) > (signed int)a4 )
+    if ( v47 > (signed int)width )
+    {
+      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 6) > (signed int)width )
         v48 = 0;
-      v47 = a4;
+      v47 = width;
     }
   }
   else
@@ -12621,11 +12621,11 @@
   }
   if ( v49 >= (signed int)y_ )
   {
-    if ( v49 > a5 )
-    {
-      if ( v90 - (signed int)v97 - 6 > a5 )
+    if ( v49 > height )
+    {
+      if ( v90 - (signed int)v97 - 6 > height )
         v48 = 0;
-      v49 = a5;
+      v49 = height;
     }
   }
   else
@@ -12705,7 +12705,7 @@
         v55 = v90 - (int)v97;
         if ( v54 >= pRenderer->field_1C_clipx )
         {
-          if ( v54 <= pRenderer->field_24_clipz && v55 >= pRenderer->field_20_clipy && v55 <= pRenderer->field_28_clipw )
+          if ( v54 <= pRenderer->field_24_width && v55 >= pRenderer->field_20_clipy && v55 <= pRenderer->field_28_height )
           {
             v74 = v86;
             if ( v5 > 512 )
@@ -12738,8 +12738,8 @@
   }
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
-    v90 = a4 - x_ + 1;
-    v95 = a5 - y_ + 1;
+    v90 = width - x_ + 1;
+    v95 = height - y_ + 1;
     v77 = &pRenderer->pTargetSurface[x_ + y_ * v79];
     v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
     black = (1 << (v56 + 16)) / v5;
@@ -12820,40 +12820,39 @@
       while ( v65 );
     }
   }
-  return result;
 }
 
 //----- (00443219) --------------------------------------------------------
-int ViewingParams::_443219()
-{
+void ViewingParams::_443219()
+    {
   this->sPartyPosZ += 512;
-  return _4432E7();
+  _4432E7();
 }
 
 //----- (00443225) --------------------------------------------------------
-int ViewingParams::_443225()
-{
+void ViewingParams::_443225()
+    {
   this->sPartyPosX -= 512;
-  return _4432E7();
+  _4432E7();
 }
 
 //----- (00443231) --------------------------------------------------------
-int ViewingParams::_443231()
-{
+void ViewingParams::_443231()
+    {
   this->sPartyPosZ -= 512;
-  return _4432E7();
+   _4432E7();
 }
 
 //----- (0044323D) --------------------------------------------------------
-int ViewingParams::_44323D()
-{
+void ViewingParams::_44323D()
+    {
   this->sPartyPosX += 512;
-  return _4432E7();
+   _4432E7();
 }
 
 //----- (00443249) --------------------------------------------------------
-int ViewingParams::_443249()
-{
+void ViewingParams::_443249()
+    {
   int v1; // edx@1
 
   v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
@@ -12862,12 +12861,12 @@
     this->field_2C = 384;
   this->sPartyPosX = pParty->vPosition.x;
   this->sPartyPosZ = pParty->vPosition.y;
-  return _4432E7();
+  _4432E7();
 }
 
 //----- (00443291) --------------------------------------------------------
-int ViewingParams::_443291()
-{
+void ViewingParams::_443291()
+    {
   int v1; // edx@1
   int v2; // eax@1
 
@@ -12880,12 +12879,12 @@
     this->field_2C = v2;
   this->sPartyPosX = pParty->vPosition.x;
   this->sPartyPosZ = pParty->vPosition.y;
-  return _4432E7();
+  _4432E7();
 }
 
 //----- (004432E7) --------------------------------------------------------
-int ViewingParams::_4432E7()
-{
+void ViewingParams::_4432E7()
+    {
   ViewingParams *v1; // esi@1
   int v2; // ebx@1
   signed int v3; // edx@1
@@ -12901,37 +12900,26 @@
   v4 = (44 - v3) << 9;
   if ( v1->sPartyPosZ > v2 + v4 )
     v1->sPartyPosZ = v2 + v4;
+
   v5 = v1->field_38;
   v6 = (v3 - 44) << 9;
   if ( v1->sPartyPosX < v5 + v6 )
     v1->sPartyPosX = v5 + v6;
+
   v7 = v2 + v6;
   if ( v1->sPartyPosZ < v7 )
     v1->sPartyPosZ = v7;
+
   result = v5 + v4;
   if ( v1->sPartyPosX > v5 + v4 )
     v1->sPartyPosX = result;
-  return result;
 }
 
 //----- (00443343) --------------------------------------------------------
-unsigned int ViewingParams::_443343()
-{
-  signed int v1; // esi@1
-  unsigned __int16 *v2; // edi@1
-  unsigned int result; // eax@2
-
-  v1 = 0;
-  v2 = this->pPalette;
-  do
-  {
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, v1);
-    *v2 = result;
-    ++v1;
-    ++v2;
-  }
-  while ( v1 < 256 );
-  return result;
+void ViewingParams::InitGrayPalette()
+    {
+  for  (unsigned short i=0; i<256; ++i)
+      pPalette[i]=GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(i, i, i);
 }
 
 //----- (00443365) --------------------------------------------------------
@@ -12956,7 +12944,7 @@
   unsigned int v17; // [sp+1Ch] [bp-4h]@2
 
   v1 = this;
-  _443343();
+  InitGrayPalette();
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v16 = 0x40000000u;
--- a/mm7_5.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/mm7_5.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -2742,9 +2742,9 @@
           _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute;
           continue;
         case UIMSG_4E:
-          if ( dword_50654C && byte_506550 )
-          {
-            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
+          if ( quick_spell_at_page && byte_506550 )
+          {
+            v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
             v157 = pGlobalTXT_LocalizationStrings[483];
 _sprintex_2args_draw_status_and_continue:
             sprintf(pTmpBuf, v157, v173);
@@ -2767,7 +2767,7 @@
           if ( sub_4637E0_is_there_popup_onscreen() )
             dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1;
           v98 = *(char *)(uNumSeconds + 6734);
-          if ( dword_50654C - 1 == uMessageParam )
+          if ( quick_spell_at_page - 1 == uMessageParam )
           {
             v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName;
             v161 = pGlobalTXT_LocalizationStrings[485];
@@ -2787,7 +2787,7 @@
           if ( !uActiveCharacter )
             continue;
           pPlayer10 = pPlayers[uActiveCharacter];
-          if ( !byte_506550 || !dword_50654C )
+          if ( !byte_506550 || !quick_spell_at_page )
           {
             v165 = 0;
             v151 = 0;
@@ -2797,11 +2797,11 @@
             v132 = 0;
             pPlayer10->uQuickSpell = 0;
             v130 = 0;
-            dword_50654C = 0;
+            quick_spell_at_page = 0;
             v127 = 203;
             goto _play_sound_and_continue;
           }
-          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
+          v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
           pPlayers[uActiveCharacter]->uQuickSpell = v99;
           stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
           if ( uActiveCharacter )
@@ -2893,14 +2893,14 @@
           if (player->spellbook.pChapters[player->lastOpenedSpellbookPage].bIsSpellAvailable[uMessageParam])
               //if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + &lastOpenedSpellbookPage) + uMessageParam + 402) )
           {
-                if ( dword_50654C - 1 == uMessageParam )
+                if ( quick_spell_at_page - 1 == uMessageParam )
                 {
                   pGUIWindow_CurrentMenu->Release();
                   pEventTimer->Resume();
                   viewparams->bRedrawGameUI = v0;
                   pCurrentScreen = SCREEN_GAME;
                   pIcons_LOD->_4114F2();
-                  v103 = dword_50654C + 11 * player->lastOpenedSpellbookPage;
+                  v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage;
                   if ( dword_50C9E8 < 40 )
                   {
                     dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook;
@@ -2912,7 +2912,7 @@
                 else
                 {
                   byte_506550 = 1;
-                  dword_50654C = uMessageParam + 1;
+                  quick_spell_at_page = uMessageParam + 1;
                 }
           }
         }
@@ -12424,9 +12424,11 @@
 }
 
 //----- (0040DEF3) --------------------------------------------------------
-unsigned int __fastcall GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b)
-{
-  return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
+unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
+    {
+  return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
+                           LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
+                           LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
 }
 
 //----- (0040DF3D) --------------------------------------------------------
@@ -13220,7 +13222,7 @@
 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
 
 //----- (00411300) --------------------------------------------------------
-void LoadSpellbook(unsigned int school)
+void LoadSpellbook(unsigned int spell_school)
 {
   //unsigned int v1; // esi@1
   Player *pPlayer; // ecx@1
@@ -13239,22 +13241,19 @@
   //v1 = uID;
   pPlayer = pPlayers[uActiveCharacter];
   v3 = pPlayer->uQuickSpell;
-  if ( v3 && (unsigned __int8)v3 / 11 == school )
-    dword_50654C = (unsigned __int8)v3 - 11 * school;
-  else
-    dword_50654C = 0;
-
-  //char *v11 = &pPlayer->field_152[11 * school + 63];
+  if ( v3 && (unsigned __int8)v3 / 11 == spell_school )
+    quick_spell_at_page = (unsigned __int8)v3 - 11 * spell_school;
+  else
+    quick_spell_at_page = 0;
 
   for (uint i = 1; i < 12; ++i)
   {
-    //if (v11[i])
-    if (pPlayer->spellbook.pChapters[school].bIsSpellAvailable[i - 1])
-    {
-      sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
+    if (pPlayer->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1])
+    {
+      sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
       dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
 
-      sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
+      sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]);
       dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
     }
   }
@@ -13298,30 +13297,15 @@
 //----- (00411473) --------------------------------------------------------
 void __cdecl sub_411473()
 {
-  Texture **v0; // esi@1
-  Texture **v1; // edi@1
-  Texture *v2; // ecx@2
-  Texture *v3; // ecx@2
-
   pTexture_pagemask->Release();
   pTexture_506448->Release();
   pTexture_50643C->Release();
-  v0 = &pTextures_tabs[0][1];
-  v1 = pTextures_5064A0;
-  do
-  {
-    (*v1)->Release();
-    v2 = *(v0 - 1);
-    *v1 = 0;
-    v2->Release();
-    v3 = *v0;
-    *(v0 - 1) = 0;
-    v3->Release();
-    *v0 = 0;
-    ++v1;
-    v0 += 2;
-  }
-  while ( (signed int)v1 < (signed int)&pTextures_5064A0[9] );
+  for (uint i = 0; i < 8; ++i)
+      {
+      pSpellBookPagesTextr[i]->Release();
+      pTextures_tabs[i][0]->Release();
+      pTextures_tabs[i][1]->Release();
+      }
   pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
   pIcons_LOD->_4114F2();
 }
@@ -13352,14 +13336,14 @@
 
 
 //----- (00412AF9) --------------------------------------------------------
-void __cdecl sub_412AF9()
-{
+void sub_412AF9()
+    {
   int v0; // ecx@1
 
   v0 = 0;
   if ( uActiveCharacter )
 	  v0 = pParty->pPlayers[uActiveCharacter-1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
-  pRenderer->DrawTextureIndexed(8u, 8u, pTextures_5064A0[v0]);
+  pRenderer->DrawTextureIndexed(8u, 8u, pSpellBookPagesTextr[v0]);
   pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
   pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
 }
@@ -13411,7 +13395,7 @@
         v5 = (Texture *)dword_506408[v4];
         if ( v5 != v3 )
         {
-          if ( dword_50654C == v4 )
+          if ( quick_spell_at_page == v4 )
           {
             v6 = dword_5063D8[v4];
             v23 = dword_5063D8[v4];
@@ -13586,7 +13570,7 @@
   Texture *v14; // [sp-4h] [bp-60h]@7
   GUIWindow a1; // [sp+8h] [bp-54h]@10
 
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[11]);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_11);
   if ( dword_506548 || !dword_506528 )
   {
     v13 = pTex_tab_an_6a__zoom_off;
@@ -13764,7 +13748,7 @@
     v7 = a1.uFrameY + v6;
     if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight )
       break;
-    pRenderer->DrawTextureTransparent(100, v7 + 12, pTextures_5064A0[10]);
+    pRenderer->DrawTextureTransparent(100, v7 + 12, pSpellBookPagesTextr_10);
     ++v3;
     a1.uFrameY = v7 + 24;
   }
@@ -14071,7 +14055,7 @@
     v16 = a1.uFrameY + v15;
     if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight )
       break;
-    pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pTextures_5064A0[10]);
+    pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10);
     ++v12;
     a1.uFrameY = v16 + 24;
   }
@@ -14079,110 +14063,95 @@
 
 
 //----- (00413980) --------------------------------------------------------
-char *__cdecl DrawBook_Maps()
-{
-  unsigned int v0; // eax@3
-  unsigned int v1; // eax@7
-  unsigned int v2; // eax@10
-  unsigned int v3; // eax@13
-  unsigned int v4; // eax@16
-  unsigned int v5; // eax@19
+void DrawBook_Maps()
+    {
+ 
   int v6; // eax@31
-  unsigned int v7; // eax@35
-  unsigned int v9; // [sp-8h] [bp-E0h]@3
-  unsigned int v10; // [sp-8h] [bp-E0h]@7
-  unsigned int v11; // [sp-8h] [bp-E0h]@10
-  unsigned int v12; // [sp-8h] [bp-E0h]@13
-  unsigned int v13; // [sp-8h] [bp-E0h]@16
-  unsigned int v14; // [sp-8h] [bp-E0h]@19
-  Texture *v15; // [sp-4h] [bp-DCh]@3
-  Texture *v16; // [sp-4h] [bp-DCh]@7
-  Texture *v17; // [sp-4h] [bp-DCh]@10
-  Texture *v18; // [sp-4h] [bp-DCh]@13
-  Texture *v19; // [sp-4h] [bp-DCh]@16
-  Texture *v20; // [sp-4h] [bp-DCh]@19
-  char Str[120]; // [sp+Ch] [bp-CCh]@37
-  GUIWindow v22; // [sp+84h] [bp-54h]@35
-
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[12]);
+  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->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_12);
   if ( dword_506548 || viewparams->field_2C / 128 >= 12 )
   {
-    v15 = pTex_tab_an_6a__zoom_off;
-    v9 = pViewport->uViewportY + 2;
-    v0 = pViewport->uViewportX + 408;
-  }
-  else
-  {
-    v15 = pTex_tab_an_6b__zoom_on;
-    v9 = pViewport->uViewportY + 1;
-    v0 = pViewport->uViewportX + 398;
-  }
-  pRenderer->DrawTextureTransparent(v0, v9, v15);
+    buttnTxtr = pTex_tab_an_6a__zoom_off;
+    textrY = pViewport->uViewportY + 2;
+    textrX = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_6b__zoom_on;
+    textrY = pViewport->uViewportY + 1;
+    textrX = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506544 || viewparams->field_2C / 128 <= 3 )
   {
-    v16 = pTex_tab_an_7a__zoot_off;
-    v10 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 408;
-  }
-  else
-  {
-    v16 = pTex_tab_an_7b__zoot_on;
-    v10 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 398;
-  }
-  pRenderer->DrawTextureTransparent(v1, v10, v16);
+    buttnTxtr = pTex_tab_an_7a__zoot_off;
+    textrY = pViewport->uViewportY + 38;
+    textrX = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_7b__zoot_on;
+    textrY = pViewport->uViewportY + 38;
+    textrX = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506540 )
   {
-    v17 = pTexture_506390;
-    v11 = pViewport->uViewportY + 113;
-    v2 = pViewport->uViewportX + 408;
-  }
-  else
-  {
-    v17 = pTexture_506394;
-    v11 = pViewport->uViewportY + 113;
-    v2 = pViewport->uViewportX + 398;
-  }
-  pRenderer->DrawTextureTransparent(v2, v11, v17);
+    buttnTxtr = pTexture_506390;
+    textrY = pViewport->uViewportY + 113;
+    textrX = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506394;
+    textrY = pViewport->uViewportY + 113;
+    textrX = pViewport->uViewportX + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_50653C )
   {
-    v18 = pTexture_506388;
-    v12 = pViewport->uViewportX + 150;
-    v3 = pViewport->uViewportY + 408;
-  }
-  else
-  {
-    v18 = pTexture_50638C;
-    v12 = pViewport->uViewportX + 150;
-    v3 = pViewport->uViewportY + 399;
-  }
-  pRenderer->DrawTextureTransparent(v3, v12, v18);
+    buttnTxtr = pTexture_506388;
+    textrY = pViewport->uViewportX + 150;
+    textrX = pViewport->uViewportY + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50638C;
+    textrY = pViewport->uViewportX + 150;
+    textrX = pViewport->uViewportY + 399;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506538 )
   {
-    v19 = pTexture_506380;
-    v13 = pViewport->uViewportY + 188;
-    v4 = pViewport->uViewportX + 408;
-  }
-  else
-  {
-    v19 = pTexture_506384;
-    v13 = pViewport->uViewportY + 188;
-    v4 = pViewport->uViewportX + 397;
-  }
-  pRenderer->DrawTextureTransparent(v4, v13, v19);
+    buttnTxtr = pTexture_506380;
+    textrY = pViewport->uViewportY + 188;
+    textrX = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506384;
+    textrY = pViewport->uViewportY + 188;
+    textrX = pViewport->uViewportX + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506534 )
   {
-    v20 = pTexture_506378;
-    v14 = pViewport->uViewportY + 226;
-    v5 = pViewport->uViewportX + 408;
-  }
-  else
-  {
-    v20 = pTexture_50637C;
-    v14 = pViewport->uViewportY + 226;
-    v5 = pViewport->uViewportX + 397;
-  }
-  pRenderer->DrawTextureTransparent(v5, v14, v20);
+    buttnTxtr = pTexture_506378;
+    textrY = pViewport->uViewportY + 226;
+    textrX = pViewport->uViewportX + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50637C;
+    textrY = pViewport->uViewportY + 226;
+    textrX = pViewport->uViewportX + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506544 )
     viewparams->_443291();
   if ( dword_506548 )
@@ -14193,12 +14162,9 @@
     viewparams->_443231();
   if ( dword_506538 )
     viewparams->_44323D();
-  //v6 = dword_506534;
   if ( dword_506534 )
-  {
     viewparams->_443225();
-    //v6 = dword_506534;
-  }
+
   if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | dword_506534 )
     pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
   dword_506548 = 0;
@@ -14209,18 +14175,18 @@
   dword_506540 = 0;
   DrawBook_Map_sub(97, 49, 361, 313, 0);
   pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
-  v22.uFrameWidth = 460;
-  v22.uFrameHeight = 344;
-  v22.uFrameX = 8;
-  v22.uFrameY = 8;
-  v22.uFrameZ = 467;
-  v22.uFrameW = 467;
-  v7 = pMapStats->GetMapInfo(pCurrentMapName);
-  if ( v7 )
-    v22.DrawTitleText(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
-  v22.uFrameX = 0;
-  sprintf(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y);
-  return v22.DrawTitleText(pFontComic, 0, 0x140u, 0, Str, 0);
+  map_window.uFrameWidth = 460;
+  map_window.uFrameHeight = 344;
+  map_window.uFrameX = 8;
+  map_window.uFrameY = 8;
+  map_window.uFrameZ = 467;
+  map_window.uFrameW = 467;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName);
+  if ( map_id )
+    map_window.DrawTitleText(pBook2Font, -14, 12, 0, 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, 0, party_coord, 0);
 }
 
 
@@ -14287,7 +14253,7 @@
   v0 = pParty->uCurrentHour;
   v6 = pMapStats->GetMapInfo(pCurrentMapName);
   a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTextures_5064A0[13]);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_13);
   v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
   if ( (signed int)v0 <= 12 )
   {
--- a/mm7_data.cpp	Fri Mar 15 15:58:18 2013 +0200
+++ b/mm7_data.cpp	Sat Mar 16 01:11:39 2013 +0400
@@ -1650,7 +1650,7 @@
 int dword_506540; // weak
 int dword_506544; // weak
 int dword_506548; // weak
-int dword_50654C; // weak
+int quick_spell_at_page; // weak
 char byte_506550; // weak
 char *aMoonPhaseNames[5];
 int dword_506568; // weak
--- a/mm7_data.h	Fri Mar 15 15:58:18 2013 +0200
+++ b/mm7_data.h	Sat Mar 16 01:11:39 2013 +0400
@@ -1164,7 +1164,7 @@
 extern int dword_506540; // weak
 extern int dword_506544; // weak
 extern int dword_506548; // weak
-extern int dword_50654C; // weak
+extern int quick_spell_at_page; // weak
 extern char byte_506550; // weak
 extern char *aMoonPhaseNames[5];
 extern int dword_506568; // weak
@@ -1811,7 +1811,7 @@
 void __fastcall intToString(int val, char *pOut);
 // int __cdecl crt_retnull_sub();
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor); // idb
-unsigned int __fastcall GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
+unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
 void __cdecl CallRenderPresent();
 void __thiscall DoBlt_Copy(unsigned __int16 *pPixels); // idb
 int __stdcall retzero_sub_40DFA7(int); // weak
@@ -1832,12 +1832,12 @@
 void __cdecl InitializeBookTextures();
 void __cdecl InitializeBookFonts();
 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
-void __cdecl sub_412AF9();
+void  sub_412AF9();
 void __cdecl DrawSpellBookContent();
 char __cdecl DrawBook_History();
 void __cdecl DrawBook_Quests();
 void __cdecl DrawBook_Autonotes();
-char *__cdecl DrawBook_Maps();
+void DrawBook_Maps();
 void __thiscall SellectDrawBook(unsigned int uBook); // idb
 char *__cdecl GetDayPart();
 char __cdecl DrawBook_Calendar();
@@ -1998,7 +1998,7 @@
 void GameUI_DrawPartySpells();
 __int16 __fastcall sub_441A4E(int a1);
 void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap);
-int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
+void DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
 void Initialize2DA();
 
 void  LoadLevel_InitializeLevelStr();