rnd-20040918-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 18 Sep 2004 01:20:03 +0000 (03:20 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:48:00 +0000 (10:48 +0200)
14 files changed:
src/conftime.h
src/files.c
src/files.h
src/game.c
src/game_em/cave.c
src/game_em/game_em.h
src/game_em/global.h
src/game_em/graphics.c
src/game_em/input.c
src/game_em/main.c
src/game_em/main_em.h
src/game_em/tile.h
src/main.h
src/screens.c

index 1b27e57d24748ff8b9f299d88c619830caf965af..e0ae55e6462bec1008135e57be7b4cd0c1e60c8c 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-09-17 20:19]"
+#define COMPILE_DATE_STRING "[2004-09-18 03:18]"
index c684ab843bd5e854d309063eb5bd7c3b1d4ae616..4b4ddebd95e8b808c7f9005d410d9c64999b42b7 100644 (file)
@@ -114,6 +114,8 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
 
   int i, j, x, y;
 
+  level->native_em_level = &native_em_level;
+
   level->game_engine_type = GAME_ENGINE_TYPE_RND;
 
   level->file_version = FILE_VERSION_ACTUAL;
@@ -1765,11 +1767,764 @@ static void OLD_LoadLevelFromFileInfo_EM(struct LevelInfo *level,
 
 #else
 
+static int map_element_RND_to_EM(int element_rnd)
+{
+  static unsigned short mapping_RND_to_EM[NUM_FILE_ELEMENTS];
+  static boolean mapping_initialized = FALSE;
+
+  struct
+  {
+    int element_em;
+    int element_rnd;
+  }
+  mapping_RND_to_EM_list[] =
+  {
+    { Xblank,                  EL_EMPTY                        },
+    { Xstone,                  EL_ROCK                         },
+    { Xnut,                    EL_NUT                          },
+    { Xbug_n,                  EL_BUG_UP                       },
+    { Xbug_e,                  EL_BUG_RIGHT                    },
+    { Xbug_s,                  EL_BUG_DOWN                     },
+    { Xbug_w,                  EL_BUG_LEFT                     },
+    { Xtank_n,                 EL_SPACESHIP_UP                 },
+    { Xtank_e,                 EL_SPACESHIP_RIGHT              },
+    { Xtank_s,                 EL_SPACESHIP_DOWN               },
+    { Xtank_w,                 EL_SPACESHIP_LEFT               },
+    { Xandroid,                        EL_EMC_ANDROID                  },
+    { Xandroid_1_n,            EL_EMC_ANDROID_UP               },
+    { Xandroid_1_e,            EL_EMC_ANDROID_RIGHT            },
+    { Xandroid_1_w,            EL_EMC_ANDROID_LEFT             },
+    { Xandroid_1_s,            EL_EMC_ANDROID_DOWN             },
+    { Xspring,                 EL_SPRING                       },
+    { Xeater_n,                        EL_YAMYAM                       },
+    { Xalien,                  EL_ROBOT                        },
+    { Xemerald,                        EL_EMERALD                      },
+    { Xdiamond,                        EL_DIAMOND                      },
+    { Xdrip_fall,              EL_AMOEBA_DROP                  },
+    { Xbomb,                   EL_BOMB                         },
+    { Xballoon,                        EL_BALLOON                      },
+    { Xgrass,                  EL_EMC_GRASS                    },
+    { Xdirt,                   EL_SAND                         },
+    { Xacid_ne,                        EL_ACID_POOL_TOPRIGHT           },
+    { Xacid_se,                        EL_ACID_POOL_BOTTOMRIGHT        },
+    { Xacid_s,                 EL_ACID_POOL_BOTTOM             },
+    { Xacid_sw,                        EL_ACID_POOL_BOTTOMLEFT         },
+    { Xacid_nw,                        EL_ACID_POOL_TOPLEFT            },
+    { Xacid_1,                 EL_ACID                         },
+    { Xball_1,                 EL_EMC_GENERATOR_BALL           },
+    { Xgrow_ns,                        EL_EMC_GROW                     },
+    { Xwonderwall,             EL_MAGIC_WALL                   },
+    { Xameuba_1,               EL_AMOEBA_WET                   },
+    { Xdoor_1,                 EL_EM_GATE_1                    },
+    { Xdoor_2,                 EL_EM_GATE_2                    },
+    { Xdoor_3,                 EL_EM_GATE_3                    },
+    { Xdoor_4,                 EL_EM_GATE_4                    },
+    { Xdoor_5,                 EL_EMC_GATE_5                   },
+    { Xdoor_6,                 EL_EMC_GATE_6                   },
+    { Xdoor_7,                 EL_EMC_GATE_7                   },
+    { Xdoor_8,                 EL_EMC_GATE_8                   },
+    { Xkey_1,                  EL_EM_KEY_1                     },
+    { Xkey_2,                  EL_EM_KEY_2                     },
+    { Xkey_3,                  EL_EM_KEY_3                     },
+    { Xkey_4,                  EL_EM_KEY_4                     },
+    { Xkey_5,                  EL_EMC_KEY_5                    },
+    { Xkey_6,                  EL_EMC_KEY_6                    },
+    { Xkey_7,                  EL_EMC_KEY_7                    },
+    { Xkey_8,                  EL_EMC_KEY_8                    },
+    { Xwind_n,                 EL_BALLOON_SWITCH_UP            },
+    { Xwind_e,                 EL_BALLOON_SWITCH_RIGHT         },
+    { Xwind_s,                 EL_BALLOON_SWITCH_DOWN          },
+    { Xwind_w,                 EL_BALLOON_SWITCH_LEFT          },
+    { Xwind_nesw,              EL_BALLOON_SWITCH_ANY           },
+    { Xwind_stop,              EL_BALLOON_SWITCH_NONE          },
+    { Xexit,                   EL_EXIT_CLOSED                  },
+    { Xexit_1,                 EL_EXIT_OPEN                    },
+    { Xdynamite,               EL_DYNAMITE                     },
+    { Xdynamite_1,             EL_DYNAMITE_ACTIVE              },
+    { Xbumper,                 EL_EMC_BUMPER                   },
+    { Xwheel,                  EL_ROBOT_WHEEL                  },
+    { Xswitch,                 EL_UNKNOWN                      },
+    { Xsand,                   EL_QUICKSAND_EMPTY              },
+    { Xsand_stone,             EL_QUICKSAND_FULL               },
+    { Xplant,                  EL_EMC_PLANT                    },
+    { Xlenses,                 EL_EMC_LENSES                   },
+    { Xmagnify,                        EL_EMC_MAGNIFY                  },
+    { Xdripper,                        EL_UNKNOWN                      },
+    { Xfake_blank,             EL_INVISIBLE_WALL               },
+    { Xfake_grass,             EL_INVISIBLE_SAND               },
+    { Xfake_door_1,            EL_EM_GATE_1_GRAY               },
+    { Xfake_door_2,            EL_EM_GATE_2_GRAY               },
+    { Xfake_door_3,            EL_EM_GATE_3_GRAY               },
+    { Xfake_door_4,            EL_EM_GATE_4_GRAY               },
+    { Xfake_door_5,            EL_EMC_GATE_5_GRAY              },
+    { Xfake_door_6,            EL_EMC_GATE_6_GRAY              },
+    { Xfake_door_7,            EL_EMC_GATE_7_GRAY              },
+    { Xfake_door_8,            EL_EMC_GATE_8_GRAY              },
+    { Xsteel_1,                        EL_UNKNOWN                      },
+    { Xsteel_2,                        EL_UNKNOWN                      },
+    { Xsteel_3,                        EL_UNKNOWN                      },
+    { Xsteel_4,                        EL_UNKNOWN                      },
+    { Xwall_1,                 EL_UNKNOWN                      },
+    { Xwall_2,                 EL_UNKNOWN                      },
+    { Xwall_3,                 EL_UNKNOWN                      },
+    { Xwall_4,                 EL_UNKNOWN                      },
+    { Xround_wall_1,           EL_UNKNOWN                      },
+    { Xround_wall_2,           EL_UNKNOWN                      },
+    { Xround_wall_3,           EL_UNKNOWN                      },
+    { Xround_wall_4,           EL_UNKNOWN                      },
+    { Xdecor_1,                        EL_UNKNOWN                      },
+    { Xdecor_2,                        EL_UNKNOWN                      },
+    { Xdecor_3,                        EL_UNKNOWN                      },
+    { Xdecor_4,                        EL_UNKNOWN                      },
+    { Xdecor_5,                        EL_UNKNOWN                      },
+    { Xdecor_6,                        EL_UNKNOWN                      },
+    { Xdecor_7,                        EL_UNKNOWN                      },
+    { Xdecor_8,                        EL_UNKNOWN                      },
+    { Xdecor_9,                        EL_UNKNOWN                      },
+    { Xdecor_10,               EL_UNKNOWN                      },
+    { Xdecor_11,               EL_UNKNOWN                      },
+    { Xdecor_12,               EL_UNKNOWN                      },
+    { Xalpha_0,                        EL_CHAR('0')                    },
+    { Xalpha_1,                        EL_CHAR('1')                    },
+    { Xalpha_2,                        EL_CHAR('2')                    },
+    { Xalpha_3,                        EL_CHAR('3')                    },
+    { Xalpha_4,                        EL_CHAR('4')                    },
+    { Xalpha_5,                        EL_CHAR('5')                    },
+    { Xalpha_6,                        EL_CHAR('6')                    },
+    { Xalpha_7,                        EL_CHAR('7')                    },
+    { Xalpha_8,                        EL_CHAR('8')                    },
+    { Xalpha_9,                        EL_CHAR('9')                    },
+    { Xalpha_excla,            EL_CHAR('!')                    },
+    { Xalpha_quote,            EL_CHAR('"')                    },
+    { Xalpha_comma,            EL_CHAR(',')                    },
+    { Xalpha_minus,            EL_CHAR('-')                    },
+    { Xalpha_perio,            EL_CHAR('.')                    },
+    { Xalpha_colon,            EL_CHAR(':')                    },
+    { Xalpha_quest,            EL_CHAR('?')                    },
+    { Xalpha_a,                        EL_CHAR('A')                    },
+    { Xalpha_b,                        EL_CHAR('B')                    },
+    { Xalpha_c,                        EL_CHAR('C')                    },
+    { Xalpha_d,                        EL_CHAR('D')                    },
+    { Xalpha_e,                        EL_CHAR('E')                    },
+    { Xalpha_f,                        EL_CHAR('F')                    },
+    { Xalpha_g,                        EL_CHAR('G')                    },
+    { Xalpha_h,                        EL_CHAR('H')                    },
+    { Xalpha_i,                        EL_CHAR('I')                    },
+    { Xalpha_j,                        EL_CHAR('J')                    },
+    { Xalpha_k,                        EL_CHAR('K')                    },
+    { Xalpha_l,                        EL_CHAR('L')                    },
+    { Xalpha_m,                        EL_CHAR('M')                    },
+    { Xalpha_n,                        EL_CHAR('N')                    },
+    { Xalpha_o,                        EL_CHAR('O')                    },
+    { Xalpha_p,                        EL_CHAR('P')                    },
+    { Xalpha_q,                        EL_CHAR('Q')                    },
+    { Xalpha_r,                        EL_CHAR('R')                    },
+    { Xalpha_s,                        EL_CHAR('S')                    },
+    { Xalpha_t,                        EL_CHAR('T')                    },
+    { Xalpha_u,                        EL_CHAR('U')                    },
+    { Xalpha_v,                        EL_CHAR('V')                    },
+    { Xalpha_w,                        EL_CHAR('W')                    },
+    { Xalpha_x,                        EL_CHAR('X')                    },
+    { Xalpha_y,                        EL_CHAR('Y')                    },
+    { Xalpha_z,                        EL_CHAR('Z')                    },
+    { Xalpha_arrow_e,          EL_CHAR('>')                    },
+    { Xalpha_arrow_w,          EL_CHAR('<')                    },
+    { Xalpha_copyr,            EL_CHAR('©')                    },
+
+    { Zplayer,                 EL_PLAYER_1                     },
+    { Zplayer,                 EL_PLAYER_2                     },
+    { Zplayer,                 EL_PLAYER_3                     },
+    { Zplayer,                 EL_PLAYER_4                     },
+
+    { ZBORDER,                 EL_EMC_LEVEL_BORDER             },
+
+    { -1,                      -1                              }
+  };
+
+  if (!mapping_initialized)
+  {
+    int i;
+
+    /* return "Xalpha_quest" for all undefined elements in mapping array */
+    for (i = 0; i < NUM_FILE_ELEMENTS; i++)
+      mapping_RND_to_EM[i] = Xalpha_quest;
+
+    for (i = 0; mapping_RND_to_EM_list[i].element_rnd != -1; i++)
+      mapping_RND_to_EM[mapping_RND_to_EM_list[i].element_rnd] =
+       mapping_RND_to_EM_list[i].element_em;
+
+    mapping_initialized = TRUE;
+  }
+
+  if (element_rnd >= 0 && element_rnd < NUM_FILE_ELEMENTS)
+    return mapping_RND_to_EM[element_rnd];
+
+  Error(ERR_WARN, "invalid RND level element %d", element_rnd);
+
+  return EL_UNKNOWN;
+}
+
+static int map_element_EM_to_RND(int element_em)
+{
+  static unsigned short mapping_EM_to_RND[TILE_MAX];
+  static boolean mapping_initialized = FALSE;
+
+  struct
+  {
+    int element_em;
+    int element_rnd;
+  }
+  mapping_EM_to_RND_list[] =
+  {
+    { Xblank,                  EL_EMPTY                        },
+    { Yacid_splash_eB,         EL_EMPTY                        },
+    { Yacid_splash_wB,         EL_EMPTY                        },
+
+#ifdef EM_ENGINE_BAD_ROLL
+    { Xstone_force_e,          EL_ROCK                         },
+    { Xstone_force_w,          EL_ROCK                         },
+    { Xnut_force_e,            EL_NUT                          },
+    { Xnut_force_w,            EL_NUT                          },
+    { Xspring_force_e,         EL_SPRING                       },
+    { Xspring_force_w,         EL_SPRING                       },
+    { Xemerald_force_e,                EL_EMERALD                      },
+    { Xemerald_force_w,                EL_EMERALD                      },
+    { Xdiamond_force_e,                EL_DIAMOND                      },
+    { Xdiamond_force_w,                EL_DIAMOND                      },
+    { Xbomb_force_e,           EL_BOMB                         },
+    { Xbomb_force_w,           EL_BOMB                         },
+#endif
+
+    { Xstone,                  EL_ROCK                         },
+    { Xstone_pause,            EL_ROCK                         },
+    { Xstone_fall,             EL_ROCK                         },
+    { Ystone_s,                        EL_ROCK                         },
+    { Ystone_sB,               EL_ROCK                         },
+    { Ystone_e,                        EL_ROCK                         },
+    { Ystone_eB,               EL_ROCK                         },
+    { Ystone_w,                        EL_ROCK                         },
+    { Ystone_wB,               EL_ROCK                         },
+    { Xnut,                    EL_NUT                          },
+    { Xnut_pause,              EL_NUT                          },
+    { Xnut_fall,               EL_NUT                          },
+    { Ynut_s,                  EL_NUT                          },
+    { Ynut_sB,                 EL_NUT                          },
+    { Ynut_e,                  EL_NUT                          },
+    { Ynut_eB,                 EL_NUT                          },
+    { Ynut_w,                  EL_NUT                          },
+    { Ynut_wB,                 EL_NUT                          },
+    { Xbug_n,                  EL_BUG_UP                       },
+    { Xbug_e,                  EL_BUG_RIGHT                    },
+    { Xbug_s,                  EL_BUG_DOWN                     },
+    { Xbug_w,                  EL_BUG_LEFT                     },
+    { Xbug_gon,                        EL_BUG_UP                       },
+    { Xbug_goe,                        EL_BUG_RIGHT                    },
+    { Xbug_gos,                        EL_BUG_DOWN                     },
+    { Xbug_gow,                        EL_BUG_LEFT                     },
+    { Ybug_n,                  EL_BUG_UP                       },
+    { Ybug_nB,                 EL_BUG_UP                       },
+    { Ybug_e,                  EL_BUG_RIGHT                    },
+    { Ybug_eB,                 EL_BUG_RIGHT                    },
+    { Ybug_s,                  EL_BUG_DOWN                     },
+    { Ybug_sB,                 EL_BUG_DOWN                     },
+    { Ybug_w,                  EL_BUG_LEFT                     },
+    { Ybug_wB,                 EL_BUG_LEFT                     },
+    { Ybug_w_n,                        EL_BUG_UP                       },
+    { Ybug_n_e,                        EL_BUG_RIGHT                    },
+    { Ybug_e_s,                        EL_BUG_DOWN                     },
+    { Ybug_s_w,                        EL_BUG_LEFT                     },
+    { Ybug_e_n,                        EL_BUG_UP                       },
+    { Ybug_s_e,                        EL_BUG_RIGHT                    },
+    { Ybug_w_s,                        EL_BUG_DOWN                     },
+    { Ybug_n_w,                        EL_BUG_LEFT                     },
+    { Ybug_stone,              EL_ROCK                         },
+    { Ybug_spring,             EL_SPRING                       },
+    { Xtank_n,                 EL_SPACESHIP_UP                 },
+    { Xtank_e,                 EL_SPACESHIP_RIGHT              },
+    { Xtank_s,                 EL_SPACESHIP_DOWN               },
+    { Xtank_w,                 EL_SPACESHIP_LEFT               },
+    { Xtank_gon,               EL_SPACESHIP_UP                 },
+    { Xtank_goe,               EL_SPACESHIP_RIGHT              },
+    { Xtank_gos,               EL_SPACESHIP_DOWN               },
+    { Xtank_gow,               EL_SPACESHIP_LEFT               },
+    { Ytank_n,                 EL_SPACESHIP_UP                 },
+    { Ytank_nB,                        EL_SPACESHIP_UP                 },
+    { Ytank_e,                 EL_SPACESHIP_RIGHT              },
+    { Ytank_eB,                        EL_SPACESHIP_RIGHT              },
+    { Ytank_s,                 EL_SPACESHIP_DOWN               },
+    { Ytank_sB,                        EL_SPACESHIP_DOWN               },
+    { Ytank_w,                 EL_SPACESHIP_LEFT               },
+    { Ytank_wB,                        EL_SPACESHIP_LEFT               },
+    { Ytank_w_n,               EL_SPACESHIP_UP                 },
+    { Ytank_n_e,               EL_SPACESHIP_RIGHT              },
+    { Ytank_e_s,               EL_SPACESHIP_DOWN               },
+    { Ytank_s_w,               EL_SPACESHIP_LEFT               },
+    { Ytank_e_n,               EL_SPACESHIP_UP                 },
+    { Ytank_s_e,               EL_SPACESHIP_RIGHT              },
+    { Ytank_w_s,               EL_SPACESHIP_DOWN               },
+    { Ytank_n_w,               EL_SPACESHIP_LEFT               },
+    { Ytank_stone,             EL_ROCK                         },
+    { Ytank_spring,            EL_SPRING                       },
+    { Xandroid,                        EL_EMC_ANDROID                  },
+    { Xandroid_1_n,            EL_EMC_ANDROID_UP               },
+    { Xandroid_2_n,            EL_EMC_ANDROID_UP               },
+    { Xandroid_1_e,            EL_EMC_ANDROID_RIGHT            },
+    { Xandroid_2_e,            EL_EMC_ANDROID_RIGHT            },
+    { Xandroid_1_w,            EL_EMC_ANDROID_LEFT             },
+    { Xandroid_2_w,            EL_EMC_ANDROID_LEFT             },
+    { Xandroid_1_s,            EL_EMC_ANDROID_DOWN             },
+    { Xandroid_2_s,            EL_EMC_ANDROID_DOWN             },
+    { Yandroid_n,              EL_EMC_ANDROID_UP               },
+    { Yandroid_nB,             EL_EMC_ANDROID_UP               },
+    { Yandroid_ne,             EL_EMC_ANDROID_RIGHT_UP         },
+    { Yandroid_neB,            EL_EMC_ANDROID_RIGHT_UP         },
+    { Yandroid_e,              EL_EMC_ANDROID_RIGHT            },
+    { Yandroid_eB,             EL_EMC_ANDROID_RIGHT            },
+    { Yandroid_se,             EL_EMC_ANDROID_RIGHT_DOWN       },
+    { Yandroid_seB,            EL_EMC_ANDROID_RIGHT_DOWN       },
+    { Yandroid_s,              EL_EMC_ANDROID_DOWN             },
+    { Yandroid_sB,             EL_EMC_ANDROID_DOWN             },
+    { Yandroid_sw,             EL_EMC_ANDROID_LEFT_DOWN        },
+    { Yandroid_swB,            EL_EMC_ANDROID_LEFT_DOWN        },
+    { Yandroid_w,              EL_EMC_ANDROID_LEFT             },
+    { Yandroid_wB,             EL_EMC_ANDROID_LEFT             },
+    { Yandroid_nw,             EL_EMC_ANDROID_LEFT_UP          },
+    { Yandroid_nwB,            EL_EMC_ANDROID_LEFT_UP          },
+    { Xspring,                 EL_SPRING                       },
+    { Xspring_pause,           EL_SPRING                       },
+    { Xspring_e,               EL_SPRING                       },
+    { Xspring_w,               EL_SPRING                       },
+    { Xspring_fall,            EL_SPRING                       },
+    { Yspring_s,               EL_SPRING                       },
+    { Yspring_sB,              EL_SPRING                       },
+    { Yspring_e,               EL_SPRING                       },
+    { Yspring_eB,              EL_SPRING                       },
+    { Yspring_w,               EL_SPRING                       },
+    { Yspring_wB,              EL_SPRING                       },
+    { Yspring_kill_e,          EL_SPRING                       },
+    { Yspring_kill_eB,         EL_SPRING                       },
+    { Yspring_kill_w,          EL_SPRING                       },
+    { Yspring_kill_wB,         EL_SPRING                       },
+    { Xeater_n,                        EL_YAMYAM                       },
+    { Xeater_e,                        EL_YAMYAM                       },
+    { Xeater_w,                        EL_YAMYAM                       },
+    { Xeater_s,                        EL_YAMYAM                       },
+    { Yeater_n,                        EL_YAMYAM                       },
+    { Yeater_nB,               EL_YAMYAM                       },
+    { Yeater_e,                        EL_YAMYAM                       },
+    { Yeater_eB,               EL_YAMYAM                       },
+    { Yeater_s,                        EL_YAMYAM                       },
+    { Yeater_sB,               EL_YAMYAM                       },
+    { Yeater_w,                        EL_YAMYAM                       },
+    { Yeater_wB,               EL_YAMYAM                       },
+    { Yeater_stone,            EL_ROCK                         },
+    { Yeater_spring,           EL_SPRING                       },
+    { Xalien,                  EL_ROBOT                        },
+    { Xalien_pause,            EL_ROBOT                        },
+    { Yalien_n,                        EL_ROBOT                        },
+    { Yalien_nB,               EL_ROBOT                        },
+    { Yalien_e,                        EL_ROBOT                        },
+    { Yalien_eB,               EL_ROBOT                        },
+    { Yalien_s,                        EL_ROBOT                        },
+    { Yalien_sB,               EL_ROBOT                        },
+    { Yalien_w,                        EL_ROBOT                        },
+    { Yalien_wB,               EL_ROBOT                        },
+    { Yalien_stone,            EL_ROCK                         },
+    { Yalien_spring,           EL_SPRING                       },
+    { Xemerald,                        EL_EMERALD                      },
+    { Xemerald_pause,          EL_EMERALD                      },
+    { Xemerald_fall,           EL_EMERALD                      },
+    { Xemerald_shine,          EL_EMERALD                      },
+    { Yemerald_s,              EL_EMERALD                      },
+    { Yemerald_sB,             EL_EMERALD                      },
+    { Yemerald_e,              EL_EMERALD                      },
+    { Yemerald_eB,             EL_EMERALD                      },
+    { Yemerald_w,              EL_EMERALD                      },
+    { Yemerald_wB,             EL_EMERALD                      },
+    { Yemerald_eat,            EL_EMERALD                      },
+    { Yemerald_stone,          EL_ROCK                         },
+    { Xdiamond,                        EL_DIAMOND                      },
+    { Xdiamond_pause,          EL_DIAMOND                      },
+    { Xdiamond_fall,           EL_DIAMOND                      },
+    { Xdiamond_shine,          EL_DIAMOND                      },
+    { Ydiamond_s,              EL_DIAMOND                      },
+    { Ydiamond_sB,             EL_DIAMOND                      },
+    { Ydiamond_e,              EL_DIAMOND                      },
+    { Ydiamond_eB,             EL_DIAMOND                      },
+    { Ydiamond_w,              EL_DIAMOND                      },
+    { Ydiamond_wB,             EL_DIAMOND                      },
+    { Ydiamond_eat,            EL_DIAMOND                      },
+    { Ydiamond_stone,          EL_ROCK                         },
+    { Xdrip_fall,              EL_AMOEBA_DROP                  },
+    { Xdrip_stretch,           EL_AMOEBA_DROP                  },
+    { Xdrip_stretchB,          EL_AMOEBA_DROP                  },
+    { Xdrip_eat,               EL_AMOEBA_DROP                  },
+    { Ydrip_s1,                        EL_AMOEBA_DROP                  },
+    { Ydrip_s1B,               EL_AMOEBA_DROP                  },
+    { Ydrip_s2,                        EL_AMOEBA_DROP                  },
+    { Ydrip_s2B,               EL_AMOEBA_DROP                  },
+    { Xbomb,                   EL_BOMB                         },
+    { Xbomb_pause,             EL_BOMB                         },
+    { Xbomb_fall,              EL_BOMB                         },
+    { Ybomb_s,                 EL_BOMB                         },
+    { Ybomb_sB,                        EL_BOMB                         },
+    { Ybomb_e,                 EL_BOMB                         },
+    { Ybomb_eB,                        EL_BOMB                         },
+    { Ybomb_w,                 EL_BOMB                         },
+    { Ybomb_wB,                        EL_BOMB                         },
+    { Ybomb_eat,               EL_BOMB                         },
+    { Xballoon,                        EL_BALLOON                      },
+    { Yballoon_n,              EL_BALLOON                      },
+    { Yballoon_nB,             EL_BALLOON                      },
+    { Yballoon_e,              EL_BALLOON                      },
+    { Yballoon_eB,             EL_BALLOON                      },
+    { Yballoon_s,              EL_BALLOON                      },
+    { Yballoon_sB,             EL_BALLOON                      },
+    { Yballoon_w,              EL_BALLOON                      },
+    { Yballoon_wB,             EL_BALLOON                      },
+    { Xgrass,                  EL_SAND                         },
+    { Ygrass_nB,               EL_SAND                         },
+    { Ygrass_eB,               EL_SAND                         },
+    { Ygrass_sB,               EL_SAND                         },
+    { Ygrass_wB,               EL_SAND                         },
+    { Xdirt,                   EL_SAND                         },
+    { Ydirt_nB,                        EL_SAND                         },
+    { Ydirt_eB,                        EL_SAND                         },
+    { Ydirt_sB,                        EL_SAND                         },
+    { Ydirt_wB,                        EL_SAND                         },
+    { Xacid_ne,                        EL_ACID_POOL_TOPRIGHT           },
+    { Xacid_se,                        EL_ACID_POOL_BOTTOMRIGHT        },
+    { Xacid_s,                 EL_ACID_POOL_BOTTOM             },
+    { Xacid_sw,                        EL_ACID_POOL_BOTTOMLEFT         },
+    { Xacid_nw,                        EL_ACID_POOL_TOPLEFT            },
+    { Xacid_1,                 EL_ACID                         },
+    { Xacid_2,                 EL_ACID                         },
+    { Xacid_3,                 EL_ACID                         },
+    { Xacid_4,                 EL_ACID                         },
+    { Xacid_5,                 EL_ACID                         },
+    { Xacid_6,                 EL_ACID                         },
+    { Xacid_7,                 EL_ACID                         },
+    { Xacid_8,                 EL_ACID                         },
+    { Xball_1,                 EL_EMC_GENERATOR_BALL           },
+    { Xball_1B,                        EL_EMC_GENERATOR_BALL           },
+    { Xball_2,                 EL_EMC_GENERATOR_BALL           },
+    { Xball_2B,                        EL_EMC_GENERATOR_BALL           },
+    { Yball_eat,               EL_EMC_GENERATOR_BALL           },
+    { Xgrow_ns,                        EL_EMC_GROW                     },
+    { Ygrow_ns_eat,            EL_EMC_GROW                     },
+    { Xgrow_ew,                        EL_EMC_GROW                     },
+    { Ygrow_ew_eat,            EL_EMC_GROW                     },
+    { Xwonderwall,             EL_MAGIC_WALL                   },
+    { XwonderwallB,            EL_MAGIC_WALL                   },
+    { Xameuba_1,               EL_AMOEBA_WET                   },
+    { Xameuba_2,               EL_AMOEBA_WET                   },
+    { Xameuba_3,               EL_AMOEBA_WET                   },
+    { Xameuba_4,               EL_AMOEBA_WET                   },
+    { Xameuba_5,               EL_AMOEBA_WET                   },
+    { Xameuba_6,               EL_AMOEBA_WET                   },
+    { Xameuba_7,               EL_AMOEBA_WET                   },
+    { Xameuba_8,               EL_AMOEBA_WET                   },
+    { Xdoor_1,                 EL_EM_GATE_1                    },
+    { Xdoor_2,                 EL_EM_GATE_2                    },
+    { Xdoor_3,                 EL_EM_GATE_3                    },
+    { Xdoor_4,                 EL_EM_GATE_4                    },
+    { Xdoor_5,                 EL_EMC_GATE_5                   },
+    { Xdoor_6,                 EL_EMC_GATE_6                   },
+    { Xdoor_7,                 EL_EMC_GATE_7                   },
+    { Xdoor_8,                 EL_EMC_GATE_8                   },
+    { Xkey_1,                  EL_EM_KEY_1                     },
+    { Xkey_2,                  EL_EM_KEY_2                     },
+    { Xkey_3,                  EL_EM_KEY_3                     },
+    { Xkey_4,                  EL_EM_KEY_4                     },
+    { Xkey_5,                  EL_EMC_KEY_5                    },
+    { Xkey_6,                  EL_EMC_KEY_6                    },
+    { Xkey_7,                  EL_EMC_KEY_7                    },
+    { Xkey_8,                  EL_EMC_KEY_8                    },
+    { Xwind_n,                 EL_BALLOON_SWITCH_UP            },
+    { Xwind_e,                 EL_BALLOON_SWITCH_RIGHT         },
+    { Xwind_s,                 EL_BALLOON_SWITCH_DOWN          },
+    { Xwind_w,                 EL_BALLOON_SWITCH_LEFT          },
+    { Xwind_nesw,              EL_BALLOON_SWITCH_ANY           },
+    { Xwind_stop,              EL_BALLOON_SWITCH_NONE          },
+    { Xexit,                   EL_EXIT_CLOSED                  },
+    { Xexit_1,                 EL_EXIT_OPEN                    },
+    { Xexit_2,                 EL_EXIT_OPEN                    },
+    { Xexit_3,                 EL_EXIT_OPEN                    },
+    { Xdynamite,               EL_DYNAMITE                     },
+    { Ydynamite_eat,           EL_DYNAMITE                     },
+    { Xdynamite_1,             EL_DYNAMITE_ACTIVE              },
+    { Xdynamite_2,             EL_DYNAMITE_ACTIVE              },
+    { Xdynamite_3,             EL_DYNAMITE_ACTIVE              },
+    { Xdynamite_4,             EL_DYNAMITE_ACTIVE              },
+    { Xbumper,                 EL_EMC_BUMPER                   },
+    { XbumperB,                        EL_EMC_BUMPER                   },
+    { Xwheel,                  EL_ROBOT_WHEEL                  },
+    { XwheelB,                 EL_ROBOT_WHEEL                  },
+    { Xswitch,                 EL_UNKNOWN                      },
+    { XswitchB,                        EL_UNKNOWN                      },
+    { Xsand,                   EL_QUICKSAND_EMPTY              },
+    { Xsand_stone,             EL_QUICKSAND_FULL               },
+    { Xsand_stonein_1,         EL_QUICKSAND_FULL               },
+    { Xsand_stonein_2,         EL_QUICKSAND_FULL               },
+    { Xsand_stonein_3,         EL_QUICKSAND_FULL               },
+    { Xsand_stonein_4,         EL_QUICKSAND_FULL               },
+    { Xsand_stonesand_1,       EL_QUICKSAND_FULL               },
+    { Xsand_stonesand_2,       EL_QUICKSAND_FULL               },
+    { Xsand_stonesand_3,       EL_QUICKSAND_FULL               },
+    { Xsand_stonesand_4,       EL_QUICKSAND_FULL               },
+    { Xsand_stoneout_1,                EL_QUICKSAND_FULL               },
+    { Xsand_stoneout_2,                EL_QUICKSAND_FULL               },
+    { Xsand_sandstone_1,       EL_QUICKSAND_FULL               },
+    { Xsand_sandstone_2,       EL_QUICKSAND_FULL               },
+    { Xsand_sandstone_3,       EL_QUICKSAND_FULL               },
+    { Xsand_sandstone_4,       EL_QUICKSAND_FULL               },
+    { Xplant,                  EL_EMC_PLANT                    },
+    { Yplant,                  EL_EMC_PLANT                    },
+    { Xlenses,                 EL_EMC_LENSES                   },
+    { Xmagnify,                        EL_EMC_MAGNIFY                  },
+    { Xdripper,                        EL_UNKNOWN                      },
+    { XdripperB,               EL_UNKNOWN                      },
+    { Xfake_blank,             EL_INVISIBLE_WALL               },
+    { Xfake_blankB,            EL_INVISIBLE_WALL               },
+    { Xfake_grass,             EL_INVISIBLE_SAND               },
+    { Xfake_grassB,            EL_INVISIBLE_SAND               },
+    { Xfake_door_1,            EL_EM_GATE_1_GRAY               },
+    { Xfake_door_2,            EL_EM_GATE_2_GRAY               },
+    { Xfake_door_3,            EL_EM_GATE_3_GRAY               },
+    { Xfake_door_4,            EL_EM_GATE_4_GRAY               },
+    { Xfake_door_5,            EL_EMC_GATE_5_GRAY              },
+    { Xfake_door_6,            EL_EMC_GATE_6_GRAY              },
+    { Xfake_door_7,            EL_EMC_GATE_7_GRAY              },
+    { Xfake_door_8,            EL_EMC_GATE_8_GRAY              },
+    { Xsteel_1,                        EL_STEELWALL                    },
+    { Xsteel_2,                        EL_UNKNOWN                      },
+    { Xsteel_3,                        EL_EMC_STEELWALL_1              },
+    { Xsteel_4,                        EL_UNKNOWN                      },
+    { Xwall_1,                 EL_WALL                         },
+    { Xwall_2,                 EL_UNKNOWN                      },
+    { Xwall_3,                 EL_UNKNOWN                      },
+    { Xwall_4,                 EL_UNKNOWN                      },
+    { Xround_wall_1,           EL_WALL_SLIPPERY                },
+    { Xround_wall_2,           EL_UNKNOWN                      },
+    { Xround_wall_3,           EL_UNKNOWN                      },
+    { Xround_wall_4,           EL_UNKNOWN                      },
+    { Xdecor_1,                        EL_UNKNOWN                      },
+    { Xdecor_2,                        EL_EMC_WALL_6                   },
+    { Xdecor_3,                        EL_EMC_WALL_4                   },
+    { Xdecor_4,                        EL_EMC_WALL_5                   },
+    { Xdecor_5,                        EL_EMC_WALL_7                   },
+    { Xdecor_6,                        EL_EMC_WALL_8                   },
+    { Xdecor_7,                        EL_UNKNOWN                      },
+    { Xdecor_8,                        EL_EMC_WALL_1                   },
+    { Xdecor_9,                        EL_EMC_WALL_2                   },
+    { Xdecor_10,               EL_EMC_WALL_3                   },
+    { Xdecor_11,               EL_UNKNOWN                      },
+    { Xdecor_12,               EL_UNKNOWN                      },
+    { Xalpha_0,                        EL_CHAR('0')                    },
+    { Xalpha_1,                        EL_CHAR('1')                    },
+    { Xalpha_2,                        EL_CHAR('2')                    },
+    { Xalpha_3,                        EL_CHAR('3')                    },
+    { Xalpha_4,                        EL_CHAR('4')                    },
+    { Xalpha_5,                        EL_CHAR('5')                    },
+    { Xalpha_6,                        EL_CHAR('6')                    },
+    { Xalpha_7,                        EL_CHAR('7')                    },
+    { Xalpha_8,                        EL_CHAR('8')                    },
+    { Xalpha_9,                        EL_CHAR('9')                    },
+    { Xalpha_excla,            EL_CHAR('!')                    },
+    { Xalpha_quote,            EL_CHAR('"')                    },
+    { Xalpha_comma,            EL_CHAR(',')                    },
+    { Xalpha_minus,            EL_CHAR('-')                    },
+    { Xalpha_perio,            EL_CHAR('.')                    },
+    { Xalpha_colon,            EL_CHAR(':')                    },
+    { Xalpha_quest,            EL_CHAR('?')                    },
+    { Xalpha_a,                        EL_CHAR('A')                    },
+    { Xalpha_b,                        EL_CHAR('B')                    },
+    { Xalpha_c,                        EL_CHAR('C')                    },
+    { Xalpha_d,                        EL_CHAR('D')                    },
+    { Xalpha_e,                        EL_CHAR('E')                    },
+    { Xalpha_f,                        EL_CHAR('F')                    },
+    { Xalpha_g,                        EL_CHAR('G')                    },
+    { Xalpha_h,                        EL_CHAR('H')                    },
+    { Xalpha_i,                        EL_CHAR('I')                    },
+    { Xalpha_j,                        EL_CHAR('J')                    },
+    { Xalpha_k,                        EL_CHAR('K')                    },
+    { Xalpha_l,                        EL_CHAR('L')                    },
+    { Xalpha_m,                        EL_CHAR('M')                    },
+    { Xalpha_n,                        EL_CHAR('N')                    },
+    { Xalpha_o,                        EL_CHAR('O')                    },
+    { Xalpha_p,                        EL_CHAR('P')                    },
+    { Xalpha_q,                        EL_CHAR('Q')                    },
+    { Xalpha_r,                        EL_CHAR('R')                    },
+    { Xalpha_s,                        EL_CHAR('S')                    },
+    { Xalpha_t,                        EL_CHAR('T')                    },
+    { Xalpha_u,                        EL_CHAR('U')                    },
+    { Xalpha_v,                        EL_CHAR('V')                    },
+    { Xalpha_w,                        EL_CHAR('W')                    },
+    { Xalpha_x,                        EL_CHAR('X')                    },
+    { Xalpha_y,                        EL_CHAR('Y')                    },
+    { Xalpha_z,                        EL_CHAR('Z')                    },
+    { Xalpha_arrow_e,          EL_CHAR('>')                    },
+    { Xalpha_arrow_w,          EL_CHAR('<')                    },
+    { Xalpha_copyr,            EL_CHAR('©')                    },
+
+    { Zplayer,                 EL_PLAYER_1                     },
+
+    { ZBORDER,                 EL_EMC_LEVEL_BORDER             },
+
+    { -1,                      -1                              }
+  };
+
+  if (!mapping_initialized)
+  {
+    int i;
+
+    /* return "EL_UNKNOWN" for all undefined elements in mapping array */
+    for (i = 0; i < TILE_MAX; i++)
+      mapping_EM_to_RND[i] = EL_UNKNOWN;
+
+    for (i = 0; mapping_EM_to_RND_list[i].element_em != -1; i++)
+      mapping_EM_to_RND[mapping_EM_to_RND_list[i].element_em] =
+       mapping_EM_to_RND_list[i].element_rnd;
+
+    mapping_initialized = TRUE;
+  }
+
+  if (element_em >= 0 && element_em < TILE_MAX)
+    return mapping_EM_to_RND[element_em];
+
+  Error(ERR_WARN, "invalid EM level element %d", element_em);
+
+  return EL_UNKNOWN;
+}
+
+void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
+{
+  struct LevelInfo_EM *level_em = level->native_em_level;
+  struct LEVEL *lev = level_em->lev;
+  struct PLAYER *ply1 = level_em->ply1;
+  struct PLAYER *ply2 = level_em->ply2;
+  int i, x, y;
+
+  lev->width  = MIN(level->fieldx, EM_MAX_CAVE_WIDTH);
+  lev->height = MIN(level->fieldy, EM_MAX_CAVE_HEIGHT);
+
+  lev->time_initial = level->time;
+  lev->required_initial = level->gems_needed;
+
+  lev->emerald_score   = level->score[SC_EMERALD];
+  lev->diamond_score   = level->score[SC_DIAMOND];
+  lev->alien_score     = level->score[SC_ROBOT];
+  lev->tank_score      = level->score[SC_SPACESHIP];
+  lev->bug_score       = level->score[SC_BUG];
+  lev->eater_score     = level->score[SC_YAMYAM];
+  lev->nut_score       = level->score[SC_NUT];
+  lev->dynamite_score  = level->score[SC_DYNAMITE];
+  lev->key_score       = level->score[SC_TIME_BONUS];  /* ??? CHECK THIS */
+
+  for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+    for (y = 0; y < 3; y++)
+      for (x = 0; x < 3; x++)
+       lev->eater_array[i][y * 3 + x] =
+         map_element_RND_to_EM(level->yamyam_content[i][x][y]);
+
+  lev->ameuba_time             = level->amoeba_speed;
+  lev->wonderwall_time_initial = level->time_magic_wall;
+  lev->wheel_time              = level->time_wheel;
+
+  /* first fill the complete playfield with the default border element */
+  for (y = 0; y < EM_MAX_CAVE_HEIGHT; y++)
+    for (x = 0; x < EM_MAX_CAVE_WIDTH; x++)
+      level_em->cave[x][y] = ZBORDER;
+
+  /* then copy the real level contents from level file into the playfield */
+  for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++)
+  {
+    int new_element = map_element_RND_to_EM(level->field[x][y]);
+
+    level_em->cave[x + 1][y + 1] = new_element;
+  }
+
+  ply1->x_initial = 0;
+  ply1->y_initial = 0;
+
+  ply2->x_initial = 0;
+  ply2->y_initial = 0;
+
+  /* at last, set the two players at their positions in the playfield */
+  for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++)
+  {
+    if (level->field[x][y] == EL_PLAYER_1)
+    {
+      ply1->x_initial = x + 1;
+      ply1->y_initial = y + 1;
+    }
+    else if (level->field[x][y] == EL_PLAYER_2)
+    {
+      ply2->x_initial = x + 1;
+      ply2->y_initial = y + 1;
+    }
+  }
+}
+
+void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
+{
+  struct LevelInfo_EM *level_em = level->native_em_level;
+  struct LEVEL *lev = level_em->lev;
+  struct PLAYER *ply1 = level_em->ply1;
+  struct PLAYER *ply2 = level_em->ply2;
+  int i, x, y;
+
+  level->fieldx = MIN(lev->width,  MAX_LEV_FIELDX);
+  level->fieldy = MIN(lev->height, MAX_LEV_FIELDY);
+
+  level->time = lev->time_initial;
+  level->gems_needed = lev->required_initial;
+
+  sprintf(level->name, "Level %d", level->file_info.nr);
+
+  level->score[SC_EMERALD]     = lev->emerald_score;
+  level->score[SC_DIAMOND]     = lev->diamond_score;
+  level->score[SC_ROBOT]       = lev->alien_score;
+  level->score[SC_SPACESHIP]   = lev->tank_score;
+  level->score[SC_BUG]         = lev->bug_score;
+  level->score[SC_YAMYAM]      = lev->eater_score;
+  level->score[SC_NUT]         = lev->nut_score;
+  level->score[SC_DYNAMITE]    = lev->dynamite_score;
+  level->score[SC_TIME_BONUS]  = lev->key_score;       /* ??? CHECK THIS */
+
+  level->num_yamyam_contents = MAX_ELEMENT_CONTENTS;
+
+  for (i = 0; i < level->num_yamyam_contents; i++)
+    for (y = 0; y < 3; y++)
+      for (x = 0; x < 3; x++)
+       level->yamyam_content[i][x][y] =
+         map_element_EM_to_RND(lev->eater_array[i][y * 3 + x]);
+
+  level->amoeba_speed          = lev->ameuba_time;
+  level->time_magic_wall       = lev->wonderwall_time_initial;
+  level->time_wheel            = lev->wheel_time;
+
+  for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++)
+  {
+    int new_element = map_element_EM_to_RND(level_em->cave[x + 1][y + 1]);
+
+    if (new_element == EL_AMOEBA_WET && level->amoeba_speed == 0)
+      new_element = EL_AMOEBA_DEAD;
+
+    level->field[x][y] = new_element;
+  }
+
+  level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1;
+  level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2;
+}
+
 static void LoadLevelFromFileInfo_EM(struct LevelInfo *level,
                                     struct LevelFileInfo *level_file_info)
 {
   if (!LoadNativeLevel_EM(level_file_info->filename))
     level->no_valid_file = TRUE;
+
+  CopyNativeLevel_EM_to_RND(level);
 }
 
 #endif
