#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 MEDIA520_F20E_F20J_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J
char* G0417_apc_BaseSkillNames[4] = { "FIGHTER", "NINJA", "PRIEST", "WIZARD" };
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
int16_t G2015_ai_BaseSkillNames[4] = { 0, 1, 3, 2 };
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN G2149_;
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN G2016_ai_SkillRecentlyUpgraded[4][4];
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
BOOLEAN G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
unsigned char G2362_auc_PaletteChanges_Invisibility[16] = { 0, 1, 2, 0, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15 };
#endif


#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void F0621_ClearChampionIconBox(
int16_t P2057_i_ChampionIndex FINAL_SEPARATOR
{
        F0733_FillZoneByIndex(P2057_i_ChampionIndex + C113_ZONE_CHAMPION_ICON_TOP_LEFT, C00_COLOR_BLACK);
}

unsigned char* F0622_PrepareChampionIconBitmap(
unsigned char* P2058_pc_ChampionIconBitmap SEPARATOR
int16_t        P2059_i_ChampionIndex       FINAL_SEPARATOR
{
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        int16_t L2250_ai_XYZ[4];
#endif


        M100_PIXEL_WIDTH(P2058_pc_ChampionIconBitmap) = G2080_C19_ChampionIconWidth;
        M101_PIXEL_HEIGHT(P2058_pc_ChampionIconBitmap) = G2081_C14_ChampionIconHeight;
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        M704_ZONE_LEFT(L2250_ai_XYZ) = 0;
        M705_ZONE_RIGHT(L2250_ai_XYZ) = G2080_C19_ChampionIconWidth - 1;
        M706_ZONE_TOP(L2250_ai_XYZ) = 0;
        M707_ZONE_BOTTOM(L2250_ai_XYZ) = G2081_C14_ChampionIconHeight - 1;
        F0134_VIDEO_FillBitmap(M772_CAST_PC(P2058_pc_ChampionIconBitmap), G0046_auc_Graphic562_ChampionColor[P2059_i_ChampionIndex], G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight);
#endif
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0134_VIDEO_FillBitmap(M772_CAST_PC(P2058_pc_ChampionIconBitmap), G0407_s_Party.Event71Count_Invisibility ? C01_COLOR_DARK_GRAY : G0046_auc_Graphic562_ChampionColor[P2059_i_ChampionIndex], G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        F0654_Call_F0132_VIDEO_Blit(M772_CAST_PC(F0489_MEMORY_GetNativeBitmapOrGraphic(C028_GRAPHIC_CHAMPION_ICONS)), M772_CAST_PC(P2058_pc_ChampionIconBitmap), L2250_ai_XYZ, M026_CHAMPION_ICON_INDEX(M516_CHAMPIONS[P2059_i_ChampionIndex].Direction, G0308_i_PartyDirection) * G2080_C19_ChampionIconWidth, 0, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0654_Call_F0132_VIDEO_Blit(M772_CAST_PC(F0489_MEMORY_GetNativeBitmapOrGraphic(C028_GRAPHIC_CHAMPION_ICONS)), M772_CAST_PC(P2058_pc_ChampionIconBitmap), F0627_GetTemporaryZoneInitializedFromDimensions(G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight), M026_CHAMPION_ICON_INDEX(M516_CHAMPIONS[P2059_i_ChampionIndex].Direction, G0308_i_PartyDirection) * G2080_C19_ChampionIconWidth, 0, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA716_I34E_I34M_A36M
        F0134_VIDEO_FillBitmap(P2058_pc_ChampionIconBitmap, G0407_s_Party.Event71Count_Invisibility ? C01_COLOR_DARK_GRAY : G0046_auc_Graphic562_ChampionColor[P2059_i_ChampionIndex], G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight);
        F0654_Call_F0132_VIDEO_Blit(F0489_MEMORY_GetNativeBitmapOrGraphic(C028_GRAPHIC_CHAMPION_ICONS), P2058_pc_ChampionIconBitmap, F0627_GetTemporaryZoneInitializedFromDimensions(G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight), M026_CHAMPION_ICON_INDEX(M516_CHAMPIONS[P2059_i_ChampionIndex].Direction, G0308_i_PartyDirection) * G2080_C19_ChampionIconWidth, 0, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (G0407_s_Party.Event71Count_Invisibility) {
                F0662_ApplyPaletteChanges(M772_CAST_PC(P2058_pc_ChampionIconBitmap), G2362_auc_PaletteChanges_Invisibility);
        }
#endif
        return P2058_pc_ChampionIconBitmap;
}
#endif

STATICFUNCTION void F0287_CHAMPION_DrawBarGraphs(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0605_i_ChampionIndex)
#endif
int16_t P0605_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
        REGISTER int16_t L0841_i_Multiple;
#define AL0841_i_ColorBits3And2 L0841_i_Multiple
#define AL0841_i_BarGraphIndex  L0841_i_Multiple
        REGISTER int16_t L0842_i_Multiple;
#define AL0842_i_BarGraphIndex  L0842_i_Multiple
#define AL0842_i_ColorBits1And0 L0842_i_Multiple
#define AL0842_l_BarGraphHeight L0842_i_Multiple
        REGISTER long L0843_l_Multiple;
#define AL0843_l_BarGraphHeight        L0843_l_Multiple
#define AL0843_l_BarGraphMaskInverted2 L0843_l_Multiple
        REGISTER int16_t L0844_i_BarGraphMaskInverted1;
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        int16_t L6191_i_Unreferenced;
#endif
        REGISTER CHAMPION* L0845_ps_Multiple;
#define AL0845_ps_Champion       L0845_ps_Multiple
#define AL0845_pi_BarGraphHeight L0845_ps_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER char* L0846_pc_VideoAddress;
        int16_t L0847_ai_BarGraphHeights[3];
        int16_t L0848_i_LastBarGraph;
#endif
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1640_ai_Box[4];
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L2251_i_Counter;
        REGISTER int16_t L2252_i_BoxIndex;
#endif
#ifdef MEDIA537_F20E_F20J_X30J_P20JA_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        REGISTER int16_t L2253_i_Height;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2254_i_Bars[3][2];
        int16_t L2004_ai_XYZBlankBar[4];
        int16_t L2005_ai_XYZColoredBar[4];
#endif


        AL0845_ps_Champion = &M516_CHAMPIONS[P0605_i_ChampionIndex];
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        AL0842_i_BarGraphIndex = 0;
        if (AL0845_ps_Champion->CurrentHealth > 0) {
                AL0843_l_BarGraphHeight = (((long)AL0845_ps_Champion->CurrentHealth << 10) * 25) / AL0845_ps_Champion->MaximumHealth;
                if (AL0843_l_BarGraphHeight & 0x000003FF) {
                        L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = (AL0843_l_BarGraphHeight >> 10) + 1;
                } else {
                        L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = (AL0843_l_BarGraphHeight >> 10);
                }
        } else {
                L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = 0;
        }
        if (AL0845_ps_Champion->CurrentStamina > 0) {
                AL0843_l_BarGraphHeight = (((long)AL0845_ps_Champion->CurrentStamina << 10) * 25) / AL0845_ps_Champion->MaximumStamina;
                if (AL0843_l_BarGraphHeight & 0x000003FF) {
                        L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = (AL0843_l_BarGraphHeight >> 10) + 1;
                } else {
                        L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = (AL0843_l_BarGraphHeight >> 10);
                }
        } else {
                L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex++] = 0;
        }
        if (AL0845_ps_Champion->CurrentMana > 0) {
                if (AL0845_ps_Champion->CurrentMana > AL0845_ps_Champion->MaximumMana) {
                        L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex] = 25;
                } else {
                        AL0843_l_BarGraphHeight = (((long)AL0845_ps_Champion->CurrentMana << 10) * 25) / AL0845_ps_Champion->MaximumMana;
                        if (AL0843_l_BarGraphHeight & 0x000003FF) {
                                L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex] = (AL0843_l_BarGraphHeight >> 10) + 1;
                        } else {
                                L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex] = (AL0843_l_BarGraphHeight >> 10);
                        }
                }
        } else {
                L0847_ai_BarGraphHeights[AL0842_i_BarGraphIndex] = 0;
        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L2254_i_Bars[0][0] = AL0845_ps_Champion->CurrentHealth;
        L2254_i_Bars[0][1] = AL0845_ps_Champion->MaximumHealth;
        L2254_i_Bars[1][0] = AL0845_ps_Champion->CurrentStamina;
        L2254_i_Bars[1][1] = AL0845_ps_Champion->MaximumStamina;
        L2254_i_Bars[2][0] = AL0845_ps_Champion->CurrentMana;
        L2254_i_Bars[2][1] = AL0845_ps_Champion->MaximumMana;
#endif
        F0077_MOUSE_EnableScreenUpdate_CPSE();
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        asm {
                        movea.l G0348_Bitmap_Screen(A4),A0
                        lea     320(A0),A0                                              /* Address of the first pixel on the third line on screen (320 bytes = 640 pixels = 2 lines). Bar graphs are never drawn above this line */
                        move.w  P0605_i_ChampionIndex(A6),D1
                        ext.l   D1
                        cmp.w   #3,D1
                        bcs.s   T0287014                                                /* If the specified champion index is 0, 1 or 2 */
                        move.l  #0x80000000,AL0842_i_ColorBits1And0
                        move.l  AL0842_i_ColorBits1And0,AL0841_i_ColorBits3And2
                        addq.l  #1,AL0841_i_ColorBits3And2
                        bra.s   T0287017                                                /* Champion #3, Color #14: AL0841_i_ColorBits3And2 = 0x80000001 AL0842_i_ColorBits1And0 = 0x80000000 */
                T0287014:
                        cmp.w   #2,D1
                        bcs.s   T0287015                                                /* If the specified champion index is 0 or 1 */
                        moveq   #0,AL0842_i_ColorBits1And0
                        move.l  #0x80000000,AL0841_i_ColorBits3And2
                        bra.s   T0287017                                                /* Champion #2, Color #08: AL0841_i_ColorBits3And2 = 0x80000000 AL0842_i_ColorBits1And0 = 0x00000000 */
                T0287015:
                        cmp.w   #1,D1
                        bcs.s   T0287016                                                /* If the specified champion index is 0 */
                        move.l  #0x80000001,AL0842_i_ColorBits1And0
                        move.l  AL0842_i_ColorBits1And0,AL0841_i_ColorBits3And2
                        subq.l  #1,AL0841_i_ColorBits3And2
                        bra.s   T0287017                                                /* Champion #1, Color #11: AL0841_i_ColorBits3And2 = 0x80000000 AL0842_i_ColorBits1And0 = 0x80000001 */
                T0287016:
                        move.l  #0x80000001,AL0842_i_ColorBits1And0
                        moveq   #1,AL0841_i_ColorBits3And2                              /* Champion #0, Color #07: AL0841_i_ColorBits3And2 = 0x00000001 AL0842_i_ColorBits1And0 = 0x80000001 */
                T0287017:
                        add.w   D1,D1
                        move.w  D1,D2
                        add.w   D1,D1
                        add.w   D2,D1
                        move.w  D1,L0848_i_LastBarGraph(A6)                             /* 6 * Champion index */
                        addq.w  #4,L0848_i_LastBarGraph(A6)
                        lea     L0847_ai_BarGraphHeights(A6),AL0845_pi_BarGraphHeight
                T0287018_Loop:
                        movea.l A0,L0846_pc_VideoAddress
                        lea     G0056_aaui_Graphic562_BarGraphByteOffsets(A4),A1
                        adda.w  0(A1,D1.w),L0846_pc_VideoAddress
                        lsl.w   #1,D1
                        lea     G0055_aaaui_Graphic562_BarGraphMasks(A4),A1
/* G0055_aaaui_Graphic562_BarGraphMasks contains the following 16 bits masks: 3 pairs of masks (for each bar graph) for each champion:
0000000000000011  1100000000000000        0000011110000000  0000000000000000        0000000000001111  0000000000000000
0001111000000000  0000000000000000        0000000000111100  0000000000000000        0111100000000000  0000000000000000
0000000011110000  0000000000000000        0000000000000001  1110000000000000        0000001111000000  0000000000000000
0000000000000111  1000000000000000        0000111100000000  0000000000000000        0000000000011110  0000000000000000 */
                        move.w  0(A1,D1.w),D2
                        move.w  2(A1,D1.w),D3
                        move.w  D2,L0844_i_BarGraphMaskInverted1
                        not.w   L0844_i_BarGraphMaskInverted1
                        move.w  D3,AL0843_l_BarGraphMaskInverted2
                        not.w   D5
                        lsr.w   #1,D1
                        move.w  (AL0845_pi_BarGraphHeight)+,D0                           /* Height of bar graph to draw */
                        jsr     S0287_CHAMPION_DrawChampionBarGraphs_Subroutine(PC)
                        cmp.w   L0848_i_LastBarGraph(A6),D1
                        beq     T0287030                                                /* Branch if there are no more bar graphs to draw */
                        addq.w  #2,D1                                                   /* Proceed to next bar graph */
                        bra.s   T0287018_Loop
                S0287_CHAMPION_DrawChampionBarGraphs_Subroutine:
                        move.w  D1,-(A7)
                        move.w  #24,D1                                                  /* Index of bar graph line to draw */
                T0287020_Loop:
                        cmp.w   D1,D0
                        bhi.s   T0287021                                                /* If height of bar graph to draw > line being drawn (if a bar graph line should be drawn) */
                        and.w   L0844_i_BarGraphMaskInverted1,(L0846_pc_VideoAddress)   /* Clear bit 0 of each pixel. Set bits for color #12 */
                        and.w   AL0843_l_BarGraphMaskInverted2,8(L0846_pc_VideoAddress)  /* Clear bit 0 of each pixel */
                        and.w   L0844_i_BarGraphMaskInverted1,2(L0846_pc_VideoAddress)  /* Clear bit 1 of each pixel */
                        and.w   AL0843_l_BarGraphMaskInverted2,10(L0846_pc_VideoAddress) /* Clear bit 1 of each pixel */
                        or.w    D2,4(L0846_pc_VideoAddress)                             /* Set bit 2 of each pixel */
                        or.w    D3,12(L0846_pc_VideoAddress)                            /* Set bit 2 of each pixel */
                        or.w    D2,6(L0846_pc_VideoAddress)                             /* Set bit 3 of each pixel */
                        or.w    D3,14(L0846_pc_VideoAddress)                            /* Set bit 3 of each pixel */
                        bra.s   T0287029
                T0287021:
                        tst.w   AL0842_i_ColorBits1And0                                  /* Test bit 0 (Color bit 0) */
                        beq.s   T0287022
                        or.w    D2,(L0846_pc_VideoAddress)                              /* Set bit 0 of each pixel */
                        or.w    D3,8(L0846_pc_VideoAddress)                             /* Set bit 0 of each pixel */
                        bra.s   T0287023
                T0287022:
                        and.w   L0844_i_BarGraphMaskInverted1,(L0846_pc_VideoAddress)   /* Clear bit 0 of each pixel */
                        and.w   AL0843_l_BarGraphMaskInverted2,8(L0846_pc_VideoAddress)  /* Clear bit 0 of each pixel */
                T0287023:
                        tst.l   AL0842_i_ColorBits1And0                                  /* Test bit 15 (Color bit 1) */
                        bge.s   T0287024
                        or.w    D2,2(L0846_pc_VideoAddress)                             /* Set bit 1 of each pixel */
                        or.w    D3,10(L0846_pc_VideoAddress)                            /* Set bit 1 of each pixel */
                        bra.s   T0287025
                T0287024:
                        and.w   L0844_i_BarGraphMaskInverted1,2(L0846_pc_VideoAddress)  /* Clear bit 1 of each pixel */
                        and.w   AL0843_l_BarGraphMaskInverted2,10(L0846_pc_VideoAddress) /* Clear bit 1 of each pixel */
                T0287025:
                        tst.w   AL0841_i_ColorBits3And2                                 /* Test bit 0 (Color bit 2) */
                        beq.s   T0287026
                        or.w    D2,4(L0846_pc_VideoAddress)                             /* Set bit 2 of each pixel */
                        or.w    D3,12(L0846_pc_VideoAddress)                            /* Set bit 2 of each pixel */
                        bra.s   T0287027
                T0287026:
                        and.w   L0844_i_BarGraphMaskInverted1,4(L0846_pc_VideoAddress)  /* Clear bit 2 of each pixel */
                        and.w   AL0843_l_BarGraphMaskInverted2,12(L0846_pc_VideoAddress) /* Clear bit 2 of each pixel */
                T0287027:
                        tst.l   AL0841_i_ColorBits3And2                                 /* Test bit 15 (Color bit 3) */
                        bge.s   T0287028
                        or.w    D2,6(L0846_pc_VideoAddress)                             /* Set bit 3 of each pixel */
                        or.w    D3,14(L0846_pc_VideoAddress)                            /* Set bit 3 of each pixel */
                        bra.s   T0287029
                T0287028:
                        and.w   L0844_i_BarGraphMaskInverted1,6(L0846_pc_VideoAddress)  /* Clear bit 3 of each pixel */
                        and.w   AL0843_l_BarGraphMaskInverted2,14(L0846_pc_VideoAddress)        /* Clear bit 3 of each pixel */
                T0287029:
                        lea     C160_BYTE_WIDTH_SCREEN(L0846_pc_VideoAddress),L0846_pc_VideoAddress     /* Proceed to next line ($00A0 = 160 bytes per line) */
                        dbf     D1,T0287020_Loop
                        move.w  (A7)+,D1
                        rts
                T0287030:
        }
#endif
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M768_BOX_LEFT(L1640_ai_Box) = P0605_i_ChampionIndex * C69_CHAMPION_STATUS_BOX_SPACING + 46;
        M769_BOX_RIGHT(L1640_ai_Box) = M768_BOX_LEFT(L1640_ai_Box) + 3;
        M770_BOX_TOP(L1640_ai_Box) = 2;
        M771_BOX_BOTTOM(L1640_ai_Box) = 26;
        for (AL0841_i_BarGraphIndex = 0; AL0841_i_BarGraphIndex < 3; AL0841_i_BarGraphIndex++) {
                AL0842_l_BarGraphHeight = L0847_ai_BarGraphHeights[AL0841_i_BarGraphIndex];
                if (AL0842_l_BarGraphHeight < 25) {
                        M770_BOX_TOP(L1640_ai_Box) = 2;
                        M771_BOX_BOTTOM(L1640_ai_Box) = 27 - AL0842_l_BarGraphHeight;
                        M524_FillScreenBox(L1640_ai_Box, C12_COLOR_DARKEST_GRAY);
                }
                if (AL0842_l_BarGraphHeight != 0) {
                        M770_BOX_TOP(L1640_ai_Box) = 27 - AL0842_l_BarGraphHeight;
                        M771_BOX_BOTTOM(L1640_ai_Box) = 26;
                        M524_FillScreenBox(L1640_ai_Box, G0046_auc_Graphic562_ChampionColor[P0605_i_ChampionIndex]);
                }
                M768_BOX_LEFT(L1640_ai_Box) += 7;
                M769_BOX_RIGHT(L1640_ai_Box) += 7;
        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L2252_i_BoxIndex = P0605_i_ChampionIndex + C195_ZONE_FIRST_BAR_GRAPH;
        for (L2251_i_Counter = 0; L2251_i_Counter < 3; L2251_i_Counter++, L2252_i_BoxIndex += 4) {
                F0638_GetZone(L2252_i_BoxIndex, L2005_ai_XYZColoredBar);
                if (L2254_i_Bars[L2251_i_Counter][0] < L2254_i_Bars[L2251_i_Counter][1]) {
                        F0007_MAIN_CopyBytes((char*)L2005_ai_XYZColoredBar, (char*)L2004_ai_XYZBlankBar, (long)sizeof(L2004_ai_XYZBlankBar));
                        if (L2254_i_Bars[L2251_i_Counter][0] != 0) {
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                                L2253_i_Height = M709_ZONE_HEIGHT(L2005_ai_XYZColoredBar);
                                M707_ZONE_BOTTOM(L2004_ai_XYZBlankBar) -= F0025_MAIN_GetMaximumValue(1, (int16_t)(((long)L2253_i_Height * (long)L2254_i_Bars[L2251_i_Counter][0]) / (long)L2254_i_Bars[L2251_i_Counter][1]));
                        }
                        if (M706_ZONE_TOP(L2004_ai_XYZBlankBar) <= M707_ZONE_BOTTOM(L2004_ai_XYZBlankBar)) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                M709_ZONE_HEIGHT(L2004_ai_XYZBlankBar) -= F0025_MAIN_GetMaximumValue(1, (int16_t)(((long)M709_ZONE_HEIGHT(L2004_ai_XYZBlankBar) * (long)L2254_i_Bars[L2251_i_Counter][0]) / (long)L2254_i_Bars[L2251_i_Counter][1]));
                        }
                        if (M709_ZONE_HEIGHT(L2004_ai_XYZBlankBar) > 0) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                F0732_FillScreenArea(L2004_ai_XYZBlankBar, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                                M706_ZONE_TOP(L2005_ai_XYZColoredBar) = M707_ZONE_BOTTOM(L2004_ai_XYZBlankBar) + 1;
                        }
                }
                if ((L2254_i_Bars[L2251_i_Counter][0] != 0) && (M706_ZONE_TOP(L2005_ai_XYZColoredBar) <= M707_ZONE_BOTTOM(L2005_ai_XYZColoredBar))) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                M706_ZONE_TOP(L2005_ai_XYZColoredBar) = M706_ZONE_TOP(L2004_ai_XYZBlankBar) + M709_ZONE_HEIGHT(L2004_ai_XYZBlankBar);
                                M709_ZONE_HEIGHT(L2005_ai_XYZColoredBar) -= M709_ZONE_HEIGHT(L2004_ai_XYZBlankBar);
                        }
                }
                if ((L2254_i_Bars[L2251_i_Counter][0] != 0) && (M709_ZONE_HEIGHT(L2005_ai_XYZColoredBar) > 0)) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0732_FillScreenArea(L2005_ai_XYZColoredBar, G0046_auc_Graphic562_ChampionColor[P0605_i_ChampionIndex]);
                }
        }
