#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA042_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t G0421_i_ObjectDescriptionTextX; /* static? */
int16_t G0422_i_ObjectDescriptionTextY; /* static? */
int16_t G0423_i_InventoryChampionOrdinal;
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t G2008_i_PanelContent = C00_PANEL_INVENTORY;
#endif
int16_t G0424_i_PanelContent = C00_PANEL_FOOD_WATER_POISONED;
THING G0425_aT_ChestSlots[8];
THING G0426_T_OpenChest = C0xFFFF_THING_NONE;
#ifdef MEDIA153_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
#ifndef NOCOPYPROTECTION
int16_t G0427_ai_CodePatch5_CPSE[34];
#endif
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
#ifndef NOCOPYPROTECTION
char G0427_ai_CodePatch5_CPSE[289];
#endif
#endif
#ifdef MEDIA193_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J /* CHANGE4_00_LOCALIZATION Translation to German language */
char* G0428_apc_SkillLevelNames[15] = {
        "NEOPHYTE",
        "NOVICE",
        "APPRENTICE",
        "JOURNEYMAN",
        "CRAFTSMAN",
        "ARTISAN",
        "ADEPT",
        "EXPERT",
        "` MASTER",
        "a MASTER",
        "b MASTER",
        "c MASTER",
        "d MASTER",
        "e MASTER",
        "ARCHMASTER" };
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
char* G0428_apc_SkillLevelNames[15] = {
#ifdef MEDIA252_S12G
        "ANFANGER",
#endif
#ifdef MEDIA446_A20G_A22G
        "ANFAENGER",
#endif
        "NEULING",
        "LEHRLING",
        "ARBEITER",
        "GESELLE",
        "HANDWERKR",
        "FACHMANN",
        "EXPERTE",
        "` MEISTER",
        "a MEISTER",
        "b MEISTER",
        "c MEISTER",
        "d MEISTER",
        "e MEISTER",
        "ERZMEISTR" };
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
char* G0428_apc_SkillLevelNames[15] = {
        "NEOPHYTE",
        "NOVICE",
        "APPRENTI",
        "COMPAGNON",
        "ARTISAN",
        "PATRON",
        "ADEPTE",
        "EXPERT",
        "MAITRE '",
        "MAITRE a",
        "MAITRE b",
        "MAITRE c",
        "MAITRE d",
        "MAITRE e",
        "SUR-MAITRE" };
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
int16_t G2014_ai_SkillLevelNames[15] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }; /* Text indices */
#endif
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
char* G2213_apc_CreatureNameScrollText = "CREANAME";
char* G2212_apc_MagicMapScrollText = "MAGICMAP";
#endif
#ifdef MEDIA006_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB /* CHANGE7_04_IMPROVEMENT */
#ifndef NOCOPYPROTECTION
int16_t* G0429_api_Graphic21Result_CPSE[3] = {
        (int16_t*)G0293_ai_FuzzyBits_CPSE,
        (int16_t*)&G0031_i_Graphic562_FuzzySectorAnalyzed_CPSE,
        (int16_t*)&G0418_l_LastEvent22Time_CPSE };
#endif
#endif
#ifdef MEDIA315_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M /* CHANGE7_04_IMPROVEMENT */
#ifndef NOCOPYPROTECTION
int16_t* G0429_api_Graphic21Result_CPSE[4] = {
        (int16_t*)G0293_ai_FuzzyBits_CPSE,
        (int16_t*)&G0031_i_Graphic562_FuzzySectorAnalyzed_CPSE,
        (int16_t*)&G0418_l_LastEvent22Time_CPSE,
        (int16_t*)&G0068_i_CheckLastEvent22Time_CPSE }; /* Set to 0 by graphic #21 or by F0277_CPSE_IsFuzzySectorValid_FuzzyBits */
#endif
#endif


#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "player"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "player"
#endif

#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
#include "CHEST.C"
#endif

STATICFUNCTION void F0332_INVENTORY_DrawIconToViewport(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0689_i_IconIndex, P0690_i_X, P0691_i_Y)
#endif
int16_t P0689_i_IconIndex SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
int16_t P0690_i_X         SEPARATOR
int16_t P0691_i_Y         FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t P2283_i_ZoneIndex FINAL_SEPARATOR
#endif
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1015_ai_Box[4];
        unsigned char* L1016_puc_Bitmap_Icon;


        L1016_puc_Bitmap_Icon = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(16, 16), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        M769_BOX_RIGHT(L1015_ai_Box) = (M768_BOX_LEFT(L1015_ai_Box) = P0690_i_X) + 15;
        M771_BOX_BOTTOM(L1015_ai_Box) = (M770_BOX_TOP(L1015_ai_Box) = P0691_i_Y) + 15;
        F0036_OBJECT_ExtractIconFromBitmap(P0689_i_IconIndex, L1016_puc_Bitmap_Icon);
        M519_F0020_MAIN_BlitToViewport(L1016_puc_Bitmap_Icon, L1015_ai_Box, C008_BYTE_WIDTH, CM1_COLOR_NO_TRANSPARENCY, 16);
        F0469_MEMORY_FreeAtHeapTop((long)M075_BITMAP_BYTE_COUNT(16, 16));
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        unsigned char* L1016_puc_Bitmap_Icon;
        int16_t L2825_ai_XYZ[4];


#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        L1016_puc_Bitmap_Icon = F0468_MEMORY_Allocate((long)G2184_ActionIconByteCount, MASK0x8000_ALLOCATE_BITMAP | C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L1016_puc_Bitmap_Icon = F0606_AllocateMemForGraphic(G2075_ObjectIconWidth, G2076_ObjectIconHeight, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
#endif
        F0618_LoadZone(P2283_i_ZoneIndex, L2825_ai_XYZ);
        F0036_OBJECT_ExtractIconFromBitmap(P0689_i_IconIndex, M775_CAST_PL(L1016_puc_Bitmap_Icon));
        F0020_MAIN_BlitToViewport(L1016_puc_Bitmap_Icon, L2825_ai_XYZ, CM1_COLOR_NO_TRANSPARENCY);
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        F0469_MEMORY_FreeAtHeapTop((long)G2184_ActionIconByteCount + 4);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0607_FreeMemForGraphic(L1016_puc_Bitmap_Icon);
#endif
#endif
}

#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#include "CHEST.C"
#endif

STATICFUNCTION void F0335_INVENTORY_DrawPanel_ObjectDescriptionString(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0695_pc_String)
char* P0695_pc_String FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER char* P0695_pc_String FINAL_SEPARATOR
#endif
{
#ifdef MEDIA054_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_X31J
        REGISTER char* L1030_pc_StringLine;
        REGISTER char* L1031_pc_String;
        REGISTER BOOLEAN L1029_B_SeveralLines;
        char L1032_ac_String[128];
#endif


        if (P0695_pc_String[0] == '\f') { /* Form feed */
                P0695_pc_String++;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0421_i_ObjectDescriptionTextX = 108;
                G0422_i_ObjectDescriptionTextY = 59;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0636_GetZoneTopLeftCoordinatesWith1PixelMargin(C556_ZONE_OBJECT_DESCRIPTION, &G0421_i_ObjectDescriptionTextX, &G0422_i_ObjectDescriptionTextY);
#endif
        }
        if (P0695_pc_String[0]) {
#ifdef MEDIA585_X30J_P20JA_P20JB_F31J_X31J_P31J
                F0052_TEXT_PrintToViewport(G0421_i_ObjectDescriptionTextX, G0422_i_ObjectDescriptionTextY, C13_COLOR_LIGHTEST_GRAY, P0695_pc_String);
                G0422_i_ObjectDescriptionTextY += G2342_C17_JapaneseTextLineHeight;
#endif
#ifdef MEDIA058_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                M547_STRCPY(L1032_ac_String, P0695_pc_String);
                L1030_pc_StringLine = L1032_ac_String;
                L1029_B_SeveralLines = C0_FALSE;
                while (*L1030_pc_StringLine) {
                        if (M544_STRLEN(L1030_pc_StringLine) > 18) { /* If string is too long to fit on one line */
                                L1031_pc_String = &L1030_pc_StringLine[17];
                                while (*L1031_pc_String != ' ') { /* Go back to the last space character */
                                        L1031_pc_String--;
                                }
                                *L1031_pc_String = '\0'; /* and split the string there */
                                L1029_B_SeveralLines = C1_TRUE;
                        }
                        F0052_TEXT_PrintToViewport(G0421_i_ObjectDescriptionTextX, G0422_i_ObjectDescriptionTextY, C13_COLOR_LIGHTEST_GRAY, L1030_pc_StringLine);
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        G0422_i_ObjectDescriptionTextY += 7;
#endif
#ifdef MEDIA554_F20E_F20J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                        G0422_i_ObjectDescriptionTextY += G2088_C7_TextLineHeight;
#endif
                        if (L1029_B_SeveralLines) {
                                L1029_B_SeveralLines = C0_FALSE;
                                L1030_pc_StringLine = ++L1031_pc_String;
                        } else {
                                *L1030_pc_StringLine = '\0';
                        }
                }
#endif
        }
}

STATICFUNCTION void F0336_INVENTORY_DrawPanel_BuildObjectAttributesString(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0696_i_PotentialAttributesMask, P0697_i_ActualAttributesMask, P0698_ppc_AttributeStrings, P0699_pc_StringDestination, P0700_pc_StringPrefix, P0701_pc_StringSuffix)
register int16_t P0696_i_PotentialAttributesMask SEPARATOR
register int16_t P0697_i_ActualAttributesMask    SEPARATOR
register char**  P0698_ppc_AttributeStrings      SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t          P0696_i_PotentialAttributesMask SEPARATOR
int16_t          P0697_i_ActualAttributesMask    SEPARATOR
char**           P0698_ppc_AttributeStrings      SEPARATOR
#endif
REGISTER char*   P0699_pc_StringDestination      SEPARATOR
char*            P0700_pc_StringPrefix           SEPARATOR
char*            P0701_pc_StringSuffix           FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L1035_ui_IdenticalBitCount;
#endif
        REGISTER unsigned int16_t L1033_ui_StringIndex;
        REGISTER int16_t L1034_i_AttributeMask;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L1035_ui_IdenticalBitCount;
#endif


        L1035_ui_IdenticalBitCount = 0;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        for (L1033_ui_StringIndex = 0, L1034_i_AttributeMask = 1; L1033_ui_StringIndex < 16; L1033_ui_StringIndex++, L1034_i_AttributeMask <<= 1) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L1034_i_AttributeMask = 1;
        for (L1033_ui_StringIndex = 0; L1033_ui_StringIndex < 16; L1033_ui_StringIndex++) {
#endif
                if (L1034_i_AttributeMask & P0696_i_PotentialAttributesMask & P0697_i_ActualAttributesMask) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE test */
                        L1035_ui_IdenticalBitCount++;
                }
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L1034_i_AttributeMask <<= 1;
#endif
        }
        if (L1035_ui_IdenticalBitCount == 0) {
                *P0699_pc_StringDestination = '\0';
                return;
        }
        M547_STRCPY(P0699_pc_StringDestination, P0700_pc_StringPrefix);
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        for (L1033_ui_StringIndex = 0, L1034_i_AttributeMask = 1; L1033_ui_StringIndex < 16; L1033_ui_StringIndex++, L1034_i_AttributeMask <<= 1) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L1034_i_AttributeMask = 1;
        for (L1033_ui_StringIndex = 0; L1033_ui_StringIndex < 16; L1033_ui_StringIndex++) {
#endif
                if (L1034_i_AttributeMask & P0696_i_PotentialAttributesMask & P0697_i_ActualAttributesMask) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE test */
                        M545_STRCAT(P0699_pc_StringDestination, P0698_ppc_AttributeStrings[L1033_ui_StringIndex]);
                        if (L1035_ui_IdenticalBitCount-- > 2) {
                                M545_STRCAT(P0699_pc_StringDestination, ", ");
                        } else {
                                if (L1035_ui_IdenticalBitCount == 1) {
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                        M545_STRCAT(P0699_pc_StringDestination, " AND ");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                        strcat(P0699_pc_StringDestination, " UND ");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                        strcat(P0699_pc_StringDestination, " ET ");
#endif
#ifdef MEDIA585_X30J_P20JA_P20JB_F31J_X31J_P31J
                                        M545_STRCAT(P0699_pc_StringDestination, " ");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                        M545_STRCAT(P0699_pc_StringDestination, F0758_TranslateLanguage(C30_TEXT_AND));
#endif
                                }
                        }
                }
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L1034_i_AttributeMask <<= 1;
#endif
        }
        M545_STRCAT(P0699_pc_StringDestination, P0701_pc_StringSuffix);
}

#ifdef MEDIA351_G14ED_G20E_G21E /* CHANGE7_04_IMPROVEMENT */
#ifndef NOCOPYPROTECTION
int16_t* G0429_api_Graphic21Result_CPSE[4] = {
        (int16_t*)G0293_ai_FuzzyBits_CPSE,
        (int16_t*)&G0031_i_Graphic562_FuzzySectorAnalyzed_CPSE,
        (int16_t*)&G0418_l_LastEvent22Time_CPSE,
        (int16_t*)&G0068_i_CheckLastEvent22Time_CPSE }; /* Set to 0 by graphic #21 or by F0277_CPSE_IsFuzzySectorValid_FuzzyBits */
#endif
#endif

