#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 MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
int16_t G0233_ai_Graphic559_DirectionToStepEastCount[4];
int16_t G0234_ai_Graphic559_DirectionToStepNorthCount[4];
unsigned char G0235_auc_Graphic559_ThingDataByteCount[16];
unsigned char G0236_auc_Graphic559_AdditionalThingCounts[16];
OBJECT_INFO G0237_as_Graphic559_ObjectInfo[180];
WEAPON_INFO G0238_as_Graphic559_WeaponInfo[46];
ARMOUR_INFO G0239_as_Graphic559_ArmourInfo[58];
int16_t G0240_i_Graphic559_State_CPSD; /* This variable is necessary even if NOCOPYPROTECTION is defined because a value is loaded for it from graphic #559 */
unsigned char G0241_auc_Graphic559_JunkInfo[53];
int16_t G0242_ai_Graphic559_FoodAmounts[8];
CREATURE_INFO G0243_as_Graphic559_CreatureInfo[C027_CREATURE_TYPE_COUNT];
unsigned char G0244_auc_Graphic559_CreatureAttackSounds[8];
unsigned int16_t G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton[3];
unsigned int16_t G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem[2];
unsigned int16_t G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman[2];
unsigned int16_t G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight[7];
unsigned int16_t G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile[5];
unsigned int16_t G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound[3];
unsigned int16_t G0251_aui_Graphic559_FixedPossessionsCreature06Screamer[3];
unsigned int16_t G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm[4];
unsigned int16_t G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon[11];
DOOR_INFO G0254_as_Graphic559_DoorInfo[4];
char G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings[32][8];
char G0256_aac_Graphic559_EscapeReplacementCharacters[32][2];
char G0257_aac_Graphic559_InscriptionEscapeReplacementStrings[32][8];
unsigned char G0258_auc_Graphic559_GroupDirections[4];
int16_t G0259_i_Graphic559Anchor;
#endif
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t G0233_ai_Graphic559_DirectionToStepEastCount[4] = {
        0,    /* North */
        1,    /* East */
        0,    /* West */
        -1 }; /* South */
int16_t G0234_ai_Graphic559_DirectionToStepNorthCount[4] = {
        -1,  /* North */
        0,   /* East */
        1,   /* West */
        0 }; /* South */
unsigned char G0235_auc_Graphic559_ThingDataByteCount[16] = {
        4,   /* Door */
        6,   /* Teleporter */
        4,   /* Text String */
        8,   /* Sensor */
        16,  /* Group */
        4,   /* Weapon */
        4,   /* Armour */
        4,   /* Scroll */
        4,   /* Potion */
        8,   /* Container */
        4,   /* Junk */
        0,   /* Unused */
        0,   /* Unused */
        0,   /* Unused */
        8,   /* Projectile */
        4 }; /* Explosion */
unsigned char G0236_auc_Graphic559_AdditionalThingCounts[16] = {
        0,    /* Door */
        0,    /* Teleporter */
        0,    /* Text String */
        0,    /* Sensor */
        75,   /* Group */
        100,  /* Weapon */
        120,  /* Armour */
        0,    /* Scroll */
        5,    /* Potion */
        0,    /* Container */
        140,  /* Junk */
        0,    /* Unused */
        0,    /* Unused */
        0,    /* Unused */
        60,   /* Projectile */
        50 }; /* Explosion */
OBJECT_INFO G0237_as_Graphic559_ObjectInfo[180] = {
        /* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */
        {  30,  1,  0, 0x0500 },   /*   0 Scroll                          Pouch/Chest */
        { 144,  0,  0, 0x0200 },   /*   1 Chest                           Hands */
        { 148, 67,  0, 0x0500 },   /*   2 Mon Potion                      Pouch/Chest */
        { 149, 67,  0, 0x0500 },   /*   3 Um Potion                       Pouch/Chest */
        { 150, 67,  0, 0x0500 },   /*   4 Des Potion                      Pouch/Chest */
        { 151, 67, 42, 0x0500 },   /*   5 Ven Potion                      Pouch/Chest */
        { 152, 67,  0, 0x0500 },   /*   6 Sar Potion                      Pouch/Chest */
        { 153, 67,  0, 0x0500 },   /*   7 Zo Potion                       Pouch/Chest */
        { 154,  2,  0, 0x0501 },   /*   8 Ros Potion                      Mouth/Pouch/Chest */
        { 155,  2,  0, 0x0501 },   /*   9 Ku Potion                       Mouth/Pouch/Chest */
        { 156,  2,  0, 0x0501 },   /*  10 Dane Potion                     Mouth/Pouch/Chest */
        { 157,  2,  0, 0x0501 },   /*  11 Neta Potion                     Mouth/Pouch/Chest */
        { 158,  2,  0, 0x0501 },   /*  12 Bro Potion / Antivenin          Mouth/Pouch/Chest */
        { 159,  2,  0, 0x0501 },   /*  13 Ma Potion / Mon Potion          Mouth/Pouch/Chest */
        { 160,  2,  0, 0x0501 },   /*  14 Ya Potion                       Mouth/Pouch/Chest */
        { 161,  2,  0, 0x0501 },   /*  15 Ee Potion                       Mouth/Pouch/Chest */
        { 162,  2,  0, 0x0501 },   /*  16 Vi Potion                       Mouth/Pouch/Chest */
        { 163,  2,  0, 0x0501 },   /*  17 Water Flask                     Mouth/Pouch/Chest */
        { 164, 68,  0, 0x0500 },   /*  18 Kath Bomb                       Pouch/Chest */
        { 165, 68,  0, 0x0500 },   /*  19 Pew Bomb                        Pouch/Chest */
        { 166, 68,  0, 0x0500 },   /*  20 Ra Bomb                         Pouch/Chest */
        { 167, 68, 42, 0x0500 },   /*  21 Ful Bomb                        Pouch/Chest */
        { 195, 80,  0, 0x0500 },   /*  22 Empty Flask                     Pouch/Chest */
        {  16, 38, 43, 0x0500 },   /*  23 Eye Of Time                     Pouch/Chest */
        {  18, 38,  7, 0x0500 },   /*  24 Stormring                       Pouch/Chest */
        {   4, 35,  5, 0x0400 },   /*  25 Torch                           Chest */
        {  14, 37,  6, 0x0400 },   /*  26 Flamitt                         Chest */
        {  20, 11,  8, 0x0040 },   /*  27 Staff Of Claws                  Quiver 1 */
        {  23, 12,  9, 0x0040 },   /*  28 Bolt Blade / Storm              Quiver 1 */
        {  25, 12, 10, 0x0040 },   /*  29 Fury / Ra Blade                 Quiver 1 */
        {  27, 39, 11, 0x0040 },   /*  30 The Firestaff                   Quiver 1 */
        {  32, 17, 12, 0x05C0 },   /*  31 Dagger                          Quiver 1/Quiver 2/Pouch/Chest */
        {  33, 12, 13, 0x0040 },   /*  32 Falchion                        Quiver 1 */
        {  34, 12, 13, 0x0040 },   /*  33 Sword                           Quiver 1 */
        {  35, 12, 14, 0x0040 },   /*  34 Rapier                          Quiver 1 */
        {  36, 12, 15, 0x0040 },   /*  35 Sabre / Biter                   Quiver 1 */
        {  37, 12, 15, 0x0040 },   /*  36 Samurai Sword                   Quiver 1 */
        {  38, 12, 16, 0x0040 },   /*  37 Delta / Side Splitter           Quiver 1 */
        {  39, 12, 17, 0x0040 },   /*  38 Diamond Edge                    Quiver 1 */
        {  40, 42, 18, 0x0040 },   /*  39 Vorpal Blade                    Quiver 1 */
        {  41, 12, 19, 0x0040 },   /*  40 The Inquisitor / Dragon Fang    Quiver 1 */
        {  42, 13, 20, 0x0040 },   /*  41 Axe                             Quiver 1 */
        {  43, 13, 21, 0x0040 },   /*  42 Hardcleave / Executioner        Quiver 1 */
        {  44, 21, 22, 0x0040 },   /*  43 Mace                            Quiver 1 */
        {  45, 21, 22, 0x0040 },   /*  44 Mace Of Order                   Quiver 1 */
        {  46, 33, 23, 0x0440 },   /*  45 Morningstar                     Quiver 1/Chest */
        {  47, 43, 24, 0x0040 },   /*  46 Club                            Quiver 1 */
        {  48, 44, 24, 0x0040 },   /*  47 Stone Club                      Quiver 1 */
        {  49, 14, 27, 0x0040 },   /*  48 Bow / Claw Bow                  Quiver 1 */
        {  50, 45, 27, 0x0040 },   /*  49 Crossbow                        Quiver 1 */
        {  51, 16, 26, 0x05C0 },   /*  50 Arrow                           Quiver 1/Quiver 2/Pouch/Chest */
        {  52, 46, 26, 0x05C0 },   /*  51 Slayer                          Quiver 1/Quiver 2/Pouch/Chest */
        {  53, 11, 27, 0x0440 },   /*  52 Sling                           Quiver 1/Chest */
        {  54, 47, 42, 0x05C0 },   /*  53 Rock                            Quiver 1/Quiver 2/Pouch/Chest */
        {  55, 48, 40, 0x05C0 },   /*  54 Poison Dart                     Quiver 1/Quiver 2/Pouch/Chest */
        {  56, 49, 42, 0x05C0 },   /*  55 Throwing Star                   Quiver 1/Quiver 2/Pouch/Chest */
        {  57, 50,  5, 0x0040 },   /*  56 Stick                           Quiver 1 */
        {  58, 11,  5, 0x0040 },   /*  57 Staff                           Quiver 1 */
        {  59, 31, 28, 0x0540 },   /*  58 Wand                            Quiver 1/Pouch/Chest */
        {  60, 31, 29, 0x0540 },   /*  59 Teowand                         Quiver 1/Pouch/Chest */
        {  61, 11, 30, 0x0040 },   /*  60 Yew Staff                       Quiver 1 */
        {  62, 11, 31, 0x0040 },   /*  61 Staff Of Manar / Staff Of Irra  Quiver 1 */
        {  63, 11, 32, 0x0040 },   /*  62 Snake Staff / Cross Of Neta     Quiver 1 Atari ST Version 1.0 1987-12-08: ObjectAspectIndex = 35 */
        {  64, 51, 33, 0x0040 },   /*  63 The Conduit / Serpent Staff     Quiver 1 */
        {  65, 32,  5, 0x0440 },   /*  64 Dragon Spit                     Quiver 1/Chest */
        {  66, 30, 35, 0x0040 },   /*  65 Sceptre Of Lyf                  Quiver 1 */
        { 135, 65, 36, 0x0440 },   /*  66 Horn Of Fear                    Quiver 1/Chest */
        { 143, 45, 27, 0x0040 },   /*  67 Speedbow                        Quiver 1 */
        {  28, 82,  1, 0x0040 },   /*  68 The Firestaff (Complete)        Quiver 1 */
        {  80, 23,  0, 0x040C },   /*  69 Cape                            Neck/Torso/Chest */
        {  81, 23,  0, 0x040C },   /*  70 Cloak Of Night                  Neck/Torso/Chest */
        {  82, 23,  0, 0x0410 },   /*  71 Barbarian Hide / Tattered Pants Legs/Chest */
        { 112, 55,  0, 0x0420 },   /*  72 Sandals                         Feet/Chest */
        { 114,  8,  0, 0x0420 },   /*  73 Leather Boots                   Feet/Chest */
        {  67, 24,  0, 0x0408 },   /*  74 Robe (Body) / Tattered Shirt    Torso/Chest */
        {  83, 24,  0, 0x0410 },   /*  75 Robe (Legs)                     Legs/Chest */
        {  68, 24,  0, 0x0408 },   /*  76 Fine Robe (Body)                Torso/Chest */
        {  84, 24,  0, 0x0410 },   /*  77 Fine Robe (Legs)                Legs/Chest */
        {  69, 69,  0, 0x0408 },   /*  78 Kirtle                          Torso/Chest */
        {  70, 24,  0, 0x0408 },   /*  79 Silk Shirt                      Torso/Chest */
        {  85, 24,  0, 0x0410 },   /*  80 Tabard                          Legs/Chest */
        {  86, 69,  0, 0x0410 },   /*  81 Gunna                           Legs/Chest */
        {  71,  7,  0, 0x0408 },   /*  82 Elven Doublet                   Torso/Chest */
        {  87,  7,  0, 0x0410 },   /*  83 Elven Huke                      Legs/Chest */
        { 119, 57,  0, 0x0420 },   /*  84 Elven Boots                     Feet/Chest */
        {  72, 23,  0, 0x0408 },   /*  85 Leather Jerkin                  Torso/Chest */
        {  88, 23,  0, 0x0410 },   /*  86 Leather Pants                   Legs/Chest */
        { 113, 29,  0, 0x0420 },   /*  87 Suede Boots                     Feet/Chest */
        {  89, 69,  0, 0x0410 },   /*  88 Blue Pants                      Legs/Chest */
        {  73, 69,  0, 0x0408 },   /*  89 Tunic                           Torso/Chest */
        {  74, 24,  0, 0x0408 },   /*  90 Ghi                             Torso/Chest */
        {  90, 24,  0, 0x0410 },   /*  91 Ghi Trousers                    Legs/Chest */
        { 103, 53,  0, 0x0402 },   /*  92 Calista                         Head/Chest */
        { 104, 53,  0, 0x0402 },   /*  93 Crown Of Nerra                  Head/Chest */
        {  96,  9,  0, 0x0402 },   /*  94 Bezerker Helm                   Head/Chest */
        {  97,  9,  0, 0x0402 },   /*  95 Helmet                          Head/Chest */
        {  98,  9,  0, 0x0402 },   /*  96 Basinet                         Head/Chest */
        { 105, 54, 41, 0x0400 },   /*  97 Buckler / Neta Shield           Chest */
        { 106, 54, 41, 0x0200 },   /*  98 Hide Shield / Crystal Shield    Hands */
        { 108, 10, 41, 0x0200 },   /*  99 Wooden Shield                   Hands */
        { 107, 54, 41, 0x0200 },   /* 100 Small Shield                    Hands */
        {  75, 19,  0, 0x0408 },   /* 101 Mail Aketon                     Torso/Chest */
        {  91, 19,  0, 0x0410 },   /* 102 Leg Mail                        Legs/Chest */
        {  76, 19,  0, 0x0408 },   /* 103 Mithral Aketon                  Torso/Chest */
        {  92, 19,  0, 0x0410 },   /* 104 Mithral Mail                    Legs/Chest */
        {  99,  9,  0, 0x0402 },   /* 105 Casque'n Coif                   Head/Chest */
        { 115, 19,  0, 0x0420 },   /* 106 Hosen                           Feet/Chest */
        { 100, 52,  0, 0x0402 },   /* 107 Armet                           Head/Chest */
        {  77, 20,  0, 0x0008 },   /* 108 Torso Plate                     Torso */
        {  93, 22,  0, 0x0010 },   /* 109 Leg Plate                       Legs */
        { 116, 56,  0, 0x0420 },   /* 110 Foot Plate                      Feet/Chest */
        { 109, 10, 41, 0x0200 },   /* 111 Large Shield / Sar Shield       Hands */
        { 101, 52,  0, 0x0402 },   /* 112 Helm Of Lyte / Helm Of Ra       Head/Chest */
        {  78, 20,  0, 0x0008 },   /* 113 Plate Of Lyte / Plate Of Ra     Torso */
        {  94, 22,  0, 0x0010 },   /* 114 Poleyn Of Lyte / Poleyn Of Ra   Legs */
        { 117, 56,  0, 0x0420 },   /* 115 Greave Of Lyte / Greave Of Ra   Feet/Chest */
        { 110, 10, 41, 0x0200 },   /* 116 Shield Of Lyte / Shield Of Ra   Hands */
        { 102, 52,  0, 0x0402 },   /* 117 Helm Of Darc / Dragon Helm      Head/Chest */
        {  79, 20,  0, 0x0008 },   /* 118 Plate Of Darc / Dragon Plate    Torso */
        {  95, 22,  0, 0x0010 },   /* 119 Poleyn Of Darc / Dragon Poleyn  Legs */
        { 118, 56,  0, 0x0420 },   /* 120 Greave Of Darc / Dragon Greave  Feet/Chest */
        { 111, 10, 41, 0x0200 },   /* 121 Shield Of Darc / Dragon Shield  Hands */
        { 140, 52,  0, 0x0402 },   /* 122 Dexhelm                         Head/Chest */
        { 141, 19,  0, 0x0408 },   /* 123 Flamebain                       Torso/Chest */
        { 142, 22,  0, 0x0010 },   /* 124 Powertowers                     Legs */
        { 194, 81,  0, 0x0420 },   /* 125 Boots Of Speed                  Feet/Chest */
        { 196, 84,  0, 0x0408 },   /* 126 Halter                          Torso/Chest */
        {   0, 34,  0, 0x0500 },   /* 127 Compass                         Pouch/Chest */
        {   8,  6,  0, 0x0501 },   /* 128 Water / Waterskin               Mouth/Pouch/Chest */
        {  10, 15,  0, 0x0504 },   /* 129 Jewel Symal                     Neck/Pouch/Chest */
        {  12, 15,  0, 0x0504 },   /* 130 Illumulet                       Neck/Pouch/Chest */
        { 146, 40,  0, 0x0500 },   /* 131 Ashes                           Pouch/Chest */
        { 147, 41,  0, 0x0400 },   /* 132 Bones                           Chest */
        { 125,  4, 37, 0x0500 },   /* 133 Copper Coin / Sar Coin          Pouch/Chest */
        { 126, 83, 37, 0x0500 },   /* 134 Silver Coin                     Pouch/Chest */
        { 127,  4, 37, 0x0500 },   /* 135 Gold Coin / Gor Coin            Pouch/Chest */
        { 176, 18,  0, 0x0500 },   /* 136 Iron Key                        Pouch/Chest */
        { 177, 18,  0, 0x0500 },   /* 137 Key Of B                        Pouch/Chest */
        { 178, 18,  0, 0x0500 },   /* 138 Solid Key                       Pouch/Chest */
        { 179, 18,  0, 0x0500 },   /* 139 Square Key                      Pouch/Chest */
        { 180, 18,  0, 0x0500 },   /* 140 Tourquoise Key                  Pouch/Chest */
        { 181, 18,  0, 0x0500 },   /* 141 Cross Key                       Pouch/Chest */
        { 182, 18,  0, 0x0500 },   /* 142 Onyx Key                        Pouch/Chest */
        { 183, 18,  0, 0x0500 },   /* 143 Skeleton Key                    Pouch/Chest */
        { 184, 62,  0, 0x0500 },   /* 144 Gold Key                        Pouch/Chest */
        { 185, 62,  0, 0x0500 },   /* 145 Winged Key                      Pouch/Chest */
        { 186, 62,  0, 0x0500 },   /* 146 Topaz Key                       Pouch/Chest */
        { 187, 62,  0, 0x0500 },   /* 147 Sapphire Key                    Pouch/Chest */
        { 188, 62,  0, 0x0500 },   /* 148 Emerald Key                     Pouch/Chest */
        { 189, 62,  0, 0x0500 },   /* 149 Ruby Key                        Pouch/Chest */
        { 190, 62,  0, 0x0500 },   /* 150 Ra Key                          Pouch/Chest */
        { 191, 62,  0, 0x0500 },   /* 151 Master Key                      Pouch/Chest */
        { 128, 76,  0, 0x0200 },   /* 152 Boulder                         Hands */
        { 129,  3,  0, 0x0500 },   /* 153 Blue Gem                        Pouch/Chest */
        { 130, 60,  0, 0x0500 },   /* 154 Orange Gem                      Pouch/Chest */
        { 131, 61,  0, 0x0500 },   /* 155 Green Gem                       Pouch/Chest */
        { 168, 27,  0, 0x0501 },   /* 156 Apple                           Mouth/Pouch/Chest */
        { 169, 28,  0, 0x0501 },   /* 157 Corn                            Mouth/Pouch/Chest */
        { 170, 25,  0, 0x0501 },   /* 158 Bread                           Mouth/Pouch/Chest */
        { 171, 26,  0, 0x0501 },   /* 159 Cheese                          Mouth/Pouch/Chest */
        { 172, 71,  0, 0x0401 },   /* 160 Screamer Slice                  Mouth/Chest */
        { 173, 70,  0, 0x0401 },   /* 161 Worm Round                      Mouth/Chest */
        { 174,  5,  0, 0x0501 },   /* 162 Drumstick / Shank               Mouth/Pouch/Chest */
        { 175, 66,  0, 0x0501 },   /* 163 Dragon Steak                    Mouth/Pouch/Chest */
        { 120, 15,  0, 0x0504 },   /* 164 Gem Of Ages                     Neck/Pouch/Chest */
        { 121, 15,  0, 0x0504 },   /* 165 Ekkhard Cross                   Neck/Pouch/Chest */
        { 122, 58,  0, 0x0504 },   /* 166 Moonstone                       Neck/Pouch/Chest */
        { 123, 59,  0, 0x0504 },   /* 167 The Hellion                     Neck/Pouch/Chest */
        { 124, 59,  0, 0x0504 },   /* 168 Pendant Feral                   Neck/Pouch/Chest */
        { 132, 79, 38, 0x0500 },   /* 169 Magical Box (Blue)              Pouch/Chest */
        { 133, 63, 38, 0x0500 },   /* 170 Magical Box (Green)             Pouch/Chest */
        { 134, 64,  0, 0x0500 },   /* 171 Mirror Of Dawn                  Pouch/Chest */
        { 136, 72, 39, 0x0400 },   /* 172 Rope                            Chest */
        { 137, 73,  0, 0x0500 },   /* 173 Rabbit's Foot                   Pouch/Chest */
        { 138, 74,  0, 0x0500 },   /* 174 Corbamite / Corbum              Pouch/Chest */
        { 139, 75,  0, 0x0504 },   /* 175 Choker                          Neck/Pouch/Chest */
        { 192, 77,  0, 0x0500 },   /* 176 Lock Picks                      Pouch/Chest */
        { 193, 78,  0, 0x0500 },   /* 177 Magnifier                       Pouch/Chest */
        { 197, 74,  0, 0x0000 },   /* 178 Zokathra Spell                  */
        { 198, 41,  0, 0x0400 } }; /* 179 Bones                           Chest */
