X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FDDScrollBuffer.c;h=70c4c5a6c4835affe4c189ed282d238a9bff69e3;hb=41def9c1d8c6939b8754fdab43579272e49d4da4;hp=0f1191ce1eb6153ba86abbba68070b6a6849179b;hpb=d45b35552f4ca1ada1266fb7e8b6968d878019a6;p=rocksndiamonds.git diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 0f1191ce..70c4c5a6 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -7,14 +7,16 @@ #include -long mWidth, mHeight; -long mhWnd; long mScrollX, mScrollY; long mScrollX_last, mScrollY_last; -long mDestXOff, mDestYOff; +#if 1 +long ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2]; +boolean redraw[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2]; +#else long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; +#endif void RestorePlayfield() @@ -48,7 +50,7 @@ static void ScrollPlayfield(int dx, int dy) int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2; int x, y; - BlitBitmap(screenBitmap, screenBitmap, + BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp, TILEX * (dx == -1), TILEY * (dy == -1), (MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0), @@ -62,9 +64,7 @@ static void ScrollPlayfield(int dx, int dy) redraw[x][y] = FALSE; redraw_tiles = 0; -#if 1 DrawFrameIfNeeded(); -#endif for (y = DisplayMinY; y <= DisplayMaxY; y++) { @@ -200,7 +200,7 @@ void UpdatePlayfield(boolean force_redraw) printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame); #endif - StretchedSprites.BltImg(sx, sy, graphic, sync_frame); + DDSpriteBuffer_BltImg(sx, sy, graphic, sync_frame); #if 1 num_redrawn++; @@ -222,23 +222,44 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY; int sx, sy, sxsize, sysize; +#if 1 + printf("::: %d, %d - %d, %d - %ld, %ld\n", + MurphyScreenXPos, MurphyScreenYPos, + ScreenScrollXPos, ScreenScrollYPos, + mScrollX, mScrollY); +#endif + int xsize = SXSIZE; int ysize = SYSIZE; - int full_xsize = (FieldWidth - (menBorder.Checked ? 0 : 1)) * TILEX; - int full_ysize = (FieldHeight - (menBorder.Checked ? 0 : 1)) * TILEY; + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; sxsize = (full_xsize < xsize ? full_xsize : xsize); sysize = (full_ysize < ysize ? full_ysize : ysize); sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); - if (!menBorder.Checked) +#if 1 + if (0 && !menBorder) + { + if (mScrollX < ScrollMinX + TILEX / 2) + px += ScrollMinX + TILEX / 2 - mScrollX; + else if (mScrollX > ScrollMaxX - TILEX / 2) + px -= mScrollX - (ScrollMaxX - TILEX / 2); + if (mScrollY < ScrollMinY + TILEY / 2) + py += ScrollMinY + TILEY / 2 - mScrollY; + else if (mScrollY > ScrollMaxY - TILEY / 2) + py -= mScrollY - (ScrollMaxY - TILEY / 2); + } +#else + if (!menBorder) { px += TILEX / 2; py += TILEY / 2; } +#endif - BlitBitmap(screenBitmap, target_bitmap, px, py, sxsize, sysize, sx, sy); + BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy); } void BackToFront_SP(void) @@ -266,7 +287,7 @@ void BackToFront_SP(void) int yy = (top + y) % MAX_BUF_YSIZE; if (redraw[xx][yy]) - BlitBitmap(screenBitmap, window, + BlitBitmap(bitmap_db_field_sp, window, xx * TILEX, yy * TILEY, TILEX, TILEY, SX + x * TILEX, SY + y * TILEY); } @@ -283,26 +304,15 @@ void BackToFront_SP(void) scrolling_last = scrolling; } -void DDScrollBuffer_Blt() -{ - BackToFront_SP(); -} - void DDScrollBuffer_ScrollTo(int X, int Y) { if (NoDisplayFlag) return; - X = X / Stretch; - Y = Y / Stretch; - mScrollX = X; - mScrollY = Y; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = X; + ScrollY = mScrollY = Y; -#if 1 ScrollPlayfieldIfNeeded(); -#endif } void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) @@ -312,12 +322,11 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) if (NoDisplayFlag) return; - X = X / Stretch; - Y = Y / Stretch; dx = X - mScrollX; dY = Y - mScrollY; + r = Sqr(dx * dx + dY * dY); - if (r == 0) // we are there already + if (r == 0) // we are there already return; if (Step < r) @@ -325,14 +334,10 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) else r = 1; - mScrollX = mScrollX + dx * r; - mScrollY = mScrollY + dY * r; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = mScrollX + dx * r; + ScrollY = mScrollY = mScrollY + dY * r; -#if 1 ScrollPlayfieldIfNeeded(); -#endif } void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) @@ -347,16 +352,14 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) return; if (AlreadyRunning) - { return; - } AlreadyRunning = True; - X = X / Stretch; - Y = Y / Stretch; + dx = X - mScrollX; dY = Y - mScrollY; maxD = (Abs(dx) < Abs(dY) ? Abs(dY) : Abs(dx)); + StepCount = FPS * (TimeMS / (double)1000); if (StepCount > maxD) StepCount = maxD; @@ -368,31 +371,17 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) tStep = (double)1 / StepCount; oldX = mScrollX; oldY = mScrollY; - // R = Sqr(dX * dX + dY * dY) - // If R = 0 Then Exit Sub 'we are there already + for (T = (double)tStep; T <= (double)1; T += tStep) { - if (UserDragFlag) - goto SoftScrollEH; - - mScrollX = oldX + T * dx; - mScrollY = oldY + T * dY; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = oldX + T * dx; + ScrollY = mScrollY = oldY + T * dY; } - if (UserDragFlag) - goto SoftScrollEH; + ScrollX = mScrollX = X; + ScrollY = mScrollY = Y; - mScrollX = X; - mScrollY = Y; - ScrollX = mScrollX; - ScrollY = mScrollY; - -SoftScrollEH: AlreadyRunning = False; -#if 1 ScrollPlayfieldIfNeeded(); -#endif }