X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FDDScrollBuffer.c;h=de24a9218fde06bdce81bf428f65f67add1f610b;hb=92a3daab2223b297cdb51fa9763c6acad423b2de;hp=263f31f646d21c1be986b016f77fa2f3981f785b;hpb=97baecdfcf386d972f6f8e6eec9ddfd3021ed7ed;p=rocksndiamonds.git diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 263f31f6..de24a921 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -7,14 +7,14 @@ #include -long mScrollX, mScrollY; -long mScrollX_last, mScrollY_last; +int mScrollX, mScrollY; +int mScrollX_last, mScrollY_last; #if 1 -long ScreenBuffer[2 + MAX_PLAYFIELD_WIDTH + 2][2 + MAX_PLAYFIELD_HEIGHT + 2]; +int 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]; +int ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; #endif @@ -50,6 +50,15 @@ static void ScrollPlayfield(int dx, int dy) int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2; int x, y; +#if NEW_TILESIZE + BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp, + TILEX_VAR * (dx == -1), + TILEY_VAR * (dy == -1), + (MAX_BUF_XSIZE * TILEX_VAR) - TILEX_VAR * (dx != 0), + (MAX_BUF_YSIZE * TILEY_VAR) - TILEY_VAR * (dy != 0), + TILEX_VAR * (dx == 1), + TILEY_VAR * (dy == 1)); +#else BlitBitmap(bitmap_db_field_sp, bitmap_db_field_sp, TILEX * (dx == -1), TILEY * (dy == -1), @@ -57,6 +66,7 @@ static void ScrollPlayfield(int dx, int dy) (MAX_BUF_YSIZE * TILEY) - TILEY * (dy != 0), TILEX * (dx == 1), TILEY * (dy == 1)); +#endif /* when scrolling the whole playfield, do not redraw single tiles */ #if 1 @@ -81,9 +91,9 @@ static void ScrollPlayfield(int dx, int dy) int sx = x - x1; int sy = y - y1; int tsi = GetSI(x, y); - long id = ((PlayField16[tsi]) | - (PlayField8[tsi] << 16) | - (DisPlayField[tsi] << 24)); + int id = ((PlayField16[tsi]) | + (PlayField8[tsi] << 16) | + (DisPlayField[tsi] << 24)); if ((dx == -1 && x == x2) || (dx == +1 && x == x1) || @@ -251,8 +261,17 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) int xsize = SXSIZE; int ysize = SYSIZE; +#if NEW_TILESIZE + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; +#else int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; +#endif + +#if NEW_TILESIZE + +#endif sxsize = (full_xsize < xsize ? full_xsize : xsize); sysize = (full_ysize < ysize ? full_ysize : ysize); @@ -271,6 +290,22 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) } #endif +#if NEW_TILESIZE + px = px * TILESIZE_VAR / TILESIZE; + py = py * TILESIZE_VAR / TILESIZE; +#endif + +#if 0 + printf("::: (%d, %d) (%d, %d) (%d, %d) [%d / %d]\n", + px, py, sxsize, sysize, sx, sy, + FieldHeight, menBorder); +#endif + +#if 0 + printf("::: (%d, %d)\n", + bitmap_db_field_sp->width, bitmap_db_field_sp->height); +#endif + BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy); } @@ -296,7 +331,8 @@ void BackToFront_SP(void) SyncDisplay(); - if (redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last || + if (0 || + redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last || ExplosionShakeMurphy != 0 || ExplosionShakeMurphy_last != 0) { BlitScreenToBitmap_SP(window); @@ -307,12 +343,35 @@ void BackToFront_SP(void) int scroll_yoffset = mScrollY - mScrollY_last + game_sp.scroll_yoffset; int x1 = 0, x2 = SCR_FIELDX - (scroll_xoffset != 0 ? 0 : 1); int y1 = 0, y2 = SCR_FIELDY - (scroll_yoffset != 0 ? 0 : 1); +#if NEW_TILESIZE + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX_VAR; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY_VAR; +#else int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; +#endif +#if 1 + int xsize = SXSIZE; + int ysize = SYSIZE; + int sxsize = (full_xsize < xsize ? full_xsize : xsize); + int sysize = (full_ysize < ysize ? full_ysize : ysize); + int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); + int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); +#else int sx = SX + (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0); int sy = SY + (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0); +#endif +#if 1 + InitGfxClipRegion(TRUE, sx, sy, sxsize, sysize); +#else InitGfxClipRegion(TRUE, SX, SY, SXSIZE, SYSIZE); +#endif + +#if NEW_TILESIZE + scroll_xoffset = scroll_xoffset * TILESIZE_VAR / TILESIZE; + scroll_yoffset = scroll_yoffset * TILESIZE_VAR / TILESIZE; +#endif for (x = x1; x <= x2; x++) { @@ -321,11 +380,19 @@ void BackToFront_SP(void) int xx = 2 + x; int yy = 2 + y; +#if NEW_TILESIZE + if (redraw[xx][yy]) + BlitBitmap(bitmap_db_field_sp, window, + xx * TILEX_VAR, yy * TILEY_VAR, TILEX_VAR, TILEY_VAR, + sx + x * TILEX_VAR - scroll_xoffset, + sy + y * TILEY_VAR - scroll_yoffset); +#else if (redraw[xx][yy]) BlitBitmap(bitmap_db_field_sp, window, xx * TILEX, yy * TILEY, TILEX, TILEY, sx + x * TILEX - scroll_xoffset, sy + y * TILEY - scroll_yoffset); +#endif } } @@ -387,12 +454,15 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) ScrollPlayfieldIfNeeded(); } -void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) +void DDScrollBuffer_SoftScrollTo(int X, int Y, int TimeMS, int FPS) { double dx, dY; - long dT, StepCount; +#if 0 + int dT; +#endif + int StepCount; double T, tStep; - long oldX, oldY, maxD; + int oldX, oldY, maxD; static boolean AlreadyRunning = False; if (NoDisplayFlag) @@ -414,7 +484,9 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) if (StepCount == 0) StepCount = 1; +#if 0 dT = 1000 / FPS; +#endif tStep = (double)1 / StepCount; oldX = mScrollX; oldY = mScrollY;