aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorEugene Sandulenko2005-03-02 20:02:59 +0000
committerEugene Sandulenko2005-03-02 20:02:59 +0000
commitee03994a782c904120a3e2f65770cfba149ab18b (patch)
tree20eedd58ebf055935bd57edac28fb01386fe1a4e /scumm
parent3cd0ff763c258b1ef24546f263265558e1bf32ea (diff)
downloadscummvm-rg350-ee03994a782c904120a3e2f65770cfba149ab18b.tar.gz
scummvm-rg350-ee03994a782c904120a3e2f65770cfba149ab18b.tar.bz2
scummvm-rg350-ee03994a782c904120a3e2f65770cfba149ab18b.zip
Commit o100_paletteOps WIP based on cyx's patch. Original patch just
tends to be unappliable anymore, so that's why I decided to commit it when it required not so much work of manual patching. I've checked validness of it against IDB but we still have main question open: How to plug it in properly into our palette code? svn-id: r16973
Diffstat (limited to 'scumm')
-rw-r--r--scumm/intern.h11
-rw-r--r--scumm/script_v100he.cpp58
-rw-r--r--scumm/script_v90he.cpp80
-rw-r--r--scumm/scumm.cpp1
4 files changed, 134 insertions, 16 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index 9d05fb4470..186ed71dea 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -860,6 +860,7 @@ protected:
int _heObject, _heObjectNum;
int _hePaletteNum;
+ uint8 *_hePalettes;
const OpcodeEntryV90he *_opcodesV90he;
FloodStateParameters _floodStateParams;
@@ -900,6 +901,16 @@ protected:
uint8 getWizPixelColor(int restype, int resnum, int state, int x, int y, int flags);
int computeWizHistogram(int resnum, int state, int x, int y, int w, int h);
+ uint8 *getHEPalette(int palSlot);
+ 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);
+ void setHEPaletteFromImage(int palSlot, int resId, int state);
+ void setHEPaletteFromRoom(int palSlot, int resId, int state);
+ void restoreHEPalette(int palSlot);
+ void copyHEPalette(int dstPalSlot, int srcPalSlot);
+ void copyHEPaletteColor(int palSlot, uint8 dstColor, uint8 srcColor);
+
int findSpriteWithClassOf(int x, int y, int spriteGroupId, int d, int num, int *args);
int spriteInfoGet_classFlags(int spriteId, int num);
int spriteInfoGet_classFlagsAnd(int spriteId, int num, int *args);
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index 0a0c311526..cecc945f61 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -1359,38 +1359,64 @@ void ScummEngine_v100he::o100_redim2dimArray() {
}
void ScummEngine_v100he::o100_paletteOps() {
+ int a, b, c, d, e;
byte subOp = fetchScriptByte();
switch (subOp) {
case 0:
_hePaletteNum = pop();
break;
case 20:
- pop();
- pop();
- pop();
- pop();
- pop();
+ e = pop();
+ d = pop();
+ c = pop();
+ b = pop();
+ a = pop();
+ if (_hePaletteNum != 0) {
+ for (; a <= b; ++a) {
+ setHEPaletteColor(_hePaletteNum, a, c, d, e);
+ }
+ }
break;
case 25:
- pop();
+ a = pop();
+ if (_hePaletteNum != 0) {
+ setHEPaletteFromCostume(_hePaletteNum, a);
+ }
break;
case 40:
- pop();
- pop();
+ b = pop();
+ a = pop();
+ if (_hePaletteNum != 0) {
+ setHEPaletteFromImage(_hePaletteNum, a, b);
+ }
break;
case 53:
+ if (_hePaletteNum != 0) {
+ restoreHEPalette(_hePaletteNum);
+ }
break;
case 57:
- pop();
+ a = pop();
+ if (_hePaletteNum != 0) {
+ copyHEPalette(_hePaletteNum, a);
+ }
break;
case 63:
- pop();
- pop();
+ b = pop();
+ a = pop();
+ if (_hePaletteNum != 0) {
+ setHEPaletteFromRoom(_hePaletteNum, a, b);
+ }
break;
case 81:
- pop();
- pop();
- pop();
+ c = pop();
+ b = pop();
+ a = pop();
+ if (_hePaletteNum) {
+ for (; a <= b; ++a) {
+ copyHEPaletteColor(_hePaletteNum, a, c);
+ }
+ }
break;
case 92:
_hePaletteNum = 0;
@@ -1398,7 +1424,7 @@ void ScummEngine_v100he::o100_paletteOps() {
default:
error("o100_paletteOps: Unknown case %d", subOp);
}
- debug(1,"o100_paletteOps stub (%d)", subOp);
+ debug(1, "o100_paletteOps stub (%d)", subOp);
}
void ScummEngine_v100he::o100_redimArray() {
@@ -2313,7 +2339,7 @@ void ScummEngine_v100he::o100_getPaletteData() {
error("o100_getPaletteData: Unknown case %d", subOp);
}
push(0);
- debug(1,"o100_getPaletteData stub (%d)", subOp);
+ debug(0, "o100_getPaletteData stub (%d)", subOp);
}
void ScummEngine_v100he::o100_readFile() {
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 05dfc69f89..eadcdb64ce 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -1888,6 +1888,86 @@ void ScummEngine_v90he::o90_getObjectData() {
debug(1,"o90_getObjectData stub (%d)", subOp);
}
+uint8 *ScummEngine_v90he::getHEPalette(int palSlot) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ if (palSlot == 1) {
+ return _currentPalette; // XXX won't work, as size == 768
+ } else {
+ return _hePalettes + (palSlot - 2) * 1024;
+ }
+}
+
+void ScummEngine_v90he::setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ uint8 *p = _hePalettes + palSlot * 1024 + color * 3;
+ *(p + 0) = r;
+ *(p + 1) = g;
+ *(p + 2) = b;
+ *(_hePalettes + palSlot * 1024 + 768 + color) = color;
+}
+
+void ScummEngine_v90he::setHEPaletteFromPtr(int palSlot, const uint8 *palData) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ uint8 *pc = _hePalettes + palSlot * 1024;
+ uint8 *pi = pc + 768;
+ for (int i = 0; i < 256; ++i) {
+ *pc++ = *palData++;
+ *pc++ = *palData++;
+ *pc++ = *palData++;
+ *pi++ = i;
+ }
+}
+
+void ScummEngine_v90he::setHEPaletteFromCostume(int palSlot, int resId) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ const uint8 *data = getResourceAddress(rtCostume, resId);
+ assert(data);
+ const uint8 *rgbs = findResourceData(MKID('RGBS'), data);
+ assert(rgbs);
+ setHEPaletteFromPtr(palSlot, rgbs);
+}
+
+void ScummEngine_v90he::setHEPaletteFromImage(int palSlot, int resId, int state) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ const uint8 *data = getResourceAddress(rtImage, resId);
+ assert(data);
+ const uint8 *rgbs = findWrappedBlock(MKID('RGBS'), data, state, 0);
+ assert(rgbs);
+ setHEPaletteFromPtr(palSlot, rgbs);
+}
+
+void ScummEngine_v90he::setHEPaletteFromRoom(int palSlot, int resId, int state) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ const uint8 *data = getResourceAddress(rtRoom, resId);
+ assert(data);
+ const uint8 *rgbs = findWrappedBlock(MKID('PALS'), data, state, 0);
+ assert(rgbs);
+ setHEPaletteFromPtr(palSlot, rgbs);
+}
+
+void ScummEngine_v90he::restoreHEPalette(int palSlot) {
+ assert(palSlot >= 1 && palSlot < _numPalettes);
+ if (palSlot != 1) {
+ memcpy(_hePalettes + palSlot * 1024, _hePalettes + 1024, 1024);
+ }
+}
+
+void ScummEngine_v90he::copyHEPalette(int dstPalSlot, int srcPalSlot) {
+ assert(dstPalSlot >= 1 && dstPalSlot < _numPalettes);
+ assert(srcPalSlot >= 1 && srcPalSlot < _numPalettes);
+ if (dstPalSlot != srcPalSlot) {
+ memcpy(_hePalettes + srcPalSlot * 1024, _hePalettes + dstPalSlot * 1024, 1024);
+ }
+}
+
+void ScummEngine_v90he::copyHEPaletteColor(int palSlot, uint8 dstColor, uint8 srcColor) {
+ assert(palSlot >= 1 && palSlot < _numPalettes - 1);
+ uint8 *dstPal = _hePalettes + palSlot * 1024 + dstColor * 3;
+ uint8 *srcPal = _hePalettes + (palSlot + 1) * 1024 + srcColor * 3;
+ memcpy(dstPal, srcPal, 3);
+ *(_hePalettes + palSlot * 1024 + 768 + dstColor) = srcColor;
+}
+
void ScummEngine_v90he::o90_getPaletteData() {
byte subOp = fetchScriptByte();
subOp -= 45;
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 46d110809f..41dc71dfa1 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1489,6 +1489,7 @@ void ScummEngine_v90he::scummInit() {
_hePaletteNum = 0;
spritesResetTables(0);
+ _hePalettes = (uint8 *)malloc(_numPalettes * 1024);
memset(&_wizParams, 0, sizeof(_wizParams));
}