WEAPON_INFO G0238_as_Graphic559_WeaponInfo[46] = {
        /* { Weight, Class, Strength, KineticEnergy, Attributes } */
        {   1, 130,   2,   0, 0x2000 },   /* EYE OF TIME */
        {   1, 131,   2,   0, 0x2000 },   /* STORMRING */
        {  11,   0,   8,   2, 0x2000 },   /* TORCH */
        {  12, 112,  10,  80, 0x2028 },   /* FLAMITT */
        {   9, 129,  16,   7, 0x2000 },   /* STAFF OF CLAWS */
        {  30, 113,  49, 110, 0x0942 },   /* BOLT BLADE */
        {  47,   0,  55,  20, 0x0900 },   /* FURY */
        {  24, 255,  25,  10, 0x20FF },   /* THE FIRESTAFF */
        {   5,   2,  10,  19, 0x0200 },   /* DAGGER */
        {  33,   0,  30,   8, 0x0900 },   /* FALCHION */
        {  32,   0,  34,  10, 0x0900 },   /* SWORD */
        {  26,   0,  38,  10, 0x0900 },   /* RAPIER */
        {  35,   0,  42,  11, 0x0900 },   /* SABRE */
        {  36,   0,  46,  12, 0x0900 },   /* SAMURAI SWORD */
        {  33,   0,  50,  14, 0x0900 },   /* DELTA */
        {  37,   0,  62,  14, 0x0900 },   /* DIAMOND EDGE */
        {  30,   0,  48,  13, 0x0000 },   /* VORPAL BLADE */
        {  39,   0,  58,  15, 0x0900 },   /* THE INQUISITOR */
        {  43,   2,  49,  33, 0x0300 },   /* AXE */
        {  65,   2,  70,  44, 0x0300 },   /* HARDCLEAVE */
        {  31,   0,  32,  10, 0x2000 },   /* MACE */
        {  41,   0,  42,  13, 0x2000 },   /* MACE OF ORDER */
        {  50,   0,  60,  15, 0x2000 },   /* MORNINGSTAR */
        {  36,   0,  19,  10, 0x2700 },   /* CLUB */
        { 110,   0,  44,  22, 0x2600 },   /* STONE CLUB */
        {  10,  20,   1,  50, 0x2032 },   /* BOW */
        {  28,  30,   1, 180, 0x2078 },   /* CROSSBOW */
        {   2,  10,   2,  10, 0x0100 },   /* ARROW */
        {   2,  10,   2,  28, 0x0500 },   /* SLAYER */
        {  19,  39,   5,  20, 0x2032 },   /* SLING */
        {  10,  11,   6,  18, 0x2000 },   /* ROCK */
        {   3,  12,   7,  23, 0x0800 },   /* POISON DART */
        {   1,   1,   3,  19, 0x0A00 },   /* THROWING STAR */
        {  8,    0,   4,   4, 0x2000 },   /* STICK */
        {  26, 129,  12,   4, 0x2000 },   /* STAFF */
        {   1, 130,   0,   0, 0x2000 },   /* WAND */
        {   2, 140,   1,  20, 0x2000 },   /* TEOWAND */
        {  35, 128,  18,   6, 0x2000 },   /* YEW STAFF */
        {  29, 159,   0,   4, 0x2000 },   /* STAFF OF MANAR */
        {  21, 131,   0,   3, 0x2000 },   /* SNAKE STAFF */
        {  33, 136,   0,   7, 0x2000 },   /* THE CONDUIT */
        {   8, 132,   3,   1, 0x2000 },   /* DRAGON SPIT */
        {  18, 131,   9,   4, 0x2000 },   /* SCEPTRE OF LYF */
        {   8, 192,   1,   1, 0x2000 },   /* HORN OF FEAR */
        {  30,  26,   1, 220, 0x207D },   /* SPEEDBOW */
        {  36, 255, 100,  50, 0x20FF } }; /* THE FIRESTAFF */
ARMOUR_INFO G0239_as_Graphic559_ArmourInfo[58] = {
        /* { Weight, Defense, Attributes, Unreferenced } */
        {   3,   5,                          1, 0 },   /* CAPE */
        {   4,  10,                          1, 0 },   /* CLOAK OF NIGHT */
        {   3,   4,                          1, 0 },   /* BARBARIAN HIDE */
        {   6,   5,                          2, 0 },   /* SANDALS */
        {  16,  25,                          4, 0 },   /* LEATHER BOOTS */
        {   4,   5,                          0, 0 },   /* ROBE */
        {   4,   5,                          0, 0 },   /* ROBE */
        {   3,   7,                          1, 0 },   /* FINE ROBE */
        {   3,   7,                          1, 0 },   /* FINE ROBE */
        {   4,   6,                          1, 0 },   /* KIRTLE */
        {   2,   4,                          0, 0 },   /* SILK SHIRT */
        {   4,   5,                          1, 0 },   /* TABARD */
        {   5,   7,                          1, 0 },   /* GUNNA */
        {   3,  11,                          2, 0 },   /* ELVEN DOUBLET */
        {   3,  13,                          2, 0 },   /* ELVEN HUKE */
        {   4,  13,                          2, 0 },   /* ELVEN BOOTS */
        {   6,  17,                          3, 0 },   /* LEATHER JERKIN */
        {   8,  20,                          3, 0 },   /* LEATHER PANTS */
        {  14,  20,                          3, 0 },   /* SUEDE BOOTS */
        {   6,  12,                          2, 0 },   /* BLUE PANTS */
        {   5,   9,                          1, 0 },   /* TUNIC */
        {   5,   8,                          1, 0 },   /* GHI */
        {   5,   9,                          1, 0 },   /* GHI TROUSERS */
        {   4,   1,                          4, 0 },   /* CALISTA */
        {   6,   5,                          4, 0 },   /* CROWN OF NERRA */
        {  11,  12,                          5, 0 },   /* BEZERKER HELM */
        {  14,  17,                          5, 0 },   /* HELMET */
        {  15,  20,                          5, 0 },   /* BASINET */
        {  11,  22, MASK0x0080_IS_A_SHIELD | 5, 0 },   /* BUCKLER */
        {  10,  16, MASK0x0080_IS_A_SHIELD | 2, 0 },   /* HIDE SHIELD */
        {  14,  20, MASK0x0080_IS_A_SHIELD | 3, 0 },   /* WOODEN SHIELD */
        {  21,  35, MASK0x0080_IS_A_SHIELD | 4, 0 },   /* SMALL SHIELD */
        {  65,  35,                          5, 0 },   /* MAIL AKETON */
        {  53,  35,                          5, 0 },   /* LEG MAIL */
        {  52,  70,                          7, 0 },   /* MITHRAL AKETON */
        {  41,  55,                          7, 0 },   /* MITHRAL MAIL */
        {  16,  25,                          6, 0 },   /* CASQUE 'N COIF */
        {  16,  30,                          6, 0 },   /* HOSEN */
        {  19,  40,                          7, 0 },   /* ARMET */
        { 120,  65,                          4, 0 },   /* TORSO PLATE */
        {  80,  56,                          4, 0 },   /* LEG PLATE */
        {  28,  37,                          5, 0 },   /* FOOT PLATE */
        {  34,  56, MASK0x0080_IS_A_SHIELD | 4, 0 },   /* LARGE SHIELD */
        {  17,  62,                          5, 0 },   /* HELM OF LYTE */
        { 108, 125,                          4, 0 },   /* PLATE OF LYTE */
        {  72,  90,                          4, 0 },   /* POLEYN OF LYTE */
        {  24,  50,                          5, 0 },   /* GREAVE OF LYTE */
        {  30,  85, MASK0x0080_IS_A_SHIELD | 4, 0 },   /* SHIELD OF LYTE */
        {  35,  76,                          4, 0 },   /* HELM OF DARC */
        { 141, 160,                          4, 0 },   /* PLATE OF DARC */
        {  90, 101,                          4, 0 },   /* POLEYN OF DARC */
        {  31,  60,                          5, 0 },   /* GREAVE OF DARC */
        {  40, 100, MASK0x0080_IS_A_SHIELD | 4, 0 },   /* SHIELD OF DARC */
        {  14,  54,                          6, 0 },   /* DEXHELM */
        {  57,  60,                          7, 0 },   /* FLAMEBAIN */
        {  81,  88,                          4, 0 },   /* POWERTOWERS */
        {   3,  16,                          2, 0 },   /* BOOTS OF SPEED */
        {   2,   3,                          3, 0 } }; /* HALTER */
#ifdef MEDIA396_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J /* Not included in Amiga DM DEMO 2.0 EN */
#ifndef NOCOPYPROTECTION
int16_t G0240_i_Graphic559_State_CPSD = 4; /* This variable is necessary even if NOCOPYPROTECTION is defined because a value is loaded for it from graphic #559 */
#endif
#endif
unsigned char G0241_auc_Graphic559_JunkInfo[53] = {
        1,   /* COMPASS */
        3,   /* WATERSKIN */
        2,   /* JEWEL SYMAL */
        2,   /* ILLUMULET */
        4,   /* ASHES */
        15,  /* BONES */
        1,   /* COPPER COIN */
        1,   /* SILVER COIN */
        1,   /* GOLD COIN */
        2,   /* IRON KEY */
        1,   /* KEY OF B */
        1,   /* SOLID KEY */
        1,   /* SQUARE KEY */
        1,   /* TOURQUOISE KEY */
        1,   /* CROSS KEY */
        1,   /* ONYX KEY */
        1,   /* SKELETON KEY */
        1,   /* GOLD KEY */
        1,   /* WINGED KEY */
        1,   /* TOPAZ KEY */
        1,   /* SAPPHIRE KEY */
        1,   /* EMERALD KEY */
        1,   /* RUBY KEY */
        1,   /* RA KEY */
        1,   /* MASTER KEY */
        81,  /* BOULDER */
        2,   /* BLUE GEM */
        3,   /* ORANGE GEM */
        2,   /* GREEN GEM */
        4,   /* APPLE */
        4,   /* CORN */
        3,   /* BREAD */
        8,   /* CHEESE */
        5,   /* SCREAMER SLICE */
        11,  /* WORM ROUND */
        4,   /* DRUMSTICK */
        6,   /* DRAGON STEAK */
        2,   /* GEM OF AGES */
        3,   /* EKKHARD CROSS */
        2,   /* MOONSTONE */
        2,   /* THE HELLION */
        2,   /* PENDANT FERAL */
        6,   /* MAGICAL BOX */
        9,   /* MAGICAL BOX */
        3,   /* MIRROR OF DAWN */
        10,  /* ROPE */
        1,   /* RABBIT'S FOOT */
        0,   /* CORBAMITE */
        1,   /* CHOKER */
        1,   /* LOCK PICKS */
        2,   /* MAGNIFIER */
        0,   /* ZOKATHRA SPELL */
        8 }; /* BONES */
int16_t G0242_ai_Graphic559_FoodAmounts[8] = {
        500,    /* Apple */
        600,    /* Corn */
        650,    /* Bread */
        820,    /* Cheese */
        550,    /* Screamer Slice */
        350,    /* Worm round */
        990,    /* Drumstick / Shank */
        1400 }; /* Dragon steak */