void F0337_INVENTORY_SetDungeonViewPalette(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA128_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t* L1040_pi_Multiple;
#define AL1040_pi_TorchLightPower L1040_pi_Multiple
#define AL1040_pi_LightAmount     L1040_pi_Multiple
        REGISTER int16_t* L1041_pi_TorchLightPower;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L1043_ps_Champion;
        WEAPON* L1042_ps_Weapon;
        REGISTER unsigned int16_t L1039_ui_Multiple;
#endif
#define AL1039_ui_SlotIndex    L1039_ui_Multiple
#define AL1039_ui_PaletteIndex L1039_ui_Multiple
#define AL1039_ui_Counter      L1039_ui_Multiple
        REGISTER int16_t L1036_i_TotalLightAmount;
        REGISTER unsigned int16_t L1037_ui_TorchLightAmountMultiplier;
        REGISTER int16_t L1038_i_Counter;
#ifdef MEDIA117_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned int16_t L1039_ui_Multiple;
        WEAPON* L1042_ps_Weapon;
        CHAMPION* L1043_ps_Champion;
        unsigned int16_t L1044_ui_Multiple;
#endif
#define AL1044_T_Thing            L1044_ui_Multiple
#define AL1044_ui_TorchLightPower L1044_ui_Multiple
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L1044_ui_Multiple;
#endif
        int16_t L1045_ai_TorchesLightPower[8];


        if (G0269_ps_CurrentMap->C.Difficulty == 0) {
#endif
                G0304_i_DungeonViewPaletteIndex = 0; /* Brightest color palette index */
#ifdef MEDIA128_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        } else {
                /* Get torch light power from both hands of each champion in the party */
                L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and F0032_OBJECT_GetType then returns -1 */
                L1043_ps_Champion = M516_CHAMPIONS;
                AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
                while (L1038_i_Counter--) {
                        AL1039_ui_SlotIndex = C01_SLOT_ACTION_HAND + 1;
                        while (AL1039_ui_SlotIndex--) {
                                if ((F0032_OBJECT_GetType(AL1044_T_Thing = L1043_ps_Champion->Slots[AL1039_ui_SlotIndex]) >= C004_ICON_WEAPON_TORCH_UNLIT) &&
                                    (F0032_OBJECT_GetType(AL1044_T_Thing = L1043_ps_Champion->Slots[AL1039_ui_SlotIndex]) <= C007_ICON_WEAPON_TORCH_LIT)) {
                                        L1042_ps_Weapon = (WEAPON*)F0156_DUNGEON_GetThingData(AL1044_T_Thing);
                                        *AL1040_pi_TorchLightPower = L1042_ps_Weapon->ChargeCount;
                                } else {
                                        *AL1040_pi_TorchLightPower = 0;
                                }
                                AL1040_pi_TorchLightPower++;
                        }
                        L1043_ps_Champion++;
                }
                /* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */
                AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
                AL1039_ui_Counter = 0;
                while (AL1039_ui_Counter != 4) {
                        L1038_i_Counter = 7 - AL1039_ui_Counter;
                        L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1];
                        while (L1038_i_Counter--) {
                                if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) {
                                        AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower;
                                        *L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower;
                                        *AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower;
                                }
                                L1041_pi_TorchLightPower++;
                        }
                        AL1040_pi_TorchLightPower++;
                        AL1039_ui_Counter++;
                }
                /* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */
                L1037_ui_TorchLightAmountMultiplier = 6;
                AL1039_ui_Counter = 5;
                L1036_i_TotalLightAmount = 0;
                AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower;
                while (AL1039_ui_Counter--) {
                        if (*AL1040_pi_TorchLightPower) {
                                L1036_i_TotalLightAmount += (G0039_ai_Graphic562_LightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6;
                                L1037_ui_TorchLightAmountMultiplier = F0025_MAIN_GetMaximumValue(0, L1037_ui_TorchLightAmountMultiplier - 1);
                        }
                        AL1040_pi_TorchLightPower++;
                }
                L1036_i_TotalLightAmount += G0407_s_Party.MagicalLightAmount;
                /* Select palette corresponding to the total light amount */
                AL1040_pi_LightAmount = G0040_ai_Graphic562_PaletteIndexToLightAmount;
                if (L1036_i_TotalLightAmount > 0) {
                        AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */
                        while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) {
                                AL1039_ui_PaletteIndex++;
                        }
                } else {
                        AL1039_ui_PaletteIndex = 5; /* Darkest color palette index */
                }
                G0304_i_DungeonViewPaletteIndex = AL1039_ui_PaletteIndex;
        }
#endif
        G0342_B_RefreshDungeonViewPaletteRequested = C1_TRUE;
}

void F0338_INVENTORY_DecreaseTorchesLightPower_CPSE(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER CHAMPION* L1050_ps_Champion;
        REGISTER WEAPON* L1051_ps_Weapon;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L1046_i_ChampionCount;
#endif
        REGISTER int16_t L1047_i_SlotIndex;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L1046_i_ChampionCount;
#endif
        REGISTER BOOLEAN L1048_B_TorchChargeCountChanged;
        REGISTER int16_t L1049_i_IconIndex;


        L1048_B_TorchChargeCountChanged = C0_FALSE;
        L1046_i_ChampionCount = G0305_ui_PartyChampionCount;
        if (G0299_ui_CandidateChampionOrdinal) {
                L1046_i_ChampionCount--;
        }
        L1050_ps_Champion = M516_CHAMPIONS;
        while (L1046_i_ChampionCount--) {
                L1047_i_SlotIndex = C01_SLOT_ACTION_HAND + 1;
                while (L1047_i_SlotIndex--) {
                        L1049_i_IconIndex = F0033_OBJECT_GetIconIndex(L1050_ps_Champion->Slots[L1047_i_SlotIndex]);
                        if ((L1049_i_IconIndex >= C004_ICON_WEAPON_TORCH_UNLIT) && (L1049_i_IconIndex <= C007_ICON_WEAPON_TORCH_LIT)) {
                                L1051_ps_Weapon = (WEAPON*)F0156_DUNGEON_GetThingData(L1050_ps_Champion->Slots[L1047_i_SlotIndex]);
                                if (L1051_ps_Weapon->ChargeCount) {
                                        if ((--L1051_ps_Weapon->ChargeCount) == 0) {
                                                L1051_ps_Weapon->DoNotDiscard = C0_FALSE;
                                        }
                                        L1048_B_TorchChargeCountChanged = C1_TRUE;
                                }
                        }
                }
                L1050_ps_Champion++;
        }
#ifdef MEDIA067_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J
#ifndef NOCOPYPROTECTION
        if (G0031_i_Graphic562_FuzzySectorAnalyzed_CPSE != C00136_TRUE) {
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
                F0137_CPSEF_PatchFunctionWithHiddenCodeLauncher(F0331_CHAMPION_ApplyTimeEffects_CPSF, F0489_MEMORY_GetNativeBitmapOrGraphic, C021_GRAPHIC_CHECK_FUZZY_BITS_IN_FUZZY_SECTOR, &M517_FuzzySectorReadingBuffer_CPSE[-94] + 94, G0429_api_Graphic21Result_CPSE, G0368_api_CodePatches_CPSE, 6);
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
                F0137_CPSEF_PatchFunctionWithHiddenCodeLauncher(F0331_CHAMPION_ApplyTimeEffects_CPSF, F0489_MEMORY_GetNativeBitmapOrGraphic, C021_GRAPHIC_CHECK_FUZZY_BITS_IN_FUZZY_SECTOR, G3958_, M517_FuzzySectorReadingBuffer_CPSE, G0429_api_Graphic21Result_CPSE, G0368_api_CodePatches_CPSE, 6);
#endif
#ifdef MEDIA423_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
                F0137_CPSEF_PatchFunctionWithHiddenCodeLauncher(F0331_CHAMPION_ApplyTimeEffects_CPSF, F0489_MEMORY_GetNativeBitmapOrGraphic, C021_GRAPHIC_CHECK_FUZZY_BITS_IN_FUZZY_SECTOR, M517_FuzzySectorReadingBuffer_CPSE, G0429_api_Graphic21Result_CPSE, G0368_api_CodePatches_CPSE, 6);
#endif
#ifdef MEDIA081_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
                G0031_i_Graphic562_FuzzySectorAnalyzed_CPSE = C00136_TRUE;
#endif
#ifdef MEDIA586_X30J_P20JA_P20JB_X31J
                if (!F0277_CPSE_IsFuzzySectorValid_FuzzyBits(M517_FuzzySectorReadingBuffer_CPSE)) {
                        G0189_i_Graphic558_StopAddingEvents_CPSE = C00136_TRUE;
                }
#endif
        }
#endif
#endif
        if (L1048_B_TorchChargeCountChanged) {
                F0337_INVENTORY_SetDungeonViewPalette();
                F0296_CHAMPION_DrawChangedObjectIcons();
        }
}

STATICFUNCTION void F0339_INVENTORY_DrawPanel_ArrowOrEye(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0702_B_PressingEye)
#endif
BOOLEAN P0702_B_PressingEye FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(P0702_B_PressingEye ? C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION : C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT), G0033_ai_Graphic562_Box_ArrowOrEye, C008_BYTE_WIDTH, C08_COLOR_RED, 9);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(P0702_B_PressingEye ? C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION : C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT, C503_ZONE_ARROW_OR_EYE, C08_COLOR_RED);
#endif
}

#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN F0802_IsMagicMap(
THING P2284_T_Thing FINAL_SEPARATOR
{
        char L2826_ac_ScrollText[200];


        if (M012_TYPE(P2284_T_Thing) == C07_THING_TYPE_SCROLL) {
                F0168_DUNGEON_DecodeText(M774_CAST_PUC(L2826_ac_ScrollText), ((SCROLL*)G0284_apuc_ThingData[C07_THING_TYPE_SCROLL])[M013_INDEX(P2284_T_Thing)].TextStringThingIndex, C2_TEXT_TYPE_SCROLL | MASK0x8000_DECODE_EVEN_IF_INVISIBLE);
                if (!M546_STRCMP(L2826_ac_ScrollText, G2212_apc_MagicMapScrollText)) {
                        return C1_TRUE;
                }
        }
        return C0_FALSE;
}

void F0803_DrawMagicMapIcon(
int16_t P2285_i_MagicMapIconIndex SEPARATOR
int16_t P2286_i_X                 SEPARATOR
int16_t P2287_i_Y                 FINAL_SEPARATOR
{
        int16_t L2827_ai_XYZ[4];


        F0654_Call_F0132_VIDEO_Blit(M772_CAST_PC(F0489_MEMORY_GetNativeBitmapOrGraphic(C012_GRAPHIC_MAGIC_MAP_ICONS)), M772_CAST_PC(G0296_puc_Bitmap_Viewport), F0787_GetZoneInitializedFromCoordinates(L2827_ai_XYZ, P2286_i_X, P2287_i_Y, G2343_i_MagicMapIconWidth, G2344_i_MagicMapIconHeight), G2343_i_MagicMapIconWidth * (P2285_i_MagicMapIconIndex & 0x0F), G2344_i_MagicMapIconHeight * (P2285_i_MagicMapIconIndex >> 4), C10_COLOR_FLESH);
}

void F0804_DrawMagicMap(
int16_t          P2288_i_X         SEPARATOR
int16_t          P2289_i_Y         SEPARATOR
int16_t          P2290_i_Direction SEPARATOR
REGISTER int16_t P2291_i_          SEPARATOR
REGISTER int16_t P2292_i_          FINAL_SEPARATOR
{
        REGISTER int16_t L2828_i_;
        REGISTER int16_t L2829_i_;
        int16_t L2830_ai_SquareAspect[M559_SQUARE_ASPECT_INT_COUNT];
        int16_t L2831_ai_XYZ[4];
        REGISTER CHAMPION* L2832_ps_Champion;
        REGISTER PROJECTILE* L2833_ps_Projectile;
        BOOLEAN L2834_B_;
        THING L2835_T_Thing;
        THING L2836_T_Thing;
        THING L2837_T_Thing;
        REGISTER THING L2838_T_Thing; /* L2838_T_Thing D3 */


        L2832_ps_Champion = &M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)];
        F0172_DUNGEON_SetSquareAspect(L2830_ai_SquareAspect, P2290_i_Direction, P2288_i_X, P2289_i_Y);
        L2828_i_ = CM1_COLOR_NO_TRANSPARENCY;
        if ((P2288_i_X == G0306_i_PartyMapX) && (P2289_i_Y == G0307_i_PartyMapY)) {
                L2828_i_ = C08_COLOR_RED;
        } else {
                if (L2832_ps_Champion->MagicMapWizardSpellCount && (L2830_ai_SquareAspect[C0_ELEMENT] != C00_ELEMENT_WALL) && M007_GET(L2830_ai_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL], MASK0x8000_FOOTPRINTS)) {
                        L2828_i_ = C04_COLOR_CYAN;
                }
        }
        if (L2828_i_ >= 0) {
                F0735_FillViewportBox(F0787_GetZoneInitializedFromCoordinates(L2831_ai_XYZ, P2291_i_ - G2345_, P2292_i_ - G2346_, (G2345_ << 1) + G2343_i_MagicMapIconWidth, (G2346_ << 1) + G2344_i_MagicMapIconHeight), L2828_i_);
        }
        L2834_B_ = (M034_SQUARE_TYPE(L2830_ai_SquareAspect[C1_SQUARE]) == C06_ELEMENT_FAKEWALL) && M007_GET(L2830_ai_SquareAspect[C1_SQUARE], MASK0x0001_FAKEWALL_IMAGINARY);
        switch (L2830_ai_SquareAspect[C0_ELEMENT]) {
                case C00_ELEMENT_WALL:
                        if (L2832_ps_Champion->MagicMapNinjaSpellCount && L2834_B_ && (G0313_ul_GameTime & 2)) {
                                F0803_DrawMagicMapIcon(1, P2291_i_, P2292_i_);
                                break;
                        }
                        F0803_DrawMagicMapIcon(0, P2291_i_, P2292_i_);
                        for (L2828_i_ = 0; L2828_i_ <= 3; L2828_i_++) {
                                if ((L2829_i_ = L2830_ai_SquareAspect[L2828_i_ + 3]) != 0) {
                                        L2829_i_--;
                                        if (L2829_i_ == G0266_i_CurrentMapViAltarWallOrnamentIndex) {
                                                L2829_i_ = L2828_i_ + 26;
                                                goto loc_E366;
                                        } else {
                                                if (F0149_DUNGEON_IsWallOrnamentAnAlcove(L2829_i_)) {
                                                        L2829_i_ = L2828_i_ + 22;
                                                        goto loc_E366;
                                                } else {
                                                        if (F0601_IsWallOrnamentAFountain(L2829_i_)) {
                                                                L2829_i_ = L2828_i_ + 30;
                                                                loc_E366:
                                                                F0803_DrawMagicMapIcon(L2829_i_, P2291_i_, P2292_i_);
                                                        }
                                                }
                                        }
                                }
                        }
                        break;
                case C01_ELEMENT_CORRIDOR:
                        F0803_DrawMagicMapIcon(2, P2291_i_, P2292_i_);
                        if ((L2829_i_ = L2830_ai_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL] & ~MASK0x8000_FOOTPRINTS) != 0) {
                                F0803_DrawMagicMapIcon(G0262_auc_CurrentMapFloorOrnamentIndices[M001_ORDINAL_TO_INDEX(L2829_i_)] + 78, P2291_i_, P2292_i_);
                        }
                        break;
                case C05_ELEMENT_TELEPORTER:
                        L2828_i_ = M004_RANDOM(4) + 6;
                        goto loc_E43E;
                        break;
                case C16_ELEMENT_DOOR_SIDE:
                        L2828_i_ = 11;
                        goto loc_2F86A;
                case C17_ELEMENT_DOOR_FRONT:
                        L2828_i_ = 10;
                        loc_2F86A:
                        if (!((((DOOR*)(G0284_apuc_ThingData[C00_THING_TYPE_DOOR]))[L2830_ai_SquareAspect[M557_DOOR_THING_INDEX]]).Button)) {
                                L2828_i_ += 2;
                        }
                        if ((L2830_ai_SquareAspect[M556_DOOR_STATE] == C0_DOOR_STATE_OPEN) || (L2830_ai_SquareAspect[M556_DOOR_STATE] == C5_DOOR_STATE_DESTROYED)) {
                                L2828_i_ += 4;
                        }
                        goto loc_E43E;
                        break;
                case C18_ELEMENT_STAIRS_SIDE:
                case C19_ELEMENT_STAIRS_FRONT:
                        L2828_i_ = M021_NORMALIZE(F0155_DUNGEON_GetStairsExitDirection(P2288_i_X, P2289_i_Y) - P2290_i_Direction);
                        if (L2830_ai_SquareAspect[M555_STAIRS_UP]) {
                                L2828_i_ += 2;
                                L2828_i_ &= 3;
                        }
                        L2828_i_ += 18;
                        goto loc_E43E;
                        break;
                case C02_ELEMENT_PIT:
                        L2828_i_ = 3;
                        if (L2830_ai_SquareAspect[M554_PIT_OR_TELEPORTER_VISIBLE]) {
                                L2828_i_++;
                                if ((L2832_ps_Champion->MagicMapNinjaSpellCount) && (G0313_ul_GameTime & 1)) {
                                        L2828_i_++;
                                }
                        }
                        loc_E43E:
                        F0803_DrawMagicMapIcon(L2828_i_, P2291_i_, P2292_i_);
        }
        if (L2832_ps_Champion->MagicMapFighterSpellCount || L2832_ps_Champion->MagicMapWizardSpellCount) {
                L2835_T_Thing = L2836_T_Thing = L2837_T_Thing = C0xFFFE_THING_ENDOFLIST;
                for (L2838_T_Thing = L2830_ai_SquareAspect[M550_FIRST_THING]; L2838_T_Thing != C0xFFFE_THING_ENDOFLIST; L2838_T_Thing = F0159_DUNGEON_GetNextThing(L2838_T_Thing)) {
                        if (((L2828_i_ = M012_TYPE(L2838_T_Thing)) == C04_THING_TYPE_GROUP) && L2832_ps_Champion->MagicMapFighterSpellCount) {
                                L2835_T_Thing = L2838_T_Thing;
                                continue;
                        }
                        if (L2832_ps_Champion->MagicMapWizardSpellCount) {
                                if (L2828_i_ == C14_THING_TYPE_PROJECTILE) {
                                        if (L2836_T_Thing == C0xFFFE_THING_ENDOFLIST) {
                                                L2836_T_Thing = L2838_T_Thing;
                                        }
                                } else {
                                        if (L2828_i_ == C15_THING_TYPE_EXPLOSION) {
                                                if (L2837_T_Thing == C0xFFFE_THING_ENDOFLIST) {
                                                        L2837_T_Thing = L2838_T_Thing;
                                                }
                                        } else {
                                                if (L2828_i_ == C10_THING_TYPE_JUNK) {
                                                        if (F0032_OBJECT_GetType(L2838_T_Thing) == C197_ICON_JUNK_ZOKATHRA) {
                                                                L2828_i_ = M021_NORMALIZE(M011_CELL(L2838_T_Thing) - P2290_i_Direction) + 34;
                                                                if ((L2830_ai_SquareAspect[C0_ELEMENT] == C00_ELEMENT_WALL) && !L2834_B_) {
                                                                        L2828_i_ += 4;
                                                                }
                                                                F0803_DrawMagicMapIcon(L2828_i_, P2291_i_, P2292_i_);
                                                        }
                                                }
                                        }
                                }
                        }
                }
                if ((L2835_T_Thing != C0xFFFE_THING_ENDOFLIST) && !M007_GET(F0144_DUNGEON_GetCreatureAttributes(L2835_T_Thing), MASK0x4000_MAGICMAP)) {
                        F0803_DrawMagicMapIcon((G0313_ul_GameTime & 1) + 76, P2291_i_, P2292_i_);
                }
                for (L2838_T_Thing = L2836_T_Thing; L2838_T_Thing != C0xFFFE_THING_ENDOFLIST; L2838_T_Thing = F0159_DUNGEON_GetNextThing(L2838_T_Thing)) {
                        if (M012_TYPE(L2838_T_Thing) != C14_THING_TYPE_PROJECTILE) {
                                continue;
                        }
                        L2833_ps_Projectile = (PROJECTILE*)F0156_DUNGEON_GetThingData(L2838_T_Thing);
                        if ((L2828_i_ = F0142_DUNGEON_GetProjectileAspect(L2833_ps_Projectile->Slot)) < 0) {
                                if (L2828_i_ == -M000_INDEX_TO_ORDINAL(C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL)) {
                                        L2828_i_ = 50;
                                } else {
                                        if (L2828_i_ == -M000_INDEX_TO_ORDINAL(C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT)) {
                                                L2828_i_ = 54;
                                        } else {
                                                if (L2828_i_ == -M000_INDEX_TO_ORDINAL(C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD)) {
                                                        L2828_i_ = 62;
                                                } else {
                                                        if (L2828_i_ == -M000_INDEX_TO_ORDINAL(C12_PROJECTILE_ASPECT_EXPLOSION_SLIME)) {
                                                                L2828_i_ = 58;
                                                        } else {
                                                                if (L2828_i_ == -M000_INDEX_TO_ORDINAL(C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT)) {
                                                                        L2828_i_ = 42;
                                                                        if (M016_IS_ORIENTED_WEST_EAST(G0370_ps_Events[L2833_ps_Projectile->EventIndex].C.Projectile.Direction) != M016_IS_ORIENTED_WEST_EAST(P2290_i_Direction)) {
                                                                                L2828_i_ += 4;
                                                                        }
                                                                }
                                                        }
                                                }
                                        }
                                }
                                if (L2828_i_ > 0) {
                                        loc_2FABD:
                                        F0803_DrawMagicMapIcon(L2828_i_ + M021_NORMALIZE(M011_CELL(L2838_T_Thing) - P2290_i_Direction), P2291_i_, P2292_i_);
                                }
                        } else {
                                if (F0032_OBJECT_GetType(L2833_ps_Projectile->Slot) == C197_ICON_JUNK_ZOKATHRA) {
                                        L2828_i_ = 34;
                                        goto loc_2FABD;
                                }
                        }
                }
                for (L2838_T_Thing = L2837_T_Thing; L2838_T_Thing != C0xFFFE_THING_ENDOFLIST; L2838_T_Thing = F0159_DUNGEON_GetNextThing(L2838_T_Thing)) {
                        if (M012_TYPE(L2838_T_Thing) != C15_THING_TYPE_EXPLOSION) {
                                continue;
                        }
                        L2833_ps_Projectile = (PROJECTILE*)F0156_DUNGEON_GetThingData(L2838_T_Thing);
                        L2829_i_ = 0;
                        if (((L2828_i_ = ((EXPLOSION*)L2833_ps_Projectile)->Type) == C000_EXPLOSION_FIREBALL) || (L2828_i_ == C002_EXPLOSION_LIGHTNING_BOLT)) {
                                L2829_i_ = 66;
                        } else {
                                if ((L2828_i_ == C006_EXPLOSION_POISON_BOLT) || (L2828_i_ == C007_EXPLOSION_POISON_CLOUD)) {
                                        L2829_i_ = M004_RANDOM(4) + 68;
                                } else {
                                        if (L2828_i_ == C050_EXPLOSION_FLUXCAGE) {
                                                L2829_i_ = M004_RANDOM(4) + 72;
                                        } else {
                                                if (L2828_i_ < (unsigned int16_t)C040_EXPLOSION_SMOKE) {
                                                        L2829_i_ = 67;
                                                }
                                        }
                                }
                        }
                        if (L2829_i_) {
                                F0803_DrawMagicMapIcon(L2829_i_, P2291_i_, P2292_i_);
                        }
                }
        }
}
#endif