#endif
        F0078_MOUSE_DisableScreenUpdate();
}

char* F0288_CHAMPION_GetStringFromInteger(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0606_ui_Integer, P0607_B_Padding, P0608_ui_PaddingCharacterCount)
#endif
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
REGISTER unsigned int16_t P0606_ui_Integer               SEPARATOR
REGISTER BOOLEAN          P0607_B_Padding                SEPARATOR
#endif
#ifdef MEDIA331_S20E_S21E_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
unsigned int16_t          P0606_ui_Integer               SEPARATOR
BOOLEAN                   P0607_B_Padding                SEPARATOR
#endif
unsigned int16_t          P0608_ui_PaddingCharacterCount FINAL_SEPARATOR
{
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        REGISTER char* L0850_pc_Character;
#endif
        REGISTER int16_t L0849_i_Digit;
#ifdef MEDIA180_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER char* L0850_pc_Character;
#endif
        static char G0419_ac_IntegerToStringConversionBuffer[6];


        if (P0607_B_Padding) {
                F0009_MAIN_WriteSpacedBytes(G0419_ac_IntegerToStringConversionBuffer, 4, ' ', sizeof(char));
        }
        L0850_pc_Character = &G0419_ac_IntegerToStringConversionBuffer[4];
        *L0850_pc_Character = '\0';
        if (!P0606_ui_Integer) {
                *(--L0850_pc_Character) = '0';
        } else {
                while (L0849_i_Digit = P0606_ui_Integer) {
                        *(--L0850_pc_Character) = '0' + L0849_i_Digit - ((P0606_ui_Integer /= 10) * 10);
                }
        }
        if (P0607_B_Padding) {
                return &G0419_ac_IntegerToStringConversionBuffer[4 - P0608_ui_PaddingCharacterCount];
        }
#ifdef MEDIA356_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J /* ANOMALY_ST_BRANCH */
        else {
#endif
                return L0850_pc_Character;
#ifdef MEDIA356_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        }
#endif
#endif
#ifdef MEDIA265_S20E_S21E /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
        static char G0419_ac_IntegerToStringConversionBuffer[5];


        asm {
                        moveq   #4,D0
                        sub.w   P0608_ui_PaddingCharacterCount(A6),D0
                        lea     G0419_ac_IntegerToStringConversionBuffer(A4),A1
                        add.l   A1,D0
                        move.l  #'    ',(A1)+                                   /* Write 4 'space' characters */
                        clr.b   (A1)                                            /* Write a 00h byte to mark the end of the string */
                        moveq   #0,D1
                        move.w  P0606_ui_Integer(A6),D1
                T0288003_Loop:
                        divu    #10,D1
                        swap    D1                                              /* This places the remainder of the division (0..9) in the least significant word of D1 */
                        add.b   #'0',D1                                         /* This converts a number (0..9) to the corresponding ASCII character */
                        move.b  D1,-(A1)                                        /* Replace the last character in the string by the digit, and decrement A1 */
                        clr.w   D1                                              /* Clear the division remainder */
                        swap    D1                                              /* This places the last quotient of the division in the least significant word of D1 */
                        bne.s   T0288003_Loop                                   /* If there is still a non zero quotient to process */
                        tst.w   P0607_B_Padding(A6)
                        bne.s   T0288007_Return                                 /* If padding (leading spaces) should be present in returned string */
                        move.l  A1,D0
                T0288007_Return:
        }
#endif
#ifdef MEDIA613_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        static char G0419_ac_IntegerToStringConversionBuffer[5];


        asm {
                        moveq   #4,D0
                        sub.w   P0608_ui_PaddingCharacterCount(A6),D0
                        lea     G0419_ac_IntegerToStringConversionBuffer(A5),A0
                        add.l   A0,D0
                        move.l  #'    ',(A0)+                                   /* Write 4 'space' characters */
                        clr.b   (A0)                                            /* Write a 00h byte to mark the end of the string */
                        moveq   #0,D1
                        move.w  P0606_ui_Integer(A6),D1
                @T0288003:
                        divu    #10,D1
                        swap    D1                                              /* This places the remainder of the division (0..9) in the least significant word of D1 */
                        add.b   #'0',D1                                         /* This converts a number (0..9) to the corresponding ASCII character */
                        move.b  D1,-(A0)                                        /* Replace the last character in the string by the digit, and decrement A1 */
                        clr.w   D1                                              /* Clear the division remainder */
                        swap    D1                                              /* This places the last quotient of the division in the least significant word of D1 */
                        bne.s   @T0288003                                       /* If there is still a non zero quotient to process */
                        tst.w   P0607_B_Padding(A6)
                        bne.s   @T0288007                                        /* If padding (leading spaces) should be present in returned string */
                        move.l  A0,D0
                @T0288007:
        }
#endif
}

STATICFUNCTION void F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0609_i_Y, P0610_i_CurrentValue, P0611_i_MaximumValue)
int16_t P0609_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 P0609_i_ZoneIndex    SEPARATOR
#endif
int16_t P0610_i_CurrentValue SEPARATOR
int16_t P0611_i_MaximumValue FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0052_TEXT_PrintToViewport(55, P0609_i_Y, C13_COLOR_LIGHTEST_GRAY, F0288_CHAMPION_GetStringFromInteger(P0610_i_CurrentValue, C1_TRUE, 3));
        F0052_TEXT_PrintToViewport(73, P0609_i_Y, C13_COLOR_LIGHTEST_GRAY, "/");
        F0052_TEXT_PrintToViewport(79, P0609_i_Y, C13_COLOR_LIGHTEST_GRAY, F0288_CHAMPION_GetStringFromInteger(P0611_i_MaximumValue, C1_TRUE, 3));
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        char ValueString[8];


        M547_STRCPY(ValueString, F0288_CHAMPION_GetStringFromInteger(P0610_i_CurrentValue, C1_TRUE, 3));
        M545_STRCAT(ValueString, "/");
        M545_STRCAT(ValueString, F0288_CHAMPION_GetStringFromInteger(P0611_i_MaximumValue, C1_TRUE, 3));
        F0648_PrintTextInViewportZone(P0609_i_ZoneIndex, C13_COLOR_LIGHTEST_GRAY, ValueString);
