projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20100418-1-src
[rocksndiamonds.git]
/
src
/
game_sp
/
DDScrollBuffer.c
diff --git
a/src/game_sp/DDScrollBuffer.c
b/src/game_sp/DDScrollBuffer.c
index 816127b4ed9952ddd08104a90bd0c1de08771b1b..792648d4d79430d7723644659cd9f09b161d83b1 100644
(file)
--- a/
src/game_sp/DDScrollBuffer.c
+++ b/
src/game_sp/DDScrollBuffer.c
@@
-7,13
+7,16
@@
#include <math.h>
#include <math.h>
-long mWidth, mHeight;
long mScrollX, mScrollY;
long mScrollX_last, mScrollY_last;
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];
long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
void RestorePlayfield()
void RestorePlayfield()
@@
-47,7
+50,7
@@
static void ScrollPlayfield(int dx, int dy)
int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2;
int x, y;
int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2;
int x, y;
- BlitBitmap(
screenBitmap, screenBitma
p,
+ BlitBitmap(
bitmap_db_field_sp, bitmap_db_field_s
p,
TILEX * (dx == -1),
TILEY * (dy == -1),
(MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0),
TILEX * (dx == -1),
TILEY * (dy == -1),
(MAX_BUF_XSIZE * TILEX) - TILEX * (dx != 0),
@@
-103,8
+106,13
@@
static void ScrollPlayfieldIfNeededExt(boolean reset)
if (mScrollX_last == -1 || mScrollY_last == -1)
{
if (mScrollX_last == -1 || mScrollY_last == -1)
{
+#if 1
+ mScrollX_last = (mScrollX / TILESIZE) * TILESIZE;
+ mScrollY_last = (mScrollY / TILESIZE) * TILESIZE;
+#else
mScrollX_last = mScrollX;
mScrollY_last = mScrollY;
mScrollX_last = mScrollX;
mScrollY_last = mScrollY;
+#endif
return;
}
return;
}
@@
-219,6
+227,15
@@
void BlitScreenToBitmap_SP(Bitmap *target_bitmap)
int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY;
int sx, sy, sxsize, sysize;
int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY;
int sx, sy, sxsize, sysize;
+#if 0
+ printf("::: %d, %d / %d, %d / %ld, %ld (%ld, %ld) / %d, %d\n",
+ MurphyScreenXPos, MurphyScreenYPos,
+ ScreenScrollXPos, ScreenScrollYPos,
+ mScrollX, mScrollY,
+ mScrollX_last, mScrollY_last,
+ px, py);
+#endif
+
int xsize = SXSIZE;
int ysize = SYSIZE;
int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX;
int xsize = SXSIZE;
int ysize = SYSIZE;
int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX;
@@
-229,13
+246,11
@@
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);
sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
- if (!menBorder)
- {
- px += TILEX / 2;
- py += TILEY / 2;
- }
+ /* scroll correction for even number of visible tiles (half tile shifted) */
+ px += game_sp.scroll_xoffset;
+ py += game_sp.scroll_yoffset;
- BlitBitmap(
screenBitma
p, target_bitmap, px, py, sxsize, sysize, sx, sy);
+ BlitBitmap(
bitmap_db_field_s
p, target_bitmap, px, py, sxsize, sysize, sx, sy);
}
void BackToFront_SP(void)
}
void BackToFront_SP(void)
@@
-263,7
+278,7
@@
void BackToFront_SP(void)
int yy = (top + y) % MAX_BUF_YSIZE;
if (redraw[xx][yy])
int yy = (top + y) % MAX_BUF_YSIZE;
if (redraw[xx][yy])
- BlitBitmap(
screenBitma
p, window,
+ BlitBitmap(
bitmap_db_field_s
p, window,
xx * TILEX, yy * TILEY, TILEX, TILEY,
SX + x * TILEX, SY + y * TILEY);
}
xx * TILEX, yy * TILEY, TILEX, TILEY,
SX + x * TILEX, SY + y * TILEY);
}
@@
-280,22
+295,13
@@
void BackToFront_SP(void)
scrolling_last = scrolling;
}
scrolling_last = scrolling;
}
-void DDScrollBuffer_Blt()
-{
- BackToFront_SP();
-}
-
void DDScrollBuffer_ScrollTo(int X, int Y)
{
if (NoDisplayFlag)
return;
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;
ScrollPlayfieldIfNeeded();
}
ScrollPlayfieldIfNeeded();
}
@@
-307,8
+313,6
@@
void DDScrollBuffer_ScrollTowards(int X, int Y, double Step)
if (NoDisplayFlag)
return;
if (NoDisplayFlag)
return;
- X = X / Stretch;
- Y = Y / Stretch;
dx = X - mScrollX;
dY = Y - mScrollY;
dx = X - mScrollX;
dY = Y - mScrollY;
@@
-321,10
+325,8
@@
void DDScrollBuffer_ScrollTowards(int X, int Y, double Step)
else
r = 1;
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;
ScrollPlayfieldIfNeeded();
}
ScrollPlayfieldIfNeeded();
}
@@
-344,8
+346,7
@@
void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS)
return;
AlreadyRunning = True;
return;
AlreadyRunning = True;
- X = X / Stretch;
- Y = Y / Stretch;
+
dx = X - mScrollX;
dY = Y - mScrollY;
maxD = (Abs(dx) < Abs(dY) ? Abs(dY) : Abs(dx));
dx = X - mScrollX;
dY = Y - mScrollY;
maxD = (Abs(dx) < Abs(dY) ? Abs(dY) : Abs(dx));
@@
-364,16
+365,12
@@
void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS)
for (T = (double)tStep; T <= (double)1; T += tStep)
{
for (T = (double)tStep; T <= (double)1; T += tStep)
{
- mScrollX = oldX + T * dx;
- mScrollY = oldY + T * dY;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
+ ScrollX = mScrollX = oldX + T * dx;
+ ScrollY = mScrollY = oldY + T * dY;
}
}
- mScrollX = X;
- mScrollY = Y;
- ScrollX = mScrollX;
- ScrollY = mScrollY;
+ ScrollX = mScrollX = X;
+ ScrollY = mScrollY = Y;
AlreadyRunning = False;
AlreadyRunning = False;