STATICFUNCTION void F0340_INVENTORY_DrawPanel_ScrollTextLine(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0703_i_Y, P0704_pc_String)
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t        P2293_i_X       SEPARATOR
#endif
int16_t        P0703_i_Y       SEPARATOR
REGISTER char* P0704_pc_String FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2839_i_Width;
        int16_t L2840_i_Height;
#endif
#ifdef MEDIA061_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
        REGISTER char* L1052_pc_Character;


        L1052_pc_Character = P0704_pc_String;
        while (*L1052_pc_Character) {
                if ((*L1052_pc_Character >= 'A') && (*L1052_pc_Character <= 'Z')) {
                        *L1052_pc_Character++ -= 64; /* Do not use default characters in font but rather special characters for scrolls */
                } else {
#ifdef MEDIA258_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E /* CHANGE5_03_IMPROVEMENT More characters are replaced by variants for scroll texts. This only includes a single quote character which is also added to the font graphic */
#ifdef MEDIA259_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_I34E_I34M
                        if (*L1052_pc_Character >= '{') { /* '{' is ASCII 123 */
#endif
#ifdef MEDIA563_F20E_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                        if (*L1052_pc_Character >= 0x7B) { /* '{' is ASCII 123 */
#endif
                                *L1052_pc_Character++ -= 96;
                        } else
#endif
                                L1052_pc_Character++;
                }
        }
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M521_F0040_TEXT_Print(G0296_puc_Bitmap_Viewport, C112_BYTE_WIDTH_VIEWPORT, 162 - ((6 * strlen(P0704_pc_String)) >> 1), P0703_i_Y, C00_COLOR_BLACK, C15_COLOR_WHITE, P0704_pc_String, C136_HEIGHT_VIEWPORT); /* Center text horizontally */
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (F0645_GetStringPixelDimensions(P0704_pc_String, &L2839_i_Width, &L2840_i_Height)) {
                M720_F0644_PrintTextAlt(G0296_puc_Bitmap_Viewport, G2073_C224_ViewportPixelWidth, P2293_i_X - (L2839_i_Width >> 1), P0703_i_Y, C00_COLOR_BLACK, C15_COLOR_WHITE, P0704_pc_String, G2074_C136_ViewportHeight);
        }
#endif
}

#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void F0805_CreatureNameScroll(
REGISTER char* P2294_pc_ScrollText FINAL_SEPARATOR
{
        REGISTER char* L2841_pc_ScrollText;
        REGISTER char* L2842_pc_CreatureName;
        REGISTER int16_t L2843_i_CreatureNameScrollTextLength;
        REGISTER THING L2844_T_Thing;
        REGISTER int16_t L2845_i_;
        REGISTER int16_t L2846_i_;


        L2842_pc_CreatureName = NULL;
        L2841_pc_ScrollText = P2294_pc_ScrollText;
        L2843_i_CreatureNameScrollTextLength = M544_STRLEN(G2213_apc_CreatureNameScrollText);
        while ((L2841_pc_ScrollText = F0816_strstr(L2841_pc_ScrollText, G2213_apc_CreatureNameScrollText)) != NULL) {
                if (L2842_pc_CreatureName == NULL) {
                        G0424_i_PanelContent = C09_PANEL_CREATURE_NAME_SCROLL;
                        L2845_i_ = G0306_i_PartyMapX;
                        L2846_i_ = G0307_i_PartyMapY;
                        L2845_i_ += G0233_ai_Graphic559_DirectionToStepEastCount[G0308_i_PartyDirection], L2846_i_ += G0234_ai_Graphic559_DirectionToStepNorthCount[G0308_i_PartyDirection];
                        if ((L2844_T_Thing = F0175_GROUP_GetThing(L2845_i_, L2846_i_)) == C0xFFFE_THING_ENDOFLIST) {
#ifdef MEDIA646_A31E_A35E_F31E
                                L2842_pc_CreatureName = "NO CREATURE";
#endif
#ifdef MEDIA689_F31J_X31J_P31J
                                L2842_pc_CreatureName = "Σέ½ΐ°Ν\n±±Ι\n’Θ’";
#endif
#ifdef MEDIA658_A31M_A33M_A35M
                                L2842_pc_CreatureName = F0758_TranslateLanguage(C107_NO_CREATURE);
#endif
                        } else {
#ifdef MEDIA647_A31E_A35E_F31E_F31J_X31J_P31J
                                L2842_pc_CreatureName = G2214_apc_CreatureNames[(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(L2844_T_Thing)]).Type];
#endif
#ifdef MEDIA658_A31M_A33M_A35M
                                L2842_pc_CreatureName = F0758_TranslateLanguage(G3047_ai_CreatureNames[(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(L2844_T_Thing)]).Type]);
#endif
                        }
                }
                F0817_SubstituteFirstCharactersByString(L2841_pc_ScrollText, L2843_i_CreatureNameScrollTextLength, L2842_pc_CreatureName);
        }
}
#endif

STATICFUNCTION void F0341_INVENTORY_DrawPanel_Scroll(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0705_ps_Scroll)
#endif
SCROLL* P0705_ps_Scroll FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        char L6190_ac_Unreferenced[4];
        REGISTER char* L1054_pc_Character;
#endif
        REGISTER char* L1055_pc_Character;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER char* L1054_pc_Character;
#endif
        REGISTER int16_t L1053_i_Multiple;
#define AL1053_B_MultipleLines L1053_i_Multiple
#define AL1053_i_LineCount     L1053_i_Multiple
#define AL1053_i_Y             L1053_i_Multiple
#define AL1053_i_Counter       L1053_i_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        char L1056_ac_StringFirstLine[256];
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2847_i_X;
        int16_t L2848_i_Y;
        char L1056_ac_StringFirstLine[200];
#endif
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L2849_ps_Champion;
        REGISTER int16_t L2850_i_;
        REGISTER int16_t L2851_i_;
        REGISTER int16_t L2852_i_;
        REGISTER int16_t L2853_i_;
        int16_t L2854_i_;
        int16_t L2855_i_;
        int16_t L2856_i_;
        char L2857_i_[2];
        char L2858_i_[4];
        int16_t L2859_i_;
        int16_t L2860_i_;
#endif


#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        F0168_DUNGEON_DecodeText(M774_CAST_PUC(L1056_ac_StringFirstLine), P0705_ps_Scroll->TextStringThingIndex, C2_TEXT_TYPE_SCROLL | MASK0x8000_DECODE_EVEN_IF_INVISIBLE);
        L1055_pc_Character = L1056_ac_StringFirstLine;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0424_i_PanelContent = M643_PANEL_SCROLL;
        F0168_DUNGEON_DecodeText(M774_CAST_PUC(L1055_pc_Character = L1056_ac_StringFirstLine), P0705_ps_Scroll->TextStringThingIndex, C2_TEXT_TYPE_SCROLL | MASK0x8000_DECODE_EVEN_IF_INVISIBLE);
#endif
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0805_CreatureNameScroll(L1055_pc_Character);
#endif
        while (*L1055_pc_Character && (*L1055_pc_Character != '\n')) { /* New line */ /* BUG0_88 Text is displayed outside of the scroll bitmap. The engine does not limit the length of each line nor the number of lines. This is not an issue in the original dungeons where no scroll contains any line longer than 15 characters or more than 8 lines */
                L1055_pc_Character++;
        }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (*L1055_pc_Character == '\0') {
                AL1053_B_MultipleLines = C0_FALSE;
        } else {
                AL1053_B_MultipleLines = C1_TRUE;
        }
