#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
#ifdef MEDIA027_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_F31E_F31J_X31J_P31J
unsigned char* G0352_apc_ObjectNames[C199_OBJECT_NAME_COUNT];
#endif
#ifdef MEDIA724_I34E_I34M_A36M_A31M_A33M_A35E_A35M
unsigned char** G0352_apc_ObjectNames;
#endif
#ifdef MEDIA689_F31J_X31J_P31J
int16_t G2230_;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t G2007_ai_XYZ[4];
#endif

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

void F0031_OBJECT_LoadNames(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER unsigned char* L0001_puc_ObjectNames;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned char* L0002_puc_Graphic;
#endif
        REGISTER unsigned int16_t L0003_ui_ObjectNameIndex;
#ifdef MEDIA557_F20E_X30J_I34E_A31E_F31E
        REGISTER unsigned char* L0002_puc_Graphic;
#endif
#ifdef MEDIA689_F31J_X31J_P31J
        REGISTER int16_t L3357_i_;
#endif


#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G4055_s_LeaderHandObject.BitmapIconForMousePointer = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(16, 16), C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        M705_ZONE_RIGHT(G2007_ai_XYZ) = G2075_ObjectIconWidth - 1;
        M707_ZONE_BOTTOM(G2007_ai_XYZ) = G2076_ObjectIconHeight - 1;
        G4055_s_LeaderHandObject.BitmapIconForMousePointer = F0468_MEMORY_Allocate((long)G2184_ActionIconByteCount, MASK0x8000_ALLOCATE_BITMAP | C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0625_GetZoneInitializedFromDimensions(G2007_ai_XYZ, G2075_ObjectIconWidth, G2076_ObjectIconHeight);
        G4055_s_LeaderHandObject.BitmapIconForMousePointer = F0606_AllocateMemForGraphic(G2075_ObjectIconWidth, G2076_ObjectIconHeight, C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA689_F31J_X31J_P31J
        G2230_ = 1;
        L0001_puc_ObjectNames = (unsigned char*)F0468_MEMORY_Allocate((long)(F0494_MEMORY_GetGraphicDecompressedByteCount(M564_GRAPHIC_OBJECT_NAMES)), C1_ALLOCATION_PERMANENT);
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | MASK0x4000_DO_NOT_COPY_DIMENSIONS | M564_GRAPHIC_OBJECT_NAMES, L0001_puc_ObjectNames);
        for (L0003_ui_ObjectNameIndex = 0; L0003_ui_ObjectNameIndex < C199_OBJECT_NAME_COUNT; L0003_ui_ObjectNameIndex++) {
                G0352_apc_ObjectNames[L0003_ui_ObjectNameIndex] = L0001_puc_ObjectNames;
                L3357_i_ = 0;
                while (*L0001_puc_ObjectNames) {
                        if (*L0001_puc_ObjectNames == 1) {
                                *L0001_puc_ObjectNames = '\0';
                                L3357_i_ = 1;
                        }
                        L0001_puc_ObjectNames++;
                }
                G2230_ &= L3357_i_;
                L0001_puc_ObjectNames++;
        }
#endif
#ifdef MEDIA724_I34E_I34M_A36M_A31M_A33M_A35E_A35M
        G0352_apc_ObjectNames = (unsigned char**)M533_F0468_MEMORY_Allocate((long)(C199_OBJECT_NAME_COUNT * sizeof(char*)), C1_ALLOCATION_PERMANENT, MASK0x0400_MEMREQ);
#endif
#ifdef MEDIA060_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_I34E_A31E_F31E
        L0001_puc_ObjectNames = (unsigned char*)M533_F0468_MEMORY_Allocate((long)(F0494_MEMORY_GetGraphicDecompressedByteCount(M564_GRAPHIC_OBJECT_NAMES) + C199_OBJECT_NAME_COUNT), C1_ALLOCATION_PERMANENT, MASK0x0400_MEMREQ);
        L0002_puc_Graphic = M533_F0468_MEMORY_Allocate((long)(C199_OBJECT_NAME_COUNT * C014_OBJECT_NAME_MAXIMUM_LENGTH), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP, MASK0x0400_MEMREQ);
#endif
#ifdef MEDIA569_F20J_X30J_P20JA_P20JB
        L0001_puc_ObjectNames = (unsigned char*)F0468_MEMORY_Allocate((long)F0494_MEMORY_GetGraphicDecompressedByteCount(M564_GRAPHIC_OBJECT_NAMES), C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA735_I34M_A36M_A31M_A33M_A35E_A35M
        L0001_puc_ObjectNames = (unsigned char*)M533_F0468_MEMORY_Allocate((long)F0494_MEMORY_GetGraphicDecompressedByteCount(M564_GRAPHIC_OBJECT_NAMES), C1_ALLOCATION_PERMANENT, MASK0x0400_MEMREQ);
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | M564_GRAPHIC_OBJECT_NAMES, L0002_puc_Graphic); /* BUG0_01 Coding error without consequence. Function call with wrong number of parameters. It should be called with 4 parameters. No consequence because the missing parameters are not used when MASK0x8000_NOT_EXPANDED is specified */
#endif
#ifdef MEDIA702_I34E_A31E_F31E
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | MASK0x4000_DO_NOT_COPY_DIMENSIONS | M564_GRAPHIC_OBJECT_NAMES, L0002_puc_Graphic);
#endif
#ifdef MEDIA569_F20J_X30J_P20JA_P20JB
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | MASK0x4000_DO_NOT_COPY_DIMENSIONS | M564_GRAPHIC_OBJECT_NAMES, L0001_puc_ObjectNames, 0, 0);
#endif
#ifdef MEDIA487_F20E
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | MASK0x4000_DO_NOT_COPY_DIMENSIONS | M564_GRAPHIC_OBJECT_NAMES, L0002_puc_Graphic, 0, 0);
#endif
#ifdef MEDIA735_I34M_A36M_A31M_A33M_A35E_A35M
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | MASK0x4000_DO_NOT_COPY_DIMENSIONS | M564_GRAPHIC_OBJECT_NAMES, L0001_puc_ObjectNames);
#endif
#ifdef MEDIA060_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_I34E_A31E_F31E
        for (L0003_ui_ObjectNameIndex = 0; L0003_ui_ObjectNameIndex < C199_OBJECT_NAME_COUNT; L0003_ui_ObjectNameIndex++) {
                G0352_apc_ObjectNames[L0003_ui_ObjectNameIndex] = L0001_puc_ObjectNames;
                while (!(*L0002_puc_Graphic & 0x80)) { /* The last character of each object name has bit 7 set */
                        *L0001_puc_ObjectNames++ = *L0002_puc_Graphic++; /* Write characters until last character is found */
                }
                *L0001_puc_ObjectNames++ = *L0002_puc_Graphic++ & 0x7F; /* Write last character without bit 7 */
                *L0001_puc_ObjectNames++ = '\0'; /* Write string termination */
        }
        F0469_MEMORY_FreeAtHeapTop((long)(C199_OBJECT_NAME_COUNT * C014_OBJECT_NAME_MAXIMUM_LENGTH));