#endif
}

STATICFUNCTION void F0290_CHAMPION_DrawHealthStaminaManaValues(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0612_ps_Champion)
#endif
REGISTER CHAMPION* P0612_ps_Champion FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(116, P0612_ps_Champion->CurrentHealth, P0612_ps_Champion->MaximumHealth);
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(124, P0612_ps_Champion->CurrentStamina / 10, P0612_ps_Champion->MaximumStamina / 10);
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(132, P0612_ps_Champion->CurrentMana, P0612_ps_Champion->MaximumMana);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(C550_ZONE_HEALTH_VALUE, P0612_ps_Champion->CurrentHealth, P0612_ps_Champion->MaximumHealth);
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(C551_ZONE_MANA_VALUE, P0612_ps_Champion->CurrentStamina / 10, P0612_ps_Champion->MaximumStamina / 10);
        F0289_CHAMPION_DrawHealthOrStaminaOrManaValue(C552_ZONE_STAMINA_VALUE, P0612_ps_Champion->CurrentMana, P0612_ps_Champion->MaximumMana);
#endif
}

void F0291_CHAMPION_DrawSlot(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0613_ui_ChampionIndex, P0614_ui_SlotIndex)
#endif
unsigned int16_t          P0613_ui_ChampionIndex SEPARATOR
REGISTER unsigned int16_t P0614_ui_SlotIndex     FINAL_SEPARATOR
{
        REGISTER CHAMPION* L0854_ps_Champion;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER THING L0851_T_Thing;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned char* L0860_puc_Bitmap;
        REGISTER int16_t L0853_i_IconIndex;
        REGISTER int16_t L0859_i_NativeBitmapIndex = -1;
#endif
        REGISTER BOOLEAN L0852_B_IsInventoryChampion;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER THING L0851_T_Thing;
#endif
        unsigned int16_t L0856_ui_SlotBoxIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0853_i_IconIndex;
        REGISTER SLOT_BOX* L0855_ps_SlotBox;
        char L0857_ac_Unreferenced[8]; /* BUG0_00 Useless code */
        int16_t L0858_ai_Box[4];
        int16_t L0859_i_NativeBitmapIndex = -1;
        unsigned char* L0860_puc_Bitmap;
#endif
        int16_t L0861_i_DestinationByteWidth;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L2255_ai_XYZ[4];
#endif
#ifdef MEDIA425_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A36M_A31E_A31M_A33M_A35E_A35M
        int16_t L1641_i_DestinationHeight;
#endif


        L0854_ps_Champion = &M516_CHAMPIONS[P0613_ui_ChampionIndex];
        L0852_B_IsInventoryChampion = (G0423_i_InventoryChampionOrdinal == M000_INDEX_TO_ORDINAL(P0613_ui_ChampionIndex));
        if (!L0852_B_IsInventoryChampion) { /* If drawing a slot for a champion other than the champion whose inventory is open */
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_08_FIX */
                if ((P0614_ui_SlotIndex > C01_SLOT_ACTION_HAND) || G0299_ui_CandidateChampionOrdinal) {
#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_08_FIX In F0280_CHAMPION_AddCandidateChampionToParty the value of G0299_ui_CandidateChampionOrdinal is set before F0388_MENUS_ClearActingChampion is called, which calls F0292_CHAMPION_DrawState which in turn calls this function to draw the action hand slot. Without this updated condition the slot would not be drawn */
                if ((P0614_ui_SlotIndex > C01_SLOT_ACTION_HAND) || (G0299_ui_CandidateChampionOrdinal == M000_INDEX_TO_ORDINAL(P0613_ui_ChampionIndex))) {
#endif
                        return;
                }
                L0856_ui_SlotBoxIndex = (P0613_ui_ChampionIndex << 1) + P0614_ui_SlotIndex;
        } else {
                L0856_ui_SlotBoxIndex = C08_SLOT_BOX_INVENTORY_FIRST_SLOT + P0614_ui_SlotIndex;
        }
        if (P0614_ui_SlotIndex >= C30_SLOT_CHEST_1) {
                L0851_T_Thing = G0425_aT_ChestSlots[P0614_ui_SlotIndex - C30_SLOT_CHEST_1];
        } else {
                L0851_T_Thing = L0854_ps_Champion->Slots[P0614_ui_SlotIndex];
        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L0855_ps_SlotBox = &G0030_as_Graphic562_SlotBoxes[L0856_ui_SlotBoxIndex];
        M769_BOX_RIGHT(L0858_ai_Box) = (M768_BOX_LEFT(L0858_ai_Box) = L0855_ps_SlotBox->X - 1) + 17;
        M771_BOX_BOTTOM(L0858_ai_Box) = (M770_BOX_TOP(L0858_ai_Box) = L0855_ps_SlotBox->Y - 1) + 17;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0619_GetSlotBoxBorderCoordinates(G0030_as_Graphic562_SlotBoxes[L0856_ui_SlotBoxIndex].ZoneIndex, L2255_ai_XYZ);
#endif
        if (L0852_B_IsInventoryChampion) {
                L0860_puc_Bitmap = 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
                L0861_i_DestinationByteWidth = C112_BYTE_WIDTH_VIEWPORT;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0861_i_DestinationByteWidth = G2073_C224_ViewportPixelWidth;
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L1641_i_DestinationHeight = C136_HEIGHT_VIEWPORT;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
                L1641_i_DestinationHeight = 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
                L0860_puc_Bitmap = (unsigned char*)G0348_Bitmap_Screen;
                L0861_i_DestinationByteWidth = C160_BYTE_WIDTH_SCREEN;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0860_puc_Bitmap = G0348_Bitmap_Screen;
                L0861_i_DestinationByteWidth = G2071_C320_ScreenPixelWidth;
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                L1641_i_DestinationHeight = C200_HEIGHT_SCREEN;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
                L1641_i_DestinationHeight = G2072_C200_ScreenPixelHeight;
#endif
                F0077_MOUSE_EnableScreenUpdate_CPSE();
        }
        if (L0851_T_Thing == C0xFFFF_THING_NONE) {
                if (P0614_ui_SlotIndex <= C05_SLOT_FEET) {
                        L0853_i_IconIndex = C212_ICON_READY_HAND + (P0614_ui_SlotIndex << 1);
                        if (M007_GET(L0854_ps_Champion->Wounds, 1 << P0614_ui_SlotIndex)) {
                                L0853_i_IconIndex++;
                                L0859_i_NativeBitmapIndex = C034_GRAPHIC_SLOT_BOX_WOUNDED;
                        } else {
#ifdef PC_FIX_CODE_SIZE
        L0853_i_IconIndex++;
        L0853_i_IconIndex++;
        L0853_i_IconIndex++;
#endif
                                L0859_i_NativeBitmapIndex = C033_GRAPHIC_SLOT_BOX_NORMAL;
                        }
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_09_OPTIMIZATION */
                        if ((P0614_ui_SlotIndex == C01_SLOT_ACTION_HAND) && (M000_INDEX_TO_ORDINAL(P0613_ui_ChampionIndex) == G0506_ui_ActingChampionOrdinal)) {
                                L0859_i_NativeBitmapIndex = C035_GRAPHIC_SLOT_BOX_ACTING_HAND;
                        }
#endif
                } else {
                        if ((P0614_ui_SlotIndex >= C10_SLOT_NECK) && (P0614_ui_SlotIndex <= C13_SLOT_BACKPACK_LINE1_1)) {
                                L0853_i_IconIndex = C208_ICON_NECK + (P0614_ui_SlotIndex - C10_SLOT_NECK);
                        } else {
                                L0853_i_IconIndex = C204_ICON_EMPTY_BOX;
                        }
                }
        } else {
                L0853_i_IconIndex = F0033_OBJECT_GetIconIndex(L0851_T_Thing); /* BUG0_35 The closed chest icon is drawn when the chest is opened. If you open the inventory of a champion and place a chest in the action hand, the closed chest icon is drawn instead of the open chest icon. If you place a Chest in the action hand before opening the inventory (in the champion status box on top of the screen) then when you open the inventory the open chest icon is drawn correctly in the action hand (by F0333_INVENTORY_OpenAndDrawChest). Code is missing to change the icon when a chest is drawn in the action hand while in the inventory */
#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_10_FIX Code added to change the icon of the Chest and Scroll when in the action hand and in the inventory. This fix causes BUG2_00 for scrolls */
                if (L0852_B_IsInventoryChampion && (P0614_ui_SlotIndex == C01_SLOT_ACTION_HAND) && ((L0853_i_IconIndex == C144_ICON_CONTAINER_CHEST_CLOSED)
#ifdef MEDIA225_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
                   || (L0853_i_IconIndex == C030_ICON_SCROLL_SCROLL_OPEN) /* BUG2_00 The closed scroll icon is drawn when the scroll is open. If you open the inventory of a champion and place a scroll in the action hand, the closed scroll icon is drawn instead of the open scroll icon. If you put another scroll in the action hand of another champion (in the status box on top of the screen) the icon is changed to the open scroll icon. If a champion in the party has a lit torch in hand then if you wait long enough without doing anything until the torch light decreases then the scroll icon changes automatically to the open scroll icon (caused by F0338_INVENTORY_DecreaseTorchesLightPower_CPSE which calls F0296_CHAMPION_DrawChangedObjectIcons if the charge count of a torch has changed). The code added to fix BUG0_35 about chest icons also affects scrolls while it should not */
#endif
                   )) {
                        L0853_i_IconIndex++;
                }
#endif
                if (P0614_ui_SlotIndex <= C05_SLOT_FEET) {
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_09_OPTIMIZATION */
                        if ((P0614_ui_SlotIndex == C01_SLOT_ACTION_HAND) && (M000_INDEX_TO_ORDINAL(P0613_ui_ChampionIndex) == G0506_ui_ActingChampionOrdinal)) {
                                L0859_i_NativeBitmapIndex = C035_GRAPHIC_SLOT_BOX_ACTING_HAND;
                        } else {
#endif
                                if (M007_GET(L0854_ps_Champion->Wounds, 1 << P0614_ui_SlotIndex)) {
                                        L0859_i_NativeBitmapIndex = C034_GRAPHIC_SLOT_BOX_WOUNDED;
                                } else {
                                        L0859_i_NativeBitmapIndex = C033_GRAPHIC_SLOT_BOX_NORMAL;
                                }
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_09_OPTIMIZATION */
                        }
#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_09_OPTIMIZATION Code deduplication */
        if ((P0614_ui_SlotIndex == C01_SLOT_ACTION_HAND) && (M000_INDEX_TO_ORDINAL(P0613_ui_ChampionIndex) == G0506_ui_ActingChampionOrdinal)) {
                L0859_i_NativeBitmapIndex = C035_GRAPHIC_SLOT_BOX_ACTING_HAND;
        }
#endif
        if (L0859_i_NativeBitmapIndex != -1) {
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
                G0578_B_UseByteBoxCoordinates = C0_FALSE, F0132_VIDEO_Blit(F0489_MEMORY_GetNativeBitmapOrGraphic(L0859_i_NativeBitmapIndex), L0860_puc_Bitmap, L0858_ai_Box, 0, 0, C016_BYTE_WIDTH, L0861_i_DestinationByteWidth, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0578_B_UseByteBoxCoordinates = C0_FALSE, F0132_VIDEO_Blit(F0489_MEMORY_GetNativeBitmapOrGraphic(L0859_i_NativeBitmapIndex), L0860_puc_Bitmap, L0858_ai_Box, 0, 0, C016_BYTE_WIDTH, L0861_i_DestinationByteWidth, C12_COLOR_DARKEST_GRAY, 18, L1641_i_DestinationHeight);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0854_ps_Champion = (CHAMPION*)F0489_MEMORY_GetNativeBitmapOrGraphic(L0859_i_NativeBitmapIndex);
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
                F0132_VIDEO_Blit((unsigned char*)L0854_ps_Champion, L0860_puc_Bitmap, L2255_ai_XYZ, 0, 0, M100_PIXEL_WIDTH((int16_t*)L0854_ps_Champion), L0861_i_DestinationByteWidth, C12_COLOR_DARKEST_GRAY, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA543_F20E_F20J_X30J_F31E_F31J_X31J
                F0132_VIDEO_Blit((unsigned char*)L0854_ps_Champion, L0860_puc_Bitmap, L2255_ai_XYZ, 0, 0, M100_PIXEL_WIDTH((int16_t*)L0854_ps_Champion), L0861_i_DestinationByteWidth, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
                F0132_VIDEO_Blit((unsigned char*)L0854_ps_Champion, L0860_puc_Bitmap, L2255_ai_XYZ, 0, 0, M100_PIXEL_WIDTH((int16_t*)L0854_ps_Champion), L0861_i_DestinationByteWidth, C12_COLOR_DARKEST_GRAY, M101_PIXEL_HEIGHT((int16_t*)L0854_ps_Champion), L1641_i_DestinationHeight);
#endif
        }
        F0038_OBJECT_DrawIconInSlotBox(L0856_ui_SlotBoxIndex, L0853_i_IconIndex);
        if (!L0852_B_IsInventoryChampion) {
                F0078_MOUSE_DisableScreenUpdate();
        }
}

#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void F0623_DrawDamageToChampion_F0320_sub(
unsigned int16_t P2060_ui_ChampionIndex SEPARATOR
int16_t P2061_i_Damage                  FINAL_SEPARATOR
{
        REGISTER int16_t L2257_i_ZoneIndex;
        REGISTER int16_t L2258_i_GraphicIndex;


        if (M000_INDEX_TO_ORDINAL(P2060_ui_ChampionIndex) == G0423_i_InventoryChampionOrdinal) {
                L2258_i_GraphicIndex = C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG;
                L2257_i_ZoneIndex = C179_ZONE_FIRST_DAMAGE_TO_CHAMPION_BIG;
        } else {
                L2258_i_GraphicIndex = C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL;
                L2257_i_ZoneIndex = C167_ZONE_FIRST_DAMAGE_TO_CHAMPION_SMALL;
        }
        F0077_MOUSE_EnableScreenUpdate_CPSE();
        F0660_(L2258_i_GraphicIndex, L2257_i_ZoneIndex += P2060_ui_ChampionIndex, C10_COLOR_FLESH);
        F0650_PrintCenteredTextToScreenZone(L2257_i_ZoneIndex, C15_COLOR_WHITE, C08_COLOR_RED, F0288_CHAMPION_GetStringFromInteger(P2061_i_Damage, C0_FALSE, 3));
        F0292_CHAMPION_DrawState(P2060_ui_ChampionIndex);
        F0078_MOUSE_DisableScreenUpdate();
}
#endif

void F0292_CHAMPION_DrawState(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0615_ui_ChampionIndex)
#endif
REGISTER unsigned int16_t P0615_ui_ChampionIndex FINAL_SEPARATOR
{
        REGISTER CHAMPION* L0865_ps_Champion;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER char* L0866_pc_ChampionName;
        REGISTER int16_t L0864_i_Multiple;
#endif
#define AL0864_i_BorderCount       L0864_i_Multiple
#define AL0864_i_ColorIndex        L0864_i_Multiple
#define AL0864_i_Load              L0864_i_Multiple
#define AL0864_i_ChampionIconIndex L0864_i_Multiple
#define AL0864_i_StatisticIndex    L0864_i_Multiple
#define AL0864_i_SlotIndex         L0864_i_Multiple
        REGISTER unsigned int16_t L0862_ui_ChampionAttributes;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0870_i_Multiple;
#endif
#define AL0870_i_NativeBitmapIndex L0870_i_Multiple
#define AL0870_i_Color             L0870_i_Multiple
        REGISTER BOOLEAN L0863_B_IsInventoryChampion;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0864_i_Multiple;
        char L0867_c_ChampionTitleFirstCharacter;
        REGISTER char* L0866_pc_ChampionName;
        int16_t L0868_i_ChampionStatusBoxX;
        int16_t L0869_i_ChampionTitleX;
        int16_t L0870_i_Multiple;
        int16_t L0871_ai_Box[4];
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        BOOLEAN L2259_B_MousePointerHidden;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        char L0867_c_ChampionTitleFirstCharacter;
        int16_t L2260_ai_XYZ[4];
#endif
        int16_t L0872_ai_NativeBitmapIndices[3];
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        char L2261_ac_String[28];
#endif


#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L0868_i_ChampionStatusBoxX = P0615_ui_ChampionIndex * C69_CHAMPION_STATUS_BOX_SPACING;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L2259_B_MousePointerHidden = C0_FALSE;
#endif
        L0865_ps_Champion = &M516_CHAMPIONS[P0615_ui_ChampionIndex];
        L0862_ui_ChampionAttributes = L0865_ps_Champion->Attributes;
        if (!M007_GET(L0862_ui_ChampionAttributes, MASK0x0080_NAME_TITLE | MASK0x0100_STATISTICS | MASK0x0200_LOAD | MASK0x0400_ICON | MASK0x0800_PANEL | MASK0x1000_STATUS_BOX | MASK0x2000_WOUNDS | MASK0x4000_VIEWPORT | MASK0x8000_ACTION_HAND))
                return;
        L0863_B_IsInventoryChampion = (M000_INDEX_TO_ORDINAL(P0615_ui_ChampionIndex) == G0423_i_InventoryChampionOrdinal);
#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 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
        F0077_MOUSE_EnableScreenUpdate_CPSE();
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (L0863_B_IsInventoryChampion && G0297_B_DrawFloorAndCeilingRequested) {
                F0355_INVENTORY_Toggle_CPSE(C05_CHAMPION_SPECIAL_INVENTORY);
        }
#endif
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x1000_STATUS_BOX)) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                M770_BOX_TOP(L0871_ai_Box) = 0;
                M771_BOX_BOTTOM(L0871_ai_Box) = 28;
                M769_BOX_RIGHT(L0871_ai_Box) = (M768_BOX_LEFT(L0871_ai_Box) = L0868_i_ChampionStatusBoxX) + 66;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0638_GetZone(P0615_ui_ChampionIndex + C151_ZONE_CHAMPION_0_STATUS_BOX_NAME_HANDS, L2260_ai_XYZ);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L2259_B_MousePointerHidden = C1_TRUE;
                F0077_MOUSE_EnableScreenUpdate_CPSE();
#endif
                if (L0865_ps_Champion->CurrentHealth) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        M524_FillScreenBox(L0871_ai_Box, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0732_FillScreenArea(L2260_ai_XYZ, C12_COLOR_DARKEST_GRAY);
#endif
                        F0008_MAIN_ClearBytes(M772_CAST_PC(L0872_ai_NativeBitmapIndices), M543_BYTE_COUNT_INT(sizeof(L0872_ai_NativeBitmapIndices)));
                        AL0864_i_BorderCount = 0;
                        if (G0407_s_Party.FireShieldDefense > 0) {
                                L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = C038_GRAPHIC_BORDER_PARTY_FIRESHIELD;
                        }
                        if (G0407_s_Party.SpellShieldDefense > 0) {
                                L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD;
                        }
                        if ((G0407_s_Party.ShieldDefense > 0) || L0865_ps_Champion->ShieldDefense) {
                                L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = C037_GRAPHIC_BORDER_PARTY_SHIELD;
                        }
                        while (AL0864_i_BorderCount--) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                M520_F0021_MAIN_BlitToScreen(F0489_MEMORY_GetNativeBitmapOrGraphic(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount]), L0871_ai_Box, C040_BYTE_WIDTH, C10_COLOR_FLESH, 29);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                F0659_(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount], L2260_ai_XYZ, C10_COLOR_FLESH);
#endif
                        }
                        if (L0863_B_IsInventoryChampion) {
                                F0354_INVENTORY_DrawStatusBoxPortrait(P0615_ui_ChampionIndex);
                                M008_SET(L0862_ui_ChampionAttributes, MASK0x0100_STATISTICS);
                        } else {
                                M008_SET(L0862_ui_ChampionAttributes, MASK0x0080_NAME_TITLE | MASK0x0100_STATISTICS | MASK0x2000_WOUNDS | MASK0x8000_ACTION_HAND);
                        }
                } else {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        M520_F0021_MAIN_BlitToScreen(F0489_MEMORY_GetNativeBitmapOrGraphic(C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION), L0871_ai_Box, C040_BYTE_WIDTH, CM1_COLOR_NO_TRANSPARENCY, 29);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0659_(C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION, L2260_ai_XYZ, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_11_OPTIMIZATION */
                        F0053_TEXT_PrintToLogicalScreen(1 + L0868_i_ChampionStatusBoxX, 5, C13_COLOR_LIGHTEST_GRAY, C01_COLOR_DARK_GRAY, L0865_ps_Champion->Name);
#endif
#ifdef MEDIA224_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G /* CHANGE2_11_OPTIMIZATION Machine code size reduced. This code produces 2 bytes less of executable code */
                        F0053_TEXT_PrintToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, C13_COLOR_LIGHTEST_GRAY, C01_COLOR_DARK_GRAY, L0865_ps_Champion->Name);
#endif
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_07_FIX Function call moved to F0319_CHAMPION_Kill so that champion icons are displayed correctly */
                        M524_FillScreenBox(&G0054_ai_Graphic562_Box_ChampionIcons[M026_CHAMPION_ICON_INDEX(L0865_ps_Champion->Cell, G0308_i_PartyDirection) << 2], C00_COLOR_BLACK); /* BUG0_36 A champion icon may be missing in the upper right corner of the screen after loading a saved game where at least one champion is dead. When a dead champion is reborn at a Vi Altar, the champion cell is set to the first available cell where there is no champion alive. It is then possible that the cell of the reborn champion is the same as the cell of another dead champion in the party. If the index of the dead champion is higher than the index of the reborn champion and the game is saved then when restarting the game from the saved game the icon of the reborn champion will not appear on screen. This is only a graphic glitch and you only need to click on the black area where the missing icon should be to make it appear again. When the game is loaded, the state of each champion is drawn. For a dead champion, this erases the champion icon according to the cell of the dead champion, even if another champion is at the same cell */
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0650_PrintCenteredTextToScreenZone(P0615_ui_ChampionIndex + C163_ZONE_FIRST_CHAMPION_NAME, C13_COLOR_LIGHTEST_GRAY, C01_COLOR_DARK_GRAY, L0865_ps_Champion->Name);
#endif
                        F0386_MENUS_DrawActionIcon(P0615_ui_ChampionIndex);
#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
                        goto T0292042;
#endif
                }
        }
        if (!(L0865_ps_Champion->CurrentHealth))
                goto T0292042;
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x0080_NAME_TITLE)) {
#ifdef MEDIA049_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                AL0864_i_ColorIndex = (P0615_ui_ChampionIndex == G0411_i_LeaderIndex) ? C09_COLOR_GOLD : C13_COLOR_LIGHTEST_GRAY;
#endif
#ifdef MEDIA469_P20JB
                AL0864_i_ColorIndex = (P0615_ui_ChampionIndex == G0411_i_LeaderIndex) ? C09_COLOR_GOLD : C15_COLOR_WHITE;
#endif
#ifdef MEDIA707_I34E_I34M
                AL0864_i_ColorIndex = (P0615_ui_ChampionIndex == G0411_i_LeaderIndex) ? C11_COLOR_YELLOW : C09_COLOR_GOLD;
#endif
                if (L0863_B_IsInventoryChampion) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        F0052_TEXT_PrintToViewport(3, 7, AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->Name);
                        L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        M547_STRCPY(L2261_ac_String, L0866_pc_ChampionName = L0865_ps_Champion->Name);
#endif
                        L0867_c_ChampionTitleFirstCharacter = L0865_ps_Champion->Title[0];
                        if ((L0867_c_ChampionTitleFirstCharacter != ',') && (L0867_c_ChampionTitleFirstCharacter != ';') && (L0867_c_ChampionTitleFirstCharacter != '-')) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                L0869_i_ChampionTitleX += 6;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                M545_STRCAT(L2261_ac_String, " ");
#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(L0869_i_ChampionTitleX, 7, AL0864_i_ColorIndex, L0865_ps_Champion->Title);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        M545_STRCAT(L2261_ac_String, L0865_ps_Champion->Title);
                        F0648_PrintTextInViewportZone(C553_ZONE_CHAMPION_NAME_AND_TITLE, AL0864_i_ColorIndex, L2261_ac_String);
#endif
                        M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
                } else {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        M770_BOX_TOP(L0871_ai_Box) = 0;
                        M771_BOX_BOTTOM(L0871_ai_Box) = 6;
                        M769_BOX_RIGHT(L0871_ai_Box) = (M768_BOX_LEFT(L0871_ai_Box) = L0868_i_ChampionStatusBoxX) + 42;
                        M524_FillScreenBox(L0871_ai_Box, C01_COLOR_DARK_GRAY);
                        F0053_TEXT_PrintToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, AL0864_i_ColorIndex, C01_COLOR_DARK_GRAY, L0865_ps_Champion->Name);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        if (!L2259_B_MousePointerHidden) {
                                L2259_B_MousePointerHidden = C1_TRUE;
                                F0077_MOUSE_EnableScreenUpdate_CPSE();
                        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0733_FillZoneByIndex(P0615_ui_ChampionIndex + C159_ZONE_CHAMPION_0_STATUS_BOX_NAME, C01_COLOR_DARK_GRAY);
                        F0650_PrintCenteredTextToScreenZone(P0615_ui_ChampionIndex + C163_ZONE_FIRST_CHAMPION_NAME, AL0864_i_ColorIndex, C01_COLOR_DARK_GRAY, L0865_ps_Champion->Name);
#endif
                }
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x0100_STATISTICS)) {
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (!L2259_B_MousePointerHidden) {
                        L2259_B_MousePointerHidden = C1_TRUE;
                        F0077_MOUSE_EnableScreenUpdate_CPSE();
                }
#endif
                F0287_CHAMPION_DrawBarGraphs(P0615_ui_ChampionIndex);
                if (L0863_B_IsInventoryChampion) {
                        F0290_CHAMPION_DrawHealthStaminaManaValues(L0865_ps_Champion);
                        if ((L0865_ps_Champion->Food < 0) || (L0865_ps_Champion->Water < 0) || (L0865_ps_Champion->PoisonEventCount)) {
                                AL0870_i_NativeBitmapIndex = C034_GRAPHIC_SLOT_BOX_WOUNDED;
                        } else {
                                AL0870_i_NativeBitmapIndex = C033_GRAPHIC_SLOT_BOX_NORMAL;
                        }
#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(AL0870_i_NativeBitmapIndex), G0048_ai_Graphic562_Box_Mouth, C016_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 18);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0619_GetSlotBoxBorderCoordinates(C545_ZONE_MOUTH, L2260_ai_XYZ);
                        F0657_BlitBitmapIndexToViewportZoneWithTransparency(AL0870_i_NativeBitmapIndex, L2260_ai_XYZ, C12_COLOR_DARKEST_GRAY);
#endif
                        AL0870_i_NativeBitmapIndex = C033_GRAPHIC_SLOT_BOX_NORMAL;
                        for (AL0864_i_StatisticIndex = C1_STATISTIC_STRENGTH; AL0864_i_StatisticIndex <= C6_STATISTIC_ANTIFIRE; AL0864_i_StatisticIndex++) {
                                if ((L0865_ps_Champion->Statistics[AL0864_i_StatisticIndex][C1_CURRENT] < L0865_ps_Champion->Statistics[AL0864_i_StatisticIndex][C0_MAXIMUM])) {
                                        AL0870_i_NativeBitmapIndex = C034_GRAPHIC_SLOT_BOX_WOUNDED;
                                        break;
                                }
                        }
#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(AL0870_i_NativeBitmapIndex), G0049_ai_Graphic562_Box_Eye, C016_BYTE_WIDTH, C12_COLOR_DARKEST_GRAY, 18);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0619_GetSlotBoxBorderCoordinates(C546_ZONE_EYE, L2260_ai_XYZ);
                        F0657_BlitBitmapIndexToViewportZoneWithTransparency(AL0870_i_NativeBitmapIndex, L2260_ai_XYZ, C12_COLOR_DARKEST_GRAY);
#endif
                        M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
                }
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x2000_WOUNDS)) {
#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
                for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? C05_SLOT_FEET : C01_SLOT_ACTION_HAND; AL0864_i_SlotIndex >= C00_SLOT_READY_HAND; AL0864_i_SlotIndex--) {
                        F0291_CHAMPION_DrawSlot(P0615_ui_ChampionIndex, AL0864_i_SlotIndex);
                }
