#define ANOMALY_STARTUP2
#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 MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN G0523_B_RestartGameRequested;
BOOLEAN G0524_B_RestartGameAllowed;
BOOLEAN G1147_B_LoadBonusDungeon;
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN G2167_B_DisabledMenusDrawn;
#endif
#ifdef MEDIA758_A36M_A35E_A35M
char G2041_ac_MemoryProfiles[31] = {
        C0_MEM_, C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C5_MEM_MOVEMENT_SOUNDS, C2_MEM_UNUSED, C1_MEM_FLIPPED_WALS, 253, 120, 254,
        C0_MEM_, C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C5_MEM_MOVEMENT_SOUNDS, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C5_MEM_MOVEMENT_SOUNDS, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, 254,
        C3_MEM_BASE_SOUNDS, 254,
        254, 255 };
#endif
#ifdef MEDIA707_I34E_I34M
char G2041_ac_MemoryProfiles[22] = {
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C5_MEM_MOVEMENT_SOUNDS, C2_MEM_UNUSED, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C2_MEM_UNUSED, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, C1_MEM_FLIPPED_WALS, 254,
        C3_MEM_BASE_SOUNDS, C4_MEM_ATTACK_SOUNDS, 254,
        C3_MEM_BASE_SOUNDS, 254,
        254, 255 };
BOOLEAN G2131_B_Unused = C0_FALSE;
int16_t G2132_B_DotNotUseEMS = C0_FALSE;
int16_t G2133_i_EMSHandle = 0;
#endif
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
#ifndef NOCOPYPROTECTION
int16_t G0533_ai_CodePatch2_CPSE[34]; /* int16_t required for alignment in C35E (char fails) */
#endif
#endif
#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
long G2134_l_NeededMemoryByteCount = -10000000;
/* String "LIMITED SOUNDS" in F0463_START_InitializeGame_CPSADEF */
/* String "NO SOUNDS" in F0463_START_InitializeGame_CPSADEF */
/* align 2 */
#endif
#ifdef MEDIA712_I34E_I34M_F31E_F31J_P31J
unsigned char* G2165_puc_BaseMemoryBottom;
long G2166_l_BaseMemorySize; /* Some memory size drawn when "mem" typed in game */
#endif
#ifdef MEDIA707_I34E_I34M
unsigned char* G2168_puc_EMSMemoryBottom;
long G2169_l_EMSMemorySize; /* Some memory size drawn when "mem" typed in game */
#endif
#ifdef MEDIA577_X30J
unsigned long* G3085_pul_X68000_1024bytes;
unsigned char* G3083_puc_X68000_256bytes;
unsigned char* G3084_puc_X68000_4096bytes;
#endif
#ifdef MEDIA607_X30J_X31J
unsigned char* G2148_puc_InterfaceAndScrollsFontCustomColors;
unsigned int16_t* G3082_pui_CurrentPalette;
#endif
#ifdef MEDIA692_X31J
unsigned char* G3139_;
#endif
#ifdef MEDIA607_X30J_X31J
#ifndef NOCOPYPROTECTION
int16_t G3093_B_LatestReadingIdenticalToUltimateReading_CPSX;
int16_t G3094_B_LatestReadingIdenticalToPenultimateReading_CPSX;
#endif
#endif


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

#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#include "SAVEPATH.C"
#endif

#ifdef MEDIA707_I34E_I34M
/* Detecting presence of Expanded Memory Manager
        1.  attempt to open file/device 'EMMXXXX0' using INT 21,3D;
            if successful continue, else no EMM
        2.  make sure EMMXXXX0 is a character device and not a disk file
            by using IOCTL function 0 (Get Device Info);  bit 7 of DX
            should be set for char device and clear for disk file
        3.  make sure Expanded Memory Manager is available using IOCTL
            function 7 (Get Output Status);  AL should be non-zero (FF)
            if Memory Manager is available, and zero if not available.
        4.  call INT 67,46  to get version information
*/

BOOLEAN F0746_IsEMSPresent(
void
)
{
        int16_t L3035_i_FileHandle;


        asm     cmp     G2132_B_DotNotUseEMS, C0_FALSE
        asm     jz      loc_240F1
        asm     jmp     loc_2412F
        asm     V0746000_filename db 'EMMXXXX0',0
        loc_240F1:
        asm     push    ds
        asm     mov     dx, seg V0746000_filename
        asm     mov     ds, dx
        asm     mov     dx, offset V0746000_filename
        asm     mov     ax, 0x3D00
                                /* DOS - 2+ - OPEN DISK FILE WITH HANDLE */
        asm     int     0x21     /* DS:DX -> ASCIZ V0746000_filename, AL = access mode, 0 - read */
        asm     pop     ds
        asm     jb      loc_2412F
        asm     mov     L3035_i_FileHandle, ax
        asm     mov     bx, ax
        asm     mov     ax, 0x4400
                                /* DOS - 2+ - IOCTL - GET DEVICE INFORMATION */
        asm     int     0x21     /* BX = file or device handle */
        asm     jb      loc_24122
        asm     and     dx, 0x80
        asm     jz      loc_24122
        asm     mov     ax, 0x4407
                                /* DOS - 2+ - IOCTL - */
        asm     int     0x21
        asm     jb      loc_24122
        asm     or      al, al
        asm     jz      loc_24122
        asm     mov     si, 1
        loc_24122:
        asm     mov     bx, L3035_i_FileHandle
        asm     mov     ah, 0x3E
                                /* DOS - 2+ - CLOSE A FILE WITH HANDLE */
        asm     int     0x21     /* BX = file handle */
        asm     jb      loc_2412F
        asm     mov     ax, si
        asm     jmp     loc_24131
        loc_2412F:
        asm     xor     ax, ax
        loc_24131: ;
}

int16_t F0747_EMM_GetVersion(
void
)
{
        unsigned char L3036_uc_Byte[2];

        asm     mov     ah, 0x46
        asm     int     0x67     /* LIM EMS - GET EMM VERSION */
        L3036_uc_Byte[1] = _AL;
        return L3036_uc_Byte[1] >> 4;
}

long F0748_Get_EMS_Memory(
unsigned char** P2152_ppuc_EMSPageFrame FINAL_SEPARATOR
{
        unsigned int16_t* L3037_pui_Buffer;
        unsigned int16_t L3038_ui_;
        unsigned int16_t L3039_ui_PageCount;
        unsigned int16_t L3040_ui_UnallocatedPageCount;
        unsigned int16_t L3041_ui_;
        int16_t L3042_i_;
        unsigned int16_t L3043_ui_;
        int16_t L3044_i_;
        int16_t L3045_i_;
        int16_t L3046_i_;
#define AL3046_i_EMMVersion L3046_i_
        unsigned int16_t L3047_aaui_[64][2]; /* Two ints: Segment Address (conv mem or EMS frame) / EMS page number */
        unsigned int16_t L3048_aui_[64];


        L3037_pui_Buffer = L3047_aaui_[0];
        *P2152_ppuc_EMSPageFrame = NULL;
        if (F0746_IsEMSPresent()) {
                asm     mov     ah, 0x42
                asm     int     0x67     /* - LIM EMS - GET NUMBER OF PAGES */
                                        /* Return: AH = 00h function successful, BX = number of unallocated pages, DX = total number of pages, AH = error code */
                L3040_ui_UnallocatedPageCount = _BX;
                if ((AL3046_i_EMMVersion = F0747_EMM_GetVersion()) >= 4) {
                        asm     mov     ax, 0x5800
                        asm     les     di, L3037_pui_Buffer
                        asm     int     0x67     /* - LIM EMS 4.0 - GET MAPPABLE PHYSICAL ADDRESS ARRAY */
                                                /* AL = get mappable physical address array, ES:DI -> buffer to be filled with array */
                        L3041_ui_ = _CX;
                        L3045_i_ = 0;
                        for (L3046_i_ = 0; L3046_i_ < L3041_ui_; L3046_i_++) {
                                L3048_aui_[L3046_i_] = 0;
                                if ((L3043_ui_ = L3047_aaui_[L3046_i_][0]) >= 0xC800) {
                                        if (L3044_i_ + 1024 == L3043_ui_) {
                                                L3048_aui_[L3045_i_]++;
                                        } else {
                                                L3045_i_ = L3046_i_;
                                                L3048_aui_[L3046_i_] = 1;
                                        }
                                }
                                L3044_i_ = L3043_ui_;
                        }
                        L3038_ui_ = 0;
                        L3039_ui_PageCount = 0;
                        for (L3046_i_ = 0; L3046_i_ < L3041_ui_; L3046_i_++) {
                                if (L3048_aui_[L3046_i_] > L3039_ui_PageCount) {
                                        L3038_ui_ = L3047_aaui_[L3046_i_][0];
                                        L3039_ui_PageCount = L3048_aui_[L3046_i_];
                                        L3045_i_ = L3046_i_;
                                }
                        }
                        if (L3040_ui_UnallocatedPageCount < L3039_ui_PageCount) {
                                L3039_ui_PageCount = L3040_ui_UnallocatedPageCount;
                        }
                        asm     mov     bx, L3039_ui_PageCount
                        asm     mov     ah, 0x43
                        asm     int     0x67     /* - LIM EMS - GET HANDLE AND ALLOCATE MEMORY */
                                                /* BX = number of logical pages to allocate, Return: AH = status */
                        G2133_i_EMSHandle = _DX;
                        for (L3046_i_ = 0; L3046_i_ < L3039_ui_PageCount; L3046_i_++) {
                                L3043_ui_ = L3047_aaui_[L3046_i_ + L3045_i_][0];
                                L3047_aaui_[L3046_i_ + L3045_i_][0] = L3046_i_;
                                L3047_aaui_[L3046_i_ + L3045_i_][1] = L3043_ui_;
                        }
                        L3037_pui_Buffer = L3047_aaui_[L3045_i_];
                        asm     push    ds
                        asm     mov     ax, 0x5001
                        asm     mov     cx, L3039_ui_PageCount
                        asm     mov     dx, G2133_i_EMSHandle
                        asm     lds     si, L3037_pui_Buffer
                        asm     int     0x67     /* - LIM EMS 4.0 - MAP/UNMAP MULTIPLE HANDLE PAGES */
                                                /* AL = 00h / 01h, DX = handle, CX = number of entries in array, DS:SI -> mapping array, Return: AH = status */
                        asm     pop     ds
                        if (L3039_ui_PageCount <= 0) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE nop */
                                return 0;
                        }
                        asm     mov     ax, L3038_ui_
                        asm     les     bx, P2152_ppuc_EMSPageFrame
                        asm     mov     word ptr es:[bx], 0
                        asm     mov     es:[bx+2], ax
                        return (long)L3039_ui_PageCount << 14; /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE nop */
                } else {
                        if (AL3046_i_EMMVersion == 3) {
                                if (L3040_ui_UnallocatedPageCount > 4) {
                                        L3040_ui_UnallocatedPageCount = 4;
                                }
                                asm     mov     ah, 0x41
                                asm     int     0x67             /* - LIM EMS - GET PAGE FRAME SEGMENT */
                                                                /* Return: AH = 00h function successful, BX = segment of page frame, AH = error code */
                                L3042_i_ = _BX;
                                asm     mov     ax, L3042_i_
                                asm     les     bx, P2152_ppuc_EMSPageFrame
                                asm     mov     word ptr es:[bx], 0
                                asm     mov     es:[bx+2], ax
                                asm     mov     bx, L3040_ui_UnallocatedPageCount
                                asm     mov     ah, 0x43
                                asm     int     0x67     /* - LIM EMS - GET HANDLE AND ALLOCATE MEMORY */
                                                        /* BX = number of logical pages to allocate, Return: AH = status */
                                G2133_i_EMSHandle = _DX;
                                for (L3046_i_ = 0; L3046_i_ < L3040_ui_UnallocatedPageCount; L3046_i_++) {
                                        asm     mov     dx, G2133_i_EMSHandle
                                        asm     mov     ax, L3046_i_
                                        asm     mov     bx, ax
                                        asm     mov     ah, 0x44
                                        asm     int     0x67     /* - LIM EMS - MAP MEMORY */
                                                                /* AL = physical page number (0-3), BX = logical page number, DX = handle, Return: AH = status */
                                }
                                return (long)L3040_ui_UnallocatedPageCount << 14; /* The size of an EMS page is 16 KB = 2^14 bytes */
                        }
                }
        }
        return 0;
}

