aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2005-04-07 10:43:51 +0000
committerTravis Howell2005-04-07 10:43:51 +0000
commit6ced0d698a9298450c00e6141bb94049e2d7cdea (patch)
tree25e6173446f0e59c8449aa06f42fdf64b9480ed8 /scumm
parent49bab70dedca35a924dfbbb7bbd16a664894dc71 (diff)
downloadscummvm-rg350-6ced0d698a9298450c00e6141bb94049e2d7cdea.tar.gz
scummvm-rg350-6ced0d698a9298450c00e6141bb94049e2d7cdea.tar.bz2
scummvm-rg350-6ced0d698a9298450c00e6141bb94049e2d7cdea.zip
Add WIP on hePalette.
svn-id: r17431
Diffstat (limited to 'scumm')
-rw-r--r--scumm/akos.cpp26
-rw-r--r--scumm/intern.h18
-rw-r--r--scumm/module.mk1
-rw-r--r--scumm/script_v90he.cpp37
-rw-r--r--scumm/scumm.cpp3
-rw-r--r--scumm/scumm.h11
-rw-r--r--scumm/wiz_he.cpp64
-rw-r--r--scumm/wiz_he.h4
8 files changed, 113 insertions, 51 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp
index ca4b97f41a..4fb79c54d0 100644
--- a/scumm/akos.cpp
+++ b/scumm/akos.cpp
@@ -289,23 +289,26 @@ void AkosRenderer::setPalette(byte *new_palette) {
uint size, i;
size = _vm->getResourceDataSize(akpl);
+ if (size == 0)
+ return;
if (size > 256)
error("akos_setPalette: %d is too many colors", size);
- for (i = 0; i < size; i++) {
- palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i];
+ if (_vm->_heversion >= 99 && _paletteNum) {
+ for (i = 0; i < size; i++)
+ palette[i] = (byte)_vm->_hePalettes[_paletteNum * 1024 + 768 + akpl[i]];
+ } else {
+ for (i = 0; i < size; i++) {
+ palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i];
+ }
}
- if (_paletteNum) {
- // TODO
- // Sets palette number to use for actor palette
- }
- if (_vm->_heversion == 70 && size) {
+ if (_vm->_heversion == 70) {
for (i = 0; i < size; i++)
palette[i] = _vm->_HEV7ActorPalette[palette[i]];
- }
+ }
if (size == 256) {
byte color = new_palette[0];
@@ -1256,8 +1259,13 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) {
if (_draw_bottom < dst.bottom)
_draw_bottom = dst.bottom;
+ const uint8 *palPtr = NULL;
+ if (_vm->_heversion >= 99) {
+ palPtr = _vm->_hePalettes + 1792;
+ }
+
byte *dstPtr = (byte *)_out.pixels + dst.left + dst.top * _out.pitch;
- Wiz::decompressWizImage(dstPtr, _out.pitch, dst, _srcptr, src);
+ Wiz::decompressWizImage(dstPtr, _out.pitch, dst, _srcptr, src, palPtr);
return 0;
}
diff --git a/scumm/intern.h b/scumm/intern.h
index addc66968a..9971510e4d 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -901,7 +901,6 @@ protected:
int _heObject, _heObjectNum;
int _hePaletteNum;
- uint8 *_hePalettes;
const OpcodeEntryV90he *_opcodesV90he;
FloodStateParameters _floodStateParams;
@@ -940,6 +939,7 @@ protected:
void sortArray(int array, int dim2start, int dim2end, int dim1start, int dim1end, int sortOrder);
uint8 *getHEPalette(int palSlot);
+ uint8 *getHEPaletteIndex(int palSlot);
int getHEPaletteColor(int palSlot, int color);
void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b);
void setHEPaletteFromPtr(int palSlot, const uint8 *palData);
@@ -1089,7 +1089,19 @@ protected:
void o90_kernelSetFunctions();
};
-class ScummEngine_v100he : public ScummEngine_v90he {
+class ScummEngine_v99he : public ScummEngine_v90he {
+public:
+ ScummEngine_v99he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v90he(detector, syst, gs, md5sum) {}
+
+protected:
+ virtual void copyPalColor(int dst, int src);
+ virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
+ virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
+ virtual void setPalColor(int index, int r, int g, int b);
+ virtual void updatePalette();
+};
+
+class ScummEngine_v100he : public ScummEngine_v99he {
protected:
typedef void (ScummEngine_v100he::*OpcodeProcV100he)();
struct OpcodeEntryV100he {
@@ -1102,7 +1114,7 @@ protected:
const OpcodeEntryV100he *_opcodesV100he;
public:
- ScummEngine_v100he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v90he(detector, syst, gs, md5sum) {}
+ ScummEngine_v100he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v99he(detector, syst, gs, md5sum) {}
protected:
virtual void setupOpcodes();
diff --git a/scumm/module.mk b/scumm/module.mk
index 9dcc3f1b5d..79add7d274 100644
--- a/scumm/module.mk
+++ b/scumm/module.mk
@@ -23,6 +23,7 @@ MODULE_OBJS := \
scumm/nut_renderer.o \
scumm/object.o \
scumm/palette.o \
+ scumm/palette_he.o \
scumm/player_mod.o \
scumm/player_v1.o \
scumm/player_nes.o \
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 10679bdbfd..9600774300 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -2131,11 +2131,20 @@ void ScummEngine_v90he::o90_getObjectData() {
}
uint8 *ScummEngine_v90he::getHEPalette(int palSlot) {
- assert(palSlot >= 1 && palSlot <= _numPalettes);
- if (palSlot == 1) {
- return _currentPalette; // XXX won't work, as size == 768
+ if (palSlot) {
+ assert(palSlot >= 1 && palSlot <= _numPalettes);
+ return _hePalettes + palSlot * 1024 + 768;
} else {
- return _hePalettes + (palSlot - 2) * 1024;
+ return _hePalettes + 1768;
+ }
+}
+
+uint8 *ScummEngine_v90he::getHEPaletteIndex(int palSlot) {
+ if (palSlot) {
+ assert(palSlot >= 1 && palSlot <= _numPalettes);
+ return _hePalettes + palSlot * 1024;
+ } else {
+ return _hePalettes + 1024;
}
}
@@ -2165,6 +2174,11 @@ void ScummEngine_v90he::setHEPaletteFromPtr(int palSlot, const uint8 *palData) {
*pc++ = *palData++;
*pi++ = i;
}
+ for (int i = 0; i < 10; ++i)
+ _hePalettes[palSlot * 1024 + 768 + i] = 1;
+ for (int i = 246; i < 256; ++i)
+ _hePalettes[palSlot * 1024 + 768 + i] = 1;
+
}
void ScummEngine_v90he::setHEPaletteFromCostume(int palSlot, int resId) {
@@ -2205,7 +2219,7 @@ 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);
+ memcpy(_hePalettes + dstPalSlot * 1024, _hePalettes + srcPalSlot * 1024, 1024);
}
}
@@ -2214,7 +2228,7 @@ void ScummEngine_v90he::copyHEPaletteColor(int palSlot, uint8 dstColor, uint8 sr
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;
+ _hePalettes[palSlot * 1024 + 768] = srcColor;
}
void ScummEngine_v90he::o90_getPaletteData() {
@@ -2225,6 +2239,13 @@ void ScummEngine_v90he::o90_getPaletteData() {
switch (subOp) {
case 0:
+ pop();
+ pop();
+ pop();
+ pop();
+ pop();
+ pop();
+ push(0);
break;
case 7:
pop();
@@ -2251,7 +2272,7 @@ void ScummEngine_v90he::o90_getPaletteData() {
default:
error("o90_getPaletteData: Unknown case %d", subOp);
}
- debug(1,"o90_getPaletteData stub (%d)", subOp);
+ debug(0,"o90_getPaletteData stub (%d)", subOp);
}
void ScummEngine_v90he::o90_paletteOps() {
@@ -2323,7 +2344,7 @@ void ScummEngine_v90he::o90_paletteOps() {
default:
error("o90_paletteOps: Unknown case %d", subOp);
}
- debug(1,"o90_paletteOps stub (%d)", subOp);
+ debug(0,"o90_paletteOps stub (%d)", subOp);
}
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index f0106d6a4e..632c24841e 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -3295,9 +3295,10 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) {
case 100:
engine = new ScummEngine_v100he(detector, syst, game, md5sum);
break;
+ case 99:
+ engine = new ScummEngine_v99he(detector, syst, game, md5sum);
case 90:
case 98:
- case 99:
engine = new ScummEngine_v90he(detector, syst, game, md5sum);
break;
case 80:
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 06f8a03ebe..d76edcd4d5 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -439,7 +439,7 @@ public:
// Cursor/palette
void updateCursor();
virtual void animateCursor() {}
- void updatePalette();
+ virtual void updatePalette();
virtual void saveOrLoadCursorImages(Serializer *s) {}
/**
@@ -983,12 +983,12 @@ protected:
void setupV1ManiacPalette();
void setupV1ZakPalette();
void setPalette(int pal, int room);
- void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
- void setPalColor(int index, int r, int g, int b);
+ virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
+ virtual void setPalColor(int index, int r, int g, int b);
void setDirtyColors(int min, int max);
const byte *findPalInPals(const byte *pal, int index);
void swapPalColors(int a, int b);
- void copyPalColor(int dst, int src);
+ virtual void copyPalColor(int dst, int src);
void cyclePalette();
void stopCycle(int i);
virtual void palManipulateInit(int resID, int start, int end, int time);
@@ -999,7 +999,7 @@ protected:
void moveMemInPalRes(int start, int end, byte direction);
void setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
- void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
+ virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor);
void setupCursor();
@@ -1089,6 +1089,7 @@ protected:
bool testGfxOtherUsageBits(int strip, int bit);
public:
+ uint8 *_hePalettes;
byte _HEV7ActorPalette[256];
byte _roomPalette[256];
byte *_shadowPalette;
diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp
index a12195b133..201178eff4 100644
--- a/scumm/wiz_he.cpp
+++ b/scumm/wiz_he.cpp
@@ -271,11 +271,11 @@ static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w,
return srcRect.isValidRect() && dstRect.isValidRect();
}
-void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) {
+void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.left + r2.top * dstw;
- decompressWizImage(dst, dstw, r2, src, r1);
+ decompressWizImage(dst, dstw, r2, src, r1, palPtr);
}
}
@@ -324,7 +324,7 @@ void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int
}
}
-void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *imagePal) {
+void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr) {
const uint8 *dataPtr, *dataPtrNext;
uint8 *dstPtr, *dstPtrNext;
uint32 code;
@@ -332,6 +332,14 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRe
int h, w, xoff;
uint16 off;
+ byte imagePal[256];
+ if (!palPtr) {
+ for (int i = 0; i < 256; i++) {
+ imagePal[i] = i;
+ }
+ palPtr = imagePal;
+ }
+
dstPtr = dst;
dataPtr = src;
@@ -406,10 +414,7 @@ dec_sub2: w -= code;
if (w < 0) {
code += w;
}
- uint8 color = *dataPtr++;
- if (imagePal) {
- color = imagePal[color];
- }
+ uint8 color = imagePal[*dataPtr++];
memset(dstPtr, color, code);
dstPtr += code;
} else {
@@ -417,14 +422,8 @@ dec_sub3: w -= code;
if (w < 0) {
code += w;
}
- if (imagePal) {
- while (code--) {
- *dstPtr++ = imagePal[*dataPtr++];
- }
- } else {
- memcpy(dstPtr, dataPtr, code);
- dstPtr += code;
- dataPtr += code;
+ while (code--) {
+ *dstPtr++ = imagePal[*dataPtr++];
}
}
}
@@ -785,7 +784,12 @@ void ScummEngine_v72he::captureWizImage(int resNum, const Common::Rect& r, bool
Common::Rect rCapt(pvs->w, pvs->h);
if (rCapt.intersects(r)) {
rCapt.clip(r);
- const uint8 *palPtr = _currentPalette;
+ const uint8 *palPtr;
+ if (_heversion >= 99) {
+ palPtr = _hePalettes + 1024;
+ } else {
+ palPtr = _currentPalette;
+ }
int w = rCapt.width();
int h = rCapt.height();
@@ -873,12 +877,20 @@ void ScummEngine_v72he::displayWizImage(WizImage *pwi) {
}
uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, int xmapNum, const Common::Rect *clipBox, int flags, int dstResNum, int paletteNum) {
- debug(1, "drawWizImage(%d, %d, %d, 0x%X)", resNum, x1, y1, flags);
+ debug(1, "drawWizImage(resNum %d, x1 %d, y1 %d, flags 0x%X, xmapNum %d paletteNum %d)", resNum, x1, y1, flags, xmapNum, paletteNum);
uint8 *dst = NULL;
+ const uint8 *palPtr = NULL;
+ if (_heversion >= 99) {
+ if (paletteNum) {
+ palPtr = _hePalettes + paletteNum * 1024 + 768;
+ } else {
+ palPtr = _hePalettes + 1792;
+ }
+ }
uint8 *dataPtr = getResourceAddress(rtImage, resNum);
if (dataPtr) {
uint8 *rmap = NULL;
- uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, state, 0);
+ //uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, state, 0);
uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
assert(wizh);
@@ -959,16 +971,15 @@ uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, in
} else if (flags & 0x100) {
warning("drawWizImage() unhandled flag 0x100");
} else {
- _wiz.copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen);
+ _wiz.copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
}
} else if (comp == 0 || comp == 2 || comp == 3) {
uint8 *trns = findWrappedBlock(MKID('TRNS'), dataPtr, state, 0);
int color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1;
- const uint8 *pal = xmap;
if (flags & kWIFRemapPalette) {
- pal = rmap + 4;
+ palPtr = rmap + 4;
}
- _wiz.copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, pal, color);
+ _wiz.copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
} else {
warning("unhandled wiz compression type %d", comp);
}
@@ -1114,6 +1125,7 @@ void ScummEngine_v72he::drawWizComplexPolygon(int resNum, int state, int po_x, i
}
void ScummEngine_v72he::drawWizPolygon(int resNum, int state, int id, int flags, int xmapNum, int dstResNum, int paletteNum) {
+ debug(1, "drawWizPolygon(resNum %d, id %d, flags 0x%X, xmapNum %d paletteNum %d)", resNum, id, flags, xmapNum, paletteNum);
int i;
WizPolygon *wp = NULL;
for (i = 0; i < ARRAYSIZE(_wiz._polygons); ++i) {
@@ -1374,6 +1386,12 @@ void ScummEngine_v90he::createWizEmptyImage(const WizParameters *params) {
}
res_size += 8 + img_w * img_h;
+ const uint8 *palPtr;
+ if (_heversion >= 99) {
+ palPtr = _hePalettes + 1024;
+ } else {
+ palPtr = _currentPalette;
+ }
uint8 *res_data = res.createResource(rtImage, params->img.resNum, res_size);
if (!res_data) {
VAR(119) = -1;
@@ -1389,7 +1407,7 @@ void ScummEngine_v90he::createWizEmptyImage(const WizParameters *params) {
if (flags & 1) {
WRITE_BE_UINT32(res_data, 'RGBS'); res_data += 4;
WRITE_BE_UINT32(res_data, 0x308); res_data += 4;
- memcpy(res_data, _currentPalette, 0x300); res_data += 0x300;
+ memcpy(res_data, palPtr, 0x300); res_data += 0x300;
}
if (flags & 2) {
WRITE_BE_UINT32(res_data, 'SPOT'); res_data += 4;
diff --git a/scumm/wiz_he.h b/scumm/wiz_he.h
index 6be4761501..c1cb826b7e 100644
--- a/scumm/wiz_he.h
+++ b/scumm/wiz_he.h
@@ -132,9 +132,9 @@ struct Wiz {
void polygonRotatePoints(Common::Point *pts, int num, int alpha);
static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);
- static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect);
+ static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr = NULL);
static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
- static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *imagePal = NULL);
+ static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr = NULL);
int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h);
uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);