From ef9242bb9320d705010959ba11fdf697dc1e5b70 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 17 Oct 2004 23:21:00 +0200 Subject: [PATCH] rnd-20041017-2-src --- src/conftime.h | 2 +- src/files.c | 57 +++++++++++++++++++++++++++++++++++++++--- src/game_em/convert.c | 9 +++++++ src/game_em/display.h | 3 +++ src/game_em/graphics.c | 2 +- src/game_em/input.c | 6 ++++- src/game_em/main_em.h | 6 ++++- src/main.h | 2 +- 8 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index fd13ab2a..342667de 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-10-17 03:55]" +#define COMPILE_DATE_STRING "[2004-10-17 23:19]" diff --git a/src/files.c b/src/files.c index d616c10c..9ff9a52f 100644 --- a/src/files.c +++ b/src/files.c @@ -49,6 +49,23 @@ #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); diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 12d7f351..6b875854 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -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; diff --git a/src/game_em/display.h b/src/game_em/display.h index e5e5f55e..3ba720be 100644 --- a/src/game_em/display.h +++ b/src/game_em/display.h @@ -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; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 3dcbb778..1d7e1130 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -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) diff --git a/src/game_em/input.c b/src/game_em/input.c index 98a896e1..33df9f3f 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -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)); } } diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index abf566f0..7620cc2f 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -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 */ diff --git a/src/main.h b/src/main.h index 1ec25ad6..134ce803 100644 --- a/src/main.h +++ b/src/main.h @@ -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]; -- 2.34.1