#endif
#ifdef MEDIA574_F20J_X30J_P20JA_P20JB_I34M_A36M_A31M_A33M_A35E_A35M
        for (L0003_ui_ObjectNameIndex = 0; L0003_ui_ObjectNameIndex < C199_OBJECT_NAME_COUNT; L0003_ui_ObjectNameIndex++) {
                G0352_apc_ObjectNames[L0003_ui_ObjectNameIndex] = L0001_puc_ObjectNames;
                while (*L0001_puc_ObjectNames++);
        }
#endif
}

int16_t F0032_OBJECT_GetType(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0039_T_Thing)
#endif
THING P0039_T_Thing FINAL_SEPARATOR
{
        REGISTER int16_t L0004_i_Multiple;
#define AL0004_i_ObjectInfoIndex L0004_i_Multiple
#define AL0004_i_ObjectType      L0004_i_Multiple


        if (P0039_T_Thing == C0xFFFF_THING_NONE) {
                return C0xFFFF_ICON_NONE;
        }
        AL0004_i_ObjectInfoIndex = F0141_DUNGEON_GetObjectInfoIndex(P0039_T_Thing);
#ifdef MEDIA069_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_F31E_F31J_X31J_P31J
        if (AL0004_i_ObjectInfoIndex != -1) {
#endif
#ifdef MEDIA488_F20E_F20J
        if (AL0004_i_ObjectInfoIndex != 0xFFFF) {
#endif
                AL0004_i_ObjectType = G0237_as_Graphic559_ObjectInfo[AL0004_i_ObjectInfoIndex].Type;
        }
        return AL0004_i_ObjectType;
}

int16_t F0033_OBJECT_GetIconIndex(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0040_T_Thing)
#endif
THING P0040_T_Thing FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0005_i_IconIndex;
#endif
        REGISTER JUNK* L0006_ps_Junk;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0005_i_IconIndex;
#endif


#ifdef MEDIA069_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_F31E_F31J_X31J_P31J
        if ((L0005_i_IconIndex = F0032_OBJECT_GetType(P0040_T_Thing)) != -1) {
#endif
#ifdef MEDIA488_F20E_F20J
        if ((L0005_i_IconIndex = F0032_OBJECT_GetType(P0040_T_Thing)) != C0xFFFF_ICON_NONE) {
#endif
                if (((L0005_i_IconIndex < C032_ICON_WEAPON_DAGGER) && (L0005_i_IconIndex >= C000_ICON_JUNK_COMPASS_NORTH)) ||
                    ((L0005_i_IconIndex >= C148_ICON_POTION_MA_POTION_MON_POTION) && (L0005_i_IconIndex <= C163_ICON_POTION_WATER_FLASK)) ||
                    (L0005_i_IconIndex == C195_ICON_POTION_EMPTY_FLASK)) {
                        L0006_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(P0040_T_Thing);
                        switch (L0005_i_IconIndex) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE jmp */
                                case C000_ICON_JUNK_COMPASS_NORTH:
                                        L0005_i_IconIndex += G0308_i_PartyDirection;
                                        break;
                                case C004_ICON_WEAPON_TORCH_UNLIT:
                                        if (((WEAPON*)L0006_ps_Junk)->Lit) {
                                                L0005_i_IconIndex += G0029_auc_Graphic562_ChargeCountToTorchType[((WEAPON*)L0006_ps_Junk)->ChargeCount];
                                        }
                                        break;
                                case C030_ICON_SCROLL_SCROLL_OPEN:
#ifdef PC_FIX_CODE_SIZE
        L0005_i_IconIndex++;
#endif
                                        if (((SCROLL*)L0006_ps_Junk)->Closed) {
                                                L0005_i_IconIndex++; /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE opt */
                                        }
                                        break;
                                case C008_ICON_JUNK_WATER:
                                case C012_ICON_JUNK_ILLUMULET_UNEQUIPPED:
                                case C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED:
#ifdef PC_FIX_CODE_SIZE
        L0005_i_IconIndex++;
#endif
                                        if (L0006_ps_Junk->ChargeCount) {
                                                L0005_i_IconIndex++; /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE opt */
                                        }
                                        break;
                                case C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY:
                                case C014_ICON_WEAPON_FLAMITT_EMPTY:
                                case C018_ICON_WEAPON_STORMRING_EMPTY:
                                case C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY:
                                case C016_ICON_WEAPON_EYE_OF_TIME_EMPTY:
                                case C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY:
                                        if (((WEAPON*)L0006_ps_Junk)->ChargeCount) {
                                                L0005_i_IconIndex++;
                                        }
                                        break;
                        }
                }
        }
        return L0005_i_IconIndex;
}

