aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kgraphics.cpp107
-rw-r--r--engines/sci/graphics/palette.cpp17
-rw-r--r--engines/sci/graphics/palette.h2
-rw-r--r--engines/sci/resource.h2
4 files changed, 68 insertions, 60 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index ca794e9884..6ec87487f8 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -253,9 +253,7 @@ reg_t kGraph(EngineState *s, int argc, reg_t *argv) {
}
reg_t kGraphGetColorCount(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isAmiga32color())
- return make_reg(0, 32);
- return make_reg(0, !g_sci->getResMan()->isVGA() ? 16 : 256);
+ return make_reg(0, g_sci->_gfxPalette->getTotalColorCount());
}
reg_t kGraphDrawLine(EngineState *s, int argc, reg_t *argv) {
@@ -551,8 +549,6 @@ reg_t kSetNowSeen(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
-// we are called on EGA/amiga games as well, this doesnt make sense.
-// doing this would actually break the system EGA/amiga palette
reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
if (!s)
return make_reg(0, getSciVersion());
@@ -560,86 +556,83 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
}
reg_t kPaletteSetFromResource(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- GuiResourceId resourceId = argv[0].toUint16();
- bool force = false;
- if (argc == 2)
- force = argv[1].toUint16() == 2 ? true : false;
- g_sci->_gfxPalette->kernelSetFromResource(resourceId, force);
- }
+ GuiResourceId resourceId = argv[0].toUint16();
+ bool force = false;
+ if (argc == 2)
+ force = argv[1].toUint16() == 2 ? true : false;
+
+ // Non-VGA games don't use palette resources
+ if (g_sci->_gfxPalette->getTotalColorCount() < 256)
+ return s->r_acc;
+
+ g_sci->_gfxPalette->kernelSetFromResource(resourceId, force);
return s->r_acc;
}
reg_t kPaletteSetFlag(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
- uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
- uint16 flags = argv[2].toUint16();
- g_sci->_gfxPalette->kernelSetFlag(fromColor, toColor, flags);
- }
+ uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 flags = argv[2].toUint16();
+ g_sci->_gfxPalette->kernelSetFlag(fromColor, toColor, flags);
return s->r_acc;
}
reg_t kPaletteUnsetFlag(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
- uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
- uint16 flags = argv[2].toUint16();
- g_sci->_gfxPalette->kernelUnsetFlag(fromColor, toColor, flags);
- }
+ uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 flags = argv[2].toUint16();
+ g_sci->_gfxPalette->kernelUnsetFlag(fromColor, toColor, flags);
return s->r_acc;
}
reg_t kPaletteSetIntensity(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
- uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
- uint16 intensity = argv[2].toUint16();
- bool setPalette = (argc < 4) ? true : (argv[3].isNull()) ? true : false;
+ uint16 fromColor = CLIP<uint16>(argv[0].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 intensity = argv[2].toUint16();
+ bool setPalette = (argc < 4) ? true : (argv[3].isNull()) ? true : false;
- g_sci->_gfxPalette->kernelSetIntensity(fromColor, toColor, intensity, setPalette);
- }
+ // Palette intensity in non-VGA SCI1 games has been removed
+ if (g_sci->_gfxPalette->getTotalColorCount() < 256)
+ return s->r_acc;
+
+ g_sci->_gfxPalette->kernelSetIntensity(fromColor, toColor, intensity, setPalette);
return s->r_acc;
}
reg_t kPaletteFindColor(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- uint16 r = argv[0].toUint16();
- uint16 g = argv[1].toUint16();
- uint16 b = argv[2].toUint16();
- return make_reg(0, g_sci->_gfxPalette->kernelFindColor(r, g, b));
- }
- return NULL_REG;
+ uint16 r = argv[0].toUint16();
+ uint16 g = argv[1].toUint16();
+ uint16 b = argv[2].toUint16();
+ return make_reg(0, g_sci->_gfxPalette->kernelFindColor(r, g, b));
}
reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- int16 argNr;
- bool paletteChanged = false;
- for (argNr = 0; argNr < argc; argNr += 3) {
- uint16 fromColor = argv[argNr].toUint16();
- uint16 toColor = argv[argNr + 1].toUint16();
- int16 speed = argv[argNr + 2].toSint16();
- if (g_sci->_gfxPalette->kernelAnimate(fromColor, toColor, speed))
- paletteChanged = true;
- }
- if (paletteChanged)
- g_sci->_gfxPalette->kernelAnimateSet();
+ int16 argNr;
+ bool paletteChanged = false;
+
+ // Palette animation in non-VGA SCI1 games has been removed
+ if (g_sci->_gfxPalette->getTotalColorCount() < 256)
+ return s->r_acc;
+
+ for (argNr = 0; argNr < argc; argNr += 3) {
+ uint16 fromColor = argv[argNr].toUint16();
+ uint16 toColor = argv[argNr + 1].toUint16();
+ int16 speed = argv[argNr + 2].toSint16();
+ if (g_sci->_gfxPalette->kernelAnimate(fromColor, toColor, speed))
+ paletteChanged = true;
}
+ if (paletteChanged)
+ g_sci->_gfxPalette->kernelAnimateSet();
+
return s->r_acc;
}
reg_t kPaletteSave(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- return g_sci->_gfxPalette->kernelSave();
- }
- return NULL_REG;
+ return g_sci->_gfxPalette->kernelSave();
}
reg_t kPaletteRestore(EngineState *s, int argc, reg_t *argv) {
- if (g_sci->getResMan()->isVGA()) {
- g_sci->_gfxPalette->kernelRestore(argv[0]);
- }
+ g_sci->_gfxPalette->kernelRestore(argv[0]);
return argv[0];
}
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 683f4369f9..1b3e259ae5 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -76,6 +76,21 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen, bool useMergi
#ifdef ENABLE_SCI32
_clutTable = 0;
#endif
+
+ switch (_resMan->getViewType()) {
+ case kViewVga:
+ case kViewVga11:
+ _totalScreenColors = 256;
+ break;
+ case kViewAmiga:
+ _totalScreenColors = 32;
+ break;
+ case kViewEga:
+ _totalScreenColors = 16;
+ break;
+ default:
+ error("GfxPalette: Unknown view type");
+ }
}
GfxPalette::~GfxPalette() {
@@ -97,7 +112,7 @@ bool GfxPalette::isMerging() {
void GfxPalette::setDefault() {
if (_resMan->getViewType() == kViewEga)
setEGA();
- else if (_resMan->isAmiga32color())
+ else if (_resMan->getViewType() == kViewAmiga)
setAmiga();
else
kernelSetFromResource(999, true);
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index 317401ac1f..d2e5151d6a 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -54,6 +54,7 @@ public:
bool merge(Palette *pFrom, bool force, bool forceRealMerge);
uint16 matchColor(byte r, byte g, byte b);
void getSys(Palette *pal);
+ uint16 getTotalColorCount() const { return _totalScreenColors; }
void setOnScreen();
void copySysPaletteToScreen();
@@ -123,6 +124,7 @@ private:
uint16 _palVaryTicks;
int _palVaryPaused;
int _palVarySignal;
+ uint16 _totalScreenColors;
void loadMacIconBarPalette();
byte *_macClut;
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 76b5a421ee..e941f666d9 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -331,8 +331,6 @@ public:
int getAudioLanguage() const;
void changeAudioDirectory(Common::String path);
bool isGMTrackIncluded();
- bool isVGA() const { return (_viewType == kViewVga) || (_viewType == kViewVga11); }
- bool isAmiga32color() const { return _viewType == kViewAmiga; }
bool isSci11Mac() const { return _volVersion == kResVersionSci11Mac; }
ViewType getViewType() const { return _viewType; }
const char *getMapVersionDesc() const { return versionDescription(_mapVersion); }