From 31b462a53d66e5d4fb8701c2b7d31180af1f5f6d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 19 Jul 2010 21:08:27 +0200 Subject: [PATCH] rnd-20100719-1-src * fixed some problems with half tile size and even tile sized playfields --- ChangeLog | 3 +++ src/conftime.h | 2 +- src/game.c | 6 +++-- src/libgame/setup.c | 11 ++++++--- src/screens.c | 2 +- src/tools.c | 57 ++++++++++++++++++++++++++++----------------- 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1a0045e..08221dca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-07-19 + * fixed some problems with half tile size and even tile sized playfields + 2010-07-12 * added level selection screen (when clicking on main menu level number) * added level tracing (played, solved) for use in level selection screen diff --git a/src/conftime.h b/src/conftime.h index da268da6..9909b538 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-07-13 01:20" +#define COMPILE_DATE_STRING "2010-07-19 21:04" diff --git a/src/game.c b/src/game.c index 7bfaa2cc..e7523585 100644 --- a/src/game.c +++ b/src/game.c @@ -4485,7 +4485,9 @@ void InitGame() local_player->jy - MIDPOSY); } +#if 0 printf("::: %d, %d (initial)\n", scroll_x, scroll_y); +#endif #if 0 /* do not use PLAYING mask for fading out from main screen */ @@ -4642,7 +4644,7 @@ void InitGame() SaveLevelSetup_SeriesInfo(); -#if 1 +#if 0 printf("::: PLAYING LEVEL (%d)\n", LevelStats_getPlayed(level_nr)); #endif } @@ -4896,7 +4898,7 @@ void GameWon() SaveLevelSetup_SeriesInfo(); -#if 1 +#if 0 printf("::: LEVEL SOLVED (%d)\n", LevelStats_getSolved(level_nr)); #endif } diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 7bb8ecdb..412779d0 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4092,7 +4092,7 @@ void LoadLevelSetup_SeriesInfo() BEGIN_HASH_ITERATION(level_setup_hash, itr) { char *token = HASH_ITERATION_TOKEN(itr); - char *value = HASH_ITERATION_TOKEN(itr); + char *value = HASH_ITERATION_VALUE(itr); if (strlen(token) == 3 && token[0] >= '0' && token[0] <= '9' && @@ -4101,8 +4101,13 @@ void LoadLevelSetup_SeriesInfo() { int level_nr = atoi(token); - LevelStats_setPlayed(level_nr, atoi(value)); - LevelStats_setSolved(level_nr, atoi(strchr(value, ' '))); + if (value != NULL) + LevelStats_setPlayed(level_nr, atoi(value)); /* read 1st column */ + + value = strchr(value, ' '); + + if (value != NULL) + LevelStats_setSolved(level_nr, atoi(value)); /* read 2nd column */ } } END_HASH_ITERATION(hash, itr) diff --git a/src/screens.c b/src/screens.c index 3b1b92fb..129d0263 100644 --- a/src/screens.c +++ b/src/screens.c @@ -3773,7 +3773,7 @@ void DrawChooseLevelNr() sprintf(identifier, "%d", value); sprintf(name, "%03d: %s", value, - (level.no_valid_file ? "(empty)" : level.name)); + (level.no_valid_file ? "(no file)" : level.name)); setString(&ti->identifier, identifier); setString(&ti->name, name); diff --git a/src/tools.c b/src/tools.c index ba0ec81c..c89ef367 100644 --- a/src/tools.c +++ b/src/tools.c @@ -323,13 +323,6 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); #endif - /* !!! THIS WORKS !!! */ - - printf("::: (%d, %d) [(%d / %d, %d / %d)]\n", - scroll_x, scroll_y, - SBX_Left, SBX_Right, - SBY_Upper, SBY_Lower); - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; @@ -338,11 +331,11 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; else - fx += (dx > 0 ? TILEX_VAR : 0); + fx += (dx_var > 0 ? TILEX_VAR : 0); } else { - fx += dx; + fx += dx_var; } if (EVEN(SCR_FIELDY)) @@ -350,13 +343,21 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; else - fy += (dy > 0 ? TILEY_VAR : 0); + fy += (dy_var > 0 ? TILEY_VAR : 0); } else { - fy += dy; + fy += dy_var; } +#if 0 + printf("::: (%d, %d) [(%d / %d, %d / %d)] => %d, %d\n", + scroll_x, scroll_y, + SBX_Left, SBX_Right, + SBY_Upper, SBY_Lower, + fx, fy); +#endif + if (border.draw_masked[GAME_MODE_PLAYING]) { if (buffer != backbuffer) @@ -394,6 +395,13 @@ void BackToFront() if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD) redraw_mask |= REDRAW_FIELD; +#if 0 + /* !!! TEST ONLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 */ + /* (force full redraw) */ + if (game_status == GAME_MODE_PLAYING) + redraw_mask |= REDRAW_FIELD; +#endif + if (redraw_mask & REDRAW_FIELD) redraw_mask &= ~REDRAW_TILES; @@ -596,18 +604,22 @@ void BackToFront() int sy = SY; // + (EVEN(SCR_FIELDY) ? TILEY_VAR / 2 : 0); int dx = 0, dy = 0; + int dx_var = dx * TILESIZE_VAR / TILESIZE; + int dy_var = dy * TILESIZE_VAR / TILESIZE; int ffx, ffy; int fx = FX, fy = FY; - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; - ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy * TILESIZE_VAR / TILESIZE; + int scr_fieldx = SCR_FIELDX + (EVEN(SCR_FIELDX) ? 2 : 0); + int scr_fieldy = SCR_FIELDY + (EVEN(SCR_FIELDY) ? 2 : 0); + + ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; + ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; if (EVEN(SCR_FIELDX)) { if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) { - fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2) + - TILEX_VAR; + fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; if (fx % TILEX_VAR) sx -= TILEX_VAR / 2; @@ -616,7 +628,7 @@ void BackToFront() } else { - fx = fx - (dx <= 0 ? TILEX_VAR : 0) + TILEX_VAR; + fx += (dx_var > 0 ? TILEX_VAR : 0); } } @@ -624,8 +636,7 @@ void BackToFront() { if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) { - fy = fy + dy * TILESIZE_VAR / TILESIZE - MIN(ffy, TILEY_VAR / 2) + - TILEY_VAR; + fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; if (fy % TILEY_VAR) sy -= TILEY_VAR / 2; @@ -634,12 +645,16 @@ void BackToFront() } else { - fy = fy - (dy <= 0 ? TILEY_VAR : 0) + TILEY_VAR; + fy += (dy_var > 0 ? TILEY_VAR : 0); } } - for (x = 0; x < SCR_FIELDX; x++) - for (y = 0 ; y < SCR_FIELDY; y++) +#if 0 + printf("::: %d, %d, %d, %d\n", sx, sy, SCR_FIELDX, SCR_FIELDY); +#endif + + for (x = 0; x < scr_fieldx; x++) + for (y = 0 ; y < scr_fieldy; y++) if (redraw[redraw_x1 + x][redraw_y1 + y]) BlitBitmap(buffer, window, FX + x * TILEX_VAR, FY + y * TILEY_VAR, -- 2.34.1