#endif
#ifdef MEDIA357_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA
CREATURE_INFO G0243_as_Graphic559_CreatureInfo[C027_CREATURE_TYPE_COUNT] = {
        /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack, Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */
        {  0,  4, 0x0482, 0x623D,   8, 20,  55, 150, 150, 240,  55, 0, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4 },
        {  1,  0, 0x0480, 0xA625,  15, 32,  20, 110,  80,  15,  20, 0, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3 },
        {  2,  6, 0x0510, 0x6198,   3,  5,  50,  10,  10,   0, 110, 0, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0 },
        {  3,  0, 0x04B4, 0xB225,  10, 21,  30,  40,  58,   0,  80, 0, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5 },
        {  4,  1, 0x0701, 0xA3B8,   9,  8,  45, 101,  90,   0,  65, 0, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4 },
        {  5,  0, 0x0581, 0x539D,  20, 18, 100,  60,  30,   0,  30, 0, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3 },
        {  6,  3, 0x070C, 0x0020, 120, 10,   5, 165,   5,   0,   5, 0, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        {  7,  7, 0x0300, 0x0220, 185, 15, 170,  50,  40,   5,  10, 0, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4 }, /* Atari ST: AttackSoundOrdinal = 0 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        {  7,  0, 0x0300, 0x0220, 185, 15, 170,  50,  40,   5,  10, 0, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4 }, /* Like Atari ST */
#endif
        {  8,  2, 0x1864, 0x5225,  11, 16,  15,  30,  55,   0,  80, 0, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        {  9, 10, 0x0282, 0x71B8,  21, 14, 240, 120, 219,   0,  35, 0, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3 }, /* Atari ST: AttackSoundOrdinal = 7 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        {  9,  7, 0x0282, 0x71B8,  21, 14, 240, 120, 219,   0,  35, 0, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3 }, /* Like Atari ST */
#endif
        { 10,  2, 0x1480, 0x11B8,  17, 12,  25,  33,  20,   0,  40, 0, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3 },
        { 11,  0, 0x18C6, 0x0225, 255,  8,  45,  80, 105,   0,  60, 0, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        { 12, 11, 0x1280, 0x6038,   7,  7,  22,  20,  22,   0,  80, 0, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4 }, /* Atari ST: AttackSoundOrdinal = 8 */
        { 13,  9, 0x14A2, 0xB23D,   5, 10,  42,  39,  90, 100,  88, 0, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4 }, /* Atari ST: AttackSoundOrdinal = 0 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        { 12,  8, 0x1280, 0x6038,   7,  7,  22,  20,  22,   0,  80, 0, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4 }, /* Like Atari ST */
        { 13,  0, 0x14A2, 0xB23D,   5, 10,  42,  39,  90, 100,  88, 0, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4 }, /* Like Atari ST */
#endif
        { 14,  0, 0x05B8, 0x1638,  10, 20,  47,  44,  75,   0,  90, 0, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5 },
        { 15,  5, 0x0381, 0x523D,  18, 19,  72,  70,  45,  35,  35, 0, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        { 16, 10, 0x0680, 0xA038,  13,  8,  28,  20,  25,   0,  41, 0, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3 }, /* Atari ST: AttackSoundOrdinal = 7 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        { 16,  7, 0x0680, 0xA038,  13,  8,  28,  20,  25,   0,  41, 0, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3 }, /* Like Atari ST */
#endif
        { 17,  0, 0x04A0, 0xF23D,   1, 16, 180,   8,  28,  20, 150, 0, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        { 18, 11, 0x0280, 0xA3BD,  14,  6, 140,  60, 105,   0,  70, 0, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4 }, /* Atari ST: AttackSoundOrdinal = 8 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        { 18,  8, 0x0280, 0xA3BD,  14,  6, 140,  60, 105,   0,  70, 0, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4 }, /* Like Atari ST */
#endif
        { 19,  0, 0x0060, 0xE23D,   5, 18,  15,  33,  61,   0,  65, 0, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5 },
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        { 20,  8, 0x10DE, 0x0225,  25, 25,  75, 144,  66,   0,  50, 0, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3 }, /* Atari ST: AttackSoundOrdinal = 0 */
#endif
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
        { 20,  0, 0x10DE, 0x0225,  25, 25,  75, 144,  66,   0,  50, 0, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3 }, /* Like Atari ST */
#endif
        { 21,  3, 0x0082, 0xA3BD,   7, 15,  33,  77, 130,   0,  60, 0, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4 },
        { 22,  0, 0x1480, 0x53BD,  10, 14,  68, 100, 100,   0,  75, 0, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3 },
        { 23,  0, 0x38AA, 0x0038,  12, 22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5 },
        { 24,  1, 0x068A, 0x97BD,  13, 28, 110, 255, 255,   0,  70, 0, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11: Ranges = 0x2645 */
        { 25,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5 },
        { 26,  0, 0x38AA, 0x0000,  12, 22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5 } };
#ifdef MEDIA385_G14ED_F20E_F20J_X30J_P20JA
unsigned char G0244_auc_Graphic559_CreatureAttackSounds[8] = {
#endif
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
unsigned char G0244_auc_Graphic559_CreatureAttackSounds[11] = {
#endif
        C03_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON,
        C07_SOUND_ATTACK_MUMMY_GHOST_RIVE,
        C14_SOUND_ATTACK_SCREAMER_OITU,
        C15_SOUND_ATTACK_GIANT_SCORPION_SCORPION,
        C19_SOUND_ATTACK_MAGENTA_WORM_WORM,
        C21_SOUND_ATTACK_GIGGLER,
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        C29_SOUND_ATTACK_ROCK_ROCKPILE,   /* Atari ST and P20JA: not present */
        C30_SOUND_ATTACK_WATER_ELEMENTAL, /* Atari ST and P20JA: not present */
        C31_SOUND_ATTACK_COUATL,          /* Atari ST and P20JA: not present */
#endif
        C04_SOUND_WOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM,
        M563_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT };
unsigned int16_t G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton[3] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C09_WEAPON_FALCHION,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C30_ARMOUR_WOODEN_SHIELD, 0 };
unsigned int16_t G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem[2] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C24_WEAPON_STONE_CLUB, 0 };
unsigned int16_t G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman[2] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C23_WEAPON_CLUB, 0 };
unsigned int16_t G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight[7] = {
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C41_ARMOUR_FOOT_PLATE,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C40_ARMOUR_LEG_PLATE,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C39_ARMOUR_TORSO_PLATE,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C10_WEAPON_SWORD,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C38_ARMOUR_ARMET,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C10_WEAPON_SWORD, 0 };
unsigned int16_t G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile[5] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C25_JUNK_BOULDER,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C25_JUNK_BOULDER | MASK0x8000_RANDOM_DROP,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C30_WEAPON_ROCK | MASK0x8000_RANDOM_DROP,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C30_WEAPON_ROCK | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound[3] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C35_JUNK_DRUMSTICK_SHANK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C35_JUNK_DRUMSTICK_SHANK | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0251_aui_Graphic559_FixedPossessionsCreature06Screamer[3] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C33_JUNK_SCREAMER_SLICE,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C33_JUNK_SCREAMER_SLICE | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm[4] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND | MASK0x8000_RANDOM_DROP,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon[11] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK | MASK0x8000_RANDOM_DROP,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK | MASK0x8000_RANDOM_DROP, 0 };
#endif
#ifdef MEDIA369_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
DOOR_INFO G0254_as_Graphic559_DoorInfo[4] = {
        /* { Attributes, Defense } Melee attacks can only destroy wooden doors because melee attacks are limited to 100 */
        { MASK0x0002_PROJECTILES_CAN_PASS_THROUGH | MASK0x0001_CREATURES_CAN_SEE_THROUGH, 110 },   /* Door type 0 Portcullis */
        { 0,                                                                               42 },   /* Door type 1 Wooden door */
        { 0,                                                                              230 },   /* Door type 2 Iron door */
        { MASK0x0004_ANIMATED | MASK0x0001_CREATURES_CAN_SEE_THROUGH,                     255 } }; /* Door type 3 Ra door */
char G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings[32][8] = {
        { 'x',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
        { 'y',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
        { 'T','H','E',' ', 0, 0, 0, 0 },
        { 'Y','O','U',' ', 0, 0, 0, 0 },
        { 'z',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '{',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '|',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '}',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '~',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 } };
char G0256_aac_Graphic559_EscapeReplacementCharacters[32][2] = {
        { 'a', 0 },
        { 'b', 0 },
        { 'c', 0 },
        { 'd', 0 },
        { 'e', 0 },
        { 'f', 0 },
        { 'g', 0 },
        { 'h', 0 },
        { 'i', 0 },
        { 'j', 0 },
        { 'k', 0 },
        { 'l', 0 },
        { 'm', 0 },
        { 'n', 0 },
        { 'o', 0 },
        { 'p', 0 },
        { 'q', 0 },
        { 'r', 0 },
        { 's', 0 },
        { 't', 0 },
        { 'u', 0 },
        { 'v', 0 },
        { 'w', 0 },
        { 'x', 0 },
        { '0', 0 },
        { '1', 0 },
        { '2', 0 },
        { '3', 0 },
        { '4', 0 },
        { '5', 0 },
        { '6', 0 },
        { '7', 0 } };
char G0257_aac_Graphic559_InscriptionEscapeReplacementStrings[32][8] = {
        { 28,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 29,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 19,  7,  4, 26, 0, 0, 0, 0 },
        { 24, 14, 20, 26, 0, 0, 0, 0 },
        { 30,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 31,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 32,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 33,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 34,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 35,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 } };
unsigned char G0258_auc_Graphic559_GroupDirections[4] = { 0x00, 0x55, 0xAA, 0xFF };
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
CREATURE_INFO G0243_as_Graphic559_CreatureInfo[C027_CREATURE_TYPE_COUNT] = {
#ifdef MEDIA469_P20JB
        {  0,  4,  0x0482,  0x623D,   8,  20,  55, 150, 150, 240,  55, 0, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        {  0,  4,  0x0482,  0x623D,   8,  20,  55, 150, 150, 240,  55, 0, 0x1153, 0x29AB, 0x0876, 0x0254, 0xFD40, 4, 0 },
#endif
        {  1, 14,  0x0480,  0xA625,  15,  32,  20, 110,  80,  15,  20, 0, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3, 0 },
#ifdef MEDIA469_P20JB
        {  2,  6,  0x0510,  0x6198,   3,   5,  50,  10,  10,   0, 110, 0, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        {  2,  6,  0x4510,  0x6198,   3,   5,  50,  10,  10,   0, 110, 0, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0, 0 },
#endif
        {  3,  0,  0x04B4,  0xB225,  10,  21,  30,  40,  58,   0,  80, 0, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5, 0 },
        {  4, 18,  0x0701,  0xA3B8,   9,   8,  45, 101,  90,   0,  65, 0, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4, 0 },
        {  5, 17,  0x0581,  0x539D,  20,  18, 100,  60,  30,   0,  30, 0, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3, 0 },
        {  6,  3,  0x070C,  0x0020, 120,  10,   5, 165,   5,   0,   5, 0, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6, 0 },
        {  7,  7,  0x0300,  0x0220, 185,  15, 170,  50,  40,   5,  10, 0, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4, 0 },
#ifdef MEDIA469_P20JB
        {  8,  2,  0x1864,  0x5225,  11,  16,  15,  30,  55,   0,  80, 0, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        {  8,  2,  0x5864,  0x5225,  11,  16,  15,  30,  55,   0,  80, 0, 0x1423, 0x4684, 0x0FC8, 0x0116, 0xFB30, 6, 0 },
#endif
        {  9, 10,  0x0282,  0x71B8,  21,  14, 240, 120, 219,   0,  35, 0, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3, 0 },
        { 10, 13,  0x1480,  0x11B8,  17,  12,  25,  33,  20,   0,  40, 0, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3, 0 },
#ifdef MEDIA469_P20JB
        { 11,  0,  0x18C6,  0x0225, 255,   8,  45,  80, 105,   0,  60, 0, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        { 11,  0,  0x18C6,  0x0225, 255,   8,  45,  80, 105,   0,  60, 0, 0x1312, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1, 0 },
#endif
        { 12, 11,  0x1280,  0x6038,   7,   7,  22,  20,  22,   0,  80, 0, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4, 0 },
#ifdef MEDIA469_P20JB
        { 13,  9,  0x14A2,  0xB23D,   5,  10,  42,  39,  90, 100,  88, 0, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        { 13,  9,  0x14A2,  0xB23D,   5,  10,  42,  39,  90, 100,  88, 0, 0x1343, 0x5745, 0x0638, 0x0112, 0xFA30, 4, 0 },
#endif
        { 14, 16,  0x05B8,  0x1638,  10,  20,  47,  44,  75,   0,  90, 0, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5, 0 },
        { 15,  5,  0x0381,  0x523D,  18,  19,  72,  70,  45,  35,  35, 0, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4, 0 },
        { 16, 10,  0x0680,  0xA038,  13,   8,  28,  20,  25,   0,  41, 0, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3, 0 },
        { 17, 15,  0x04A0,  0xF23D,   1,  16, 180,   8,  28,  20, 150, 0, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4, 0 },
        { 18, 12,  0x0280,  0xA3BD,  14,   6, 140,  60, 105,   0,  70, 0, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4, 0 },
#ifdef MEDIA469_P20JB
        { 19,  0,  0x0060,  0xE23D,   5,  18,  15,  33,  61,   0,  65, 0, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5, 0 },
        { 20,  8,  0x10DE,  0x0225,  25,  25,  75, 144,  66,   0,  50, 0, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3, 0 },
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        { 19,  0,  0x4060,  0xE23D,   5,  18,  15,  33,  61,   0,  65, 0, 0x3258, 0xAC97, 0x0F56, 0x0117, 0xFC40, 5, 0 },
        { 20,  8,  0x10DE,  0x0225,  25,  25,  75, 144,  66,   0,  50, 0, 0x1381, 0x7699, 0x0EA7, 0x0345, 0xFD93, 3, 0 },
#endif
        { 21,  3,  0x0082,  0xA3BD,   7,  15,  33,  77, 130,   0,  60, 0, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4, 0 },
        { 22, 16,  0x1480,  0x53BD,  10,  14,  68, 100, 100,   0,  75, 0, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3, 0 },
#ifdef MEDIA469_P20JB
        { 23,  0,  0x38AA,  0x0038,  12,  22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5, 0 },
        { 24,  1,  0x068A,  0x97BD,  13,  28, 110, 255, 255,   0,  70, 0, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4, 0 },
        { 25,  0,  0x38AA,  0x0000,  12,  22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5, 0 },
        { 26,  0,  0x38AA,  0x0000,  12,  22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5, 0 } };
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        { 23,  0,  0x78AA,  0x0038,  12,  22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFFA7, 0x0FBF, 0x0564, 0xFB52, 5, 0 },
        { 24,  1,  0x068A,  0x97BD,  13,  28, 110, 255, 255,   0,  70, 0, 0x3645, 0xBFBC, 0x06CD, 0x0445, 0xFC30, 4, 0 },
        { 25,  0,  0x78AA,  0x0000,  12,  22, 255, 180, 210,   0, 130, 0, 0x6369, 0xFFBC, 0x0FBF, 0x0564, 0xFB52, 5, 0 },
        { 26,  0,  0x78AA,  0x0000, 255, 255, 255, 180, 210,   0, 130, 0, 0x6369, 0xFFF0, 0x0FBF, 0x0564, 0xFB52, 5, 0 } };
#endif
char G2003_aauc_CreatureSounds[18][2] = { /* Replaces G0244_auc_Graphic559_CreatureAttackSounds */
        { C23_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON,                C33_SOUND_MOVE_RED_DRAGON },
        { C25_SOUND_ATTACK_MUMMY_GHOST_RIVE,                             CM1_SOUND_NONE },
        { C19_SOUND_ATTACK_SCREAMER_OITU,                                C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU },
        { C20_SOUND_ATTACK_GIANT_SCORPION_SCORPION,                      C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU },
        { C21_SOUND_ATTACK_MAGENTA_WORM_WORM,                            C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU },
        { C22_SOUND_ATTACK_GIGGLER,                                      C30_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON },
        { C24_SOUND_ATTACK_ROCK_ROCKPILE,                                C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU },
        { C26_SOUND_ATTACK_WATER_ELEMENTAL,                              C32_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL },
        { C27_SOUND_ATTACK_COUATL,                                       C29_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER },
        { C04_SOUND_WOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM,        C30_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON },
        { M563_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, C34_SOUND_MOVE_SKELETON },
        { M563_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, C28_SOUND_MOVE_ANIMATED_ARMOUR_DETH_KNIGHT },
        { C25_SOUND_ATTACK_MUMMY_GHOST_RIVE,                             C30_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON },
        { CM1_SOUND_NONE,                                                C32_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL },
        { CM1_SOUND_NONE,                                                C29_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER },
        { CM1_SOUND_NONE,                                                C30_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON },
        { CM1_SOUND_NONE,                                                C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU },
        { C23_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON,                C31_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU } };
unsigned int16_t G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton[3] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C09_WEAPON_FALCHION,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C30_ARMOUR_WOODEN_SHIELD, 0 };
unsigned int16_t G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem[2] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C24_WEAPON_STONE_CLUB, 0 };
unsigned int16_t G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman[2] = {
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C23_WEAPON_CLUB, 0 };
unsigned int16_t G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight[7] = {
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C41_ARMOUR_FOOT_PLATE,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C40_ARMOUR_LEG_PLATE,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C39_ARMOUR_TORSO_PLATE,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C10_WEAPON_SWORD,
        C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + C38_ARMOUR_ARMET,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C10_WEAPON_SWORD, 0 };
unsigned int16_t G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile[5] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C25_JUNK_BOULDER,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C25_JUNK_BOULDER | MASK0x8000_RANDOM_DROP,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C30_WEAPON_ROCK | MASK0x8000_RANDOM_DROP,
        C023_OBJECT_INFO_INDEX_FIRST_WEAPON + C30_WEAPON_ROCK | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound[3] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C35_JUNK_DRUMSTICK_SHANK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C35_JUNK_DRUMSTICK_SHANK | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0251_aui_Graphic559_FixedPossessionsCreature06Screamer[3] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C33_JUNK_SCREAMER_SLICE,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C33_JUNK_SCREAMER_SLICE | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm[4] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND | MASK0x8000_RANDOM_DROP,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C34_JUNK_WORM_ROUND | MASK0x8000_RANDOM_DROP, 0 };
unsigned int16_t G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon[11] = {
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK | MASK0x8000_RANDOM_DROP,
        C127_OBJECT_INFO_INDEX_FIRST_JUNK + C36_JUNK_DRAGON_STEAK | MASK0x8000_RANDOM_DROP, 0 };
#endif
#ifdef MEDIA492_F20E_F20J_P20JA_P20JB_F31E_F31J
DOOR_INFO G0254_as_Graphic559_DoorInfo[4] = {
        /* { Attributes, Defense } Melee attacks can only destroy wooden doors because melee attacks are limited to 100 */
        { MASK0x0002_PROJECTILES_CAN_PASS_THROUGH | MASK0x0001_CREATURES_CAN_SEE_THROUGH, 110 },   /* Door type 0 Portcullis */
        { 0,                                                                               42 },   /* Door type 1 Wooden door */
        { 0,                                                                              230 },   /* Door type 2 Iron door */
        { MASK0x0004_ANIMATED | MASK0x0001_CREATURES_CAN_SEE_THROUGH,                     255 } }; /* Door type 3 Ra door */
char G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings[32][8] = {
        { 'x',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?',  0,  0,  0, 0, 0, 0, 0 }, */
        { 'y',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!',  0,  0,  0, 0, 0, 0, 0 }, */
        { 'T','H','E',' ', 0, 0, 0, 0 },
        { 'Y','O','U',' ', 0, 0, 0, 0 },
        { 'z',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '{',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '|',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '}',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '~',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { '',  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 },
        {   0,  0,  0,  0, 0, 0, 0, 0 } };
char G0256_aac_Graphic559_EscapeReplacementCharacters[32][2] = {
        { 'a', 0 },
        { 'b', 0 },
        { 'c', 0 },
        { 'd', 0 },
        { 'e', 0 },
        { 'f', 0 },
        { 'g', 0 },
        { 'h', 0 },
        { 'i', 0 },
        { 'j', 0 },
        { 'k', 0 },
        { 'l', 0 },
        { 'm', 0 },
        { 'n', 0 },
        { 'o', 0 },
        { 'p', 0 },
        { 'q', 0 },
        { 'r', 0 },
        { 's', 0 },
        { 't', 0 },
        { 'u', 0 },
        { 'v', 0 },
        { 'w', 0 },
        { 'x', 0 },
        { '0', 0 },
        { '1', 0 },
        { '2', 0 },
        { '3', 0 },
        { '4', 0 },
        { '5', 0 },
        { '6', 0 },
        { '7', 0 } };
char G0257_aac_Graphic559_InscriptionEscapeReplacementStrings[32][8] = {
        { 28,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 29,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 19,  7,  4, 26, 0, 0, 0, 0 },
        { 24, 14, 20, 26, 0, 0, 0, 0 },
        { 30,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 31,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 32,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 33,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 34,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        { 35,  0,  0,  0, 0, 0, 0, 0 }, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0,  0,  0,  0, 0, 0, 0, 0 }, */
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 },
        {  0,  0,  0,  0, 0, 0, 0, 0 } };
unsigned char G0258_auc_Graphic559_GroupDirections[4] = { 0x00, 0x55, 0xAA, 0xFF };
#endif
#ifdef MEDIA646_A31E_A35E_F31E
char* G2214_apc_CreatureNames[27] = {
        "GIANT SCORPION",
        "SLIME DEVIL",
        "GIGGLER",
        "GAZER",
        "HELL HOUND",
        "RUSTER",
        "SCREAMER",
        "ROCKPILE",
        "RIVE",
        "STONE GOLEM",
        "MUMMY",
        "BLACK FLAME",
        "SKELETON",
        "COUATL",
        "MON VEXIRK",
        "ARMOURED WORM",
        "ANT MAN",
        "MUNCHER",
        "DETH KNIGHT",
        "ZYTAZ",
        "WATER ELEMENTAL",
        "GREATER OITU",
        "VIPER DEMON",
        "LORD CHAOS",
        "RED DRAGON",
        "LORD ORDER",
        "GREY LORD" };
#endif
#ifdef MEDIA689_F31J_X31J_P31J
char* G2214_apc_CreatureNames[27] = {
        "\x1B""GIANT\n""\x1B""SCORPION",
        "\x1B""SLIME\n""\x1B""DEVIL",
        "\x1B""GIGGLER",
        "\x1B""GAZER",
        "\x1B""HELL\n""\x1B""HOUND",
        "\x1B""RUSTER",
        "\x1B""SCREAMER",
        "\x1B""ROCKPILE",
        "\x1B""RIVE",
        "\x1B""STONE\n""\x1B""GOLEM",
        "\x1B""MUMMY",
        "\x1B""BLACK\n""\x1B""FLAME",
        "\x1B""SKELETON",
        "\x1B""COUATL",
        "\x1B""MON VEXIRK",
        "\x1B""ARMOURED\n""\x1B""WORM",
        "\x1B""ANT MAN",
        "\x1B""MUNCHER",
        "\x1B""DETH\n""\x1B""KNIGHT",
        "\x1B""ZYTAZ",
        "\x1B""WATER\n""\x1B""ELEMENTAL",
        "\x1B""GREATER\n""\x1B""OITU",
        "\x1B""VIPER\n""\x1B""DEMON",
        "\x1B""LORD CHAOS",
        "\x1B""RED DRAGON",
        "\x1B""LORD ORDER",
        "\x1B""GREY LORD" };
#endif
#ifdef MEDIA658_A31M_A33M_A35M
int16_t G3047_ai_CreatureNames[27] = {
        108,
        109,
        110,
        111,
        112,
        113,
        114,
        115,
        116,
        117,
        118,
        119,
        120,
        121,
        122,
        123,
        124,
        125,
        126,
        127,
        128,
        129,
        130,
        131,
        132,
        133,
        134 };
#endif
unsigned int16_t* G0260_pui_DungeonTextData;
unsigned char G0261_auc_CurrentMapWallOrnamentIndices[16];
unsigned char G0262_auc_CurrentMapFloorOrnamentIndices[16]; /* Last byte is not used */
unsigned char G0263_auc_CurrentMapDoorOrnamentIndices[17]; /* Last two bytes are not used */
unsigned char* G0264_puc_CurrentMapAllowedCreatureTypes;
int16_t G0265_i_CurrentMapInscriptionWallOrnamentIndex;
int16_t G0266_i_CurrentMapViAltarWallOrnamentIndex;
int16_t G0267_ai_CurrentMapAlcoveOrnamentIndices[C003_ALCOVE_ORNAMENT_COUNT];
int16_t G0268_ai_CurrentMapFountainOrnamentIndices[C001_FOUNTAIN_ORNAMENT_COUNT];
MAP* G0269_ps_CurrentMap;
unsigned int16_t* G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount; /* Pointer to value in G0280_pui_DungeonColumnsCumulativeSquareThingCount for the first column of the current map */
unsigned char** G0271_ppuc_CurrentMapData;
int16_t G0272_i_CurrentMapIndex = CM1_MAP_INDEX_NONE;
int16_t G0273_i_CurrentMapWidth;
int16_t G0274_i_CurrentMapHeight;
DOOR_INFO G0275_as_CurrentMapDoorInfo[2];
unsigned char* G0276_puc_DungeonRawMapData;
MAP* G0277_ps_DungeonMaps;
DUNGEON_HEADER* G0278_ps_DungeonHeader;
unsigned char*** G0279_pppuc_DungeonMapData;
unsigned int16_t* G0280_pui_DungeonColumnsCumulativeSquareThingCount; /* For each column of each map in the dungeon, cumulative count of things in G0283_pT_SquareFirstThings present in preceding columns */
unsigned int16_t* G0281_pui_DungeonMapsFirstColumnIndex;
unsigned int16_t G0282_ui_DungeonColumnCount;
THING* G0283_pT_SquareFirstThings;
unsigned char* G0284_apuc_ThingData[16];
int16_t G0285_i_SquareAheadElement;
BOOLEAN G0286_B_FacingAlcove;
BOOLEAN G0287_B_FacingViAltar;
BOOLEAN G0288_B_FacingFountain;
int16_t G0289_i_DungeonView_ChampionPortraitOrdinal;
THING G0290_T_DungeonView_InscriptionThing;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
unsigned char G0291_aauc_DungeonViewClickableBoxes[6][4]; /* Four boxes for objects on top of piles on the floor, one box for object on top of pile in alcove and one box for a door button or a wall ornament */
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t G2210_aai_XYZ_DungeonViewClickable[6][4]; /* Replaces G0291_aauc_DungeonViewClickableBoxes. Four zones for objects on top of piles on the floor, one zone for object on top of pile in alcove and one zone for a door button or a wall ornament */
#endif
THING G0292_aT_PileTopObject[5];
#ifdef MEDIA146_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J
#ifndef NOCOPYPROTECTION
int16_t G0293_ai_FuzzyBits_CPSE[32]; /* Unused in P20JA */
#endif
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
#ifndef NOCOPYPROTECTION
char G0293_ai_FuzzyBits_CPSE[345];
#endif
#endif


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

BOOLEAN F0139_DUNGEON_IsCreatureAllowedOnMap(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0234_T_Thing, P0235_ui_MapIndex)
#endif
THING            P0234_T_Thing     SEPARATOR
unsigned int16_t P0235_ui_MapIndex FINAL_SEPARATOR
{
        REGISTER unsigned char* L0236_puc_Multiple;
#define AL0236_puc_Group               L0236_puc_Multiple
#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple
        REGISTER MAP* L0237_ps_Map;
        REGISTER int16_t L0234_i_Counter;
        REGISTER unsigned int16_t L0235_ui_CreatureType;


#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        L0235_ui_CreatureType = ((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0234_T_Thing)].Type;
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        AL0236_puc_Group = F0156_DUNGEON_GetThingData(P0234_T_Thing);
        L0235_ui_CreatureType = ((GROUP*)AL0236_puc_Group)->Type;
#endif
        L0237_ps_Map = &G0277_ps_DungeonMaps[P0235_ui_MapIndex];
        AL0236_puc_AllowedCreatureType = G0279_pppuc_DungeonMapData[P0235_ui_MapIndex][L0237_ps_Map->A.Width] + L0237_ps_Map->A.Height + 1;
        for (L0234_i_Counter = L0237_ps_Map->C.CreatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) {
                if (*AL0236_puc_AllowedCreatureType++ == L0235_ui_CreatureType) {
                        return C1_TRUE;
                }
        }
        return C0_FALSE;
}

unsigned int16_t F0140_DUNGEON_GetObjectWeight(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0236_T_Thing)
#endif
REGISTER THING P0236_T_Thing FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned int16_t L0239_ui_Weight;
#endif
        REGISTER JUNK* L0238_ps_Junk;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0239_ui_Weight;
#endif


        if (P0236_T_Thing == C0xFFFF_THING_NONE) {
                return 0;
        }
        L0238_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(P0236_T_Thing);
        switch M012_TYPE(P0236_T_Thing) {
                case C05_THING_TYPE_WEAPON:
                        L0239_ui_Weight = G0238_as_Graphic559_WeaponInfo[((WEAPON*)L0238_ps_Junk)->Type].Weight;
                        break;
                case C06_THING_TYPE_ARMOUR:
                        L0239_ui_Weight = G0239_as_Graphic559_ArmourInfo[((ARMOUR*)L0238_ps_Junk)->Type].Weight;
                        break;
                case C10_THING_TYPE_JUNK:
                        L0239_ui_Weight = G0241_auc_Graphic559_JunkInfo[L0238_ps_Junk->Type];
                        if (L0238_ps_Junk->Type == C01_JUNK_WATERSKIN) {
                               L0239_ui_Weight += L0238_ps_Junk->ChargeCount << 1;
                        }
                        break;
                case C09_THING_TYPE_CONTAINER:
                        L0239_ui_Weight = 50;
                        P0236_T_Thing = ((CONTAINER*)L0238_ps_Junk)->Slot;
                        while (P0236_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                                L0239_ui_Weight += F0140_DUNGEON_GetObjectWeight(P0236_T_Thing);
                                P0236_T_Thing = F0159_DUNGEON_GetNextThing(P0236_T_Thing);
                        }
                        break;
                case C08_THING_TYPE_POTION:
                        if (((POTION*)L0238_ps_Junk)->Type == C20_POTION_EMPTY_FLASK) {
                                L0239_ui_Weight = 1;
                        } else {
                                L0239_ui_Weight = 3;
                        }
                        break;
                case C07_THING_TYPE_SCROLL:
                        L0239_ui_Weight = 1;
                        break;
        }
        return L0239_ui_Weight;
}

int16_t F0141_DUNGEON_GetObjectInfoIndex(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0237_T_Thing)
#endif
THING P0237_T_Thing FINAL_SEPARATOR
{
        REGISTER GENERIC* L0240_ps_Generic;


        L0240_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0237_T_Thing);
        switch M012_TYPE(P0237_T_Thing) {
                case C07_THING_TYPE_SCROLL:
                        return C000_OBJECT_INFO_INDEX_FIRST_SCROLL;
                case C09_THING_TYPE_CONTAINER:
                        return C001_OBJECT_INFO_INDEX_FIRST_CONTAINER + ((CONTAINER*)L0240_ps_Generic)->Type;
                case C10_THING_TYPE_JUNK:
                        return C127_OBJECT_INFO_INDEX_FIRST_JUNK + ((JUNK*)L0240_ps_Generic)->Type;
                case C05_THING_TYPE_WEAPON:
                        return C023_OBJECT_INFO_INDEX_FIRST_WEAPON + ((WEAPON*)L0240_ps_Generic)->Type;
                case C06_THING_TYPE_ARMOUR:
                        return C069_OBJECT_INFO_INDEX_FIRST_ARMOUR + ((ARMOUR*)L0240_ps_Generic)->Type;
                case C08_THING_TYPE_POTION:
                        return C002_OBJECT_INFO_INDEX_FIRST_POTION + ((POTION*)L0240_ps_Generic)->Type;
                default:
                        return -1;
        }
}

/* Returns a negative value (PROJECTIL_ASPECT ordinal) or positive value (OBJECT_ASPECT index) */
int16_t F0142_DUNGEON_GetProjectileAspect(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0238_T_Thing)
#endif
REGISTER THING P0238_T_Thing FINAL_SEPARATOR
{
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        REGISTER WEAPON_INFO* L0243_ps_WeaponInfo;
#endif
        REGISTER int16_t L0241_i_ThingType;
        REGISTER int16_t L0242_i_ProjectileAspectOrdinal;


        if ((L0241_i_ThingType = M012_TYPE(P0238_T_Thing)) == C15_THING_TYPE_EXPLOSION) {
                if (P0238_T_Thing == C0xFF80_THING_EXPLOSION_FIREBALL) {
                        return -M000_INDEX_TO_ORDINAL(C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL);
                }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                else {
#endif
                        if (P0238_T_Thing == C0xFF81_THING_EXPLOSION_SLIME) {
                                return -M000_INDEX_TO_ORDINAL(C12_PROJECTILE_ASPECT_EXPLOSION_SLIME);
                        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                        else {
#endif
                                if (P0238_T_Thing == C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT) {
                                        return -M000_INDEX_TO_ORDINAL(C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT);
                                }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                                else {
#endif
                                        if ((P0238_T_Thing == C0xFF86_THING_EXPLOSION_POISON_BOLT) || (P0238_T_Thing == C0xFF87_THING_EXPLOSION_POISON_CLOUD)) {
                                                return -M000_INDEX_TO_ORDINAL(C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD);
                                        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                                        else {
#endif
                                                return -M000_INDEX_TO_ORDINAL(C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT);
#ifdef MEDIA365_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
                                        }
                                }
                        }
                }
#endif
        } else {
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                if ((L0241_i_ThingType == C05_THING_TYPE_WEAPON) && (L0242_i_ProjectileAspectOrdinal = M066_PROJECTILE_ASPECT_ORDINAL(G0238_as_Graphic559_WeaponInfo[((WEAPON*)G0284_apuc_ThingData[C05_THING_TYPE_WEAPON])[M013_INDEX(P0238_T_Thing)].Type].Attributes))) {
                        return -L0242_i_ProjectileAspectOrdinal;
                }
                return G0237_as_Graphic559_ObjectInfo[F0141_DUNGEON_GetObjectInfoIndex(P0238_T_Thing)].ObjectAspectIndex;
        }
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                if (L0241_i_ThingType == C05_THING_TYPE_WEAPON) {
                        L0243_ps_WeaponInfo = F0158_DUNGEON_GetWeaponInfo(P0238_T_Thing);
                        if (L0242_i_ProjectileAspectOrdinal = M066_PROJECTILE_ASPECT_ORDINAL(L0243_ps_WeaponInfo->Attributes)) {
                                return -L0242_i_ProjectileAspectOrdinal;
                        }
                }
        }
        return G0237_as_Graphic559_ObjectInfo[F0141_DUNGEON_GetObjectInfoIndex(P0238_T_Thing)].ObjectAspectIndex;
#endif
}

unsigned int16_t F0143_DUNGEON_GetArmourDefense(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0239_ps_ArmourInfo, P0240_B_UseSharpDefense)
#endif
REGISTER ARMOUR_INFO* P0239_ps_ArmourInfo     SEPARATOR
BOOLEAN               P0240_B_UseSharpDefense FINAL_SEPARATOR
{
        REGISTER unsigned int16_t L0244_ui_Defense;


        L0244_ui_Defense = P0239_ps_ArmourInfo->Defense;
        if (P0240_B_UseSharpDefense) {
                L0244_ui_Defense = F0030_MAIN_GetScaledProduct(L0244_ui_Defense, 3, M007_GET(P0239_ps_ArmourInfo->Attributes, MASK0x0007_SHARP_DEFENSE) + 4);
        }
        return L0244_ui_Defense;
}

unsigned int16_t F0144_DUNGEON_GetCreatureAttributes(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0241_T_Thing)
#endif
THING P0241_T_Thing FINAL_SEPARATOR
{
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        return G0243_as_Graphic559_CreatureInfo[((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0241_T_Thing)].Type].Attributes;
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        GROUP* L0245_ps_Group = (GROUP*)F0156_DUNGEON_GetThingData(P0241_T_Thing);


        return G0243_as_Graphic559_CreatureInfo[L0245_ps_Group->Type].Attributes;
#endif
}

unsigned int16_t F0145_DUNGEON_GetGroupCells(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0242_ps_Group, P0243_ui_MapIndex)
#endif
GROUP*           P0242_ps_Group    SEPARATOR
unsigned int16_t P0243_ui_MapIndex FINAL_SEPARATOR
{
        REGISTER unsigned char L0246_uc_Cells;


        L0246_uc_Cells = P0242_ps_Group->Cells;
        if (P0243_ui_MapIndex == G0309_i_PartyMapIndex) {
                L0246_uc_Cells = G0375_ps_ActiveGroups[L0246_uc_Cells].Cells;
        }
        return L0246_uc_Cells;
}

void F0146_DUNGEON_SetGroupCells(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0244_ps_Group, P0245_ui_Cells, P0246_ui_MapIndex)
#endif
GROUP*           P0244_ps_Group    SEPARATOR
unsigned int16_t P0245_ui_Cells    SEPARATOR
unsigned int16_t P0246_ui_MapIndex FINAL_SEPARATOR
{
        if (P0246_ui_MapIndex == G0309_i_PartyMapIndex) {
                G0375_ps_ActiveGroups[P0244_ps_Group->ActiveGroupIndex].Cells = P0245_ui_Cells;
        } else {
                P0244_ps_Group->Cells = P0245_ui_Cells;
        }
}

unsigned int16_t F0147_DUNGEON_GetGroupDirections(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0247_ps_Group, P0248_ui_MapIndex)
#endif
GROUP*           P0247_ps_Group    SEPARATOR
unsigned int16_t P0248_ui_MapIndex FINAL_SEPARATOR
{
        if (P0248_ui_MapIndex == G0309_i_PartyMapIndex) {
                return G0375_ps_ActiveGroups[P0247_ps_Group->ActiveGroupIndex].Directions;
        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
        else {
#endif
                return G0258_auc_Graphic559_GroupDirections[P0247_ps_Group->Direction];
#ifdef MEDIA365_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
        }
#endif
}

void F0148_DUNGEON_SetGroupDirections(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0249_ps_Group, P0250_ui_Directions, P0251_ui_MapIndex)
#endif
GROUP*           P0249_ps_Group      SEPARATOR
unsigned int16_t P0250_ui_Directions SEPARATOR
unsigned int16_t P0251_ui_MapIndex   FINAL_SEPARATOR
{
        if (P0251_ui_MapIndex == G0309_i_PartyMapIndex) {
                G0375_ps_ActiveGroups[P0249_ps_Group->ActiveGroupIndex].Directions = P0250_ui_Directions;
        } else {
                P0249_ps_Group->Direction = M021_NORMALIZE(P0250_ui_Directions);
        }
}

BOOLEAN F0149_DUNGEON_IsWallOrnamentAnAlcove(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0252_i_WallOrnamentIndex)
#endif
int16_t P0252_i_WallOrnamentIndex FINAL_SEPARATOR
{
        REGISTER int16_t L0247_i_Counter;


        if (P0252_i_WallOrnamentIndex >= 0) {
                for (L0247_i_Counter = 0; L0247_i_Counter < C003_ALCOVE_ORNAMENT_COUNT; L0247_i_Counter++) {
                        if (G0267_ai_CurrentMapAlcoveOrnamentIndices[L0247_i_Counter] == P0252_i_WallOrnamentIndex) {
                                return C1_TRUE;
                        }
                }
        }
        return C0_FALSE;
}

#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN F0601_IsWallOrnamentAFountain(
int16_t P2002_i_WallOrnamentIndex FINAL_SEPARATOR
{
        REGISTER int16_t L0247_i_Counter;


        if (P2002_i_WallOrnamentIndex >= 0) {
                for (L0247_i_Counter = 0; L0247_i_Counter < C001_FOUNTAIN_ORNAMENT_COUNT; L0247_i_Counter++) {
                        if (G0268_ai_CurrentMapFountainOrnamentIndices[L0247_i_Counter] == P2002_i_WallOrnamentIndex) {
                                return C1_TRUE;
                        }
                }
        }
        return C0_FALSE;
}
#endif

#ifdef MEDIA423_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
#include "COPYPRO5.C"
#endif

void F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0253_i_Direction, P0254_i_StepsForwardCount, P0255_i_StepsRightCount, P0256_pi_MapX, P0257_pi_MapY)
#endif
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
REGISTER int16_t  P0253_i_Direction         SEPARATOR
REGISTER int16_t  P0254_i_StepsForwardCount SEPARATOR
REGISTER int16_t  P0255_i_StepsRightCount   SEPARATOR
#endif
#ifdef MEDIA331_S20E_S21E_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
int16_t           P0253_i_Direction         SEPARATOR
int16_t           P0254_i_StepsForwardCount SEPARATOR
int16_t           P0255_i_StepsRightCount   SEPARATOR
#endif
REGISTER int16_t* P0256_pi_MapX             SEPARATOR
REGISTER int16_t* P0257_pi_MapY             FINAL_SEPARATOR
{
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
        *P0256_pi_MapX += G0233_ai_Graphic559_DirectionToStepEastCount[P0253_i_Direction] * P0254_i_StepsForwardCount, *P0257_pi_MapY += G0234_ai_Graphic559_DirectionToStepNorthCount[P0253_i_Direction] * P0254_i_StepsForwardCount;
        P0253_i_Direction += 1, P0253_i_Direction &= 3; /* Simulate turning right */
        *P0256_pi_MapX += G0233_ai_Graphic559_DirectionToStepEastCount[P0253_i_Direction] * P0255_i_StepsRightCount, *P0257_pi_MapY += G0234_ai_Graphic559_DirectionToStepNorthCount[P0253_i_Direction] * P0255_i_StepsRightCount;
#endif
#ifdef MEDIA331_S20E_S21E_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
        asm {
#ifdef MEDIA265_S20E_S21E
                lea     G0233_ai_Graphic559_DirectionToStepEastCount(A4),A0
                lea     G0234_ai_Graphic559_DirectionToStepNorthCount(A4),A1
#endif
#ifdef MEDIA613_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                lea     G0233_ai_Graphic559_DirectionToStepEastCount(A5),A0
                lea     G0234_ai_Graphic559_DirectionToStepNorthCount(A5),A1
#endif
                move.w  P0253_i_Direction(A6),D0
                add.w   D0,D0
                move.w  P0254_i_StepsForwardCount(A6),D1
                move.w  D1,D2
                muls    0(A0,D0.w),D1
                add.w   D1,(P0256_pi_MapX)               /* Update P0256_pi_MapX with G0233_ai_Graphic559_DirectionToStepEastCount value associated to P0254_i_StepsForwardCount */
                muls    0(A1,D0.w),D2
                add.w   D2,(P0257_pi_MapY)               /* Update P0257_pi_MapY with G0234_ai_Graphic559_DirectionToStepNorthCount value associated to P0254_i_StepsForwardCount */
                addq.w  #2,D0                           /* Simulate turning right */
                andi.w  #7,D0
                move.w  P0255_i_StepsRightCount(A6),D1
                move.w  D1,D2
                muls    0(A0,D0.w),D1
                add.w   D1,(P0256_pi_MapX)               /* Update P0256_pi_MapX with G0233_ai_Graphic559_DirectionToStepEastCount value associated to P0255_i_StepsRightCount */
                muls    0(A1,D0.w),D2
                add.w   D2,(P0257_pi_MapY)               /* Update P0257_pi_MapY with G0234_ai_Graphic559_DirectionToStepNorthCount value associated to P0255_i_StepsRightCount */
        }
#endif
}

unsigned char F0151_DUNGEON_GetSquare(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0258_i_MapX, P0259_i_MapY)
#endif
REGISTER int16_t P0258_i_MapX SEPARATOR
REGISTER int16_t P0259_i_MapY FINAL_SEPARATOR
{
        REGISTER int16_t L0248_i_Multiple;
#define AL0248_B_IsMapXInBounds L0248_i_Multiple
#define AL0248_i_SquareType     L0248_i_Multiple
        REGISTER int16_t L0249_i_Multiple;
#define AL0249_B_IsMapYInBounds L0249_i_Multiple
#define AL0249_i_SquareType     L0249_i_Multiple


        AL0249_B_IsMapYInBounds = (P0259_i_MapY >= 0) && (P0259_i_MapY < G0274_i_CurrentMapHeight);
        if ((AL0248_B_IsMapXInBounds = (P0258_i_MapX >= 0) && (P0258_i_MapX < G0273_i_CurrentMapWidth)) && AL0249_B_IsMapYInBounds) {
                return G0271_ppuc_CurrentMapData[P0258_i_MapX][P0259_i_MapY];
        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
        else {
#endif
                /* If processing goes below this line then either P0258_i_MapX or P0259_i_MapY is out of the map bounds and the returned square type will be C00_ELEMENT_WALL. The use of uninitialized variables in conditions does not have any visible consequence */
                if (AL0249_B_IsMapYInBounds) {
                        if (((P0258_i_MapX == -1) && ((AL0249_i_SquareType = M034_SQUARE_TYPE(G0271_ppuc_CurrentMapData[0][P0259_i_MapY])) == C01_ELEMENT_CORRIDOR)) || (AL0249_i_SquareType == C02_ELEMENT_PIT)) { /* BUG0_01 Use of uninitialized variable AL0249_i_SquareType in comparison (AL0249_i_SquareType == C02_ELEMENT_PIT) if P0258_i_MapX != -1. No consequence here as AL0249_i_SquareType = AL0249_B_IsMapYInBounds = 0 (C0_FALSE) or 1 (C1_TRUE) and thus cannot be equal to 2 (C02_ELEMENT_PIT) */
                                return M035_SQUARE(C00_ELEMENT_WALL, MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED);
                        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                        else {
#endif
                                if (((P0258_i_MapX == G0273_i_CurrentMapWidth) && ((AL0249_i_SquareType = M034_SQUARE_TYPE(G0271_ppuc_CurrentMapData[G0273_i_CurrentMapWidth - 1][P0259_i_MapY])) == C01_ELEMENT_CORRIDOR)) || (AL0249_i_SquareType == C02_ELEMENT_PIT)) { /* BUG0_01 Use of uninitialized variable AL0249_i_SquareType in comparison (AL0249_i_SquareType == C02_ELEMENT_PIT) if P0258_i_MapX != G0273_i_CurrentMapWidth. If P0258_i_MapX == -1 then AL0249_i_SquareType contains the square type from the previous test: no consequence here as AL0249_i_SquareType cannot be equal to 2 (C02_ELEMENT_PIT) otherwise the previous test would have succeeded and the function would have returned. If P0258_i_MapX != -1 then AL0249_i_SquareType = AL0249_B_IsMapYInBounds = 0 (C0_FALSE) or 1 (C1_TRUE): no consequence as it cannot be equal to 2 (C02_ELEMENT_PIT) */ /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE jmp */
                                        return M035_SQUARE(C00_ELEMENT_WALL, MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED);
                                }
#ifdef MEDIA365_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
                        }
#endif
                } else {
                        if (AL0248_B_IsMapXInBounds) {
                                if (((P0259_i_MapY == -1) && ((AL0248_i_SquareType = M034_SQUARE_TYPE(G0271_ppuc_CurrentMapData[P0258_i_MapX][0])) == C01_ELEMENT_CORRIDOR)) || (AL0248_i_SquareType == C02_ELEMENT_PIT)) { /* BUG0_01 Use of uninitialized variable AL0248_i_SquareType in comparison (AL0248_i_SquareType == C02_ELEMENT_PIT) if P0259_i_MapY != -1. If the value of register D5 (storing AL0248_i_SquareType) is 2 before the function call then the condition is true and if P0259_i_MapY == G0274_i_CurrentMapHeight then this can prevent a wall on the south border of the map to allow a random ornament on its north side. No consequence as the only case where this would have a consequence is in F0172_DUNGEON_SetSquareAspect where register D5 contains the same value as P0259_i_MapY so it is not possible to have both AL0248_i_SquareType == 2 and P0259_i_MapY == G0274_i_CurrentMapHeight */
                                        return M035_SQUARE(C00_ELEMENT_WALL, MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED);
                                }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                                else {
#endif
                                        if (((P0259_i_MapY == G0274_i_CurrentMapHeight) && ((AL0248_i_SquareType = M034_SQUARE_TYPE(G0271_ppuc_CurrentMapData[P0258_i_MapX][G0274_i_CurrentMapHeight - 1])) == C01_ELEMENT_CORRIDOR)) || (AL0248_i_SquareType == C02_ELEMENT_PIT)) { /* BUG0_01 Use of uninitialized variable AL0248_i_SquareType in comparison (AL0248_i_SquareType == C02_ELEMENT_PIT) if P0259_i_MapY != G0274_i_CurrentMapHeight. If P0259_i_MapY == -1 then AL0248_i_SquareType contains the square type from the previous test: no consequence here as AL0248_i_SquareType cannot be equal to 2 (C02_ELEMENT_PIT) otherwise the previous test would have succeeded and the function would have returned. If P0259_i_MapY != -1 then AL0248_i_SquareType contains the value of D5 before the function call which cannot be 2 (see previous condition) */
                                                return M035_SQUARE(C00_ELEMENT_WALL, MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED);
                                        }
#ifdef MEDIA365_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
                                }
#endif
                        }
                }
                return M035_SQUARE(C00_ELEMENT_WALL, 0);
#ifdef MEDIA365_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
        }
#endif
}

unsigned char F0152_DUNGEON_GetRelativeSquare(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0260_i_Direction, P0261_i_StepsForwardCount, P0262_i_StepsRightCount, P0263_i_MapX, P0264_i_MapY)
#endif
int16_t P0260_i_Direction         SEPARATOR
int16_t P0261_i_StepsForwardCount SEPARATOR
int16_t P0262_i_StepsRightCount   SEPARATOR
int16_t P0263_i_MapX              SEPARATOR
int16_t P0264_i_MapY              FINAL_SEPARATOR
{
        F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement(P0260_i_Direction, P0261_i_StepsForwardCount, P0262_i_StepsRightCount, &P0263_i_MapX, &P0264_i_MapY);
        return F0151_DUNGEON_GetSquare(P0263_i_MapX, P0264_i_MapY);
}

int16_t F0153_DUNGEON_GetRelativeSquareType(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0265_i_Direction, P0266_i_StepsForwardCount, P0267_i_StepsRightCount, P0268_i_MapX, P0269_i_MapY) /* Unused but present in DM PC and CSB PC-98 */
#endif
int16_t P0265_i_Direction         SEPARATOR
int16_t P0266_i_StepsForwardCount SEPARATOR
int16_t P0267_i_StepsRightCount   SEPARATOR
int16_t P0268_i_MapX              SEPARATOR
int16_t P0269_i_MapY              FINAL_SEPARATOR
{
        return M034_SQUARE_TYPE(F0152_DUNGEON_GetRelativeSquare(P0265_i_Direction, P0266_i_StepsForwardCount, P0267_i_StepsRightCount, P0268_i_MapX, P0269_i_MapY));
}

int16_t F0154_DUNGEON_GetLocationAfterLevelChange(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0270_i_MapIndex, P0271_i_LevelDelta, P0272_pi_MapX, P0273_pi_MapY)
#endif
int16_t  P0270_i_MapIndex   SEPARATOR
int16_t  P0271_i_LevelDelta SEPARATOR
int16_t* P0272_pi_MapX      SEPARATOR
int16_t* P0273_pi_MapY      FINAL_SEPARATOR
{
        REGISTER MAP* L0254_ps_Map;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0253_i_Offset;
#endif
        REGISTER int16_t L0250_i_NewMapX;
        REGISTER int16_t L0251_i_NewMapY;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0252_i_NewLevel;
        REGISTER int16_t L0253_i_Offset;
        int16_t L0255_i_TargetMapIndex;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0255_i_TargetMapIndex;
        REGISTER int16_t L0252_i_NewLevel;
#endif


        if (G0309_i_PartyMapIndex == C255_MAP_INDEX_ENTRANCE) {
                return CM1_MAP_INDEX_NONE;
        }
        L0254_ps_Map = G0277_ps_DungeonMaps + P0270_i_MapIndex;
        L0250_i_NewMapX = L0254_ps_Map->OffsetMapX + *P0272_pi_MapX;
        L0251_i_NewMapY = L0254_ps_Map->OffsetMapY + *P0273_pi_MapY;
        L0252_i_NewLevel = L0254_ps_Map->A.Level + P0271_i_LevelDelta;
#ifdef MEDIA178_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED /* CHANGE7_11_OPTIMIZATION Comma removed */
        for (L0255_i_TargetMapIndex = 0, L0254_ps_Map = G0277_ps_DungeonMaps; L0255_i_TargetMapIndex < G0278_ps_DungeonHeader->MapCount; L0255_i_TargetMapIndex++, L0254_ps_Map++) {
#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_11_OPTIMIZATION Comma removed */
        L0254_ps_Map = G0277_ps_DungeonMaps;
        for (L0255_i_TargetMapIndex = 0; L0255_i_TargetMapIndex < G0278_ps_DungeonHeader->MapCount; L0255_i_TargetMapIndex++) {
#endif
                if ((L0254_ps_Map->A.Level == L0252_i_NewLevel) && (L0250_i_NewMapX >= (L0253_i_Offset = L0254_ps_Map->OffsetMapX)) && (L0250_i_NewMapX <= (L0253_i_Offset + L0254_ps_Map->A.Width)) && (L0251_i_NewMapY >= (L0253_i_Offset = L0254_ps_Map->OffsetMapY)) && (L0251_i_NewMapY <= (L0253_i_Offset + L0254_ps_Map->A.Height))) {
                        *P0273_pi_MapY = L0251_i_NewMapY - L0253_i_Offset;
                        *P0272_pi_MapX = L0250_i_NewMapX - L0254_ps_Map->OffsetMapX;
                        return L0255_i_TargetMapIndex;
                }
#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_11_OPTIMIZATION Comma removed */
                L0254_ps_Map++;
#endif
        }
        return CM1_MAP_INDEX_NONE;
}

int16_t F0155_DUNGEON_GetStairsExitDirection(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0274_i_MapX, P0275_i_MapY)
#endif
REGISTER int16_t P0274_i_MapX SEPARATOR
REGISTER int16_t P0275_i_MapY FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0256_i_SquareType;
#endif
        REGISTER BOOLEAN L0257_B_NorthSouthOrientedStairs;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0256_i_SquareType;
#endif


        if (L0257_B_NorthSouthOrientedStairs = !M007_GET(F0151_DUNGEON_GetSquare(P0274_i_MapX, P0275_i_MapY), MASK0x0008_STAIRS_NORTH_SOUTH_ORIENTATION)) {
                P0274_i_MapX += G0233_ai_Graphic559_DirectionToStepEastCount[C1_DIRECTION_EAST], P0275_i_MapY += G0234_ai_Graphic559_DirectionToStepNorthCount[C1_DIRECTION_EAST];
        } else {
                P0274_i_MapX += G0233_ai_Graphic559_DirectionToStepEastCount[C0_DIRECTION_NORTH], P0275_i_MapY += G0234_ai_Graphic559_DirectionToStepNorthCount[C0_DIRECTION_NORTH];
        }
        return ((((L0256_i_SquareType = M034_SQUARE_TYPE(F0151_DUNGEON_GetSquare(P0274_i_MapX, P0275_i_MapY))) == C00_ELEMENT_WALL) || (L0256_i_SquareType == C03_ELEMENT_STAIRS)) << 1) + L0257_B_NorthSouthOrientedStairs;
}

unsigned char* F0156_DUNGEON_GetThingData(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0276_T_Thing)
#endif
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
REGISTER THING P0276_T_Thing FINAL_SEPARATOR
#endif
#ifdef MEDIA331_S20E_S21E_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
THING P0276_T_Thing FINAL_SEPARATOR
#endif
{
#ifdef MEDIA182_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
        return G0284_apuc_ThingData[M012_TYPE(P0276_T_Thing)] + (M013_INDEX(P0276_T_Thing) * G0235_auc_Graphic559_ThingDataByteCount[M012_TYPE(P0276_T_Thing)]);
#endif
#ifdef MEDIA265_S20E_S21E /* CHANGE7_16_OPTIMIZATION Source code converted from C language to assembly language for better performance and smaller machine code size */
        asm {
                move.w  P0276_T_Thing(A6),D3
                move.w  D3,D2
                andi.w  #0x03FF,D3                              /* Thing index */
                lsr.w   #2,D2
                lsr.w   #8,D2
                andi.w  #0x000F,D2                              /* Thing category */
                lea     G0235_auc_Graphic559_ThingDataByteCount(A4),A0
                moveq   #0,D0
                move.b  0(A0,D2.w),D0                           /* Thing data byte count */
                mulu.w  D3,D0
                lea     G0284_apuc_ThingData(A4),A0
                asl.w   #2,D2
                add.l   0(A0,D2.w),D0                           /* Address of thing data */
        }
#endif
#ifdef MEDIA613_X30J_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        asm {
                move.w  P0276_T_Thing(A6),D1
                move.w  D1,D2
                andi.w  #0x03FF,D1                              /* Thing index */
                lsr.w   #2,D2
                lsr.w   #8,D2
                moveq   #0x000F,D0
                and.w   D0,D2                                   /* Thing category */
                lea     G0235_auc_Graphic559_ThingDataByteCount(A5),A0
                move.b  0(A0,D2.w),D0                           /* Thing data byte count */
                mulu.w  D1,D0
                lea     G0284_apuc_ThingData(A5),A0
#ifdef MEDIA577_X30J
                asl.w   #2,D2
#endif
#ifdef MEDIA749_A36M_A31E_A31M_A33M_A35E_A35M_X31J
                add.w   D2,D2
                add.w   D2,D2
#endif
                add.l   0(A0,D2.w),D0                           /* Address of thing data */
        }
#endif
}

#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
unsigned char* F0157_DUNGEON_GetSquareFirstThingData(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0277_i_MapX, P0278_i_MapY)
#endif
int16_t P0277_i_MapX SEPARATOR
int16_t P0278_i_MapY FINAL_SEPARATOR
{
        return F0156_DUNGEON_GetThingData(F0161_DUNGEON_GetSquareFirstThing(P0277_i_MapX, P0278_i_MapY));
}

WEAPON_INFO* F0158_DUNGEON_GetWeaponInfo(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0279_T_Thing)
#endif
THING P0279_T_Thing FINAL_SEPARATOR
{
        WEAPON* L0258_ps_Weapon = (WEAPON*)F0156_DUNGEON_GetThingData(P0279_T_Thing);


        return &G0238_as_Graphic559_WeaponInfo[L0258_ps_Weapon->Type];
}
#endif

THING F0159_DUNGEON_GetNextThing(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0280_T_Thing)
#endif
THING P0280_T_Thing FINAL_SEPARATOR
{
#ifdef MEDIA036_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_F31E_F31J_P31J
        GENERIC* L0259_ps_Generic;


        L0259_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0280_T_Thing);
        return L0259_ps_Generic->Next;
#endif
#ifdef MEDIA749_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        asm {
                move.w  P0280_T_Thing(A6),D1
                move.w  D1,D2
                andi.w  #0x03FF,D1                              /* Thing index */
                lsr.w   #2,D2
                lsr.w   #8,D2
                moveq   #0x000F,D0
                and.w   D0,D2                                   /* Thing category */
                lea     G0235_auc_Graphic559_ThingDataByteCount(A5),A0
                move.b  0(A0,D2.w),D0                           /* Thing data byte count */
                mulu.w  D1,D0
                lea     G0284_apuc_ThingData(A5),A0
                add.w   d2,d2
                add.w   d2,d2
                add.l   0(A0,D2.w),D0                           /* Address of thing data */
                movea.l d0,a0
                move.w  (a0)+,d0
        }
#endif
}

STATICFUNCTION int16_t F0160_DUNGEON_GetSquareFirstThingIndex(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0281_i_MapX, P0282_i_MapY)
#endif
REGISTER int16_t P0281_i_MapX SEPARATOR
REGISTER int16_t P0282_i_MapY FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned char* L0262_puc_Square;
#endif
        REGISTER unsigned int16_t L0260_ui_ThingIndex;
        REGISTER int16_t L0261_i_MapY;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned char* L0262_puc_Square;
#endif


        L0262_puc_Square = G0271_ppuc_CurrentMapData[P0281_i_MapX];
        if (!((P0281_i_MapX >= 0) && (P0281_i_MapX < G0273_i_CurrentMapWidth)) || !((P0282_i_MapY >= 0) && (P0282_i_MapY < G0274_i_CurrentMapHeight)) || !M007_GET(L0262_puc_Square[P0282_i_MapY], MASK0x0010_THING_LIST_PRESENT)) {
                return -1;
        }
        L0261_i_MapY = 0;
        L0260_ui_ThingIndex = G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount[P0281_i_MapX];
        while (L0261_i_MapY++ != P0282_i_MapY) {
                if (M007_GET(*L0262_puc_Square++, MASK0x0010_THING_LIST_PRESENT)) {
                        L0260_ui_ThingIndex++;
                }
        }
        return L0260_ui_ThingIndex;
}

THING F0161_DUNGEON_GetSquareFirstThing(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0283_i_MapX, P0284_i_MapY)
#endif
int16_t P0283_i_MapX SEPARATOR
int16_t P0284_i_MapY FINAL_SEPARATOR
{
        int16_t L0263_i_SquareFirstThingIndex;


        if ((L0263_i_SquareFirstThingIndex = F0160_DUNGEON_GetSquareFirstThingIndex(P0283_i_MapX, P0284_i_MapY)) == -1) {
                return C0xFFFE_THING_ENDOFLIST;
        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
        else {
#endif
                return G0283_pT_SquareFirstThings[L0263_i_SquareFirstThingIndex];
#ifdef MEDIA365_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
        }
#endif
}

THING F0162_DUNGEON_GetSquareFirstObject(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0285_i_MapX, P0286_i_MapY)
#endif
int16_t P0285_i_MapX SEPARATOR
int16_t P0286_i_MapY FINAL_SEPARATOR
{
        REGISTER THING L0264_T_Thing;


        L0264_T_Thing = F0161_DUNGEON_GetSquareFirstThing(P0285_i_MapX, P0286_i_MapY);
        while ((L0264_T_Thing != C0xFFFE_THING_ENDOFLIST) && (M012_TYPE(L0264_T_Thing) < C04_THING_TYPE_GROUP)) {
                L0264_T_Thing = F0159_DUNGEON_GetNextThing(L0264_T_Thing);
        }
        return L0264_T_Thing;
}

void F0163_DUNGEON_LinkThingToList(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0287_T_ThingToLink, P0288_T_ThingInList, P0289_i_MapX, P0290_i_MapY)
#endif
THING            P0287_T_ThingToLink SEPARATOR /* This thing is linked at the end of the thing list and is made the last thing (It is not possible to link a list of things to another list) */
THING            P0288_T_ThingInList SEPARATOR /* Any thing currently in the list. The function searches for the last thing in the list before linking the new thing */
REGISTER int16_t P0289_i_MapX        SEPARATOR
REGISTER int16_t P0290_i_MapY        FINAL_SEPARATOR
{
        REGISTER THING* L0267_pT_Thing;
        REGISTER unsigned char* L0268_puc_Square;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER GENERIC* L0269_ps_Generic;
#endif
        REGISTER THING L0265_T_Thing;
        REGISTER unsigned int16_t L0266_ui_Multiple;
#define AL0266_ui_Column                L0266_ui_Multiple
#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        GENERIC* L0269_ps_Generic;
        unsigned int16_t L0270_ui_MapY;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0270_ui_MapY;
#endif


        if (P0287_T_ThingToLink == C0xFFFE_THING_ENDOFLIST)
                return;
        L0269_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0287_T_ThingToLink);
        L0269_ps_Generic->Next = C0xFFFE_THING_ENDOFLIST;
        /* If P0289_i_MapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */
        if (P0289_i_MapX >= 0) {
                L0268_puc_Square = &G0271_ppuc_CurrentMapData[P0289_i_MapX][P0290_i_MapY];
                if (M007_GET(*L0268_puc_Square, MASK0x0010_THING_LIST_PRESENT)) {
                        P0288_T_ThingInList = F0161_DUNGEON_GetSquareFirstThing(P0289_i_MapX, P0290_i_MapY);
                } else {
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        if (G0283_pT_SquareFirstThings[G0278_ps_DungeonHeader->SquareFirstThingCount - 1] != C0xFFFF_THING_NONE) {
                                F0019_MAIN_DisplayErrorAndStop(C72_ERROR_INVALID_SQUARE_THING_LIST);
                        }
#endif
                        M008_SET(*L0268_puc_Square, MASK0x0010_THING_LIST_PRESENT);
                        L0267_pT_Thing = G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + P0289_i_MapX + 1;
                        AL0266_ui_Column = G0282_ui_DungeonColumnCount - (G0281_pui_DungeonMapsFirstColumnIndex[G0272_i_CurrentMapIndex] + P0289_i_MapX) - 1;
                        while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */
                                ++(*L0267_pT_Thing++); /* Increment the cumulative first thing count */
                        }
                        L0270_ui_MapY = 0;
                        L0268_puc_Square -= P0290_i_MapY;
                        AL0266_ui_SquareFirstThingIndex = G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount[P0289_i_MapX];
                        while (L0270_ui_MapY++ != P0290_i_MapY) {
                                if (M007_GET(*L0268_puc_Square++, MASK0x0010_THING_LIST_PRESENT)) {
                                        AL0266_ui_SquareFirstThingIndex++;
                                }
                        }
                        L0267_pT_Thing = &G0283_pT_SquareFirstThings[AL0266_ui_SquareFirstThingIndex]; /* BUG0_08 Objects disappear in the dungeon and data is corrupted in memory. The game manages an array of limited size containing the first thing on each square where there is at least one thing. There is no check to stop adding things to this array when it is full and this causes data corruptions in memory. With the original Dungeon Master and Chaos Strikes back dungeons the array is large enough so that most players will not get into trouble, however it is still possible to fill it by placing one thing on as many squares as possible in the dungeon. The number of free slots to store first square things is 676 in DM for Atari ST 1.0a EN, 678 in DM for Atari ST 1.0b EN, 679 in DM for Atari ST 1.1 EN, 1.2 EN, 1.2 GE, 1.3a FR and 1.3b FR, 690 in CSB for Atari ST 2.0 EN and 2.1 EN (each dungeon contains a number of free slots and the game adds 300 more when loading the dungeon).
                        If all THING entries in G0283_pT_SquareFirstThings are already used then inserting an additional one will overwrite the word of data in memory that follows the buffer allocated for G0283_pT_SquareFirstThings. If inserting a THING at the end of a full G0283_pT_SquareFirstThings then AL0266_ui_SquareFirstThingIndex is out of bounds and the next call will corrupt memory because the specified size will be negative (= large high positive value) */
                        F0007_MAIN_CopyBytes(M772_CAST_PC(L0267_pT_Thing), M772_CAST_PC(L0267_pT_Thing + 1), M543_BYTE_COUNT_INT((G0278_ps_DungeonHeader->SquareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1) << 1));
                        *L0267_pT_Thing = P0287_T_ThingToLink;
                        return;
                }
        }
        L0265_T_Thing = F0159_DUNGEON_GetNextThing(P0288_T_ThingInList);
        while (L0265_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                L0265_T_Thing = F0159_DUNGEON_GetNextThing(P0288_T_ThingInList = L0265_T_Thing);
        }
        L0269_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0288_T_ThingInList);
        L0269_ps_Generic->Next = P0287_T_ThingToLink;
}

void F0164_DUNGEON_UnlinkThingFromList(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0291_T_ThingToUnlink, P0292_T_ThingInList, P0293_i_MapX, P0294_i_MapY)
#endif
REGISTER THING   P0291_T_ThingToUnlink SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
THING            P0292_T_ThingInList   SEPARATOR
int16_t          P0293_i_MapX          SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER THING   P0292_T_ThingInList   SEPARATOR
REGISTER int16_t P0293_i_MapX          SEPARATOR
#endif
int16_t          P0294_i_MapY          FINAL_SEPARATOR
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER GENERIC* L0274_ps_Generic;
#endif
        REGISTER THING* L0275_pui_Multiple;
#define AL0275_pT_Thing                      L0275_pui_Multiple
#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned int16_t L0271_ui_SquareFirstThingIndex;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER GENERIC* L0274_ps_Generic;
        REGISTER THING L0273_T_Thing;
#endif
        REGISTER unsigned int16_t L0272_ui_Multiple;
#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple
#define AL0272_ui_Column                L0272_ui_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER THING L0273_T_Thing;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0271_ui_SquareFirstThingIndex;
#endif


        if (P0291_T_ThingToUnlink == C0xFFFE_THING_ENDOFLIST) {
                return;
        }
        M009_CLEAR(P0291_T_ThingToUnlink, MASK0xC000_THING_CELL);
        if (P0293_i_MapX >= 0) {
                L0274_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0291_T_ThingToUnlink);
                AL0275_pT_Thing = &G0283_pT_SquareFirstThings[L0271_ui_SquareFirstThingIndex = F0160_DUNGEON_GetSquareFirstThingIndex(P0293_i_MapX, P0294_i_MapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. F0160_DUNGEON_GetSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */
                if ((L0274_ps_Generic->Next == C0xFFFE_THING_ENDOFLIST) && (M014_TYPE_AND_INDEX(*AL0275_pT_Thing) == P0291_T_ThingToUnlink)) { /* If the thing to unlink is the last thing on the square */
                        M009_CLEAR(G0271_ppuc_CurrentMapData[P0293_i_MapX][P0294_i_MapY], MASK0x0010_THING_LIST_PRESENT);
                        F0007_MAIN_CopyBytes(M772_CAST_PC(AL0275_pT_Thing + 1), M772_CAST_PC(AL0275_pT_Thing), M543_BYTE_COUNT_INT(((AL0272_ui_SquareFirstThingIndex = G0278_ps_DungeonHeader->SquareFirstThingCount - 1) - L0271_ui_SquareFirstThingIndex) << 1));
                        G0283_pT_SquareFirstThings[AL0272_ui_SquareFirstThingIndex] = C0xFFFF_THING_NONE;
                        AL0275_pui_CumulativeFirstThingCount = G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + P0293_i_MapX + 1;
                        AL0272_ui_Column = G0282_ui_DungeonColumnCount - (G0281_pui_DungeonMapsFirstColumnIndex[G0272_i_CurrentMapIndex] + P0293_i_MapX) - 1;
                        while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */
                                --(*AL0275_pui_CumulativeFirstThingCount++); /* Decrement the cumulative first thing count */
                        }
                        goto T0164011;
                }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                else {
#endif
                        if (M014_TYPE_AND_INDEX(*AL0275_pT_Thing) == P0291_T_ThingToUnlink) {
                                *AL0275_pT_Thing = L0274_ps_Generic->Next;
                                goto T0164011;
                        }
#ifdef MEDIA365_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
                }
#endif
                P0292_T_ThingInList = *AL0275_pT_Thing;
        }
        L0273_T_Thing = F0159_DUNGEON_GetNextThing(P0292_T_ThingInList);
        while (M014_TYPE_AND_INDEX(L0273_T_Thing) != P0291_T_ThingToUnlink) {
                if ((L0273_T_Thing == C0xFFFE_THING_ENDOFLIST) || (L0273_T_Thing == C0xFFFF_THING_NONE)) {
                        goto T0164011;
                }
                L0273_T_Thing = F0159_DUNGEON_GetNextThing(P0292_T_ThingInList = L0273_T_Thing);
        }
        L0274_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0292_T_ThingInList);
        L0274_ps_Generic->Next = F0159_DUNGEON_GetNextThing(L0273_T_Thing);
        L0274_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(P0291_T_ThingToUnlink);
        T0164011:
        L0274_ps_Generic->Next = C0xFFFE_THING_ENDOFLIST;
}

STATICFUNCTION THING F0165_DUNGEON_GetDiscardedThing(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0295_ui_ThingType)
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
unsigned int16_t          P0295_ui_ThingType FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER unsigned int16_t P0295_ui_ThingType FINAL_SEPARATOR
#endif
{
        REGISTER unsigned char* L0280_puc_Square;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER GENERIC* L0282_ps_Generic;
#endif
        REGISTER THING* L0281_pT_SquareFirstThing;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0279_ui_MapIndex;
        REGISTER THING L0278_T_Thing;
#endif
#ifdef MEDIA070_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
        REGISTER unsigned int16_t L0276_ui_MapX;
        REGISTER unsigned int16_t L0277_ui_MapY;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        REGISTER int16_t L0276_ui_MapX;
        REGISTER int16_t L0277_ui_MapY;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER THING L0278_T_Thing;
        REGISTER unsigned int16_t L0279_ui_MapIndex;
        GENERIC* L0282_ps_Generic;
        unsigned int16_t L0283_ui_DiscardThingMapIndex;
        int16_t L0284_i_CurrentMapIndex;
#endif
        unsigned int16_t L0285_ui_MapWidth;
        unsigned int16_t L0286_ui_MapHeight;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        unsigned int16_t L0283_ui_DiscardThingMapIndex;
        int16_t L0284_i_CurrentMapIndex;
#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_17_FIX */
        unsigned int16_t L0287_ui_ThingType;
#endif
        static unsigned char G0294_auc_LastDiscardedThingMapIndex[16];


        if (P0295_ui_ThingType == C15_THING_TYPE_EXPLOSION) {
                return C0xFFFF_THING_NONE;
        }
        L0284_i_CurrentMapIndex = G0272_i_CurrentMapIndex;
        if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[P0295_ui_ThingType]) == G0309_i_PartyMapIndex) && (++L0279_ui_MapIndex >= G0278_ps_DungeonHeader->MapCount)) {
                L0279_ui_MapIndex = 0;
        }
        L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex;
        for (;;) { /*_Infinite loop_*/
                L0285_ui_MapWidth = G0277_ps_DungeonMaps[L0279_ui_MapIndex].A.Width;
                L0286_ui_MapHeight = G0277_ps_DungeonMaps[L0279_ui_MapIndex].A.Height;
                L0280_puc_Square = G0279_pppuc_DungeonMapData[L0279_ui_MapIndex][0];
                L0281_pT_SquareFirstThing = &G0283_pT_SquareFirstThings[G0280_pui_DungeonColumnsCumulativeSquareThingCount[G0281_pui_DungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]];
                for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) {
                        for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) {
                                if (M007_GET(*L0280_puc_Square++, MASK0x0010_THING_LIST_PRESENT)) {
                                        L0278_T_Thing = *L0281_pT_SquareFirstThing++;
#ifdef MEDIA070_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
                                        if ((L0279_ui_MapIndex == G0309_i_PartyMapIndex) && ((L0276_ui_MapX - G0306_i_PartyMapX + 5) <= 10) && ((L0277_ui_MapY - G0307_i_PartyMapY + 5) <= 10)) /* If square is too close to the party */
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                                        if ((L0279_ui_MapIndex == G0309_i_PartyMapIndex) && ((unsigned int16_t)(L0276_ui_MapX - G0306_i_PartyMapX + 5) <= 10) && ((unsigned int16_t)(L0277_ui_MapY - G0307_i_PartyMapY + 5) <= 10)) /* If square is too close to the party */
#endif
                                                goto T0165029;
                                        do {
#ifdef MEDIA006_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB /* CHANGE7_17_FIX */
                                                if (M012_TYPE(L0278_T_Thing) == P0295_ui_ThingType) { /* BUG0_09 The game may trigger a sensor and cause an undesired effect when discarding a thing from a square. When the game needs to create a new thing but has run out of storage for the corresponding thing type (for example when creating a Screamer Slice after a Screamer is killed) it will try to remove another thing of the same type elsewhere in the dungeon (except things that are explicitly marked as non discardable). If the square where the thing is removed contains a sensor, it may be triggered and cause an undesired effect. For example, discarding a Screamer Slice placed by the player on a pressure plate on the floor may close a door or open a pit which may block the party */
#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_17_FIX Squares with enabled sensors are ignored when searching for a thing to discard */
                                                if ((L0287_ui_ThingType = M012_TYPE(L0278_T_Thing)) == C03_THING_TYPE_SENSOR) {
                                                        L0282_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L0278_T_Thing);
                                                        if (M039_TYPE((SENSOR*)L0282_ps_Generic)) /* If sensor is not disabled */
                                                                break;
                                                } else {
                                                        if (L0287_ui_ThingType == P0295_ui_ThingType) {
#endif
                                                                L0282_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L0278_T_Thing);
                                                                switch (P0295_ui_ThingType) {
                                                                        case C04_THING_TYPE_GROUP:
                                                                                if ((((GROUP*)L0282_ps_Generic)->DoNotDiscard)
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                                                   || (((GROUP*)L0282_ps_Generic)->Slot != C0xFFFE_THING_ENDOFLIST)
#endif
                                                                                   )
                                                                                        continue;
                                                                        case C14_THING_TYPE_PROJECTILE:
                                                                                F0173_DUNGEON_SetCurrentMap(L0279_ui_MapIndex);
                                                                                if (P0295_ui_ThingType == C04_THING_TYPE_GROUP) {
                                                                                        F0188_GROUP_DropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, CM1_MODE_DO_NOT_PLAY_SOUND);
                                                                                        F0189_GROUP_Delete(L0276_ui_MapX, L0277_ui_MapY);
                                                                                } else {
                                                                                        F0214_PROJECTILE_DeleteEvent(L0278_T_Thing);
                                                                                        F0164_DUNGEON_UnlinkThingFromList(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY);
#ifdef PC_FIX_CODE_SIZE
L0278_T_Thing++;
L0278_T_Thing++;
L0278_T_Thing++;
#endif
                                                                                        F0215_PROJECTILE_Delete(L0278_T_Thing, NULL, L0276_ui_MapX, L0277_ui_MapY); /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE opt */
                                                                                }
                                                                                break;
                                                                        case C06_THING_TYPE_ARMOUR:
                                                                                if (((ARMOUR*)L0282_ps_Generic)->DoNotDiscard)
                                                                                        continue;
                                                                                goto T0165026;
                                                                        case C05_THING_TYPE_WEAPON:
                                                                                if (((WEAPON*)L0282_ps_Generic)->DoNotDiscard)
                                                                                        continue;
                                                                                goto T0165026;
                                                                        case C10_THING_TYPE_JUNK:
                                                                                if (((JUNK*)L0282_ps_Generic)->DoNotDiscard)
                                                                                        continue;
                                                                                goto T0165026;
                                                                        case C08_THING_TYPE_POTION:
                                                                                if (((POTION*)L0282_ps_Generic)->DoNotDiscard)
                                                                                        continue;
                                                                                T0165026:
                                                                                F0173_DUNGEON_SetCurrentMap(L0279_ui_MapIndex);
                                                                                F0267_MOVE_GetMoveResult_CPSCE(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, CM1_MAPX_NOT_ON_A_SQUARE, 0);
                                                                }
                                                                F0173_DUNGEON_SetCurrentMap(L0284_i_CurrentMapIndex);
                                                                G0294_auc_LastDiscardedThingMapIndex[P0295_ui_ThingType] = L0279_ui_MapIndex;
                                                                return M014_TYPE_AND_INDEX(L0278_T_Thing);
                                                        }
#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_17_FIX */
                                                }
#endif
                                        } while ((L0278_T_Thing = F0159_DUNGEON_GetNextThing(L0278_T_Thing)) != C0xFFFE_THING_ENDOFLIST);
                                        T0165029: ;
                                }
                        }
                }
                if ((L0279_ui_MapIndex == G0309_i_PartyMapIndex) || (G0278_ps_DungeonHeader->MapCount <= 1)) {
                        G0294_auc_LastDiscardedThingMapIndex[P0295_ui_ThingType] = L0279_ui_MapIndex;
                        return C0xFFFF_THING_NONE;
                }
                do {
                        if (++L0279_ui_MapIndex >= G0278_ps_DungeonHeader->MapCount) {
                                L0279_ui_MapIndex = 0;
                        }
                } while (L0279_ui_MapIndex == G0309_i_PartyMapIndex);
                if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) {
                        L0279_ui_MapIndex = G0309_i_PartyMapIndex;
                }
        }
}

