- 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;
- }
-#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
- printf("::: (%ld, %ld), (%ld, %ld) -> (%d, %d), (%d, %d)\n",
- DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
- ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
-#endif
+ ScrollMaxX = (DisplayMaxX + border1_offset - SCR_FIELDX) * TILEX;
+ ScrollMaxY = (DisplayMaxY + border1_offset - SCR_FIELDY) * TILEY;
+
+ /* 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;