aboutsummaryrefslogtreecommitdiff
path: root/engines/prince
diff options
context:
space:
mode:
authorKamil Zbróg2013-11-02 15:28:56 +0000
committerKamil Zbróg2013-11-02 15:28:56 +0000
commite72742d0e3c040869e57c559cbc6ed8504dd5d09 (patch)
treecff3cea240be69f1931bc7c15d1fe0eb412701ba /engines/prince
parent9250a6f6f8804fec74704ea9e01bdb6d8af7d0ed (diff)
downloadscummvm-rg350-e72742d0e3c040869e57c559cbc6ed8504dd5d09.tar.gz
scummvm-rg350-e72742d0e3c040869e57c559cbc6ed8504dd5d09.tar.bz2
scummvm-rg350-e72742d0e3c040869e57c559cbc6ed8504dd5d09.zip
PRINCE: intro works much beter. Still some synchronization issues
Diffstat (limited to 'engines/prince')
-rw-r--r--engines/prince/prince.cpp10
-rw-r--r--engines/prince/prince.h2
-rw-r--r--engines/prince/script.cpp46
-rw-r--r--engines/prince/script.h4
4 files changed, 45 insertions, 17 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 5910ca5e35..1d8f71ddcb 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -85,7 +85,7 @@ Graphics::Surface *loadCursor(const char *curName)
PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL),
_locationNr(0), _debugger(NULL), _objectList(NULL), _mobList(NULL), _midiPlayer(NULL),
- _cameraX(0), _newCameraX(0) {
+ _cameraX(0), _newCameraX(0), _frameNr(0) {
// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
@@ -479,6 +479,7 @@ void PrinceEngine::drawScreen() {
//if (_objectList)
// _graph->drawTransparent(_objectList->getSurface());
+
hotspot();
showTexts();
@@ -490,10 +491,6 @@ void PrinceEngine::drawScreen() {
void PrinceEngine::mainLoop() {
- //loadLocation(1);
- //changeCursor(1);
- //CursorMan.showMouse(true);
-
while (!shouldQuit()) {
uint32 currentTime = _system->getMillis();
@@ -524,8 +521,8 @@ void PrinceEngine::mainLoop() {
if (shouldQuit())
return;
- _script->step();
drawScreen();
+ _script->step();
// Calculate the frame delay based off a desired frame time
int delay = 1000/15 - int32(_system->getMillis() - currentTime);
@@ -534,6 +531,7 @@ void PrinceEngine::mainLoop() {
_system->delayMillis(delay);
_cameraX = _newCameraX;
+ ++_frameNr;
}
}
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 43d94654c7..68a7793157 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -110,6 +110,8 @@ public:
static const uint8 MAXTEXTS = 32;
Text _textSlots[MAXTEXTS];
+ uint64 _frameNr;
+
private:
bool playNextFrame();
void keyHandler(Common::Event event);
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index b3fdf3536d..49a0a9751c 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -31,13 +31,16 @@
#include "common/stream.h"
#include "common/archive.h"
+#include "audio/decoders/wave.h"
+#include "audio/audiostream.h"
+
namespace Prince {
static const uint16 NUM_OPCODES = 144;
Script::Script(PrinceEngine *vm) :
_code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false),
- _waitFlag(0) {
+ _waitFlag(0), _voiceStream(NULL) {
}
Script::~Script() {
@@ -70,7 +73,7 @@ void Script::debugScript(const char *s, ...) {
str += Common::String::format("op %04d: ", _lastOpcode);
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
- debug("PrinceEngine::Script %s %s", str.c_str(), buf);
+ debug("PrinceEngine::Script frame %ld %s %s", _vm->_frameNr, str.c_str(), buf);
}
void Script::step() {
@@ -164,6 +167,12 @@ void Script::O_PLAYSAMPLE() {
uint16 sampleId = readScript16bits();
uint16 loopType = readScript16bits();
debugScript("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType);
+
+ if (_voiceStream) {
+
+ Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(_voiceStream, DisposeAfterUse::YES);
+ _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, audioStream, sampleId);
+ }
}
void Script::O_PUTOBJECT() {
@@ -621,22 +630,36 @@ void Script::O_PRINTAT() {
}
void Script::O_ZOOMIN() {}
+
void Script::O_ZOOMOUT() {}
+
void Script::O_SETSTRINGOFFSET() {}
+
void Script::O_GETOBJDATA() {}
+
void Script::O_SETOBJDATA() {}
+
void Script::O_SWAPOBJECTS() {}
+
void Script::O_CHANGEHEROSET() {}
+
void Script::O_ADDSTRING() {}
+
void Script::O_SUBSTRING() {}
+
void Script::O_INITDIALOG() {}
+
void Script::O_ENABLEDIALOGOPT() {}
+
void Script::O_DISABLEDIALOGOPT() {}
+
void Script::O_SHOWDIALOGBOX() {}
void Script::O_STOPSAMPLE() {
uint16 slot = readScript16bits();
debugScript("O_STOPSAMPLE slot %d", slot);
+
+ _vm->_mixer->stopID(slot);
}
void Script::O_BACKANIMRANGE() {
@@ -826,32 +849,33 @@ void Script::SetVoice(uint32 slot) {
const Common::String streamName = Common::String::format("%03d-01.WAV", _currentString);
debugScript("Loading wav %s slot %d", streamName.c_str(), slot);
- Common::SeekableReadStream *voiceStream = SearchMan.createReadStreamForMember(streamName);
- if (!voiceStream) {
+ _voiceStream = SearchMan.createReadStreamForMember(streamName);
+ if (!_voiceStream) {
error("Can't open %s", streamName.c_str());
}
- uint32 id = voiceStream->readUint32LE();
+ uint32 id = _voiceStream->readUint32LE();
if (id != 0x46464952) {
error("It's not RIFF file %s", streamName.c_str());
return;
}
- voiceStream->skip(0x20);
- id = voiceStream->readUint32LE();
+ _voiceStream->skip(0x20);
+ id = _voiceStream->readUint32LE();
if (id != 0x61746164) {
error("No data section in %s id %04x", streamName.c_str(), id);
return;
}
- id = voiceStream->readUint32LE();
+ id = _voiceStream->readUint32LE();
+ debugScript("SetVoice slot %d time %04x", slot, id);
id <<= 3;
id /= 22050;
id += 2;
- _vm->_textSlots[slot]._time = voiceStream->readUint32LE();
+ _vm->_textSlots[slot]._time = id;
- debugScript("SetVoice slot %d time %04x", slot, _vm->_textSlots[slot]._time);
- delete voiceStream;
+ debugScript("SetVoice slot %d time %04x", slot, id);
+ _voiceStream->seek(0);
}
void Script::O_SETVOICEH() {
diff --git a/engines/prince/script.h b/engines/prince/script.h
index de8db0bfb5..1343051fc9 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -25,6 +25,8 @@
#include "common/random.h"
+#include "audio/mixer.h"
+
namespace Common {
class SeekableReadStream;
}
@@ -60,9 +62,11 @@ private:
uint8 _stacktop;
uint8 _savedStacktop;
uint32 _waitFlag;
+ Audio::SoundHandle _soundHandle;
const byte * _string;
uint32 _currentString;
+ Common::SeekableReadStream *_voiceStream;
// Helper functions
void checkPC(uint32 address);