THING F0166_DUNGEON_GetUnusedThing(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0296_ui_ThingType)
#endif
REGISTER unsigned int16_t P0296_ui_ThingType FINAL_SEPARATOR
{
        REGISTER GENERIC* L0291_ps_Generic;
        REGISTER int16_t L0288_i_ThingIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        register int16_t L0289_i_ThingDataByteCount;
#endif
        REGISTER int16_t L0290_i_ThingCount;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        THING L0292_T_Thing;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0289_i_ThingDataByteCount;
        REGISTER THING L0292_T_Thing;
#endif


#ifdef MEDIA178_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_G14ED /* CHANGE7_18_FIX */
        L0290_i_ThingCount = G0278_ps_DungeonHeader->ThingCount[P0296_ui_ThingType]; /* BUG0_10 Coding error without consequence. Out of bounds array index. The game reserves a pool of 3 things to make sure it can create 'Bones' objects for dead champions in the party. When the game creates a thing for a dead champion's bones then Bit 15 is set in the requested thing type to indicate that the pool of reserved things can be used. This bit is not cleared before using the thing type as an array index. No consequence because the machine code generated by the Megamax C compiler left shifts the 16 bits value by 1 bit and then keeps the least significant 16 bits, effectively truncating the original and unwanted bit 15. With other compilers or other platforms this may cause an out of bounds array index issue */
#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_18_FIX Clear bit 15 to get the actual thing type before using the value */
        L0290_i_ThingCount = G0278_ps_DungeonHeader->ThingCount[M007_GET(P0296_ui_ThingType, MASK0x7FFF_THING_TYPE)];
#endif
        if (P0296_ui_ThingType == (MASK0x8000_CHAMPION_BONES | C10_THING_TYPE_JUNK)) {
                P0296_ui_ThingType = C10_THING_TYPE_JUNK;
        } else {
                if (P0296_ui_ThingType == C10_THING_TYPE_JUNK) {
                        L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */
                }
        }
        L0288_i_ThingIndex = L0290_i_ThingCount;
        L0289_i_ThingDataByteCount = G0235_auc_Graphic559_ThingDataByteCount[P0296_ui_ThingType] >> 1;
        L0291_ps_Generic = (GENERIC*)G0284_apuc_ThingData[P0296_ui_ThingType];
        for (;;) { /*_Infinite loop_*/
                if (L0291_ps_Generic->Next == C0xFFFF_THING_NONE) { /* If thing data is unused */
                        L0292_T_Thing = (P0296_ui_ThingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex);
                        break;
                }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
                else {
#endif
                        if (--L0288_i_ThingIndex) { /* If there are thing data left to process */
                                L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */
                        } else {
                                if ((L0292_T_Thing = F0165_DUNGEON_GetDiscardedThing(P0296_ui_ThingType)) == C0xFFFF_THING_NONE) {
                                        return C0xFFFF_THING_NONE;
                                }
                                L0291_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L0292_T_Thing);
                                break;
                        }
#ifdef MEDIA365_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
                }
#endif
        }
        F0008_MAIN_ClearBytes(M772_CAST_PC(L0291_ps_Generic), M543_BYTE_COUNT_INT(L0289_i_ThingDataByteCount << 1));
        L0291_ps_Generic->Next = C0xFFFE_THING_ENDOFLIST;
        return L0292_T_Thing;
}