#endif
        *L1055_pc_Character = '\0'; /* Mark the end of the first line */
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (M546_STRCMP(L1056_ac_StringFirstLine, G2212_apc_MagicMapScrollText) == 0) {
                G0424_i_PanelContent = C10_PANEL_MAGIC_MAP_SCROLL;
                F0658_BlitBitmapIndexToZoneIndexWithTransparency(C024_GRAPHIC_PANEL_MAGIC_MAP, C101_ZONE_PANEL, C08_COLOR_RED);
                L2849_ps_Champion = &M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)];
                L2858_i_[0] = L2849_ps_Champion->MagicMapFighterSpellCount;
                L2858_i_[1] = L2849_ps_Champion->MagicMapNinjaSpellCount;
                L2858_i_[2] = L2849_ps_Champion->MagicMapWizardSpellCount;
                L2858_i_[3] = L2849_ps_Champion->MagicMapPriestSpellDirectionOrdinal;
                L2857_i_[1] = 0;
                for (L2850_i_ = 0; L2850_i_ < 4; L2850_i_++) {
                        L2857_i_[0] = L2850_i_ + 114; /* Character index of symbol in font */
                        F0649_PrintCenteredTextToViewportZone(L2850_i_ + C615_ZONE_MAGIC_MAP_CORNER_SYMBOL, L2858_i_[L2850_i_] ? C08_COLOR_RED : C00_COLOR_BLACK, C15_COLOR_WHITE, L2857_i_);
                }
                if (L2849_ps_Champion->MagicMapPriestSpellDirectionOrdinal) {
                        F0173_DUNGEON_SetCurrentMap(L2849_ps_Champion->MagicMapLocationPriestSpell.MapIndex);
                        L2859_i_ = L2849_ps_Champion->MagicMapLocationPriestSpell.MapX;
                        L2860_i_ = L2849_ps_Champion->MagicMapLocationPriestSpell.MapY;
                        L2854_i_ = M001_ORDINAL_TO_INDEX(L2849_ps_Champion->MagicMapPriestSpellDirectionOrdinal);
                } else {
                        L2859_i_ = G0306_i_PartyMapX;
                        L2860_i_ = G0307_i_PartyMapY;
                        L2854_i_ = G0308_i_PartyDirection;
                }
                L2855_i_ = -1;
                F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement(L2854_i_, 3, -3, &L2859_i_, &L2860_i_);
                F0636_GetZoneTopLeftCoordinatesWith1PixelMargin(C614_ZONE_MAGIC_MAP_ON_SCROLL, &L2847_i_X, &L2848_i_Y);
                for (AL1053_i_Counter = 0; AL1053_i_Counter < 7; AL1053_i_Counter++) {
                        L2853_i_ = L2847_i_X;
                        L2851_i_ = L2859_i_;
                        L2852_i_ = L2860_i_;
                        for (L2850_i_ = 0; L2850_i_ < 7; L2850_i_++) {
                                if ((G0272_i_CurrentMapIndex == G0309_i_PartyMapIndex) && (L2851_i_ == G0306_i_PartyMapX) && (L2852_i_ == G0307_i_PartyMapY)) {
                                        L2855_i_ = L2853_i_;
                                        L2856_i_ = L2848_i_Y;
                                } else {
                                        F0804_DrawMagicMap(L2851_i_, L2852_i_, L2854_i_, L2853_i_, L2848_i_Y);
                                }
                                L2853_i_ += G2343_i_MagicMapIconWidth + G2345_;
                                L2851_i_ += G0233_ai_Graphic559_DirectionToStepEastCount[(L2854_i_ + 1) & 3];
                                L2852_i_ += G0234_ai_Graphic559_DirectionToStepNorthCount[(L2854_i_ + 1) & 3];
                        }
                        L2859_i_ += G0233_ai_Graphic559_DirectionToStepEastCount[(L2854_i_ + 2) & 3];
                        L2860_i_ += G0234_ai_Graphic559_DirectionToStepNorthCount[(L2854_i_ + 2) & 3];
                        L2848_i_Y += G2344_i_MagicMapIconHeight + G2346_;
                }
                if (L2855_i_ >= 0) {
                        F0804_DrawMagicMap(G0306_i_PartyMapX, G0307_i_PartyMapY, L2854_i_, L2855_i_, L2856_i_);
                }
                if (L2849_ps_Champion->MagicMapPriestSpellDirectionOrdinal) {
                        F0173_DUNGEON_SetCurrentMap(G0309_i_PartyMapIndex);
                        return;
                }
        } else {
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C023_GRAPHIC_PANEL_OPEN_SCROLL), G0032_ai_Graphic562_Box_Panel, C072_BYTE_WIDTH, C08_COLOR_RED, 73);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0658_BlitBitmapIndexToZoneIndexWithTransparency(C023_GRAPHIC_PANEL_OPEN_SCROLL, C101_ZONE_PANEL, C08_COLOR_RED);
                F0636_GetZoneTopLeftCoordinatesWith1PixelMargin(C560_ZONE_SCROLL_TEXT, &L2847_i_X, &L2848_i_Y);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (AL1053_B_MultipleLines == C0_FALSE) {
#endif
                        AL1053_i_LineCount = 1;
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                } else {
#endif
                        L1055_pc_Character++;
                        L1054_pc_Character = (char*)L1055_pc_Character; /* First character of second line */
                        while (*L1054_pc_Character) { /* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll (with no line feed character) then L1054_pc_Character points to undefined data. This may result in a graphical glitch and also corrupt other memory. This is not an issue in the original dungeons where all scrolls contain at least one line feed character */
                                if (*L1054_pc_Character == '\n') { /* New line */
                                        AL1053_i_LineCount++;
                                }
                                L1054_pc_Character++;
                        }
                        if (*(L1054_pc_Character - 1) != '\n') { /* New line */
                                AL1053_i_LineCount++; /* BUG0_88 Text is displayed outside of the scroll bitmap. The engine does not limit the length of each line nor the number of lines. This is not an issue in the original dungeons where no scroll contains any line longer than 15 characters or more than 8 lines */
                        } else {
                                if (*(L1054_pc_Character - 2) == '\n') { /* New line */
                                        AL1053_i_LineCount--;
                                }
                        }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                }
#endif
#ifdef MEDIA579_X30J_P20JA_P20JB
                L2848_i_Y -= (((G2342_C17_JapaneseTextLineHeight * AL1053_i_LineCount) - G2341_) >> 1) - G2338_i_JapaneseCharacterMaximumHeight;
#endif
#ifdef MEDIA689_F31J_X31J_P31J
                L2848_i_Y -= (((G2342_C17_JapaneseTextLineHeight * AL1053_i_LineCount) - G2341_ - 1) >> 1) - G2338_i_JapaneseCharacterMaximumHeight;
#endif
#ifdef MEDIA487_F20E
                L2848_i_Y -= ((G2088_C7_TextLineHeight * AL1053_i_LineCount) >> 1) - (G2083_C6_ >> 1);
#endif
#ifdef MEDIA564_F20J
                L2848_i_Y -= ((G2342_C17_JapaneseTextLineHeight * AL1053_i_LineCount) >> 1) - (G2338_i_JapaneseCharacterMaximumHeight >> 1);
#endif
#ifdef MEDIA718_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                L2848_i_Y -= (((G2088_C7_TextLineHeight * AL1053_i_LineCount) - G2086_C1_ - 1) >> 1) - G2083_C6_;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                AL1053_i_Y = 92 - ((7 * AL1053_i_LineCount) / 2); /* Center text vertically */
                F0340_INVENTORY_DrawPanel_ScrollTextLine(AL1053_i_Y, L1056_ac_StringFirstLine);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0340_INVENTORY_DrawPanel_ScrollTextLine(L2847_i_X, L2848_i_Y, L1056_ac_StringFirstLine);
#endif
                L1054_pc_Character = L1055_pc_Character;
                while (*L1054_pc_Character) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        AL1053_i_Y += 7;
#endif
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
                        L2848_i_Y += G2342_C17_JapaneseTextLineHeight;
#endif
#ifdef MEDIA562_F20E_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                        L2848_i_Y += G2088_C7_TextLineHeight;
#endif
                        while (*L1055_pc_Character && (*L1055_pc_Character != '\n')) { /* New line */
                                L1055_pc_Character++;
                        }
                        if (!(*L1055_pc_Character)) {
                                L1055_pc_Character[1] = '\0';
                        }
                        *L1055_pc_Character++ = '\0';
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        F0340_INVENTORY_DrawPanel_ScrollTextLine(AL1053_i_Y, L1054_pc_Character);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0340_INVENTORY_DrawPanel_ScrollTextLine(L2847_i_X, L2848_i_Y, L1054_pc_Character);
#endif
                        L1054_pc_Character = L1055_pc_Character;
                }
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
#endif
}

#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
#include "CHEST.C"
#endif

void F0342_INVENTORY_DrawPanel_Object(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0706_T_Thing, P0707_B_PressingEye)
#endif
THING   P0706_T_Thing       SEPARATOR
BOOLEAN P0707_B_PressingEye FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER char* L1061_pc_DescriptionString;
#endif
        REGISTER JUNK* L1062_ps_Junk;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER char* L1061_pc_DescriptionString;
#endif
#ifdef MEDIA674_F31E_F31J_X31J_P31J
        REGISTER char* L2861_pc_;
#endif
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        REGISTER unsigned int16_t L1057_ui_Weight;
#endif
        REGISTER unsigned int16_t L1058_ui_IconIndex;
        REGISTER int16_t L1059_i_PotentialAttributesMask;
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        REGISTER unsigned int16_t L1057_ui_Weight;
#endif
        REGISTER int16_t L1060_i_ActualAttributesMask;
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        char L1063_ac_Unreferenced[48]; /* BUG0_00 Useless code */
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        char* L1064_apc_AttributeStrings[4];
        char* L1065_pc_RightParenthesis = ")";
        char* L1066_pc_LeftParenthesis = "(";
#endif
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        unsigned int16_t L1067_ui_ThingType;
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        REGISTER unsigned int16_t L1067_ui_ThingType;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        char* L1064_apc_AttributeStrings[16];
#endif
        char L1068_ac_String[40];
#ifdef MEDIA196_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
        static char* G0430_apc_DirectionNames[4] = { "NORTH", "EAST", "SOUTH", "WEST" };
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
        static char* G0430_apc_DirectionNames[4] = { "NORDEN", "OSTEN", "SUEDEN", "WESTEN" };
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
        static char* G0430_apc_DirectionNames[4] = { "AU NORD", "A L'EST", "AU SUD", "A L'OUEST" };
#endif
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
        static char* G0430_apc_DirectionNames[4] = { "k", "", "μ", "Ό" };
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        static int16_t G2013_ai_DirectionNames[4] = { 22, 24, 23, 25 }; /* Text indices */
#endif


#ifdef MEDIA689_F31J_X31J_P31J
        L2861_pc_ = NULL;
#endif
#ifdef MEDIA335_S20E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA /* CHANGE7_27_FIX The chest is closed and reopened in F0333_INVENTORY_OpenAndDrawChest only if pressing the eye or mouth and no more when placing an object that has a modifier. CHANGE8_09_FIX Make sure the chest is always closed. This reintroduces BUG0_48 in C21E */
        if (G0331_B_PressingEye || G0333_B_PressingMouth) {
#endif
                F0334_INVENTORY_CloseChest(); /* BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion */
#ifdef MEDIA335_S20E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA /* CHANGE7_27_FIX CHANGE8_09_FIX */
        }
#endif
        L1062_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(P0706_T_Thing);
        F0335_INVENTORY_DrawPanel_ObjectDescriptionString("\f"); /* Form Feed */
        L1067_ui_ThingType = M012_TYPE(P0706_T_Thing);
        if (L1067_ui_ThingType == C07_THING_TYPE_SCROLL) {
                F0341_INVENTORY_DrawPanel_Scroll(M777_CAST_SCROLL(L1062_ps_Junk));
        } else {
                if (L1067_ui_ThingType == C09_THING_TYPE_CONTAINER) {
                        F0333_INVENTORY_OpenAndDrawChest(P0706_T_Thing, M778_CAST_CONTAINER(L1062_ps_Junk), P0707_B_PressingEye);
                } else {
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G0424_i_PanelContent = C03_PANEL_OBJECT_DESCRIPTION;
#endif
                        L1058_ui_IconIndex = F0033_OBJECT_GetIconIndex(P0706_T_Thing);
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C020_GRAPHIC_PANEL_EMPTY), G0032_ai_Graphic562_Box_Panel, C072_BYTE_WIDTH, C08_COLOR_RED, 73);
                        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE), G0034_ai_Graphic562_Box_ObjectDescriptionCircle, C016_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 27);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C020_GRAPHIC_PANEL_EMPTY, C101_ZONE_PANEL, C08_COLOR_RED);
                        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE, C504_ZONE_OBJECT_DESCRIPTION_CIRCLE, C12_COLOR_DARKEST_GRAY);
#endif
                        if (L1058_ui_IconIndex == C147_ICON_JUNK_CHAMPION_BONES) {
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
                                L1068_ac_String[0] = 0x1B;
                                M547_STRCPY(&L1068_ac_String[1], M516_CHAMPIONS[L1062_ps_Junk->ChargeCount].Name);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                if (G2000_Language == C1_FRENCH) {
                                        M547_STRCPY(L1068_ac_String, G0352_apc_ObjectNames[L1058_ui_IconIndex]);
                                        M545_STRCAT(L1068_ac_String, " ");
                                        M545_STRCAT(L1068_ac_String, M516_CHAMPIONS[L1062_ps_Junk->ChargeCount].Name);
                                } else {
#endif
#ifdef MEDIA189_S10EA_S10EB_S11E_S12E_S12G_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20G_A21E_A22E_A22G_F20E_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E /* CHANGE5_00_LOCALIZATION Translation to French language */
                                        M547_STRCPY(L1068_ac_String, M516_CHAMPIONS[L1062_ps_Junk->ChargeCount].Name);
                                        M545_STRCAT(L1068_ac_String, " ");
                                        M545_STRCAT(L1068_ac_String, M772_CAST_PC(G0352_apc_ObjectNames[L1058_ui_IconIndex]));
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                }
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                strcat(L1068_ac_String, G0352_apc_ObjectNames[L1058_ui_IconIndex]); /* BUG5_00 When looking at a champion's dead bones by pressing the eye, the name in the panel only contains the champion name and the object name is missing. This call to strcat and the call to strcpy below were swapped while translating the game to French in order to change the order of words in the final string. However, only the strings should have been swapped and not the function calls */
                                strcat(L1068_ac_String, " ");
                                strcpy(L1068_ac_String, M516_CHAMPIONS[L1062_ps_Junk->ChargeCount].Name);
#endif
                                L1061_pc_DescriptionString = L1068_ac_String;
                        } else {
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
                                L1061_pc_DescriptionString = M772_CAST_PC(G0352_apc_ObjectNames[L1058_ui_IconIndex]);
#endif
#ifdef MEDIA689_F31J_X31J_P31J
                                if (G2230_) {
                                        L2861_pc_ = L1061_pc_DescriptionString + M544_STRLEN(L1061_pc_DescriptionString) + 1;
                                }
#endif
#ifdef MEDIA061_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                                if ((L1067_ui_ThingType == C08_THING_TYPE_POTION) && (L1058_ui_IconIndex != C163_ICON_POTION_WATER_FLASK) && (F0303_CHAMPION_GetSkillLevel(M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal), C02_SKILL_PRIEST) > 1)) { /* BUG0_49 When examining an 'Empty Flask' the description string shows an undesired symbol. The code contains an exception not to draw the power for 'Water Flask' potions C195_ICON_POTION_EMPTY_FLASK but a similar exception is missing for 'Empty Flask' potions. These are processed like all other potions so that the power symbol is drawn: '_' for an 'Empty Flask' with Power / 40 = 0, or the power symbol of the last potion contained in the Flask: after drinking a potion, the potion type is set to Empty Flask but the potion power is not reset in F0349_INVENTORY_ProcessCommand70_ClickOnMouth */
                                        L1068_ac_String[0] = '_' + ((POTION*)L1062_ps_Junk)->Power / 40; /* Character '_' precedes the first Symbol in the font. Potions are always created with a minimum power of 40 in F0412_MENUS_GetChampionSpellCastResult */
                                        L1068_ac_String[1] = ' ';
                                        L1068_ac_String[2] = '\0';
                                        M545_STRCAT(L1068_ac_String, M772_CAST_PC(G0352_apc_ObjectNames[L1058_ui_IconIndex]));
                                        L1061_pc_DescriptionString = L1068_ac_String;
                                } else {
                                        L1061_pc_DescriptionString = (char*)G0352_apc_ObjectNames[L1058_ui_IconIndex];
                                }
