From: Holger Schemel Date: Thu, 8 Jul 2010 13:42:00 +0000 (+0200) Subject: rnd-20100708-1-src X-Git-Tag: 3.3.1.0^2~12 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=205e33df255a817dc1032696f065256a08aa61fa;p=rocksndiamonds.git rnd-20100708-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 3ac52c50..d417f020 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-07-07 09:32" +#define COMPILE_DATE_STRING "2010-07-08 15:40" diff --git a/src/game.c b/src/game.c index 8236de11..7c70ae07 100644 --- a/src/game.c +++ b/src/game.c @@ -4355,21 +4355,26 @@ void InitGame() } #if NEW_TILESIZE -#if 1 - // if (TILESIZE_VAR < TILESIZE && EVEN(SCR_FIELDX)) + + if (lev_fieldx + (SBX_Left < 0 ? 2 : 0) <= SCR_FIELDX) + SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; + + if (lev_fieldy + (SBY_Upper < 0 ? 2 : 0) <= SCR_FIELDY) + SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; + if (EVEN(SCR_FIELDX)) - { SBX_Left--; - // SBX_Right++; - } -#endif -#endif + if (EVEN(SCR_FIELDY)) + SBY_Upper--; + +#else if (lev_fieldx + (SBX_Left == -1 ? 2 : 0) <= SCR_FIELDX) SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; if (lev_fieldy + (SBY_Upper == -1 ? 2 : 0) <= SCR_FIELDY) SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; +#endif /* if local player not found, look for custom element that might create the player (make some assumptions about the right custom element) */ @@ -4480,6 +4485,8 @@ void InitGame() local_player->jy - MIDPOSY); } + printf("::: %d, %d (initial)\n", scroll_x, scroll_y); + #if 0 /* do not use PLAYING mask for fading out from main screen */ game_status = GAME_MODE_MAIN; diff --git a/src/tools.c b/src/tools.c index 9a712934..ba0ec81c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -312,8 +312,9 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) #if NEW_TILESIZE int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); - - int bx1, bx2, ffx, ffy; + int dx_var = dx * TILESIZE_VAR / TILESIZE; + int dy_var = dy * TILESIZE_VAR / TILESIZE; + int ffx, ffy; // fx += dx * TILESIZE_VAR / TILESIZE; // fy += dy * TILESIZE_VAR / TILESIZE; @@ -324,24 +325,36 @@ void BlitScreenToBitmap(Bitmap *target_bitmap) /* !!! THIS WORKS !!! */ - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; + 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; if (EVEN(SCR_FIELDX)) { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + 2 * TILEX_VAR / 2) - { - fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2) + - 1 * TILEX_VAR; - } + if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) + fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; else - { - fx = fx - (dx <= 0 ? TILEX_VAR : 0) + 1 * TILEX_VAR; - - printf("::: STOPPED\n"); - } + fx += (dx > 0 ? TILEX_VAR : 0); + } + else + { + fx += dx; + } - printf("::: %d (%d, %d) [%d] [%d] => %d\n", - ffx, SBX_Left * TILEX_VAR, SBX_Right * TILEX_VAR, dx, FX, fx); + if (EVEN(SCR_FIELDY)) + { + 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); + } + else + { + fy += dy; } if (border.draw_masked[GAME_MODE_PLAYING]) @@ -458,172 +471,88 @@ void BackToFront() } else { +#if 1 + BlitScreenToBitmap(window); +#else int fx = FX, fy = FY; - if (setup.soft_scrolling) - { #if NEW_TILESIZE - int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); - int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); - - int bx1, bx2, ffx, ffy; + int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); + int dx_var = dx * TILESIZE_VAR / TILESIZE; + int dy_var = dy * TILESIZE_VAR / TILESIZE; + int ffx, ffy; - // fx += dx * TILESIZE_VAR / TILESIZE; - // fy += dy * TILESIZE_VAR / TILESIZE; + // fx += dx * TILESIZE_VAR / TILESIZE; + // fy += dy * TILESIZE_VAR / TILESIZE; #else - fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); - fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); -#endif - -#if 1 - -#if 0 - bx1 = SBX_Left * TILEX_VAR + TILEX_VAR / 2; - // bx1 = SBX_Left * TILEX_VAR; - bx2 = SBX_Right * TILEX_VAR - TILEX_VAR / 2; - ffx = scroll_x * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; - - if (ffx > bx1) // && ffx < bx2) - fx += dx * TILESIZE_VAR / TILESIZE; - - // fx += TILEX_VAR - (ffx - bx1) % TILEX_VAR; - - printf("::: %d (%d, %d) (%d)\n", ffx, bx1, bx2, dx); - -#if 0 - if (ffx > SBX_Left * TILEX_VAR) - fx -= MIN(ffx, TILEX_VAR / 2); - if (ffx > SBX_Left * TILEX_VAR && ffx < (SBX_Right + 1) * TILEX_VAR) - fx -= MIN(ffx, TILEX_VAR / 2); + fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); #endif -#else - -#if 0 - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; - - if (EVEN(SCR_FIELDX)) - { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2) - fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2); - else - fx = fx - (dx <= 0 ? TILEX_VAR : 0); - - printf("::: %d (%d, %d) [%d] [%d] => %d\n", - ffx, SBX_Left * TILEX_VAR, SBX_Right * TILEX_VAR, dx, FX, fx); - } -#else - -#if 0 - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; - - if (EVEN(SCR_FIELDX)) - { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + 0 * TILEX_VAR / 2) - { - fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2) + - 1 * TILEX_VAR; - } - else - { - fx = fx - (dx <= 0 ? TILEX_VAR : 0) + 1 * TILEX_VAR; - - printf("::: STOPPED\n"); - } - - printf("::: %d (%d, %d) [%d] [%d] => %d\n", - ffx, SBX_Left * TILEX_VAR, SBX_Right * TILEX_VAR, dx, FX, fx); - } -#else - /* !!! THIS WORKS !!! */ + /* !!! THIS WORKS !!! */ - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; - - if (EVEN(SCR_FIELDX)) - { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + 2 * TILEX_VAR / 2) - { - fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2) + - 1 * TILEX_VAR; - } - else - { - fx = fx - (dx <= 0 ? TILEX_VAR : 0) + 1 * TILEX_VAR; + printf("::: %d, %d\n", scroll_x, scroll_y); - printf("::: STOPPED\n"); - } + ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; + ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; - printf("::: %d (%d, %d) [%d] [%d] [%d, %d] => %d\n", - ffx, SBX_Left * TILEX_VAR, SBX_Right * TILEX_VAR, - dx, FX, ScreenMovDir, ScreenGfxPos, fx); - } + if (EVEN(SCR_FIELDX)) + { + if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) + fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; else - { - fx += dx; - } + fx += (dx > 0 ? TILEX_VAR : 0); + } + else + { + fx += dx; + } + if (EVEN(SCR_FIELDY)) + { + 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); + } + else + { fy += dy; -#endif - -#endif - -#endif - -#if 0 - printf("::: %d, %d [%d, %d] [%d, %d] [%d, %d] [%d] [%d, %d]\n", - fx, fy, FX, FY, ScreenMovDir, ScreenGfxPos, - scroll_x, scroll_y, - ffx, - SBX_Left, SBX_Right); -#endif - -#endif - -#if 0 -#if NEW_TILESIZE - fx = fx * TILESIZE_VAR / TILESIZE; - fy = fy * TILESIZE_VAR / TILESIZE; -#endif -#endif } - if (setup.soft_scrolling || - ABS(ScreenMovPos) + ScrollStepSize == TILEX || - ABS(ScreenMovPos) == ScrollStepSize || - redraw_tiles > REDRAWTILES_THRESHOLD) + if (border.draw_masked[GAME_MODE_PLAYING]) { - if (border.draw_masked[GAME_MODE_PLAYING]) - { - if (buffer != backbuffer) - { - /* copy playfield buffer to backbuffer to add masked border */ - BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY); - DrawMaskedBorder(REDRAW_FIELD); - } - - BlitBitmap(backbuffer, window, - REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, - REAL_SX, REAL_SY); - } - else + if (buffer != backbuffer) { - BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY); + /* copy playfield buffer to backbuffer to add masked border */ + BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY); + DrawMaskedBorder(REDRAW_FIELD); } + BlitBitmap(backbuffer, window, + REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, + REAL_SX, REAL_SY); + } + else + { + BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY); + } +#endif + #if 0 #ifdef DEBUG - printf("redrawing all (ScreenGfxPos == %d) because %s\n", - ScreenGfxPos, - (setup.soft_scrolling ? - "setup.soft_scrolling" : - ABS(ScreenGfxPos) + ScrollStepSize == TILEX ? - "ABS(ScreenGfxPos) + ScrollStepSize == TILEX" : - ABS(ScreenGfxPos) == ScrollStepSize ? - "ABS(ScreenGfxPos) == ScrollStepSize" : - "redraw_tiles > REDRAWTILES_THRESHOLD")); + printf("redrawing all (ScreenGfxPos == %d) because %s\n", + ScreenGfxPos, + (setup.soft_scrolling ? + "setup.soft_scrolling" : + ABS(ScreenGfxPos) + ScrollStepSize == TILEX ? + "ABS(ScreenGfxPos) + ScrollStepSize == TILEX" : + ABS(ScreenGfxPos) == ScrollStepSize ? + "ABS(ScreenGfxPos) == ScrollStepSize" : + "redraw_tiles > REDRAWTILES_THRESHOLD")); #endif #endif - } } redraw_mask &= ~REDRAW_MAIN; @@ -670,14 +599,15 @@ void BackToFront() int ffx, ffy; int fx = FX, fy = FY; - ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; + ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx * TILESIZE_VAR / TILESIZE; + ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy * TILESIZE_VAR / TILESIZE; if (EVEN(SCR_FIELDX)) { - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + 2 * TILEX_VAR / 2) + if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) { fx = fx + dx * TILESIZE_VAR / TILESIZE - MIN(ffx, TILEX_VAR / 2) + - 1 * TILEX_VAR; + TILEX_VAR; if (fx % TILEX_VAR) sx -= TILEX_VAR / 2; @@ -686,7 +616,25 @@ void BackToFront() } else { - fx = fx - (dx <= 0 ? TILEX_VAR : 0) + 1 * TILEX_VAR; + fx = fx - (dx <= 0 ? TILEX_VAR : 0) + TILEX_VAR; + } + } + + if (EVEN(SCR_FIELDY)) + { + if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) + { + fy = fy + dy * TILESIZE_VAR / TILESIZE - MIN(ffy, TILEY_VAR / 2) + + TILEY_VAR; + + if (fy % TILEY_VAR) + sy -= TILEY_VAR / 2; + else + sy -= TILEY_VAR; + } + else + { + fy = fy - (dy <= 0 ? TILEY_VAR : 0) + TILEY_VAR; } } @@ -7281,6 +7229,7 @@ inline static int get_effective_element_EM(int tile, int frame_em) return (frame_em > 5 ? EL_EMPTY : element); #if 0 + /* !!! FIX !!! */ case Ydiamond_stone: // if (!game.use_native_emc_graphics_engine) return EL_ROCK;