THING F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0297_ui_IconIndex)
#endif
REGISTER unsigned int16_t P0297_ui_IconIndex FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER JUNK* L0296_ps_Junk;
#endif
        REGISTER unsigned int16_t L0293_ui_Type;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0294_i_ThingType;
#endif
        REGISTER THING L0295_T_Thing;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER JUNK* L0296_ps_Junk;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0294_i_ThingType;
#endif


        L0294_i_ThingType = C05_THING_TYPE_WEAPON;
        if ((P0297_ui_IconIndex >= C004_ICON_WEAPON_TORCH_UNLIT) && (P0297_ui_IconIndex <= C007_ICON_WEAPON_TORCH_LIT)) {
                P0297_ui_IconIndex = C004_ICON_WEAPON_TORCH_UNLIT;
        }
        switch (P0297_ui_IconIndex) {
                case C054_ICON_WEAPON_ROCK:
                        L0293_ui_Type = C30_WEAPON_ROCK;
                        break;
                case C128_ICON_JUNK_BOULDER:
                        L0293_ui_Type = C25_JUNK_BOULDER;
                        L0294_i_ThingType = C10_THING_TYPE_JUNK;
                        break;
                case C051_ICON_WEAPON_ARROW:
                        L0293_ui_Type = C27_WEAPON_ARROW;
                        break;
                case C052_ICON_WEAPON_SLAYER:
                        L0293_ui_Type = C28_WEAPON_SLAYER;
                        break;
                case C055_ICON_WEAPON_POISON_DART:
                        L0293_ui_Type = C31_WEAPON_POISON_DART;
                        break;
                case C056_ICON_WEAPON_THROWING_STAR:
                        L0293_ui_Type = C32_WEAPON_THROWING_STAR;
                        break;
                case C032_ICON_WEAPON_DAGGER:
                        L0293_ui_Type = C08_WEAPON_DAGGER;
                        break;
                case C004_ICON_WEAPON_TORCH_UNLIT:
                        L0293_ui_Type = C02_WEAPON_TORCH;
                        break;
                default:
                        return C0xFFFF_THING_NONE;
        }
        if ((L0295_T_Thing = F0166_DUNGEON_GetUnusedThing(L0294_i_ThingType)) == C0xFFFF_THING_NONE) {
                return C0xFFFF_THING_NONE;
        }
        L0296_ps_Junk = (JUNK*)F0156_DUNGEON_GetThingData(L0295_T_Thing);
        L0296_ps_Junk->Type = L0293_ui_Type; /* Also works for WEAPON in cases other than Boulder */
        if ((P0297_ui_IconIndex == C004_ICON_WEAPON_TORCH_UNLIT) && ((WEAPON*)L0296_ps_Junk)->Lit) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */
                ((WEAPON*)L0296_ps_Junk)->ChargeCount = 15;
        }
        return L0295_T_Thing;
}