#endif
                        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        F0052_TEXT_PrintToViewport(134, 68, C13_COLOR_LIGHTEST_GRAY, L1061_pc_DescriptionString);
                        F0332_INVENTORY_DrawIconToViewport(L1058_ui_IconIndex, 111, 59);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0648_PrintTextInViewportZone(C506_ZONE_OBJECT_DESCRIPTION, C13_COLOR_LIGHTEST_GRAY, L1061_pc_DescriptionString);
                        F0332_INVENTORY_DrawIconToViewport(L1058_ui_IconIndex, C505_ZONE_OBJECT_DESCRIPTION_ICON);
#endif
#ifdef MEDIA689_F31J_X31J_P31J
                        if (L2861_pc_ == NULL) {
                                G0422_i_ObjectDescriptionTextY = 98;
                        } else {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                G0422_i_ObjectDescriptionTextY = 87;
#endif
#ifdef MEDIA689_F31J_X31J_P31J
                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L2861_pc_);
                        }
#endif
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                        L1064_apc_AttributeStrings[0] = "CONSUMABLE";
                        L1064_apc_AttributeStrings[1] = "POISONED";
                        L1064_apc_AttributeStrings[2] = "BROKEN";
                        L1064_apc_AttributeStrings[3] = "CURSED";
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                        L1064_apc_AttributeStrings[0] = "ESSBAR";
                        L1064_apc_AttributeStrings[1] = "VERGIFTET";
                        L1064_apc_AttributeStrings[2] = "DEFEKT";
                        L1064_apc_AttributeStrings[3] = "VERFLUCHT";
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                        L1064_apc_AttributeStrings[0] = "COMESTIBLE";
                        L1064_apc_AttributeStrings[1] = "EMPOISONNE";
                        L1064_apc_AttributeStrings[2] = "BRISE";
                        L1064_apc_AttributeStrings[3] = "MAUDIT";
#endif
#ifdef MEDIA585_X30J_P20JA_P20JB_F31J_X31J_P31J
                        L1064_apc_AttributeStrings[0] = "Hp";
                        L1064_apc_AttributeStrings[1] = "LΕ";
                        L1064_apc_AttributeStrings[2] = "jΉ";
                        L1064_apc_AttributeStrings[3] = "τνκ½";
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                        L1064_apc_AttributeStrings[0] = F0758_TranslateLanguage(C26_CONSUMABLE);
                        L1064_apc_AttributeStrings[1] = F0758_TranslateLanguage(C27_POISONED);
                        L1064_apc_AttributeStrings[2] = F0758_TranslateLanguage(C28_BROKEN);
                        L1064_apc_AttributeStrings[3] = F0758_TranslateLanguage(C29_CURSED);
#endif
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
                        G0422_i_ObjectDescriptionTextY = 87;
#endif
#ifdef MEDIA579_X30J_P20JA_P20JB
                        G0422_i_ObjectDescriptionTextY = 98;
#endif
                        switch (L1067_ui_ThingType) {
                                case C05_THING_TYPE_WEAPON:
                                        L1059_i_PotentialAttributesMask = MASK0x0008_DESCRIPTION_CURSED | MASK0x0002_DESCRIPTION_POISONED | MASK0x0004_DESCRIPTION_BROKEN;
                                        L1060_i_ActualAttributesMask = (((WEAPON*)L1062_ps_Junk)->Cursed << 3) | (((WEAPON*)L1062_ps_Junk)->Poisoned << 1) | (((WEAPON*)L1062_ps_Junk)->Broken << 2);
                                        if ((L1058_ui_IconIndex >= C004_ICON_WEAPON_TORCH_UNLIT) && (L1058_ui_IconIndex <= C007_ICON_WEAPON_TORCH_LIT) && (((WEAPON*)L1062_ps_Junk)->ChargeCount == 0)) {
#ifdef MEDIA585_X30J_P20JA_P20JB_F31J_X31J_P31J
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString("R¦s«½");
#endif
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString("(BURNT OUT)");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString("(AUSGEBRANNT)");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString("(CONSUME)");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString(F0758_TranslateLanguage(C31_BURNT_OUT));
#endif
                                        }
                                        break;
                                case C06_THING_TYPE_ARMOUR:
                                        L1059_i_PotentialAttributesMask = MASK0x0008_DESCRIPTION_CURSED | MASK0x0004_DESCRIPTION_BROKEN;
                                        L1060_i_ActualAttributesMask = (((ARMOUR*)L1062_ps_Junk)->Cursed << 3) | (((ARMOUR*)L1062_ps_Junk)->Broken << 2);
                                        break;
                                case C08_THING_TYPE_POTION:
                                        L1059_i_PotentialAttributesMask = MASK0x0001_DESCRIPTION_CONSUMABLE;
#ifdef PC_FIX_CODE_SIZE
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
#endif
                                        L1060_i_ActualAttributesMask = G0237_as_Graphic559_ObjectInfo[C002_OBJECT_INFO_INDEX_FIRST_POTION + ((POTION*)L1062_ps_Junk)->Type].AllowedSlots;
                                        break;
                                case C10_THING_TYPE_JUNK:
#ifdef MEDIA594_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_X31J_P31J
                                        if ((L1058_ui_IconIndex >= C000_ICON_JUNK_COMPASS_NORTH) && (L1058_ui_IconIndex <= C003_ICON_JUNK_COMPASS_WEST)) {
#endif
#ifdef MEDIA686_F31J
                                        if (L1058_ui_IconIndex <= C003_ICON_JUNK_COMPASS_WEST) {
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                L1059_i_PotentialAttributesMask = 0;
#endif
#ifdef MEDIA585_X30J_P20JA_P20JB_F31J_X31J_P31J
                                                M547_STRCPY(L1068_ac_String, "");
#endif
#ifdef MEDIA703_I34E_A31E_A35E_F31E
                                                M547_STRCPY(L1068_ac_String, "PARTY FACING ");
#endif
#ifdef MEDIA588_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J
                                                M545_STRCAT(L1068_ac_String, G0430_apc_DirectionNames[L1058_ui_IconIndex]);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                M547_STRCPY(L1068_ac_String, F0758_TranslateLanguage(C21_PARTY_FACING));
                                                M545_STRCAT(L1068_ac_String, F0758_TranslateLanguage(G2013_ai_DirectionNames[L1058_ui_IconIndex]));
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L1068_ac_String);
                                        } else {
#endif
#ifdef MEDIA058_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
/* BUGX_XX ? CSB FM-Towns does not display the state of Waterskin (Full / empty) */
                                                if ((L1058_ui_IconIndex >= C008_ICON_JUNK_WATER) && (L1058_ui_IconIndex <= C009_ICON_JUNK_WATERSKIN)) {
                                                        L1059_i_PotentialAttributesMask = 0;
                                                        switch (L1062_ps_Junk->ChargeCount) {
                                                                case 0:
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(EMPTY)";
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(LEER)";
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                                        L1061_pc_DescriptionString = "(VIDE)";
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                                        L1061_pc_DescriptionString = F0758_TranslateLanguage(C32_EMPTY);
#endif
                                                                        break;
                                                                case 1:
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(ALMOST EMPTY)";
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(FAST LEER)";
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                                        L1061_pc_DescriptionString = "(PRESQUE VIDE)";
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                                        L1061_pc_DescriptionString = F0758_TranslateLanguage(C33_ALMOST_EMPTY);
#endif
                                                                        break;
                                                                case 2:
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(ALMOST FULL)";
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(FAST VOLL)";
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                                        L1061_pc_DescriptionString = "(PRESQUE PLEINE)";
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                                        L1061_pc_DescriptionString = F0758_TranslateLanguage(C34_ALMOST_FULL);
#endif
                                                                        break;
                                                                case 3:
#ifdef MEDIA194_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(FULL)";
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                        L1061_pc_DescriptionString = "(VOLL)";
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                                        L1061_pc_DescriptionString = "(PLEINE)";
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                                                                        L1061_pc_DescriptionString = F0758_TranslateLanguage(C35_FULL);
#endif
                                                        }
#ifdef PC_FIX_CODE_SIZE
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
        L1058_ui_IconIndex++;
#endif
                                                        F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L1061_pc_DescriptionString);
                                                } else {
#endif
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
                                                        if ((L1058_ui_IconIndex >= C000_ICON_JUNK_COMPASS_NORTH) && (L1058_ui_IconIndex <= C003_ICON_JUNK_COMPASS_WEST)) {
                                                                L1059_i_PotentialAttributesMask = 0;
#ifdef MEDIA192_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                M547_STRCPY(L1068_ac_String, "PARTY FACING ");
#endif
#ifdef MEDIA564_F20J
                                                                M547_STRCPY(L1068_ac_String, "");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                                                                M547_STRCPY(L1068_ac_String, "GRUPPE BLICKT NACH ");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                                                                M547_STRCPY(L1068_ac_String, "GROUPE FACE ");
#endif
                                                                M545_STRCAT(L1068_ac_String, G0430_apc_DirectionNames[L1058_ui_IconIndex - 0]);
                                                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L1068_ac_String);
                                                        } else {
#endif
                                                                L1059_i_PotentialAttributesMask = MASK0x0001_DESCRIPTION_CONSUMABLE;
                                                                L1060_i_ActualAttributesMask = G0237_as_Graphic559_ObjectInfo[C127_OBJECT_INFO_INDEX_FIRST_JUNK + L1062_ps_Junk->Type].AllowedSlots;
#ifdef MEDIA058_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E
                                                        }
#endif
                                                }
                                        break;
                        }
                        if (L1059_i_PotentialAttributesMask) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                F0336_INVENTORY_DrawPanel_BuildObjectAttributesString(L1059_i_PotentialAttributesMask, L1060_i_ActualAttributesMask, L1064_apc_AttributeStrings, L1068_ac_String, L1066_pc_LeftParenthesis, L1065_pc_RightParenthesis);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                F0336_INVENTORY_DrawPanel_BuildObjectAttributesString(L1059_i_PotentialAttributesMask, L1060_i_ActualAttributesMask, L1064_apc_AttributeStrings, L1068_ac_String, "(", ")");
#endif
                                F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L1068_ac_String);
                        }
#ifdef MEDIA196_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_I34E_A31E_A35E_F31E /* CHANGE4_00_LOCALIZATION Translation to German language */
                        M547_STRCPY(L1068_ac_String, "WEIGHS ");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                        strcpy(L1068_ac_String, "WIEGT ");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                        strcpy(L1068_ac_String, "PESE ");
#endif
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
                        M547_STRCPY(L1068_ac_String, " ");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                        M547_STRCPY(L1068_ac_String, F0758_TranslateLanguage(C37_WEIGHS));
#endif
                        L1057_ui_Weight = F0140_DUNGEON_GetObjectWeight(P0706_T_Thing);
                        M545_STRCAT(L1068_ac_String, F0288_CHAMPION_GetStringFromInteger(L1057_ui_Weight / 10, C0_FALSE, 3));
#ifdef MEDIA193_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J /* CHANGE4_00_LOCALIZATION Translation to German language */
                        M545_STRCAT(L1068_ac_String, ".");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                        strcat(L1068_ac_String, ",");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                        strcat(L1068_ac_String, "KG,");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                        M545_STRCAT(L1068_ac_String, F0758_TranslateLanguage(C38_CHAMPION_LOAD_DECIMAL_SEPARATOR));
#endif
                        L1057_ui_Weight -= (L1057_ui_Weight / 10) * 10;
                        M545_STRCAT(L1068_ac_String, F0288_CHAMPION_GetStringFromInteger(L1057_ui_Weight, C0_FALSE, 1));
#ifdef MEDIA188_S10EA_S10EB_S11E_S12E_S12G_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J /* CHANGE5_00_LOCALIZATION Translation to French language */
                        M545_STRCAT(L1068_ac_String, " KG.");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                        strcat(L1068_ac_String, ".");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                        M545_STRCAT(L1068_ac_String, F0758_TranslateLanguage(C39_CHAMPION_LOAD_KILOGRAM));
#endif
                        F0335_INVENTORY_DrawPanel_ObjectDescriptionString(L1068_ac_String);
                }
        }
        F0339_INVENTORY_DrawPanel_ArrowOrEye(P0707_B_PressingEye);
}

#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
void F0343_INVENTORY_DrawPanel_HorizontalBar(
P0708_i_X, P0709_i_Y, P0710_i_PixelWidth, P0711_i_Color)
int16_t P0708_i_X          SEPARATOR
int16_t P0709_i_Y          SEPARATOR
int16_t P0710_i_PixelWidth SEPARATOR
int16_t P0711_i_Color      FINAL_SEPARATOR
{
        int16_t L1069_ai_Box[4];


        M769_BOX_RIGHT(L1069_ai_Box) = (M768_BOX_LEFT(L1069_ai_Box) = P0708_i_X) + P0710_i_PixelWidth;
        M771_BOX_BOTTOM(L1069_ai_Box) = (M770_BOX_TOP(L1069_ai_Box) = P0709_i_Y) + 6;
        G0578_B_UseByteBoxCoordinates = C0_FALSE;
        M525_F0135_VIDEO_FillBox(G0296_puc_Bitmap_Viewport, L1069_ai_Box, P0711_i_Color, C112_BYTE_WIDTH_VIEWPORT, C136_HEIGHT_VIEWPORT);
}
#endif