void F0749_EMM_ReleaseHandle(
void
)
{
        if (G2133_i_EMSHandle) {
                asm     mov     dx, G2133_i_EMSHandle
                asm     mov     ah, 0x45
                asm     int     0x67     /*  - LIM EMS - RELEASE HANDLE AND MEMORY */
                                        /* DX = EMM handle, Return: AH = status */
        }
}
#endif

#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
#include "STARTUP1.C"
#endif

#ifdef MEDIA712_I34E_I34M_F31E_F31J_P31J
void F0750_CPSX(
void
)
{
        F0740_MUSIC_Pause();
#ifdef MEDIA707_I34E_I34M
        F0749_EMM_ReleaseHandle();
#endif
#ifdef MEDIA709_I34E_I34M_P31J
        farfree(G2165_puc_BaseMemoryBottom);
#endif
#ifdef MEDIA670_F31E_F31J
        F2244_CallFree(G2165_puc_BaseMemoryBottom);
#endif
        if (G0302_B_GameWon) {
#ifdef MEDIA667_P31J
                setvect(C253_INTERRUPT, (void interrupt (*)())"anim ending.anm");
                exit(1);
#endif
#ifdef MEDIA670_F31E_F31J
                F0077_MOUSE_EnableScreenUpdate_CPSE();
                F2248_PlayAnimation("ending.anm");
#endif
#ifdef MEDIA707_I34E_I34M
                if (G0302_B_GameWon) {
                        _exit(1);
                }
#endif
        }
#ifdef MEDIA670_F31E_F31J
        F2247_RESTORE_TOWNS();
#endif
#ifdef MEDIA671_F31E_F31J_P31J
        exit(0);
#endif
#ifdef MEDIA707_I34E_I34M
        _exit(0);
#endif
}
#endif

void F0456_START_DrawDisabledMenus(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        if (!G0300_B_PartyIsResting) {
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (!G2167_B_DisabledMenusDrawn && !G2062_DialogSetIndex) {
                G2167_B_DisabledMenusDrawn = C1_TRUE;
                F0703_ReleaseChampionIcon();
#endif
                F0077_MOUSE_EnableScreenUpdate_CPSE();
                F0363_COMMAND_HighlightBoxDisable();
#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
                if (G0423_i_InventoryChampionOrdinal) {
#ifdef MEDIA177_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA /* CHANGE8_09_FIX Make sure the chest is always closed */
                        if (G0424_i_PanelContent == M569_PANEL_CHEST) {
#endif
#ifdef MEDIA006_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB /* CHANGE7_38_OPTIMIZATION */
                                F0347_INVENTORY_DrawPanel();
#endif
#ifdef MEDIA278_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 /* CHANGE7_38_OPTIMIZATION Function call replaced by an equivalent call. The previous call to F0347_INVENTORY_DrawPanel() caused the chest to be closed and opened again but only closing is really necessary. Each time F0456_START_DrawDisabledMenus is called, the panel is overwritten anyway (by the save game dialog, the Rest screen or the Freeze Game screen) so drawing the chest contents is not necessary */
                                F0334_INVENTORY_CloseChest();
#endif
#ifdef MEDIA177_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA /* CHANGE8_09_FIX */
                        }
#endif
                } else {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        F0136_VIDEO_HatchScreenBox(G0002_ai_Graphic562_Box_MovementArrows, C00_COLOR_BLACK);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0136_VIDEO_HatchScreenBox(C009_ZONE_MOVEMENT_ARROWS, C00_COLOR_BLACK);
#endif
                }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                F0136_VIDEO_HatchScreenBox(G0000_ai_Graphic562_Box_SpellArea, C00_COLOR_BLACK);
                F0136_VIDEO_HatchScreenBox(G0001_ai_Graphic562_Box_ActionArea, C00_COLOR_BLACK);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0136_VIDEO_HatchScreenBox(C013_ZONE_SPELL_AREA, C00_COLOR_BLACK);
                F0136_VIDEO_HatchScreenBox(C011_ZONE_ACTION_AREA, C00_COLOR_BLACK);
#endif
                F0067_MOUSE_SetPointerToNormal(C0_POINTER_ARROW); /* BUG0_60 On the Reincarnate/Resurrect screen, the 'Arrow' mouse pointer is replaced by the 'Hand' pointer after you grab an object and put it back. After an object is placed in the inventory, the mouse pointer is always set to the 'Hand' without checking if the Reincarnate/Resurrect buttons are on screen. When called by F0280_CHAMPION_AddCandidateChampionToParty this replaces the Hand pointer by the Arrow pointer */
                F0078_MOUSE_DisableScreenUpdate();
        }
}

void F0457_START_DrawEnabledMenus_CPSF(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER int16_t L1462_i_Multiple;
#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple


#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        if (G2167_B_DisabledMenusDrawn && !G2062_DialogSetIndex) {
#endif
                if (G0300_B_PartyIsResting) {
                        F0379_COMMAND_DrawRestScreen();
                        F0097_DUNGEONVIEW_DrawViewport(C0_VIEWPORT_NOT_DUNGEON_VIEW);
                } else {
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G2167_B_DisabledMenusDrawn = C0_FALSE;
#endif
                        AL1462_i_MagicCasterChampionIndex = G0514_i_MagicCasterChampionIndex;
                        G0514_i_MagicCasterChampionIndex = CM1_CHAMPION_NONE; /* Force next function to draw the spell area */
                        F0394_MENUS_SetMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_10_FIX The variable defining what to draw in the action area is set in the appropriate function */
                        if (!G0506_ui_ActingChampionOrdinal) {
                                G0509_B_ActionAreaContainsIcons = C1_TRUE;
                        }
#endif
                        F0387_MENUS_DrawActionArea();
                        if (AL1462_i_InventoryChampionOrdinal = G0423_i_InventoryChampionOrdinal) {
                                G0423_i_InventoryChampionOrdinal = M000_INDEX_TO_ORDINAL(CM1_CHAMPION_NONE);
                                F0355_INVENTORY_Toggle_CPSE(M001_ORDINAL_TO_INDEX(AL1462_i_InventoryChampionOrdinal));
                        } else {
                                F0098_DUNGEONVIEW_DrawFloorAndCeiling();
                                F0395_MENUS_DrawMovementArrows();
                        }
                        F0069_MOUSE_SetPointer();
                }
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
#endif
#ifdef MEDIA137_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#ifndef NOCOPYPROTECTION
        G0328_i_TimeBombToKillParty_CPSF = 0;
#endif
#endif
}

#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
#ifndef NOCOPYPROTECTION
int16_t F0458_START_GetCommandLineParameters_CPSA(
P0866_pc_CommandLineParameters)
char* P0866_pc_CommandLineParameters FINAL_SEPARATOR
{
        REGISTER int16_t L1463_i_CommandLineLength;
        REGISTER int16_t L1464_i_Character;
        REGISTER unsigned char* L1465_puc_CommandLineParameters;


        L1465_puc_CommandLineParameters = (unsigned char*)_base + 128; /* Address of command line parameters in the process base page */
        L1463_i_CommandLineLength = *L1465_puc_CommandLineParameters++;
        for (L1464_i_Character = 0; L1464_i_Character < L1463_i_CommandLineLength; L1464_i_Character++) {
                P0866_pc_CommandLineParameters[L1464_i_Character] = (char)L1465_puc_CommandLineParameters[L1464_i_Character];
        }
        P0866_pc_CommandLineParameters[++L1464_i_Character] = '\0';
        return L1463_i_CommandLineLength;
}
#endif
#endif

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

#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
#ifdef MEDIA719_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_P31J
unsigned int16_t F0751_GetBitmapByteCount(
#endif
#ifdef MEDIA692_X31J
long F0751_GetBitmapByteCount(
#endif
int16_t P2153_i_GraphicIndex FINAL_SEPARATOR
{
        return M103_BITMAP_BYTE_COUNT(G2005_GraphicWidthHeight[P2153_i_GraphicIndex].Width, G2005_GraphicWidthHeight[P2153_i_GraphicIndex].Height);
}
#endif

#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
STATICFUNCTION void F0752_AllocateAndSetNegativeBitmapPointer(
int16_t P2154_i_             SEPARATOR
int16_t P2155_i_GraphicIndex FINAL_SEPARATOR
{
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        F0632_COORD_SetNegativeBitmapPointer(P2154_i_, F0468_MEMORY_Allocate((long)M103_BITMAP_BYTE_COUNT(G2005_GraphicWidthHeight[P2155_i_GraphicIndex].Width, G2005_GraphicWidthHeight[P2155_i_GraphicIndex].Height), MASK0x8000_ALLOCATE_BITMAP | C1_ALLOCATION_PERMANENT));
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0632_COORD_SetNegativeBitmapPointer(P2154_i_, F0606_AllocateMemForGraphic(G2005_GraphicWidthHeight[P2155_i_GraphicIndex].Width, G2005_GraphicWidthHeight[P2155_i_GraphicIndex].Height, C1_ALLOCATION_PERMANENT));
#endif
}

STATICFUNCTION void F0753_(
int16_t P2156_i_GraphicIndex SEPARATOR
int16_t P2157_i_             FINAL_SEPARATOR
{
        F0632_COORD_SetNegativeBitmapPointer(P2157_i_, F0631_GetBitmapPointer(P2156_i_GraphicIndex));
}
#endif

void F0460_START_InitializeGraphicData(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
        REGISTER OBJECT_ASPECT* L1470_ps_ObjectAspect;
        REGISTER CREATURE_ASPECT* L1471_ps_CreatureAspect;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER PROJECTIL_ASPECT* L1472_ps_ProjectileAspect;
        REGISTER int16_t L1468_i_DerivedBitmapIndex;
#endif
        REGISTER int16_t L1466_i_Multiple;
#define AL1466_i_DoorOrnamentIndex     L1466_i_Multiple
#define AL1466_i_ObjectAspectIndex     L1466_i_Multiple
#define AL1466_i_ProjectileAspectIndex L1466_i_Multiple
#define AL1466_i_ExplosionAspectIndex  L1466_i_Multiple
#define AL1466_i_CreatureGraphicInfo   L1466_i_Multiple
#define AL1466_i_NativeBitmapIndex     L1466_i_Multiple
        REGISTER int16_t L1467_i_Multiple;
#define AL1467_i_ProjectileScaleIndex L1467_i_Multiple
#define AL1467_i_Scale                L1467_i_Multiple
#define AL1467_i_CreatureIndex        L1467_i_Multiple
#define AL1467_i_NativeBitmapIndex    L1467_i_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        register int16_t L1468_i_DerivedBitmapIndex;
        register int16_t L1469_i_BitmapByteCount;
        PROJECTIL_ASPECT* L1472_ps_ProjectileAspect;
        EXPLOSION_ASPECT* L1473_ps_ExplosionAspect;
        int16_t L1474_i_CreatureFrontBitmapD2ByteCount;
        int16_t L1475_i_Multiple;
#define AL1475_i_CreatureFrontBitmapD3ByteCount L1475_i_Multiple
#define AL1475_i_AdditionalFrontGraphicCount    L1475_i_Multiple
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L3049_i_Multiple;
#define AL3049_i_NativeBitmapIndex           L3049_i_Multiple
#define AL3049_i_Counter                     L3049_i_Multiple
#define AL3049_i_CreatureGraphicInfo         L3049_i_Multiple
#define AL3049_i_AdditionalFrontGraphicCount L3049_i_Multiple
#endif
#ifdef MEDIA534_F20E_F20J_X30J_P20JA_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J
        REGISTER int16_t L3050_;
        int16_t L3051_;
#endif
#ifdef MEDIA692_X31J
        register long L3050_;
        long L3051_;
#endif


#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0085_puc_Bitmap_Ceiling = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(224, 29), C1_ALLOCATION_PERMANENT);
        G0084_puc_Bitmap_Floor = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(224, 70), C1_ALLOCATION_PERMANENT);
        G0697_puc_Bitmap_WallSet_Wall_D3L2 = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(16, 49), C1_ALLOCATION_PERMANENT);
        G0696_puc_Bitmap_WallSet_Wall_D3R2 = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(16, 49), C1_ALLOCATION_PERMANENT);
        G0698_puc_Bitmap_WallSet_Wall_D3LCR = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(128, 51), C1_ALLOCATION_PERMANENT);
        G0699_puc_Bitmap_WallSet_Wall_D2LCR = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(144, 71), C1_ALLOCATION_PERMANENT);
        G0700_puc_Bitmap_WallSet_Wall_D1LCR = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(256, 111), C1_ALLOCATION_PERMANENT);
        G0701_puc_Bitmap_WallSet_Wall_D0L = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 136), C1_ALLOCATION_PERMANENT);
        G0702_puc_Bitmap_WallSet_Wall_D0R = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 136), C1_ALLOCATION_PERMANENT);
        G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(96, 3), C1_ALLOCATION_PERMANENT);
        G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(128, 4), C1_ALLOCATION_PERMANENT);
        G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 43), C1_ALLOCATION_PERMANENT);
        G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 44), C1_ALLOCATION_PERMANENT);
        G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(48, 65), C1_ALLOCATION_PERMANENT);
        G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 94), C1_ALLOCATION_PERMANENT);
        G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 94), C1_ALLOCATION_PERMANENT);
        G0709_puc_Bitmap_WallSet_DoorFrameFront = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 123), C1_ALLOCATION_PERMANENT);
        G0296_puc_Bitmap_Viewport = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(224, 136), C1_ALLOCATION_PERMANENT);
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
        G0086_puc_Bitmap_ViewportBlackArea = G0296_puc_Bitmap_Viewport + M075_BITMAP_BYTE_COUNT(224, 29);
        G0087_puc_Bitmap_ViewportFloorArea = G0086_puc_Bitmap_ViewportBlackArea + M075_BITMAP_BYTE_COUNT(224, 37);
