diff options
author | sirlemonhead | 2015-05-12 00:42:57 +0100 |
---|---|---|
committer | Paul Gilbert | 2015-05-12 08:56:53 -0400 |
commit | 7b2da2abc58866d6ad33730d2237bc0decf4ae0e (patch) | |
tree | d3e72cd2290b677a34c40e82b1aec34804fb5979 /engines/sherlock | |
parent | 0d3750a768c8f9457530344fa6871b98dd20276b (diff) | |
download | scummvm-rg350-7b2da2abc58866d6ad33730d2237bc0decf4ae0e.tar.gz scummvm-rg350-7b2da2abc58866d6ad33730d2237bc0decf4ae0e.tar.bz2 scummvm-rg350-7b2da2abc58866d6ad33730d2237bc0decf4ae0e.zip |
SHERLOCK: Re-factored Scalpel arrays out of Animation
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/animation.cpp | 87 | ||||
-rw-r--r-- | engines/sherlock/animation.h | 15 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel.cpp | 41 |
3 files changed, 104 insertions, 39 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp index dac903a358..5c11c4f6fb 100644 --- a/engines/sherlock/animation.cpp +++ b/engines/sherlock/animation.cpp @@ -26,39 +26,6 @@ namespace Sherlock { -// The following are a list of filenames played in the prologue that have -// special effects associated with them at specific frames - -#define FRAMES_END 32000 -#define PROLOGUE_NAMES_COUNT 6 -#define TITLE_NAMES_COUNT 7 -static const char *const PROLOGUE_NAMES[6] = { - "subway1", "subway2", "finale2", "suicid", "coff3", "coff4" -}; -static const int PROLOGUE_FRAMES[6][9] = { - { 4, 26, 54, 72, 92, 134, FRAMES_END }, - { 2, 80, 95, 117, 166, FRAMES_END }, - { 1, FRAMES_END }, - { 42, FRAMES_END }, - { FRAMES_END }, - { FRAMES_END } -}; - -// Title animations file list -static const char *const TITLE_NAMES[7] = { - "27pro1", "14note", "coff1", "coff2", "coff3", "coff4", "14kick" -}; - -static const int TITLE_FRAMES[7][9] = { - { 29, 131, FRAMES_END }, - { 55, 80, 95, 117, 166, FRAMES_END }, - { 15, FRAMES_END }, - { 4, 37, 92, FRAMES_END }, - { 2, 43, FRAMES_END }, - { 2, FRAMES_END }, - { 10, 50, FRAMES_END } -}; - static const int NO_FRAMES = FRAMES_END; Animation::Animation(SherlockEngine *vm): _vm(vm) { @@ -172,22 +139,64 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade, } /** + * Load the prologue name array + */ +void Animation::setPrologueNames(const char *const *names, int count) { + for (int idx = 0; idx < count; ++idx, names++) { + _prologueNames.push_back(*names); + } +} + +/** + * Load the prologue frame array + */ +void Animation::setPrologueFrames(const int *frames, int count, int maxFrames) { + _prologueFrames.resize(count); + + for (int idx = 0; idx < count; ++idx, frames + maxFrames) { + _prologueFrames[idx].resize(maxFrames); + Common::copy(frames, frames + maxFrames, &_prologueFrames[idx][0]); + } +} + +/** + * Load the title name array + */ +void Animation::setTitleNames(const char *const *names, int count) { + for (int idx = 0; idx < count; ++idx, names++) { + _titleNames.push_back(*names); + } +} + +/** + * Load the title frame array + */ +void Animation::setTitleFrames(const int *frames, int count, int maxFrames) { + _titleFrames.resize(count); + + for (int idx = 0; idx < count; ++idx, frames + maxFrames) { + _titleFrames[idx].resize(maxFrames); + Common::copy(frames, frames + maxFrames, &_titleFrames[idx][0]); + } +} + +/** * Checks for whether an animation is being played that has associated sound */ const int *Animation::checkForSoundFrames(const Common::String &filename) { const int *frames = &NO_FRAMES; if (_vm->_soundOverride.empty()) { - for (int idx = 0; idx < PROLOGUE_NAMES_COUNT; ++idx) { - if (filename.equalsIgnoreCase(PROLOGUE_NAMES[idx])) { - frames = &PROLOGUE_FRAMES[idx][0]; + for (Common::Array<const char *>::size_type idx = 0; idx < _prologueNames.size(); ++idx) { + if (filename.equalsIgnoreCase(_prologueNames[idx])) { + frames = &_prologueFrames[idx][0]; break; } } } else { - for (int idx = 0; idx < TITLE_NAMES_COUNT; ++idx) { - if (filename.equalsIgnoreCase(TITLE_NAMES[idx])) { - frames = &TITLE_FRAMES[idx][0]; + for (Common::Array<const char *>::size_type idx = 0; idx < _titleNames.size(); ++idx) { + if (filename.equalsIgnoreCase(_titleNames[idx])) { + frames = &_titleFrames[idx][0]; break; } } diff --git a/engines/sherlock/animation.h b/engines/sherlock/animation.h index 245d83789f..5802ffcd88 100644 --- a/engines/sherlock/animation.h +++ b/engines/sherlock/animation.h @@ -25,20 +25,35 @@ #include "common/scummsys.h" #include "common/str.h" +#include "common/array.h" namespace Sherlock { +#define FRAMES_END 32000 + class SherlockEngine; class Animation { private: SherlockEngine *_vm; + Common::Array<const char *> _prologueNames; + Common::Array<Common::Array<int>> _prologueFrames; + + Common::Array<const char *> _titleNames; + Common::Array<Common::Array<int>> _titleFrames; + const int *checkForSoundFrames(const Common::String &filename); public: public: Animation(SherlockEngine *vm); + void setPrologueNames(const char *const *names, int count); + void setPrologueFrames(const int *frames, int count, int maxFrames); + + void setTitleNames(const char *const *names, int count); + void setTitleFrames(const int *frames, int count, int maxFrames); + bool play(const Common::String &filename, int minDelay, int fade, bool setPalette, int speed); }; diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp index 8dc75c034f..5d84a7f5ed 100644 --- a/engines/sherlock/scalpel/scalpel.cpp +++ b/engines/sherlock/scalpel/scalpel.cpp @@ -22,11 +22,46 @@ #include "sherlock/scalpel/scalpel.h" #include "sherlock/sherlock.h" +#include "sherlock/animation.h" namespace Sherlock { namespace Scalpel { +#define PROLOGUE_NAMES_COUNT 6 + +// The following are a list of filenames played in the prologue that have +// special effects associated with them at specific frames +static const char *const PROLOGUE_NAMES[PROLOGUE_NAMES_COUNT] = { + "subway1", "subway2", "finale2", "suicid", "coff3", "coff4" +}; + +static const int PROLOGUE_FRAMES[6][9] = { + { 4, 26, 54, 72, 92, 134, FRAMES_END }, + { 2, 80, 95, 117, 166, FRAMES_END }, + { 1, FRAMES_END }, + { 42, FRAMES_END }, + { FRAMES_END }, + { FRAMES_END } +}; + +#define TITLE_NAMES_COUNT 7 + +// Title animations file list +static const char *const TITLE_NAMES[TITLE_NAMES_COUNT] = { + "27pro1", "14note", "coff1", "coff2", "coff3", "coff4", "14kick" +}; + +static const int TITLE_FRAMES[7][9] = { + { 29, 131, FRAMES_END }, + { 55, 80, 95, 117, 166, FRAMES_END }, + { 15, FRAMES_END }, + { 4, 37, 92, FRAMES_END }, + { 2, 43, FRAMES_END }, + { 2, FRAMES_END }, + { 10, 50, FRAMES_END } +}; + #define NUM_PLACES 100 const int MAP_X[NUM_PLACES] = { 0, 368, 0, 219, 0, 282, 0, 43, 0, 0, 396, 408, 0, 0, 0, 568, 37, 325, @@ -227,6 +262,12 @@ void ScalpelEngine::initialize() { // Set up constants used by the talk system _talk->setSequences(&TALK_SEQUENCES[0][0], &STILL_SEQUENCES[0][0], MAX_PEOPLE); + _animation->setPrologueNames(&PROLOGUE_NAMES[0], PROLOGUE_NAMES_COUNT); + _animation->setPrologueFrames(&PROLOGUE_FRAMES[0][0], 6, 9); + + _animation->setTitleNames(&TITLE_NAMES[0], TITLE_NAMES_COUNT); + _animation->setTitleFrames(&TITLE_FRAMES[0][0], 7, 9); + // Starting scene if (getIsDemo()) _scene->_goToScene = 3; |