[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.381,2.382 script_v100he.cpp,2.70,2.71 script_v90he.cpp,2.170,2.171 scumm.cpp,1.341,1.342
Eugene Sandulenko
sev at users.sourceforge.net
Wed Mar 2 12:04:24 CET 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26975
Modified Files:
intern.h script_v100he.cpp script_v90he.cpp scumm.cpp
Log Message:
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?
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.381
retrieving revision 2.382
diff -u -d -r2.381 -r2.382
--- intern.h 2 Mar 2005 07:00:42 -0000 2.381
+++ intern.h 2 Mar 2005 20:02:58 -0000 2.382
@@ -860,6 +860,7 @@
int _heObject, _heObjectNum;
int _hePaletteNum;
+ uint8 *_hePalettes;
const OpcodeEntryV90he *_opcodesV90he;
FloodStateParameters _floodStateParams;
@@ -900,6 +901,16 @@
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);
Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.70
retrieving revision 2.71
diff -u -d -r2.70 -r2.71
--- script_v100he.cpp 28 Feb 2005 04:17:17 -0000 2.70
+++ script_v100he.cpp 2 Mar 2005 20:02:59 -0000 2.71
@@ -1359,38 +1359,64 @@
}
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 @@
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 @@
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() {
Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.170
retrieving revision 2.171
diff -u -d -r2.170 -r2.171
--- script_v90he.cpp 28 Feb 2005 13:23:10 -0000 2.170
+++ script_v90he.cpp 2 Mar 2005 20:02:59 -0000 2.171
@@ -1888,6 +1888,86 @@
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;
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.341
retrieving revision 1.342
diff -u -d -r1.341 -r1.342
--- scumm.cpp 28 Feb 2005 13:23:10 -0000 1.341
+++ scumm.cpp 2 Mar 2005 20:02:59 -0000 1.342
@@ -1489,6 +1489,7 @@
_hePaletteNum = 0;
spritesResetTables(0);
+ _hePalettes = (uint8 *)malloc(_numPalettes * 1024);
memset(&_wizParams, 0, sizeof(_wizParams));
}
More information about the Scummvm-git-logs
mailing list