diff options
-rw-r--r-- | engines/made/made.cpp | 3 | ||||
-rw-r--r-- | engines/made/made.h | 1 | ||||
-rw-r--r-- | engines/made/scriptfuncs.cpp | 20 |
3 files changed, 18 insertions, 6 deletions
diff --git a/engines/made/made.cpp b/engines/made/made.cpp index 927b597c2a..892e8b1638 100644 --- a/engines/made/made.cpp +++ b/engines/made/made.cpp @@ -284,6 +284,9 @@ Common::Error MadeEngine::go() { } else { error ("Unknown MADE game"); } + + if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED)) + checkCD(); _autoStopSound = false; _eventNum = _eventKey = _eventMouseX = _eventMouseY = 0; diff --git a/engines/made/made.h b/engines/made/made.h index 0b66146e0b..16ccf66b71 100644 --- a/engines/made/made.h +++ b/engines/made/made.h @@ -121,6 +121,7 @@ public: SoundEnergyArray *_soundEnergyArray; uint32 _musicBeatStart; + uint32 _cdTimeStart; int32 _timers[50]; int16 getTicks(); diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp index a548aff15f..7a07550b6f 100644 --- a/engines/made/scriptfuncs.cpp +++ b/engines/made/scriptfuncs.cpp @@ -580,8 +580,13 @@ int16 ScriptFunctions::sfPlayVoice(int16 argc, int16 *argv) { } int16 ScriptFunctions::sfPlayCd(int16 argc, int16 *argv) { - AudioCD.play(argv[0], -1, 0, 0); - return 0; + AudioCD.play(argv[0] - 1, 1, 0, 0); + _vm->_cdTimeStart = _vm->_system->getMillis(); + if (AudioCD.isPlaying()) { + return 1; + } else { + return 0; + } } int16 ScriptFunctions::sfStopCd(int16 argc, int16 *argv) { @@ -598,10 +603,13 @@ int16 ScriptFunctions::sfGetCdStatus(int16 argc, int16 *argv) { } int16 ScriptFunctions::sfGetCdTime(int16 argc, int16 *argv) { - // This one is called loads of times, so it has been commented out to reduce spam - //warning("Unimplemented opcode: sfGetCdTime"); - // TODO - return 32000; + if (AudioCD.isPlaying()) { + uint32 deltaTime = _vm->_system->getMillis() - _vm->_cdTimeStart; + // This basically converts the time from milliseconds to MSF format to MADE's format + return (deltaTime / 1000 * 30) + (deltaTime % 1000 / 75 * 30 / 75); + } else { + return 32000; + } } int16 ScriptFunctions::sfPlayCdSegment(int16 argc, int16 *argv) { |