void F0168_DUNGEON_DecodeText(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0298_pc_String, P0299_T_Thing, P0300_i_TextType)
#endif
REGISTER unsigned char* P0298_pc_String  SEPARATOR /* There is no check to see if the decoded text fits in this string buffer */
THING                   P0299_T_Thing    SEPARATOR
REGISTER int16_t        P0300_i_TextType FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER char* L0303_pc_EscapeReplacementString;
#endif
        REGISTER unsigned int16_t* L0300_pui_CodeWord;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        register unsigned int16_t L0297_ui_Codes;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0299_ui_Code;
#endif
        REGISTER unsigned int16_t L0298_ui_CodeCounter;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned int16_t L0299_ui_Code;
        char L0301_c_SeparatorCharacter;
        int16_t L0302_i_EscapeCharacter;
        char* L0303_pc_EscapeReplacementString;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0302_i_EscapeCharacter;
        REGISTER unsigned int16_t L0297_ui_Codes;
        char L0301_c_SeparatorCharacter;
#endif
        TEXTSTRING L0304_s_TextString;
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
        unsigned char* L2419_puc_Source;
        unsigned char* L2420_puc_Destination;
#ifdef MEDIA569_F20J_X30J_P20JA_P20JB
        unsigned char* L2421_puc_Useless;