#endif
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | C558_GRAPHIC_GLOBAL_VARIABLES, &G0229_i_Graphic558Anchor + 1, 0, 0); /* +1 adds two bytes as &G0229_i_Graphic558Anchor is pointer to an int16_t */
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | C561_GRAPHIC_GLOBAL_VARIABLES, &G0479_i_Graphic561Anchor + 1, 0, 0);
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | C560_GRAPHIC_GLOBAL_VARIABLES, &G0505_i_Graphic560Anchor + 1, 0, 0);
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | C559_GRAPHIC_GLOBAL_VARIABLES, &G0259_i_Graphic559Anchor + 1, 0, 0);
        F0490_MEMORY_LoadDecompressAndExpandGraphic(MASK0x8000_NOT_EXPANDED | C562_GRAPHIC_GLOBAL_VARIABLES, &G0067_i_Graphic562Anchor + 1, 0, 0);
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0086_puc_Bitmap_ViewportBlackArea = G0296_puc_Bitmap_Viewport + M091_BITPLANE_SIZE(224, 29);
        G0087_puc_Bitmap_ViewportFloorArea = G0086_puc_Bitmap_ViewportBlackArea + M091_BITPLANE_SIZE(224, 37);
#endif
        G0639_DerivedBitmapByteCount[C000_DERIVED_BITMAP_VIEWPORT] = M075_BITMAP_BYTE_COUNT(224, 136);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0752_AllocateAndSetNegativeBitmapPointer(G2109_Ceiling, M651_GRAPHIC_FLOOR_SET_0_CEILING);
        F0752_AllocateAndSetNegativeBitmapPointer(G2108_Floor, M650_GRAPHIC_FLOOR_SET_0_FLOOR);
#endif
#ifdef MEDIA506_F20E_F20J_X30J
        F0752_AllocateAndSetNegativeBitmapPointer(G3072_i_WallSet_Wall_D3R2, M663_GRAPHIC_WALLSET_0_D3L2);
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        F0752_AllocateAndSetNegativeBitmapPointer(G3010_i_WallSet_Wall_D3L2, M663_GRAPHIC_WALLSET_0_D3L2);
        F0752_AllocateAndSetNegativeBitmapPointer(G3011_i_WallSet_Wall_D3C, C088_GRAPHIC_WALLSET_0_D3LCR);
        F0753_(G3011_i_WallSet_Wall_D3C, G3005_i_WallSet_Wall_D3R);
        F0753_(G3011_i_WallSet_Wall_D3C, G3004_i_WallSet_Wall_D3L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3012_i_WallSet_Wall_D2C, C087_GRAPHIC_WALLSET_0_D2LCR);
        F0753_(G3012_i_WallSet_Wall_D2C, G3007_i_WallSet_Wall_D2R);
        F0753_(G3012_i_WallSet_Wall_D2C, G3006_i_WallSet_Wall_D2L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3013_i_WallSet_Wall_D1C, C086_GRAPHIC_WALLSET_0_D1LCR);
        F0753_(G3013_i_WallSet_Wall_D1C, G3009_i_WallSet_Wall_D1R);
        F0753_(G3013_i_WallSet_Wall_D1C, G3008_i_WallSet_Wall_D1L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3014_i_WallSet_Wall_D0L, M662_GRAPHIC_WALLSET_0_D0L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3015_i_WallSet_Wall_D0R, M661_GRAPHIC_WALLSET_0_D0R);
        F0752_AllocateAndSetNegativeBitmapPointer(G2115_DoorFrameTopD2LCR, M660_GRAPHIC_WALLSET_0_DOOR_FRAME_TOP_D2LCR);
        F0753_(G2115_DoorFrameTopD2LCR, G2113_DoorFrameTopD2R);
        F0753_(G2115_DoorFrameTopD2LCR, G2114_DoorFrameTopD2L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2112_DoorFrameTopD1LCR, M659_GRAPHIC_WALLSET_0_DOOR_FRAME_TOP_D1LCR);
        F0753_(G2112_DoorFrameTopD1LCR, G2110_DoorFrameTopD1R);
        F0753_(G2112_DoorFrameTopD1LCR, G2111_DoorFrameTopD1L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2120_DoorFrameLeftD3L, M658_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D3L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2119_DoorFrameLeftD3C, M657_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D3C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2118_DoorFrameLeftD2C, M656_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D2C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2117_DoorFrameLeftD1C, M655_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D1C);
#ifdef MEDIA506_F20E_F20J_X30J
        F0752_AllocateAndSetNegativeBitmapPointer(G2196_DoorFrameRightD1C, M655_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D1C);
#endif
        F0752_AllocateAndSetNegativeBitmapPointer(G2116_DoorFrameFrontD0C, M654_GRAPHIC_WALLSET_0_DOOR_FRAME_FRONT_D0C);
        F0753_(G3013_i_WallSet_Wall_D1C, M712_NEGGRAPHIC_);
        F0632_COORD_SetNegativeBitmapPointer(M710_NEGGRAPHIC_THIEVES_EYE_VISIBLE_AREA, G0296_puc_Bitmap_Viewport);
        G0296_puc_Bitmap_Viewport = F0468_MEMORY_Allocate((long)G2070_ViewportBitmapByteCount, MASK0x8000_ALLOCATE_BITMAP | C1_ALLOCATION_PERMANENT);
        G0086_puc_Bitmap_ViewportBlackArea = G0296_puc_Bitmap_Viewport + M103_BITMAP_BYTE_COUNT(G2005_GraphicWidthHeight[M651_GRAPHIC_FLOOR_SET_0_CEILING].Width, G2005_GraphicWidthHeight[M651_GRAPHIC_FLOOR_SET_0_CEILING].Height);
        G0087_puc_Bitmap_ViewportFloorArea = G0086_puc_Bitmap_ViewportBlackArea + G2142_ViewportBlackAreaByteCount;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C10_WALL_D3R2], C103_GRAPHIC_WALLSET_0_D3R2);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C11_WALL_D3L2], M663_GRAPHIC_WALLSET_0_D3L2);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C12_WALL_D3R], C105_GRAPHIC_WALLSET_0_D3R);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C13_WALL_D3L], C106_GRAPHIC_WALLSET_0_D3L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C14_WALL_D3C], C107_GRAPHIC_WALLSET_0_D3C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C05_WALL_D2R2], C098_GRAPHIC_WALLSET_0_D2R2);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C06_WALL_D2L2], C099_GRAPHIC_WALLSET_0_D2L2);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C07_WALL_D2R], C100_GRAPHIC_WALLSET_0_D2R);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C08_WALL_D2L], C101_GRAPHIC_WALLSET_0_D2L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C09_WALL_D2C], C102_GRAPHIC_WALLSET_0_D2C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C02_WALL_D1R], C095_GRAPHIC_WALLSET_0_D1R);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C03_WALL_D1L], C096_GRAPHIC_WALLSET_0_D1L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C04_WALL_D1C], C097_GRAPHIC_WALLSET_0_D1C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C00_WALL_D0R], M661_GRAPHIC_WALLSET_0_D0R);
        F0752_AllocateAndSetNegativeBitmapPointer(G2107_WallSet[C01_WALL_D0L], M662_GRAPHIC_WALLSET_0_D0L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2115_DoorFrameTopD2LCR, M660_GRAPHIC_WALLSET_0_DOOR_FRAME_TOP_D2LCR);
        F0753_(G2115_DoorFrameTopD2LCR, G2113_DoorFrameTopD2R);
        F0753_(G2115_DoorFrameTopD2LCR, G2114_DoorFrameTopD2L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2112_DoorFrameTopD1LCR, M659_GRAPHIC_WALLSET_0_DOOR_FRAME_TOP_D1LCR);
        F0753_(G2112_DoorFrameTopD1LCR, G2110_DoorFrameTopD1R);
        F0753_(G2112_DoorFrameTopD1LCR, G2111_DoorFrameTopD1L);
        F0752_AllocateAndSetNegativeBitmapPointer(G2120_DoorFrameLeftD3L, M658_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D3L);
        F0753_(G2120_DoorFrameLeftD3L, G2121_);
        F0753_(G2120_DoorFrameLeftD3L, G2122_);
        F0752_AllocateAndSetNegativeBitmapPointer(G2119_DoorFrameLeftD3C, M657_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D3C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2118_DoorFrameLeftD2C, M656_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D2C);
        F0752_AllocateAndSetNegativeBitmapPointer(G2117_DoorFrameLeftD1C, M655_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D1C);
#ifdef MEDIA747_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
        F0752_AllocateAndSetNegativeBitmapPointer(G2196_DoorFrameRightD1C, M655_GRAPHIC_WALLSET_0_DOOR_FRAME_LEFT_D1C);
#endif
        F0752_AllocateAndSetNegativeBitmapPointer(G2116_DoorFrameFrontD0C, M654_GRAPHIC_WALLSET_0_DOOR_FRAME_FRONT_D0C);
        F0753_(G2107_WallSet[C04_WALL_D1C], M712_NEGGRAPHIC_);
        F0632_COORD_SetNegativeBitmapPointer(M710_NEGGRAPHIC_THIEVES_EYE_VISIBLE_AREA, G0296_puc_Bitmap_Viewport);
        G0296_puc_Bitmap_Viewport = F0606_AllocateMemForGraphic(G2073_C224_ViewportPixelWidth, G2074_C136_ViewportHeight, C1_ALLOCATION_PERMANENT);
        G2142_ViewportBlackAreaByteCount = G2070_ViewportBitmapByteCount - F0751_GetBitmapByteCount(M651_GRAPHIC_FLOOR_SET_0_CEILING) - F0751_GetBitmapByteCount(M650_GRAPHIC_FLOOR_SET_0_FLOOR), /* ANOMALY_FMT Comma instead of semicolon */
        G2140_i_LargestCacheableNativeBitmapWidth = G2005_GraphicWidthHeight[C097_GRAPHIC_WALLSET_0_D1C].Width;
        G2141_i_LargestCacheableNativeBitmapHeight = G2005_GraphicWidthHeight[C097_GRAPHIC_WALLSET_0_D1C].Height;