#endif
                if (L0863_B_IsInventoryChampion) {
                        M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
                }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                else {
                        if (!L2259_B_MousePointerHidden) {
                                L2259_B_MousePointerHidden = C1_TRUE;
                                F0077_MOUSE_EnableScreenUpdate_CPSE();
                        }
                }
                for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? C05_SLOT_FEET : C01_SLOT_ACTION_HAND; AL0864_i_SlotIndex >= C00_SLOT_READY_HAND; AL0864_i_SlotIndex--) {
                        F0291_CHAMPION_DrawSlot(P0615_ui_ChampionIndex, AL0864_i_SlotIndex);
                }
#endif
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x0200_LOAD) && L0863_B_IsInventoryChampion) {
                if (L0865_ps_Champion->Load > (AL0864_i_Load = F0309_CHAMPION_GetMaximumLoad(L0865_ps_Champion))) {
                        AL0870_i_Color = C08_COLOR_RED;
                } else {
                        if (((long)L0865_ps_Champion->Load << 3) > ((long)AL0864_i_Load * 5)) {
                                AL0870_i_Color = C11_COLOR_YELLOW;
                        } else {
                                AL0870_i_Color = C13_COLOR_LIGHTEST_GRAY;
                        }
                }
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_08_OPTIMIZATION */
                F0052_TEXT_PrintToViewport(104, 132, AL0870_i_Color, "LOAD");
#endif
#ifdef MEDIA249_S12E_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A21E_A22E /* CHANGE3_08_OPTIMIZATION Trailing space characters removed from strings */
                F0052_TEXT_PrintToViewport(104, 132, AL0870_i_Color, "LOAD ");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                F0052_TEXT_PrintToViewport(104, 132, AL0870_i_Color, "LAST ");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                F0052_TEXT_PrintToViewport(104, 132, AL0870_i_Color, "CHARGE ");
#endif
#ifdef MEDIA561_F20E_I34E_A31E_A35E_F31E
                F0648_PrintTextInViewportZone(C554_ZONE_CHAMPION_LOAD_LABEL, AL0870_i_Color, "LOAD ");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                F0648_PrintTextInViewportZone(C554_ZONE_CHAMPION_LOAD_LABEL, AL0870_i_Color, F0758_TranslateLanguage(C36_CHAMPION_LOAD_LABEL));
#endif
                AL0864_i_Load = L0865_ps_Champion->Load / 10;
                M547_STRCPY(G0353_ac_StringBuildBuffer, F0288_CHAMPION_GetStringFromInteger(AL0864_i_Load, C1_TRUE, 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(G0353_ac_StringBuildBuffer, ".");
#endif
#ifdef MEDIA255_S12G_A20G_A22G /* CHANGE4_00_LOCALIZATION Translation to German language */
                strcat(G0353_ac_StringBuildBuffer, ",");
#endif
#ifdef MEDIA261_S13FA_S13FB_A20F /* CHANGE5_00_LOCALIZATION Translation to French language */
                strcat(G0353_ac_StringBuildBuffer, "KG,");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                M545_STRCAT(G0353_ac_StringBuildBuffer, F0758_TranslateLanguage(C38_CHAMPION_LOAD_DECIMAL_SEPARATOR));
#endif
                AL0864_i_Load = L0865_ps_Champion->Load - (AL0864_i_Load * 10);
                M545_STRCAT(G0353_ac_StringBuildBuffer, F0288_CHAMPION_GetStringFromInteger(AL0864_i_Load, C0_FALSE, 1));
                M545_STRCAT(G0353_ac_StringBuildBuffer, "/");
                AL0864_i_Load = (F0309_CHAMPION_GetMaximumLoad(L0865_ps_Champion) + 5) / 10;
                M545_STRCAT(G0353_ac_StringBuildBuffer, F0288_CHAMPION_GetStringFromInteger(AL0864_i_Load, C1_TRUE, 3));
#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(G0353_ac_StringBuildBuffer, " KG");
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                M545_STRCAT(G0353_ac_StringBuildBuffer, F0758_TranslateLanguage(C40_CHAMPION_LOAD_KILOGRAM));
#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(148, 132, AL0870_i_Color, G0353_ac_StringBuildBuffer);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0648_PrintTextInViewportZone(C555_ZONE_CHAMPION_LOAD_VALUE, AL0870_i_Color, G0353_ac_StringBuildBuffer);
#endif
                M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
        }
        AL0864_i_ChampionIconIndex = M026_CHAMPION_ICON_INDEX(L0865_ps_Champion->Cell, G0308_i_PartyDirection);
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x0400_ICON) && (G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap != M000_INDEX_TO_ORDINAL(AL0864_i_ChampionIconIndex))) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                M524_FillScreenBox(&G0054_ai_Graphic562_Box_ChampionIcons[AL0864_i_ChampionIconIndex << 2], G0046_auc_Graphic562_ChampionColor[P0615_ui_ChampionIndex]);
#endif
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
                F0132_VIDEO_Blit(F0489_MEMORY_GetNativeBitmapOrGraphic(C028_GRAPHIC_CHAMPION_ICONS), G0348_Bitmap_Screen, &G0054_ai_Graphic562_Box_ChampionIcons[AL0864_i_ChampionIconIndex << 2], M026_CHAMPION_ICON_INDEX(L0865_ps_Champion->Direction, G0308_i_PartyDirection) * 19, 0, C040_BYTE_WIDTH, C160_BYTE_WIDTH_SCREEN, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0132_VIDEO_Blit(F0489_MEMORY_GetNativeBitmapOrGraphic(C028_GRAPHIC_CHAMPION_ICONS), G0348_Bitmap_Screen, &G0054_ai_Graphic562_Box_ChampionIcons[AL0864_i_ChampionIconIndex << 2], M026_CHAMPION_ICON_INDEX(L0865_ps_Champion->Direction, G0308_i_PartyDirection) * 19, 0, C040_BYTE_WIDTH, C160_BYTE_WIDTH_SCREEN, C12_COLOR_DARKEST_GRAY, 14, C200_HEIGHT_SCREEN);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (!L2259_B_MousePointerHidden) {
                        L2259_B_MousePointerHidden = C1_TRUE;
                        F0077_MOUSE_EnableScreenUpdate_CPSE();
                }
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                L0866_pc_ChampionName = (char*)F0468_MEMORY_Allocate((long)M103_BITMAP_BYTE_COUNT(G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight), 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
                L0866_pc_ChampionName = M772_CAST_PC(F0606_AllocateMemForGraphic(G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP));
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0622_PrepareChampionIconBitmap((unsigned char*)L0866_pc_ChampionName, P0615_ui_ChampionIndex);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                F0733_FillZoneByIndex(AL0864_i_ChampionIconIndex + C113_ZONE_CHAMPION_ICON_TOP_LEFT, C00_COLOR_BLACK);
                F0021_MAIN_BlitToScreen(M774_CAST_PUC(L0866_pc_ChampionName), AL0864_i_ChampionIconIndex + C113_ZONE_CHAMPION_ICON_TOP_LEFT, C12_COLOR_DARKEST_GRAY);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0621_ClearChampionIconBox(AL0864_i_ChampionIconIndex);
                F0021_MAIN_BlitToScreen(M774_CAST_PUC(L0866_pc_ChampionName), AL0864_i_ChampionIconIndex + C113_ZONE_CHAMPION_ICON_TOP_LEFT, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                F0469_MEMORY_FreeAtHeapTop((long)M103_BITMAP_BYTE_COUNT(G2080_C19_ChampionIconWidth, G2081_C14_ChampionIconHeight) + 4);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0607_FreeMemForGraphic(M774_CAST_PUC(L0866_pc_ChampionName));
#endif
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x0800_PANEL) && L0863_B_IsInventoryChampion) {
                if (G0333_B_PressingMouth) {
                        F0345_INVENTORY_DrawPanel_FoodWaterPoisoned();
                } else {
                        if (G0331_B_PressingEye) {
                                if (G0415_ui_LeaderEmptyHanded) {
                                        F0351_INVENTORY_DrawChampionSkillsAndStatistics();
#ifdef MEDIA629_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                } else {
                                        if ((G0424_i_PanelContent == C09_PANEL_CREATURE_NAME_SCROLL) || (G0424_i_PanelContent == C10_PANEL_MAGIC_MAP_SCROLL)) {
                                                F0342_INVENTORY_DrawPanel_Object(G4055_s_LeaderHandObject.Thing, C1_TRUE);
                                        }
#endif
                                }
                        } else {
                                F0347_INVENTORY_DrawPanel();
                        }
                }
                M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x8000_ACTION_HAND)) {
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (!L2259_B_MousePointerHidden) {
                        L2259_B_MousePointerHidden = C1_TRUE;
                        F0077_MOUSE_EnableScreenUpdate_CPSE();
                }
#endif
                F0291_CHAMPION_DrawSlot(P0615_ui_ChampionIndex, C01_SLOT_ACTION_HAND);
                F0386_MENUS_DrawActionIcon(P0615_ui_ChampionIndex);
                if (L0863_B_IsInventoryChampion) {
                        M008_SET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT);
                }
        }
        if (M007_GET(L0862_ui_ChampionAttributes, MASK0x4000_VIEWPORT)) {
#ifdef MEDIA481_P20JB_I34E_I34M_F31E_F31J_P31J
                if (G2106_B_ShowMusicState) {
#endif
#ifdef MEDIA505_F20E_F20J_P20JB_I34E_I34M_F31E_F31J_P31J
                        if (G2024_B_PendingMusicOn) {
                                F0658_BlitBitmapIndexToZoneIndexWithTransparency(M713_NEGGRAPHIC_MUSIC_ICON, M701_ZONE_TOGGLE_MUSIC_ICON, CM1_COLOR_NO_TRANSPARENCY);
                        } else {
                                F0734_ClearZoneInInventory(M701_ZONE_TOGGLE_MUSIC_ICON);
                        }
#endif
#ifdef MEDIA481_P20JB_I34E_I34M_F31E_F31J_P31J
                }
#endif
                F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
        }
        T0292042:
        M009_CLEAR(L0865_ps_Champion->Attributes, MASK0x0080_NAME_TITLE | MASK0x0100_STATISTICS | MASK0x0200_LOAD | MASK0x0400_ICON | MASK0x0800_PANEL | MASK0x1000_STATUS_BOX | MASK0x2000_WOUNDS | MASK0x4000_VIEWPORT | MASK0x8000_ACTION_HAND);
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (L2259_B_MousePointerHidden)
#endif
                F0078_MOUSE_DisableScreenUpdate();
}

