From: Holger Schemel Date: Mon, 23 Nov 2009 20:41:20 +0000 (+0100) Subject: rnd-20091123-1-src X-Git-Tag: 3.3.0.0^2~63 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=66815b1b9363de7741defc14e5f7f0dc2183781a;p=rocksndiamonds.git rnd-20091123-1-src --- diff --git a/ChangeLog b/ChangeLog index c1bb34c0..8f62c76e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2009-11-12 * fixed bug with single step mode (there were some cases where the game did not automatically return to pause mode, e.g. when trying to push - things that don't move or when trying to run against a wall) + things that cannot be pushed or when trying to run against a wall) 2009-11-01 * added support for loading Supaplex levels in MPX level file format diff --git a/src/conftime.h b/src/conftime.h index 70b165cd..db5c8315 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-11-12 23:54" +#define COMPILE_DATE_STRING "2009-11-23 21:41" diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index e9b94f96..e11c561c 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -31,11 +31,139 @@ DirectDrawSurface7 mPrimary; long mWidth, mHeight; long mhWnd; long mScrollX, mScrollY; +long mScrollX_last, mScrollY_last; long mDestXOff, mDestYOff; long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +int TEST_flag = 0; + + +static void ScrollPlayfield() +{ + int sx_last = mScrollX_last / TILEX; + int sy_last = mScrollY_last / TILEY; + int sx = mScrollX / TILEX; + int sy = mScrollY / TILEY; + int dx = (sx < sx_last ? +1 : sx > sx_last ? -1 : 0); + int dy = (sy < sy_last ? +1 : sy > sy_last ? -1 : 0); + int x, y; + int sx1 = mScrollX - TILEX; + int sy1 = mScrollY - TILEY; + int sx2 = mScrollX + SXSIZE + TILEX; + int sy2 = mScrollY + SYSIZE + TILEY; + int x1 = sx1 / TILEX; + int y1 = sy1 / TILEY; + int x2 = sx2 / TILEX; + int y2 = sy2 / TILEY; +#if 1 + int buf_xsize = SCR_FIELDX + 2; + int buf_ysize = SCR_FIELDY + 2; +#else + int buf_xsize = MAX_BUF_XSIZE; + int buf_ysize = MAX_BUF_YSIZE; +#endif + + BlitBitmap(screenBitmap, screenBitmap, + TILEX * (dx == -1), + TILEY * (dy == -1), + (MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0), + (MAX_BUF_YSIZE * TILEY) - TILEY * (dy != 0), + TILEX * (dx == 1), + TILEY * (dy == 1)); + + /* when scrolling the whole playfield, do not redraw single tiles */ + for (x = 0; x < MAX_BUF_XSIZE; x++) + for (y = 0; y < MAX_BUF_YSIZE; y++) + redraw[x][y] = FALSE; + redraw_tiles = 0; + + for (y = DisplayMinY; y <= DisplayMaxY; y++) + { + for (x = DisplayMinX; x <= DisplayMaxX; x++) + { + if (x >= x1 && x < x2 && y >= y1 && y < y2) + { + int sx = x - x1; + int sy = y - y1; + int tsi = GetSI(x, y); + long id = ((PlayField16[tsi]) | + (PlayField8[tsi] << 16) | + (DisPlayField[tsi] << 24)); + +#if 0 +#if 1 + printf("::: [%d] %d [%d, %d] [%d]\n", dx, sx, x, y, buf_xsize); +#else + if (sx == 0 || sx == MAX_BUF_XSIZE - 1) + printf("::: %d, %d\n", dx, sx); +#endif +#endif + + if ((dx == -1 && sx == buf_xsize - 1) || + (dx == +1 && sx == 0) || + (dy == -1 && sy == buf_ysize - 1) || + (dy == +1 && sy == 0)) + { + printf("::: %d, %d\n", sx, sy); + + TEST_flag = 1; + + DrawFieldNoAnimated(x, y); + DrawFieldAnimated(x, y); + + TEST_flag = 0; + } + + ScreenBuffer[sx][sy] = id; + } + } + } +} + +static void ScrollPlayfieldIfNeededExt(boolean reset) +{ + int sx_last = mScrollX_last / TILEX; + int sy_last = mScrollY_last / TILEY; + int sx = mScrollX / TILEX; + int sy = mScrollY / TILEY; + boolean initialized = (mScrollX_last != -1 && mScrollY_last != -1); + + if (reset) + { + mScrollX_last = -1; + mScrollY_last = -1; + + return; + } + +#if 0 + if (mScrollX_last == -1 || mScrollY_last == -1) + { + mScrollX_last = mScrollX; + mScrollY_last = mScrollY; + + return; + } +#endif + + if (initialized && (sx != sx_last || sy != sy_last)) + ScrollPlayfield(); + + mScrollX_last = mScrollX; + mScrollY_last = mScrollY; +} + +static void ScrollPlayfieldIfNeeded() +{ + ScrollPlayfieldIfNeededExt(FALSE); +} + +void InitScrollPlayfield() +{ + ScrollPlayfieldIfNeededExt(TRUE); +} void UpdatePlayfield() { @@ -63,10 +191,17 @@ void UpdatePlayfield() (DisPlayField[tsi] << 24)); boolean redraw_screen_tile = (ScreenBuffer[sx][sy] != id); +#if 0 + if (LowByte(PlayField16[tsi]) == fiMurphy) + continue; +#endif + if (redraw_screen_tile) { +#if 0 DrawFieldNoAnimated(x, y); DrawFieldAnimated(x, y); +#endif ScreenBuffer[sx][sy] = id; @@ -571,6 +706,10 @@ void DDScrollBuffer_ScrollTo(int X, int Y) printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTo(): mScroll: %ld, %ld [%d, %d]\n", mScrollX, mScrollY, X, Y); #endif + +#if 1 + ScrollPlayfieldIfNeeded(); +#endif } void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) @@ -607,6 +746,10 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTowards(): (2) mScroll: %ld, %ld [%d, %d, %f]\n", mScrollX, mScrollY, X, Y, Step); #endif + +#if 1 + ScrollPlayfieldIfNeeded(); +#endif } void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) @@ -685,4 +828,8 @@ SoftScrollEH: printf("::: DDScrollBuffer.c: DDScrollBuffer_SoftScrollTo(): mScroll: %ld, %ld\n", mScrollX, mScrollY); #endif + +#if 1 + ScrollPlayfieldIfNeeded(); +#endif } diff --git a/src/game_sp/DDScrollBuffer.h b/src/game_sp/DDScrollBuffer.h index dbcb1db5..d8633813 100644 --- a/src/game_sp/DDScrollBuffer.h +++ b/src/game_sp/DDScrollBuffer.h @@ -16,6 +16,10 @@ extern long mScrollX, mScrollY; extern boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +extern int TEST_flag; + + +extern void InitScrollPlayfield(); extern void UpdatePlayfield(); extern void DDScrollBuffer_Blt_Ext(Bitmap *); diff --git a/src/game_sp/DDSpriteBuffer.c b/src/game_sp/DDSpriteBuffer.c index 7572c919..95ac25a3 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -183,8 +183,10 @@ static void Blt(int pX, int pY, int SpriteX, int SpriteY) int sy2 = mScrollY + SYSIZE + TILEY; int x1 = sx1 / TILEX; int y1 = sy1 / TILEY; +#if 0 int x2 = sx2 / TILEX; int y2 = sy2 / TILEY; +#endif int sx = pX - x1 * TILEX; int sy = pY - y1 * TILEY; @@ -197,6 +199,18 @@ static void Blt(int pX, int pY, int SpriteX, int SpriteY) if (NoDisplayFlag) return; +#if 1 + if (TEST_flag) + { + if (pX < sx1 || pX >= sx2 || pY < sy1 || pY >= sy2) + printf("::: DDSpriteBuffer.c: Blt(): %d, %d [%d..%d, %d..%d] (%d, %d) [SKIPPED]\n", + pX, pY, sx1, sx2, sy1, sy2, mScrollX, mScrollY); + else + printf("::: DDSpriteBuffer.c: Blt(): %d, %d [%d..%d, %d..%d] (%d, %d)\n", + pX, pY, sx1, sx2, sy1, sy2, mScrollX, mScrollY); + } +#endif + /* do not draw fields that are outside the visible screen area */ if (pX < sx1 || pX >= sx2 || pY < sy1 || pY >= sy2) return; @@ -249,6 +263,8 @@ static void Blt(int pX, int pY, int SpriteX, int SpriteY) #endif } +#if 0 + static void OLD_Blt(int pX, int pY, int SpriteX, int SpriteY) { RECT DR, SR; @@ -323,6 +339,8 @@ static void OLD_Blt(int pX, int pY, int SpriteX, int SpriteY) #endif } +#endif + void DDSpriteBuffer_BltEx(int pX, int pY, int SpritePos) { int XPos, YPos; @@ -333,6 +351,12 @@ void DDSpriteBuffer_BltEx(int pX, int pY, int SpritePos) XPos = (SpritePos % mXSpriteCount) + 1; YPos = (SpritePos / mXSpriteCount) + 1; +#if 0 + if (TEST_flag) + printf("::: DDSpriteBuffer_BltEx(): %d, %d [%d]\n", + pX, pY, SpritePos); +#endif + Blt(pX, pY, XPos, YPos); } diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 2f845154..9897250e 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -3208,8 +3208,9 @@ void DrawFieldNoAnimated(int X, int Y) } #if 0 - printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n", - X, Y, Tmp); + if (TEST_flag) + printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n", + X, Y, Tmp); #endif StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 467c82d2..bd24db8b 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -11,6 +11,8 @@ void InitGameEngine_SP() game_sp_info.LevelSolved = FALSE; game_sp_info.GameOver = FALSE; + InitScrollPlayfield(); + #if 1 menPlay_Click(); #else