aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/prince.cpp46
-rw-r--r--engines/prince/prince.h6
-rw-r--r--engines/prince/script.cpp54
-rw-r--r--engines/prince/script.h3
4 files changed, 70 insertions, 39 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 5fd97fca76..35619fdc1e 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -593,6 +593,27 @@ bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::Strin
return true;
}
+void PrinceEngine::setVoice(uint16 slot, uint32 sampleSlot, uint16 flag) {
+ Common::String sampleName;
+ uint32 currentString = _interpreter->getCurrentString();
+
+ if (currentString >= 80000) {
+ sampleName = Common::String::format("%05d-%02d.WAV", currentString - 80000, flag);
+ } else if (currentString >= 70000) {
+ sampleName = Common::String::format("inv%02d-01.WAV", currentString - 70000);
+ } else if (currentString >= 60000) {
+ sampleName = Common::String::format("M%04d-%02d.WAV", currentString - 60000, flag);
+ } else if (currentString >= 2000) {
+ return;
+ } else if (flag >= 100) {
+ sampleName = Common::String::format("%03d-%03d.WAV", currentString, flag);
+ } else {
+ sampleName = Common::String::format("%03d-%02d.WAV", currentString, flag);
+ }
+
+ loadVoice(slot, sampleSlot, sampleName);
+}
+
bool PrinceEngine::loadAnim(uint16 animNr, bool loop) {
Common::String streamName = Common::String::format("AN%02d", animNr);
Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);
@@ -922,7 +943,7 @@ void PrinceEngine::showTexts(Graphics::Surface *screen) {
_font->wordWrapText(text._str, _graph->_frontScreen->w, lines);
int wideLine = 0;
- for (uint8 i = 0; i < lines.size(); i++) {
+ for (uint i = 0; i < lines.size(); i++) {
int textLen = getTextWidth(lines[i].c_str());
if (textLen > wideLine) {
wideLine = textLen;
@@ -1771,7 +1792,7 @@ void PrinceEngine::inventoryLeftMouseButton() {
return;
}
} else {
- // when this happens?
+ error("PrinceEngine::inventoryLeftMouseButton() - optionsFlag = 1, selectedMob = 0");
// test bx, RMBMask 7996 ? right mouse button here? - > return;
//disable_use
if (_currentPointerNumber == 2) {
@@ -1800,12 +1821,13 @@ void PrinceEngine::inventoryLeftMouseButton() {
//use_item_on_item
int invObjUU = _script->scanMobEventsWithItem(_invMobList[_selectedMob - 1]._mask, _script->_scriptInfo.invObjUU, _selectedItem);
if (invObjUU == -1) {
- int textNr = 11; // "I can't do it."
+ int textNr = 80011; // "I can't do it."
if (_selectedItem == 31 || _invMobList[_selectedMob - 1]._mask == 31) {
- textNr = 20; // "Nothing is happening."
+ textNr = 80020; // "Nothing is happening."
}
- printAt(0, 216, _variaTxt->getString(textNr), kNormalWidth / 2, 100);
- loadVoice(0, 28, Common::String::format("%05d-01.WAV", textNr));
+ _interpreter->setCurrentString(textNr);
+ printAt(0, 216, _variaTxt->getString(textNr - 80000), kNormalWidth / 2, 100);
+ setVoice(0, 28, 1);
playSample(28, 0);
//exit_normally
_selectedMob = 0;
@@ -1829,7 +1851,8 @@ void PrinceEngine::inventoryLeftMouseButton() {
if (invObjExamEvent == -1) {
// do_standard
printAt(0, 216, _invMobList[_selectedMob - 1]._examText.c_str(), kNormalWidth / 2, _invExamY);
- loadVoice(0, 28, Common::String::format("inv%02d-01.WAV", _invMobList[_selectedMob - 1]._mask));
+ _interpreter->setCurrentString(_invMobList[_selectedMob - 1]._mask + 70000);
+ setVoice(0, 28, 1);
playSample(28, 0);
// disableuseuse
changeCursor(0);
@@ -1873,12 +1896,13 @@ void PrinceEngine::inventoryLeftMouseButton() {
// use_item_on_item
int invObjUU = _script->scanMobEventsWithItem(_invMobList[_selectedMob - 1]._mask, _script->_scriptInfo.invObjUU, _selectedItem);
if (invObjUU == -1) {
- int textNr = 11; // "I can't do it."
+ int textNr = 80011; // "I can't do it."
if (_selectedItem == 31 || _invMobList[_selectedMob - 1]._mask == 31) {
- textNr = 20; // "Nothing is happening."
+ textNr = 80020; // "Nothing is happening."
}
- printAt(0, 216, _variaTxt->getString(textNr), kNormalWidth / 2, 100);
- loadVoice(0, 28, Common::String::format("%05d-01.WAV", textNr));
+ _interpreter->setCurrentString(textNr);
+ printAt(0, 216, _variaTxt->getString(textNr - 80000), kNormalWidth / 2, 100);
+ setVoice(0, 28, 1);
playSample(28, 0);
//exit_normally
} else {
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index de3809b92d..28ef4b662a 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -245,6 +245,8 @@ public:
void playSample(uint16 sampleId, uint16 loopType);
void stopSample(uint16 sampleId);
+ void setVoice(uint16 slot, uint32 sampleSlot, uint16 flag);
+
virtual GUI::Debugger *getDebugger();
void changeCursor(uint16 curId);
@@ -258,6 +260,7 @@ public:
Hero *_mainHero;
Hero *_secondHero;
+ uint16 _locationNr;
uint16 _sceneWidth;
int32 _picWindowX;
int32 _picWindowY;
@@ -267,6 +270,7 @@ public:
Common::Array<AnimListItem> _animList;
Common::Array<BackgroundAnim> _backAnimList;
Common::Array<Common::Array<DialogLine>> _dialogBoxList;
+ Common::Array<Mob> _mobList;
Common::RandomSource _randomSource;
@@ -391,7 +395,6 @@ private:
uint32 getTextWidth(const char *s);
void debugEngine(const char *s, ...);
- uint16 _locationNr;
uint8 _cursorNr;
Common::RandomSource *_rnd;
@@ -412,7 +415,6 @@ private:
Audio::SoundHandle _soundHandle[MAX_SAMPLES];
Common::Array<PScr *> _pscrList;
- Common::Array<Mob> _mobList;
Common::Array<Object *> _objList;
Common::Array<Mask> _maskList;
Common::Array<DrawNode> _drawNodeList;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 68508a89de..86d9b78cd5 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -454,7 +454,7 @@ void Interpreter::debugInterpreter(const char *s, ...) {
Common::String str = Common::String::format("@0x%08X: ", _lastInstruction);
str += Common::String::format("op %04d: ", _lastOpcode);
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
-
+ debug(10, "PrinceEngine::Script %s %s", str.c_str(), buf);
//debug("Prince::Script frame %08ld mode %s %s %s", _vm->_frameNr, _mode, str.c_str(), buf);
}
@@ -504,6 +504,14 @@ void Interpreter::storeNewPC(int opcodePC) {
_fgOpcodePC = opcodePC;
}
+uint32 Interpreter::getCurrentString() {
+ return _currentString;
+}
+
+void Interpreter::setCurrentString(uint32 value) {
+ _currentString = value;
+}
+
template <typename T>
T Interpreter::readScript() {
T data = _script->read<T>(_currentInstruction);
@@ -808,11 +816,9 @@ void Interpreter::O_SETSTRING() {
int32 offset = readScript<uint32>();
_currentString = offset;
- // FIXME: Make it better ;)
if (offset >= 80000) {
- debugInterpreter("GetVaria %s", _vm->_variaTxt->getString(offset - 80000));
_string = (const byte *)_vm->_variaTxt->getString(offset - 80000);
- _currentString = offset - 80000; // TODO - wrong sample
+ debugInterpreter("GetVaria %s", _string);
}
else if (offset < 2000) {
uint32 of = READ_LE_UINT32(_vm->_talkTxt+offset*4);
@@ -886,10 +892,11 @@ void Interpreter::O_XORFLAG() {
}
void Interpreter::O_GETMOBTEXT() {
- uint16 value = readScriptFlagValue();
+ uint16 mob = readScriptFlagValue();
+ _currentString = _vm->_locationNr * 100 + mob + 60001;
+ _string = (const byte *)_vm->_mobList[mob]._examText.c_str();
- debugInterpreter("O_GETMOBTEXT value %d", value);
- // Use Mob::ExamText as current string
+ debugInterpreter("O_GETMOBTEXT mob %d", mob);
}
void Interpreter::O_MOVEHERO() {
@@ -1517,42 +1524,39 @@ void Interpreter::O_SKIPTEXT() {
debugInterpreter("O_SKIPTEXT");
}
-void Interpreter::SetVoice(uint32 sampleSlot) {
- uint16 slot = readScriptFlagValue();
- _vm->loadVoice(
- slot,
- sampleSlot,
- Common::String::format(
- "%03d-%02d.WAV",
- _currentString,
- _flags->getFlagValue(Flags::VOICE_H_LINE)
- )
- );
-}
-
void Interpreter::O_SETVOICEH() {
+ uint16 slot = readScriptFlagValue();
static const uint32 VOICE_H_SLOT = 28;
- SetVoice(VOICE_H_SLOT);
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_H_SLOT, voiceLineH);
}
void Interpreter::O_SETVOICEA() {
+ uint16 slot = readScriptFlagValue();
static const uint32 VOICE_A_SLOT = 29;
- SetVoice(VOICE_A_SLOT);
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_A_SLOT, voiceLineH);
}
void Interpreter::O_SETVOICEB() {
+ uint16 slot = readScriptFlagValue();
static const uint32 VOICE_B_SLOT = 30;
- SetVoice(VOICE_B_SLOT);
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_B_SLOT, voiceLineH);
}
void Interpreter::O_SETVOICEC() {
+ uint16 slot = readScriptFlagValue();
static const uint32 VOICE_C_SLOT = 31;
- SetVoice(VOICE_C_SLOT);
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_C_SLOT, voiceLineH);
}
void Interpreter::O_SETVOICED() {
+ uint16 slot = readScriptFlagValue();
static const uint32 VOICE_D_SLOT = 32;
- SetVoice(VOICE_D_SLOT);
+ uint16 voiceLineH = _flags->getFlagValue(Flags::VOICE_H_LINE);
+ _vm->setVoice(slot, VOICE_D_SLOT, voiceLineH);
}
void Interpreter::O_VIEWFLCLOOP() {
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 19c64ba5b6..f3e3b3cded 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -179,6 +179,8 @@ public:
void step();
void storeNewPC(int opcodePC);
+ uint32 getCurrentString();
+ void setCurrentString(uint32 value);
private:
PrinceEngine *_vm;
@@ -216,7 +218,6 @@ private:
template <typename T> T readScript();
void debugInterpreter(const char *s, ...);
- void SetVoice(uint32 slot);
typedef void (Interpreter::*OpcodeFunc)();
static OpcodeFunc _opcodes[];