void F0293_CHAMPION_DrawAllChampionStates(
#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
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
void
#endif
)
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
unsigned int16_t P2062_ui_ FINAL_SEPARATOR
#endif
{
        REGISTER unsigned int16_t L0873_ui_ChampionIndex;


#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        M526_WaitVerticalBlank();
#endif
        for (L0873_ui_ChampionIndex = C00_CHAMPION_FIRST; L0873_ui_ChampionIndex < G0305_ui_PartyChampionCount; L0873_ui_ChampionIndex++) {
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                M516_CHAMPIONS[L0873_ui_ChampionIndex].Attributes |= P2062_ui_;
#endif
                F0292_CHAMPION_DrawState(L0873_ui_ChampionIndex);
        }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G2149_ = C0_FALSE;
#endif
}

#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#include "AMMO.C"
#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
BOOLEAN G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen;
#endif

STATICFUNCTION BOOLEAN F0295_CHAMPION_HasObjectIconInSlotBoxChanged(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0619_i_SlotBoxIndex, P0620_T_Thing)
REGISTER int16_t P0619_i_SlotBoxIndex SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t          P0619_i_SlotBoxIndex SEPARATOR
#endif
THING            P0620_T_Thing        FINAL_SEPARATOR
{
        REGISTER int16_t L0880_i_CurrentIconIndex;
        REGISTER int16_t L0881_i_NewIconIndex;


        L0880_i_CurrentIconIndex = F0039_OBJECT_GetIconIndexInSlotBox(P0619_i_SlotBoxIndex);
        if (((L0880_i_CurrentIconIndex < C032_ICON_WEAPON_DAGGER) && (L0880_i_CurrentIconIndex >= C000_ICON_JUNK_COMPASS_NORTH)) ||
            ((L0880_i_CurrentIconIndex >= C148_ICON_POTION_MA_POTION_MON_POTION) && (L0880_i_CurrentIconIndex <= C163_ICON_POTION_WATER_FLASK)) ||
            (L0880_i_CurrentIconIndex == C195_ICON_POTION_EMPTY_FLASK)) {
                L0881_i_NewIconIndex = F0033_OBJECT_GetIconIndex(P0620_T_Thing);
                if (L0881_i_NewIconIndex != L0880_i_CurrentIconIndex) {
                        if ((P0619_i_SlotBoxIndex < C08_SLOT_BOX_INVENTORY_FIRST_SLOT) && !G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen) {
                                G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen = C1_TRUE;
                                F0077_MOUSE_EnableScreenUpdate_CPSE();
                        }
                        F0038_OBJECT_DrawIconInSlotBox(P0619_i_SlotBoxIndex, L0881_i_NewIconIndex);
                        return C1_TRUE;
                }
        }
        return C0_FALSE;
}