#endif
        int16_t L2422_i_TextType;


        L2422_i_TextType = P0300_i_TextType;
        P0300_i_TextType &= 0xBFFF; /* Clear MASK0x4000_NOT_JAPANESE_TEXT */
#endif
#ifdef MEDIA569_F20J_X30J_P20JA_P20JB
        L2421_puc_Useless = L2420_puc_Destination = L2419_puc_Source = P0298_pc_String;
#endif
#ifdef MEDIA689_F31J_X31J_P31J
        L2420_puc_Destination = L2419_puc_Source = P0298_pc_String;
#endif
        L0304_s_TextString = ((TEXTSTRING*)G0284_apuc_ThingData[C02_THING_TYPE_TEXTSTRING])[M013_INDEX(P0299_T_Thing)];
        if ((L0304_s_TextString.Visible) || M007_GET(P0300_i_TextType, MASK0x8000_DECODE_EVEN_IF_INVISIBLE)) {
                M009_CLEAR(P0300_i_TextType, MASK0x8000_DECODE_EVEN_IF_INVISIBLE);
                if (P0300_i_TextType == C1_TEXT_TYPE_MESSAGE) {
                        *P0298_pc_String++ = '\n'; /* New line */
                        L0301_c_SeparatorCharacter = ' ';
                } else {
                        if (P0300_i_TextType == C0_TEXT_TYPE_INSCRIPTION) {
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
                                L0301_c_SeparatorCharacter = '\200'; /* Octal. Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                                L0301_c_SeparatorCharacter = 0x80;
#endif
                        } else {
                                L0301_c_SeparatorCharacter = '\n'; /* New line */
                        }
                }
                L0298_ui_CodeCounter = 0;
                L0302_i_EscapeCharacter = 0;
                L0300_pui_CodeWord = G0260_pui_DungeonTextData + L0304_s_TextString.TextDataWordOffset;
                for (;;) { /*_Infinite loop_*/
                        if (!L0298_ui_CodeCounter) {
                                L0297_ui_Codes = *L0300_pui_CodeWord++;
                                L0299_ui_Code = (L0297_ui_Codes >> 10) & 0x001F;
                        } else {
                                if (L0298_ui_CodeCounter == 1) {
                                        L0299_ui_Code = (L0297_ui_Codes >> 5) & 0x001F;
                                } else {
                                        L0299_ui_Code = L0297_ui_Codes & 0x001F;
                                }
                        }
                        L0298_ui_CodeCounter = ++L0298_ui_CodeCounter % 3;
                        if (L0302_i_EscapeCharacter) {
                                *P0298_pc_String = '\0';
                                if (L0302_i_EscapeCharacter == 30) {
                                        if (P0300_i_TextType != C0_TEXT_TYPE_INSCRIPTION) {
                                                L0303_pc_EscapeReplacementString = G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings[L0299_ui_Code];
                                        } else {
#ifdef PC_FIX_CODE_SIZE
        P0300_i_TextType++;
        P0300_i_TextType++;
        P0300_i_TextType++;
        P0300_i_TextType++;
        P0300_i_TextType++;
        P0300_i_TextType++;
#endif
                                                L0303_pc_EscapeReplacementString = G0257_aac_Graphic559_InscriptionEscapeReplacementStrings[L0299_ui_Code]; /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE opt */
                                        }
                                } else {
                                        if (P0300_i_TextType != C0_TEXT_TYPE_INSCRIPTION) { /* BUG0_00 Useless code. The same statement is executed in both cases */
                                                L0303_pc_EscapeReplacementString = G0256_aac_Graphic559_EscapeReplacementCharacters[L0299_ui_Code];
                                        } else {
                                                L0303_pc_EscapeReplacementString = G0256_aac_Graphic559_EscapeReplacementCharacters[L0299_ui_Code];
                                        }
                                }
                                M545_STRCAT(M772_CAST_PC(P0298_pc_String), L0303_pc_EscapeReplacementString);
                                P0298_pc_String += M544_STRLEN(L0303_pc_EscapeReplacementString);
                                L0302_i_EscapeCharacter = 0;
                        } else {
                                if (L0299_ui_Code < 28) {
                                        if (P0300_i_TextType != C0_TEXT_TYPE_INSCRIPTION) {
                                                if (L0299_ui_Code == 26) {
                                                        L0299_ui_Code = ' ';
                                                } else {
                                                        if (L0299_ui_Code == 27) {
                                                                L0299_ui_Code = '.';
                                                        } else {
                                                                L0299_ui_Code += 'A';
                                                        }
                                                }
                                        }
                                        *P0298_pc_String++ = L0299_ui_Code;
                                } else {
                                        if (L0299_ui_Code == 28) {
                                                *P0298_pc_String++ = L0301_c_SeparatorCharacter;
                                        } else {
                                                if (L0299_ui_Code <= 30) { /* Codes 29 and 30 are escape characters */
                                                        L0302_i_EscapeCharacter = L0299_ui_Code;
                                                } else { /* Code 31 marks the end of the text */
                                                        break;
                                                }
                                        }
                                }
                        }
                }
        }
        if (P0300_i_TextType == C0_TEXT_TYPE_INSCRIPTION) {
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
                *P0298_pc_String = '\201'; /* Octal. Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
                *P0298_pc_String = 0x81;
#endif
        } else {
                *P0298_pc_String = '\0';
        }
#ifdef MEDIA571_F20J_X30J_P20JA_P20JB_F31J_X31J_P31J
        if (!M007_GET(L2422_i_TextType, MASK0x4000_NOT_JAPANESE_TEXT)) { /* If the text is Japanese, a second decoding pass is required */
                if (*L2419_puc_Source == 'A') {
                        L2419_puc_Source++;
                        *L2420_puc_Destination++ = *L2419_puc_Source++;
                }
                while (*L2419_puc_Source != 0) {
                        if ((*L2419_puc_Source >= 'A') && (*L2419_puc_Source <= 'P')) {
                                *L2420_puc_Destination++ = ((*L2419_puc_Source - 'A') << 4) | (*(L2419_puc_Source + 1) - 'A');
                                L2419_puc_Source += 2;
                        } else {
                                *L2420_puc_Destination++ = *L2419_puc_Source++;
                        }
                }
                *L2420_puc_Destination = 0;
        }
#endif
}

STATICFUNCTION int16_t F0169_DUNGEON_GetRandomOrnamentIndex(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0301_ui_Value1, P0302_ui_Value2, P0303_i_Modulo)
#endif
unsigned int16_t P0301_ui_Value1 SEPARATOR
unsigned int16_t P0302_ui_Value2 SEPARATOR
unsigned int16_t P0303_i_Modulo  FINAL_SEPARATOR
{
        return ((((P0301_ui_Value1 * 31417) >> 1) + (P0302_ui_Value2 * 11) + G0278_ps_DungeonHeader->OrnamentRandomSeed) >> 2) % P0303_i_Modulo; /* Pseudorandom number generator */
}

STATICFUNCTION int16_t F0170_DUNGEON_GetRandomOrnamentOrdinal(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0304_B_RandomOrnamentAllowed, P0305_i_OrnamentCount, P0306_i_MapX, P0307_i_MapY, P0308_i_Modulo)
#endif
BOOLEAN P0304_B_RandomOrnamentAllowed SEPARATOR
int16_t P0305_i_OrnamentCount         SEPARATOR
int16_t P0306_i_MapX                  SEPARATOR
int16_t P0307_i_MapY                  SEPARATOR
int16_t P0308_i_Modulo                FINAL_SEPARATOR
{
        int16_t L0305_i_RandomOrnamentIndex;


        if (P0304_B_RandomOrnamentAllowed && ((L0305_i_RandomOrnamentIndex = F0169_DUNGEON_GetRandomOrnamentIndex(2000 + (P0306_i_MapX << 5) + P0307_i_MapY, 3000 + (G0272_i_CurrentMapIndex << 6) + G0273_i_CurrentMapWidth + G0274_i_CurrentMapHeight, P0308_i_Modulo)) < P0305_i_OrnamentCount)) {
                return M000_INDEX_TO_ORDINAL(L0305_i_RandomOrnamentIndex);
        }
#ifdef MEDIA365_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 /* ANOMALY_ST_BRANCH */
        else {
#endif
                return 0;
#ifdef MEDIA365_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
        }
#endif
}

