Skip to content

Commit

Permalink
ACCESS: Implemented cmdFreeSound
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 29, 2014
1 parent d31a0f1 commit d2cb9d4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
4 changes: 2 additions & 2 deletions engines/access/access.cpp
Expand Up @@ -256,7 +256,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
_sound->_soundPriority[0] = 1;
_sound->playSound(1);
_scripts->CMDFREESOUND();
_scripts->cmdFreeSound();

_events->pollEvents();

Expand Down Expand Up @@ -291,7 +291,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array<Common::String> msgArr)
_sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile);
_sound->_soundPriority[0] = 1;
_sound->playSound(1);
_scripts->CMDFREESOUND();
_scripts->cmdFreeSound();

_events->pollEvents();

Expand Down
40 changes: 37 additions & 3 deletions engines/access/scripts.cpp
Expand Up @@ -67,6 +67,24 @@ void Scripts::searchForSequence() {
} while (sequenceId != _sequence);
}

void Scripts::charLoop() {
bool endFlag = _endFlag;
int pos = _data->pos();

_sequence = 2000;
searchForSequence();
_vm->_images.clear();
_vm->_buffer2.copyFrom(_vm->_buffer1);
_vm->_newRects.clear();

executeScript();
_vm->plotList1();
_vm->copyBlocks();

_data->seek(pos);
_endFlag = endFlag;
}

void Scripts::findNull() {
// No implementation required in ScummVM, the strings in the script files are already skipped by the use of readByte()
}
Expand Down Expand Up @@ -112,7 +130,7 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT,
&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice,
&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
&Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff,
&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
Expand Down Expand Up @@ -608,7 +626,7 @@ void Scripts::cmdTexChoice() {

int choice = -1;
do {
warning("TODO CHARLOOP");
charLoop();
_vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str();
if (_vm->_events->_leftButton) {
if (_vm->_events->_mouseRow >= 22) {
Expand Down Expand Up @@ -669,7 +687,23 @@ void Scripts::cmdLoadSound() {
_vm->_sound->_soundPriority[0] = 1;
}

void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); }
void Scripts::cmdFreeSound() {
SoundManager &sound = *_vm->_sound;

if (sound._soundTable.size() > 0 && sound._soundTable[0]) {
// Keep doing char display loop if playing sound for it
do {
if (_vm->_flags[236] == 1)
charLoop();

_vm->_events->pollEvents();
} while (!_vm->shouldQuit() && sound._playingSound);

// Free the sound
delete sound._soundTable[0];
sound._soundTable[0] = nullptr;
}
}

void Scripts::cmdSetVideoSound() {
uint32 startPos = _data->pos();
Expand Down
3 changes: 2 additions & 1 deletion engines/access/scripts.h
Expand Up @@ -37,6 +37,7 @@ class Scripts: public Manager {
Resource *_resource;
int _specialFunction;

void charLoop();
protected:
Common::SeekableReadStream *_data;

Expand Down Expand Up @@ -144,7 +145,7 @@ class Scripts: public Manager {

void findNull();

void CMDFREESOUND();
void cmdFreeSound();
};

} // End of namespace Access
Expand Down
1 change: 1 addition & 0 deletions engines/access/sound.cpp
Expand Up @@ -31,6 +31,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
_vm(vm), _mixer(mixer) {
_music = nullptr;
_musicRepeat = false;
_playingSound = false;
}

SoundManager::~SoundManager() {
Expand Down
1 change: 1 addition & 0 deletions engines/access/sound.h
Expand Up @@ -47,6 +47,7 @@ class SoundManager {
Common::Array<int> _soundPriority;
Resource *_music;
bool _musicRepeat;
bool _playingSound;
public:
SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
~SoundManager();
Expand Down

0 comments on commit d2cb9d4

Please sign in to comment.