Implement flipping the QuickHero and SpeedText flags in GPL2.

All GPL2 callbacks are now fully implemented.  It remains to implement
proper walking.

svn-id: r45501
This commit is contained in:
Robert Špalek 2009-10-29 15:26:48 +00:00
parent 8178d548eb
commit 403668898f
6 changed files with 85 additions and 20 deletions

View file

@ -264,6 +264,9 @@ void DraciEngine::handleEvents() {
// Show walking map toggle
_showWalkingMap = !_showWalkingMap;
break;
case Common::KEYCODE_q:
_game->setWantQuickHero(!_game->getWantQuickHero());
break;
case Common::KEYCODE_i:
if (_game->getRoomNum() == _game->getMapRoom() ||
_game->getLoopSubstatus() != kSubstatusOrdinary) {
@ -394,8 +397,7 @@ Common::Error DraciEngine::loadGameState(int slot) {
// to our constraint in canLoadGameStateCurrently() and to having
// enterNewRoom() called right after we exit from here.
//
// TODO: Handle saving in the map room. Verify inventory and fix
// dialogs.
// TODO: Handle saving in the map room
return loadSavegameData(slot, this);
}

View file

@ -166,6 +166,9 @@ void Game::init() {
setExitLoop(false);
_scheduledPalette = 0;
_fadePhases = _fadePhase = 0;
setEnableQuickHero(true);
setWantQuickHero(false);
setEnableSpeedText(true);
setLoopStatus(kStatusGate);
setLoopSubstatus(kSubstatusOrdinary);
@ -439,15 +442,14 @@ void Game::loop() {
if (_loopSubstatus == kSubstatusTalk) {
// If the current speech text has expired or the user clicked a mouse button,
// advance to the next line of text
if (_vm->_mouse->lButtonPressed() ||
_vm->_mouse->rButtonPressed() ||
if (getEnableSpeedText() && (_vm->_mouse->lButtonPressed() || _vm->_mouse->rButtonPressed()) ||
(_vm->_system->getMillis() - _speechTick) >= _speechDuration) {
setExitLoop(true);
}
_vm->_mouse->lButtonSet(false);
_vm->_mouse->rButtonSet(false);
}
}
// This returns true if we got a signal to quit the game
if (shouldQuit())
@ -1573,6 +1575,19 @@ void Game::initializeFading(int phases) {
_fadeTick = _vm->_system->getMillis();
}
void Game::setEnableQuickHero(bool value) {
_enableQuickHero = value;
}
void Game::setWantQuickHero(bool value) {
_wantQuickHero = value;
// TODO: after proper walking is implemented, do super-fast animation when walking
}
void Game::setEnableSpeedText(bool value) {
_enableSpeedText = value;
}
/**
* 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

@ -79,12 +79,13 @@ enum {
kBlackPalette = -1
};
// Constants tuned such that with ScummVM's default talkspeed 60, the speed
// Constants tuned such that with ScummVM's default talkspeed kStandardSpeed, the speed
// computed by equation (kBaseSpeechDuration + kSpeechTimeUnit * #characters) /
// talkspeed is equal to the original game.
enum SpeechConstants {
kBaseSpeechDuration = 12000,
kSpeechTimeUnit = 2640
kSpeechTimeUnit = 2640,
kStandardSpeed = 60
};
// One fading phase is 50ms.
@ -366,6 +367,12 @@ public:
void schedulePalette(int paletteID);
int getScheduledPalette() const;
void initializeFading(int phases);
void setEnableQuickHero(bool value);
bool getEnableQuickHero() const { return _enableQuickHero; }
void setWantQuickHero(bool value);
bool getWantQuickHero() const { return _wantQuickHero; }
void setEnableSpeedText(bool value);
bool getEnableSpeedText() const { return _enableSpeedText; }
void DoSync(Common::Serializer &s);
@ -432,6 +439,10 @@ private:
int _fadePhases;
int _fadePhase;
uint _fadeTick;
bool _enableQuickHero;
bool _wantQuickHero;
bool _enableSpeedText;
};
} // End of namespace Draci

View file

@ -70,26 +70,27 @@ void Script::setupCommandList() {
{ 15, 1, "ExecInit", 1, { 3 }, &Script::execInit },
{ 15, 2, "ExecLook", 1, { 3 }, &Script::execLook },
{ 15, 3, "ExecUse", 1, { 3 }, &Script::execUse },
{ 16, 1, "RepaintInventory", 0, { 0 }, NULL }, // not used in the original game files
{ 16, 2, "ExitInventory", 0, { 0 }, NULL }, // not used in the original game files
{ 17, 1, "ExitMap", 0, { 0 }, NULL }, // not used in the original game files
{ 18, 1, "LoadMusic", 1, { 2 }, &Script::loadMusic },
{ 18, 2, "StartMusic", 0, { 0 }, &Script::startMusic },
{ 18, 3, "StopMusic", 0, { 0 }, &Script::stopMusic },
{ 18, 4, "FadeOutMusic", 1, { 1 }, NULL },
{ 18, 5, "FadeInMusic", 1, { 1 }, NULL },
{ 19, 1, "Mark", 0, { 0 }, &Script::mark },
{ 19, 2, "Release", 0, { 0 }, &Script::release },
{ 20, 1, "Play", 0, { 0 }, &Script::play },
{ 21, 1, "LoadMap", 1, { 2 }, &Script::loadMap },
{ 21, 2, "RoomMap", 0, { 0 }, &Script::roomMap },
{ 22, 1, "DisableQuickHero", 0, { 0 }, NULL },
{ 22, 2, "EnableQuickHero", 0, { 0 }, NULL },
{ 23, 1, "DisableSpeedText", 0, { 0 }, NULL },
{ 23, 2, "EnableSpeedText", 0, { 0 }, NULL },
{ 22, 1, "DisableQuickHero", 0, { 0 }, &Script::disableQuickHero },
{ 22, 2, "EnableQuickHero", 0, { 0 }, &Script::enableQuickHero },
{ 23, 1, "DisableSpeedText", 0, { 0 }, &Script::disableSpeedText },
{ 23, 2, "EnableSpeedText", 0, { 0 }, &Script::enableSpeedText },
{ 24, 1, "QuitGame", 0, { 0 }, &Script::quitGame },
{ 25, 1, "PushNewRoom", 0, { 0 }, &Script::pushNewRoom },
{ 25, 2, "PopNewRoom", 0, { 0 }, &Script::popNewRoom },
// The following commands are not used in the original game files.
{ 16, 1, "RepaintInventory", 0, { 0 }, NULL },
{ 16, 2, "ExitInventory", 0, { 0 }, NULL },
{ 17, 1, "ExitMap", 0, { 0 }, NULL },
{ 18, 4, "FadeOutMusic", 1, { 1 }, NULL },
{ 18, 5, "FadeInMusic", 1, { 1 }, NULL },
// The following commands are not even defined in the game
// sources, but their numbers are allocated for internal
// purposes of the old player.
@ -746,8 +747,19 @@ void Script::talk(Common::Queue<int> &params) {
}
// Record time
uint subtitleDuration = (kBaseSpeechDuration + speechFrame->getLength() * kSpeechTimeUnit)
/ _vm->_sound->talkSpeed();
int talkSpeed = _vm->_sound->talkSpeed();
if (!_vm->_game->getEnableSpeedText() && talkSpeed > kStandardSpeed) {
talkSpeed = kStandardSpeed;
}
if (talkSpeed <= 0) {
talkSpeed = 1;
}
uint subtitleDuration;
if (talkSpeed >= 255) {
subtitleDuration = 0;
} else {
subtitleDuration = (kBaseSpeechDuration + speechFrame->getLength() * kSpeechTimeUnit) / talkSpeed;
}
const uint duration = MAX(subtitleDuration, dubbingDuration);
_vm->_game->setSpeechTiming(_vm->_system->getMillis(), duration);
@ -829,6 +841,22 @@ void Script::roomMap(Common::Queue<int> &params) {
_vm->_game->loadWalkingMap();
}
void Script::disableQuickHero(Common::Queue<int> &params) {
_vm->_game->setEnableQuickHero(false);
}
void Script::enableQuickHero(Common::Queue<int> &params) {
_vm->_game->setEnableQuickHero(true);
}
void Script::disableSpeedText(Common::Queue<int> &params) {
_vm->_game->setEnableSpeedText(false);
}
void Script::enableSpeedText(Common::Queue<int> &params) {
_vm->_game->setEnableSpeedText(true);
}
void Script::loadPalette(Common::Queue<int> &params) {
int palette = params.pop() - 1;
@ -1166,6 +1194,10 @@ void Script::run(const GPL2Program &program, uint16 offset) {
} while (cmd->_number != 0 && !shouldEndProgram()); // 0 = gplend and exit
_jump = oldJump;
// Reset the flags which may have temporarily been altered inside the script.
_vm->_game->setEnableQuickHero(true);
_vm->_game->setEnableSpeedText(true);
}
} // End of namespace Draci

View file

@ -131,6 +131,10 @@ private:
void talk(Common::Queue<int> &params);
void loadMap(Common::Queue<int> &params);
void roomMap(Common::Queue<int> &params);
void disableQuickHero(Common::Queue<int> &params);
void enableQuickHero(Common::Queue<int> &params);
void disableSpeedText(Common::Queue<int> &params);
void enableSpeedText(Common::Queue<int> &params);
void dialogue(Common::Queue<int> &params);
void exitDialogue(Common::Queue<int> &params);
void resetDialogue(Common::Queue<int> &params);

View file

@ -31,6 +31,7 @@
#include "draci/sound.h"
#include "draci/draci.h"
#include "draci/game.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
@ -162,7 +163,7 @@ SoundSample *SoundArchive::getSample(int i, uint freq) {
}
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _muteSound(false), _muteVoice(false),
_showSubtitles(true), _talkSpeed(60) {
_showSubtitles(true), _talkSpeed(kStandardSpeed) {
for (int i = 0; i < SOUND_HANDLES; i++)
_handles[i].type = kFreeHandle;