/* This function draws visible object icons that have changed (in the leader hand, champion hands, champion inventory slots and open chest slots) */
void F0296_CHAMPION_DrawChangedObjectIcons(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER THING* L0886_pT_Thing;
        REGISTER CHAMPION* L0887_ps_Champion;
        REGISTER unsigned int16_t L0882_ui_Counter;
#define AL0882_ui_SlotBoxIndex L0882_ui_Counter
#define AL0882_ui_SlotIndex    L0882_ui_Counter
        REGISTER unsigned int16_t L0883_ui_InventoryChampionOrdinal;
        REGISTER int16_t L0884_i_Multiple;
#define AL0884_i_LeaderHandObjectIconIndex L0884_i_Multiple
#define AL0884_B_DrawViewport              L0884_i_Multiple
        REGISTER int16_t L0885_i_ChampionIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0888_i_IconIndex;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0888_i_IconIndex;
#endif
        unsigned int16_t L0889_ui_ObjectIconChanged;


        L0883_ui_InventoryChampionOrdinal = G0423_i_InventoryChampionOrdinal;
        if (G0299_ui_CandidateChampionOrdinal && !L0883_ui_InventoryChampionOrdinal) {
                return;
        }
        G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen = C0_FALSE;
        if ((((AL0884_i_LeaderHandObjectIconIndex = G4055_s_LeaderHandObject.IconIndex) < C032_ICON_WEAPON_DAGGER) && ((AL0884_i_LeaderHandObjectIconIndex = G4055_s_LeaderHandObject.IconIndex) >= C000_ICON_JUNK_COMPASS_NORTH)) || (((AL0884_i_LeaderHandObjectIconIndex = G4055_s_LeaderHandObject.IconIndex) >= C148_ICON_POTION_MA_POTION_MON_POTION) && ((AL0884_i_LeaderHandObjectIconIndex = G4055_s_LeaderHandObject.IconIndex) <= C163_ICON_POTION_WATER_FLASK)) || ((AL0884_i_LeaderHandObjectIconIndex = G4055_s_LeaderHandObject.IconIndex) == C195_ICON_POTION_EMPTY_FLASK)) {
                L0888_i_IconIndex = F0033_OBJECT_GetIconIndex(G4055_s_LeaderHandObject.Thing);
                if (L0888_i_IconIndex != AL0884_i_LeaderHandObjectIconIndex) {
                        G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen = C1_TRUE;
                        F0077_MOUSE_EnableScreenUpdate_CPSE();
                        F0036_OBJECT_ExtractIconFromBitmap(L0888_i_IconIndex, M775_CAST_PL(G4055_s_LeaderHandObject.BitmapIconForMousePointer));
                        F0068_MOUSE_SetPointerToObject(G4055_s_LeaderHandObject.BitmapIconForMousePointer);
                        G4055_s_LeaderHandObject.IconIndex = L0888_i_IconIndex;
                        F0034_OBJECT_DrawLeaderHandObjectName(G4055_s_LeaderHandObject.Thing);
                }
        }
        for (AL0882_ui_SlotBoxIndex = 0; AL0882_ui_SlotBoxIndex < (G0305_ui_PartyChampionCount << 1); AL0882_ui_SlotBoxIndex++) {
                L0885_i_ChampionIndex = AL0882_ui_SlotBoxIndex >> 1;
                if (L0883_ui_InventoryChampionOrdinal == M000_INDEX_TO_ORDINAL(L0885_i_ChampionIndex))
                        continue;
                if ((F0295_CHAMPION_HasObjectIconInSlotBoxChanged(AL0882_ui_SlotBoxIndex, M516_CHAMPIONS[L0885_i_ChampionIndex].Slots[M070_HAND_SLOT_INDEX(AL0882_ui_SlotBoxIndex)])) && (M070_HAND_SLOT_INDEX(AL0882_ui_SlotBoxIndex) == C01_SLOT_ACTION_HAND)) {
                        F0386_MENUS_DrawActionIcon(L0885_i_ChampionIndex);
                }
        }
        if (L0883_ui_InventoryChampionOrdinal) {
                L0887_ps_Champion = &M516_CHAMPIONS[M001_ORDINAL_TO_INDEX(L0883_ui_InventoryChampionOrdinal)];
                L0886_pT_Thing = &L0887_ps_Champion->Slots[AL0882_ui_SlotIndex = C00_SLOT_READY_HAND];
                for (AL0884_B_DrawViewport = C0_FALSE; AL0882_ui_SlotIndex < C30_SLOT_CHEST_1; AL0882_ui_SlotIndex++, L0886_pT_Thing++) {
                        AL0884_B_DrawViewport |= (L0889_ui_ObjectIconChanged = F0295_CHAMPION_HasObjectIconInSlotBoxChanged(AL0882_ui_SlotIndex + C08_SLOT_BOX_INVENTORY_FIRST_SLOT, *L0886_pT_Thing));
                        if (L0889_ui_ObjectIconChanged && (AL0882_ui_SlotIndex == C01_SLOT_ACTION_HAND)) {
                                F0386_MENUS_DrawActionIcon(M001_ORDINAL_TO_INDEX(L0883_ui_InventoryChampionOrdinal));
                        }
                }
#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 (G0424_i_PanelContent == M569_PANEL_CHEST) {
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (G2008_i_PanelContent == M569_PANEL_CHEST) {
#endif
                        L0886_pT_Thing = G0425_aT_ChestSlots;
                        for (AL0882_ui_SlotIndex = 0; AL0882_ui_SlotIndex < 8; AL0882_ui_SlotIndex++, L0886_pT_Thing++) {
                                AL0884_B_DrawViewport |= F0295_CHAMPION_HasObjectIconInSlotBoxChanged(AL0882_ui_SlotIndex + C38_SLOT_BOX_CHEST_FIRST_SLOT, *L0886_pT_Thing);
                        }
                }
                if (AL0884_B_DrawViewport) {
                        M008_SET(L0887_ps_Champion->Attributes, MASK0x4000_VIEWPORT);
                        F0292_CHAMPION_DrawState(M001_ORDINAL_TO_INDEX(L0883_ui_InventoryChampionOrdinal));
                }
        }
        if (G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen) {
                F0078_MOUSE_DisableScreenUpdate();
        }
}

#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
#include "PORTRAIT.C"
#endif
#endif
