rnd-20041017-2-src
authorHolger Schemel <info@artsoft.org>
Sun, 17 Oct 2004 21:21:00 +0000 (23:21 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:48:13 +0000 (10:48 +0200)
src/conftime.h
src/files.c
src/game_em/convert.c
src/game_em/display.h
src/game_em/graphics.c
src/game_em/input.c
src/game_em/main_em.h
src/main.h

index fd13ab2aae43ef8f8d0f2829c380a39ef9e91c18..342667de4631c0643f8c925de786abf16660cf76 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2004-10-17 03:55]"
+#define COMPILE_DATE_STRING "[2004-10-17 23:19]"
index d616c10caf618e5fcdd8238e51b9cb335eb5d9f6..9ff9a52fbddd7127a6eea81ab833c7b68ef041e3 100644 (file)
 #define TAPE_COOKIE_TMPL       "ROCKSNDIAMONDS_TAPE_FILE_VERSION_x.x"
 #define SCORE_COOKIE           "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.2"
 
+static struct
+{
+  int filetype;
+  char *id;
+}
+filetype_id_list[] =
+{
+  { LEVEL_FILE_TYPE_RND,       "RND"   },
+  { LEVEL_FILE_TYPE_BD,                "BD"    },
+  { LEVEL_FILE_TYPE_EM,                "EM"    },
+  { LEVEL_FILE_TYPE_SP,                "SP"    },
+  { LEVEL_FILE_TYPE_DX,                "DX"    },
+  { LEVEL_FILE_TYPE_SB,                "SB"    },
+  { LEVEL_FILE_TYPE_DC,                "DC"    },
+  { -1,                                NULL    },
+};
+
 
 /* ========================================================================= */
 /* level file functions                                                      */
@@ -418,6 +435,8 @@ static char *getSingleLevelBasename(int nr, int type)
 
   if (level_filename == NULL)
     level_filename = getStringCat2("%03d.", LEVELFILE_EXTENSION);
+  else
+    type = LEVEL_FILE_TYPE_UNKNOWN;    /* force specified file name/pattern */
 
   switch (type)
   {
@@ -516,6 +535,35 @@ static void setLevelFileInfo_PackedLevelFilename(struct LevelFileInfo *lfi,
   lfi->filename = getLevelFilenameFromBasename(lfi->basename);
 }
 
+static int getFiletypeFromID(char *filetype_id)
+{
+  char *filetype_id_lower;
+  int filetype = LEVEL_FILE_TYPE_UNKNOWN;
+  int i;
+
+  if (filetype_id == NULL)
+    return LEVEL_FILE_TYPE_UNKNOWN;
+
+  filetype_id_lower = getStringToLower(filetype_id);
+
+  for (i = 0; filetype_id_list[i].id != NULL; i++)
+  {
+    char *id_lower = getStringToLower(filetype_id_list[i].id);
+    
+    if (strcmp(filetype_id_lower, id_lower) == 0)
+      filetype = filetype_id_list[i].filetype;
+
+    free(id_lower);
+
+    if (filetype != LEVEL_FILE_TYPE_UNKNOWN)
+      break;
+  }
+
+  free(filetype_id_lower);
+
+  return filetype;
+}
+
 static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi)
 {
   /* special case: level number is negative => check for level template file */
@@ -528,8 +576,11 @@ static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi)
 
   if (leveldir_current->level_filename != NULL)
   {
+    int filetype = getFiletypeFromID(leveldir_current->level_filetype);
+
     /* check for file name/pattern specified in "levelinfo.conf" */
-    setLevelFileInfo_SingleLevelFilename(lfi, LEVEL_FILE_TYPE_UNKNOWN);
+    setLevelFileInfo_SingleLevelFilename(lfi, filetype);
+
     if (fileExists(lfi->filename))
       return;
   }
@@ -1809,7 +1860,7 @@ void CopyNativeLevel_RND_to_EM(struct LevelInfo *level)
   lev->width  = MIN(level->fieldx, EM_MAX_CAVE_WIDTH);
   lev->height = MIN(level->fieldy, EM_MAX_CAVE_HEIGHT);
 
-  lev->time_initial     = level->time * 5;
+  lev->time_seconds     = level->time;
   lev->required_initial = level->gems_needed;
 
   lev->emerald_score   = level->score[SC_EMERALD];
@@ -1918,7 +1969,7 @@ void CopyNativeLevel_EM_to_RND(struct LevelInfo *level)
   level->fieldx = MIN(lev->width,  MAX_LEV_FIELDX);
   level->fieldy = MIN(lev->height, MAX_LEV_FIELDY);
 
