mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-15 00:27:31 +00:00
SCI: kPalette / animate adjustments to behave more like sierra sci, also doesnt crash in island of brain anymore
svn-id: r46975
This commit is contained in:
parent
8cc690935a
commit
01eb329be2
@ -569,12 +569,16 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
|
||||
}
|
||||
case 6: { // Animate
|
||||
int16 argNr;
|
||||
bool paletteChanged = false;
|
||||
for (argNr = 1; argNr < argc; argNr += 3) {
|
||||
uint16 fromColor = argv[argNr].toUint16();
|
||||
uint16 toColor = argv[argNr + 1].toUint16();
|
||||
int16 speed = argv[argNr + 2].toSint16();
|
||||
s->_gui->paletteAnimate(fromColor, toColor, speed);
|
||||
if (s->_gui->paletteAnimate(fromColor, toColor, speed))
|
||||
paletteChanged = true;
|
||||
}
|
||||
if (paletteChanged)
|
||||
s->_gui->paletteAnimateSet();
|
||||
break;
|
||||
}
|
||||
case 7: { // Save palette to heap
|
||||
@ -963,7 +967,6 @@ reg_t kAnimate(EngineState *s, int argc, reg_t *argv) {
|
||||
// Take care of incoming events (kAnimate is called semi-regularly)
|
||||
process_sound_events(s);
|
||||
#endif
|
||||
|
||||
s->_gui->animate(castListReference, cycle, argc, argv);
|
||||
|
||||
return s->r_acc;
|
||||
|
@ -573,12 +573,16 @@ void SciGui::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intens
|
||||
_palette->setIntensity(fromColor, toColor, intensity, setPalette);
|
||||
}
|
||||
|
||||
void SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed) {
|
||||
bool SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed) {
|
||||
// we are also called on Amiga as well, but for colors above 32, so it doesnt make sense
|
||||
if (!_s->resMan->isVGA())
|
||||
return;
|
||||
return false;
|
||||
|
||||
_palette->animate(fromColor, toColor, speed);
|
||||
return _palette->animate(fromColor, toColor, speed);
|
||||
}
|
||||
|
||||
void SciGui::paletteAnimateSet() {
|
||||
_palette->setOnScreen();
|
||||
}
|
||||
|
||||
void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) {
|
||||
|
@ -116,7 +116,8 @@ public:
|
||||
virtual void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
||||
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, int16 speed);
|
||||
virtual bool paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed);
|
||||
virtual void paletteAnimateSet();
|
||||
|
||||
virtual void shakeScreen(uint16 shakeCount, uint16 directions);
|
||||
|
||||
|
@ -296,37 +296,59 @@ void SciGuiPalette::setIntensity(uint16 fromColor, uint16 toColor, uint16 intens
|
||||
setOnScreen();
|
||||
}
|
||||
|
||||
void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) {
|
||||
// Returns true, if palette got changed
|
||||
bool SciGuiPalette::animate(byte fromColor, byte toColor, int speed) {
|
||||
GuiColor col;
|
||||
int len = toColor - fromColor - 1;
|
||||
byte colorNr;
|
||||
int16 colorCount;
|
||||
uint32 now = g_system->getMillis() * 60 / 1000;
|
||||
|
||||
// search for sheduled animations with the same 'from' value
|
||||
int sz = _schedules.size();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if (_schedules[i].from == fromColor) {
|
||||
if (_schedules[i].schedule < now) {
|
||||
// schedule animation...
|
||||
int scheduleCount = _schedules.size();
|
||||
int scheduleNr;
|
||||
for (scheduleNr = 0; scheduleNr < scheduleCount; scheduleNr++) {
|
||||
if (_schedules[scheduleNr].from == fromColor)
|
||||
break;
|
||||
}
|
||||
if (scheduleNr == scheduleCount) {
|
||||
// adding a new schedule
|
||||
GuiPalSchedule newSchedule;
|
||||
newSchedule.from = fromColor;
|
||||
newSchedule.schedule = now + ABS(speed);
|
||||
_schedules.push_back(newSchedule);
|
||||
scheduleCount++;
|
||||
}
|
||||
|
||||
for (scheduleNr = 0; scheduleNr < scheduleCount; scheduleNr++) {
|
||||
if (_schedules[scheduleNr].from == fromColor) {
|
||||
if (_schedules[scheduleNr].schedule <= now) {
|
||||
if (speed > 0) {
|
||||
// TODO: Not really sure about this, sierra sci seems to do exactly this here
|
||||
col = _sysPalette.colors[fromColor];
|
||||
memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], len * sizeof(GuiColor));
|
||||
if (fromColor < toColor) {
|
||||
colorCount = toColor - fromColor - 1;
|
||||
memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], colorCount * sizeof(GuiColor));
|
||||
}
|
||||
_sysPalette.colors[toColor - 1] = col;
|
||||
} else {
|
||||
col = _sysPalette.colors[toColor - 1];
|
||||
memmove(&_sysPalette.colors[fromColor + 1], &_sysPalette.colors[fromColor], len * sizeof(GuiColor));
|
||||
if (fromColor < toColor) {
|
||||
colorCount = toColor - fromColor - 1;
|
||||
memmove(&_sysPalette.colors[fromColor + 1], &_sysPalette.colors[fromColor], colorCount * sizeof(GuiColor));
|
||||
}
|
||||
_sysPalette.colors[fromColor] = col;
|
||||
}
|
||||
// removing schedule
|
||||
_schedules.remove_at(i);
|
||||
_schedules[scheduleNr].schedule = now + ABS(speed);
|
||||
// TODO: Not sure when sierra actually removes a schedule
|
||||
//_schedules.remove_at(scheduleNr);
|
||||
return true;
|
||||
}
|
||||
setOnScreen();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// adding a new schedule
|
||||
GuiPalSchedule newSchedule;
|
||||
newSchedule.from = fromColor;
|
||||
newSchedule.schedule = now + ABS(speed);
|
||||
_schedules.push_back(newSchedule);
|
||||
return false;
|
||||
}
|
||||
|
||||
// palVary
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
void setFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
||||
void unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
||||
void setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
|
||||
void animate(byte fromColor, byte toColor, int speed);
|
||||
bool animate(byte fromColor, byte toColor, int speed);
|
||||
|
||||
GuiPalette _sysPalette;
|
||||
|
||||
|
@ -1588,8 +1588,12 @@ void SciGui32::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 inte
|
||||
#endif
|
||||
}
|
||||
|
||||
void SciGui32::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
|
||||
bool SciGui32::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
|
||||
//warning("STUB");
|
||||
return false;
|
||||
}
|
||||
|
||||
void SciGui32::paletteAnimateSet() {
|
||||
}
|
||||
|
||||
#define SHAKE_DOWN 1
|
||||
|
@ -94,7 +94,8 @@ public:
|
||||
void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
|
||||
int16 paletteFind(uint16 r, uint16 g, uint16 b);
|
||||
void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity);
|
||||
void paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
|
||||
bool paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
|
||||
void paletteAnimateSet();
|
||||
|
||||
void shakeScreen(uint16 shakeCount, uint16 directions);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user