aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2005-04-21 15:40:40 +0000
committerTravis Howell2005-04-21 15:40:40 +0000
commit098e0cce58a0c4039ac05fd7134c378ce33e1b71 (patch)
treec7c75c146fe81ae3e31aea04c8f5f246953879bb
parentf281ea4427c992c6232aa75ac012e1039facf425 (diff)
downloadscummvm-rg350-098e0cce58a0c4039ac05fd7134c378ce33e1b71.tar.gz
scummvm-rg350-098e0cce58a0c4039ac05fd7134c378ce33e1b71.tar.bz2
scummvm-rg350-098e0cce58a0c4039ac05fd7134c378ce33e1b71.zip
Add palette function foe He99+ games.
svn-id: r17736
-rw-r--r--scumm/intern.h2
-rw-r--r--scumm/palette_he.cpp53
-rw-r--r--scumm/script_v90he.cpp23
3 files changed, 69 insertions, 9 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index 7abd6812f6..06e1ab6962 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -1002,6 +1002,8 @@ protected:
uint8 *getHEPaletteIndex(int palSlot);
int getHEPaletteColor(int palSlot, int color);
+ int getPaletteUnk1(int palSlot, int arg_4, int arg_8, int start, int end);
+
void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b);
void setHEPaletteFromPtr(int palSlot, const uint8 *palData);
void setHEPaletteFromCostume(int palSlot, int resId);
diff --git a/scumm/palette_he.cpp b/scumm/palette_he.cpp
index 4a8199a335..ed2c27ab26 100644
--- a/scumm/palette_he.cpp
+++ b/scumm/palette_he.cpp
@@ -78,6 +78,59 @@ uint8 *ScummEngine_v90he::getHEPaletteIndex(int palSlot) {
}
}
+int ScummEngine_v90he::getPaletteUnk1(int palSlot, int arg_4, int arg_8, int start, int end) {
+ assert(palSlot >= 1 && palSlot <= _numPalettes);
+ assert(start >= 1 && start <= 255);
+ assert(end >= 1 && end <= 255);
+
+ int eax, edi, edp, edx, esi;
+ int sum, bestitem, bestsum;
+ uint8 *palPtr;
+
+ palPtr = _hePalettes + palSlot * 1024 + start * 3;
+
+ bestsum = 0xFFFFFFFF;
+ bestitem = start;
+ edp = arg_8;
+
+ for (int i = start; i <= end; i++) {
+ esi = arg_4;
+
+ edi = *palPtr++;
+ edx = *palPtr;
+ esi -= edi;
+ eax = edx;
+
+ edi = edp;
+ eax = -eax;
+ eax <<= 31;
+ eax -= edx;
+ edi -= edx;
+
+ eax += edp;
+
+ edx = esi;
+
+ eax *= edi;
+ edx *= esi;
+
+ sum = edx + eax * 2;
+
+ palPtr += 2;
+
+ if (sum < bestsum) {
+ if (sum == 0) {
+ return i;
+ }
+
+ bestsum = sum;
+ bestitem = i;
+ }
+ }
+
+ return bestitem;
+}
+
int ScummEngine_v90he::getHEPaletteColor(int palSlot, int color) {
assert(palSlot >= 1 && palSlot <= _numPalettes);
assert(color >= 1 && color <= 255);
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index d2567d7bb0..28bfc3175f 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -2256,6 +2256,7 @@ void ScummEngine_v90he::o90_getObjectData() {
}
void ScummEngine_v90he::o90_getPaletteData() {
+ int b, c, d, e;
int palSlot, color;
byte subOp = fetchScriptByte();
@@ -2263,13 +2264,13 @@ void ScummEngine_v90he::o90_getPaletteData() {
switch (subOp) {
case 0:
+ e = pop();
+ d = pop();
+ palSlot = pop();
pop();
- pop();
- pop();
- pop();
- pop();
- pop();
- push(0);
+ c = pop();
+ b = pop();
+ push(getPaletteUnk1(palSlot, b, c, d, e));
break;
case 7:
pop();
@@ -2289,9 +2290,13 @@ void ScummEngine_v90he::o90_getPaletteData() {
break;
case 172:
pop();
- pop();
- pop();
- push(0);
+ c = pop();
+ c = MAX(0, c);
+ c = MIN(c, 255);
+ b = pop();
+ b = MAX(0, b);
+ b = MIN(b, 255);
+ push(getPaletteUnk1(1, b, c, 10, 245));
break;
default:
error("o90_getPaletteData: Unknown case %d", subOp);