index f0a043454732fdc8265e236f8f9d5d711fe83cc9..558837256d5f30fb07ae49c97b8d8d0212ecd66a 100644 (file)
@@ -57,6 +57,9 @@ void SaveLevel(int);
 void SaveLevelTemplate();
 void DumpLevel(struct LevelInfo *);
 
+void CopyNativeLevel_RND_to_EM(struct LevelInfo *);
+void CopyNativeLevel_EM_to_RND(struct LevelInfo *);
+
 void LoadTapeFromFilename(char *);
 void LoadTape(int);
 void LoadSolutionTape(int);
index 423f64d50ed563a88e76b486ccff40a1d130dd7c..cb8a7974bcf2a5f5345cd7b50b22fa6b723c4040 100644 (file)
@@ -2063,13 +2063,7 @@ void InitGame()
   /* !!! FIX THIS (START) !!! */
   if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
   {
-    if (em_main_init_game(level_nr, level.file_info.filename) != 0)
-    {
-      game_status = GAME_MODE_MAIN;
-      DrawMainMenu();
-
-      return;
-    }
+    InitGameEngine_EM();
   }
   else
   {
index 0e7caea5013f510cf8d0e9f314b20c0a6d910bea..a6c2a33b2166d8d2d338635da41663b311350e97 100644 (file)
@@ -22,6 +22,10 @@ struct cave_node *cave_list;
 
 static void setLevelInfoToDefaults_EM(void)
 {
+  native_em_level.lev = &lev;
+  native_em_level.ply1 = &ply1;
+  native_em_level.ply2 = &ply2;
+
   lev.width = 64;
   lev.height = 32;
 
index 9dcb6871468f161c221ab870dfcc054f282005e1..4b05c49cd87c7dec2280f0f9cca591bfd94bb598 100644 (file)
@@ -33,11 +33,13 @@ extern void DrawGameDoorValues_EM(int, int, int, int);
 
 #include "main_em.h"
 
+extern struct LevelInfo_EM native_em_level;
+
 extern void em_open_all();
 extern void em_close_all();
 
-extern int em_main_init_game(int, char *);
-extern int em_main_handle_game(byte);
+extern void InitGameEngine_EM();
+extern void GameActions_EM(byte);
 
 boolean LoadNativeLevel_EM(char *);
 
index 51d541849d46b7c2b28bfaf6ff68064ed54b8568..c168a62b7d938d9d7c263b2f8cd547191677bf49 100644 (file)
@@ -22,12 +22,6 @@ extern int arg_silence;
 
 extern unsigned int frame;
 
-#define EM_GAME_STATUS_MENU    1
-#define EM_GAME_STATUS_PLAY    2
-
-extern int em_game_status;
-extern boolean skip_menu;
-
 extern short ulaw_to_linear[256];
 extern unsigned char linear_to_ulaw[65536];
 
@@ -41,13 +35,7 @@ void input_eventloop(void);
 
 void blitscreen(void);
 void game_initscreen(void);
-void game_blitscore(void);
 void game_animscreen(void);
-void title_initscreen(void);
-void title_blitscore(void);
-void title_animscreen(void);
-void title_string(unsigned int y, unsigned int left, unsigned int right,
-                 char *string);
 
 void sound_play(void);
 
@@ -55,8 +43,8 @@ int cave_convert(char *);
 boolean LoadNativeLevel_EM(char *);
 
 void game_init_vars(void);
-int game_play_init(int, char *);
-int game_loop(byte);
+void game_play_init(int, char *);
+void game_loop(byte);
 
 void synchro_1(void);
 void synchro_2(void);
index edc1564336ba694eafd70df79cedbf811d3a80bf..2de3e1702d41d67ffdf9955ebfec4923cf21dfe8 100644 (file)
 #include "display.h"
 #include "level.h"
 
-#include <stdio.h>
-
 
 #if defined(TARGET_X11)
 
-unsigned int frame; /* current frame */
-unsigned int screen_x; /* current scroll position */
+unsigned int frame;            /* current screen frame */
+unsigned int screen_x;         /* current scroll position */
 unsigned int screen_y;
 
 /* tiles currently on screen */
 static unsigned short screentiles[MAX_BUF_YSIZE][MAX_BUF_XSIZE];
 
-static unsigned int colours[8];
-static unsigned int colour_anim;
-
-static void xdebug(char *msg)
-{
-#if 0
-  XSync(display, False);
-  printf("EM DEBUG: %s\n", msg);
-#endif
-}
-
-static void colour_shuffle(void)
-{
-  unsigned int i, j, k;
-
-  for (i = 0; i < 8; i++)
-    colours[i] = i;
-
-  for (i = 0; i < 8; i++)
-  {
-    Random = Random * 129 + 1;
-    j = (Random >> 10) & 7;
-    k = colours[i];
-    colours[i] = colours[j];
-    colours[j] = k;
-  }
-}
-
 
 /* copy the entire screen to the window at the scroll position
  *
@@ -61,16 +31,6 @@ void blitscreen(void)
   unsigned int x = screen_x % (MAX_BUF_XSIZE * TILEX);
   unsigned int y = screen_y % (MAX_BUF_YSIZE * TILEY);
 
-  xdebug("blitscreen");
-
-  if (em_game_status == EM_GAME_STATUS_MENU)
-  {
-    ClearRectangle(screenBitmap, 0, SCR_MENUY * TILEY,
-                  SCR_FIELDX * TILEX, (17 - SCR_MENUY) * TILEY);
-    BlitBitmap(scoreBitmap, screenBitmap, 0, 0, SCR_MENUX * TILEX, SCOREY,
-              0, SCR_MENUY * TILEY);
-  }
-
   if (x < 2 * TILEX && y < 2 * TILEY)
   {
     BlitBitmap(screenBitmap, window, x, y,
@@ -110,17 +70,7 @@ void blitscreen(void)
               SX + MAX_BUF_XSIZE * TILEX - x, SY + MAX_BUF_YSIZE * TILEY - y);
   }
 
-  if (em_game_status == EM_GAME_STATUS_PLAY && SCR_FIELDY < 17)
-  {
-    BlitBitmap(scoreBitmap, window, 0, 0, SCR_FIELDX * TILEX, SCOREY,
-              SX, SY + SCR_FIELDY * TILEY);
-    ClearRectangle(window, SX, SY + SCR_FIELDY * TILEY + SCOREY,
-                  SCR_FIELDX * TILEX, (17 - SCR_FIELDY) * TILEY - SCOREY);
-  }
-
   XFlush(display);
-
-  xdebug("blitscreen - done");
 }
 
 
@@ -138,8 +88,6 @@ static void animscreen(void)
   unsigned int left = screen_x / TILEX;
   unsigned int top = screen_y / TILEY;
 
-  xdebug("animscreen");
-
   for (y = top; y < top + MAX_BUF_YSIZE; y++)
   {
     dy = y % MAX_BUF_YSIZE;
@@ -170,8 +118,6 @@ static void blitplayer(struct PLAYER *ply)
   unsigned int x, y, dx, dy;
   unsigned short obj, spr;
 
-  xdebug("blitplayer");
-
   if (ply->alive)
   {
     x = (frame * ply->oldx + (8 - frame) * ply->x) * TILEX / 8;
@@ -290,15 +236,10 @@ static void blitplayer(struct PLAYER *ply)
   }
 }
 
-
-/* draw static text for time, gems and score counter */
-
 void game_initscreen(void)
 {
   unsigned int x,y;
 
-  xdebug("game_initscreen");
-
   frame = 6;
   screen_x = 0;
   screen_y = 0;
@@ -307,133 +248,14 @@ void game_initscreen(void)
     for (x = 0; x < MAX_BUF_XSIZE; x++)
       screentiles[y][x] = -1;
 
-  colour_shuffle();
-  colours[0] += 16;
-  colours[1] += 16;
-  colours[2] += 16;
-  colour_anim = 0;
-
-  ClearRectangle(scoreBitmap, 0, 0, SCR_FIELDX * TILEX, SCOREY);
-  BlitBitmap(botBitmap, scoreBitmap,
-            11 * SCOREX, colours[0] * SCOREY, 3 * SCOREX, SCOREY,
-            1 * SCOREX, 0);                            /* 0-63 time */
-  BlitBitmap(botBitmap, scoreBitmap,
-            18 * SCOREX, colours[0] * SCOREY, 6 * SCOREX, SCOREY,
-            11 * SCOREX, 0);                           /* 112-207 diamonds */
-  BlitBitmap(botBitmap, scoreBitmap,
-            14 * SCOREX, colours[0] * SCOREY, 4 * SCOREX, SCOREY,
-            24 * SCOREX, 0);                           /* 256-319 score */
-}
-
-
-/* draw current values for time, gems and score counter */
-
-void game_blitscore(void)
-{
-  unsigned int i;
-
-  xdebug("game_blitscore");
-
   DrawGameDoorValues_EM(lev.required, ply1.dynamite, lev.score,
                        (lev.time + 4) / 5);
-
-  i = (lev.time + 4) / 5;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            7 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            6 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            5 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            4 * SCOREX, 0);
-
-  i = lev.score;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            31 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            30 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            29 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            28 * SCOREX, 0);
-
-  if (lev.home == 0)
-  {
-    BlitBitmap(botBitmap, scoreBitmap,
-              12 * SCOREX, 24 * SCOREY, 12 * SCOREX, SCOREY,
-              14 * SCOREX, 0); /* relax */
-
-    goto done;
-  }
-
-  if (ply1.alive + ply2.alive >= lev.home && lev.required == 0)
-  {
-    BlitBitmap(botBitmap, scoreBitmap,
-              24 * SCOREX, colours[2] * SCOREY, 12 * SCOREX, SCOREY,
-              14 * SCOREX, 0); /* find the exit */
-
-    goto done;
-  }
-
-  if (ply1.alive + ply2.alive < lev.home)
-  {
-    if (++colour_anim > 11)
-      colour_anim = 0;
-
-    if (colour_anim < 6)
-    {
-      BlitBitmap(botBitmap, scoreBitmap,
-                0, 24 * SCOREY, 12 * SCOREX, SCOREY,
-                14 * SCOREX, 0); /* forget it */
-
-      goto done;
-    }
-
-    BlitBitmap(botBitmap, scoreBitmap,
-              18 * SCOREX, colours[0] * SCOREY, 6 * SCOREX, SCOREY,
-              15 * SCOREX, 0); /* diamonds */
-  }
-
-  i = lev.required;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            20 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            19 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            18 * SCOREX, 0);
-  i /= 10;
-  BlitBitmap(botBitmap, scoreBitmap,
-            (i % 10) * SCOREX, colours[1] * SCOREY, SCOREX, SCOREY,
-            17 * SCOREX, 0);
-
- done:
 }
 
 void game_animscreen(void)
 {
   unsigned int x,y;
 
-  xdebug("game_animscreen");
-
   x = (frame * ply1.oldx + (8 - frame) * ply1.x) * TILEX / 8
     + ((SCR_FIELDX - 1) * TILEX) / 2;
   y = (frame * ply1.oldy + (8 - frame) * ply1.y) * TILEY / 8
@@ -458,195 +280,6 @@ void game_animscreen(void)
   blitscreen();
 
   XFlush(display);
-
-  Random = Random * 129 + 1;
-}
-
-
-/* draw main menu background and copyright note */
-
-void title_initscreen(void)
-{
-  xdebug("title_initscreen");
-
-  screen_x = 0;
-  screen_y = 0;
-
-  colour_shuffle();
-  colours[1] += 8;
-  colour_anim = 0;
-
-#if 1
-
-  /* draw title screen on menu background */
-
-  BlitBitmap(ttlBitmap, screenBitmap, ORIG_MENU_SX, ORIG_MENU_SY,
-            SCR_MENUX * TILEX, SCR_MENUY * TILEY, 0, 0);
-
-  /* draw copyright note at footer */
-
-  if (botmaskBitmap)
-  {
-    BlitBitmap(botBitmap, scoreBitmap, 0, colours[1] * SCOREY,
-              SCR_MENUX * TILEX, SCOREY, 0, 0);
-
-    SetClipOrigin(botBitmap, botBitmap->stored_clip_gc,
-                 0, 0 - colours[0] * SCOREY);
-  }
-
-  BlitBitmapMasked(botBitmap, scoreBitmap, 0, colours[0] * SCOREY,
-                  SCR_MENUX * TILEX, SCOREY, 0, 0);
-
-#else
-
-  XCopyArea(display, ttlPixmap, screenPixmap, screenGC,
-           0, 0, SCR_MENUX * TILEX, SCR_MENUY * TILEY, 0, 0);
-
-  if (botmaskBitmap)
-  {
-    XCopyArea(display, botPixmap, scorePixmap, scoreGC,
-             0, colours[1] * SCOREY, SCR_MENUX * TILEX, SCOREY, 0, 0);
-    XSetClipMask(display, scoreGC, botmaskBitmap);
-    XSetClipOrigin(display, scoreGC, 0, 0 - colours[0] * SCOREY);
-  }
-
-  XCopyArea(display, botPixmap, scorePixmap, scoreGC,
-           0, colours[0] * SCOREY, SCR_MENUX * TILEX, SCOREY, 0, 0);
-
-  if (botmaskBitmap)
-    XSetClipMask(display, scoreGC, None);
-
-#endif
-}
-
-
-/* draw bouncing ball on main menu footer */
-
-void title_blitscore(void)
-{
-  unsigned int x, y, i;
-
-  xdebug("title_blitscore");
-
-  if (++colour_anim > 30)
-    colour_anim = 0;
-
-  i = colour_anim >= 16 ? 31 - colour_anim : colour_anim;
-  x = (i / 8 + 18) * 2 * SCOREX;
-  y = (i % 8 + 16) * SCOREY;
-
-#if 1
-  if (botmaskBitmap)
-  {
-    BlitBitmap(botBitmap, scoreBitmap,
-              32 * SCOREX, colours[1] * SCOREY, 2 * SCOREX, SCOREY,
-              32 * SCOREX, 0);
-
-    SetClipOrigin(botBitmap, botBitmap->stored_clip_gc,
-                 32 * SCOREX - x, 0 - y);
-  }
-
-  BlitBitmapMasked(botBitmap, scoreBitmap,
-                  x, y, 2 * SCOREX, SCOREY, 32 * SCOREX, 0);
-
-#else
-
-  if (botmaskBitmap)
-  {
-    XCopyArea(display, botPixmap, scorePixmap, scoreGC,
-             32 * SCOREX, colours[1] * SCOREY, 2 * SCOREX, SCOREY,
-             32 * SCOREX, 0);
-    XSetClipMask(display, scoreGC, botmaskBitmap);
-    XSetClipOrigin(display, scoreGC, 32 * SCOREX - x, 0 - y);
-  }
-
-  XCopyArea(display, botPixmap, scorePixmap, scoreGC,
-           x, y, 2 * SCOREX, SCOREY, 32 * SCOREX, 0);
-
-  if (botmaskBitmap)
-    XSetClipMask(display, scoreGC, None);
-#endif
-}
-
-void title_animscreen(void)
-{
-  blitscreen();
-  XFlush(display);
-
-  Random = Random * 129 + 1;
-}
-
-static int ttl_map[] =
-{
-  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-  -1,0,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,2,3,4,-1,      /* !',-. */
-  5,6,7,8,9,10,11,12,13,14,15,-1,-1,-1,-1,16,      /* 0123456789:? */
-  -1,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, /* ABCDEFGHIJKLMNO */
-  32,33,34,35,36,37,38,39,40,41,42,-1,-1,-1,-1,-1, /* PQRSTUVWXYZ */
-  -1,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, /* abcdefghijklmno */
-  32,33,34,35,36,37,38,39,40,41,42,-1,-1,-1,-1,-1  /* pqrstuvwxyz */
-};
-
-void title_string(unsigned int y, unsigned int left, unsigned int right,
-                 char *string)
-{
-  int i;
-  unsigned int x;
-
-  xdebug("title_string");
-
-  y *= TILEY;
-  left *= SCOREX;
-  right *= SCOREX;
-
-  x = (left + right - strlen(string) * MENUFONTX) / 2;
-  if (x < left || x >= right)
-    x = left;
-
-  /* restore background graphic where text will be drawn */
-  BlitBitmap(ttlBitmap, screenBitmap, ORIG_MENU_SX + left, ORIG_MENU_SY + y,
-            right - left, MENUFONTY, left, y);
-
-#if 1
-#else
-  if (ttlmaskBitmap)
-    XSetClipMask(display, screenGC, ttlmaskBitmap);
-#endif
-
-  for (i = 0; string[i] && x < right; i++)
-  {
-    int ch_pos, ch_x, ch_y;
-
-    ch_pos = ttl_map[string[i] & 127];
-
-    if (ch_pos == -1 || ch_pos > 22 * 2)
-      continue;                                /* no graphic for this character */
-
-    ch_x = (ch_pos % 22) * GFXMENUFONTX;
-    ch_y = (ch_pos / 22 + 12) * TILEY;
-
-#if 1
-    SetClipOrigin(ttlBitmap, ttlBitmap->stored_clip_gc,
-                 x - ORIG_MENU_SX - ch_x, y - ORIG_MENU_SY - ch_y);
-
-    BlitBitmapMasked(ttlBitmap, screenBitmap, ch_x, ch_y, MENUFONTX, MENUFONTY,
-                    x - ORIG_MENU_SX, y - ORIG_MENU_SY);
-#else
-    if (ttlmaskBitmap)
-      XSetClipOrigin(display, screenGC, x - ch_x, y - ch_y);
-
-    XCopyArea(display, ttlPixmap, screenPixmap, screenGC,
-             ch_x, ch_y, MENUFONTX, MENUFONTY, x, y);
-#endif
-
-    x += MENUFONTX;
-  }
-
-#if 1
-#else
-  XSetClipMask(display, screenGC, None);
-#endif
 }
 
 #endif