void F0034_OBJECT_DrawLeaderHandObjectName(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0041_T_Thing)
#endif
REGISTER THING P0041_T_Thing FINAL_SEPARATOR
{
        REGISTER char* L0008_pc_ObjectName;
        REGISTER JUNK* L0009_ps_Junk;
        REGISTER int16_t L0007_i_IconIndex;
        char L0010_ac_ObjectName[16];


#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0035_OBJECT_ClearLeaderHandObjectName();
#endif
        L0007_i_IconIndex = F0033_OBJECT_GetIconIndex(P0041_T_Thing);
        if (L0007_i_IconIndex == C147_ICON_JUNK_CHAMPION_BONES) {
                L0009_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(P0041_T_Thing);
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                if (G2000_Language == C1_FRENCH) {
#endif
#ifdef MEDIA262_S13FA_S13FB_A20F_I34M_A36M_A31M_A33M_A35M /* CHANGE5_00_LOCALIZATION Translation to French language */
                        M547_STRCPY(L0010_ac_ObjectName, G0352_apc_ObjectNames[L0007_i_IconIndex]); /* No space is added between the strings as the space is included directly in the object name */
                        M545_STRCAT(L0010_ac_ObjectName, M516_CHAMPIONS[L0009_ps_Junk->ChargeCount].Name);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                } 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 */ /* CHANGE7_07_LOCALIZATION Translation to English language (differences with original Dungeon Master) */
                        M547_STRCPY(L0010_ac_ObjectName, M516_CHAMPIONS[L0009_ps_Junk->ChargeCount].Name);
#endif
#ifdef MEDIA004_S10EA_S10EB_S11E_S12E_S12G /* CHANGE5_00_LOCALIZATION Translation to French language */
                        M545_STRCAT(L0010_ac_ObjectName, " ");
#endif
#ifdef MEDIA316_S20E_S21E_A20ED_A20E_A20G_A21E_A22E_A22G_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M
/* BUG7_00 When holding a champion's dead bones in hand, a space character is missing between the champion name and the object name */
#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 */ /* CHANGE7_07_LOCALIZATION Translation to English language (differences with original Dungeon Master) */
                        M545_STRCAT(L0010_ac_ObjectName, M772_CAST_PC(G0352_apc_ObjectNames[L0007_i_IconIndex]));
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                }
#endif
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
                L0010_ac_ObjectName[0] = 0x1B;
                M547_STRCPY(&L0010_ac_ObjectName[1], M516_CHAMPIONS[L0009_ps_Junk->ChargeCount].Name); /* BUG7_00 When holding a champion's dead bones in hand, a space character is missing between the champion name and the object name */
#endif
                L0008_pc_ObjectName = L0010_ac_ObjectName;
        } else {
                L0008_pc_ObjectName = (char*)G0352_apc_ObjectNames[L0007_i_IconIndex];
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M721_F0041_TEXT_PrintWithTrailingSpaces(G0348_Bitmap_Screen, C160_BYTE_WIDTH_SCREEN, 233, 37, C04_COLOR_CYAN, C00_COLOR_BLACK, L0008_pc_ObjectName, C014_OBJECT_NAME_MAXIMUM_LENGTH, C200_HEIGHT_SCREEN);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        M722_F0768_TEXT_PrintToZoneWithTrailingSpaces(G0348_Bitmap_Screen, G2071_C320_ScreenPixelWidth, C017_ZONE_LEADER_HAND_OBJECT_NAME, C04_COLOR_CYAN, C00_COLOR_BLACK, L0008_pc_ObjectName, C014_OBJECT_NAME_MAXIMUM_LENGTH, G2072_C200_ScreenPixelHeight);
#endif
}