#ifdef MEDIA713_I34E_I34M_F31E_F31J_X31J_P31J
        G0086_puc_Bitmap_ViewportBlackArea = G0296_puc_Bitmap_Viewport + F0751_GetBitmapByteCount(M651_GRAPHIC_FLOOR_SET_0_CEILING);
        G0087_puc_Bitmap_ViewportFloorArea = G0086_puc_Bitmap_ViewportBlackArea + G2142_ViewportBlackAreaByteCount;
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        G0086_puc_Bitmap_ViewportBlackArea = G0296_puc_Bitmap_Viewport + (F0751_GetBitmapByteCount(M651_GRAPHIC_FLOOR_SET_0_CEILING) >> 2);
        G0087_puc_Bitmap_ViewportFloorArea = G0086_puc_Bitmap_ViewportBlackArea + (G2142_ViewportBlackAreaByteCount >> 2);
        if (F0751_GetBitmapByteCount(M650_GRAPHIC_FLOOR_SET_0_FLOOR) > M103_BITMAP_BYTE_COUNT(G2140_i_LargestCacheableNativeBitmapWidth, G2141_i_LargestCacheableNativeBitmapHeight)) {
                G2140_i_LargestCacheableNativeBitmapWidth = G2005_GraphicWidthHeight[M650_GRAPHIC_FLOOR_SET_0_FLOOR].Width;
                G2141_i_LargestCacheableNativeBitmapHeight = G2005_GraphicWidthHeight[M650_GRAPHIC_FLOOR_SET_0_FLOOR].Height;
        }
        if (F0751_GetBitmapByteCount(M651_GRAPHIC_FLOOR_SET_0_CEILING) > M103_BITMAP_BYTE_COUNT(G2140_i_LargestCacheableNativeBitmapWidth, G2141_i_LargestCacheableNativeBitmapHeight)) {
                G2140_i_LargestCacheableNativeBitmapWidth = G2005_GraphicWidthHeight[M651_GRAPHIC_FLOOR_SET_0_CEILING].Width;
                G2141_i_LargestCacheableNativeBitmapHeight = G2005_GraphicWidthHeight[M651_GRAPHIC_FLOOR_SET_0_CEILING].Height;
        }
#endif
        G2069_LargestCacheableNativeBitmapByteCount += M103_BITMAP_BYTE_COUNT(G2140_i_LargestCacheableNativeBitmapWidth, G2141_i_LargestCacheableNativeBitmapHeight); /* Largest cacheable native bitmap: 160 x 111 pixels = 8880 bytes */
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0639_DerivedBitmapByteCount[C000_DERIVED_BITMAP_VIEWPORT] = G2070_ViewportBitmapByteCount;
#endif
        G0639_DerivedBitmapByteCount[C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA] = M075_BITMAP_BYTE_COUNT(96, 95);
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0639_DerivedBitmapByteCount[C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM] = M075_BITMAP_BYTE_COUNT(64, 37);
        G0639_DerivedBitmapByteCount[C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL] = M075_BITMAP_BYTE_COUNT(48, 37);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0639_DerivedBitmapByteCount[C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM] = M103_BITMAP_BYTE_COUNT(G2093_DamageToCreatureMediumWidth, G2094_DamageToCreatureMediumHeight);
        G0639_DerivedBitmapByteCount[C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL] = M103_BITMAP_BYTE_COUNT(G2095_DamageToCreatureSmallWidth, G2096_DamageToCreatureSmallHeight);
#endif
        /* Prepare two special door ornaments for the two door masks */
        for (AL1466_i_DoorOrnamentIndex = C15_DOOR_ORNAMENT_DESTROYED_MASK; AL1466_i_DoorOrnamentIndex <= C16_DOOR_ORNAMENT_THIEVES_EYE_MASK; AL1466_i_DoorOrnamentIndex++) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0103_as_CurrentMapDoorOrnamentsInfo[AL1466_i_DoorOrnamentIndex].NativeBitmapIndex = AL1466_i_DoorOrnamentIndex + (M649_GRAPHIC_DOOR_MASK_DESTROYED - C15_DOOR_ORNAMENT_DESTROYED_MASK);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                AL1467_i_NativeBitmapIndex = AL1466_i_DoorOrnamentIndex + (M649_GRAPHIC_DOOR_MASK_DESTROYED - C15_DOOR_ORNAMENT_DESTROYED_MASK);
                G0103_as_CurrentMapDoorOrnamentsInfo[AL1466_i_DoorOrnamentIndex].NativeBitmapIndex = AL1467_i_NativeBitmapIndex;
#endif
                G0103_as_CurrentMapDoorOrnamentsInfo[AL1466_i_DoorOrnamentIndex].CoordinateSet = 1;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0639_DerivedBitmapByteCount[AL1466_i_DoorOrnamentIndex * 2 + C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3] = M075_BITMAP_BYTE_COUNT(48, 41);
                G0639_DerivedBitmapByteCount[AL1466_i_DoorOrnamentIndex * 2 + C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2] = M075_BITMAP_BYTE_COUNT(64, 61);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                G0639_DerivedBitmapByteCount[AL1466_i_DoorOrnamentIndex * 2 + C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                G0639_DerivedBitmapByteCount[AL1466_i_DoorOrnamentIndex * 2 + C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M638_SCALE_21_23);
#endif
        }
        /* Prepare one special floor ornament for the footprints */
        G0102_as_CurrentMapFloorOrnamentsInfo[C15_FLOOR_ORNAMENT_FOOTPRINTS].NativeBitmapIndex = M639_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0102_as_CurrentMapFloorOrnamentsInfo[C15_FLOOR_ORNAMENT_FOOTPRINTS].CoordinateSet = 1;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0102_as_CurrentMapFloorOrnamentsInfo[C15_FLOOR_ORNAMENT_FOOTPRINTS].CoordinateSet = 0;
#endif
        for (AL1466_i_ObjectAspectIndex = 0, L1470_ps_ObjectAspect = G0209_as_Graphic558_ObjectAspects; AL1466_i_ObjectAspectIndex < C085_OBJECT_ASPECT_COUNT; AL1466_i_ObjectAspectIndex++, L1470_ps_ObjectAspect++) {
#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
                L1468_i_DerivedBitmapIndex = C104_DERIVED_BITMAP_FIRST_OBJECT + L1470_ps_ObjectAspect->FirstDerivedBitmapRelativeIndex;
#endif
#ifdef MEDIA671_F31E_F31J_P31J
                L1468_i_DerivedBitmapIndex = C104_DERIVED_BITMAP_FIRST_OBJECT + (L1470_ps_ObjectAspect->FirstDerivedBitmapRelativeIndex * 2);
#endif
#ifdef MEDIA721_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                L1468_i_DerivedBitmapIndex = C104_DERIVED_BITMAP_FIRST_OBJECT + (L1470_ps_ObjectAspect->FirstDerivedBitmapRelativeIndex * 5);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                AL1467_i_NativeBitmapIndex = M612_GRAPHIC_FIRST_OBJECT + L1470_ps_ObjectAspect->FirstNativeBitmapRelativeIndex;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1470_ps_ObjectAspect->ByteWidth, L1470_ps_ObjectAspect->Height, C16_SCALE_D3);
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1470_ps_ObjectAspect->ByteWidth, L1470_ps_ObjectAspect->Height, C20_SCALE_D2);
#endif
#ifdef MEDIA516_F20E_F20J_X30J_P20JA_P20JB_F31E_F31J_P31J
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
#endif
#ifdef MEDIA721_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                for (AL3049_i_Counter = 0; AL3049_i_Counter < 5; AL3049_i_Counter++) {
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, G2030_auc_ObjectScales[AL3049_i_Counter]);
                }
#endif
                if (M007_GET(L1470_ps_ObjectAspect->GraphicInfo, MASK0x0001_FLIP_ON_RIGHT)) {
#ifdef MEDIA030_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_F31E_F31J_P31J
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex - 2];
                        L1468_i_DerivedBitmapIndex++;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex - 2];
                        L1468_i_DerivedBitmapIndex++;
#endif
#ifdef MEDIA721_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                        for (AL3049_i_Counter = 0; AL3049_i_Counter < 5; AL3049_i_Counter++) {
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex - 5];
                                L1468_i_DerivedBitmapIndex++;
                        }
#endif
                }
                if (M007_GET(L1470_ps_ObjectAspect->GraphicInfo, MASK0x0010_ALCOVE)) {
#ifdef MEDIA019_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex - 2];
                        L1468_i_DerivedBitmapIndex++;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex - 2];
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        AL1467_i_NativeBitmapIndex++;
#endif
#ifdef MEDIA474_P20JB_F31E_F31J_P31J
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
#endif
#ifdef MEDIA721_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                        for (AL3049_i_Counter = 0; AL3049_i_Counter < 5; AL3049_i_Counter++) {
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1467_i_NativeBitmapIndex].Height, G2030_auc_ObjectScales[AL3049_i_Counter]);
                                L1468_i_DerivedBitmapIndex++;
                        }
#endif
                }
        }
#ifdef MEDIA721_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        G2031_apuc_PaletteChanges_FloorOrnament[2] = G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3;
        G2031_apuc_PaletteChanges_FloorOrnament[1] = G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2;
        G2031_apuc_PaletteChanges_FloorOrnament[0] = NULL;
#endif
        for (AL1466_i_ProjectileAspectIndex = 0, L1472_ps_ProjectileAspect = G0210_as_Graphic558_ProjectileAspects; AL1466_i_ProjectileAspectIndex < C014_PROJECTILE_ASPECT_COUNT; AL1466_i_ProjectileAspectIndex++, L1472_ps_ProjectileAspect++) {
                if (!M007_GET(L1472_ps_ProjectileAspect->GraphicInfo, MASK0x0100_SCALE_WITH_KINETIC_ENERGY)) {
                        L1468_i_DerivedBitmapIndex = M537_DERIVED_BITMAP_FIRST_PROJECTILE + L1472_ps_ProjectileAspect->FirstDerivedBitmapRelativeIndex;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        AL3049_i_NativeBitmapIndex = M613_GRAPHIC_FIRST_PROJECTILE + L1472_ps_ProjectileAspect->FirstNativeBitmapRelativeIndex;
#endif
                        for (AL1467_i_ProjectileScaleIndex = 0; AL1467_i_ProjectileScaleIndex < 6; AL1467_i_ProjectileScaleIndex++, L1468_i_DerivedBitmapIndex++) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = (L1469_i_BitmapByteCount = F0459_START_GetScaledBitmapByteCount(L1472_ps_ProjectileAspect->ByteWidth, L1472_ps_ProjectileAspect->Height, G0215_auc_Graphic558_ProjectileScales[AL1467_i_ProjectileScaleIndex]));
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Height, G0215_auc_Graphic558_ProjectileScales[AL1467_i_ProjectileScaleIndex]);
#endif
                                if (M007_GET(L1472_ps_ProjectileAspect->GraphicInfo, MASK0x0003_ASPECT_TYPE) != C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex + 6] = L1469_i_BitmapByteCount;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex + 6] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex + 1].Width, G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex + 1].Height, G0215_auc_Graphic558_ProjectileScales[AL1467_i_ProjectileScaleIndex]);
#endif
                                        if (M007_GET(L1472_ps_ProjectileAspect->GraphicInfo, MASK0x0003_ASPECT_TYPE) != C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex + 12] = L1469_i_BitmapByteCount;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex + 12] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex + 2].Width, G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex + 2].Height, G0215_auc_Graphic558_ProjectileScales[AL1467_i_ProjectileScaleIndex]);