index f550494ceeaac64d6d30ca5a2010df304f2705bd..86feeb4d3e54acfaf7d3281ceb3ad85a183c3330 100644 (file)
@@ -38,78 +38,6 @@ unsigned short **Draw;
 static unsigned short *Index[4][HEIGHT];
 static unsigned short Array[4][HEIGHT][WIDTH];
 
-static int input_die;
-static int input_pause;
-static int input_refresh;
-static int input_esc;
-
-static struct timeval tv1;
-static struct timeval tv2;
-
-static int player_mode;
-static char player_name[32];
-static int player_level;
-
-static void drawmenu(int pos)
-{
-  char buffer[256];
-
-  switch(pos)
-  {
-    case 0:
-      switch(player_mode)
-      {
-        case 0:
-         strcpy(buffer, "quit emerald mine");
-         break;
-
-        case 1:
-         strcpy(buffer, "single player");
-         break;
-
-        case 2:
-         strcpy(buffer, "teamwork");
-         break;
-      }
-
-      title_string(4, 0, 40, buffer);
-      break;
-
-    case 1:
-      sprintf(buffer, "name: %s", player_name);
-      title_string(5, 0, 40, buffer);
-      break;
-
-    case 2:
-      sprintf(buffer, "level: %d", player_level);
-      title_string(6, 0, 40, buffer);
-      break;
-
-    case 3:
-      title_string(7, 0, 40, "highscores");
-      break;
-
-    case 4:
-      title_string(8, 0, 40, "start");
-      break;
-
-    case 5:
-      title_string(10, 3, 13, "played");
-      title_string(10, 14, 26, "score");
-      title_string(10, 27, 37, "won");
-      break;
-
-    case 6:
-      sprintf(buffer, "%d", 0);
-      title_string(11, 3, 13, buffer);
-      sprintf(buffer, "%d", 0);
-      title_string(11, 14, 26, buffer);
-      sprintf(buffer, "%d", 0);
-      title_string(11, 27, 37, buffer);
-      break;
-  }
-}
-
 void game_init_vars(void)
 {
   int x, y;
@@ -142,217 +70,42 @@ void game_init_vars(void)
   Next = Index[1];
   Draw = Index[2];
   Boom = Index[3];
-
-  player_mode = 1;                     /* start off as single player */
-  strcpy(player_name, "dave");
-  player_level = 0;
-
-  input_pause = 1    * 0;
 }
 