STATICFUNCTION void F0344_INVENTORY_DrawPanel_FoodOrWaterBar(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0712_i_Amount, P0713_i_Y, P0714_i_Color)
#endif
REGISTER int16_t P0712_i_Amount    SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
int16_t          P0713_i_Y         SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t          P2295_i_ZoneIndex SEPARATOR
#endif
int16_t          P0714_i_Color     FINAL_SEPARATOR
{
        REGISTER int16_t L1070_i_Color;
#ifdef MEDIA085_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A36M_A31E_A31M_A33M_A35E_A35M
        REGISTER int16_t L1071_i_PixelWidth;
#endif
#ifdef MEDIA519_F20E_F20J_X30J_P20JA_P20JB_X31J
        REGISTER int16_t L2862_i_Counter;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2863_ai_XYZ[4];
        int16_t L2864_ai_XYZ[4];
#endif


        if (P0712_i_Amount < -512) {
                L1070_i_Color = C08_COLOR_RED;
        } else {
                if (P0712_i_Amount < 0) {
                        L1070_i_Color = C11_COLOR_YELLOW;
                } else {
                        L1070_i_Color = P0714_i_Color;
                }
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L1071_i_PixelWidth = P0712_i_Amount + 1024;
        if (L1071_i_PixelWidth == 3072) {
                L1071_i_PixelWidth = 3071;
        }
        L1071_i_PixelWidth >>= 5;
        F0343_INVENTORY_DrawPanel_HorizontalBar(115, P0713_i_Y + 2, L1071_i_PixelWidth, C00_COLOR_BLACK);
        F0343_INVENTORY_DrawPanel_HorizontalBar(113, P0713_i_Y, L1071_i_PixelWidth, L1070_i_Color);
#endif
#ifdef MEDIA535_F20E_F20J_X30J_P20JA_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        P0712_i_Amount += 1024;
#endif
#ifdef MEDIA709_I34E_I34M_P31J
        P0712_i_Amount -= -1024;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (!F0637_GetProportionalZone(P2295_i_ZoneIndex, L2863_ai_XYZ, ((int)P0712_i_Amount * 10000L) / (unsigned int16_t)3072L, 10000))
                return;
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        for (L2862_i_Counter = 0; L2862_i_Counter <= 3; L2862_i_Counter++) {
                L2864_ai_XYZ[L2862_i_Counter] = L2863_ai_XYZ[L2862_i_Counter] + G2097_FoodOrWaterBarShadowOffset;
        }
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0007_MAIN_CopyBytes((char*)L2863_ai_XYZ, (char*)L2864_ai_XYZ, 8L);
        L2864_ai_XYZ[0] += G2097_FoodOrWaterBarShadowOffset;
        L2864_ai_XYZ[1] += G2097_FoodOrWaterBarShadowOffset;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        M525_F0135_VIDEO_FillBox(G0296_puc_Bitmap_Viewport, L2864_ai_XYZ, C00_COLOR_BLACK, G2073_C224_ViewportPixelWidth, G2074_C136_ViewportHeight);
        M525_F0135_VIDEO_FillBox(G0296_puc_Bitmap_Viewport, L2863_ai_XYZ, L1070_i_Color, G2073_C224_ViewportPixelWidth, G2074_C136_ViewportHeight);
#endif
}

void F0345_INVENTORY_DrawPanel_FoodWaterPoisoned(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER CHAMPION* L1074_ps_Champion;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L1072_i_Unreferenced; /* BUG0_00 Useless code */
        REGISTER int16_t L1073_i_Unreferenced; /* BUG0_00 Useless code */
#endif


#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0424_i_PanelContent = M565_PANEL_FOOD_WATER_POISONED;
#endif
        L1074_ps_Champion = &M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)];
        F0334_INVENTORY_CloseChest();
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C020_GRAPHIC_PANEL_EMPTY), G0032_ai_Graphic562_Box_Panel, C072_BYTE_WIDTH, C08_COLOR_RED, 73);
#endif
#ifdef MEDIA191_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E /* CHANGE4_00_LOCALIZATION Translation to German language */
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C030_GRAPHIC_FOOD_LABEL), G0035_ai_Graphic562_Box_Food, C024_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C031_GRAPHIC_WATER_LABEL), G0036_ai_Graphic562_Box_Water, C024_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C030_GRAPHIC_FOOD_LABEL), G0035_ai_Graphic562_Box_Food, C032_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C031_GRAPHIC_WATER_LABEL), G0036_ai_Graphic562_Box_Water, C032_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C030_GRAPHIC_FOOD_LABEL), G0035_ai_Graphic562_Box_Food, C048_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C031_GRAPHIC_WATER_LABEL), G0036_ai_Graphic562_Box_Water, C024_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 9);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C020_GRAPHIC_PANEL_EMPTY, C101_ZONE_PANEL, C08_COLOR_RED);
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C030_GRAPHIC_FOOD_LABEL, C500_ZONE_FOOD, C12_COLOR_DARKEST_GRAY);
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C031_GRAPHIC_WATER_LABEL, C501_ZONE_WATER, C12_COLOR_DARKEST_GRAY);
#endif
        if (L1074_ps_Champion->PoisonEventCount) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C032_GRAPHIC_POISONED_LABEL), G0037_ai_Graphic562_Box_Poisoned, C048_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 15);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0658_BlitBitmapIndexToZoneIndexWithTransparency(C032_GRAPHIC_POISONED_LABEL, C502_ZONE_POISONED, C12_COLOR_DARKEST_GRAY);
#endif
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0344_INVENTORY_DrawPanel_FoodOrWaterBar(L1074_ps_Champion->Food, 69, C05_COLOR_LIGHT_BROWN);
        F0344_INVENTORY_DrawPanel_FoodOrWaterBar(L1074_ps_Champion->Water, 92, C14_COLOR_BLUE);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0344_INVENTORY_DrawPanel_FoodOrWaterBar(L1074_ps_Champion->Food, C103_ZONE_FOOD_BAR, C05_COLOR_LIGHT_BROWN);
        F0344_INVENTORY_DrawPanel_FoodOrWaterBar(L1074_ps_Champion->Water, C104_ZONE_FOOD_WATER, C14_COLOR_BLUE);
#endif
}

STATICFUNCTION void F0346_INVENTORY_DrawPanel_ResurrectReincarnate(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        G0424_i_PanelContent = M568_PANEL_RESURRECT_REINCARNATE;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0424_i_PanelContent = G2008_i_PanelContent = M568_PANEL_RESURRECT_REINCARNATE;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE), G0032_ai_Graphic562_Box_Panel, C072_BYTE_WIDTH, C06_COLOR_DARK_GREEN, 73);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE, C101_ZONE_PANEL, C06_COLOR_DARK_GREEN);
#endif
}

void F0347_INVENTORY_DrawPanel(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER THING L1075_T_Thing;
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        REGISTER GENERIC* L1076_ps_Generic;
#endif


#ifdef MEDIA348_S21E_X30J_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE8_09_FIX Make sure the chest is always closed */
        F0334_INVENTORY_CloseChest();
#endif
        if (G0299_ui_CandidateChampionOrdinal) {
                F0346_INVENTORY_DrawPanel_ResurrectReincarnate();
                return;
        }
        L1075_T_Thing = M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)].Slots[C01_SLOT_ACTION_HAND];
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        L1076_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L1075_T_Thing);
#endif
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        G0424_i_PanelContent = M565_PANEL_FOOD_WATER_POISONED;
#endif
        switch (M012_TYPE(L1075_T_Thing)) {
                case C09_THING_TYPE_CONTAINER:
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
                        G0424_i_PanelContent = M569_PANEL_CHEST;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G2008_i_PanelContent = M569_PANEL_CHEST;
#endif
                        break;
                case C07_THING_TYPE_SCROLL:
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
                        G0424_i_PanelContent = M643_PANEL_SCROLL;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G2008_i_PanelContent = M643_PANEL_SCROLL;
#endif
                        break;
                default:
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G2008_i_PanelContent = M565_PANEL_FOOD_WATER_POISONED;
#endif
                        L1075_T_Thing = C0xFFFF_THING_NONE;
        }
        if (L1075_T_Thing == C0xFFFF_THING_NONE) {
                F0345_INVENTORY_DrawPanel_FoodWaterPoisoned();
        } else {
                F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);
        }
}

STATICFUNCTION void F0348_INVENTORY_AdjustStatisticCurrentValue(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0715_ps_Champion, P0716_ui_StatisticIndex, P0717_i_ValueDelta)
#endif
REGISTER CHAMPION*        P0715_ps_Champion       SEPARATOR
REGISTER unsigned int16_t P0716_ui_StatisticIndex SEPARATOR
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_12_OPTIMIZATION Variable definition changed */
int16_t                   P0717_i_ValueDelta      FINAL_SEPARATOR
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_12_OPTIMIZATION Variable definition changed */
REGISTER int16_t          P0717_i_ValueDelta      FINAL_SEPARATOR
#endif
{
        REGISTER int16_t L1077_i_Multiple;
#define AL1077_i_CurrentValue L1077_i_Multiple
#define AL1077_i_Delta        L1077_i_Multiple


        if (P0717_i_ValueDelta >= 0) {
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_14_IMPROVEMENT Halve delta if current value is above 120 */
                if ((AL1077_i_CurrentValue = P0715_ps_Champion->Statistics[P0716_ui_StatisticIndex][C1_CURRENT]) > 120) {
                        P0717_i_ValueDelta >>= 1;
#ifdef MEDIA222_S11E /* CHANGE3_13_IMPROVEMENT Halve again delta if current value is above 180 */
                        if (AL1077_i_CurrentValue > 180) {
#endif
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_13_IMPROVEMENT Halve again delta if current value is above 150 (maximum value is now 170 so the 180 threshold is too high) */
                        if (AL1077_i_CurrentValue > 150) {
#endif
                                P0717_i_ValueDelta >>= 1;
                        }
                        P0717_i_ValueDelta++;
                }
#endif
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_14_IMPROVEMENT Maximum value is 255 */
                AL1077_i_Delta = F0024_MAIN_GetMinimumValue(P0717_i_ValueDelta, 255 - P0715_ps_Champion->Statistics[P0716_ui_StatisticIndex][C1_CURRENT]);
#endif
#ifdef MEDIA222_S11E /* CHANGE2_14_IMPROVEMENT Maximum value is 250 */
                AL1077_i_Delta = F0024_MAIN_GetMinimumValue(P0717_i_ValueDelta, 250 - AL1077_i_CurrentValue);
#endif
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_13_IMPROVEMENT Maximum value is 170 */
                AL1077_i_Delta = F0024_MAIN_GetMinimumValue(P0717_i_ValueDelta, 170 - AL1077_i_CurrentValue);
#endif
        } else { /* BUG0_00 Useless code. The function is always called with P0717_i_ValueDelta having a positive value */
                AL1077_i_Delta = F0025_MAIN_GetMaximumValue(P0717_i_ValueDelta, P0715_ps_Champion->Statistics[P0716_ui_StatisticIndex][C2_MINIMUM] - P0715_ps_Champion->Statistics[P0716_ui_StatisticIndex][C1_CURRENT]);
        }
        P0715_ps_Champion->Statistics[P0716_ui_StatisticIndex][C1_CURRENT] += AL1077_i_Delta;
}

void F0349_INVENTORY_ProcessCommand70_ClickOnMouth(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER THING L1078_T_Thing;
        REGISTER unsigned int16_t L1079_ui_IconIndex;
        REGISTER unsigned int16_t L1080_ui_ChampionIndex;
        REGISTER BOOLEAN L1081_B_RemoveObjectFromLeaderHand;
        REGISTER JUNK* L1082_ps_Junk;
#endif
        REGISTER CHAMPION* L1083_ps_Champion;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        EVENT L1084_s_Event;
        unsigned int16_t L1085_ui_Multiple;
        unsigned int16_t L1086_ui_Counter;
#endif
#define AL1085_ui_PotionPower         L1085_ui_Multiple
#define AL1085_ui_AdjustedPotionPower L1085_ui_Multiple
#define AL1085_ui_Counter             L1085_ui_Multiple
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER JUNK* L1082_ps_Junk;
        REGISTER unsigned int16_t L1085_ui_Multiple;
        REGISTER unsigned int16_t L1088_ui_Multiple;
        REGISTER unsigned int16_t L1086_ui_Counter;
        REGISTER THING L1078_T_Thing;
        REGISTER BOOLEAN L1081_B_RemoveObjectFromLeaderHand;
        REGISTER unsigned int16_t L1080_ui_ChampionIndex;
        REGISTER unsigned int16_t L1079_ui_IconIndex;
#endif
#define AL1088_ui_ThingType               L1088_ui_Multiple
#define AL1088_ui_Mana                    L1088_ui_Multiple
#define AL1088_ui_HealWoundIterationCount L1088_ui_Multiple
        unsigned int16_t L1087_ui_Wounds;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L1088_ui_Multiple;
#endif
        unsigned int16_t L1089_ui_Weight;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        EVENT L1084_s_Event;
#endif


        if (G0415_ui_LeaderEmptyHanded) {
                if (G0424_i_PanelContent == M565_PANEL_FOOD_WATER_POISONED) {
                        return;
                }
                G0597_B_IgnoreMouseMovements = C1_TRUE;
                G0333_B_PressingMouth = C1_TRUE;
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
                F0706_GetMouseState(&G2010_, &G2011_, &G0588_i_MouseButtonsStatus);
#endif
#ifdef MEDIA141_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (!M007_GET(G0588_i_MouseButtonsStatus, MASK0x0002_MOUSE_LEFT_BUTTON)) {
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
                if (!M007_GET(F2158_GetMouseButtonsStatus(), MASK0x0002_MOUSE_LEFT_BUTTON)) {
#endif
                        G0597_B_IgnoreMouseMovements = C0_FALSE;
                        T0349001: /* ANOMALY_FMT Label required to disable optimization */
                        G0333_B_PressingMouth = C0_FALSE;
                        T0349002: ; /* ANOMALY_FMT Label required to disable optimization */
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
                        G0334_B_StopPressingMouth = C0_FALSE;
#endif
                } else {
                        M522_MOUSE_HidePointer();
#ifdef MEDIA351_G14ED_G20E_G21E
                        F2159_ClampMousePointerOnASinglePixel();
#endif
                        G0587_i_HideMousePointerRequestCount = 1;
                        F0345_INVENTORY_DrawPanel_FoodWaterPoisoned();
                        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
                }
                return;
        }
        if (G0299_ui_CandidateChampionOrdinal) {
                return;
        }
        if (!M007_GET(G0237_as_Graphic559_ObjectInfo[F0141_DUNGEON_GetObjectInfoIndex(L1078_T_Thing = G4055_s_LeaderHandObject.Thing)].AllowedSlots, MASK0x0001_MOUTH)) {
                return;
        }
        L1079_ui_IconIndex = F0033_OBJECT_GetIconIndex(L1078_T_Thing);
        AL1088_ui_ThingType = M012_TYPE(L1078_T_Thing);
        L1089_ui_Weight = F0140_DUNGEON_GetObjectWeight(L1078_T_Thing);
        L1083_ps_Champion = &M516_CHAMPIONS[L1080_ui_ChampionIndex = M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)];
        L1082_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(L1078_T_Thing);
        if ((L1079_ui_IconIndex >= C008_ICON_JUNK_WATER) && (L1079_ui_IconIndex <= C009_ICON_JUNK_WATERSKIN)) {
                if (!(L1082_ps_Junk->ChargeCount))
                        return;
                L1083_ps_Champion->Water = F0024_MAIN_GetMinimumValue(L1083_ps_Champion->Water + 800, 2048);
                L1082_ps_Junk->ChargeCount--;
                L1081_B_RemoveObjectFromLeaderHand = C0_FALSE;
        } else {
                if (AL1088_ui_ThingType == C08_THING_TYPE_POTION) {
                        L1081_B_RemoveObjectFromLeaderHand = C0_FALSE;
                } else {
                        L1082_ps_Junk->Next = C0xFFFF_THING_NONE;
                        L1081_B_RemoveObjectFromLeaderHand = C1_TRUE;
                }
        }
        F0077_MOUSE_EnableScreenUpdate_CPSE();
        if (L1081_B_RemoveObjectFromLeaderHand) {
                F0298_CHAMPION_GetObjectRemovedFromLeaderHand();
        }
        if (AL1088_ui_ThingType == C08_THING_TYPE_POTION) {
                AL1085_ui_PotionPower = ((POTION*)L1082_ps_Junk)->Power;
#ifdef MEDIA070_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
                L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 2 / 2 / 2)) >> 1;