#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
        G0075_apuc_PaletteChanges_Projectile[0] = G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3;
        G0075_apuc_PaletteChanges_Projectile[1] = G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        G0075_apuc_PaletteChanges_Projectile[2] = G0075_apuc_PaletteChanges_Projectile[3] = G0017_auc_Graphic562_PaletteChanges_NoChanges;
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
        G0075_apuc_PaletteChanges_Projectile[2] = G0075_apuc_PaletteChanges_Projectile[3] = NULL;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G0075_apuc_PaletteChanges_Projectile[3] = G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3;
        G0075_apuc_PaletteChanges_Projectile[2] = G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2;
        G0075_apuc_PaletteChanges_Projectile[1] = G0075_apuc_PaletteChanges_Projectile[0] = NULL;
#endif
        L1468_i_DerivedBitmapIndex = M538_DERIVED_BITMAP_FIRST_EXPLOSION;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        for (AL1466_i_ExplosionAspectIndex = 0, L1473_ps_ExplosionAspect = G0211_as_Graphic558_ExplosionAspects; AL1466_i_ExplosionAspectIndex < C004_EXPLOSION_ASPECT_COUNT; AL1466_i_ExplosionAspectIndex++, L1473_ps_ExplosionAspect++) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        AL3049_i_NativeBitmapIndex = M614_GRAPHIC_FIRST_EXPLOSION;
        for (AL1466_i_ExplosionAspectIndex = 0; AL1466_i_ExplosionAspectIndex < C004_EXPLOSION_ASPECT_COUNT; AL1466_i_ExplosionAspectIndex++) {
#endif
                for (AL1467_i_Scale = 4; AL1467_i_Scale < 32; AL1467_i_Scale += 2) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1473_ps_ExplosionAspect->ByteWidth, L1473_ps_ExplosionAspect->Height, AL1467_i_Scale);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Height, AL1467_i_Scale);
#endif
                }
                if (AL1466_i_ExplosionAspectIndex == C3_EXPLOSION_ASPECT_SMOKE) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L1473_ps_ExplosionAspect->ByteWidth * L1473_ps_ExplosionAspect->Height;
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = M103_BITMAP_BYTE_COUNT(G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL3049_i_NativeBitmapIndex].Height);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0751_GetBitmapByteCount(AL3049_i_NativeBitmapIndex);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                }
                if (AL1466_i_ExplosionAspectIndex < C2_EXPLOSION_ASPECT_POISON) {
                        AL3049_i_NativeBitmapIndex++;
#endif
                }
        }
        L1468_i_DerivedBitmapIndex = M539_DERIVED_BITMAP_FIRST_CREATURE;
        for (AL1467_i_CreatureIndex = 0; AL1467_i_CreatureIndex < C027_CREATURE_TYPE_COUNT; AL1467_i_CreatureIndex++) {
                L1471_ps_CreatureAspect = &G0219_as_Graphic558_CreatureAspects[AL1467_i_CreatureIndex];
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                AL1466_i_CreatureGraphicInfo = G0243_as_Graphic559_CreatureInfo[AL1467_i_CreatureIndex].GraphicInfo;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                AL1466_i_NativeBitmapIndex = M618_GRAPHIC_FIRST_CREATURE + L1471_ps_CreatureAspect->FirstNativeBitmapRelativeIndex;
                AL3049_i_CreatureGraphicInfo = G0243_as_Graphic559_CreatureInfo[AL1467_i_CreatureIndex].GraphicInfo;
#endif
                L1471_ps_CreatureAspect->FirstDerivedBitmapIndex = L1468_i_DerivedBitmapIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = AL1475_i_CreatureFrontBitmapD3ByteCount = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthFront, L1471_ps_CreatureAspect->HeightFront, C16_SCALE_D3);
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L1474_i_CreatureFrontBitmapD2ByteCount = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthFront, L1471_ps_CreatureAspect->HeightFront, C20_SCALE_D2);
                if (M007_GET(AL1466_i_CreatureGraphicInfo, MASK0x0008_SIDE)) {
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthSide, L1471_ps_CreatureAspect->HeightSide, C16_SCALE_D3);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthSide, L1471_ps_CreatureAspect->HeightSide, C20_SCALE_D2);
                }
                if (M007_GET(AL1466_i_CreatureGraphicInfo, MASK0x0010_BACK)) {
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = AL1475_i_CreatureFrontBitmapD3ByteCount;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L1474_i_CreatureFrontBitmapD2ByteCount;
                }
                if (M007_GET(AL1466_i_CreatureGraphicInfo, MASK0x0020_ATTACK)) {
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthAttack, L1471_ps_CreatureAspect->HeightAttack, C16_SCALE_D3);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthAttack, L1471_ps_CreatureAspect->HeightAttack, C20_SCALE_D2);
                }
                if (AL1475_i_AdditionalFrontGraphicCount = M007_GET(AL1466_i_CreatureGraphicInfo, MASK0x0003_ADDITIONAL)) {
                        do {
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L1471_ps_CreatureAspect->ByteWidthFront * L1471_ps_CreatureAspect->HeightFront;
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthFront, L1471_ps_CreatureAspect->HeightFront, C16_SCALE_D3);
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(L1471_ps_CreatureAspect->ByteWidthFront, L1471_ps_CreatureAspect->HeightFront, C20_SCALE_D2);
                        } while (--AL1475_i_AdditionalFrontGraphicCount);
                }
#endif
#ifdef MEDIA508_F20E_F20J_X30J_P20JA_P20JB
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L3051_ = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L3050_ = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
#endif
#ifdef MEDIA747_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                L3051_ = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                L3050_ = G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if (M007_GET(AL3049_i_CreatureGraphicInfo, MASK0x0008_SIDE)) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE nop */
                        AL1466_i_NativeBitmapIndex++;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
                }
                if (M007_GET(AL3049_i_CreatureGraphicInfo, MASK0x0010_BACK)) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE nop */
                        AL1466_i_NativeBitmapIndex++;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
                }
                if (M007_GET(AL3049_i_CreatureGraphicInfo, MASK0x0020_ATTACK)) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE nop */
                        AL1466_i_NativeBitmapIndex++;
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M637_SCALE_14_16);
                        G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0459_START_GetScaledBitmapByteCount(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height, M638_SCALE_21_20);
                }
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                if (AL3049_i_AdditionalFrontGraphicCount = M007_GET(AL3049_i_CreatureGraphicInfo, MASK0x0003_ADDITIONAL)) {
                        AL1466_i_NativeBitmapIndex = M618_GRAPHIC_FIRST_CREATURE + L1471_ps_CreatureAspect->FirstNativeBitmapRelativeIndex;
                        do {
#ifdef MEDIA506_F20E_F20J_X30J
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = M103_BITMAP_BYTE_COUNT(G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Width, G2005_GraphicWidthHeight[AL1466_i_NativeBitmapIndex].Height);
#endif
#ifdef MEDIA747_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = F0751_GetBitmapByteCount(AL1466_i_NativeBitmapIndex);
#endif
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L3051_;
                                G0639_DerivedBitmapByteCount[L1468_i_DerivedBitmapIndex++] = L3050_;
                        } while (--AL3049_i_AdditionalFrontGraphicCount);
                }
#endif
        }
}

#ifdef MEDIA041_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
void F0461_START_AllocateFlippedWallBitmaps(
#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
        G0090_puc_Bitmap_WallD3LCR_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(128, 51), C1_ALLOCATION_PERMANENT);
        G0091_puc_Bitmap_WallD2LCR_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(144, 71), C1_ALLOCATION_PERMANENT);
        G0092_puc_Bitmap_WallD1LCR_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(256, 111), C1_ALLOCATION_PERMANENT);
        G0093_puc_Bitmap_WallD0L_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 136), C1_ALLOCATION_PERMANENT);
        G0094_puc_Bitmap_WallD0R_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 136), C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        G4050_puc_Bitmap_Floor_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(224, 70), C1_ALLOCATION_PERMANENT);
        G4051_puc_Bitmap_Ceiling_Flipped = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(224, 29), C1_ALLOCATION_PERMANENT);
#endif
#ifdef MEDIA506_F20E_F20J_X30J
        F0752_AllocateAndSetNegativeBitmapPointer(G3049_i_WallSetFlipped_Wall_D3C, C088_GRAPHIC_WALLSET_0_D3LCR);
        F0753_(G3049_i_WallSetFlipped_Wall_D3C, G3051_i_WallSetFlipped_Wall_D3R);
        F0753_(G3049_i_WallSetFlipped_Wall_D3C, G3050_i_WallSetFlipped_Wall_D3L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3052_i_WallSetFlipped_Wall_D2C, C087_GRAPHIC_WALLSET_0_D2LCR);
        F0753_(G3052_i_WallSetFlipped_Wall_D2C, G3054_i_WallSetFlipped_Wall_D2R);
        F0753_(G3052_i_WallSetFlipped_Wall_D2C, G3053_i_WallSetFlipped_Wall_D2L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3055_i_WallSetFlipped_Wall_D1C, C086_GRAPHIC_WALLSET_0_D1LCR);
        F0753_(G3055_i_WallSetFlipped_Wall_D1C, G3057_i_WallSetFlipped_Wall_D1R);
        F0753_(G3055_i_WallSetFlipped_Wall_D1C, G3056_i_WallSetFlipped_Wall_D1L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3058_i_WallSetFlipped_Wall_D0L, M662_GRAPHIC_WALLSET_0_D0L);
        F0752_AllocateAndSetNegativeBitmapPointer(G3059_i_WallSetFlipped_Wall_D0R, M661_GRAPHIC_WALLSET_0_D0R);
#endif
#ifdef MEDIA758_A36M_A35E_A35M
        if (G2040_auc_MemoryFlags[C1_MEM_FLIPPED_WALS]) {
#endif
#ifdef MEDIA747_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                F0007_MAIN_CopyBytes(M772_CAST_PC(G2107_WallSet), M772_CAST_PC(G3071_WallSetNotFlipped), sizeof(G3071_WallSetNotFlipped));
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C10_WALL_D3R2], C103_GRAPHIC_WALLSET_0_D3R2);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C11_WALL_D3L2], M663_GRAPHIC_WALLSET_0_D3L2);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C12_WALL_D3R], C105_GRAPHIC_WALLSET_0_D3R);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C13_WALL_D3L], C106_GRAPHIC_WALLSET_0_D3L);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C14_WALL_D3C], C107_GRAPHIC_WALLSET_0_D3C);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C05_WALL_D2R2], C098_GRAPHIC_WALLSET_0_D2R2);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C06_WALL_D2L2], C099_GRAPHIC_WALLSET_0_D2L2);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C07_WALL_D2R], C100_GRAPHIC_WALLSET_0_D2R);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C08_WALL_D2L], C101_GRAPHIC_WALLSET_0_D2L);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C09_WALL_D2C], C102_GRAPHIC_WALLSET_0_D2C);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C02_WALL_D1R], C095_GRAPHIC_WALLSET_0_D1R);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C03_WALL_D1L], C096_GRAPHIC_WALLSET_0_D1L);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C04_WALL_D1C], C097_GRAPHIC_WALLSET_0_D1C);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C00_WALL_D0R], M661_GRAPHIC_WALLSET_0_D0R);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C01_WALL_D0L], M662_GRAPHIC_WALLSET_0_D0L);
#endif
#ifdef MEDIA670_F31E_F31J
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C15_WALL_], M650_GRAPHIC_FLOOR_SET_0_FLOOR);
                F0752_AllocateAndSetNegativeBitmapPointer(G3048_WallSetFlipped[C16_WALL_], M651_GRAPHIC_FLOOR_SET_0_CEILING);
#endif
#ifdef MEDIA758_A36M_A35E_A35M
        }
#endif
}
#endif