-int game_play_init(int level_nr, char *filename)
+void InitGameEngine_EM()
 {
-#if 0
-  if (filename != NULL)
-  {
-#endif
-
-    player_level = level_nr;
-
-#if 1
-    prepare_em_level();
-#else
-    if (!LoadNativeLevel_EM(filename))
-      return 1;
-#endif
-
-#if 0
-  }
-  else /* !!! SOON OBSOLETE !!! */
-  {
-    char name[MAXNAME+2];
-
-    name[MAXNAME] = 0;
-    snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level);
-
-    if (name[MAXNAME])
-      snprintf_overflow("read a level in cave/");
-
-    if (cave_convert(name) != 0)
-      return 1;
-  }
-#endif
+  prepare_em_level();
 
   game_initscreen();
-  game_blitscore();
   game_animscreen();
-
-  return 0;
 }
 
-int game_menu_loop(boolean init, byte action)
+void GameActions_EM(byte action)
 {
-  static int temp = -1;
-  static int pos = -1;
-
-  if (init)
-  {
-    temp = 1;
-    pos = 4;
-
-    return 0;
-  }
-
   input_eventloop();
 
-  if (input_die)
-    return 1;
-
-  if (input_refresh)
-    blitscreen();
-
-  if (!input_pause)
-  {
-    title_blitscore();
-    title_animscreen();
-
-    ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0;
-
-    readjoy(action);
-
-    if (temp == 0)
-    {
-      if (ply1.joy_fire)
-       return 2;
-
-      if (ply1.joy_e && player_level < 99)
-      {
-       player_level++;
-       drawmenu(2);
-      }
-
-      if (ply1.joy_w && player_level > 0)
-      {
-       player_level--;
-       drawmenu(2);
-      }
-
-      if (ply1.joy_n && pos > 0)
-      {
-       drawmenu(pos);
-       pos--;
-      }
-
-      if (ply1.joy_s && pos < 4)
-      {
-       drawmenu(pos);
-       pos++;
-      }
-    }
-
-    temp = (ply1.joy_n || ply1.joy_e || ply1.joy_s || ply1.joy_w ||
-           ply1.joy_fire);
-  }
-
-  return 0;
-}
+  game_animscreen();
 