STATICFUNCTION void F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0309_pi_SquareAspect, P0310_B_LeftRandomWallOrnamentAllowed, P0311_B_FrontRandomWallOrnamentAllowed, P0312_B_RightRandomWallOrnamentAllowed, P0313_i_Direction, P0314_i_MapX, P0315_i_MapY, P0316_B_SquareIsFakeWall)
#endif
REGISTER int16_t* P0309_pi_SquareAspect                  SEPARATOR
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
BOOLEAN           P2003_B_BackRandomWallOrnamentAllowed  SEPARATOR
#endif
BOOLEAN           P0310_B_LeftRandomWallOrnamentAllowed  SEPARATOR
BOOLEAN           P0311_B_FrontRandomWallOrnamentAllowed SEPARATOR
BOOLEAN           P0312_B_RightRandomWallOrnamentAllowed SEPARATOR
REGISTER int16_t  P0313_i_Direction                      SEPARATOR
REGISTER int16_t  P0314_i_MapX                           SEPARATOR
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER int16_t  P0315_i_MapY                           FINAL_SEPARATOR
#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
REGISTER int16_t  P0315_i_MapY                           SEPARATOR
BOOLEAN           P0316_B_SquareIsFakeWall               FINAL_SEPARATOR
#endif
{
        REGISTER int16_t L0306_i_Multiple;
#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple
#define AL0306_i_SideIndex               L0306_i_Multiple


        AL0306_i_RandomWallOrnamentCount = G0269_ps_CurrentMap->B.RandomWallOrnamentCount;
#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
        P0309_pi_SquareAspect[M551_RIGHT_WALL_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(P0310_B_LeftRandomWallOrnamentAllowed, AL0306_i_RandomWallOrnamentCount, P0314_i_MapX, ++P0315_i_MapY * (M021_NORMALIZE(++P0313_i_Direction) + 1), 30);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        P0309_pi_SquareAspect[C3_BACK_WALL_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(P2003_B_BackRandomWallOrnamentAllowed, AL0306_i_RandomWallOrnamentCount, P0314_i_MapX, ++P0315_i_MapY * (M021_NORMALIZE(P0313_i_Direction) + 1), 30);
        P0309_pi_SquareAspect[M551_RIGHT_WALL_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(P0310_B_LeftRandomWallOrnamentAllowed, AL0306_i_RandomWallOrnamentCount, P0314_i_MapX, P0315_i_MapY * (M021_NORMALIZE(++P0313_i_Direction) + 1), 30);
#endif
        P0309_pi_SquareAspect[M552_FRONT_WALL_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(P0311_B_FrontRandomWallOrnamentAllowed, AL0306_i_RandomWallOrnamentCount, P0314_i_MapX, P0315_i_MapY * (M021_NORMALIZE(++P0313_i_Direction) + 1), 30);
        P0309_pi_SquareAspect[M553_LEFT_WALL_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(P0312_B_RightRandomWallOrnamentAllowed, AL0306_i_RandomWallOrnamentCount, P0314_i_MapX, P0315_i_MapY-- * (M021_NORMALIZE(++P0313_i_Direction) + 1), 30);
        if (
#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
           P0316_B_SquareIsFakeWall ||
#endif
#ifdef MEDIA012_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JA_P20JB_I34E_I34M_P31J
           (P0314_i_MapX < 0) || (P0314_i_MapX >= G0273_i_CurrentMapWidth) || (P0315_i_MapY < 0) || (P0315_i_MapY >= G0274_i_CurrentMapHeight)) { /* If square is a fake wall or is out of map bounds */
#endif
#ifdef MEDIA548_F20E_F20J_X30J_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J
           !((P0314_i_MapX >= 0) && (P0314_i_MapX < G0273_i_CurrentMapWidth)) || !((P0315_i_MapY >= 0) && (P0315_i_MapY < G0274_i_CurrentMapHeight))) { /* If square is a fake wall or is out of map bounds */
#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
                for (AL0306_i_SideIndex = M551_RIGHT_WALL_ORNAMENT_ORDINAL; AL0306_i_SideIndex <= M553_LEFT_WALL_ORNAMENT_ORDINAL; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                for (AL0306_i_SideIndex = C3_BACK_WALL_ORNAMENT_ORDINAL; AL0306_i_SideIndex <= M553_LEFT_WALL_ORNAMENT_ORDINAL; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */
#endif
                        if (F0149_DUNGEON_IsWallOrnamentAnAlcove(M001_ORDINAL_TO_INDEX(P0309_pi_SquareAspect[AL0306_i_SideIndex]))) {
                                P0309_pi_SquareAspect[AL0306_i_SideIndex] = 0;
                        }
                }
        }
}

void F0172_DUNGEON_SetSquareAspect(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0317_pui_SquareAspect, P0318_i_Direction, P0319_i_MapX, P0320_i_MapY)
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
REGISTER unsigned int16_t* P0317_pui_SquareAspect SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER int16_t*          P0317_pui_SquareAspect SEPARATOR
#endif
REGISTER int16_t           P0318_i_Direction      SEPARATOR
REGISTER int16_t           P0319_i_MapX           SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
register int16_t           P0320_i_MapY           FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t                    P0320_i_MapY           FINAL_SEPARATOR
#endif
#define AP0318_i_ThingType P0318_i_Direction
{
        REGISTER SENSOR* L0308_ps_Sensor;
        REGISTER unsigned char L0307_uc_Multiple;
#define AL0307_uc_Square            L0307_uc_Multiple
#define AL0307_uc_FootprintsAllowed L0307_uc_Multiple
#define AL0307_uc_ScentOrdinal      L0307_uc_Multiple
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER THING L0314_T_Thing;
        REGISTER int16_t L0310_i_Multiple;
#endif
        BOOLEAN L0309_B_LeftRandomWallOrnamentAllowed;
#define AL0310_B_FrontRandomWallOrnamentAllowed L0310_i_Multiple
#define AL0310_i_SideIndex                      L0310_i_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0310_i_Multiple;
#endif
        BOOLEAN L0311_B_RightRandomWallOrnamentAllowed;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0312_i_ThingType;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        BOOLEAN L2423_B_BackRandomWallOrnamentAllowed; /* Added to get aspect of back wall for the magic map in CSB 3.x */
#endif
        BOOLEAN L0313_B_SquareIsFakeWall;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        THING L0314_T_Thing;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L0312_i_ThingType;
#endif


        F0008_MAIN_ClearBytes(M772_CAST_PC(P0317_pui_SquareAspect), M543_BYTE_COUNT_INT(M559_SQUARE_ASPECT_INT_COUNT * sizeof(int16_t)));
        L0314_T_Thing = F0161_DUNGEON_GetSquareFirstThing(P0319_i_MapX, P0320_i_MapY);
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        P0317_pui_SquareAspect[C1_SQUARE] =
#endif
        AL0307_uc_Square = F0151_DUNGEON_GetSquare(P0319_i_MapX, P0320_i_MapY);
        switch (P0317_pui_SquareAspect[C0_ELEMENT] = M034_SQUARE_TYPE(AL0307_uc_Square)) {
                case C00_ELEMENT_WALL:
                        switch (P0318_i_Direction) {
                                case C0_DIRECTION_NORTH:
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L2423_B_BackRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED);
#endif
                                        L0309_B_LeftRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED);
                                        AL0310_B_FrontRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED);
                                        L0311_B_RightRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED);
                                        break;
                                case C1_DIRECTION_EAST:
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L2423_B_BackRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED);
#endif
                                        L0309_B_LeftRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED);
                                        AL0310_B_FrontRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED);
                                        L0311_B_RightRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED);
                                        break;
                                case C2_DIRECTION_SOUTH:
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L2423_B_BackRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED);
#endif
                                        L0309_B_LeftRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED);
                                        AL0310_B_FrontRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED);
                                        L0311_B_RightRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED);
                                        break;
                                case C3_DIRECTION_WEST:
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L2423_B_BackRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED);
#endif
                                        L0309_B_LeftRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED);
                                        AL0310_B_FrontRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED);
                                        L0311_B_RightRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED);
                        }
                        G0289_i_DungeonView_ChampionPortraitOrdinal = 0; /* BUG0_75 Multiple champion portraits are drawn (one at a time) then the game crashes. This variable is only reset to 0 when at least one square in the dungeon view is a wall. If the party is in front of a wall with a champion portrait and the next time the dungeon view is drawn there is no wall square in the view and the square in front of the party is a fake wall with a random ornament then the same champion portrait will be drawn again because the variable was not reset to 0. Each time F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF draws the portrait, G0289_i_DungeonView_ChampionPortraitOrdinal is decremented so that the portait is different each time the dungeon view is drawn until the game crashes */
                        L0313_B_SquareIsFakeWall = C0_FALSE;
#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
                        T0172010_ClosedFakeWall:
                        F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals(P0317_pui_SquareAspect, L0309_B_LeftRandomWallOrnamentAllowed, AL0310_B_FrontRandomWallOrnamentAllowed, L0311_B_RightRandomWallOrnamentAllowed, P0318_i_Direction, P0319_i_MapX, P0320_i_MapY, L0313_B_SquareIsFakeWall);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals(P0317_pui_SquareAspect, L2423_B_BackRandomWallOrnamentAllowed, L0309_B_LeftRandomWallOrnamentAllowed, AL0310_B_FrontRandomWallOrnamentAllowed, L0311_B_RightRandomWallOrnamentAllowed, P0318_i_Direction, P0319_i_MapX, P0320_i_MapY);
                        T0172010_ClosedFakeWall: /* On version 3.x, random decorations are not allowed on fake walls (F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals is not executed for fake walls). This avoids for example the fountain on the northern wall at (04,14,10) */
#endif
                        while ((L0314_T_Thing != C0xFFFE_THING_ENDOFLIST) && ((L0312_i_ThingType = M012_TYPE(L0314_T_Thing)) <= C03_THING_TYPE_SENSOR)) {
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
                                if (AL0310_i_SideIndex = M021_NORMALIZE(M011_CELL(L0314_T_Thing) - P0318_i_Direction)) { /* Invisible on the back wall if 0 */
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                AL0310_i_SideIndex = M021_NORMALIZE(M011_CELL(L0314_T_Thing) - P0318_i_Direction) + 3;
#endif
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_02_OPTIMIZATION Inline code replaced by function calls */
                                        if (L0312_i_ThingType == C02_THING_TYPE_TEXTSTRING) {
                                                if (((TEXTSTRING*)G0284_apuc_ThingData[C02_THING_TYPE_TEXTSTRING])[M013_INDEX(L0314_T_Thing)].Visible) {
#endif
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_02_OPTIMIZATION Inline code replaced by function calls */
                                        L0308_ps_Sensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0314_T_Thing);
                                        if (L0312_i_ThingType == C02_THING_TYPE_TEXTSTRING) {
                                                if (((TEXTSTRING*)L0308_ps_Sensor)->Visible) {
#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
                                                        P0317_pui_SquareAspect[AL0310_i_SideIndex + 1] = G0265_i_CurrentMapInscriptionWallOrnamentIndex + 1;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                        P0317_pui_SquareAspect[AL0310_i_SideIndex] = G0265_i_CurrentMapInscriptionWallOrnamentIndex + 1;
#endif
#ifdef MEDIA707_I34E_I34M
                                                        if (AL0310_i_SideIndex == M552_FRONT_WALL_ORNAMENT_ORDINAL) {
#endif
                                                                G0290_T_DungeonView_InscriptionThing = L0314_T_Thing; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on different sides of the wall, the same text is drawn on each affected side */
#ifdef MEDIA707_I34E_I34M
                                                        }
#endif
                                                }
                                        } else {
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_02_OPTIMIZATION Inline code replaced by function calls */
                                                L0308_ps_Sensor = &((SENSOR*)G0284_apuc_ThingData[C03_THING_TYPE_SENSOR])[M013_INDEX(L0314_T_Thing)];
#endif
#ifdef MEDIA020_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB
                                                P0317_pui_SquareAspect[AL0310_i_SideIndex + 1] = L0308_ps_Sensor->Remote.OrnamentOrdinal;
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                P0317_pui_SquareAspect[AL0310_i_SideIndex] = L0308_ps_Sensor->Remote.OrnamentOrdinal;
#endif
                                                if (M039_TYPE(L0308_ps_Sensor) == C127_SENSOR_WALL_CHAMPION_PORTRAIT) {
#ifdef MEDIA707_I34E_I34M
                                                        if (AL0310_i_SideIndex == M552_FRONT_WALL_ORNAMENT_ORDINAL) {
#endif
                                                                G0289_i_DungeonView_ChampionPortraitOrdinal = M000_INDEX_TO_ORDINAL(M040_DATA(L0308_ps_Sensor));
#ifdef MEDIA707_I34E_I34M
                                                        }
#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
                                }
#endif
                                L0314_T_Thing = F0159_DUNGEON_GetNextThing(L0314_T_Thing);
                        }
                        if (L0313_B_SquareIsFakeWall && (G0306_i_PartyMapX != P0319_i_MapX) && (G0307_i_PartyMapY != P0320_i_MapY)) {
                                P0317_pui_SquareAspect[M550_FIRST_THING] = C0xFFFE_THING_ENDOFLIST;
                                return;
                        }
                        break;
                case C02_ELEMENT_PIT:
                        if (M007_GET(AL0307_uc_Square, MASK0x0008_PIT_OPEN)) {
                                P0317_pui_SquareAspect[M554_PIT_OR_TELEPORTER_VISIBLE] = M007_GET(AL0307_uc_Square, MASK0x0004_PIT_INVISIBLE);
                                AL0307_uc_FootprintsAllowed &= MASK0x0001_PIT_IMAGINARY;
                        } else { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE opt */
#ifdef PC_FIX_CODE_SIZE
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
        L0314_T_Thing++;
#endif
                                P0317_pui_SquareAspect[C0_ELEMENT] = C01_ELEMENT_CORRIDOR;
                                AL0307_uc_FootprintsAllowed = C1_TRUE;
                        }
                        goto T0172030_Pit;
                case C06_ELEMENT_FAKEWALL:
                        if (!M007_GET(AL0307_uc_Square, MASK0x0004_FAKEWALL_OPEN)) {
                                P0317_pui_SquareAspect[C0_ELEMENT] = C00_ELEMENT_WALL;
#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
                                L0309_B_LeftRandomWallOrnamentAllowed = L0311_B_RightRandomWallOrnamentAllowed = AL0310_B_FrontRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                L2423_B_BackRandomWallOrnamentAllowed = L0309_B_LeftRandomWallOrnamentAllowed = AL0310_B_FrontRandomWallOrnamentAllowed = L0311_B_RightRandomWallOrnamentAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED);
#endif
                                L0313_B_SquareIsFakeWall = C1_TRUE;
                                goto T0172010_ClosedFakeWall;
                        }
                        P0317_pui_SquareAspect[C0_ELEMENT] = C01_ELEMENT_CORRIDOR;
                        AL0307_uc_FootprintsAllowed = M007_GET(AL0307_uc_Square, MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED) ? 8 : 0;
                case C01_ELEMENT_CORRIDOR:
                        P0317_pui_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL] = F0170_DUNGEON_GetRandomOrnamentOrdinal(M007_GET(AL0307_uc_Square, MASK0x0008_CORRIDOR_RANDOM_ORNAMENT_ALLOWED), G0269_ps_CurrentMap->B.RandomFloorOrnamentCount, P0319_i_MapX, P0320_i_MapY, 30);
                        T0172029_Teleporter:
                        AL0307_uc_FootprintsAllowed = C1_TRUE;
                        T0172030_Pit:
                        while ((L0314_T_Thing != C0xFFFE_THING_ENDOFLIST) && ((AP0318_i_ThingType = M012_TYPE(L0314_T_Thing)) <= C03_THING_TYPE_SENSOR)) {
                                if (AP0318_i_ThingType == C03_THING_TYPE_SENSOR) {
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_02_OPTIMIZATION Inline code replaced by function calls */
                                        P0317_pui_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL] = ((SENSOR*)G0284_apuc_ThingData[C03_THING_TYPE_SENSOR])[M013_INDEX(L0314_T_Thing)].Remote.OrnamentOrdinal;
#endif
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_02_OPTIMIZATION Inline code replaced by function calls */
                                        L0308_ps_Sensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0314_T_Thing);
                                        P0317_pui_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL] = L0308_ps_Sensor->Remote.OrnamentOrdinal;
#endif
                                }
                                L0314_T_Thing = F0159_DUNGEON_GetNextThing(L0314_T_Thing);
                        }
                        goto T0172049_Footprints;
                case C05_ELEMENT_TELEPORTER:
#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
                        P0317_pui_SquareAspect[M554_PIT_OR_TELEPORTER_VISIBLE] = M007_GET(AL0307_uc_Square, MASK0x0008_TELEPORTER_OPEN) && M007_GET(AL0307_uc_Square, MASK0x0004_TELEPORTER_VISIBLE);
#endif
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        if ((!M007_GET(AL0307_uc_Square, MASK0x0008_TELEPORTER_OPEN) || !M007_GET(AL0307_uc_Square, MASK0x0004_TELEPORTER_VISIBLE))) {
                                P0317_pui_SquareAspect[C0_ELEMENT] = C01_ELEMENT_CORRIDOR;
                        }
#endif
                        goto T0172029_Teleporter;
                case C03_ELEMENT_STAIRS:
                        P0317_pui_SquareAspect[C0_ELEMENT] = ((M007_GET(AL0307_uc_Square, MASK0x0008_STAIRS_NORTH_SOUTH_ORIENTATION) >> 3) == M016_IS_ORIENTED_WEST_EAST(P0318_i_Direction)) ? C18_ELEMENT_STAIRS_SIDE : C19_ELEMENT_STAIRS_FRONT;
                        P0317_pui_SquareAspect[M555_STAIRS_UP] = M007_GET(AL0307_uc_Square, MASK0x0004_STAIRS_UP);
                        AL0307_uc_FootprintsAllowed = C0_FALSE;
                        goto T0172046_Stairs;
                case C04_ELEMENT_DOOR:
                        if ((M007_GET(AL0307_uc_Square, MASK0x0008_DOOR_NORTH_SOUTH_ORIENTATION) >> 3) == M016_IS_ORIENTED_WEST_EAST(P0318_i_Direction)) {
                                P0317_pui_SquareAspect[C0_ELEMENT] = C16_ELEMENT_DOOR_SIDE;
                        } else {
                                P0317_pui_SquareAspect[C0_ELEMENT] = C17_ELEMENT_DOOR_FRONT;
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        }
#endif
                                P0317_pui_SquareAspect[M556_DOOR_STATE] = M036_DOOR_STATE(AL0307_uc_Square);
                                P0317_pui_SquareAspect[M557_DOOR_THING_INDEX] = M013_INDEX(F0161_DUNGEON_GetSquareFirstThing(P0319_i_MapX, P0320_i_MapY));
#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
                        }
#endif
                        AL0307_uc_FootprintsAllowed = C1_TRUE;
                        T0172046_Stairs:
                        while ((L0314_T_Thing != C0xFFFE_THING_ENDOFLIST) && (M012_TYPE(L0314_T_Thing) <= C03_THING_TYPE_SENSOR)) {
                                L0314_T_Thing = F0159_DUNGEON_GetNextThing(L0314_T_Thing);
                        }
                        T0172049_Footprints:
                        if (AL0307_uc_FootprintsAllowed && (AL0307_uc_ScentOrdinal = F0315_CHAMPION_GetScentOrdinal(P0319_i_MapX, P0320_i_MapY)) && (--AL0307_uc_ScentOrdinal >= G0407_s_Party.FirstScentIndex) && (AL0307_uc_ScentOrdinal < G0407_s_Party.LastScentIndex)) {
                                M008_SET(P0317_pui_SquareAspect[M558_FLOOR_ORNAMENT_ORDINAL], MASK0x8000_FOOTPRINTS);
                        }
        }
        P0317_pui_SquareAspect[M550_FIRST_THING] = L0314_T_Thing;
}

void F0173_DUNGEON_SetCurrentMap(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0321_ui_MapIndex)
#endif
REGISTER unsigned int16_t P0321_ui_MapIndex FINAL_SEPARATOR
{
        if (G0272_i_CurrentMapIndex == P0321_ui_MapIndex)
                return;
        G0272_i_CurrentMapIndex = P0321_ui_MapIndex;
        G0271_ppuc_CurrentMapData = G0279_pppuc_DungeonMapData[P0321_ui_MapIndex];
        G0269_ps_CurrentMap = G0277_ps_DungeonMaps + P0321_ui_MapIndex;
        G0273_i_CurrentMapWidth = G0269_ps_CurrentMap->A.Width + 1;
        G0274_i_CurrentMapHeight = G0269_ps_CurrentMap->A.Height + 1;
        G0275_as_CurrentMapDoorInfo[0] = G0254_as_Graphic559_DoorInfo[G0269_ps_CurrentMap->D.DoorSet0];
        G0275_as_CurrentMapDoorInfo[1] = G0254_as_Graphic559_DoorInfo[G0269_ps_CurrentMap->D.DoorSet1];
        G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount = &G0280_pui_DungeonColumnsCumulativeSquareThingCount[G0281_pui_DungeonMapsFirstColumnIndex[P0321_ui_MapIndex]];
}

void F0174_DUNGEON_SetCurrentMapAndPartyMap(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0322_i_MapIndex)
REGISTER int16_t P0322_i_MapIndex FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t          P0322_i_MapIndex FINAL_SEPARATOR
#endif
{
        REGISTER unsigned char* L0316_puc_MapMetaData;
        REGISTER int16_t L0315_i_FloorOrnamentCount;


        F0173_DUNGEON_SetCurrentMap(G0309_i_PartyMapIndex = P0322_i_MapIndex);
        L0316_puc_MapMetaData = G0271_ppuc_CurrentMapData[G0273_i_CurrentMapWidth - 1] + G0274_i_CurrentMapHeight;
        G0264_puc_CurrentMapAllowedCreatureTypes = L0316_puc_MapMetaData;
        F0007_MAIN_CopyBytes(M772_CAST_PC(L0316_puc_MapMetaData += G0269_ps_CurrentMap->C.CreatureTypeCount), M772_CAST_PC(G0261_auc_CurrentMapWallOrnamentIndices), M543_BYTE_COUNT_INT(G0265_i_CurrentMapInscriptionWallOrnamentIndex = G0269_ps_CurrentMap->B.WallOrnamentCount));
        F0007_MAIN_CopyBytes(M772_CAST_PC(L0316_puc_MapMetaData += G0265_i_CurrentMapInscriptionWallOrnamentIndex), M772_CAST_PC(G0262_auc_CurrentMapFloorOrnamentIndices), M543_BYTE_COUNT_INT(L0315_i_FloorOrnamentCount = G0269_ps_CurrentMap->B.FloorOrnamentCount));
        F0007_MAIN_CopyBytes(M772_CAST_PC(L0316_puc_MapMetaData + L0315_i_FloorOrnamentCount), M772_CAST_PC(G0263_auc_CurrentMapDoorOrnamentIndices), M543_BYTE_COUNT_INT(G0269_ps_CurrentMap->C.DoorOrnamentCount));
        G0261_auc_CurrentMapWallOrnamentIndices[G0265_i_CurrentMapInscriptionWallOrnamentIndex] = C0_WALL_ORNAMENT_INSCRIPTION;
}
#endif