#ifdef MEDIA621_A31E_A31M_A33M_F31E_F31J_X31J
void F1009_(
long* P3091_l_  SEPARATOR
long* P3092_pl_ FINAL_SEPARATOR
{
        register long L3052_l_;
        register int16_t L3053_i_;


        L3052_l_ = 0;
        for (L3053_i_ = 7; L3053_i_ <= 670; L3053_i_++) {
                if ((L3053_i_ < 78) || (L3053_i_ >= 108)) {
                        L3052_l_ += F0494_MEMORY_GetGraphicDecompressedByteCount(L3053_i_) + 3;
                }
        }
#ifdef MEDIA673_F31E_F31J_X31J
        for (L3053_i_ = 0; L3053_i_ <= M513_SOUND_COUNT - 1; L3053_i_++) {
                        L3052_l_ += F0494_MEMORY_GetGraphicDecompressedByteCount(G0060_as_Graphic562_Sounds[L3053_i_].GraphicIndex) + 3;
        }
#endif
        *P3091_l_ = L3052_l_;
        L3052_l_ = 0;
        L3052_l_ += F0751_GetBitmapByteCount(C103_GRAPHIC_WALLSET_0_D3R2);
        L3052_l_ += F0751_GetBitmapByteCount(M663_GRAPHIC_WALLSET_0_D3L2);
        L3052_l_ += F0751_GetBitmapByteCount(C105_GRAPHIC_WALLSET_0_D3R);
        L3052_l_ += F0751_GetBitmapByteCount(C106_GRAPHIC_WALLSET_0_D3L);
        L3052_l_ += F0751_GetBitmapByteCount(C107_GRAPHIC_WALLSET_0_D3C);
        L3052_l_ += F0751_GetBitmapByteCount(C098_GRAPHIC_WALLSET_0_D2R2);
        L3052_l_ += F0751_GetBitmapByteCount(C099_GRAPHIC_WALLSET_0_D2L2);
        L3052_l_ += F0751_GetBitmapByteCount(C100_GRAPHIC_WALLSET_0_D2R);
        L3052_l_ += F0751_GetBitmapByteCount(C101_GRAPHIC_WALLSET_0_D2L);
        L3052_l_ += F0751_GetBitmapByteCount(C102_GRAPHIC_WALLSET_0_D2C);
        L3052_l_ += F0751_GetBitmapByteCount(C095_GRAPHIC_WALLSET_0_D1R);
        L3052_l_ += F0751_GetBitmapByteCount(C096_GRAPHIC_WALLSET_0_D1L);
        L3052_l_ += F0751_GetBitmapByteCount(C097_GRAPHIC_WALLSET_0_D1C);
        L3052_l_ += F0751_GetBitmapByteCount(M661_GRAPHIC_WALLSET_0_D0R);
        L3052_l_ += F0751_GetBitmapByteCount(M662_GRAPHIC_WALLSET_0_D0L);
#ifdef MEDIA670_F31E_F31J
        L3052_l_ += F0751_GetBitmapByteCount(M650_GRAPHIC_FLOOR_SET_0_FLOOR);
        L3052_l_ += F0751_GetBitmapByteCount(M651_GRAPHIC_FLOOR_SET_0_CEILING);
#endif
        *P3092_pl_ = L3052_l_;
}
#endif

#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
BOOLEAN F0755_SetMemoryFlags(
unsigned char** P2158_ppuc_        SEPARATOR
long*           P2159_pl_ByteCount FINAL_SEPARATOR
{
        unsigned char* L3054_puc_;
        unsigned char L3055_c_Counter;


        L3054_puc_ = *P2158_ppuc_;
        for (L3055_c_Counter = 0; L3055_c_Counter < 6; L3055_c_Counter++) {
                G2040_auc_MemoryFlags[L3055_c_Counter] = C0_FALSE;
        }
        *P2159_pl_ByteCount = 0;
        while ((L3055_c_Counter = *L3054_puc_++) != 0xFE) {
                if (L3055_c_Counter == 0xFF) {
                        return C0_FALSE;
                }
                if (L3055_c_Counter == 0xFD) { /* Data in DM PC does not use this value */
                        *P2159_pl_ByteCount = (long)(*L3054_puc_++) * 1024; /* Kilobytes */
                } else {
                        G2040_auc_MemoryFlags[L3055_c_Counter] = C1_TRUE;
                }
        }
        *P2158_ppuc_ = L3054_puc_;
        return (*L3054_puc_ != 0xFF);
}

BOOLEAN F0756_EvaluateMemoryRequirements(
BOOLEAN P2160_B_NoMoreMemoryProfileToTest SEPARATOR
long    P2161_l_ByteCount                 FINAL_SEPARATOR
{ /* Check if there is enough memory to load graphics for each map in the dungeon */
        register int16_t L3056_i_MapIndex;
        register long L3057_l_AvailableMemoryByteCountForSounds;
        register int16_t L3058_i_PartyMapIndexBackup;
        char L3059_ac_Value[16];
        char L3060_ac_String[80];


        L3058_i_PartyMapIndexBackup = G0309_i_PartyMapIndex;
        G2136_B_EvaluatingMemoryRequirements = C1_TRUE;
        L3057_l_AvailableMemoryByteCountForSounds = 2147483647; /* 0x7FFFFFFF = 2^31 - 1 */
        for (L3056_i_MapIndex = 0; L3056_i_MapIndex < G0278_ps_DungeonHeader->MapCount; L3056_i_MapIndex++) {
                F0003_MAIN_ProcessNewPartyMap_CPSE(L3056_i_MapIndex);
                if (G2138_l_AvailableMemoryByteCountForSounds - P2161_l_ByteCount < L3057_l_AvailableMemoryByteCountForSounds) { /* P2161_l_ByteCount is always 0 */
                        L3057_l_AvailableMemoryByteCountForSounds = G2138_l_AvailableMemoryByteCountForSounds - P2161_l_ByteCount;
                }
        }
        if (L3057_l_AvailableMemoryByteCountForSounds > G2134_l_NeededMemoryByteCount) {
                G2134_l_NeededMemoryByteCount = L3057_l_AvailableMemoryByteCountForSounds;
        }
        if ((P2160_B_NoMoreMemoryProfileToTest != C0_FALSE) && (L3057_l_AvailableMemoryByteCountForSounds < 0)) {
                F0671_ConvertLongToString((-G2134_l_NeededMemoryByteCount + 1023) >> 10, L3059_ac_Value); /* Rounded number of kilobytes of memory needed */
#ifdef MEDIA732_I34E_A35E
                F0670_ReplaceCharacterByString("OUT OF MEMORY. ~K NEEDED.", L3059_ac_Value, '~', L3060_ac_String);
                F0427_DIALOG_Draw(NULL, L3060_ac_String, G0560_pc_OK, NULL, NULL, NULL);
#endif
#ifdef MEDIA738_I34M_A36M_A35M
                F0670_ReplaceCharacterByString(F0758_TranslateLanguage(C135_OUT_OF_MEMORY_K_NEEDED), L3059_ac_Value, '~', L3060_ac_String);
                F0427_DIALOG_Draw(NULL, L3060_ac_String, F0758_TranslateLanguage(C105_OK), NULL, NULL, NULL);
#endif
                F0424_DIALOG_GetChoice(C1_ONE_CHOICE, C0_DRIVE_TYPE_NONE, C0_DIALOG_CHOICE_NONE);
                F0666_endgame();
        }
        G2136_B_EvaluatingMemoryRequirements = C0_FALSE;
        G0309_i_PartyMapIndex = L3058_i_PartyMapIndexBackup;
        return L3057_l_AvailableMemoryByteCountForSounds >= 0;
}
#endif

void F0462_START_StartGame_CPSEF(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA291_S20E_S21E_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 /* CHANGE7_39_FIX */
        int16_t L1476_i_GraphicsDatFileReferenceCountBackup;
#endif


        G0331_B_PressingEye = C0_FALSE;
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
        G0332_B_StopPressingEye = C0_FALSE;
#endif
        G0333_B_PressingMouth = C0_FALSE;
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
        G0334_B_StopPressingMouth = 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
        G0340_B_HighlightBoxInversionRequested = C0_FALSE;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G2152_B_PressingClosedImaginaryFakeWall = C0_FALSE;
#ifdef MEDIA622_A31E_A31M_A33M_F31E_F31J_X31J_P31J
        G2229_B_StopPressingClosedImaginaryFakeWall = C0_FALSE;
#endif
        G2150_B_ = C0_FALSE;
#endif
        G0341_B_HighlightBoxEnabled = C0_FALSE;
        G0300_B_PartyIsResting = C0_FALSE;
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        G2167_B_DisabledMenusDrawn = C0_FALSE;
        F0008_MAIN_ClearBytes(M772_CAST_PC(G2016_ai_SkillRecentlyUpgraded), (long)sizeof(G2016_ai_SkillRecentlyUpgraded));
#endif
#ifdef MEDIA232_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M /* CHANGE2_00_IMPROVEMENT Status variables for CPSF are now reset each time a game is restarted */
#ifndef NOCOPYPROTECTION
        G0069_ui_State_CPSF = 15;
        G0070_B_FuzzySectorAnalyzed_CPSF = C0_FALSE;
        G0071_B_FuzzySectorReadingInitiated_CPSF = C0_FALSE;
#endif
#endif
        G0506_ui_ActingChampionOrdinal = M000_INDEX_TO_ORDINAL(CM1_CHAMPION_NONE);
        G0509_B_ActionAreaContainsIcons = C1_TRUE;
        G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap = M000_INDEX_TO_ORDINAL(CM1_CHAMPION_NONE);
        /* BUG0_61 The game stops with message 'SYSTEM ERROR 60' right after restarting from a saved game. The game manages a watchdog event to detect when the copy protection has stopped processing events in the timeline. Each time the watchdog event expires, a new watchdog event is scheduled to occur 300 ticks later. If at any point the watchdog event time G0374_l_WatchdogTime_CPSE is in the past compared to the current game time G0313_ul_GameTime then the game is stopped (in F0002_MAIN_GameLoop_CPSDF) with the error message. The issue is that the watchdog event time is not reset when restarting from a saved game so if you restore a game where the current time is in the future compared to the watchdog time then the game stops. How to reproduce:
        - Start a new game and save the game on floppy A. In this saved game, time is for example 250 ticks.
        - Wait for at least 600 ticks (around 2 minutes) and save the game again on floppy B. In this saved game, time is for example 850 ticks.
        - Boot the game and resume the game from floppy A. Game time is restored to 250. Wait a moment then at time = 300, G0374_l_WatchdogTime_CPSE is set to 600.
        - Kill your party (bump in walls or cast Fireballs while facing a wall).
        - On the end screen, click on 'Restart this game' and resume from floppy B. Game time is restored to 850. Because watchdog is still at 600 (not reinitialized to 16777215), as soon as the game loop starts the 'SYSTEM ERROR 60' message is drawn and the game hangs */
#ifdef MEDIA228_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J /* CHANGE2_05_FIX The watchdog event time is reset after the game is restarted */
#ifndef NOCOPYPROTECTION
        G0374_l_WatchdogTime_CPSE = 0x00FFFFFF;
#endif
#endif
        G0441_ps_PrimaryMouseInput = G0447_as_Graphic561_PrimaryMouseInput_Interface;
        G0442_ps_SecondaryMouseInput = G0448_as_Graphic561_SecondaryMouseInput_Movement;
        G0443_ps_PrimaryKeyboardInput = G0458_as_Graphic561_PrimaryKeyboardInput_Interface;
        G0444_ps_SecondaryKeyboardInput = G0459_as_Graphic561_SecondaryKeyboardInput_Movement;
        F0003_MAIN_ProcessNewPartyMap_CPSE(G0309_i_PartyMapIndex);
        if (!G0298_B_NewGame) {
#ifdef MEDIA128_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                M518_FillScreenBlack();
#ifdef MEDIA117_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G
                F0436_STARTEND_FadeToPalette(G0347_aui_Palette_TopAndBottomScreen);
#endif
#ifdef MEDIA613_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                F0436_STARTEND_FadeToPalette(G3088_aui_Palette_TopAndBottomScreen);
#endif
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
                F0694_SetMultipleColorsInPalette(G2099_i_InterfacePaletteIndex);
#endif
#ifdef MEDIA120_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
                F0427_DIALOG_Draw(NULL, G0536_pc_GAMELOADEDREADYTOPLAY, G0560_pc_OK, NULL, NULL, NULL, C1_TRUE, C1_TRUE, C1_TRUE);
#endif
#ifdef MEDIA588_X30J_P20JA_P20JB_I34E_A31E_A35E_F31E_F31J_X31J_P31J
                M540_F0427_DIALOG_Draw(NULL, G0536_pc_GAMELOADEDREADYTOPLAY, G0560_pc_OK, NULL, NULL, NULL, C0_DRIVE_TYPE_NONE, C0_DIALOG_CHOICE_NONE);
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
                F0427_DIALOG_Draw(NULL, F0758_TranslateLanguage(C78_GAME_LOADED_READY_TO_PLAY), F0758_TranslateLanguage(C105_OK), NULL, NULL, NULL);
#endif
#ifdef MEDIA006_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB /* CHANGE7_34_OPTIMIZATION */
                F0078_MOUSE_DisableScreenUpdate();
                F0424_DIALOG_GetChoice(C1_ONE_CHOICE, C1_DIALOG_SET_SCREEN);
                F0077_MOUSE_EnableScreenUpdate_CPSE();
#endif
#ifdef MEDIA294_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J /* CHANGE7_34_OPTIMIZATION */
                F0424_DIALOG_GetChoice(C1_ONE_CHOICE, C1_DIALOG_SET_SCREEN, C0_DRIVE_TYPE_NONE, C0_DIALOG_CHOICE_NONE);
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0424_DIALOG_GetChoice(C1_ONE_CHOICE, C0_DRIVE_TYPE_NONE, C0_DIALOG_CHOICE_NONE);
#endif
#ifdef MEDIA297_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_39_FIX Close graphics.dat if it is open before calling F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn */
                if (L1476_i_GraphicsDatFileReferenceCountBackup = G0631_i_GraphicsDatFileReferenceCount) {
                        G0631_i_GraphicsDatFileReferenceCount = 1;
                        F0478_MEMORY_CloseGraphicsDat_CPSDF();
                }
#endif
#ifdef MEDIA120_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
                F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, C1_TRUE); /* BUG0_62 The game stops with message 'SYSTEM ERROR 41' if the game disk is removed from the floppy disk drive after resuming from a saved game on the entrance screen and before clicking OK in the 'Game loaded, ready to play.' dialog. This occurs because the graphics.dat file is still open at this point and F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn calls F0452_FLOPPY_GetDiskTypeInDrive_CPSB which then closes the file and tries to open it again. This does not occur when restarting the game after the party has died because in that case the graphics.dat file is closed at this point so F0452_FLOPPY_GetDiskTypeInDrive_CPSB does not have to close it and open it again */
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB);
#endif
#ifdef MEDIA297_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_39_FIX Reopen graphics.dat if it was open before calling F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn */
                if (L1476_i_GraphicsDatFileReferenceCountBackup) {
                        F0477_MEMORY_OpenGraphicsDat_CPSDF();
                        G0631_i_GraphicsDatFileReferenceCount = L1476_i_GraphicsDatFileReferenceCountBackup;
                }
#endif
                M526_WaitVerticalBlank();
#ifdef MEDIA122_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_P31J
                M518_FillScreenBlack();
#endif
#ifdef MEDIA577_X30J
                F0732_FillScreenArea(G3000_ai_Box_Screen, C00_COLOR_BLACK);
#endif
#ifdef MEDIA692_X31J
                F0733_FillZoneByIndex(C002_ZONE_SCREEN, C00_COLOR_BLACK);
#endif
#endif
#ifdef MEDIA607_X30J_X31J
                F1010_LoadX68000BorderGraphics();
#endif
        } else {
#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
                M526_WaitVerticalBlank();
#ifdef MEDIA607_X30J_X31J
                F1010_LoadX68000BorderGraphics();
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                G2062_DialogSetIndex = C0_DIALOG_SET_VIEWPORT;
#endif
                /* Erase everything on screen except the viewport */
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                M524_FillScreenBox(G0061_ai_Graphic562_Box_ScreenTop, C00_COLOR_BLACK);
                M524_FillScreenBox(G0062_ai_Graphic562_Box_ScreenRight, C00_COLOR_BLACK);
                M524_FillScreenBox(G0063_ai_Graphic562_Box_ScreenBottom, C00_COLOR_BLACK);
#endif
#ifdef MEDIA595_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
                F0733_FillZoneByIndex(C401_ZONE_SCREEN_TOP, C00_COLOR_BLACK);
                F0733_FillZoneByIndex(C403_ZONE_SCREEN_RIGHT, C00_COLOR_BLACK);
                F0733_FillZoneByIndex(C405_ZONE_SCREEN_BOTTOM, C00_COLOR_BLACK);
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                F2249_CLEAR_FRONT_SCREEN();
#endif
        }
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        Setpalette(G0021_aaui_Graphic562_Palette_DungeonView[0]);
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        F0007_MAIN_CopyBytes(G0347_aui_Palette_TopAndBottomScreen, G3949_pui_Palette_MiddleScreen, sizeof(G0347_aui_Palette_TopAndBottomScreen));
        F0007_MAIN_CopyBytes(G0347_aui_Palette_TopAndBottomScreen, G4049_pui_Palette_, sizeof(G0347_aui_Palette_TopAndBottomScreen));
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        M526_WaitVerticalBlank();
        F0508_AMIGA_BuildPaletteChangeCopperList(G0021_aaui_Graphic562_Palette_DungeonView[0], G0347_aui_Palette_TopAndBottomScreen);
#endif
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        F0694_SetMultipleColorsInPalette(G2099_i_InterfacePaletteIndex);
#endif
#ifdef MEDIA607_X30J_X31J
        F1016_SetPalette(G3088_aui_Palette_TopAndBottomScreen);
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        G3123_PaletteSourceForMiddleScreen = G0021_aaui_Graphic562_Palette_DungeonView;
        G3119_pui_ColorPalette_SourceForTopAndBottomScreen = G3088_aui_Palette_TopAndBottomScreen;
        G3127_B_UpdateTopAndBottomScreenPaletteInNextVerticalBlank = G3121_B_UpdateMiddleScreenPaletteInNextVerticalBlank = C1_TRUE;
        while (G3121_B_UpdateMiddleScreenPaletteInNextVerticalBlank || G3127_B_UpdateTopAndBottomScreenPaletteInNextVerticalBlank);
#endif
        F0395_MENUS_DrawMovementArrows();
        F0278_CHAMPION_ResetDataToStartGame();
        G0301_B_GameTimeTicking = C1_TRUE;
}

#ifdef MEDIA278_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 /* CHANGE7_03_IMPROVEMENT Support for two floppy disk drives (Added call to F0451_FLOPPY_Initialize) CHANGE7_05_OPTIMIZATION Refactored game initialization function. This function and the new version of F0448_STARTUP1_InitializeMemoryManager_CPSADEF is equivalent to the older version of F0448_STARTUP1_InitializeMemoryManager_CPSADEF. */
void F0463_START_InitializeGame_CPSADEF(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA265_S20E_S21E
#ifndef NOCOPYPROTECTION
        REGISTER BOOLEAN L1477_B_CommandLineParameterIsAUTO_CPSA;
        char L1478_ac_CommandLineParameters_CPSA[130];
#endif
#endif
#ifdef MEDIA748_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        long L3061_l_;
#endif
#ifdef MEDIA486_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        long L3062_l_;
#endif
#ifdef MEDIA749_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        register int16_t L3065_i_Unreferenced;
#endif


#ifdef MEDIA469_P20JB
        L3062_l_ = 0;
#endif
#ifdef MEDIA448_A21E_A22E
        G1147_B_LoadBonusDungeon = F0512_STARTUP1_IsAltKeyPressed();
#endif
#ifdef MEDIA265_S20E_S21E
        Supexec(S0059_TOS_SetException257Vector_CriticalError);
#ifndef NOCOPYPROTECTION
        F0458_START_GetCommandLineParameters_CPSA(L1478_ac_CommandLineParameters_CPSA);
#endif
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        F0745_SetFileNamesAccordingToLanguage();
#endif
#ifdef MEDIA269_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        F0451_FLOPPY_Initialize();
#endif
#ifdef MEDIA270_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        F0448_STARTUP1_InitializeMemoryManager_CPSADEF();
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        F1067_InitAmigaStuff();
#endif
#ifdef MEDIA466_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_P31J
        F0451_FLOPPY_Initialize();
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        F0536_INPUT_Initialize();
#endif
#ifdef MEDIA265_S20E_S21E
#ifndef NOCOPYPROTECTION
        L1477_B_CommandLineParameterIsAUTO_CPSA = (L1478_ac_CommandLineParameters_CPSA[0] == 'A') && (L1478_ac_CommandLineParameters_CPSA[1] == 'U') && (L1478_ac_CommandLineParameters_CPSA[2] == 'T') && (L1478_ac_CommandLineParameters_CPSA[3] == 'O');
#endif
#endif
#ifdef MEDIA607_X30J_X31J
        F1020_InitializeX68000();
        F1024_SetTrap14VectorErrorProcessing();
#endif
        F0479_MEMORY_ReadGraphicsDatHeader();
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0641_InitializeLayout();
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        F0757_LoadTexts();
#endif
        F0460_START_InitializeGraphicData();
#ifdef MEDIA607_X30J_X31J
        F1038_UpdateMousePointer();
#endif
#ifdef MEDIA265_S20E_S21E
#ifndef NOCOPYPROTECTION
        F0447_STARTEND_HangIfFalse_CPSA(L1477_B_CommandLineParameterIsAUTO_CPSA);
#endif
#endif
#ifdef MEDIA388_G20E_G21E
        F2164_PatchAddresses();
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0506_AMIGA_AllocateData();
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        F0054_TEXT_Initialize();
        F1051_();
#endif
#ifdef MEDIA274_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A35E
        F0437_STARTEND_DrawTitle();
#endif
        F0094_DUNGEONVIEW_LoadFloorSet(C0_FLOOR_SET_STONE);
        F0095_DUNGEONVIEW_LoadWallSet(C0_WALL_SET_STONE);
#ifdef MEDIA692_X31J
        F0054_TEXT_Initialize();
#endif
#ifdef MEDIA265_S20E_S21E
#ifndef NOCOPYPROTECTION
        Floprd(M517_FuzzySectorReadingBuffer_CPSE, C0L_FILLER, C0_FLOPPY_DRIVE_A, C007_SECTOR_7, C0_TRACK_0, C0_SIDE_0, C1_ONE_SECTOR);
#endif
#endif
#ifdef MEDIA368_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J
#ifndef NOCOPYPROTECTION
        F0527_FLOPPY_ReadFuzzySector_CPSX(M517_FuzzySectorReadingBuffer_CPSE);
#endif
#endif
#ifdef MEDIA276_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        F0054_TEXT_Initialize();
#endif
#ifdef MEDIA736_I34M_A36M_A31M_A33M_A35M
        F0620_LoadActionNames();
#endif
        F0031_OBJECT_LoadNames();
#ifdef MEDIA265_S20E_S21E
        F0007_MAIN_CopyBytes(G0021_aaui_Graphic562_Palette_DungeonView[0], G0346_aui_Palette_MiddleScreen, sizeof(G0346_aui_Palette_MiddleScreen));
        F0007_MAIN_CopyBytes(G0021_aaui_Graphic562_Palette_DungeonView[0], G0347_aui_Palette_TopAndBottomScreen, sizeof(G0347_aui_Palette_TopAndBottomScreen));
#endif
#ifdef MEDIA722_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
        F0672_InitializeAllMouseInput();
#endif
#ifdef MEDIA315_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
#ifndef NOCOPYPROTECTION
        G0626_pfv_S0080_CPSDF_CheckDMATransferCompletion = F0211_CPSDF_GetSubroutineAbsoluteAddress(S0080_CPSDF_CheckDMATransferCompletion);
        G0627_pfv_S0081_CPSDF_TurnOffFloppyDrive = F0211_CPSDF_GetSubroutineAbsoluteAddress(S0081_CPSDF_TurnOffFloppyDrive);
#endif
#endif
        F0066_MOUSE_Initialize();
#ifdef MEDIA349_G14ED
        F2164_PatchAddresses();
#endif
#ifdef MEDIA265_S20E_S21E
        Supexec(F0018_MAIN_SetExceptionVectors);
        Jdisint(C05_INTERRUPT_TIMER_C);
#endif
#ifdef MEDIA266_S20E_S21E_G14ED_G20E_G21E
        F0062_SOUND_Initialize();
#endif
#ifdef MEDIA265_S20E_S21E
        M526_WaitVerticalBlank();
#endif
#ifdef MEDIA279_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0441_STARTEND_ProcessEntrance();
        while (F0435_STARTEND_LoadGame() != C01_LOAD_GAME_SUCCESS) {
                F0477_MEMORY_OpenGraphicsDat_CPSDF();
                F0441_STARTEND_ProcessEntrance();
        }
#endif
#ifdef MEDIA707_I34E_I34M
        if (F0435_STARTEND_LoadGame() != C01_LOAD_GAME_SUCCESS) {
                G0524_B_RestartGameAllowed = C0_FALSE;
                F0444_STARTEND_Endgame(C0_FALSE);
        }
#endif
        F0477_MEMORY_OpenGraphicsDat_CPSDF();
#ifdef MEDIA267_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0396_MENUS_LoadSpellAreaLinesBitmap();
#endif
#ifdef MEDIA266_S20E_S21E_G14ED_G20E_G21E
        F0476_MEMORY_InitializeGraphicMemory();
#endif
#ifdef MEDIA427_A20ED_A20E_A20F_A20G_A22G
        if (G1014_l_AvailableFastMemoryByteCount) {
                F0476_MEMORY_InitializeGraphicMemory(G1015_puc_AllocatedFastMemory + G1014_l_AvailableFastMemoryByteCount);
        } else {
                F0476_MEMORY_InitializeGraphicMemory(NULL);
        }
#endif
#ifdef MEDIA448_A21E_A22E
        if (G1014_l_AvailableFastMemoryByteCount) {
                if (!F0476_MEMORY_InitializeGraphicMemory(7, 532, G1015_puc_AllocatedFastMemory + G1014_l_AvailableFastMemoryByteCount, G1014_l_AvailableFastMemoryByteCount)) {
                        FreeMem(G1015_puc_AllocatedFastMemory, G1014_l_AvailableFastMemoryByteCount);
                }
        } else {
                F0476_MEMORY_InitializeGraphicMemory(7, 532, NULL, NULL);
        }
#endif
#ifdef MEDIA507_F20E_F20J_X30J_P20JA
        F0476_MEMORY_InitializeGraphicMemory(7, 555);
#endif
#ifdef MEDIA469_P20JB
        L3062_l_ = 1000000;
        F0476_MEMORY_InitializeGraphicMemory(L3062_l_);
#endif
#ifdef MEDIA667_P31J
        L3062_l_ = 0;
        F0476_MEMORY_InitializeGraphicMemory((L3061_l_ = NULL) + L3062_l_);
#endif
#ifdef MEDIA621_A31E_A31M_A33M_F31E_F31J_X31J
        F1009_(&L3061_l_, &L3062_l_);
#endif
#ifdef MEDIA673_F31E_F31J_X31J
        F0476_MEMORY_InitializeGraphicMemory(L3061_l_ + L3062_l_);
#endif
#ifdef MEDIA620_A31E_A31M_A33M
        if (G3168_l_FastMemoryBlockByteCount) {
                F0476_MEMORY_InitializeGraphicMemory(L3061_l_, L3062_l_, G3170_puc_FastMemoryBlockBottom + G3168_l_FastMemoryBlockByteCount, G3168_l_FastMemoryBlockByteCount);
        } else {
                F0476_MEMORY_InitializeGraphicMemory(L3061_l_, L3062_l_, NULL, 0L);
        }
#endif
#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
        F0476_MEMORY_InitializeGraphicMemory(G2041_ac_MemoryProfiles);
        F0799_SOUND_DisableUnavailableSounds();
#endif
        F0462_START_StartGame_CPSEF();
#ifdef MEDIA707_I34E_I34M
        if (!G2040_auc_MemoryFlags[C3_MEM_BASE_SOUNDS] || !G2040_auc_MemoryFlags[C4_MEM_ATTACK_SOUNDS] || !G2040_auc_MemoryFlags[C5_MEM_MOVEMENT_SOUNDS]) {
                F0051_TEXT_MESSAGEAREA_PrintLineFeed();
                if (G2040_auc_MemoryFlags[C3_MEM_BASE_SOUNDS] || G2040_auc_MemoryFlags[C4_MEM_ATTACK_SOUNDS] || G2040_auc_MemoryFlags[C5_MEM_MOVEMENT_SOUNDS]) {
                        F0047_TEXT_MESSAGEAREA_PrintMessage(C15_COLOR_WHITE, "LIMITED SOUNDS");
                } else {
                        F0047_TEXT_MESSAGEAREA_PrintMessage(C15_COLOR_WHITE, "NO SOUNDS");
                }
        }
#endif
        F0478_MEMORY_CloseGraphicsDat_CPSDF();
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        F0511_AMIGA_EmptyFunction();
#endif
        if (G0298_B_NewGame) {
                F0267_MOVE_GetMoveResult_CPSCE(C0xFFFF_THING_PARTY, CM1_MAPX_NOT_ON_A_SQUARE, 0, G0306_i_PartyMapX, G0307_i_PartyMapY);
        }
#ifdef MEDIA270_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA613_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        F0549_MOUSE_ShowPointer();
#endif
        F0357_COMMAND_DiscardAllInput();
}
#endif

#ifdef MEDIA607_X30J_X31J
unsigned char* F1017_Malloc(
long P3093_l_ FINAL_SEPARATOR
{
        asm {
                move.l  P3093_l_(a6),-(sp)
                dc.w    0xFF48  /* DOS CALL MALLOC */
                addq.l  #4,sp
        }
}
#endif

#ifdef MEDIA692_X31J
void F1018_Mfree(
void
)
{
        asm {
                move.l  G3139_(a5),-(sp)
                dc.w    0xFF49  /* DOS CALL MFREE */
                addq.l  #4,sp
        }
}
#endif

#ifdef MEDIA577_X30J
void F1019_(
void
)
{
        register unsigned char L3063_uc_;
        register unsigned char L3066_uc_;
        register unsigned char L3067_uc_;
        register unsigned char L3068_uc_;
        register unsigned char L3069_uc_;


        L3063_uc_ = 0;
        do {
                G3083_puc_X68000_256bytes[L3063_uc_] = (L3063_uc_ << 4) | (L3063_uc_ >> 4);
                L3063_uc_++;
        } while (L3063_uc_);
        L3068_uc_ = 0;
        do {
                L3069_uc_ = L3068_uc_ & 0xF0;
                L3067_uc_ = L3068_uc_ & 0x0F;
                L3063_uc_ = 0;
                do {
                        L3066_uc_ = 0xFF;
                        if ((L3063_uc_ & 0x0F0) == L3069_uc_) {
                                L3066_uc_ = 0x0F;
                        }
                        if ((L3063_uc_ & 0x0F) == L3067_uc_) {
                                L3066_uc_ &= 0xF0;
                        }
                        G3084_puc_X68000_4096bytes[(L3067_uc_ << 8) + L3063_uc_] = L3066_uc_;
                        L3063_uc_++;
                } while (L3063_uc_);
        } while ((L3068_uc_ += 17) != (unsigned char)16);
        L3063_uc_ = 0;
        do {
                G3085_pul_X68000_1024bytes[L3063_uc_] = ((long)(L3063_uc_ & 0xF0) << 12) | (long)(L3063_uc_ & 0x0F);
        } while (L3063_uc_++ != 0xFF);
}
#endif

#ifdef MEDIA607_X30J_X31J
void F1016_SetPalette(
unsigned int16_t* P2754_pui_Palette FINAL_SEPARATOR
{
        long L3070_l_SupervisorStack;


        asm {
                clr.l   -(sp)
                dc.w    0xFF20  /* DOS CALL SUPER */
                move.l  d0,L3070_l_SupervisorStack(a6)
                movea.l P2754_pui_Palette(a6),a0
                lea     (0xE82000).l,a1
                movem.l d3-d7,-(sp)
                movem.l (a0),d0-d7
                movem.l d0-d7,(a1)
                movem.l (sp)+,d3-d7
                move.l  L3070_l_SupervisorStack(a6),-(sp)
                dc.w    0xFF20  /* DOS CALL SUPER */
                addq.l  #4,sp
                move.l  P2754_pui_Palette(a6),G3082_pui_CurrentPalette(a5)
        }
}

void F1020_InitializeX68000(
void
)
{
#ifdef MEDIA577_X30J
        register unsigned char* L3071_puc_;
#endif
        register long L3064_l_;


        asm {
                moveq   #0x56,d0        /* TIMEGET */
                trap    #15             /* TRAP 15 (IOCS CALL) */
                move.l  d0,G0349_ul_LastRandomNumber(a5)
        }
#ifdef MEDIA577_X30J
        L3064_l_ = 800000;
        L3071_puc_ = F1017_Malloc(L3064_l_);
        if ((long)L3071_puc_ < 0) {
                L3064_l_ = ((long)L3071_puc_ & 0x00FFFFFF) - 8000;
                L3071_puc_ = F1017_Malloc(L3064_l_);
        }
        F0475_MEMORY_Initialize(L3071_puc_, L3064_l_, 0L, 0L);
#endif
#ifdef MEDIA692_X31J
        L3064_l_ = 1000000;
        G3139_ = F1017_Malloc(L3064_l_);
        if ((long)G3139_ < 0) {
                L3064_l_ = ((long)G3139_ & 0x00FFFFFF) - 8000;
                G3139_ = F1017_Malloc(L3064_l_);
        }
        F0475_MEMORY_Initialize(G3139_, L3064_l_, 0L, 0L);
#endif
        G2148_puc_InterfaceAndScrollsFontCustomColors = F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(1024, 6), C1_ALLOCATION_PERMANENT);
#ifdef MEDIA577_X30J
        G3083_puc_X68000_256bytes = F0468_MEMORY_Allocate(256, C1_ALLOCATION_PERMANENT);
        G3084_puc_X68000_4096bytes = F0468_MEMORY_Allocate(4096, C1_ALLOCATION_PERMANENT);
        G3085_pul_X68000_1024bytes = (unsigned long*)F0468_MEMORY_Allocate(1024, C1_ALLOCATION_PERMANENT);
        F1019_();
#endif
#ifdef MEDIA692_X31J
        VDEO_19_Operation(3, &G3076_B_);
        G3076_B_ = !G3076_B_;
        G3090_X68000VideoMemoryAddress = G9002_VDEObase->_pc_0x50[G9002_VDEObase->_w_0x4E_PhysicalScreenOrdinal - 1];
        G3118_ = G3090_X68000VideoMemoryAddress + (G3089_ * G2068_i_ViewportScreenY) + (G2067_i_ViewportScreenX * 2);
#endif
}
#endif

#ifdef MEDIA692_X31J
void F0750_CPSX(
void
)
{
        F1042_();
        F1018_Mfree();
        if (!G0302_B_GameWon) {
                F1028_FillX68000LargeScreenBlack();
        }
}
#endif
#endif