-int game_play_loop(byte action)
-{
-  input_eventloop();
+  Random = Random * 129 + 1;
 
-  if (input_die || input_esc)
-    return 1;
+  frame = (frame - 1) & 7;
 
-  if (input_refresh)
-    blitscreen();
+  readjoy(action);
 
-  if (!input_pause)
+  if (frame == 7)
   {
-    game_animscreen();
-
-    frame = (frame - 1) & 7;
-
-    readjoy(action);
-
-#if 1
-    if (input_esc)
-      return 1;
-#endif
-
-    if (frame == 7)
-    {
-      synchro_1();
-      synchro_2();
-    }
-
-    if (frame == 6)
-    {
-      synchro_3();
-      sound_play();
-      game_blitscore();
-    }
+    synchro_1();
+    synchro_2();
   }
 
-  return 0;
-}
-
-void game_menu_init(void)
-{
-  int i;
-
-  title_initscreen();
-
-  for (i = 0; i < 7; i++)
-    drawmenu(i);                       /* display all lines */
-
-  title_blitscore();
-  title_animscreen();
-
-  game_menu_loop(1, 0);
-}
-
-int game_loop(byte action)
-{
-#if 0
-  printf("::: action == 0x%02x\n", action);
-#endif
-
-  if (em_game_status == EM_GAME_STATUS_MENU)
-  {
-    int result = game_menu_loop(0, action);
-
-    if (result == 1)
-    {
-      /* exit program */
-
-      return 1;
-    }
-
-    if (result == 2)
-    {
-      /* start playing */
-
-      em_game_status = EM_GAME_STATUS_PLAY;
-      if (game_play_init(player_level, NULL) != 0)
-       em_game_status = EM_GAME_STATUS_MENU;
-    }
-  }
-  else if (em_game_status == EM_GAME_STATUS_PLAY)
+  if (frame == 6)
   {
-    if (game_play_loop(action) != 0)
-    {
-      /* stop playing */
-
-      if (skip_menu)
-       return 1;
+    synchro_3();
+    sound_play();
 
-      em_game_status = EM_GAME_STATUS_MENU;
-      game_menu_init();
-    }
+    DrawGameDoorValues_EM(lev.required, ply1.dynamite, lev.score,
+                         (lev.time + 4) / 5);
   }
-
-  return 0;
 }
 
 