#endif
                AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
                switch (((POTION*)L1082_ps_Junk)->Type) {
                        case C06_POTION_ROS_POTION:
                                F0348_INVENTORY_AdjustStatisticCurrentValue(L1083_ps_Champion, C2_STATISTIC_DEXTERITY, AL1085_ui_AdjustedPotionPower);
                                break;
                        case C07_POTION_KU_POTION:
                                F0348_INVENTORY_AdjustStatisticCurrentValue(L1083_ps_Champion, C1_STATISTIC_STRENGTH, (((POTION*)L1082_ps_Junk)->Power / 35) + 5); /* Value between 5 and 12 */
                                break;
                        case C08_POTION_DANE_POTION:
                                F0348_INVENTORY_AdjustStatisticCurrentValue(L1083_ps_Champion, C3_STATISTIC_WISDOM, AL1085_ui_AdjustedPotionPower);
                                break;
                        case C09_POTION_NETA_POTION:
                                F0348_INVENTORY_AdjustStatisticCurrentValue(L1083_ps_Champion, C4_STATISTIC_VITALITY, AL1085_ui_AdjustedPotionPower);
                                break;
                        case C10_POTION_ANTIVENIN:
                                F0323_CHAMPION_Unpoison(L1080_ui_ChampionIndex);
                                break;
                        case C11_POTION_MON_POTION:
                                L1083_ps_Champion->CurrentStamina += F0024_MAIN_GetMinimumValue(L1083_ps_Champion->MaximumStamina - L1083_ps_Champion->CurrentStamina, L1083_ps_Champion->MaximumStamina / L1086_ui_Counter);
                                break;
                        case C12_POTION_YA_POTION:
                                AL1085_ui_AdjustedPotionPower += AL1085_ui_AdjustedPotionPower >> 1;
                                if (L1083_ps_Champion->ShieldDefense > 50) {
                                        AL1085_ui_AdjustedPotionPower >>= 2;
                                }
                                L1083_ps_Champion->ShieldDefense += AL1085_ui_AdjustedPotionPower;
                                L1084_s_Event.A.A.Type = C72_EVENT_CHAMPION_SHIELD;
                                M033_SET_MAP_AND_TIME(L1084_s_Event.Map_Time, G0309_i_PartyMapIndex, G0313_ul_GameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
                                L1084_s_Event.A.A.Priority = L1080_ui_ChampionIndex;
                                L1084_s_Event.B.Defense = AL1085_ui_AdjustedPotionPower;
                                F0238_TIMELINE_AddEvent_GetEventIndex_CPSE(&L1084_s_Event);
                                M008_SET(L1083_ps_Champion->Attributes, MASK0x1000_STATUS_BOX);
                                break;
                        case C13_POTION_EE_POTION:
                                AL1088_ui_Mana = F0024_MAIN_GetMinimumValue(900, (L1083_ps_Champion->CurrentMana + AL1085_ui_AdjustedPotionPower) + (AL1085_ui_AdjustedPotionPower - 8));
                                if (AL1088_ui_Mana > L1083_ps_Champion->MaximumMana) {
                                        AL1088_ui_Mana -= (AL1088_ui_Mana - F0025_MAIN_GetMaximumValue(L1083_ps_Champion->CurrentMana, L1083_ps_Champion->MaximumMana)) >> 1;
                                }
                                L1083_ps_Champion->CurrentMana = AL1088_ui_Mana;
                                break;
                        case C14_POTION_VI_POTION:
                                AL1088_ui_HealWoundIterationCount = F0025_MAIN_GetMaximumValue(1, (((POTION*)L1082_ps_Junk)->Power / 42));
                                L1083_ps_Champion->CurrentHealth += L1083_ps_Champion->MaximumHealth / L1086_ui_Counter;
                                if (L1087_ui_Wounds = L1083_ps_Champion->Wounds) { /* If the champion is wounded */
                                        L1086_ui_Counter = 10;
                                        do {
                                                for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) {
                                                        L1083_ps_Champion->Wounds &= M006_RANDOM(65536);
                                                }
                                                AL1088_ui_HealWoundIterationCount = 1;
                                        } while ((L1087_ui_Wounds == L1083_ps_Champion->Wounds) && --L1086_ui_Counter); /* Loop until at least one wound is healed or there are no more heal iterations */
                                }
                                M008_SET(L1083_ps_Champion->Attributes, MASK0x0200_LOAD | MASK0x2000_WOUNDS);
                                break;
                        case C15_POTION_WATER_FLASK:
                                L1083_ps_Champion->Water = F0024_MAIN_GetMinimumValue(L1083_ps_Champion->Water + 1600, 2048);
                                break;
                }
                ((POTION*)L1082_ps_Junk)->Type = C20_POTION_EMPTY_FLASK;
        } else {
                if ((L1079_ui_IconIndex >= C168_ICON_JUNK_APPLE) && (L1079_ui_IconIndex < C176_ICON_JUNK_IRON_KEY)) {
                        L1083_ps_Champion->Food = F0024_MAIN_GetMinimumValue(L1083_ps_Champion->Food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - C168_ICON_JUNK_APPLE], 2048);
                }
        }
        if (L1083_ps_Champion->CurrentStamina > L1083_ps_Champion->MaximumStamina) {
                L1083_ps_Champion->CurrentStamina = L1083_ps_Champion->MaximumStamina;
        }
        if (L1083_ps_Champion->CurrentHealth > L1083_ps_Champion->MaximumHealth) {
                L1083_ps_Champion->CurrentHealth = L1083_ps_Champion->MaximumHealth;
        }
        if (L1081_B_RemoveObjectFromLeaderHand) {
                for (L1086_ui_Counter = 5; --L1086_ui_Counter; ) { /* Animate mouth icon */
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        F0037_OBJECT_DrawIconToScreen(C205_ICON_MOUTH_OPEN + !(L1086_ui_Counter & 0x0001), 56, 46);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0332_INVENTORY_DrawIconToViewport(C205_ICON_MOUTH_OPEN + !(L1086_ui_Counter & 0x0001), C545_ZONE_MOUTH);
                        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
#endif
                        F0022_MAIN_Delay(8);
                }
        } else {
                F0296_CHAMPION_DrawChangedObjectIcons();
                M516_CHAMPIONS[G0411_i_LeaderIndex].Load += F0140_DUNGEON_GetObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
                M008_SET(M516_CHAMPIONS[G0411_i_LeaderIndex].Attributes, MASK0x0200_LOAD);
        }
        F0064_SOUND_RequestPlay_CPSD(C08_SOUND_SWALLOW, G0306_i_PartyMapX, G0307_i_PartyMapY, C00_MODE_PLAY_IMMEDIATELY);
        M008_SET(L1083_ps_Champion->Attributes, MASK0x0100_STATISTICS);
        if (G0424_i_PanelContent == M565_PANEL_FOOD_WATER_POISONED) {
                M008_SET(L1083_ps_Champion->Attributes, MASK0x0800_PANEL);
        }
        F0292_CHAMPION_DrawState(L1080_ui_ChampionIndex);
        F0078_MOUSE_DisableScreenUpdate();
}

void F0350_INVENTORY_DrawStopPressingMouth(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        F0347_INVENTORY_DrawPanel();
        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
        G0587_i_HideMousePointerRequestCount = 1;
        M523_MOUSE_ShowPointer();
}

void F0351_INVENTORY_DrawChampionSkillsAndStatistics(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER CHAMPION* L1094_ps_Champion;
        REGISTER unsigned int16_t L1090_ui_Multiple;
#define AL1090_ui_SkillIndex     L1090_ui_Multiple
#define AL1090_ui_StatisticIndex L1090_ui_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L1091_i_Y;
#endif
        REGISTER int16_t L1092_i_Multiple;
#define AL1092_i_SkillLevel            L1092_i_Multiple
#define AL1092_i_StatisticCurrentValue L1092_i_Multiple
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L1095_i_StatisticColor;
        REGISTER unsigned int16_t L1096_ui_StatisticMaximumValue;
#endif
        REGISTER unsigned int16_t L1093_ui_ChampionIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1095_i_StatisticColor;
        unsigned int16_t L1096_ui_StatisticMaximumValue;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2865_i_X;
        int16_t L2866_i_X2;
        int16_t L1091_i_Y;
#endif
        char L1097_ac_String[20];
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_08_OPTIMIZATION */
        static char* G0431_apc_StatisticNames[7] = { "L", "STRENGTH   ", "DEXTERITY  ", "WISDOM     ", "VITALITY   ", "ANTI-MAGIC ", "ANTI-FIRE  " };
#endif
#ifdef MEDIA250_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J /* CHANGE3_08_OPTIMIZATION Trailing space characters removed from strings CHANGE4_00_LOCALIZATION Translation to German language */
        static char* G0431_apc_StatisticNames[7] = { "L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE" };
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
        static char* G0431_apc_StatisticNames[7] = { "L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER" };
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
        static char* G0431_apc_StatisticNames[7] = { "L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU" };
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        static int16_t G2017_ai_StatisticNames[7] = { 41, 42, 43, 44, 45, 46, 47 }; /* Text indices */
#endif


        F0334_INVENTORY_CloseChest();
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0424_i_PanelContent = C02_PANEL_SKILLS_AND_STATISTICS;
#endif
        L1094_ps_Champion = &M516_CHAMPIONS[L1093_ui_ChampionIndex = M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)];
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M519_F0020_MAIN_BlitToViewport(F0489_MEMORY_GetNativeBitmapOrGraphic(C020_GRAPHIC_PANEL_EMPTY), G0032_ai_Graphic562_Box_Panel, C072_BYTE_WIDTH, C08_COLOR_RED, 73);
        L1091_i_Y = 58;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0658_BlitBitmapIndexToZoneIndexWithTransparency(C020_GRAPHIC_PANEL_EMPTY, C101_ZONE_PANEL, C08_COLOR_RED);
        F0636_GetZoneTopLeftCoordinatesWith1PixelMargin(C557_ZONE_SKILL_VALUE, &L2865_i_X, &L1091_i_Y);
#endif
        for (AL1090_ui_SkillIndex = C00_SKILL_FIGHTER; AL1090_ui_SkillIndex <= C03_SKILL_WIZARD; AL1090_ui_SkillIndex++) {
                AL1092_i_SkillLevel = F0024_MAIN_GetMinimumValue(16, F0303_CHAMPION_GetSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE));
                if (AL1092_i_SkillLevel == 1)
                        continue;
