Skip to content

Commit

Permalink
MORTEVIELLE: Replace g_vm in SpeechManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jun 26, 2013
1 parent 266c8cb commit 2e40eba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions engines/mortevielle/mortevielle.cpp
Expand Up @@ -79,6 +79,7 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
_mouse.setParent(this);
_text.setParent(this);
_soundManager.setParent(this);
_speechManager.setParent(this);

_lastGameFrame = 0;
_mouseClick = false;
Expand Down
31 changes: 17 additions & 14 deletions engines/mortevielle/speech.cpp
Expand Up @@ -81,7 +81,7 @@ void SpeechManager::spfrac(int wor) {
}

void SpeechManager::charg_car(int &currWordNumb) {
int wor = swap(READ_LE_UINT16(&g_vm->_mem[kAdrWord + currWordNumb]));
int wor = swap(READ_LE_UINT16(&_vm->_mem[kAdrWord + currWordNumb]));
int int_ = wor & 0x3f; // 63

if ((int_ >= 0) && (int_ <= 13)) {
Expand Down Expand Up @@ -121,7 +121,7 @@ void SpeechManager::charg_car(int &currWordNumb) {


void SpeechManager::entroct(byte o) {
g_vm->_mem[kAdrTroct * 16 + _ptr_oct] = o;
_vm->_mem[kAdrTroct * 16 + _ptr_oct] = o;
++_ptr_oct;
}

Expand All @@ -134,7 +134,7 @@ void SpeechManager::cctable(tablint &t) {

tb[0] = 0;
for (int k = 0; k <= 255; ++k) {
tb[k + 1] = g_vm->_addFix + tb[k];
tb[k + 1] = _vm->_addFix + tb[k];
t[255 - k] = abs((int)tb[k] + 1);
}
}
Expand All @@ -143,7 +143,7 @@ void SpeechManager::regenbruit() {
int i = kOffsetB3 + 8590;
int j = 0;
do {
_cfiphBuffer[j] = READ_LE_UINT16(&g_vm->_mem[kAdrNoise3 + i]);
_cfiphBuffer[j] = READ_LE_UINT16(&_vm->_mem[kAdrNoise3 + i]);
i += 2;
++j;
} while (i < kOffsetB3 + 8790);
Expand All @@ -159,9 +159,9 @@ void SpeechManager::loadMusicSound() {
if (!f.open("sonmus.mor"))
error("Missing file - sonmus.mor");

f.read(&g_vm->_mem[0x7414 * 16 + 0], 273);
f.read(&_vm->_mem[0x7414 * 16 + 0], 273);

g_vm->_soundManager.decodeMusic(&g_vm->_mem[0x7414 * 16], &g_vm->_mem[kAdrNoise * 16], 273);
_vm->_soundManager.decodeMusic(&_vm->_mem[0x7414 * 16], &_vm->_mem[kAdrNoise * 16], 273);
f.close();
}

Expand Down Expand Up @@ -192,10 +192,10 @@ void SpeechManager::loadNoise() {
if (!f.open("bruits")) //Translation: "noise"
error("Missing file - bruits");

f.read(&g_vm->_mem[kAdrNoise * 16 + 0], 250);
f.read(&_vm->_mem[kAdrNoise * 16 + 0], 250);
for (i = 0; i <= 19013; ++i)
g_vm->_mem[kAdrNoise * 16 + 32000 + i] = g_vm->_mem[kAdrNoise5 + i];
f.read(&g_vm->_mem[kAdrNoise1 * 16 + kOffsetB1], 149);
_vm->_mem[kAdrNoise * 16 + 32000 + i] = _vm->_mem[kAdrNoise5 + i];
f.read(&_vm->_mem[kAdrNoise1 * 16 + kOffsetB1], 149);

f.close();
}
Expand Down Expand Up @@ -531,7 +531,7 @@ void SpeechManager::handlePhoneme() {
int endPos = swap(_cfiphBuffer[_phonemeNumb]) + deca[_typlec];
int wordCount = endPos - startPos;
for (int i = (uint)startPos >> 1, currWord = 0; i < (int)((uint)endPos >> 1); i++, currWord += 2)
WRITE_LE_UINT16(&g_vm->_mem[kAdrWord + currWord], _cfiphBuffer[i]);
WRITE_LE_UINT16(&_vm->_mem[kAdrWord + currWord], _cfiphBuffer[i]);

_ptr_oct = 0;
int currWord = 0;
Expand All @@ -556,7 +556,7 @@ void SpeechManager::startSpeech(int rep, int ht, int typ) {
int savph[501];
int tempo;

if (g_vm->_soundOff)
if (_vm->_soundOff)
return;

_phonemeNumb = rep;
Expand All @@ -570,7 +570,7 @@ void SpeechManager::startSpeech(int rep, int ht, int typ) {
tempo = kTempoF;
else
tempo = kTempoM;
g_vm->_addFix = (float)((tempo - 8)) / 256;
_vm->_addFix = (float)((tempo - 8)) / 256;
cctable(_tbi);
switch (typ) {
case 1:
Expand All @@ -586,13 +586,16 @@ void SpeechManager::startSpeech(int rep, int ht, int typ) {
break;
}
handlePhoneme();
g_vm->_soundManager.litph(_tbi, typ, tempo);
_vm->_soundManager.litph(_tbi, typ, tempo);
if (_typlec != 0)
for (int i = 0; i <= 500; ++i) {
_cfiphBuffer[i] = savph[i];
_mlec = _typlec;
}
g_vm->setPal(g_vm->_numpal);
_vm->setPal(_vm->_numpal);
}

void SpeechManager::setParent(MortevielleEngine *vm) {
_vm = vm;
}
} // End of namespace Mortevielle
3 changes: 3 additions & 0 deletions engines/mortevielle/speech.h
Expand Up @@ -66,6 +66,8 @@ struct SpeechQueue {

class SpeechManager {
private:
MortevielleEngine *_vm;

int _typlec;
int _phonemeNumb;

Expand All @@ -78,6 +80,7 @@ class SpeechManager {
int _mlec;

SpeechManager();
void setParent(MortevielleEngine *vm);
void spfrac(int wor);
void charg_car(int &currWordNumb);
void entroct(byte o);
Expand Down

0 comments on commit 2e40eba

Please sign in to comment.