* Implemented LoadPalette, SetPalette and BlackPalette GPL commands.

* Used a more natural condition (whether the scheduled room number is different from the current room number) instead of the _roomChange hack.

svn-id: r43391
This commit is contained in:
Denis Kasak 2009-08-15 02:42:34 +00:00
parent fad77de234
commit abf10049bb
4 changed files with 47 additions and 4 deletions

View File

@ -217,6 +217,7 @@ void Game::start() {
void Game::init() {
_shouldQuit = false;
_shouldExitLoop = false;
_scheduledPalette = 0;
_animUnderCursor = kOverlayImage;
@ -437,7 +438,7 @@ void Game::loop() {
_vm->_system->delayMillis(20);
// HACK: Won't be needed once the game loop is implemented properly
_shouldExitLoop = _shouldExitLoop || (_roomChange &&
_shouldExitLoop = _shouldExitLoop || (_newRoom != _currentRoom._roomNum &&
(_loopStatus == kStatusOrdinary || _loopStatus == kStatusGate));
} while (!shouldExitLoop());
@ -1160,6 +1161,14 @@ int Game::getEscRoom() {
return _currentRoom._escRoom;
}
void Game::schedulePalette(int paletteID) {
_scheduledPalette = paletteID;
}
int Game::getScheduledPalette() {
return _scheduledPalette;
}
/**
* The GPL command Mark sets the animation index (which specifies the order in which
* animations were loaded in) which is then used by the Release command to delete

View File

@ -73,6 +73,10 @@ enum {
kNoDialogue = -1, kDialogueLines = 4
};
enum {
kBlackPalette = -1
};
enum SpeechConstants {
kBaseSpeechDuration = 200,
kSpeechTimeUnit = 400
@ -293,6 +297,9 @@ public:
void dialogueDone();
void runDialogueProg(GPL2Program, int offset);
void schedulePalette(int paletteID);
int getScheduledPalette();
bool _roomChange;
private:
@ -341,6 +348,8 @@ public:
int _animUnderCursor;
int _markedAnimationIndex; //!< Used by the Mark GPL command
int _scheduledPalette;
};
} // End of namespace Draci

View File

@ -61,9 +61,9 @@ void Script::setupCommandList() {
{ 10, 1, "WalkOn", 3, { 1, 1, 3 }, &Script::walkOn },
{ 10, 2, "StayOn", 3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation
{ 10, 3, "WalkOnPlay", 3, { 1, 1, 3 }, &Script::walkOnPlay },
{ 11, 1, "LoadPalette", 1, { 2 }, NULL },
{ 12, 1, "SetPalette", 0, { 0 }, NULL },
{ 12, 2, "BlackPalette", 0, { 0 }, NULL },
{ 11, 1, "LoadPalette", 1, { 2 }, &Script::loadPalette },
{ 12, 1, "SetPalette", 0, { 0 }, &Script::setPalette },
{ 12, 2, "BlackPalette", 0, { 0 }, &Script::blackPalette },
{ 13, 1, "FadePalette", 3, { 1, 1, 1 }, NULL },
{ 13, 2, "FadePalettePlay", 3, { 1, 1, 1 }, NULL },
{ 14, 1, "NewRoom", 2, { 3, 1 }, &Script::newRoom },
@ -716,6 +716,28 @@ void Script::roomMap(Common::Queue<int> &params) {
_vm->_game->loadWalkingMap();
}
void Script::loadPalette(Common::Queue<int> &params) {
int palette = params.pop() - 1;
_vm->_game->schedulePalette(palette);
}
void Script::blackPalette(Common::Queue<int> &params) {
_vm->_game->schedulePalette(kBlackPalette);
}
void Script::setPalette(Common::Queue<int> &params) {
if (_vm->_game->getScheduledPalette() == -1) {
_vm->_screen->setPaletteEmpty();
} else {
BAFile *f;
f = _vm->_paletteArchive->getFile(_vm->_game->getScheduledPalette());
_vm->_screen->setPalette(f->_data, 0, kNumColours);
}
}
void Script::endCurrentProgram() {
_endProgram = true;
}

View File

@ -127,6 +127,9 @@ private:
void resetDialogue(Common::Queue<int> &params);
void resetDialogueFrom(Common::Queue<int> &params);
void resetBlock(Common::Queue<int> &params);
void setPalette(Common::Queue<int> &params);
void blackPalette(Common::Queue<int> &params);
void loadPalette(Common::Queue<int> &params);
int operAnd(int op1, int op2);
int operOr(int op1, int op2);