SCI: Some palette related changes

- Moved palette color count inside the GfxPalette class
- Enabled all of the kPalette subops for 16 color SCI1 games, apart from
the ones for intensity palette animation, and palette resource loading
- Removed isVGA() and isAmiga32color() methods from the resource manager -
they ended up in having inconsistent code
This commit is contained in:
md5 2011-03-04 21:56:14 +02:00
parent 5b9677da72
commit d95b5331fb
4 changed files with 68 additions and 60 deletions

View File

@ -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];
}

View File

@ -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);

View File

@ -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;

View File

@ -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); }