aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2011-09-08 00:19:43 +0200
committerJohannes Schickel2011-09-08 00:19:43 +0200
commitc386a5520ff389b77dd004f55ae78fc5f24856e2 (patch)
treec6dadcc882b4975bcc1044f22fba17110ca12c4a
parent3a15c10241421beaa8a3fe84f3b0567bb2215573 (diff)
downloadscummvm-rg350-c386a5520ff389b77dd004f55ae78fc5f24856e2.tar.gz
scummvm-rg350-c386a5520ff389b77dd004f55ae78fc5f24856e2.tar.bz2
scummvm-rg350-c386a5520ff389b77dd004f55ae78fc5f24856e2.zip
SWORD1: Replace inRange with CLIP.
-rw-r--r--engines/sword1/logic.cpp8
-rw-r--r--engines/sword1/logic.h2
-rw-r--r--engines/sword1/screen.cpp20
-rw-r--r--engines/sword1/screen.h1
4 files changed, 10 insertions, 21 deletions
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index d8933bc2f7..d1c69c80ff 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -1189,8 +1189,8 @@ int Logic::fnISpeak(Object *cpt, int32 id, int32 cdt, int32 textNo, int32 spr, i
textTopMargin = SCREEN_TOP_EDGE + TEXT_MARGIN + _scriptVars[SCROLL_OFFSET_Y];
textBottomMargin = SCREEN_BOTTOM_EDGE - TEXT_MARGIN + _scriptVars[SCROLL_OFFSET_Y] - textSpriteHeight;
- textCpt->o_anim_x = textCpt->o_xcoord = inRange(textLeftMargin, textX, textRightMargin);
- textCpt->o_anim_y = textCpt->o_ycoord = inRange(textTopMargin, textY, textBottomMargin);
+ textCpt->o_anim_x = textCpt->o_xcoord = CLIP<uint16>(textX, textLeftMargin, textRightMargin);
+ textCpt->o_anim_y = textCpt->o_ycoord = CLIP<uint16>(textY, textTopMargin, textBottomMargin);
}
return SCRIPT_STOP;
}
@@ -1689,10 +1689,6 @@ int Logic::fnBlack(Object *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, in
return SCRIPT_CONT;
}
-uint16 Logic::inRange(uint16 a, uint16 b, uint16 c) {
- return (a > b) ? a : (((b > c) ? c : b));
-}
-
void Logic::startPosCallFn(uint8 fnId, uint32 param1, uint32 param2, uint32 param3) {
Object *obj = NULL;
switch (fnId) {
diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h
index d4b297e8ea..a146d340cf 100644
--- a/engines/sword1/logic.h
+++ b/engines/sword1/logic.h
@@ -97,8 +97,6 @@ private:
void setupMcodeTable();
const BSMcodeTable *_mcodeTable;
- uint16 inRange(uint16 a, uint16 b, uint16 c);
-
//- mcodeTable:
int fnBackground(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnForeground(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index c7368c9184..ae128b8c05 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -78,13 +78,9 @@ void Screen::useTextManager(Text *pTextMan) {
_textMan = pTextMan;
}
-int32 Screen::inRange(int32 a, int32 b, int32 c) { // return b(!) so that: a <= b <= c
- return (a > b) ? (a) : ((b < c) ? b : c);
-}
-
void Screen::setScrolling(int16 offsetX, int16 offsetY) {
- offsetX = inRange(0, offsetX, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
- offsetY = inRange(0, offsetY, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
+ offsetX = CLIP<int32>(offsetX, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
+ offsetY = CLIP<int32>(offsetY, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
if (Logic::_scriptVars[SCROLL_FLAG] == 2) { // first time on this screen - need absolute scroll immediately!
_oldScrollX = Logic::_scriptVars[SCROLL_OFFSET_X] = (uint32)offsetX;
@@ -101,18 +97,18 @@ void Screen::setScrolling(int16 offsetX, int16 offsetY) {
_oldScrollY = Logic::_scriptVars[SCROLL_OFFSET_Y];
int dx = offsetX - Logic::_scriptVars[SCROLL_OFFSET_X];
int dy = offsetY - Logic::_scriptVars[SCROLL_OFFSET_Y];
- int scrlDistX = inRange(-MAX_SCROLL_DISTANCE, (((SCROLL_FRACTION - 1) + ABS(dx)) / SCROLL_FRACTION) * ((dx > 0) ? 1 : -1), MAX_SCROLL_DISTANCE);
- int scrlDistY = inRange(-MAX_SCROLL_DISTANCE, (((SCROLL_FRACTION - 1) + ABS(dy)) / SCROLL_FRACTION) * ((dy > 0) ? 1 : -1), MAX_SCROLL_DISTANCE);
+ int scrlDistX = CLIP<int32>((((SCROLL_FRACTION - 1) + ABS(dx)) / SCROLL_FRACTION) * ((dx > 0) ? 1 : -1), -MAX_SCROLL_DISTANCE, MAX_SCROLL_DISTANCE);
+ int scrlDistY = CLIP<int32>((((SCROLL_FRACTION - 1) + ABS(dy)) / SCROLL_FRACTION) * ((dy > 0) ? 1 : -1), -MAX_SCROLL_DISTANCE, MAX_SCROLL_DISTANCE);
if ((scrlDistX != 0) || (scrlDistY != 0))
_fullRefresh = true;
- Logic::_scriptVars[SCROLL_OFFSET_X] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_X] + scrlDistX, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
- Logic::_scriptVars[SCROLL_OFFSET_Y] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_Y] + scrlDistY, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
+ Logic::_scriptVars[SCROLL_OFFSET_X] = CLIP<int32>(Logic::_scriptVars[SCROLL_OFFSET_X] + scrlDistX, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
+ Logic::_scriptVars[SCROLL_OFFSET_Y] = CLIP<int32>(Logic::_scriptVars[SCROLL_OFFSET_Y] + scrlDistY, 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
} else {
// SCROLL_FLAG == 0, this usually means that the screen is smaller than 640x400 and doesn't need scrolling at all
// however, it can also mean that the gamescript overwrote the scrolling flag to take care of scrolling directly,
// (see bug report #1345130) so we ignore the offset arguments in this case
- Logic::_scriptVars[SCROLL_OFFSET_X] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_X], Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
- Logic::_scriptVars[SCROLL_OFFSET_Y] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_Y], Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
+ Logic::_scriptVars[SCROLL_OFFSET_X] = CLIP<int32>(Logic::_scriptVars[SCROLL_OFFSET_X], 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
+ Logic::_scriptVars[SCROLL_OFFSET_Y] = CLIP<int32>(Logic::_scriptVars[SCROLL_OFFSET_Y], 0, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
if ((Logic::_scriptVars[SCROLL_OFFSET_X] != _oldScrollX) || (Logic::_scriptVars[SCROLL_OFFSET_Y] != _oldScrollY)) {
_fullRefresh = true;
_oldScrollX = Logic::_scriptVars[SCROLL_OFFSET_X];
diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h
index 45608531fb..7586e937a7 100644
--- a/engines/sword1/screen.h
+++ b/engines/sword1/screen.h
@@ -126,7 +126,6 @@ private:
void decompressRLE0(uint8 *src, uint32 compSize, uint8 *dest);
void decompressTony(uint8 *src, uint32 compSize, uint8 *dest);
void fastShrink(uint8 *src, uint32 width, uint32 height, uint32 scale, uint8 *dest);
- int32 inRange(int32 a, int32 b, int32 c);
void fadePalette();
void flushPsxCache();