Skip to content

Commit

Permalink
ACCESS: Implement speakText()
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Aug 24, 2014
1 parent 89a3c43 commit 6774dd4
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 9 deletions.
91 changes: 86 additions & 5 deletions engines/access/access.cpp
Expand Up @@ -264,6 +264,90 @@ void AccessEngine::loadEstablish(int sub) {
_countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i));
}

void AccessEngine::speakText(int idx) {
int curPage = 0;
int soundsLeft = 0;

Common::String msg;
for (int i = idx; _eseg[i] != 0; ++i)
msg += _eseg[i];

while(true) {
soundsLeft = _countTbl[curPage];
_events->zeroKeys();

Common::String line;
int width = 0;
bool lastLine = _fonts._font2.getLine(msg, _bubbleBox->_maxChars * 6, line, width);
// Set font colors
_fonts._font2._fontColors[0] = 0;
_fonts._font2._fontColors[1] = 28;
_fonts._font2._fontColors[2] = 29;
_fonts._font2._fontColors[3] = 30;

_fonts._font2.drawString(_screen, line, _fonts._printOrg);
_fonts._printOrg = Common::Point(_fonts._printStart.x, _fonts._printOrg.y + 9);

if ((_fonts._printOrg.y > _printEnd) && (!lastLine)) {
while (true) {
_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
_sound->_soundPriority[0] = 1;
_sound->playSound(1);
_scripts->CMDFREESOUND();

_events->pollEvents();

if (_events->_leftButton) {
_events->debounceLeft();
_sndSubFile += soundsLeft;
break;
} else if (_events->_keypresses.size() != 0) {
_sndSubFile += soundsLeft;
break;
} else {
++_sndSubFile;
--soundsLeft;
if (soundsLeft == 0)
break;
}
}
_buffer2.copyBuffer(_screen);
_fonts._printOrg.y = _fonts._printStart.y;
++curPage;
soundsLeft = _countTbl[curPage];
}

if (lastLine)
break;
}

if (soundsLeft == 0)
return;

while(true) {
_sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile);
_sound->_soundPriority[0] = 1;
_sound->playSound(1);
_scripts->CMDFREESOUND();

_events->pollEvents();

if (_events->_leftButton) {
_events->debounceLeft();
_sndSubFile += soundsLeft;
break;
} else if (_events->_keypresses.size() != 0) {
_sndSubFile += soundsLeft;
break;
} else {
++_sndSubFile;
--soundsLeft;
if (soundsLeft == 0)
break;
}
}
}

void AccessEngine::doEstablish(int esatabIndex, int sub) {
_establishMode = 1;

Expand All @@ -289,16 +373,13 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) {
loadEstablish(sub);
_et = sub;
warning("CHECKME: Use of di");
Common::String msg;
int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2);
for (int i = idx; _eseg[i] != 0; ++i)
msg += _eseg[i];

_printEnd = 155;
if (_txtPages == 0)
warning("TODO: printText(%s)", msg.c_str());
warning("TODO: printText()");
else
warning("TODO: speakText(%s)", msg.c_str());
speakText(idx);

_screen->forceFadeOut();
_screen->clearScreen();
Expand Down
2 changes: 2 additions & 0 deletions engines/access/access.h
Expand Up @@ -91,6 +91,8 @@ class AccessEngine : public Engine {

void dummyLoop();

void speakText(int idx);

void doEstablish(int esatabIndex, int sub);
protected:
const AccessGameDescription *_gameDescription;
Expand Down
2 changes: 1 addition & 1 deletion engines/access/scripts.cpp
Expand Up @@ -658,7 +658,7 @@ void Scripts::cmdLoadSound() {
_vm->_sound->_soundPriority[0] = 1;
}

void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); }
void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); }

void Scripts::cmdSetVideoSound() {
uint32 startPos = _data->pos();
Expand Down
3 changes: 2 additions & 1 deletion engines/access/scripts.h
Expand Up @@ -113,7 +113,6 @@ class Scripts: public Manager {
void cmdReturnChoice();
void cmdClearBlock();
void cmdLoadSound();
void CMDFREESOUND();
void cmdSetVideoSound();
void CMDPLAYVIDSND();
void CMDPUSHLOCATION();
Expand Down Expand Up @@ -144,6 +143,8 @@ class Scripts: public Manager {
int executeScript();

void findNull();

void CMDFREESOUND();
};

} // End of namespace Access
Expand Down
3 changes: 1 addition & 2 deletions engines/access/sound.h
Expand Up @@ -42,8 +42,6 @@ class SoundManager {
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;

byte *loadSound(int fileNum, int subfile);

void playSound(byte *data, uint32 size);
public:
SoundEntry _soundTable[MAX_SOUNDS];
Expand All @@ -61,6 +59,7 @@ class SoundManager {

void playSound(int soundIndex);

byte *loadSound(int fileNum, int subfile);
void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);

void midiPlay();
Expand Down

0 comments on commit 6774dd4

Please sign in to comment.