#ifdef MEDIA193_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J /* CHANGE4_00_LOCALIZATION Translation to German language */
                M547_STRCPY(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
                M545_STRCAT(L1097_ac_String, " ");
                M545_STRCAT(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
#endif
#ifdef MEDIA254_S12G_S13FA_S13FB_A20F_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                strcpy(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]);
                strcat(L1097_ac_String, " ");
                strcat(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                if (G2000_Language == C0_ENGLISH) {
                        M547_STRCPY(L1097_ac_String, F0758_TranslateLanguage(G2014_ai_SkillLevelNames[AL1092_i_SkillLevel - 2]));
                        M545_STRCAT(L1097_ac_String, " ");
                        M545_STRCAT(L1097_ac_String, F0758_TranslateLanguage(G2015_ai_BaseSkillNames[AL1090_ui_SkillIndex]));
                } else {
                        M547_STRCPY(L1097_ac_String, F0758_TranslateLanguage(G2015_ai_BaseSkillNames[AL1090_ui_SkillIndex]));
                        M545_STRCAT(L1097_ac_String, " ");
                        M545_STRCAT(L1097_ac_String, F0758_TranslateLanguage(G2014_ai_SkillLevelNames[AL1092_i_SkillLevel - 2]));
                }
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0052_TEXT_PrintToViewport(108, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, L1097_ac_String);
                L1091_i_Y += 7;
#endif
#ifdef MEDIA488_F20E_F20J
                F0052_TEXT_PrintToViewport(L2865_i_X, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, L1097_ac_String);
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0052_TEXT_PrintToViewport(L2865_i_X, L1091_i_Y, (G2016_ai_SkillRecentlyUpgraded[L1093_ui_ChampionIndex][AL1090_ui_SkillIndex]) ? C07_COLOR_LIGHT_GREEN : C13_COLOR_LIGHTEST_GRAY, L1097_ac_String);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L1091_i_Y += G2088_C7_TextLineHeight;
#endif
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L1091_i_Y = 86;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0636_GetZoneTopLeftCoordinatesWith1PixelMargin(C559_ZONE_STATISTIC_VALUE, &L2866_i_X2, &L1091_i_Y);
#endif
        for (AL1090_ui_StatisticIndex = C1_STATISTIC_STRENGTH; AL1090_ui_StatisticIndex <= C6_STATISTIC_ANTIFIRE; AL1090_ui_StatisticIndex++) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0052_TEXT_PrintToViewport(108, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
#endif
#ifdef MEDIA520_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J
                F0052_TEXT_PrintToViewport(L2865_i_X, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                F0052_TEXT_PrintToViewport(L2865_i_X, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, F0758_TranslateLanguage(G2017_ai_StatisticNames[AL1090_ui_StatisticIndex]));
#endif
                AL1092_i_StatisticCurrentValue = L1094_ps_Champion->Statistics[AL1090_ui_StatisticIndex][C1_CURRENT];
                L1096_ui_StatisticMaximumValue = L1094_ps_Champion->Statistics[AL1090_ui_StatisticIndex][C0_MAXIMUM];
                if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) {
                        L1095_i_StatisticColor = C08_COLOR_RED;
                } else {
                        if (AL1092_i_StatisticCurrentValue > L1096_ui_StatisticMaximumValue) {
                                L1095_i_StatisticColor = C07_COLOR_LIGHT_GREEN;
                        } else {
                                L1095_i_StatisticColor = C13_COLOR_LIGHTEST_GRAY;
                        }
                }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0052_TEXT_PrintToViewport(174, L1091_i_Y, L1095_i_StatisticColor, F0288_CHAMPION_GetStringFromInteger(AL1092_i_StatisticCurrentValue, C1_TRUE, 3));
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0052_TEXT_PrintToViewport(L2866_i_X2, L1091_i_Y, L1095_i_StatisticColor, F0288_CHAMPION_GetStringFromInteger(AL1092_i_StatisticCurrentValue, C1_TRUE, 3));
#endif
                M547_STRCPY(L1097_ac_String, "/");
                M545_STRCAT(L1097_ac_String, F0288_CHAMPION_GetStringFromInteger(L1096_ui_StatisticMaximumValue, C1_TRUE, 3));
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0052_TEXT_PrintToViewport(192, L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, L1097_ac_String);
                L1091_i_Y += 7;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0052_TEXT_PrintToViewport(L2866_i_X2  + (G2087_C6_TextCharacterWidth * 3), L1091_i_Y, C13_COLOR_LIGHTEST_GRAY, L1097_ac_String);
                L1091_i_Y += G2088_C7_TextLineHeight;
#endif
        }
}

void F0352_INVENTORY_ProcessCommand71_ClickOnEye(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
        REGISTER int16_t L1098_i_Unreferenced; /* BUG0_00 Useless code */
        REGISTER int16_t L1099_i_Unreferenced; /* BUG0_00 Useless code */
#endif


        G0597_B_IgnoreMouseMovements = C1_TRUE;
        G0331_B_PressingEye = C1_TRUE;
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        F0706_GetMouseState(&G2010_, &G2011_, &G0588_i_MouseButtonsStatus);
#endif
#ifdef MEDIA141_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (!M007_GET(G0588_i_MouseButtonsStatus, MASK0x0002_MOUSE_LEFT_BUTTON)) {
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        if (!M007_GET(F2158_GetMouseButtonsStatus(), MASK0x0002_MOUSE_LEFT_BUTTON)) {
#endif
                G0597_B_IgnoreMouseMovements = C0_FALSE;
                G0331_B_PressingEye = C0_FALSE;
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
                G0332_B_StopPressingEye = C0_FALSE;
#endif
                return;
        }
        F0357_COMMAND_DiscardAllInput();
        M522_MOUSE_HidePointer();
#ifdef MEDIA351_G14ED_G20E_G21E
        F2159_ClampMousePointerOnASinglePixel();
#endif
        F0022_MAIN_Delay(8);
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0332_INVENTORY_DrawIconToViewport(C203_ICON_EYE_LOOKING, 12, 13);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0332_INVENTORY_DrawIconToViewport(C203_ICON_EYE_LOOKING, C546_ZONE_EYE);
#endif
        if (G0415_ui_LeaderEmptyHanded) {
                F0351_INVENTORY_DrawChampionSkillsAndStatistics();
        } else {
                F0035_OBJECT_ClearLeaderHandObjectName();
                F0342_INVENTORY_DrawPanel_Object(G4055_s_LeaderHandObject.Thing, C1_TRUE);
        }
        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
}

void F0353_INVENTORY_DrawStopPressingEye(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L2867_i_;
#endif
        REGISTER THING L1100_T_LeaderHandObject;


#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0332_INVENTORY_DrawIconToViewport(C202_ICON_EYE_NOT_LOOKING, 12, 13);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0332_INVENTORY_DrawIconToViewport(C202_ICON_EYE_NOT_LOOKING, C546_ZONE_EYE);
#endif
        F0347_INVENTORY_DrawPanel();
        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        if ((L1100_T_LeaderHandObject = G4055_s_LeaderHandObject.Thing) != C0xFFFF_THING_NONE) {
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if ((L1100_T_LeaderHandObject = G4055_s_LeaderHandObject.Thing) == C0xFFFF_THING_NONE) {
                for (L2867_i_ = 0; L2867_i_ <= 3; G2016_ai_SkillRecentlyUpgraded[M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal)][L2867_i_++] = C0_FALSE);
        } else {
#endif
                F0034_OBJECT_DrawLeaderHandObjectName(L1100_T_LeaderHandObject);
        }
        M523_MOUSE_ShowPointer();
}

void F0354_INVENTORY_DrawStatusBoxPortrait(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0718_i_ChampionIndex)
#endif
int16_t P0718_i_ChampionIndex FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1101_ai_Box[4];
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned char* L1642_puc_Bitmap_Portrait_ChipMemory;
#endif


        G0578_B_UseByteBoxCoordinates = C0_FALSE;
        M770_BOX_TOP(L1101_ai_Box) = 0;
        M771_BOX_BOTTOM(L1101_ai_Box) = 28;
        M769_BOX_RIGHT(L1101_ai_Box) = (M768_BOX_LEFT(L1101_ai_Box) = (P0718_i_ChampionIndex * C69_CHAMPION_STATUS_BOX_SPACING) + 7) + 31; /* There is a 7 pixels left margin in the status box */
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
        F0021_MAIN_BlitToScreen(M516_CHAMPIONS[P0718_i_ChampionIndex].Portrait, L1101_ai_Box, C016_BYTE_WIDTH, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L1642_puc_Bitmap_Portrait_ChipMemory = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 29), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        F0007_MAIN_CopyBytes(M516_CHAMPIONS[P0718_i_ChampionIndex].Portrait, L1642_puc_Bitmap_Portrait_ChipMemory, M075_BITMAP_BYTE_COUNT(32, 29));
        F0021_MAIN_BlitToScreen(L1642_puc_Bitmap_Portrait_ChipMemory, L1101_ai_Box, C016_BYTE_WIDTH, CM1_COLOR_NO_TRANSPARENCY, 29);
        F0469_MEMORY_FreeAtHeapTop((long)M075_BITMAP_BYTE_COUNT(32, 29));
#endif
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2868_ai_XYZ[4];


        F0638_GetZone(C175_ZONE_FIRST_CHAMPION_STATUS_BOX + P0718_i_ChampionIndex, L2868_ai_XYZ);
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        F0132_VIDEO_Blit(M516_CHAMPIONS[P0718_i_ChampionIndex].Portrait, G0348_Bitmap_Screen, L2868_ai_XYZ, 0, 0, G2078_C32_PortraitWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA543_F20E_F20J_X30J_F31E_F31J_X31J
        F0132_VIDEO_Blit(M774_CAST_PUC(M516_CHAMPIONS[P0718_i_ChampionIndex].Portrait), G0348_Bitmap_Screen, L2868_ai_XYZ, 0, 0, G2078_C32_PortraitWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        F0132_VIDEO_Blit(M516_CHAMPIONS[P0718_i_ChampionIndex].Portrait, G0348_Bitmap_Screen, L2868_ai_XYZ, 0, 0, G2078_C32_PortraitWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY, G2079_C29_PortraitHeight, G2072_C200_ScreenPixelHeight);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (G0407_s_Party.Event71Count_Invisibility) {
                F0136_VIDEO_HatchScreenBox(C175_ZONE_FIRST_CHAMPION_STATUS_BOX + P0718_i_ChampionIndex, C12_COLOR_DARKEST_GRAY);
        }
#endif
}

void F0355_INVENTORY_Toggle_CPSE(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0719_i_ChampionIndex)
#endif
REGISTER int16_t P0719_i_ChampionIndex FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L1103_ps_Champion;
#endif
        REGISTER unsigned int16_t L1102_ui_Multiple;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER CHAMPION* L1103_ps_Champion;
#endif
#define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple
#define AL1102_ui_SlotIndex                L1102_ui_Multiple
#ifdef MEDIA382_G14ED_A20ED
        static int16_t G1143_ai_Box_ViewportFloppy[4] = { 174, 182, 2, 12 };
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER BOOLEAN L2869_B_;
#endif


#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        if ((P0719_i_ChampionIndex != C04_CHAMPION_CLOSE_INVENTORY) && !M516_CHAMPIONS[P0719_i_ChampionIndex].CurrentHealth) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L2869_B_ = C0_FALSE;
        if (G2152_B_PressingClosedImaginaryFakeWall)
                return;
        if ((P0719_i_ChampionIndex < C04_CHAMPION_CLOSE_INVENTORY) && !M516_CHAMPIONS[P0719_i_ChampionIndex].CurrentHealth) {
#endif
                return;
        }
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        if (G0333_B_PressingMouth || G0331_B_PressingEye) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if ((P0719_i_ChampionIndex != C05_CHAMPION_SPECIAL_INVENTORY) && (G0333_B_PressingMouth || G0331_B_PressingEye)) {
#endif
                return;
        }
        G0321_B_StopWaitingForPlayerInput = C1_TRUE;
#ifdef MEDIA284_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M /* CHANGE7_04_IMPROVEMENT */
#ifndef NOCOPYPROTECTION
        if ((G0068_i_CheckLastEvent22Time_CPSE == C00555_TRUE) && ((G0313_ul_GameTime - G0418_l_LastEvent22Time_CPSE) > 1000)) {
                G0330_i_StopExpiringEvents_CPSE++;
        }
#endif
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (P0719_i_ChampionIndex != C05_CHAMPION_SPECIAL_INVENTORY) {
                G0424_i_PanelContent = C00_PANEL_INVENTORY;
        }
#endif
        AL1102_ui_InventoryChampionOrdinal = G0423_i_InventoryChampionOrdinal;
        if (M000_INDEX_TO_ORDINAL(P0719_i_ChampionIndex) == AL1102_ui_InventoryChampionOrdinal) {
                P0719_i_ChampionIndex = C04_CHAMPION_CLOSE_INVENTORY;
        }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (!AL1102_ui_InventoryChampionOrdinal || (P0719_i_ChampionIndex == C04_CHAMPION_CLOSE_INVENTORY)) {
                L2869_B_ = C1_TRUE;
#endif
                F0077_MOUSE_EnableScreenUpdate_CPSE();
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        if (AL1102_ui_InventoryChampionOrdinal) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
        G0297_B_DrawFloorAndCeilingRequested = C0_FALSE;
        if (AL1102_ui_InventoryChampionOrdinal && (P0719_i_ChampionIndex != C05_CHAMPION_SPECIAL_INVENTORY)) {
#endif
                G0423_i_InventoryChampionOrdinal = M000_INDEX_TO_ORDINAL(CM1_CHAMPION_NONE);
                F0334_INVENTORY_CloseChest();
                L1103_ps_Champion = &M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(AL1102_ui_InventoryChampionOrdinal)];
                if (L1103_ps_Champion->CurrentHealth && !G0299_ui_CandidateChampionOrdinal) {
                        M008_SET(L1103_ps_Champion->Attributes, MASK0x1000_STATUS_BOX);
                        F0292_CHAMPION_DrawState(M001_ORDINAL_TO_INDEX(AL1102_ui_InventoryChampionOrdinal));
                }
                if (G0300_B_PartyIsResting) {
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        if (!L2869_B_) {
                                return;
                        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0700_TriggerImmediateMouseEvent();
#endif
                        F0078_MOUSE_DisableScreenUpdate();
                        return;
                }
                if (P0719_i_ChampionIndex == C04_CHAMPION_CLOSE_INVENTORY) {
                        G0326_B_RefreshMousePointerInMainLoop = C1_TRUE;
                        F0395_MENUS_DrawMovementArrows();
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        if (L2869_B_) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                F0700_TriggerImmediateMouseEvent();
#endif
                                F0078_MOUSE_DisableScreenUpdate();
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        }
#endif
                        G0442_ps_SecondaryMouseInput = G0448_as_Graphic561_SecondaryMouseInput_Movement;
                        G0444_ps_SecondaryKeyboardInput = G0459_as_Graphic561_SecondaryKeyboardInput_Movement;
                        F0357_COMMAND_DiscardAllInput();
                        F0098_DUNGEONVIEW_DrawFloorAndCeiling();
                        return;
                }
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0578_B_UseByteBoxCoordinates = C0_FALSE;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (P0719_i_ChampionIndex == C05_CHAMPION_SPECIAL_INVENTORY) {
                P0719_i_ChampionIndex = M001_ORDINAL_TO_INDEX(G0423_i_InventoryChampionOrdinal);
        } else {
#endif
                G0423_i_InventoryChampionOrdinal = M000_INDEX_TO_ORDINAL(P0719_i_ChampionIndex);
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
#endif
        if (!AL1102_ui_InventoryChampionOrdinal) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0136_VIDEO_HatchScreenBox(G0002_ai_Graphic562_Box_MovementArrows, C00_COLOR_BLACK);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0136_VIDEO_HatchScreenBox(C009_ZONE_MOVEMENT_ARROWS, C00_COLOR_BLACK);
#endif
        }
        L1103_ps_Champion = &M516_CHAMPIONS[P0719_i_ChampionIndex];
        F0488_MEMORY_ExpandGraphicToBitmap(C017_GRAPHIC_INVENTORY, G0296_puc_Bitmap_Viewport);
        if (G0299_ui_CandidateChampionOrdinal) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                M525_F0135_VIDEO_FillBox(G0296_puc_Bitmap_Viewport, G0041_ai_Graphic562_Box_ViewportFloppyZzzCross, C12_COLOR_DARKEST_GRAY, C112_BYTE_WIDTH_VIEWPORT, C136_HEIGHT_VIEWPORT);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0734_ClearZoneInInventory(C562_ZONE_SAVE_GAME_ICON);
                F0734_ClearZoneInInventory(C564_ZONE_REST_ICON);
                F0734_ClearZoneInInventory(C566_ZONE_CLOSE_INVENTORY_ICON);
#endif
#ifdef MEDIA382_G14ED_A20ED
        } else {
                M525_F0135_VIDEO_FillBox(G0296_puc_Bitmap_Viewport, G1143_ai_Box_ViewportFloppy, C12_COLOR_DARKEST_GRAY, C112_BYTE_WIDTH_VIEWPORT, C136_HEIGHT_VIEWPORT); /* Hide the floppy disk icon */
#endif
        }
#ifdef MEDIA481_P20JB_I34E_I34M_F31E_F31J_P31J
        if (!G2106_B_ShowMusicState) {
                F0734_ClearZoneInInventory(C568_ZONE_TOGGLE_MUSIC_ICON); /* Probable BUGX_XX in P20JB? Should be zone 570! */
        }
#endif
#ifdef MEDIA191_S10EA_S10EB_S11E_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E /* CHANGE4_00_LOCALIZATION Translation to German language */
        F0052_TEXT_PrintToViewport(5, 116, C13_COLOR_LIGHTEST_GRAY, "HEALTH");
        F0052_TEXT_PrintToViewport(5, 124, C13_COLOR_LIGHTEST_GRAY, "STAMINA");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
        F0052_TEXT_PrintToViewport(5, 116, C13_COLOR_LIGHTEST_GRAY, "GESUND");
        F0052_TEXT_PrintToViewport(5, 124, C13_COLOR_LIGHTEST_GRAY, "KRAFT");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
        F0052_TEXT_PrintToViewport(5, 116, C13_COLOR_LIGHTEST_GRAY, "SANTE");
        F0052_TEXT_PrintToViewport(5, 124, C13_COLOR_LIGHTEST_GRAY, "VIGUEUR");
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0052_TEXT_PrintToViewport(5, 132, C13_COLOR_LIGHTEST_GRAY, "MANA");
#endif
#ifdef MEDIA561_F20E_I34E_A31E_A35E_F31E
        F0648_PrintTextInViewportZone(C547_ZONE_HEALTH_LABEL, C13_COLOR_LIGHTEST_GRAY, "HEALTH");
        F0648_PrintTextInViewportZone(C548_ZONE_STAMINA_LABEL, C13_COLOR_LIGHTEST_GRAY, "STAMINA");
        F0648_PrintTextInViewportZone(C549_ZONE_MANA_LABEL, C13_COLOR_LIGHTEST_GRAY, "MANA");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        F0648_PrintTextInViewportZone(C547_ZONE_HEALTH_LABEL, C13_COLOR_LIGHTEST_GRAY, F0758_TranslateLanguage(C48_HEALTH));
        F0648_PrintTextInViewportZone(C548_ZONE_STAMINA_LABEL, C13_COLOR_LIGHTEST_GRAY, F0758_TranslateLanguage(C49_STAMINA));
        F0648_PrintTextInViewportZone(C549_ZONE_MANA_LABEL, C13_COLOR_LIGHTEST_GRAY, F0758_TranslateLanguage(C50_MANA));
#endif
        for (AL1102_ui_SlotIndex = C00_SLOT_READY_HAND; AL1102_ui_SlotIndex < C30_SLOT_CHEST_1; AL1102_ui_SlotIndex++) {
                F0291_CHAMPION_DrawSlot(P0719_i_ChampionIndex, AL1102_ui_SlotIndex);
        }
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
        M008_SET(L1103_ps_Champion->Attributes, MASK0x4000_VIEWPORT | MASK0x1000_STATUS_BOX | MASK0x0800_PANEL | MASK0x0200_LOAD | MASK0x0100_STATISTICS | MASK0x0080_NAME_TITLE);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        M008_SET(L1103_ps_Champion->Attributes, MASK0x4000_VIEWPORT | MASK0x1000_STATUS_BOX | MASK0x0800_PANEL | MASK0x0400_ICON | MASK0x0200_LOAD | MASK0x0100_STATISTICS | MASK0x0080_NAME_TITLE);
#endif
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        M526_WaitVerticalBlank();
#endif
        F0292_CHAMPION_DrawState(P0719_i_ChampionIndex);
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (L2869_B_) {
#endif
                G0598_B_MousePointerBitmapUpdated = C1_TRUE;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0700_TriggerImmediateMouseEvent();
#endif
                F0078_MOUSE_DisableScreenUpdate();
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
#endif
        G0442_ps_SecondaryMouseInput = G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory;
        G0444_ps_SecondaryKeyboardInput = NULL;
        F0357_COMMAND_DiscardAllInput();
}
#endif
