aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-20 16:11:31 +0000
committerMartin Kiewitz2009-10-20 16:11:31 +0000
commit361977e7ed074ab0a099360ef58a0bf5a8b5182a (patch)
tree28656df38580226fcb90b4ab1601c630c9dca13f /engines/sci
parent55dd109653c56c2847a06f9acb2fc3bf3834f730 (diff)
downloadscummvm-rg350-361977e7ed074ab0a099360ef58a0bf5a8b5182a.tar.gz
scummvm-rg350-361977e7ed074ab0a099360ef58a0bf5a8b5182a.tar.bz2
scummvm-rg350-361977e7ed074ab0a099360ef58a0bf5a8b5182a.zip
SCI/newgui: kPalette cleanup, preparing for sq5 paletteAnimate support
svn-id: r45273
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.cpp2
-rw-r--r--engines/sci/engine/kernel.h1
-rw-r--r--engines/sci/engine/kgraphics.cpp73
-rw-r--r--engines/sci/gui/gui.cpp12
-rw-r--r--engines/sci/gui/gui.h8
-rw-r--r--engines/sci/gui/gui_palette.cpp6
-rw-r--r--engines/sci/gui/gui_palette.h4
-rw-r--r--engines/sci/gui32/gui32.cpp8
-rw-r--r--engines/sci/gui32/gui32.h8
9 files changed, 72 insertions, 50 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index c296d74ac7..ee795454b0 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -337,6 +337,7 @@ SciKernelFunction kfunct_mappers[] = {
// its a stub, but its needed for Pharkas to work
DEFUN("PalVary", kPalVary, "ii*"),
+ DEFUN("AssertPalette", kAssertPalette, "i"),
#if 0
// Stub functions
@@ -345,7 +346,6 @@ SciKernelFunction kfunct_mappers[] = {
DEFUN("ListOps", kListOps, ".*"),
DEFUN("ATan", kATan, ".*"),
DEFUN("MergePoly", kMergePoly, ".*"),
- DEFUN("AssertPalette", kAssertPalette, ".*"),
DEFUN("Record", kRecord, ".*"),
DEFUN("PlayBack", kPlayBack, ".*"),
DEFUN("DbugStr", kDbugStr, ".*"),
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index f5d003d670..7cf3bcd4e3 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -303,6 +303,7 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv);
reg_t kLock(EngineState *s, int argc, reg_t *argv);
reg_t kPalette(EngineState *s, int argc, reg_t *argv);
reg_t kPalVary(EngineState *s, int argc, reg_t *argv);
+reg_t kAssertPalette(EngineState *s, int argc, reg_t *argv);
reg_t kNumCels(EngineState *s, int argc, reg_t *argv);
reg_t kNumLoops(EngineState *s, int argc, reg_t *argv);
reg_t kDrawCel(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index d12f343587..677b59db0f 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -559,55 +559,70 @@ reg_t kSetNowSeen(EngineState *s, int argc, reg_t *argv) {
}
reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
-// warning("kPalette %d", argv[0].toUint16());
switch (argv[0].toUint16()) {
- case 1:
+ case 1: // Set resource palette
if (argc==3) {
- int resourceNo = argv[1].toUint16();
- int flags = argv[2].toUint16();
- s->_gui->paletteSet(resourceNo, flags);
+ GuiResourceId resourceId = argv[1].toUint16();
+ uint16 flags = argv[2].toUint16();
+ s->_gui->paletteSet(resourceId, flags);
}
break;
- case 2:
- debug(5, "STUB: kPalette() effect 2, set flag to colors");
+ case 2: // Set flag to colors
+ warning("kPalette(2), set flag to colors");
break;
- case 3:
- debug(5, "STUB: kPalette() effect 3, clear flag to colors");
+ case 3: // Clear flag to colors
+ warning("kPalette(3), clear flag to colors");
break;
case 4: { // Set palette intensity
- if (argc >= 4) {
- int16 fromColor = CLIP<int>(argv[1].toUint16(), 1, 255);
- int16 toColor = CLIP<int>(argv[2].toUint16(), 1, 255);
- int16 intensity = argv[3].toUint16();
+ switch (argc) {
+ case 4:
+ case 5: {
+ uint16 fromColor = CLIP<int>(argv[1].toUint16(), 1, 255);
+ uint16 toColor = CLIP<int>(argv[2].toUint16(), 1, 255);
+ uint16 intensity = argv[3].toUint16();
bool setPalette = (argc < 5) ? true : (argv[4].isNull()) ? true : false;
s->_gui->paletteSetIntensity(fromColor, toColor, intensity, setPalette);
+ break;
+ }
+ default:
+ warning("kPalette(4) called with %d parameters", argc);
}
break;
}
case 5: { // Find closest color
- int r = argv[1].toUint16();
- int g = argv[2].toUint16();
- int b = argv[3].toUint16();
+ uint16 r = argv[1].toUint16();
+ uint16 g = argv[2].toUint16();
+ uint16 b = argv[3].toUint16();
return make_reg(0, s->_gui->paletteFind(r, g, b));
}
- case 6:
- if (argc==4) {
- int fromColor = argv[1].toUint16();
- int toColor = argv[2].toUint16();
- int speed = argv[3].toSint16();
+ case 6: { // Animate
+ switch (argc) {
+ case 4: {
+ uint16 fromColor = argv[1].toUint16();
+ uint16 toColor = argv[2].toUint16();
+ uint16 speed = argv[3].toSint16();
s->_gui->paletteAnimate(fromColor, toColor, speed);
+ break;
+ }
+ case 22:
+
+ default:
+ warning("kPalette(6) called with %d parameters", argc);
}
break;
- case 7:
- debug(5, "STUB: kPalette() effect 7, save palette to heap");
+ }
+ case 7: { // Save palette to heap
+ warning("kPalette(7), save palette to heap STUB");
break;
- case 8:
- debug(5, "STUB: kPalette() effect 8, set stored palette");
+ }
+ case 8: { // Restore palette from heap
+ warning("kPalette(8), set stored palette STUB");
break;
+ }
default:
- warning("kPalette(): Unimplemented subfunction: %d", argv[0].toUint16());
+ warning("kPalette(%d), not implemented", argv[0].toUint16());
}
return s->r_acc;
@@ -619,6 +634,12 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
return NULL_REG;
}
+reg_t kAssertPalette(EngineState *s, int argc, reg_t *argv) {
+ GuiResourceId viewId = argv[1].toUint16();
+ warning("kAssertPalette() called with viewId = %d", viewId);
+ return s->r_acc;
+}
+
static void disableCertainButtons(SegManager *segMan, Common::String gameName, reg_t obj) {
reg_t text_pos = GET_SEL32(segMan, obj, text);
Common::String text;
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 24b87f68b9..a4d4dac4e1 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -457,20 +457,20 @@ int16 SciGui::picNotValid(int16 newPicNotValid) {
}
-void SciGui::paletteSet(int resourceNo, int flags) {
- _palette->setFromResource(resourceNo, flags);
+void SciGui::paletteSet(GuiResourceId resourceId, uint16 flags) {
+ _palette->setFromResource(resourceId, flags);
}
-int16 SciGui::paletteFind(int r, int g, int b) {
+int16 SciGui::paletteFind(uint16 r, uint16 g, uint16 b) {
return _palette->matchColor(&_palette->_sysPalette, r, g, b) & 0xFF;
}
-void SciGui::paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette) {
+void SciGui::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette) {
_palette->setIntensity(fromColor, toColor, intensity, setPalette);
}
-void SciGui::paletteAnimate(int fromColor, int toColor, int speed) {
- // kAnimate gets called for Amiga as well, but for colors above 32, so it doesnt make sense
+void SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
+ // we are also called on Amiga as well, but for colors above 32, so it doesnt make sense
if (!_s->resMan->isVGA())
return;
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index b0101c7781..697edf976d 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -100,10 +100,10 @@ public:
virtual int16 picNotValid(int16 newPicNotValid);
- virtual void paletteSet(int resourceNo, int flags);
- virtual int16 paletteFind(int r, int g, int b);
- virtual void paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette);
- virtual void paletteAnimate(int fromColor, int toColor, int speed);
+ virtual void paletteSet(GuiResourceId resourceNo, uint16 flags);
+ virtual int16 paletteFind(uint16 r, uint16 g, uint16 b);
+ virtual void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
+ virtual void paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
virtual void shakeScreen(uint16 shakeCount, uint16 directions);
diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp
index 7b84beb17c..83b94e2085 100644
--- a/engines/sci/gui/gui_palette.cpp
+++ b/engines/sci/gui/gui_palette.cpp
@@ -170,8 +170,8 @@ void SciGuiPalette::setEGA() {
setOnScreen();
}
-bool SciGuiPalette::setFromResource(int16 resourceNo, int16 flag) {
- Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceNo), 0);
+bool SciGuiPalette::setFromResource(GuiResourceId resourceId, uint16 flag) {
+ Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), 0);
GuiPalette palette;
if (palResource) {
@@ -182,7 +182,7 @@ bool SciGuiPalette::setFromResource(int16 resourceNo, int16 flag) {
return false;
}
-void SciGuiPalette::set(GuiPalette *sciPal, int16 flag) {
+void SciGuiPalette::set(GuiPalette *sciPal, uint16 flag) {
uint32 systime = _sysPalette.timestamp;
if (flag == 2 || sciPal->timestamp != systime) {
merge(sciPal, &_sysPalette, flag);
diff --git a/engines/sci/gui/gui_palette.h b/engines/sci/gui/gui_palette.h
index 1bfc3aa3e4..9313d7e169 100644
--- a/engines/sci/gui/gui_palette.h
+++ b/engines/sci/gui/gui_palette.h
@@ -39,8 +39,8 @@ public:
void createFromData(byte *data, GuiPalette *paletteOut);
bool setAmiga();
void setEGA();
- bool setFromResource(int16 resourceNo, int16 flag);
- void set(GuiPalette *sciPal, int16 flag);
+ bool setFromResource(GuiResourceId resourceId, uint16 flag);
+ void set(GuiPalette *sciPal, uint16 flag);
void merge(GuiPalette *pFrom, GuiPalette *pTo, uint16 flag);
uint16 matchColor(GuiPalette *pPal, byte r, byte g, byte b);
void getSys(GuiPalette *pal);
diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp
index 82fc341a85..a5a7987d8b 100644
--- a/engines/sci/gui32/gui32.cpp
+++ b/engines/sci/gui32/gui32.cpp
@@ -1342,11 +1342,11 @@ int16 SciGui32::picNotValid(int16 newPicNotValid) {
return oldPicNotValid;
}
-void SciGui32::paletteSet(int resourceNo, int flags) {
+void SciGui32::paletteSet(GuiResourceId resourceNo, uint16 flags) {
//warning("STUB");
}
-int16 SciGui32::paletteFind(int r, int g, int b) {
+int16 SciGui32::paletteFind(uint16 r, uint16 g, uint16 b) {
int i, delta, bestindex = -1, bestdelta = 200000;
for (i = 0; i < _s->gfx_state->gfxResMan->getColorCount(); i++) {
@@ -1366,13 +1366,13 @@ int16 SciGui32::paletteFind(int r, int g, int b) {
return bestindex;
}
-void SciGui32::paletteSetIntensity(int fromColor, int toColor, int intensity) {
+void SciGui32::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity) {
#if 0
_s->gfx_state->gfxResMan->setPaletteIntensity(fromColor, toColor, intensity);
#endif
}
-void SciGui32::paletteAnimate(int fromColor, int toColor, int speed) {
+void SciGui32::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
//warning("STUB");
}
diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h
index da4aa229b6..3f7d12e80c 100644
--- a/engines/sci/gui32/gui32.h
+++ b/engines/sci/gui32/gui32.h
@@ -78,10 +78,10 @@ public:
int16 picNotValid(int16 newPicNotValid);
- void paletteSet(int resourceNo, int flags);
- int16 paletteFind(int r, int g, int b);
- void paletteSetIntensity(int fromColor, int toColor, int intensity);
- void paletteAnimate(int fromColor, int toColor, int speed);
+ void paletteSet(GuiResourceId resourceNo, uint16 flags);
+ int16 paletteFind(uint16 r, uint16 g, uint16 b);
+ void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity);
+ void paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
void shakeScreen(uint16 shakeCount, uint16 directions);