-  level->time        = lev->time_initial / 5;
+  level->time        = lev->time_seconds;
   level->gems_needed = lev->required_initial;
 
   sprintf(level->name, "Level %d", level->file_info.nr);
index 12d7f351220687318c3a1b9dc371efc0bd790915..6b8758546ad4f5116e888394985b75cbc6f8508b 100644 (file)
@@ -434,10 +434,17 @@ void convert_em_level(unsigned char *src, int file_version)
   };
   unsigned int i, x, y, temp;
 
+#if 1
+  lev.time_seconds = src[0x83E] << 8 | src[0x83F];
+  if (lev.time_seconds > 9999)
+    lev.time_seconds = 9999;
+#else
   temp = ((src[0x83E] << 8 | src[0x83F]) * 25 + 3) / 4;
   if (temp == 0 || temp > 9999)
     temp = 9999;
   lev.time_initial = temp;
+#endif
+
   lev.required_initial = src[0x82F];
 
   temp = src[0x830] << 8 | src[0x831];
@@ -779,7 +786,9 @@ void prepare_em_level(void)
     for (x = 0; x < WIDTH; x++)
       Draw[y][x] = Cave[y][x];
 
+  lev.time_initial = (lev.time_seconds * 50 + 7) / 8;
   lev.time = lev.time_initial;
+
   lev.required = lev.required_initial;
   lev.score = 0;
 
index e5e5f55e42788dacbe83d83c563da3494a3a67e1..3ba720be692335a1d5e3da031ce29491df911cd7 100644 (file)
@@ -41,6 +41,9 @@
 #define SXSIZE                 (SCR_FIELDX * TILEX)
 #define SYSIZE                 (SCR_FIELDY * TILEY)
 
+#define DISPLAY_TIME(x)                (((x) * 8 + 49) / 50)
+
+
 extern Bitmap *screenBitmap;
 extern Bitmap *scoreBitmap;
 
index 3dcbb778486e284080a6df999778dda3c0a4e9aa..1d7e113030abba7e75b5d508eb49017e869e8ebd 100644 (file)
@@ -232,7 +232,7 @@ void game_initscreen(void)
       screentiles[y][x] = -1;
 
   DrawGameDoorValues_EM(lev.required, ply1.dynamite, lev.score,
-                       (lev.time + 4) / 5);
+                       DISPLAY_TIME(lev.time + 4));
 }
 
 void game_animscreen(void)
index 98a896e191209aae6604c238e9125e82f0c25276..33df9f3fb4a1ff8471fbff2564235bfc316ec07c 100644 (file)
@@ -70,7 +70,11 @@ void InitGameEngine_EM()
 void GameActions_EM(byte action)
 {
   static unsigned long game_frame_delay = 0;
+#if 1
+  unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
+#else
   unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
+#endif
 
 #if 0
   /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
@@ -101,7 +105,7 @@ void GameActions_EM(byte action)
     sound_play();
 
     DrawGameDoorValues_EM(lev.required, ply1.dynamite, lev.score,
-                         (lev.time + 4) / 5);
+                         DISPLAY_TIME(lev.time));
   }
 }
 
index abf566f03ac92dacba42f7605b98ac7f4dad3bfd..7620cc2fd194129ff237ca884b850ff4da904973 100644 (file)
@@ -471,10 +471,14 @@ struct LEVEL
 
   unsigned int width;                 /* playfield width */
   unsigned int height;                /* playfield height */
-  unsigned int time_initial;          /* time remaining (initial) */
+
+  unsigned int time_seconds;          /* available time (seconds) */
+  unsigned int time_initial;          /* available time (initial) */
   unsigned int time;                  /* time remaining (runtime) */
+
   unsigned int required_initial;      /* emeralds needed (initial) */
   unsigned int required;              /* emeralds needed (runtime) */
+
   unsigned int score;                 /* score */
 
   /* fill in all below /every/ time you read a level */
index 1ec25ad6fd2295d8e2010f2568ef198f575eaa6a..134ce8033b2017703137d83a6a9e4c947616f729 100644 (file)
@@ -1532,7 +1532,7 @@ struct LevelInfo
 
   int fieldx, fieldy;
 
-  int time;
+  int time;                            /* available time (seconds) */
   int gems_needed;
 
   char name[MAX_LEVEL_NAME_LEN + 1];