diff options
Diffstat (limited to 'gob/palanim.cpp')
-rw-r--r-- | gob/palanim.cpp | 189 |
1 files changed, 96 insertions, 93 deletions
diff --git a/gob/palanim.cpp b/gob/palanim.cpp index ed5a37f274..62b4897c2c 100644 --- a/gob/palanim.cpp +++ b/gob/palanim.cpp @@ -27,74 +27,77 @@ namespace Gob { -int16 pal_fadeValue = 1; - -byte pal_toFadeRed[256]; -byte pal_toFadeGreen[256]; -byte pal_toFadeBlue[256]; +PalAnim::PalAnim(GobEngine *vm) : _vm(vm) { + fadeValue = 1; + for (int i = 0; i < 256; i++) { + toFadeRed[i] = 0; + toFadeGreen[i] = 0; + toFadeBlue[i] = 0; + } +} -char pal_fadeColor(char from, char to) { - if ((int16)from - pal_fadeValue > (int16)to) - return from - pal_fadeValue; - else if ((int16)from + pal_fadeValue < (int16)to) - return from + pal_fadeValue; +char PalAnim::fadeColor(char from, char to) { + if ((int16)from - fadeValue > (int16)to) + return from - fadeValue; + else if ((int16)from + fadeValue < (int16)to) + return from + fadeValue; else return to; } -char pal_fadeStep(int16 oper) { +char PalAnim::fadeStep(int16 oper) { byte newRed; byte newGreen; byte newBlue; char stop; int16 i; - if (colorCount != 256) - error("pal_fadeStep: Only 256 color mode is supported!"); + if (_vm->_global->colorCount != 256) + error("fadeStep: Only 256 color mode is supported!"); if (oper == 0) { stop = 1; - if (setAllPalette) { - if (inVM != 0) - error("pal_fade: inVM != 0 not supported."); + if (_vm->_global->setAllPalette) { + if (_vm->_global->inVM != 0) + error("fade: _vm->_global->inVM != 0 not supported."); for (i = 0; i < 256; i++) { newRed = - pal_fadeColor(redPalette[i], - pal_toFadeRed[i]); + fadeColor(_vm->_global->redPalette[i], + toFadeRed[i]); newGreen = - pal_fadeColor(greenPalette[i], - pal_toFadeGreen[i]); + fadeColor(_vm->_global->greenPalette[i], + toFadeGreen[i]); newBlue = - pal_fadeColor(bluePalette[i], - pal_toFadeBlue[i]); + fadeColor(_vm->_global->bluePalette[i], + toFadeBlue[i]); - if (redPalette[i] != newRed - || greenPalette[i] != newGreen - || bluePalette[i] != newBlue) { + if (_vm->_global->redPalette[i] != newRed + || _vm->_global->greenPalette[i] != newGreen + || _vm->_global->bluePalette[i] != newBlue) { - vid_setPalElem(i, newRed, newGreen, newBlue, 0, 0x13); + _vm->_video->setPalElem(i, newRed, newGreen, newBlue, 0, 0x13); - redPalette[i] = newRed; - greenPalette[i] = newGreen; - bluePalette[i] = newBlue; + _vm->_global->redPalette[i] = newRed; + _vm->_global->greenPalette[i] = newGreen; + _vm->_global->bluePalette[i] = newBlue; stop = 0; } } } else { for (i = 0; i < 16; i++) { - vid_setPalElem(i, - pal_fadeColor(redPalette[i], - pal_toFadeRed[i]), - pal_fadeColor(greenPalette[i], - pal_toFadeGreen[i]), - pal_fadeColor(bluePalette[i], - pal_toFadeBlue[i]), -1, videoMode); - - if (redPalette[i] != pal_toFadeRed[i] || - greenPalette[i] != pal_toFadeGreen[i] || - bluePalette[i] != pal_toFadeBlue[i]) + _vm->_video->setPalElem(i, + fadeColor(_vm->_global->redPalette[i], + toFadeRed[i]), + fadeColor(_vm->_global->greenPalette[i], + toFadeGreen[i]), + fadeColor(_vm->_global->bluePalette[i], + toFadeBlue[i]), -1, _vm->_global->videoMode); + + if (_vm->_global->redPalette[i] != toFadeRed[i] || + _vm->_global->greenPalette[i] != toFadeGreen[i] || + _vm->_global->bluePalette[i] != toFadeBlue[i]) stop = 0; } } @@ -102,36 +105,36 @@ char pal_fadeStep(int16 oper) { } else if (oper == 1) { stop = 1; for (i = 0; i < 16; i++) { - vid_setPalElem(i, - pal_fadeColor(redPalette[i], pal_toFadeRed[i]), - greenPalette[i], bluePalette[i], -1, videoMode); + _vm->_video->setPalElem(i, + fadeColor(_vm->_global->redPalette[i], toFadeRed[i]), + _vm->_global->greenPalette[i], _vm->_global->bluePalette[i], -1, _vm->_global->videoMode); - if (redPalette[i] != pal_toFadeRed[i]) + if (_vm->_global->redPalette[i] != toFadeRed[i]) stop = 0; } return stop; } else if (oper == 2) { stop = 1; for (i = 0; i < 16; i++) { - vid_setPalElem(i, - redPalette[i], - pal_fadeColor(greenPalette[i], pal_toFadeGreen[i]), - bluePalette[i], -1, videoMode); + _vm->_video->setPalElem(i, + _vm->_global->redPalette[i], + fadeColor(_vm->_global->greenPalette[i], toFadeGreen[i]), + _vm->_global->bluePalette[i], -1, _vm->_global->videoMode); - if (greenPalette[i] != pal_toFadeGreen[i]) + if (_vm->_global->greenPalette[i] != toFadeGreen[i]) stop = 0; } return stop; } else if (oper == 3) { stop = 1; for (i = 0; i < 16; i++) { - vid_setPalElem(i, - redPalette[i], - greenPalette[i], - pal_fadeColor(bluePalette[i], pal_toFadeBlue[i]), - -1, videoMode); + _vm->_video->setPalElem(i, + _vm->_global->redPalette[i], + _vm->_global->greenPalette[i], + fadeColor(_vm->_global->bluePalette[i], toFadeBlue[i]), + -1, _vm->_global->videoMode); - if (bluePalette[i] != pal_toFadeBlue[i]) + if (_vm->_global->bluePalette[i] != toFadeBlue[i]) stop = 0; } return stop; @@ -139,95 +142,95 @@ char pal_fadeStep(int16 oper) { return 1; } -void pal_fade(PalDesc *palDesc, int16 fade, int16 allColors) { +void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) { char stop; int16 i; - if (fade < 0) - pal_fadeValue = -fade; + if (fadeV < 0) + fadeValue = -fadeV; else - pal_fadeValue = 2; + fadeValue = 2; - if (colorCount < 256) { + if (_vm->_global->colorCount < 256) { if (palDesc != 0) - vid_setFullPalette(palDesc); + _vm->_video->setFullPalette(palDesc); return; } - if (setAllPalette == 0) { + if (_vm->_global->setAllPalette == 0) { if (palDesc == 0) { for (i = 0; i < 16; i++) { - pal_toFadeRed[i] = 0; - pal_toFadeGreen[i] = 0; - pal_toFadeBlue[i] = 0; + toFadeRed[i] = 0; + toFadeGreen[i] = 0; + toFadeBlue[i] = 0; } } else { for (i = 0; i < 16; i++) { - pal_toFadeRed[i] = palDesc->vgaPal[i].red; - pal_toFadeGreen[i] = palDesc->vgaPal[i].green; - pal_toFadeBlue[i] = palDesc->vgaPal[i].blue; + toFadeRed[i] = palDesc->vgaPal[i].red; + toFadeGreen[i] = palDesc->vgaPal[i].green; + toFadeBlue[i] = palDesc->vgaPal[i].blue; } } } else { - if (inVM != 0) - error("pal_fade: inVM != 0 is not supported"); + if (_vm->_global->inVM != 0) + error("fade: _vm->_global->inVM != 0 is not supported"); if (palDesc == 0) { for (i = 0; i < 256; i++) { - pal_toFadeRed[i] = 0; - pal_toFadeGreen[i] = 0; - pal_toFadeBlue[i] = 0; + toFadeRed[i] = 0; + toFadeGreen[i] = 0; + toFadeBlue[i] = 0; } } else { for (i = 0; i < 256; i++) { - pal_toFadeRed[i] = palDesc->vgaPal[i].red; - pal_toFadeGreen[i] = palDesc->vgaPal[i].green; - pal_toFadeBlue[i] = palDesc->vgaPal[i].blue; + toFadeRed[i] = palDesc->vgaPal[i].red; + toFadeGreen[i] = palDesc->vgaPal[i].green; + toFadeBlue[i] = palDesc->vgaPal[i].blue; } } } if (allColors == 0) { do { - if (tmpPalBuffer == 0) - vid_waitRetrace(videoMode); + if (_vm->_global->tmpPalBuffer == 0) + _vm->_video->waitRetrace(_vm->_global->videoMode); - stop = pal_fadeStep(0); + stop = fadeStep(0); - if (fade > 0) - util_delay(fade); + if (fadeV > 0) + _vm->_util->delay(fadeV); } while (stop == 0); if (palDesc != 0) - vid_setFullPalette(palDesc); + _vm->_video->setFullPalette(palDesc); else - util_clearPalette(); + _vm->_util->clearPalette(); } if (allColors == 1) { do { - vid_waitRetrace(videoMode); - stop = pal_fadeStep(1); + _vm->_video->waitRetrace(_vm->_global->videoMode); + stop = fadeStep(1); } while (stop == 0); do { - vid_waitRetrace(videoMode); - stop = pal_fadeStep(2); + _vm->_video->waitRetrace(_vm->_global->videoMode); + stop = fadeStep(2); } while (stop == 0); do { - vid_waitRetrace(videoMode); - stop = pal_fadeStep(3); + _vm->_video->waitRetrace(_vm->_global->videoMode); + stop = fadeStep(3); } while (stop == 0); if (palDesc != 0) - vid_setFullPalette(palDesc); + _vm->_video->setFullPalette(palDesc); else - util_clearPalette(); + _vm->_util->clearPalette(); } - free(tmpPalBuffer); - tmpPalBuffer = 0; + free(_vm->_global->tmpPalBuffer); + _vm->_global->tmpPalBuffer = 0; } } // End of namespace Gob |