diff options
author | Paul Gilbert | 2014-11-01 22:20:23 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 22:19:55 -0500 |
commit | f3063a13f08a2b085d92d0a79231e568671501b3 (patch) | |
tree | 2bc4544ce8ee93bf4f25d0a45b0d20df411941c1 /engines | |
parent | 7e4d76b1fb41662cd48e21d775322d2a0ad3325e (diff) | |
download | scummvm-rg350-f3063a13f08a2b085d92d0a79231e568671501b3.tar.gz scummvm-rg350-f3063a13f08a2b085d92d0a79231e568671501b3.tar.bz2 scummvm-rg350-f3063a13f08a2b085d92d0a79231e568671501b3.zip |
ACCESS: Implement palette cycling script commands
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/amazon/amazon_scripts.cpp | 6 | ||||
-rw-r--r-- | engines/access/amazon/amazon_scripts.h | 2 | ||||
-rw-r--r-- | engines/access/screen.cpp | 38 | ||||
-rw-r--r-- | engines/access/screen.h | 9 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 14 | ||||
-rw-r--r-- | engines/access/scripts.h | 4 |
6 files changed, 64 insertions, 9 deletions
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7ad68bd5bc..0ea9ee5ebe 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -413,7 +413,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)(); void AmazonScripts::executeCommand(int commandIndex) { static const AmazonScriptMethodPtr COMMAND_LIST[] = { - &AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK, + &AmazonScripts::cmdHelp, &AmazonScripts::cmdCycleBack, &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp, &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, &AmazonScripts::CMDRETFLASH @@ -449,8 +449,8 @@ void AmazonScripts::cmdHelp() { error("TODO: more cmdHelp"); } -void AmazonScripts::CMDCYCLEBACK() { - error("TODO CMDCYCLEBACK"); +void AmazonScripts::cmdCycleBack() { + _vm->_screen->cyclePaletteBackwards(); } void AmazonScripts::cmdChapter() { int chapter = _data->readByte(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index edb8843da3..694260ddcb 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -52,7 +52,7 @@ protected: void boatWalls(int param1, int param2); void cmdHelp(); - void CMDCYCLEBACK(); + void cmdCycleBack(); void cmdChapter(); void cmdSetHelp(); void cmdCenterPanel(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 227d9d7d0c..17f36fc072 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -59,6 +59,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _vWindowLinesTall = this->h; _clipWidth = _vWindowBytesWide - 1; _clipHeight = _vWindowLinesTall - 1; + _startCycle = 0; + _cycleStart = 0; + _endCycle = 0; } void Screen::clearScreen() { @@ -244,4 +247,39 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); } +void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { + _startCycle = _cycleStart = startCycle; + _endCycle = endCycle; + + TimerEntry &te = _vm->_timers[6]; + te._timer = te._initTm = timer; + te._flag++; +} + +void Screen::cyclePaletteForward() { + cyclePaletteBackwards(); +} + +void Screen::cyclePaletteBackwards() { + if (!_vm->_timers[6]._flag) { + _vm->_timers[6]._flag++; + byte *pStart = &_rawPalette[_cycleStart * 3]; + byte *pEnd = &_rawPalette[_endCycle * 3]; + + for (int idx = _startCycle; idx < _endCycle; ++idx) { + g_system->getPaletteManager()->setPalette(pStart, idx, 1); + + pStart += 3; + if (pStart == pEnd) + pStart = &_rawPalette[_cycleStart * 3]; + } + + if (--_cycleStart <= _startCycle) + _cycleStart = _endCycle - 1; + + g_system->updateScreen(); + g_system->delayMillis(10); + } +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index b278062d13..2db05a5f9d 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -60,6 +60,9 @@ private: Common::Point _virtualOffsetsTable[4]; bool _hideFlag; ScreenSave _screenSave; + int _startCycle; + int _cycleStart; + int _endCycle; void updatePalette(); public: @@ -150,6 +153,12 @@ public: * Restores previously saved screen display state variables */ void restoreScreen(); + + void setPaletteCycle(int startCycle, int endCycle, int timer); + + void cyclePaletteForward(); + + void cyclePaletteBackwards(); }; } // End of namespace Access diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bed1a775f6..2aa10b6b4a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -126,7 +126,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, + &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, @@ -514,8 +514,16 @@ void Scripts::cmdSpecial() { } } -void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); } -void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); } +void Scripts::cmdSetCycle() { + int startCycle = _data->readUint16LE(); + int endCycle = _data->readUint16LE(); + int timer = _data->readUint16LE(); + _vm->_screen->setPaletteCycle(startCycle, endCycle, timer); +} + +void Scripts::cmdCycle() { + _vm->_screen->cyclePaletteForward(); +} void Scripts::cmdCharSpeak() { _vm->_screen->_printOrg = _charsOrg; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 49c3b562b9..f4128f4e31 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -101,8 +101,8 @@ protected: void CMDPLAYBUFVID(); void cmdRemoveLast(); void cmdSpecial(); - void CMDSETCYCLE(); - void CMDCYCLE(); + void cmdSetCycle(); + void cmdCycle(); void cmdCharSpeak(); void cmdTexSpeak(); void cmdTexChoice(); |