+#include "game_em/game_em.h"
+#include "game_sp/game_sp.h"
+#include "game_mm/game_mm.h"
+#include "engines.h"
+
+#include "conf_gfx.h" // include auto-generated data structure definitions
+#include "conf_snd.h" // include auto-generated data structure definitions
+#include "conf_mus.h" // include auto-generated data structure definitions
+
+
+#define IMG_UNDEFINED (-1)
+#define IMG_EMPTY IMG_EMPTY_SPACE
+#define IMG_SP_EMPTY IMG_EMPTY_SPACE
+#define IMG_SP_EMPTY_SPACE IMG_EMPTY_SPACE
+#define IMG_EXPLOSION IMG_DEFAULT_EXPLODING
+#define IMG_CHAR_START IMG_CHAR_SPACE
+#define IMG_STEEL_CHAR_START IMG_STEEL_CHAR_SPACE
+#define IMG_CUSTOM_START IMG_CUSTOM_1
+
+#define SND_UNDEFINED (-1)
+#define MUS_UNDEFINED (-1)
+
+#define WIN_XSIZE_DEFAULT 672
+#define WIN_YSIZE_DEFAULT 560
+
+#define SCR_FIELDX_DEFAULT 17
+#define SCR_FIELDY_DEFAULT 17
+
+#define SXSIZE_DEFAULT (SCR_FIELDX_DEFAULT * TILEX)
+#define SYSIZE_DEFAULT (SCR_FIELDY_DEFAULT * TILEY)
+
+#define MAX_BUF_XSIZE (SCR_FIELDX + 2)
+#define MAX_BUF_YSIZE (SCR_FIELDY + 2)
+#define MIN_LEV_FIELDX 3
+#define MIN_LEV_FIELDY 3
+#define STD_LEV_FIELDX 64
+#define STD_LEV_FIELDY 32
+#define MAX_LEV_FIELDX MAX_PLAYFIELD_WIDTH
+#define MAX_LEV_FIELDY MAX_PLAYFIELD_HEIGHT
+
+#define MIN_SCROLL_DELAY 0
+#define STD_SCROLL_DELAY 3
+#define MAX_SCROLL_DELAY 8
+
+#define SCREENX(a) ((a) - scroll_x)
+#define SCREENY(a) ((a) - scroll_y)
+#define LEVELX(a) ((a) + scroll_x)
+#define LEVELY(a) ((a) + scroll_y)
+
+#define IN_FIELD(x, y, xsize, ysize) ((x) >= 0 && (x) < (xsize) && \
+ (y) >= 0 && (y) < (ysize))
+#define IN_FIELD_MINMAX(x, y, xmin, ymin, xmax, ymax) \
+ ((x) >= (xmin) && (x) <= (xmax) && \
+ (y) >= (ymin) && (y) <= (ymax))
+
+#define IN_PIX_FIELD(x, y) IN_FIELD(x, y, SXSIZE, SYSIZE)
+#define IN_VIS_FIELD(x, y) IN_FIELD(x, y, SCR_FIELDX, SCR_FIELDY)
+#define IN_LEV_FIELD(x, y) IN_FIELD(x, y, lev_fieldx, lev_fieldy)
+#define IN_SCR_FIELD(x, y) IN_FIELD_MINMAX(x,y, BX1,BY1, BX2,BY2)
+
+// values for configurable properties (custom elem's only, else pre-defined)
+// (never change these values, as they are stored in level files!)
+#define EP_DIGGABLE 0
+#define EP_COLLECTIBLE_ONLY 1
+#define EP_DONT_RUN_INTO 2
+#define EP_DONT_COLLIDE_WITH 3
+#define EP_DONT_TOUCH 4
+#define EP_INDESTRUCTIBLE 5
+#define EP_SLIPPERY 6
+#define EP_CAN_CHANGE 7
+#define EP_CAN_MOVE 8
+#define EP_CAN_FALL 9
+#define EP_CAN_SMASH_PLAYER 10
+#define EP_CAN_SMASH_ENEMIES 11
+#define EP_CAN_SMASH_EVERYTHING 12
+#define EP_EXPLODES_BY_FIRE 13
+#define EP_EXPLODES_SMASHED 14
+#define EP_EXPLODES_IMPACT 15
+#define EP_WALKABLE_OVER 16
+#define EP_WALKABLE_INSIDE 17
+#define EP_WALKABLE_UNDER 18
+#define EP_PASSABLE_OVER 19
+#define EP_PASSABLE_INSIDE 20
+#define EP_PASSABLE_UNDER 21
+#define EP_DROPPABLE 22
+#define EP_EXPLODES_1X1_OLD 23
+#define EP_PUSHABLE 24
+#define EP_EXPLODES_CROSS_OLD 25
+#define EP_PROTECTED 26
+#define EP_CAN_MOVE_INTO_ACID 27
+#define EP_THROWABLE 28
+#define EP_CAN_EXPLODE 29
+#define EP_GRAVITY_REACHABLE 30
+#define EP_DONT_GET_HIT_BY 31
+
+// values for pre-defined properties
+// (from here on, values can be changed by inserting new values)
+#define EP_PLAYER 32
+#define EP_CAN_PASS_MAGIC_WALL 33
+#define EP_CAN_PASS_DC_MAGIC_WALL 34
+#define EP_SWITCHABLE 35
+#define EP_BD_ELEMENT 36
+#define EP_SP_ELEMENT 37
+#define EP_SB_ELEMENT 38
+#define EP_GEM 39
+#define EP_FOOD_DARK_YAMYAM 40
+#define EP_FOOD_PENGUIN 41
+#define EP_FOOD_PIG 42
+#define EP_HISTORIC_WALL 43
+#define EP_HISTORIC_SOLID 44
+#define EP_CLASSIC_ENEMY 45
+#define EP_BELT 46
+#define EP_BELT_ACTIVE 47
+#define EP_BELT_SWITCH 48
+#define EP_TUBE 49
+#define EP_ACID_POOL 50
+#define EP_KEYGATE 51
+#define EP_AMOEBOID 52
+#define EP_AMOEBALIVE 53
+#define EP_HAS_EDITOR_CONTENT 54
+#define EP_CAN_TURN_EACH_MOVE 55
+#define EP_CAN_GROW 56
+#define EP_ACTIVE_BOMB 57
+#define EP_INACTIVE 58
+
+// values for special configurable properties (depending on level settings)
+#define EP_EM_SLIPPERY_WALL 59
+
+// values for special graphics properties (no effect on game engine)
+#define EP_GFX_CRUMBLED 60
+
+// values for derived properties (determined from properties above)
+#define EP_ACCESSIBLE_OVER 61
+#define EP_ACCESSIBLE_INSIDE 62
+#define EP_ACCESSIBLE_UNDER 63
+#define EP_WALKABLE 64
+#define EP_PASSABLE 65
+#define EP_ACCESSIBLE 66
+#define EP_COLLECTIBLE 67
+#define EP_SNAPPABLE 68
+#define EP_WALL 69
+#define EP_SOLID_FOR_PUSHING 70
+#define EP_DRAGONFIRE_PROOF 71
+#define EP_EXPLOSION_PROOF 72
+#define EP_CAN_SMASH 73
+#define EP_EXPLODES_3X3_OLD 74
+#define EP_CAN_EXPLODE_BY_FIRE 75
+#define EP_CAN_EXPLODE_SMASHED 76
+#define EP_CAN_EXPLODE_IMPACT 77
+#define EP_SP_PORT 78
+#define EP_CAN_EXPLODE_BY_DRAGONFIRE 79
+#define EP_CAN_EXPLODE_BY_EXPLOSION 80
+#define EP_COULD_MOVE_INTO_ACID 81
+#define EP_MAYBE_DONT_COLLIDE_WITH 82
+#define EP_CAN_BE_CLONED_BY_ANDROID 83
+
+// values for internal purpose only (level editor)
+#define EP_WALK_TO_OBJECT 84
+#define EP_DEADLY 85
+#define EP_EDITOR_CASCADE 86
+#define EP_EDITOR_CASCADE_ACTIVE 87
+#define EP_EDITOR_CASCADE_INACTIVE 88
+
+// values for internal purpose only (game engine)
+#define EP_HAS_ACTION 89
+#define EP_CAN_CHANGE_OR_HAS_ACTION 90
+
+// values for internal purpose only (other)
+#define EP_OBSOLETE 91
+
+#define NUM_ELEMENT_PROPERTIES 92
+
+#define NUM_EP_BITFIELDS ((NUM_ELEMENT_PROPERTIES + 31) / 32)
+#define EP_BITFIELD_BASE_NR 0
+
+#define EP_BITMASK_BASE_DEFAULT (1 << EP_CAN_MOVE_INTO_ACID)
+#define EP_BITMASK_DEFAULT 0
+
+#define PROPERTY_BIT(p) (1 << ((p) % 32))
+#define PROPERTY_VAR(e,p) (element_info[e].properties[(p) / 32])
+#define HAS_PROPERTY(e,p) ((PROPERTY_VAR(e, p) & PROPERTY_BIT(p)) != 0)
+#define SET_PROPERTY(e,p,v) ((v) ? \
+ (PROPERTY_VAR(e,p) |= PROPERTY_BIT(p)) : \
+ (PROPERTY_VAR(e,p) &= ~PROPERTY_BIT(p)))
+
+
+// values for change events for custom elements (stored in level file)
+#define CE_DELAY 0
+#define CE_TOUCHED_BY_PLAYER 1
+#define CE_PRESSED_BY_PLAYER 2
+#define CE_PUSHED_BY_PLAYER 3
+#define CE_DROPPED_BY_PLAYER 4
+#define CE_HITTING_SOMETHING 5
+#define CE_IMPACT 6
+#define CE_SMASHED 7
+#define CE_TOUCHING_X 8
+#define CE_CHANGE_OF_X 9
+#define CE_EXPLOSION_OF_X 10
+#define CE_PLAYER_TOUCHES_X 11
+#define CE_PLAYER_PRESSES_X 12
+#define CE_PLAYER_PUSHES_X 13
+#define CE_PLAYER_COLLECTS_X 14
+#define CE_PLAYER_DROPS_X 15
+#define CE_VALUE_GETS_ZERO 16
+#define CE_VALUE_GETS_ZERO_OF_X 17
+#define CE_BY_OTHER_ACTION 18
+#define CE_BY_DIRECT_ACTION 19
+#define CE_PLAYER_DIGS_X 20
+#define CE_ENTERED_BY_PLAYER 21
+#define CE_LEFT_BY_PLAYER 22
+#define CE_PLAYER_ENTERS_X 23
+#define CE_PLAYER_LEAVES_X 24
+#define CE_SWITCHED 25
+#define CE_SWITCH_OF_X 26
+#define CE_HIT_BY_SOMETHING 27
+#define CE_HITTING_X 28
+#define CE_HIT_BY_X 29
+#define CE_BLOCKED 30
+#define CE_SWITCHED_BY_PLAYER 31
+#define CE_PLAYER_SWITCHES_X 32
+#define CE_SNAPPED_BY_PLAYER 33
+#define CE_PLAYER_SNAPS_X 34
+#define CE_MOVE_OF_X 35
+#define CE_DIGGING_X 36
+#define CE_CREATION_OF_X 37
+#define CE_SCORE_GETS_ZERO 38
+#define CE_SCORE_GETS_ZERO_OF_X 39
+#define CE_VALUE_CHANGES 40
+#define CE_VALUE_CHANGES_OF_X 41
+#define CE_SCORE_CHANGES 42
+#define CE_SCORE_CHANGES_OF_X 43
+#define CE_CLICKED_BY_MOUSE 44
+#define CE_PRESSED_BY_MOUSE 45
+#define CE_MOUSE_CLICKED_ON_X 46
+#define CE_MOUSE_PRESSED_ON_X 47
+
+#define NUM_CHANGE_EVENTS 48
+
+#define NUM_CE_BITFIELDS ((NUM_CHANGE_EVENTS + 31) / 32)
+
+#define CE_HEADLINE_SPECIAL_EVENTS 250
+#define CE_UNDEFINED 255
+
+#define CE_BITMASK_DEFAULT 0
+
+#define CH_EVENT_BITFIELD_NR(e) (e / 32)
+#define CH_EVENT_BIT(e) (1 << ((e) % 32))
+
+#define CH_EVENT_VAR(e,c) (element_info[e].change->has_event[c])
+#define CH_ANY_EVENT_VAR(e,c) (element_info[e].has_change_event[c])
+
+#define PAGE_HAS_CHANGE_EVENT(p,c) ((p)->has_event[c])
+#define HAS_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \
+ CH_EVENT_VAR(e,c))
+#define HAS_ANY_CHANGE_EVENT(e,c) (IS_CUSTOM_ELEMENT(e) && \
+ CH_ANY_EVENT_VAR(e,c))
+
+#define SET_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \
+ CH_EVENT_VAR(e,c) = (v) : 0)
+#define SET_ANY_CHANGE_EVENT(e,c,v) (IS_CUSTOM_ELEMENT(e) ? \
+ CH_ANY_EVENT_VAR(e,c) = (v) : 0)
+
+// values for player bitmasks
+#define PLAYER_BITS_NONE 0
+#define PLAYER_BITS_1 (1 << 0)
+#define PLAYER_BITS_2 (1 << 1)
+#define PLAYER_BITS_3 (1 << 2)
+#define PLAYER_BITS_4 (1 << 3)
+#define PLAYER_BITS_ANY (PLAYER_BITS_1 | \
+ PLAYER_BITS_2 | \
+ PLAYER_BITS_3 | \
+ PLAYER_BITS_4)
+#define PLAYER_BITS_TRIGGER (1 << 4)
+#define PLAYER_BITS_ACTION (1 << 5)
+
+// values for move directions (bits 0 - 3: basic move directions)
+#define MV_BIT_PREVIOUS 4
+#define MV_BIT_TRIGGER 5
+#define MV_BIT_TRIGGER_BACK 6
+#define MV_BIT_NORMAL MV_BIT_TRIGGER
+#define MV_BIT_REVERSE MV_BIT_TRIGGER_BACK
+
+#define MV_PREVIOUS (1 << MV_BIT_PREVIOUS)
+#define MV_TRIGGER (1 << MV_BIT_TRIGGER)
+#define MV_TRIGGER_BACK (1 << MV_BIT_TRIGGER_BACK)
+#define MV_NORMAL (1 << MV_BIT_NORMAL)
+#define MV_REVERSE (1 << MV_BIT_REVERSE)
+
+// values for move stepsize
+#define STEPSIZE_NOT_MOVING 0
+#define STEPSIZE_VERY_SLOW 1
+#define STEPSIZE_SLOW 2
+#define STEPSIZE_NORMAL 4
+#define STEPSIZE_FAST 8
+#define STEPSIZE_VERY_FAST 16
+#define STEPSIZE_EVEN_FASTER 32
+#define STEPSIZE_SLOWER 50 // (symbolic value only)
+#define STEPSIZE_FASTER 200 // (symbolic value only)
+#define STEPSIZE_RESET 100 // (symbolic value only)
+
+// values for change side for custom elements
+#define CH_SIDE_NONE MV_NONE
+#define CH_SIDE_LEFT MV_LEFT
+#define CH_SIDE_RIGHT MV_RIGHT
+#define CH_SIDE_TOP MV_UP
+#define CH_SIDE_BOTTOM MV_DOWN
+#define CH_SIDE_LEFT_RIGHT MV_HORIZONTAL
+#define CH_SIDE_TOP_BOTTOM MV_VERTICAL
+#define CH_SIDE_ANY MV_ANY_DIRECTION
+
+// values for change player for custom elements
+#define CH_PLAYER_NONE PLAYER_BITS_NONE
+#define CH_PLAYER_1 PLAYER_BITS_1
+#define CH_PLAYER_2 PLAYER_BITS_2
+#define CH_PLAYER_3 PLAYER_BITS_3
+#define CH_PLAYER_4 PLAYER_BITS_4
+#define CH_PLAYER_ANY PLAYER_BITS_ANY
+
+// values for change page for custom elements
+#define CH_PAGE_ANY_FILE (0xff)
+#define CH_PAGE_ANY (0xffffffff)
+
+// values for change power for custom elements
+#define CP_WHEN_EMPTY 0
+#define CP_WHEN_DIGGABLE 1
+#define CP_WHEN_DESTRUCTIBLE 2
+#define CP_WHEN_COLLECTIBLE 3
+#define CP_WHEN_REMOVABLE 4
+#define CP_WHEN_WALKABLE 5
+
+// values for change actions for custom elements (stored in level file)
+#define CA_NO_ACTION 0
+#define CA_EXIT_PLAYER 1
+#define CA_KILL_PLAYER 2
+#define CA_MOVE_PLAYER 3
+#define CA_RESTART_LEVEL 4
+#define CA_SHOW_ENVELOPE 5
+#define CA_SET_LEVEL_TIME 6
+#define CA_SET_LEVEL_GEMS 7
+#define CA_SET_LEVEL_SCORE 8
+#define CA_SET_LEVEL_WIND 9
+#define CA_SET_PLAYER_GRAVITY 10
+#define CA_SET_PLAYER_KEYS 11
+#define CA_SET_PLAYER_SPEED 12
+#define CA_SET_PLAYER_SHIELD 13
+#define CA_SET_PLAYER_ARTWORK 14
+#define CA_SET_CE_SCORE 15
+#define CA_SET_CE_VALUE 16
+#define CA_SET_ENGINE_SCAN_MODE 17
+#define CA_SET_PLAYER_INVENTORY 18
+#define CA_SET_CE_ARTWORK 19
+#define CA_SET_LEVEL_RANDOM_SEED 20
+#define CA_MOVE_PLAYER_NEW 21
+
+#define CA_HEADLINE_LEVEL_ACTIONS 250
+#define CA_HEADLINE_PLAYER_ACTIONS 251
+#define CA_HEADLINE_CE_ACTIONS 252
+#define CA_HEADLINE_ENGINE_ACTIONS 253
+#define CA_UNDEFINED 255
+
+// values for change action mode for custom elements
+#define CA_MODE_UNDEFINED 0
+#define CA_MODE_SET 1
+#define CA_MODE_ADD 2
+#define CA_MODE_SUBTRACT 3
+#define CA_MODE_MULTIPLY 4
+#define CA_MODE_DIVIDE 5
+#define CA_MODE_MODULO 6
+
+// values for change action parameters for custom elements
+#define CA_ARG_MIN 0
+#define CA_ARG_0 0
+#define CA_ARG_1 1
+#define CA_ARG_2 2
+#define CA_ARG_3 3
+#define CA_ARG_4 4
+#define CA_ARG_5 5
+#define CA_ARG_6 6
+#define CA_ARG_7 7
+#define CA_ARG_8 8
+#define CA_ARG_9 9
+#define CA_ARG_10 10
+#define CA_ARG_100 100
+#define CA_ARG_1000 1000
+#define CA_ARG_MAX 9999
+#define CA_ARG_PLAYER 10000
+#define CA_ARG_PLAYER_1 (CA_ARG_PLAYER + PLAYER_BITS_1)
+#define CA_ARG_PLAYER_2 (CA_ARG_PLAYER + PLAYER_BITS_2)
+#define CA_ARG_PLAYER_3 (CA_ARG_PLAYER + PLAYER_BITS_3)
+#define CA_ARG_PLAYER_4 (CA_ARG_PLAYER + PLAYER_BITS_4)
+#define CA_ARG_PLAYER_ANY (CA_ARG_PLAYER + PLAYER_BITS_ANY)
+#define CA_ARG_PLAYER_TRIGGER (CA_ARG_PLAYER + PLAYER_BITS_TRIGGER)
+#define CA_ARG_PLAYER_ACTION (CA_ARG_PLAYER + PLAYER_BITS_ACTION)
+#define CA_ARG_PLAYER_HEADLINE (CA_ARG_PLAYER + 999)
+#define CA_ARG_NUMBER 11000
+#define CA_ARG_NUMBER_MIN (CA_ARG_NUMBER + 0)
+#define CA_ARG_NUMBER_MAX (CA_ARG_NUMBER + 1)
+#define CA_ARG_NUMBER_RESET (CA_ARG_NUMBER + 2)
+#define CA_ARG_NUMBER_CE_SCORE (CA_ARG_NUMBER + 3)
+#define CA_ARG_NUMBER_CE_VALUE (CA_ARG_NUMBER + 4)
+#define CA_ARG_NUMBER_CE_DELAY (CA_ARG_NUMBER + 5)
+#define CA_ARG_NUMBER_LEVEL_TIME (CA_ARG_NUMBER + 6)
+#define CA_ARG_NUMBER_LEVEL_GEMS (CA_ARG_NUMBER + 7)
+#define CA_ARG_NUMBER_LEVEL_SCORE (CA_ARG_NUMBER + 8)
+#define CA_ARG_NUMBER_HEADLINE (CA_ARG_NUMBER + 999)
+#define CA_ARG_ELEMENT 12000
+#define CA_ARG_ELEMENT_RESET (CA_ARG_ELEMENT + 0)
+#define CA_ARG_ELEMENT_TARGET (CA_ARG_ELEMENT + 1)
+#define CA_ARG_ELEMENT_TRIGGER (CA_ARG_ELEMENT + 2)
+#define CA_ARG_ELEMENT_ACTION (CA_ARG_ELEMENT + 7)
+#define CA_ARG_ELEMENT_HEADLINE (CA_ARG_ELEMENT + 997)
+#define CA_ARG_ELEMENT_CV_TARGET (CA_ARG_ELEMENT_TARGET)
+#define CA_ARG_ELEMENT_CV_TRIGGER (CA_ARG_ELEMENT_TRIGGER)
+#define CA_ARG_ELEMENT_CV_ACTION (CA_ARG_ELEMENT_ACTION)
+#define CA_ARG_ELEMENT_CV_HEADLINE (CA_ARG_ELEMENT_HEADLINE)
+#define CA_ARG_ELEMENT_NR_TARGET (CA_ARG_ELEMENT + 3)
+#define CA_ARG_ELEMENT_NR_TRIGGER (CA_ARG_ELEMENT + 4)
+#define CA_ARG_ELEMENT_NR_ACTION (CA_ARG_ELEMENT + 8)
+#define CA_ARG_ELEMENT_NR_HEADLINE (CA_ARG_ELEMENT + 998)
+#define CA_ARG_ELEMENT_CS_TARGET (CA_ARG_ELEMENT + 5)
+#define CA_ARG_ELEMENT_CS_TRIGGER (CA_ARG_ELEMENT + 6)
+#define CA_ARG_ELEMENT_CS_ACTION (CA_ARG_ELEMENT + 9)
+#define CA_ARG_ELEMENT_CS_HEADLINE (CA_ARG_ELEMENT + 999)
+#define CA_ARG_SPEED 13000
+#define CA_ARG_SPEED_NOT_MOVING (CA_ARG_SPEED + STEPSIZE_NOT_MOVING)
+#define CA_ARG_SPEED_VERY_SLOW (CA_ARG_SPEED + STEPSIZE_VERY_SLOW)
+#define CA_ARG_SPEED_SLOW (CA_ARG_SPEED + STEPSIZE_SLOW)
+#define CA_ARG_SPEED_NORMAL (CA_ARG_SPEED + STEPSIZE_NORMAL)
+#define CA_ARG_SPEED_FAST (CA_ARG_SPEED + STEPSIZE_FAST)
+#define CA_ARG_SPEED_VERY_FAST (CA_ARG_SPEED + STEPSIZE_VERY_FAST)
+#define CA_ARG_SPEED_EVEN_FASTER (CA_ARG_SPEED + STEPSIZE_EVEN_FASTER)
+#define CA_ARG_SPEED_SLOWER (CA_ARG_SPEED + STEPSIZE_SLOWER)
+#define CA_ARG_SPEED_FASTER (CA_ARG_SPEED + STEPSIZE_FASTER)
+#define CA_ARG_SPEED_RESET (CA_ARG_SPEED + STEPSIZE_RESET)
+#define CA_ARG_SPEED_HEADLINE (CA_ARG_SPEED + 999)
+#define CA_ARG_GRAVITY 14000
+#define CA_ARG_GRAVITY_OFF (CA_ARG_GRAVITY + 0)
+#define CA_ARG_GRAVITY_ON (CA_ARG_GRAVITY + 1)
+#define CA_ARG_GRAVITY_TOGGLE (CA_ARG_GRAVITY + 2)
+#define CA_ARG_GRAVITY_HEADLINE (CA_ARG_GRAVITY + 999)
+#define CA_ARG_DIRECTION 15000
+#define CA_ARG_DIRECTION_NONE (CA_ARG_DIRECTION + MV_NONE)
+#define CA_ARG_DIRECTION_LEFT (CA_ARG_DIRECTION + MV_LEFT)
+#define CA_ARG_DIRECTION_RIGHT (CA_ARG_DIRECTION + MV_RIGHT)
+#define CA_ARG_DIRECTION_UP (CA_ARG_DIRECTION + MV_UP)
+#define CA_ARG_DIRECTION_DOWN (CA_ARG_DIRECTION + MV_DOWN)
+#define CA_ARG_DIRECTION_TRIGGER (CA_ARG_DIRECTION + MV_TRIGGER)
+#define CA_ARG_DIRECTION_TRIGGER_BACK (CA_ARG_DIRECTION + MV_TRIGGER_BACK)
+#define CA_ARG_DIRECTION_HEADLINE (CA_ARG_DIRECTION + 999)
+#define CA_ARG_SHIELD 16000
+#define CA_ARG_SHIELD_OFF (CA_ARG_SHIELD + 0)
+#define CA_ARG_SHIELD_NORMAL (CA_ARG_SHIELD + 1)
+#define CA_ARG_SHIELD_DEADLY (CA_ARG_SHIELD + 2)
+#define CA_ARG_SHIELD_HEADLINE (CA_ARG_SHIELD + 999)
+#define CA_ARG_SCAN_MODE 17000
+#define CA_ARG_SCAN_MODE_NORMAL (CA_ARG_SCAN_MODE + MV_NORMAL)
+#define CA_ARG_SCAN_MODE_REVERSE (CA_ARG_SCAN_MODE + MV_REVERSE)
+#define CA_ARG_SCAN_MODE_HEADLINE (CA_ARG_SCAN_MODE + 999)
+#define CA_ARG_INVENTORY 18000
+#define CA_ARG_INVENTORY_RESET (CA_ARG_INVENTORY + 0)
+#define CA_ARG_INVENTORY_RM_TARGET (CA_ARG_INVENTORY + 1)
+#define CA_ARG_INVENTORY_RM_TRIGGER (CA_ARG_INVENTORY + 2)
+#define CA_ARG_INVENTORY_RM_ACTION (CA_ARG_INVENTORY + 3)
+#define CA_ARG_INVENTORY_RM_FIRST (CA_ARG_INVENTORY + 4)
+#define CA_ARG_INVENTORY_RM_LAST (CA_ARG_INVENTORY + 5)
+#define CA_ARG_INVENTORY_RM_ALL (CA_ARG_INVENTORY + 6)
+#define CA_ARG_INVENTORY_HEADLINE (CA_ARG_INVENTORY + 998)
+#define CA_ARG_INVENTORY_RM_HEADLINE (CA_ARG_INVENTORY + 999)
+#define CA_ARG_UNDEFINED 65535
+
+// values for custom move patterns (bits 0 - 3: basic move directions)
+#define MV_BIT_TOWARDS_PLAYER 4
+#define MV_BIT_AWAY_FROM_PLAYER 5
+#define MV_BIT_ALONG_LEFT_SIDE 6
+#define MV_BIT_ALONG_RIGHT_SIDE 7
+#define MV_BIT_TURNING_LEFT 8
+#define MV_BIT_TURNING_RIGHT 9
+#define MV_BIT_WHEN_PUSHED 10
+#define MV_BIT_MAZE_RUNNER 11
+#define MV_BIT_MAZE_HUNTER 12
+#define MV_BIT_WHEN_DROPPED 13
+#define MV_BIT_TURNING_LEFT_RIGHT 14
+#define MV_BIT_TURNING_RIGHT_LEFT 15
+#define MV_BIT_TURNING_RANDOM 16
+#define MV_BIT_WIND_DIRECTION 17
+
+// values for custom move patterns
+#define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER)
+#define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER)
+#define MV_ALONG_LEFT_SIDE (1 << MV_BIT_ALONG_LEFT_SIDE)
+#define MV_ALONG_RIGHT_SIDE (1 << MV_BIT_ALONG_RIGHT_SIDE)
+#define MV_TURNING_LEFT (1 << MV_BIT_TURNING_LEFT)
+#define MV_TURNING_RIGHT (1 << MV_BIT_TURNING_RIGHT)
+#define MV_WHEN_PUSHED (1 << MV_BIT_WHEN_PUSHED)
+#define MV_MAZE_RUNNER (1 << MV_BIT_MAZE_RUNNER)
+#define MV_MAZE_HUNTER (1 << MV_BIT_MAZE_HUNTER)
+#define MV_MAZE_RUNNER_STYLE (MV_MAZE_RUNNER | MV_MAZE_HUNTER)
+#define MV_WHEN_DROPPED (1 << MV_BIT_WHEN_DROPPED)
+#define MV_TURNING_LEFT_RIGHT (1 << MV_BIT_TURNING_LEFT_RIGHT)
+#define MV_TURNING_RIGHT_LEFT (1 << MV_BIT_TURNING_RIGHT_LEFT)
+#define MV_TURNING_RANDOM (1 << MV_BIT_TURNING_RANDOM)
+#define MV_WIND_DIRECTION (1 << MV_BIT_WIND_DIRECTION)
+
+// values for initial move direction
+#define MV_START_NONE (MV_NONE)
+#define MV_START_AUTOMATIC (MV_NONE)
+#define MV_START_LEFT (MV_LEFT)
+#define MV_START_RIGHT (MV_RIGHT)
+#define MV_START_UP (MV_UP)
+#define MV_START_DOWN (MV_DOWN)
+#define MV_START_RANDOM (MV_ALL_DIRECTIONS)
+#define MV_START_PREVIOUS (MV_PREVIOUS)
+
+// values for elements left behind by custom elements
+#define LEAVE_TYPE_UNLIMITED 0
+#define LEAVE_TYPE_LIMITED 1
+
+// values for slippery property for custom elements
+#define SLIPPERY_ANY_RANDOM 0
+#define SLIPPERY_ANY_LEFT_RIGHT 1
+#define SLIPPERY_ANY_RIGHT_LEFT 2
+#define SLIPPERY_ONLY_LEFT 3
+#define SLIPPERY_ONLY_RIGHT 4
+
+// values for explosion type for custom elements
+#define EXPLODES_3X3 0
+#define EXPLODES_1X1 1
+#define EXPLODES_CROSS 2
+
+// macros for configurable properties
+#define IS_DIGGABLE(e) HAS_PROPERTY(e, EP_DIGGABLE)
+#define IS_COLLECTIBLE_ONLY(e) HAS_PROPERTY(e, EP_COLLECTIBLE_ONLY)
+#define DONT_RUN_INTO(e) HAS_PROPERTY(e, EP_DONT_RUN_INTO)
+#define DONT_COLLIDE_WITH(e) HAS_PROPERTY(e, EP_DONT_COLLIDE_WITH)
+#define DONT_TOUCH(e) HAS_PROPERTY(e, EP_DONT_TOUCH)
+#define IS_INDESTRUCTIBLE(e) HAS_PROPERTY(e, EP_INDESTRUCTIBLE)
+#define IS_SLIPPERY(e) HAS_PROPERTY(e, EP_SLIPPERY)
+#define CAN_CHANGE(e) HAS_PROPERTY(e, EP_CAN_CHANGE)
+#define CAN_MOVE(e) HAS_PROPERTY(e, EP_CAN_MOVE)
+#define CAN_FALL(e) HAS_PROPERTY(e, EP_CAN_FALL)
+#define CAN_SMASH_PLAYER(e) HAS_PROPERTY(e, EP_CAN_SMASH_PLAYER)
+#define CAN_SMASH_ENEMIES(e) HAS_PROPERTY(e, EP_CAN_SMASH_ENEMIES)
+#define CAN_SMASH_EVERYTHING(e) HAS_PROPERTY(e, EP_CAN_SMASH_EVERYTHING)
+#define EXPLODES_BY_FIRE(e) HAS_PROPERTY(e, EP_EXPLODES_BY_FIRE)
+#define EXPLODES_SMASHED(e) HAS_PROPERTY(e, EP_EXPLODES_SMASHED)
+#define EXPLODES_IMPACT(e) HAS_PROPERTY(e, EP_EXPLODES_IMPACT)
+#define IS_WALKABLE_OVER(e) HAS_PROPERTY(e, EP_WALKABLE_OVER)
+#define IS_WALKABLE_INSIDE(e) HAS_PROPERTY(e, EP_WALKABLE_INSIDE)
+#define IS_WALKABLE_UNDER(e) HAS_PROPERTY(e, EP_WALKABLE_UNDER)
+#define IS_PASSABLE_OVER(e) HAS_PROPERTY(e, EP_PASSABLE_OVER)
+#define IS_PASSABLE_INSIDE(e) HAS_PROPERTY(e, EP_PASSABLE_INSIDE)
+#define IS_PASSABLE_UNDER(e) HAS_PROPERTY(e, EP_PASSABLE_UNDER)
+#define IS_DROPPABLE(e) HAS_PROPERTY(e, EP_DROPPABLE)
+#define EXPLODES_1X1_OLD(e) HAS_PROPERTY(e, EP_EXPLODES_1X1_OLD)
+#define IS_PUSHABLE(e) HAS_PROPERTY(e, EP_PUSHABLE)
+#define EXPLODES_CROSS_OLD(e) HAS_PROPERTY(e, EP_EXPLODES_CROSS_OLD)
+#define IS_PROTECTED(e) HAS_PROPERTY(e, EP_PROTECTED)
+#define CAN_MOVE_INTO_ACID(e) HAS_PROPERTY(e, EP_CAN_MOVE_INTO_ACID)
+#define IS_THROWABLE(e) HAS_PROPERTY(e, EP_THROWABLE)
+#define CAN_EXPLODE(e) HAS_PROPERTY(e, EP_CAN_EXPLODE)
+#define IS_GRAVITY_REACHABLE(e) HAS_PROPERTY(e, EP_GRAVITY_REACHABLE)
+#define DONT_GET_HIT_BY(e) HAS_PROPERTY(e, EP_DONT_GET_HIT_BY)
+
+// macros for special configurable properties
+#define IS_EM_SLIPPERY_WALL(e) HAS_PROPERTY(e, EP_EM_SLIPPERY_WALL)
+
+// macros for special graphics properties
+#define GFX_CRUMBLED(e) HAS_PROPERTY(GFX_ELEMENT(e), EP_GFX_CRUMBLED)
+
+// macros for pre-defined properties
+#define ELEM_IS_PLAYER(e) HAS_PROPERTY(e, EP_PLAYER)
+#define CAN_PASS_MAGIC_WALL(e) HAS_PROPERTY(e, EP_CAN_PASS_MAGIC_WALL)
+#define CAN_PASS_DC_MAGIC_WALL(e) HAS_PROPERTY(e, EP_CAN_PASS_DC_MAGIC_WALL)
+#define IS_SWITCHABLE(e) HAS_PROPERTY(e, EP_SWITCHABLE)
+#define IS_BD_ELEMENT(e) HAS_PROPERTY(e, EP_BD_ELEMENT)
+#define IS_SP_ELEMENT(e) HAS_PROPERTY(e, EP_SP_ELEMENT)
+#define IS_SB_ELEMENT(e) HAS_PROPERTY(e, EP_SB_ELEMENT)
+#define IS_GEM(e) HAS_PROPERTY(e, EP_GEM)
+#define IS_FOOD_DARK_YAMYAM(e) HAS_PROPERTY(e, EP_FOOD_DARK_YAMYAM)
+#define IS_FOOD_PENGUIN(e) HAS_PROPERTY(e, EP_FOOD_PENGUIN)
+#define IS_FOOD_PIG(e) HAS_PROPERTY(e, EP_FOOD_PIG)
+#define IS_HISTORIC_WALL(e) HAS_PROPERTY(e, EP_HISTORIC_WALL)
+#define IS_HISTORIC_SOLID(e) HAS_PROPERTY(e, EP_HISTORIC_SOLID)
+#define IS_CLASSIC_ENEMY(e) HAS_PROPERTY(e, EP_CLASSIC_ENEMY)
+#define IS_BELT(e) HAS_PROPERTY(e, EP_BELT)
+#define IS_BELT_ACTIVE(e) HAS_PROPERTY(e, EP_BELT_ACTIVE)
+#define IS_BELT_SWITCH(e) HAS_PROPERTY(e, EP_BELT_SWITCH)
+#define IS_TUBE(e) HAS_PROPERTY(e, EP_TUBE)
+#define IS_ACID_POOL(e) HAS_PROPERTY(e, EP_ACID_POOL)
+#define IS_KEYGATE(e) HAS_PROPERTY(e, EP_KEYGATE)
+#define IS_AMOEBOID(e) HAS_PROPERTY(e, EP_AMOEBOID)
+#define IS_AMOEBALIVE(e) HAS_PROPERTY(e, EP_AMOEBALIVE)
+#define HAS_EDITOR_CONTENT(e) HAS_PROPERTY(e, EP_HAS_EDITOR_CONTENT)
+#define CAN_TURN_EACH_MOVE(e) HAS_PROPERTY(e, EP_CAN_TURN_EACH_MOVE)
+#define CAN_GROW(e) HAS_PROPERTY(e, EP_CAN_GROW)
+#define IS_ACTIVE_BOMB(e) HAS_PROPERTY(e, EP_ACTIVE_BOMB)
+#define IS_INACTIVE(e) HAS_PROPERTY(e, EP_INACTIVE)
+
+// macros for derived properties
+#define IS_ACCESSIBLE_OVER(e) HAS_PROPERTY(e, EP_ACCESSIBLE_OVER)
+#define IS_ACCESSIBLE_INSIDE(e) HAS_PROPERTY(e, EP_ACCESSIBLE_INSIDE)
+#define IS_ACCESSIBLE_UNDER(e) HAS_PROPERTY(e, EP_ACCESSIBLE_UNDER)
+#define IS_WALKABLE(e) HAS_PROPERTY(e, EP_WALKABLE)
+#define IS_PASSABLE(e) HAS_PROPERTY(e, EP_PASSABLE)
+#define IS_ACCESSIBLE(e) HAS_PROPERTY(e, EP_ACCESSIBLE)
+#define IS_COLLECTIBLE(e) HAS_PROPERTY(e, EP_COLLECTIBLE)
+#define IS_SNAPPABLE(e) HAS_PROPERTY(e, EP_SNAPPABLE)
+#define IS_WALL(e) HAS_PROPERTY(e, EP_WALL)
+#define IS_SOLID_FOR_PUSHING(e) HAS_PROPERTY(e, EP_SOLID_FOR_PUSHING)
+#define IS_DRAGONFIRE_PROOF(e) HAS_PROPERTY(e, EP_DRAGONFIRE_PROOF)
+#define IS_EXPLOSION_PROOF(e) HAS_PROPERTY(e, EP_EXPLOSION_PROOF)
+#define CAN_SMASH(e) HAS_PROPERTY(e, EP_CAN_SMASH)
+#define EXPLODES_3X3_OLD(e) HAS_PROPERTY(e, EP_EXPLODES_3X3_OLD)
+#define CAN_EXPLODE_BY_FIRE(e) HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_FIRE)
+#define CAN_EXPLODE_SMASHED(e) HAS_PROPERTY(e, EP_CAN_EXPLODE_SMASHED)
+#define CAN_EXPLODE_IMPACT(e) HAS_PROPERTY(e, EP_CAN_EXPLODE_IMPACT)
+#define IS_SP_PORT(e) HAS_PROPERTY(e, EP_SP_PORT)
+#define CAN_EXPLODE_BY_DRAGONFIRE(e) \
+ HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_DRAGONFIRE)
+#define CAN_EXPLODE_BY_EXPLOSION(e) \
+ HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_EXPLOSION)
+#define COULD_MOVE_INTO_ACID(e) HAS_PROPERTY(e, EP_COULD_MOVE_INTO_ACID)
+#define MAYBE_DONT_COLLIDE_WITH(e) HAS_PROPERTY(e, EP_MAYBE_DONT_COLLIDE_WITH)
+#define CAN_BE_CLONED_BY_ANDROID(e) \
+ HAS_PROPERTY(e, EP_CAN_BE_CLONED_BY_ANDROID)
+
+#define IS_EDITOR_CASCADE(e) HAS_PROPERTY(e, EP_EDITOR_CASCADE)
+#define IS_EDITOR_CASCADE_ACTIVE(e) \
+ HAS_PROPERTY(e, EP_EDITOR_CASCADE_ACTIVE)
+#define IS_EDITOR_CASCADE_INACTIVE(e) \
+ HAS_PROPERTY(e, EP_EDITOR_CASCADE_INACTIVE)
+
+#define HAS_ACTION(e) HAS_PROPERTY(e, EP_HAS_ACTION)
+#define CAN_CHANGE_OR_HAS_ACTION(e) \
+ HAS_PROPERTY(e, EP_CAN_CHANGE_OR_HAS_ACTION)
+
+#define IS_OBSOLETE(e) HAS_PROPERTY(e, EP_OBSOLETE)
+
+// special macros used in game engine
+#define IS_FILE_ELEMENT(e) ((e) >= 0 && \
+ (e) <= NUM_FILE_ELEMENTS)
+
+#define IS_DRAWABLE_ELEMENT(e) ((e) >= 0 && \
+ (e) <= NUM_DRAWABLE_ELEMENTS)
+
+#define IS_RUNTIME_ELEMENT(e) ((e) >= 0 && \
+ (e) <= NUM_RUNTIME_ELEMENTS)
+
+#define IS_VALID_ELEMENT(e) ((e) >= 0 && \
+ (e) <= MAX_NUM_ELEMENTS)
+
+#define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \
+ (e) <= EL_CUSTOM_END)
+
+#define IS_GROUP_ELEMENT(e) ((e) >= EL_GROUP_START && \
+ (e) <= EL_GROUP_END)
+
+#define IS_CLIPBOARD_ELEMENT(e) ((e) >= EL_INTERNAL_CLIPBOARD_START && \
+ (e) <= EL_INTERNAL_CLIPBOARD_END)
+
+#define IS_INTERNAL_ELEMENT(e) ((e) >= EL_INTERNAL_START && \
+ (e) <= EL_INTERNAL_END)
+
+#define IS_MM_ELEMENT(e) ((e) >= EL_MM_START && \
+ (e) <= EL_MM_END)
+
+#define IS_DF_ELEMENT(e) ((e) >= EL_DF_START && \
+ (e) <= EL_DF_END)
+
+#define IS_MM_MCDUFFIN(e) ((e) >= EL_MM_MCDUFFIN_START && \
+ (e) <= EL_MM_MCDUFFIN_END)
+
+#define IS_DF_LASER(e) ((e) >= EL_DF_LASER_START && \
+ (e) <= EL_DF_LASER_END)
+
+#define IS_MM_WALL(e) (((e) >= EL_MM_WALL_START && \
+ (e) <= EL_MM_WALL_END) || \
+ ((e) >= EL_DF_WALL_START && \
+ (e) <= EL_DF_WALL_END))
+
+#define IS_DF_WALL(e) ((e) >= EL_DF_WALL_START && \
+ (e) <= EL_DF_WALL_END)
+
+#define IS_MM_WALL_EDITOR(e) ((e) == EL_MM_STEEL_WALL || \
+ (e) == EL_MM_WOODEN_WALL || \
+ (e) == EL_MM_ICE_WALL || \
+ (e) == EL_MM_AMOEBA_WALL || \
+ (e) == EL_DF_STEEL_WALL || \
+ (e) == EL_DF_WOODEN_WALL)
+
+#define IS_ENVELOPE(e) ((e) >= EL_ENVELOPE_1 && \
+ (e) <= EL_ENVELOPE_4)
+
+#define IS_BALLOON_ELEMENT(e) ((e) == EL_BALLOON || \
+ (e) == EL_BALLOON_SWITCH_LEFT || \
+ (e) == EL_BALLOON_SWITCH_RIGHT || \
+ (e) == EL_BALLOON_SWITCH_UP || \
+ (e) == EL_BALLOON_SWITCH_DOWN || \
+ (e) == EL_BALLOON_SWITCH_ANY || \
+ (e) == EL_BALLOON_SWITCH_NONE)
+
+#define IS_RND_KEY(e) ((e) >= EL_KEY_1 && \
+ (e) <= EL_KEY_4)
+#define IS_EM_KEY(e) ((e) >= EL_EM_KEY_1 && \
+ (e) <= EL_EM_KEY_4)
+#define IS_EMC_KEY(e) ((e) >= EL_EMC_KEY_5 && \
+ (e) <= EL_EMC_KEY_8)
+#define IS_KEY(e) (IS_RND_KEY(e) || \
+ IS_EM_KEY(e) || \
+ IS_EMC_KEY(e))
+#define RND_KEY_NR(e) ((e) - EL_KEY_1)
+#define EM_KEY_NR(e) ((e) - EL_EM_KEY_1)
+#define EMC_KEY_NR(e) ((e) - EL_EMC_KEY_5 + 4)
+#define KEY_NR(e) (IS_RND_KEY(e) ? RND_KEY_NR(e) : \
+ IS_EM_KEY(e) ? EM_KEY_NR(e) : \
+ IS_EMC_KEY(e) ? EMC_KEY_NR(e) : 0)
+
+#define IS_RND_GATE(e) ((e) >= EL_GATE_1 && \
+ (e) <= EL_GATE_4)
+#define IS_EM_GATE(e) ((e) >= EL_EM_GATE_1 && \
+ (e) <= EL_EM_GATE_4)
+#define IS_EMC_GATE(e) ((e) >= EL_EMC_GATE_5 && \
+ (e) <= EL_EMC_GATE_8)
+#define IS_DC_GATE(e) ((e) == EL_DC_GATE_WHITE)
+#define IS_GATE(e) (IS_RND_GATE(e) || \
+ IS_EM_GATE(e) || \
+ IS_EMC_GATE(e) || \
+ IS_DC_GATE(e))
+#define RND_GATE_NR(e) ((e) - EL_GATE_1)
+#define EM_GATE_NR(e) ((e) - EL_EM_GATE_1)
+#define EMC_GATE_NR(e) ((e) - EL_EMC_GATE_5 + 4)
+#define GATE_NR(e) (IS_RND_GATE(e) ? RND_GATE_NR(e) : \
+ IS_EM_GATE(e) ? EM_GATE_NR(e) : \
+ IS_EMC_GATE(e) ? EMC_GATE_NR(e) : 0)
+
+#define IS_RND_GATE_GRAY(e) ((e) >= EL_GATE_1_GRAY && \
+ (e) <= EL_GATE_4_GRAY)
+#define IS_RND_GATE_GRAY_ACTIVE(e) ((e) >= EL_GATE_1_GRAY_ACTIVE && \
+ (e) <= EL_GATE_4_GRAY_ACTIVE)
+#define IS_EM_GATE_GRAY(e) ((e) >= EL_EM_GATE_1_GRAY && \
+ (e) <= EL_EM_GATE_4_GRAY)
+#define IS_EM_GATE_GRAY_ACTIVE(e) ((e) >= EL_EM_GATE_1_GRAY_ACTIVE && \
+ (e) <= EL_EM_GATE_4_GRAY_ACTIVE)
+#define IS_EMC_GATE_GRAY(e) ((e) >= EL_EMC_GATE_5_GRAY && \
+ (e) <= EL_EMC_GATE_8_GRAY)
+#define IS_EMC_GATE_GRAY_ACTIVE(e) ((e) >= EL_EMC_GATE_5_GRAY_ACTIVE && \
+ (e) <= EL_EMC_GATE_8_GRAY_ACTIVE)
+#define IS_DC_GATE_GRAY(e) ((e) == EL_DC_GATE_WHITE_GRAY)
+#define IS_DC_GATE_GRAY_ACTIVE(e) ((e) == EL_DC_GATE_WHITE_GRAY_ACTIVE)
+
+#define IS_GATE_GRAY(e) (IS_RND_GATE_GRAY(e) || \
+ IS_EM_GATE_GRAY(e) || \
+ IS_EMC_GATE_GRAY(e) || \
+ IS_DC_GATE_GRAY(e))
+#define IS_GATE_GRAY_ACTIVE(e) (IS_RND_GATE_GRAY_ACTIVE(e) || \
+ IS_EM_GATE_GRAY_ACTIVE(e) || \
+ IS_EMC_GATE_GRAY_ACTIVE(e) || \
+ IS_DC_GATE_GRAY_ACTIVE(e))
+#define RND_GATE_GRAY_NR(e) ((e) - EL_GATE_1_GRAY)
+#define RND_GATE_GRAY_ACTIVE_NR(e) ((e) - EL_GATE_1_GRAY_ACTIVE)
+#define EM_GATE_GRAY_NR(e) ((e) - EL_EM_GATE_1_GRAY)
+#define EM_GATE_GRAY_ACTIVE_NR(e) ((e) - EL_EM_GATE_1_GRAY_ACTIVE)
+#define EMC_GATE_GRAY_NR(e) ((e) - EL_EMC_GATE_5_GRAY + 4)
+#define EMC_GATE_GRAY_ACTIVE_NR(e) ((e) - EL_EMC_GATE_5_GRAY_ACTIVE + 4)
+#define GATE_GRAY_NR(e) (IS_RND_GATE_GRAY(e) ? RND_GATE_GRAY_NR(e) : \
+ IS_EM_GATE_GRAY(e) ? EM_GATE_GRAY_NR(e) : \
+ IS_EMC_GATE_GRAY(e) ? EMC_GATE_GRAY_NR(e) : 0)
+
+#define IS_ACID_POOL_OR_ACID(e) (IS_ACID_POOL(e) || (e) == EL_ACID)
+
+#define IS_EMC_PILLAR(e) ((e) >= EL_EMC_WALL_1 && \
+ (e) <= EL_EMC_WALL_3)
+#define IS_SP_CHIP(e) ((e) == EL_SP_CHIP_SINGLE || \
+ (e) == EL_SP_CHIP_LEFT || \
+ (e) == EL_SP_CHIP_RIGHT || \
+ (e) == EL_SP_CHIP_TOP || \
+ (e) == EL_SP_CHIP_BOTTOM)
+#define IS_SP_HARDWARE_BASE(e) ((e) == EL_SP_HARDWARE_BASE_1 || \
+ (e) == EL_SP_HARDWARE_BASE_2 || \
+ (e) == EL_SP_HARDWARE_BASE_3 || \
+ (e) == EL_SP_HARDWARE_BASE_4 || \
+ (e) == EL_SP_HARDWARE_BASE_5 || \
+ (e) == EL_SP_HARDWARE_BASE_6)
+
+#define IS_DC_STEELWALL_2(e) ((e) >= EL_DC_STEELWALL_2_LEFT && \
+ (e) <= EL_DC_STEELWALL_2_SINGLE)
+
+// !!! IMPROVE THIS !!!
+#define IS_EM_ELEMENT(e) (map_element_EM_to_RND_cave(map_element_RND_to_EM_cave(e)) == (e))
+
+#define MM_WALL_BASE(e) ((e) & 0xfff0)
+#define MM_WALL_BITS(e) ((e) & 0x000f)
+
+#define GFX_ELEMENT(e) (element_info[e].gfx_element)
+
+// !!! CHECK THIS !!!
+#if 1
+#define TILE_GFX_ELEMENT(x, y) \
+ (GfxElement[x][y] != EL_UNDEFINED && \
+ Tile[x][y] != EL_EXPLOSION ? \
+ GfxElement[x][y] : Tile[x][y])
+#else
+#define TILE_GFX_ELEMENT(x, y) \
+ GFX_ELEMENT(GfxElement[x][y] != EL_UNDEFINED && \
+ Tile[x][y] != EL_EXPLOSION ? \
+ GfxElement[x][y] : Tile[x][y])
+#endif
+
+// !!! "use sound" deactivated due to problems with level "bug machine" !!!
+// (solution: add separate "use sound of element" to level file and editor)
+#if 0
+#define SND_ELEMENT(e) GFX_ELEMENT(e)
+#else
+#define SND_ELEMENT(e) (e)
+#endif
+
+#define GROUP_NR(e) ((e) - EL_GROUP_START)
+#define IS_IN_GROUP(e, nr) (element_info[e].in_group[nr] == TRUE)
+#define IS_IN_GROUP_EL(e, ge) (IS_IN_GROUP(e, (ge) - EL_GROUP_START))
+
+#define IS_EQUAL_OR_IN_GROUP(e, ge) \
+ (ge == EL_ANY_ELEMENT ? TRUE : \
+ IS_GROUP_ELEMENT(ge) ? IS_IN_GROUP(e, GROUP_NR(ge)) : (e) == (ge))