@@ -377,11 +130,6 @@ void readjoy(byte action)
   if (action & JOY_BUTTON_1)
     fire = 1;
 
-#if 0
-  if (action & JOY_BUTTON_2)
-    input_esc = 1;
-#endif
-
   ply1.joy_fire = fire;
   if (ply1.joy_stick || (north | east | south | west))
   {
@@ -397,35 +145,30 @@ void readjoy(byte action)
 
 void input_eventloop(void)
 {
+  static struct timeval tv1 = { 0, 0 };
+  static struct timeval tv2 = { 0, 0 };
   unsigned long count;
 
-  if (!input_pause)
-  {
-    XSync(display, False); /* block until all graphics are drawn */
+  XSync(display, False); /* block until all graphics are drawn */
 
-    if (gettimeofday(&tv2, 0) == -1)
-      tv2.tv_usec = 0;
+  if (gettimeofday(&tv2, 0) == -1)
+    tv2.tv_usec = 0;
 
-    count = tv2.tv_usec + 1000000 - tv1.tv_usec;
-    if (count >= 1000000)
-      count -= 1000000;
+  count = tv2.tv_usec + 1000000 - tv1.tv_usec;
+  if (count >= 1000000)
+    count -= 1000000;
 
-    tv1.tv_usec = tv2.tv_usec;
-    if (count < 25000)
-    {
-      tv2.tv_sec = 0;
-      tv2.tv_usec = 25000 - count;
+  tv1.tv_usec = tv2.tv_usec;
+  if (count < 25000)
+  {
+    tv2.tv_sec = 0;
+    tv2.tv_usec = 25000 - count;
 #if 1
-      select(0, 0, 0, 0, &tv2); /* sleep a bit */
+    select(0, 0, 0, 0, &tv2); /* sleep a bit */
 #else
-      usleep(tv2.tv_usec);
+    usleep(tv2.tv_usec);
 #endif
-    }
   }
-
-  input_esc = 0;
-  input_die = 0;
-  input_refresh = 0;
 }
 
 #endif
index 252e45f24fc5b1eee2a6461a90156b379c36e176..874bc78074843a82c4ce80d28857902b6cb25365 100644 (file)
@@ -25,9 +25,6 @@ char *arg_geometry;
 int arg_install;
 int arg_silence;
 
-int em_game_status;
-boolean skip_menu = TRUE;
-
 extern void tab_generate();
 extern void ulaw_generate();
 
@@ -52,34 +49,6 @@ void em_close_all()
   close_all();
 }
 
-int em_main_init_game(int level_nr, char *filename)
-{
-#if 0
-  if (skip_menu)
-  {
-#endif
-
-    em_game_status = EM_GAME_STATUS_PLAY;
-    if (game_play_init(level_nr, filename) != 0)
-      return 1;
-
-#if 0
-  }
-  else
-  {
-    em_game_status = EM_GAME_STATUS_MENU;
-    game_menu_init();
-  }
-#endif
-
-  return 0;
-}
-
-int em_main_handle_game(byte action)
-{
-  return game_loop(action);
-}
-
 /* massive kludge for buffer overflows
  * i cant think of an elegant way to handle this situation.
  * oh wait yes i can. dynamically allocate each string. oh well
index 5a0d04367a2634a7c66e8b9d65c159359909f42c..0824083f30011fc5e42ad8732d0267552051a1dd 100644 (file)
@@ -7,8 +7,8 @@
 #define EM_MAX_CAVE_HEIGHT             102
 
 /* define these for backwards compatibility */
-#define BAD_ROLL
-#define BAD_SPRING
+#define EM_ENGINE_BAD_ROLL
+#define EM_ENGINE_BAD_SPRING
 
 enum
 {
@@ -16,7 +16,7 @@ enum
   Yacid_splash_eB,     /* hmm */
   Yacid_splash_wB,     /* hmm */
 
-#ifdef BAD_ROLL
+#ifdef EM_ENGINE_BAD_ROLL
   Xstone_force_e,      /* only use these in eater */
   Xstone_force_w,
   Xnut_force_e,
@@ -524,15 +524,10 @@ struct PLAYER
 
 struct LevelInfo_EM
 {
-  struct LEVEL lev;
-  struct PLAYER ply1, ply2;
+  struct LEVEL *lev;
+  struct PLAYER *ply1, *ply2;
 
   unsigned short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT];
-
-  unsigned short **Boom;
-  unsigned short **Cave;
-  unsigned short **Next;
-  unsigned short **Draw;
 };
 
 #endif /* MAIN_EM_H */
index 5d6654de490c8f18b2c2d54f8ec0ef99675d6957..c0e15c2fad48c4e49281d585e9e7503a691442f7 100644 (file)
@@ -3,6 +3,15 @@
 
 #include "main_em.h"
 
+#ifdef EM_ENGINE_BAD_ROLL
+#define BAD_ROLL
+#endif
+
+#ifdef EM_ENGINE_BAD_SPRING
+#define BAD_SPRING
+#endif
+
+
 #if 0
 
 /* 2000-07-30T11:06:03Z
index 3e25cd2f839d523d72a7ba24298107ec86934579..dcf4f1df9e9fc2c3bbeaf888fccef8ef5b9be958 100644 (file)
 #define EL_SP_GRAVITY_OFF_PORT_LEFT    665
 #define EL_SP_GRAVITY_OFF_PORT_UP      666
 
+#if 1
+
 #define NUM_FILE_ELEMENTS              667
 
+/* the following EMC style elements are currently not implemented in R'n'D */
+#define EL_BALLOON_SWITCH_NONE         EL_UNKNOWN
+#define EL_EMC_LEVEL_BORDER            EL_UNKNOWN
+#define EL_EMC_ANDROID                 EL_UNKNOWN
+#define EL_EMC_ANDROID_RIGHT           EL_UNKNOWN
+#define EL_EMC_ANDROID_UP              EL_UNKNOWN
+#define EL_EMC_ANDROID_LEFT            EL_UNKNOWN
+#define EL_EMC_ANDROID_DOWN            EL_UNKNOWN
+#define EL_EMC_ANDROID_LEFT_UP         EL_UNKNOWN
+#define EL_EMC_ANDROID_LEFT_DOWN       EL_UNKNOWN
+#define EL_EMC_ANDROID_RIGHT_UP                EL_UNKNOWN
+#define EL_EMC_ANDROID_RIGHT_DOWN      EL_UNKNOWN
+#define EL_EMC_GRASS                   EL_UNKNOWN
+#define EL_EMC_GENERATOR_BALL          EL_UNKNOWN
+#define EL_EMC_GROW                    EL_UNKNOWN
+#define EL_EMC_GATE_1                  EL_UNKNOWN
+#define EL_EMC_GATE_2                  EL_UNKNOWN
+#define EL_EMC_GATE_3                  EL_UNKNOWN
+#define EL_EMC_GATE_4                  EL_UNKNOWN
+#define EL_EMC_GATE_5                  EL_UNKNOWN
+#define EL_EMC_GATE_6                  EL_UNKNOWN
+#define EL_EMC_GATE_7                  EL_UNKNOWN
+#define EL_EMC_GATE_8                  EL_UNKNOWN
+#define EL_EMC_GATE_1_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_2_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_3_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_4_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_5_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_6_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_7_GRAY             EL_UNKNOWN
+#define EL_EMC_GATE_8_GRAY             EL_UNKNOWN
+#define EL_EMC_KEY_1                   EL_UNKNOWN
+#define EL_EMC_KEY_2                   EL_UNKNOWN
+#define EL_EMC_KEY_3                   EL_UNKNOWN
+#define EL_EMC_KEY_4                   EL_UNKNOWN
+#define EL_EMC_KEY_5                   EL_UNKNOWN
+#define EL_EMC_KEY_6                   EL_UNKNOWN
+#define EL_EMC_KEY_7                   EL_UNKNOWN
+#define EL_EMC_KEY_8                   EL_UNKNOWN
+#define EL_EMC_BUMPER                  EL_UNKNOWN
+#define EL_EMC_PLANT                   EL_UNKNOWN
+#define EL_EMC_LENSES                  EL_UNKNOWN
+#define EL_EMC_MAGNIFY                 EL_UNKNOWN
+
+#else
+
+/* the following EMC style elements are currently not implemented in R'n'D */
+#define EL_BALLOON_SWITCH_NONE         667
+#define EL_EMC_LEVEL_BORDER            668
+#define EL_EMC_ANDROID                 669
+#define EL_EMC_ANDROID_RIGHT           670
+#define EL_EMC_ANDROID_UP              671
+#define EL_EMC_ANDROID_LEFT            672
+#define EL_EMC_ANDROID_DOWN            673
+#define EL_EMC_ANDROID_LEFT_UP         674
+#define EL_EMC_ANDROID_LEFT_DOWN       675
+#define EL_EMC_ANDROID_RIGHT_UP                676
+#define EL_EMC_ANDROID_RIGHT_DOWN      677
+#define EL_EMC_GRASS                   678
+#define EL_EMC_GENERATOR_BALL          679
+#define EL_EMC_GROW                    680
+#define EL_EMC_GATE_1                  681
+#define EL_EMC_GATE_2                  682
+#define EL_EMC_GATE_3                  683
+#define EL_EMC_GATE_4                  684
+#define EL_EMC_GATE_5                  685
+#define EL_EMC_GATE_6                  686
+#define EL_EMC_GATE_7                  687
+#define EL_EMC_GATE_8                  688
+#define EL_EMC_GATE_1_GRAY             689
+#define EL_EMC_GATE_2_GRAY             690
+#define EL_EMC_GATE_3_GRAY             691
+#define EL_EMC_GATE_4_GRAY             692
+#define EL_EMC_GATE_5_GRAY             693
+#define EL_EMC_GATE_6_GRAY             694
+#define EL_EMC_GATE_7_GRAY             695
+#define EL_EMC_GATE_8_GRAY             696
+#define EL_EMC_KEY_1                   697
+#define EL_EMC_KEY_2                   698
+#define EL_EMC_KEY_3                   699
+#define EL_EMC_KEY_4                   700
+#define EL_EMC_KEY_5                   701
+#define EL_EMC_KEY_6                   702
+#define EL_EMC_KEY_7                   703
+#define EL_EMC_KEY_8                   704
+#define EL_EMC_BUMPER                  705
+#define EL_EMC_PLANT                   706
+#define EL_EMC_LENSES                  707
+#define EL_EMC_MAGNIFY                 708
+
+#define NUM_FILE_ELEMENTS              709
+
+#endif
+
 
 /* "real" (and therefore drawable) runtime elements */
 #define EL_FIRST_RUNTIME_REAL          NUM_FILE_ELEMENTS
@@ -1479,7 +1575,7 @@ struct LevelInfo
   struct LevelFileInfo file_info;
 
   /* level stored in native format for the native game engines */
-  struct LevelInfo_EM native_em_level;
+  struct LevelInfo_EM *native_em_level;
 
   int game_engine_type;
 
index 1ba452fbc249bf0c60b915decf32aa82b22fe6ac..b1b57242660171d5c6df975fa3b35a667699f624 100644 (file)
@@ -2985,11 +2985,7 @@ void HandleGameActions()
     if (tape.recording)
       TapeRecordAction(tape_action);
 
-    if (em_main_handle_game(local_player->effective_action) != 0)
-    {
-      game_status = GAME_MODE_MAIN;
-      DrawMainMenu();
-    }
+    GameActions_EM(local_player->effective_action);
 
     if (TimeFrames >= FRAMES_PER_SECOND)
     {