void F0035_OBJECT_ClearLeaderHandObjectName(
#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
        M524_FillScreenBox(G0028_ai_Graphic562_Box_LeaderHandObjectName, C00_COLOR_BLACK);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0733_FillZoneByIndex(C017_ZONE_LEADER_HAND_OBJECT_NAME, C00_COLOR_BLACK);
#endif
}

void F0036_OBJECT_ExtractIconFromBitmap(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0042_ui_IconIndex, P0043_pl_Bitmap)
#endif
REGISTER unsigned int16_t P0042_ui_IconIndex SEPARATOR
REGISTER long*            P0043_pl_Bitmap    FINAL_SEPARATOR
{
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        long* L3358_pl_;
#endif
        REGISTER unsigned int16_t L0011_ui_Counter;
        REGISTER long* L0012_pl_Bitmap_Icon;
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned char L1568_auc_Box[4];
#endif


#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        L3358_pl_ = P0043_pl_Bitmap;
        M100_PIXEL_WIDTH(L3358_pl_) = G2075_ObjectIconWidth;
        M101_PIXEL_HEIGHT(L3358_pl_) = G2076_ObjectIconHeight;
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        M100_PIXEL_WIDTH(P0043_pl_Bitmap) = G2075_ObjectIconWidth;
        M101_PIXEL_HEIGHT(P0043_pl_Bitmap) = G2076_ObjectIconHeight;
#endif
        for (L0011_ui_Counter = 0; L0011_ui_Counter < 7; L0011_ui_Counter++) {
                if (G0026_ai_Graphic562_IconGraphicFirstIconIndex[L0011_ui_Counter] > P0042_ui_IconIndex)
                        break;
        }
        L0012_pl_Bitmap_Icon = (long*)F0489_MEMORY_GetNativeBitmapOrGraphic(C042_GRAPHIC_OBJECT_ICONS_000_TO_031 + --L0011_ui_Counter);
        P0042_ui_IconIndex -= G0026_ai_Graphic562_IconGraphicFirstIconIndex[L0011_ui_Counter];
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
        L0012_pl_Bitmap_Icon += (((P0042_ui_IconIndex & 0x0FF0) << 5) + ((P0042_ui_IconIndex & 0x000F) << 1));
        for (L0011_ui_Counter = 0; L0011_ui_Counter < 16; L0011_ui_Counter++) {
                *P0043_pl_Bitmap++ = *L0012_pl_Bitmap_Icon++;
                *P0043_pl_Bitmap++ = *L0012_pl_Bitmap_Icon;
                L0012_pl_Bitmap_Icon += 31;
        }
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0578_B_UseByteBoxCoordinates = C1_TRUE;
        M770_BOX_TOP(L1568_auc_Box) = 0;
        M768_BOX_LEFT(L1568_auc_Box) = 0;
        M771_BOX_BOTTOM(L1568_auc_Box) = 15;
        M769_BOX_RIGHT(L1568_auc_Box) = 15;
        F0132_VIDEO_Blit(L0012_pl_Bitmap_Icon, P0043_pl_Bitmap, L1568_auc_Box, (P0042_ui_IconIndex & 0x000F) << 4, P0042_ui_IconIndex & 0x0FF0, 128, 8, CM1_COLOR_NO_TRANSPARENCY, G1074_ai_IconGraphicHeight[L0011_ui_Counter], 16);
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        F0654_Call_F0132_VIDEO_Blit(L0012_pl_Bitmap_Icon, L3358_pl_, G2007_ai_XYZ, (P0042_ui_IconIndex & 0x000F) * G2076_ObjectIconHeight, (P0042_ui_IconIndex >> 4) * G2075_ObjectIconWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        F0654_Call_F0132_VIDEO_Blit(M772_CAST_PC(L0012_pl_Bitmap_Icon), M772_CAST_PC(P0043_pl_Bitmap), G2007_ai_XYZ, (P0042_ui_IconIndex & 0x000F) * G2076_ObjectIconHeight, (P0042_ui_IconIndex >> 4) * G2075_ObjectIconWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
}

#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
void F0037_OBJECT_DrawIconToScreen(
P0044_i_IconIndex, P0045_i_X, P0046_i_Y)
int16_t P0044_i_IconIndex SEPARATOR
int16_t P0045_i_X         SEPARATOR
int16_t P0046_i_Y         FINAL_SEPARATOR
{
        unsigned char* L0013_puc_Bitmap_Icon;
        int16_t L0014_ai_Box[4];


        L0013_puc_Bitmap_Icon = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(16, 16), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        M769_BOX_RIGHT(L0014_ai_Box) = (M768_BOX_LEFT(L0014_ai_Box) = P0045_i_X) + 15;
        M771_BOX_BOTTOM(L0014_ai_Box) = (M770_BOX_TOP(L0014_ai_Box) = P0046_i_Y) + 15;
        F0036_OBJECT_ExtractIconFromBitmap(P0044_i_IconIndex, L0013_puc_Bitmap_Icon);
        M520_F0021_MAIN_BlitToScreen(L0013_puc_Bitmap_Icon, L0014_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
void F0618_LoadZone(
int16_t  P2053_i_ZoneIndex SEPARATOR
int16_t* P2054_pi_XYZ      FINAL_SEPARATOR
{
        int16_t L3359_i_X;
        int16_t L3360_i_Y;


        L3359_i_X = G2075_ObjectIconWidth;
        L3360_i_Y = G2076_ObjectIconHeight;
        F0635_(NULL, P2054_pi_XYZ, P2053_i_ZoneIndex, &L3359_i_X, &L3360_i_Y);
}

void F0619_GetSlotBoxBorderCoordinates(
int16_t           P2055_i_ZoneIndex SEPARATOR
REGISTER int16_t* P2056_pi_XYZ      FINAL_SEPARATOR
{
        F0618_LoadZone(P2055_i_ZoneIndex, P2056_pi_XYZ);
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        M704_ZONE_LEFT(P2056_pi_XYZ) -= G2077_C1_TextMargin;
        M706_ZONE_TOP(P2056_pi_XYZ) -= G2077_C1_TextMargin;
        M705_ZONE_RIGHT(P2056_pi_XYZ) += G2077_C1_TextMargin;
        M707_ZONE_BOTTOM(P2056_pi_XYZ) += G2077_C1_TextMargin;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0628_AddZoneMargin(P2056_pi_XYZ, G2077_C1_TextMargin, G2077_C1_TextMargin);
#endif
}
#endif

void F0038_OBJECT_DrawIconInSlotBox(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0047_ui_SlotBoxIndex, P0048_IconIndex)
#endif
REGISTER unsigned int16_t P0047_ui_SlotBoxIndex SEPARATOR
#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
REGISTER int16_t          P0048_IconIndex    FINAL_SEPARATOR
#endif
#ifdef MEDIA488_F20E_F20J
REGISTER unsigned int16_t P0048_IconIndex    FINAL_SEPARATOR
#endif
#ifdef MEDIA670_F31E_F31J
REGISTER int16_t P0048_IconIndex    FINAL_SEPARATOR
#endif
{
        REGISTER unsigned int16_t L0015_ui_IconGraphicIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER SLOT_BOX* L0017_ps_SlotBox;
#endif
        REGISTER unsigned char* L0018_puc_Bitmap_Icons;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0019_ai_Box[4];
        unsigned char* L0020_puc_Bitmap_Destination;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER SLOT_BOX* L0017_ps_SlotBox;
        REGISTER unsigned char* L0020_puc_Bitmap_Destination;
#endif
        REGISTER int16_t L0016_i_ByteWidth;
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1569_i_Height;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        register int16_t L1569_i_Height;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L3361_ai_XYZ[4];
#endif


        L0017_ps_SlotBox = &G0030_as_Graphic562_SlotBoxes[P0047_ui_SlotBoxIndex];
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L0017_ps_SlotBox->IconIndex = P0048_IconIndex;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        if ((L0017_ps_SlotBox->IconIndex = P0048_IconIndex) == C0xFFFF_ICON_NONE)
#endif
#ifdef MEDIA531_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
        if (P0048_IconIndex == C0xFFFF_ICON_NONE)
#endif
#ifdef MEDIA670_F31E_F31J
        if ((int16_t)P0048_IconIndex == -1)
#endif
                return;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M769_BOX_RIGHT(L0019_ai_Box) = (M768_BOX_LEFT(L0019_ai_Box) = L0017_ps_SlotBox->X) + 15;
        M771_BOX_BOTTOM(L0019_ai_Box) = (M770_BOX_TOP(L0019_ai_Box) = L0017_ps_SlotBox->Y) + 15;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0618_LoadZone(L0017_ps_SlotBox->ZoneIndex, L3361_ai_XYZ);
#endif
        for (L0015_ui_IconGraphicIndex = 0; L0015_ui_IconGraphicIndex < 7; L0015_ui_IconGraphicIndex++) {
#ifdef MEDIA045_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_X31J_P31J
                if (G0026_ai_Graphic562_IconGraphicFirstIconIndex[L0015_ui_IconGraphicIndex] > P0048_IconIndex)
#endif
#ifdef MEDIA670_F31E_F31J
                if (G0026_ai_Graphic562_IconGraphicFirstIconIndex[L0015_ui_IconGraphicIndex] > P0048_IconIndex)
#endif
                        break;
        }
        L0015_ui_IconGraphicIndex--;
        L0018_puc_Bitmap_Icons = F0489_MEMORY_GetNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + C042_GRAPHIC_OBJECT_ICONS_000_TO_031);
        P0048_IconIndex -= G0026_ai_Graphic562_IconGraphicFirstIconIndex[L0015_ui_IconGraphicIndex];
        if (P0047_ui_SlotBoxIndex >= C08_SLOT_BOX_INVENTORY_FIRST_SLOT) {
                L0020_puc_Bitmap_Destination = G0296_puc_Bitmap_Viewport;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L0016_i_ByteWidth = C112_BYTE_WIDTH_VIEWPORT;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0016_i_ByteWidth = G2073_C224_ViewportPixelWidth;
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L1569_i_Height = 136;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
                L1569_i_Height = G2074_C136_ViewportHeight;
#endif
        } else {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L0020_puc_Bitmap_Destination = (unsigned char*)G0348_Bitmap_Screen;
                L0016_i_ByteWidth = C160_BYTE_WIDTH_SCREEN;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0020_puc_Bitmap_Destination = G0348_Bitmap_Screen;
                L0016_i_ByteWidth = G2071_C320_ScreenPixelWidth;
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L1569_i_Height = 200;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
                L1569_i_Height = G2072_C200_ScreenPixelHeight;
#endif
        }
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
        G0578_B_UseByteBoxCoordinates = C0_FALSE, F0132_VIDEO_Blit(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_ai_Box, (P0048_IconIndex & 0x000F) << 4, P0048_IconIndex & 0x0FF0, C128_BYTE_WIDTH, L0016_i_ByteWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0578_B_UseByteBoxCoordinates = C0_FALSE, F0132_VIDEO_Blit(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_ai_Box, (P0048_IconIndex & 0x000F) << 4, P0048_IconIndex & 0x0FF0, C128_BYTE_WIDTH, L0016_i_ByteWidth, CM1_COLOR_NO_TRANSPARENCY, G1074_ai_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Height);
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        F0132_VIDEO_Blit(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L3361_ai_XYZ, (P0048_IconIndex & 0x000F) * G2075_ObjectIconWidth, ((P0048_IconIndex & 0x0FF0) >> 4) * G2076_ObjectIconHeight, M100_PIXEL_WIDTH(L0018_puc_Bitmap_Icons), L0016_i_ByteWidth, CM1_COLOR_NO_TRANSPARENCY, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA543_F20E_F20J_X30J_F31E_F31J_X31J
        F0132_VIDEO_Blit(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L3361_ai_XYZ, (P0048_IconIndex & 0x000F) * G2075_ObjectIconWidth, ((P0048_IconIndex & 0x0FF0) >> 4) * G2076_ObjectIconHeight, M100_PIXEL_WIDTH(L0018_puc_Bitmap_Icons), L0016_i_ByteWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        F0132_VIDEO_Blit(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L3361_ai_XYZ, (P0048_IconIndex & 0x000F) * G2075_ObjectIconWidth, ((P0048_IconIndex & 0x0FF0) >> 4) * G2076_ObjectIconHeight, M100_PIXEL_WIDTH(L0018_puc_Bitmap_Icons), L0016_i_ByteWidth, CM1_COLOR_NO_TRANSPARENCY, M101_PIXEL_HEIGHT(L0018_puc_Bitmap_Icons), L1569_i_Height);
#endif
}

int16_t F0039_OBJECT_GetIconIndexInSlotBox(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0049_ui_SlotBoxIndex)
#endif
unsigned int16_t P0049_ui_SlotBoxIndex FINAL_SEPARATOR
{
        return G0030_as_Graphic562_SlotBoxes[P0049_ui_SlotBoxIndex].IconIndex;
}
#endif
