aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorChristopher Page2008-06-16 19:06:48 +0000
committerChristopher Page2008-06-16 19:06:48 +0000
commit37a7a572cff7c3648f23fab42d45e98c21942d20 (patch)
tree84ae8cd418276d6531ba9a0ad19c8e5286105c84 /engines
parent7009aae8930835221677e71f085841abf66c0151 (diff)
parentbc01acd18f6a0fae36497826d3a21baf3fec958d (diff)
downloadscummvm-rg350-37a7a572cff7c3648f23fab42d45e98c21942d20.tar.gz
scummvm-rg350-37a7a572cff7c3648f23fab42d45e98c21942d20.tar.bz2
scummvm-rg350-37a7a572cff7c3648f23fab42d45e98c21942d20.zip
Merged revisions 32668-32669,32676,32687-32689,32693,32695,32698-32701,32705 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk svn-id: r32720
Diffstat (limited to 'engines')
-rw-r--r--engines/cine/part.cpp6
-rw-r--r--engines/cine/unpack.cpp73
-rw-r--r--engines/cine/unpack.h64
-rw-r--r--engines/made/database.cpp9
-rw-r--r--engines/made/database.h6
-rw-r--r--engines/made/detection.cpp17
-rw-r--r--engines/made/made.cpp13
-rw-r--r--engines/made/made.h15
-rw-r--r--engines/made/screen.h1
-rw-r--r--engines/made/script.cpp7
-rw-r--r--engines/made/scriptfuncs.cpp22
11 files changed, 161 insertions, 72 deletions
diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp
index 535bf841d5..b39f1eff7d 100644
--- a/engines/cine/part.cpp
+++ b/engines/cine/part.cpp
@@ -128,7 +128,7 @@ void CineEngine::readVolCnf() {
f.read(buf, packedSize);
if (packedSize != unpackedSize) {
CineUnpacker cineUnpacker;
- if (!cineUnpacker.unpack(buf, buf, packedSize)) {
+ if (!cineUnpacker.unpack(buf, packedSize, buf, unpackedSize)) {
error("Error while unpacking 'vol.cnf' data");
}
}
@@ -226,7 +226,9 @@ byte *readBundleFile(int16 foundFileIdx) {
byte *unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize);
readFromPart(foundFileIdx, unpackBuffer);
CineUnpacker cineUnpacker;
- cineUnpacker.unpack(dataPtr, unpackBuffer, partBuffer[foundFileIdx].packedSize);
+ if (!cineUnpacker.unpack(unpackBuffer, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize)) {
+ warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName);
+ }
free(unpackBuffer);
} else {
readFromPart(foundFileIdx, dataPtr);
diff --git a/engines/cine/unpack.cpp b/engines/cine/unpack.cpp
index 364331e439..dcd3181242 100644
--- a/engines/cine/unpack.cpp
+++ b/engines/cine/unpack.cpp
@@ -31,13 +31,17 @@
namespace Cine {
uint32 CineUnpacker::readSource() {
+ if (_src < _srcBegin || _src + 4 > _srcEnd) {
+ _error = true;
+ return 0; // The source pointer is out of bounds, returning a default value
+ }
uint32 value = READ_BE_UINT32(_src);
_src -= 4;
return value;
}
-int CineUnpacker::rcr(int inputCarry) {
- int outputCarry = (_chunk32b & 1);
+uint CineUnpacker::rcr(bool inputCarry) {
+ uint outputCarry = (_chunk32b & 1);
_chunk32b >>= 1;
if (inputCarry) {
_chunk32b |= 0x80000000;
@@ -45,20 +49,20 @@ int CineUnpacker::rcr(int inputCarry) {
return outputCarry;
}
-int CineUnpacker::nextBit() {
- int carry = rcr(0);
+uint CineUnpacker::nextBit() {
+ uint carry = rcr(false);
// Normally if the chunk becomes zero then the carry is one as
// the end of chunk marker is always the last to be shifted out.
if (_chunk32b == 0) {
_chunk32b = readSource();
_crc ^= _chunk32b;
- carry = rcr(1); // Put the end of chunk marker in the most significant bit
+ carry = rcr(true); // Put the end of chunk marker in the most significant bit
}
return carry;
}
-uint16 CineUnpacker::getBits(byte numBits) {
- uint16 c = 0;
+uint CineUnpacker::getBits(uint numBits) {
+ uint c = 0;
while (numBits--) {
c <<= 1;
c |= nextBit();
@@ -66,30 +70,45 @@ uint16 CineUnpacker::getBits(byte numBits) {
return c;
}
-void CineUnpacker::unpackRawBytes(uint16 numBytes) {
- _datasize -= numBytes;
+void CineUnpacker::unpackRawBytes(uint numBytes) {
+ if (_dst >= _dstEnd || _dst - numBytes + 1 < _dstBegin) {
+ _error = true;
+ return; // Destination pointer is out of bounds for this operation
+ }
while (numBytes--) {
*_dst = (byte)getBits(8);
--_dst;
}
}
-void CineUnpacker::copyRelocatedBytes(uint16 offset, uint16 numBytes) {
- _datasize -= numBytes;
+void CineUnpacker::copyRelocatedBytes(uint offset, uint numBytes) {
+ if (_dst + offset >= _dstEnd || _dst - numBytes + 1 < _dstBegin) {
+ _error = true;
+ return; // Destination pointer is out of bounds for this operation
+ }
while (numBytes--) {
*_dst = *(_dst + offset);
--_dst;
}
}
-bool CineUnpacker::unpack(byte *dst, const byte *src, int srcLen) {
- _src = src + srcLen - 4;
- _datasize = readSource(); // Unpacked length in bytes
- _dst = dst + _datasize - 1;
+bool CineUnpacker::unpack(const byte *src, uint srcLen, byte *dst, uint dstLen) {
+ // Initialize variables used for detecting errors during unpacking
+ _error = false;
+ _srcBegin = src;
+ _srcEnd = src + srcLen;
+ _dstBegin = dst;
+ _dstEnd = dst + dstLen;
+
+ // Initialize other variables
+ _src = _srcBegin + srcLen - 4;
+ uint32 unpackedLength = readSource(); // Unpacked length in bytes
+ _dst = _dstBegin + unpackedLength - 1;
_crc = readSource();
_chunk32b = readSource();
_crc ^= _chunk32b;
- do {
+
+ while (_dst >= _dstBegin && !_error) {
/*
Bits => Action:
0 0 => unpackRawBytes(3 bits + 1) i.e. unpackRawBytes(1..9)
@@ -101,30 +120,30 @@ bool CineUnpacker::unpack(byte *dst, const byte *src, int srcLen) {
*/
if (!nextBit()) { // 0...
if (!nextBit()) { // 0 0
- uint16 numBytes = getBits(3) + 1;
+ uint numBytes = getBits(3) + 1;
unpackRawBytes(numBytes);
} else { // 0 1
- uint16 numBytes = 2;
- uint16 offset = getBits(8);
+ uint numBytes = 2;
+ uint offset = getBits(8);
copyRelocatedBytes(offset, numBytes);
}
} else { // 1...
- uint16 c = getBits(2);
+ uint c = getBits(2);
if (c == 3) { // 1 1 1
- uint16 numBytes = getBits(8) + 9;
+ uint numBytes = getBits(8) + 9;
unpackRawBytes(numBytes);
} else if (c < 2) { // 1 0 x
- uint16 numBytes = c + 3;
- uint16 offset = getBits(c + 9);
+ uint numBytes = c + 3;
+ uint offset = getBits(c + 9);
copyRelocatedBytes(offset, numBytes);
} else { // 1 1 0
- uint16 numBytes = getBits(8) + 1;
- uint16 offset = getBits(12);
+ uint numBytes = getBits(8) + 1;
+ uint offset = getBits(12);
copyRelocatedBytes(offset, numBytes);
}
}
- } while (_datasize > 0 && _src >= src - 4);
- return _crc == 0;
+ }
+ return !_error && (_crc == 0);
}
} // End of namespace Cine
diff --git a/engines/cine/unpack.h b/engines/cine/unpack.h
index f0a7ee3804..e16cb594a9 100644
--- a/engines/cine/unpack.h
+++ b/engines/cine/unpack.h
@@ -39,41 +39,77 @@ namespace Cine {
*/
class CineUnpacker {
public:
- /** Returns true if unpacking was successful, otherwise false. */
- bool unpack(byte *dst, const byte *src, int srcLen);
+ /**
+ * Unpacks packed data from the source buffer to the destination buffer.
+ * @warning Do NOT call this on data that is not packed.
+ * @note Source and destination buffer pointers can be the same as long as there's space for the unpacked data.
+ * @param src Pointer to the source buffer.
+ * @param srcLen Length of the source buffer.
+ * @param dst Pointer to the destination buffer.
+ * @param dstLen Length of the destination buffer.
+ * @return True if no errors were detected in the source data and unpacking was successful, otherwise false.
+ */
+ bool unpack(const byte *src, uint srcLen, byte *dst, uint dstLen);
private:
- /** Reads a single big endian 32-bit integer from the source and goes backwards 4 bytes. */
+ /**
+ * Reads an unsigned big endian 32-bit integer from the source stream and goes backwards 4 bytes.
+ * @return If the operation is valid, an unsigned big endian 32-bit integer read from the source stream.
+ * @return If the operation is invalid, zero.
+ * @note Sets internal error state if the read operation would be out of source bounds.
+ */
uint32 readSource();
/**
* Shifts the current internal 32-bit chunk to the right by one.
* Puts input carry into internal chunk's topmost (i.e. leftmost) bit.
- * Returns the least significant bit that was shifted out.
+ * @return The least significant bit that was shifted out from the chunk.
*/
- int rcr(int inputCarry);
- int nextBit();
- uint16 getBits(byte numBits);
+ uint rcr(bool inputCarry);
+
+ /**
+ * Get the next bit from the source stream.
+ * @note Changes the bit position in the source stream.
+ * @return The next bit from the source stream.
+ */
+ uint nextBit();
+
+ /**
+ * Get bits from the source stream.
+ * @note Changes the bit position in the source stream.
+ * @param numBits Number of bits to read from the source stream.
+ * @return Integer value consisting of the bits read from the source stream (In range [0, (2 ** numBits) - 1]).
+ * @return Later the bit was read from the source, the less significant it is in the return value.
+ */
+ uint getBits(uint numBits);
/**
* Copy raw bytes from the input stream and write them to the destination stream.
* This is used when no adequately long match is found in the sliding window.
+ * @note Sets internal error state if the operation would be out of bounds.
* @param numBytes Amount of bytes to copy from the input stream
*/
- void unpackRawBytes(uint16 numBytes);
+ void unpackRawBytes(uint numBytes);
/**
* Copy bytes from the sliding window in the destination buffer.
* This is used when a match of two bytes or longer is found.
+ * @note Sets internal error state if the operation would be out of bounds.
* @param offset Offset in the sliding window
* @param numBytes Amount of bytes to copy
*/
- void copyRelocatedBytes(uint16 offset, uint16 numBytes);
+ void copyRelocatedBytes(uint offset, uint numBytes);
private:
- int _datasize; //!< Bytes left to write into the unpacked data stream
- uint32 _crc; //!< Error-detecting code
- uint32 _chunk32b; //!< The current internal 32-bit chunk
- byte *_dst; //!< Destination buffer pointer
- const byte *_src; //!< Source buffer pointer
+ uint32 _crc; //!< Error-detecting code (This should be zero after successful unpacking)
+ uint32 _chunk32b; //!< The current internal 32-bit chunk of source data
+ byte *_dst; //!< Pointer to the current position in the destination buffer
+ const byte *_src; //!< Pointer to the current position in the source buffer
+
+ // These are used for detecting errors (e.g. out of bounds issues) during unpacking
+ bool _error; //!< Did an error occur during unpacking?
+ const byte *_srcBegin; //!< Source buffer's beginning
+ const byte *_srcEnd; //!< Source buffer's end
+ byte *_dstBegin; //!< Destination buffer's beginning
+ byte *_dstEnd; //!< Destination buffer's end
};
} // End of namespace Cine
diff --git a/engines/made/database.cpp b/engines/made/database.cpp
index 4616b63252..55e0e90732 100644
--- a/engines/made/database.cpp
+++ b/engines/made/database.cpp
@@ -301,7 +301,7 @@ int16 GameDatabase::getObjectProperty(int16 objectIndex, int16 propertyId) {
return 0;
int16 propertyFlag;
- int16 *property = getObjectPropertyPtr(objectIndex, propertyId, propertyFlag);
+ int16 *property = findObjectProperty(objectIndex, propertyId, propertyFlag);
if (property) {
return (int16)READ_LE_UINT16(property);
@@ -317,7 +317,7 @@ int16 GameDatabase::setObjectProperty(int16 objectIndex, int16 propertyId, int16
return 0;
int16 propertyFlag;
- int16 *property = getObjectPropertyPtr(objectIndex, propertyId, propertyFlag);
+ int16 *property = findObjectProperty(objectIndex, propertyId, propertyFlag);
if (property) {
if (propertyFlag == 1) {
@@ -430,7 +430,7 @@ int16 GameDatabaseV2::loadgame(const char *filename, int16 version) {
return result;
}
-int16 *GameDatabaseV2::getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
+int16 *GameDatabaseV2::findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
Object *obj = getObject(objectIndex);
int16 *prop = (int16*)obj->getData();
@@ -489,6 +489,7 @@ int16 *GameDatabaseV2::getObjectPropertyPtr(int16 objectIndex, int16 propertyId,
}
+ debug(1, "findObjectProperty(%04X, %04X) Property not found", objectIndex, propertyId);
return NULL;
}
@@ -597,7 +598,7 @@ int16 GameDatabaseV3::loadgame(const char *filename, int16 version) {
return result;
}
-int16 *GameDatabaseV3::getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
+int16 *GameDatabaseV3::findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
Object *obj = getObject(objectIndex);
int16 *prop = (int16*)obj->getData();
diff --git a/engines/made/database.h b/engines/made/database.h
index 476439c1e2..466d1a8f69 100644
--- a/engines/made/database.h
+++ b/engines/made/database.h
@@ -133,7 +133,7 @@ public:
const char *getObjectString(int16 index);
void setObjectString(int16 index, const char *str);
- virtual int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
+ virtual int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
virtual const char *getString(uint16 offset) = 0;
virtual bool getSavegameDescription(const char *filename, Common::String &description) = 0;
virtual int16 savegame(const char *filename, const char *description, int16 version) = 0;
@@ -157,7 +157,7 @@ class GameDatabaseV2 : public GameDatabase {
public:
GameDatabaseV2(MadeEngine *vm);
~GameDatabaseV2();
- int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
+ int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
const char *getString(uint16 offset);
bool getSavegameDescription(const char *filename, Common::String &description);
int16 savegame(const char *filename, const char *description, int16 version);
@@ -170,7 +170,7 @@ protected:
class GameDatabaseV3 : public GameDatabase {
public:
GameDatabaseV3(MadeEngine *vm);
- int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
+ int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
const char *getString(uint16 offset);
bool getSavegameDescription(const char *filename, Common::String &description);
int16 savegame(const char *filename, const char *description, int16 version);
diff --git a/engines/made/detection.cpp b/engines/made/detection.cpp
index 7d30873866..dc7dbdee87 100644
--- a/engines/made/detection.cpp
+++ b/engines/made/detection.cpp
@@ -65,6 +65,7 @@ static const PlainGameDescriptor madeGames[] = {
{"manhole", "The Manhole"},
{"rtz", "Return to Zork"},
{"lgop2", "Leather Goddesses of Phobos 2"},
+ {"rodney", "Rodney's Fun Screen"},
{0, 0}
};
@@ -276,6 +277,22 @@ static const MadeGameDescription gameDescriptions[] = {
0,
},
+ {
+ // Rodney's Fun Screen
+ {
+ "rodney",
+ "",
+ AD_ENTRY1("rodneys.dat", "a79887dbaa47689facd7c6f09258ba5a"),
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ Common::ADGF_NO_FLAGS
+ },
+ GID_RODNEY,
+ 0,
+ GF_FLOPPY,
+ 0,
+ },
+
{ AD_TABLE_END_MARKER, 0, 0, 0, 0 }
};
diff --git a/engines/made/made.cpp b/engines/made/made.cpp
index 09a9a85ec6..59ec487c37 100644
--- a/engines/made/made.cpp
+++ b/engines/made/made.cpp
@@ -35,6 +35,7 @@
#include "base/plugins.h"
#include "base/version.h"
+#include "sound/audiocd.h"
#include "sound/mixer.h"
#include "made/made.h"
@@ -87,7 +88,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
_res = new ProjectReader();
_screen = new Screen(this);
- if (getGameID() == GID_LGOP2 || getGameID() == GID_MANHOLE) {
+ if (getGameID() == GID_LGOP2 || getGameID() == GID_MANHOLE || getGameID() == GID_RODNEY) {
_dat = new GameDatabaseV2(this);
} else if (getGameID() == GID_RTZ) {
_dat = new GameDatabaseV3(this);
@@ -119,7 +120,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
// Set default sound frequency
// Return to Zork sets it itself via a script funtion
- if (getGameID() == GID_MANHOLE) {
+ if (getGameID() == GID_MANHOLE || getGameID() == GID_RODNEY) {
_soundRate = 11025;
} else {
_soundRate = 8000;
@@ -238,6 +239,8 @@ void MadeEngine::handleEvents() {
}
}
+
+ AudioCD.updateCD();
}
@@ -245,7 +248,7 @@ int MadeEngine::go() {
for (int i = 0; i < ARRAYSIZE(_timers); i++)
_timers[i] = -1;
-
+
if (getGameID() == GID_RTZ) {
_engineVersion = 3;
if (getFeatures() & GF_DEMO) {
@@ -271,6 +274,10 @@ int MadeEngine::go() {
_engineVersion = 2;
_dat->open("lgop2.dat");
_res->open("lgop2.prj");
+ } else if (getGameID() == GID_RODNEY) {
+ _engineVersion = 2;
+ _dat->open("rodneys.dat");
+ _res->open("rodneys.prj");
} else {
error ("Unknown MADE game");
}
diff --git a/engines/made/made.h b/engines/made/made.h
index f7e3354c4d..461941e5cf 100644
--- a/engines/made/made.h
+++ b/engines/made/made.h
@@ -48,16 +48,17 @@
namespace Made {
enum MadeGameID {
- GID_RTZ = 0,
- GID_MANHOLE = 1,
- GID_LGOP2 = 2
+ GID_RTZ = 0,
+ GID_MANHOLE = 1,
+ GID_LGOP2 = 2,
+ GID_RODNEY = 3
};
enum MadeGameFeatures {
- GF_DEMO = 1 << 0,
- GF_CD = 1 << 1,
- GF_CD_COMPRESSED = 1 << 2,
- GF_FLOPPY = 1 << 3
+ GF_DEMO = 1 << 0,
+ GF_CD = 1 << 1,
+ GF_CD_COMPRESSED = 1 << 2,
+ GF_FLOPPY = 1 << 3
};
const uint32 kTimerResolution = 40;
diff --git a/engines/made/screen.h b/engines/made/screen.h
index 92f3512954..5d55085e5c 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -95,6 +95,7 @@ public:
void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
bool isPaletteLocked() { return _paletteLock; }
void setPaletteLock(bool lock) { _paletteLock = lock; }
+ bool isScreenLocked() { return _screenLock; }
void setScreenLock(bool lock) { _screenLock = lock; }
void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
diff --git a/engines/made/script.cpp b/engines/made/script.cpp
index 4bda35dcc3..6f4ff7ace3 100644
--- a/engines/made/script.cpp
+++ b/engines/made/script.cpp
@@ -363,8 +363,7 @@ void ScriptInterpreter::cmd_set() {
void ScriptInterpreter::cmd_print() {
// TODO: This opcode was used for printing debug messages
- Object *obj = _vm->_dat->getObject(_stack.top());
- const char *text = obj->getString();
+ const char *text = _vm->_dat->getObjectString(_stack.top());
debug(4, "%s", text);
_stack.setTop(0);
}
@@ -672,7 +671,7 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
debug(1, "Dumping code for object %04X", objectIndex);
Object *obj = _vm->_dat->getObject(objectIndex);
- byte *code = obj->getData(), *codeEnd = code + obj->getSize();
+ byte *code = obj->getData(), *codeStart = code, *codeEnd = code + obj->getSize();
while (code < codeEnd) {
byte opcode = *code++;
@@ -684,6 +683,8 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
int16 value;
char tempStr[32];
opcodeStats[opcode - 1]++;
+ snprintf(tempStr, 32, "[%04X] ", (uint16)(code - codeStart - 1));
+ codeLine += tempStr;
codeLine += desc;
for (; *sig != '\0'; sig++) {
codeLine += " ";
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 8e06c2e8bf..932447a1eb 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -26,8 +26,8 @@
#include "common/endian.h"
#include "common/util.h"
#include "common/events.h"
-
#include "graphics/cursorman.h"
+#include "sound/audiocd.h"
#include "made/made.h"
#include "made/resource.h"
@@ -94,7 +94,7 @@ void ScriptFunctions::setupExternalsTable() {
External(sfSetSpriteGround);
External(sfLoadResText);
- if (_vm->getGameID() == GID_MANHOLE || _vm->getGameID() == GID_LGOP2) {
+ if (_vm->getGameID() == GID_MANHOLE || _vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_RODNEY) {
External(sfAddScreenMask);
External(sfSetSpriteMask);
} else if (_vm->getGameID() == GID_RTZ) {
@@ -183,6 +183,8 @@ int16 ScriptFunctions::sfDrawPicture(int16 argc, int16 *argv) {
}
int16 ScriptFunctions::sfClearScreen(int16 argc, int16 *argv) {
+ if (_vm->_screen->isScreenLocked())
+ return 0;
if (_vm->_autoStopSound) {
_vm->_mixer->stopHandle(_audioStreamHandle);
_vm->_autoStopSound = false;
@@ -548,25 +550,27 @@ int16 ScriptFunctions::sfPlayVoice(int16 argc, int16 *argv) {
}
int16 ScriptFunctions::sfPlayCd(int16 argc, int16 *argv) {
- // This one is called loads of times, so it has been commented out to reduce spam
- //warning("Unimplemented opcode: sfPlayCd");
+ AudioCD.play(argv[0], -1, 0, 0);
return 0;
}
int16 ScriptFunctions::sfStopCd(int16 argc, int16 *argv) {
- warning("Unimplemented opcode: sfStopCd");
- return 0;
+ if (AudioCD.isPlaying()) {
+ AudioCD.stop();
+ return 1;
+ } else {
+ return 0;
+ }
}
int16 ScriptFunctions::sfGetCdStatus(int16 argc, int16 *argv) {
- // This one is called loads of times, so it has been commented out to reduce spam
- //warning("Unimplemented opcode: sfGetCdStatus");
- return 0;
+ return AudioCD.isPlaying() ? 1 : 0;
}
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 0;
}