From: Holger Schemel Date: Sun, 18 Apr 2010 18:52:21 +0000 (+0200) Subject: rnd-20100418-1-src X-Git-Tag: 3.3.0.0^2~8 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=475d747d7f6122bf9b62ccf1518fc7e8fc0f201c rnd-20100418-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 631c6c00..06f20856 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-04-17 23:20" +#define COMPILE_DATE_STRING "2010-04-18 20:47" diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 80cddf0d..792648d4 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -227,7 +227,7 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY; int sx, sy, sxsize, sysize; -#if 1 +#if 0 printf("::: %d, %d / %d, %d / %ld, %ld (%ld, %ld) / %d, %d\n", MurphyScreenXPos, MurphyScreenYPos, ScreenScrollXPos, ScreenScrollYPos, @@ -246,40 +246,9 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); -#if 1 -#if 1 - { - px += game_sp.scroll_xoffset; - py += game_sp.scroll_yoffset; - } -#else - if (1) - { - px += TILEX / 2; - py += TILEY / 2; - } -#endif -#else -#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 -#endif + /* scroll correction for even number of visible tiles (half tile shifted) */ + px += game_sp.scroll_xoffset; + py += game_sp.scroll_yoffset; BlitBitmap(bitmap_db_field_sp, target_bitmap, px, py, sxsize, sysize, sx, sy); } diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index 330b5470..dc5d3c96 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -16,9 +16,8 @@ #define ScrollDelta ((long)1) #define ZoomFactor (2) -#define BaseWidth (ZoomFactor * 16) + #define StretchWidth (ZoomFactor * 16) -#define TileSize (ZoomFactor * 16) #define TwoPixels (ZoomFactor * 2) diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index ec0ba33d..d612a6c6 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -181,56 +181,28 @@ static void ReStretch() void SetScrollEdges() { -#if 1 - int border_offset = (menBorder ? 1 : 2); + int border1_offset = (menBorder ? 1 : 2); + int border2_offset = (menBorder ? 0 : TILESIZE / 2); + /* scroll correction for border frame (1 tile) or border element (2 tiles) */ ScrollMinX = 0; ScrollMinY = 0; - ScrollMaxX = (DisplayMaxX + border_offset) * BaseWidth - SXSIZE; - ScrollMaxY = (DisplayMaxY + border_offset) * BaseWidth - SYSIZE; - -#if 1 - if (!menBorder) - { - ScrollMinX += TILEX / 2; - ScrollMinY += TILEY / 2; - ScrollMaxX -= TILEX / 2; - ScrollMaxY -= TILEY / 2; - } -#if 1 - { - ScrollMinX -= game_sp.scroll_xoffset; - ScrollMaxX -= game_sp.scroll_xoffset; - ScrollMinY -= game_sp.scroll_yoffset; - ScrollMaxY -= game_sp.scroll_yoffset; - } -#else - if (1) - { - ScrollMinX -= TILEX / 2; - ScrollMaxX -= TILEX / 2; - ScrollMinY -= TILEY / 2; - ScrollMaxY -= TILEY / 2; - } -#endif -#else - if (!menBorder) - { - ScrollMinX += TILEX / 2; - ScrollMinY += TILEY / 2; - ScrollMaxX -= TILEX / 2; - ScrollMaxY -= TILEY / 2; - } -#endif - -#else - ScrollMinX = (int)(DisplayMinX - 0.5) * BaseWidth; - ScrollMinY = (int)(DisplayMinY - 0.5) * BaseWidth; - ScrollMaxX = (int)(DisplayMaxX + 1.5) * BaseWidth - SXSIZE; - ScrollMaxY = (int)(DisplayMaxY + 1.5) * BaseWidth - SYSIZE; -#endif - -#if 1 + ScrollMaxX = (DisplayMaxX + border1_offset) * TILEX - SXSIZE; + ScrollMaxY = (DisplayMaxY + border1_offset) * TILEY - SYSIZE; + + /* scroll correction for border element (half tile on left and right side) */ + ScrollMinX += border2_offset; + ScrollMinY += border2_offset; + ScrollMaxX -= border2_offset; + ScrollMaxY -= border2_offset; + + /* scroll correction for even number of visible tiles (half tile shifted) */ + ScrollMinX -= game_sp.scroll_xoffset; + ScrollMaxX -= game_sp.scroll_xoffset; + ScrollMinY -= game_sp.scroll_yoffset; + ScrollMaxY -= game_sp.scroll_yoffset; + +#if 0 printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n", DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY); diff --git a/src/game_sp/MainGameLoop.c b/src/game_sp/MainGameLoop.c index 2a6d2551..b7285292 100644 --- a/src/game_sp/MainGameLoop.c +++ b/src/game_sp/MainGameLoop.c @@ -98,11 +98,10 @@ locExitMainGameLoop: void subCalculateScreenScrollPos() { - int ax, ay; - #if 1 int jump_pos = TILEX / 2; + /* handle wrap-around */ if (MurphyScreenXPos < -jump_pos) { MurphyScreenXPos = FieldWidth * TILEX + MurphyScreenXPos; @@ -122,17 +121,6 @@ void subCalculateScreenScrollPos() // printf("::: ExplosionShake [%d]\n", FrameCounter); } -#if 1 - ax = (SCR_FIELDX / 2) * TILESIZE; - ay = (SCR_FIELDY / 2) * TILESIZE; - - ScreenScrollXPos = MurphyScreenXPos - ax; - ScreenScrollYPos = MurphyScreenYPos - ay; -#else - ax = SXSIZE / 2; - ay = SYSIZE / 2; - - ScreenScrollXPos = (MurphyScreenXPos + TILEX / 2) - ax; - ScreenScrollYPos = (MurphyScreenYPos + TILEY / 2) - ay; -#endif + ScreenScrollXPos = MurphyScreenXPos - (SCR_FIELDX / 2) * TILESIZE; + ScreenScrollYPos = MurphyScreenYPos - (SCR_FIELDY / 2) * TILESIZE; } diff --git a/src/game_sp/init.c b/src/game_sp/init.c index a8e67276..d8e4597d 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -10,20 +10,6 @@ struct EngineSnapshotInfo_SP engine_snapshot_sp; void sp_open_all() { Form_Load(); - -#if 0 - printf("::: open 1: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp); - - /* - bitmap_db_field_sp = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); - bitmap_db_field_sp = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, - DEFAULT_DEPTH); - */ - - ReCreateBitmap(&bitmap_db_field_sp, FXSIZE, FYSIZE, DEFAULT_DEPTH); - - printf("::: open 2: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp); -#endif } void sp_close_all() @@ -32,18 +18,7 @@ void sp_close_all() void InitGfxBuffers_SP() { -#if 1 - printf("::: init 1: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp); - - /* - ReCreateBitmap(&bitmap_db_field_sp, MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, - DEFAULT_DEPTH); - */ - ReCreateBitmap(&bitmap_db_field_sp, FXSIZE, FYSIZE, DEFAULT_DEPTH); - - printf("::: init 2: %d, %d [%08x]\n", FXSIZE, FYSIZE, bitmap_db_field_sp); -#endif } unsigned int InitEngineRandom_SP(long seed)