diff options
author | Gregory Montoir | 2005-04-21 19:27:17 +0000 |
---|---|---|
committer | Gregory Montoir | 2005-04-21 19:27:17 +0000 |
commit | 8d768798497c22530d436f901b232b1b43a4d51c (patch) | |
tree | c94e9770fe5056c9ffd270e8c988615df7b4b09c /scumm | |
parent | 97749a934ee97f229e7c111fc80042d550b34864 (diff) | |
download | scummvm-rg350-8d768798497c22530d436f901b232b1b43a4d51c.tar.gz scummvm-rg350-8d768798497c22530d436f901b232b1b43a4d51c.tar.bz2 scummvm-rg350-8d768798497c22530d436f901b232b1b43a4d51c.zip |
cleanup
svn-id: r17740
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/intern.h | 5 | ||||
-rw-r--r-- | scumm/palette_he.cpp | 55 | ||||
-rw-r--r-- | scumm/script_v100he.cpp | 8 | ||||
-rw-r--r-- | scumm/script_v90he.cpp | 8 |
4 files changed, 24 insertions, 52 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 7b73fa8e14..34288bfcbe 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -1002,9 +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); - int getPaletteUnk2(int palSlot, int unk1, int unk2); - + int getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end); + int getHEPaletteColorComponent(int palSlot, int color, int component); 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 e7a8d1886b..ab564020bf 100644 --- a/scumm/palette_he.cpp +++ b/scumm/palette_he.cpp @@ -78,64 +78,37 @@ uint8 *ScummEngine_v90he::getHEPaletteIndex(int palSlot) { } } -int ScummEngine_v90he::getPaletteUnk1(int palSlot, int arg_4, int arg_8, int start, int end) { +int ScummEngine_v90he::getHEPaletteSimilarColor(int palSlot, int red, int green, 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; + uint8 *pal = _hePalettes + palSlot * 1024 + start * 3; - bestsum = 0xFFFFFFFF; - bestitem = start; - edp = arg_8; + int bestsum = 0xFFFFFFFF; + int bestitem = start; 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; - + int dr = red - pal[0]; + int dg = green - pal[1]; + int sum = dr * dr + dg * dg * 2; + if (sum == 0) { + return i; + } if (sum < bestsum) { - if (sum == 0) { - return i; - } - bestsum = sum; bestitem = i; } + pal += 3; } - return bestitem; } -int ScummEngine_v90he::getPaletteUnk2(int palSlot, int unk1, int unk2) { +int ScummEngine_v90he::getHEPaletteColorComponent(int palSlot, int color, int component) { assert(palSlot >= 1 && palSlot <= _numPalettes); - assert(unk1 >= 1 && unk1 <= 255); + assert(color >= 1 && color <= 255); - return _hePalettes[palSlot * 1024 + unk1 * 3 + unk2 / 3]; + return _hePalettes[palSlot * 1024 + color * 3 + component % 3]; } int ScummEngine_v90he::getHEPaletteColor(int palSlot, int color) { diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp index 6910e1b905..824ee9570c 100644 --- a/scumm/script_v100he.cpp +++ b/scumm/script_v100he.cpp @@ -2397,7 +2397,7 @@ void ScummEngine_v100he::o100_getPaletteData() { case 13: c = pop(); b = pop(); - push(getPaletteUnk2(1, b, c)); + push(getHEPaletteColorComponent(1, b, c)); break; case 20: color = pop(); @@ -2411,7 +2411,7 @@ void ScummEngine_v100he::o100_getPaletteData() { pop(); c = pop(); b = pop(); - push(getPaletteUnk1(palSlot, b, c, d, e)); + push(getHEPaletteSimilarColor(palSlot, b, c, d, e)); break; case 53: pop(); @@ -2421,13 +2421,13 @@ void ScummEngine_v100he::o100_getPaletteData() { b = pop(); b = MAX(0, b); b = MIN(b, 255); - push(getPaletteUnk1(1, b, c, 10, 245)); + push(getHEPaletteSimilarColor(1, b, c, 10, 245)); break; case 73: c = pop(); b = pop(); palSlot = pop(); - push(getPaletteUnk2(palSlot, b, c)); + push(getHEPaletteColorComponent(palSlot, b, c)); break; default: error("o100_getPaletteData: Unknown case %d", subOp); diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index 4a99c17d5b..6e851ad34f 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -2270,13 +2270,13 @@ void ScummEngine_v90he::o90_getPaletteData() { pop(); c = pop(); b = pop(); - push(getPaletteUnk1(palSlot, b, c, d, e)); + push(getHEPaletteSimilarColor(palSlot, b, c, d, e)); break; case 7: c = pop(); b = pop(); palSlot = pop(); - push(getPaletteUnk2(palSlot, b, c)); + push(getHEPaletteColorComponent(palSlot, b, c)); break; case 21: color = pop(); @@ -2286,7 +2286,7 @@ void ScummEngine_v90he::o90_getPaletteData() { case 87: c = pop(); b = pop(); - push(getPaletteUnk2(1, b, c)); + push(getHEPaletteColorComponent(1, b, c)); break; case 172: pop(); @@ -2296,7 +2296,7 @@ void ScummEngine_v90he::o90_getPaletteData() { b = pop(); b = MAX(0, b); b = MIN(b, 255); - push(getPaletteUnk1(1, b, c, 10, 245)); + push(getHEPaletteSimilarColor(1, b, c, 10, 245)); break; default: error("o90_getPaletteData: Unknown case %d", subOp); |