aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2010-11-02 00:51:12 +0000
committerPaul Gilbert2010-11-02 00:51:12 +0000
commit97a0c281ebef3acc276132892c2dcdfcfb46719e (patch)
tree8314cfac664dcf2a717ab7b0039209912b4ab225 /engines
parent274fbd028df99c20f6c80fcf23144a389f888913 (diff)
downloadscummvm-rg350-97a0c281ebef3acc276132892c2dcdfcfb46719e.tar.gz
scummvm-rg350-97a0c281ebef3acc276132892c2dcdfcfb46719e.tar.bz2
scummvm-rg350-97a0c281ebef3acc276132892c2dcdfcfb46719e.zip
M4: Converted all printf's to debug
svn-id: r54035
Diffstat (limited to 'engines')
-rw-r--r--engines/m4/assets.cpp30
-rw-r--r--engines/m4/converse.cpp300
-rw-r--r--engines/m4/events.cpp2
-rw-r--r--engines/m4/font.cpp10
-rw-r--r--engines/m4/globals.cpp32
-rw-r--r--engines/m4/graphics.cpp10
-rw-r--r--engines/m4/hotspot.cpp2
-rw-r--r--engines/m4/m4.cpp7
-rw-r--r--engines/m4/m4.h4
-rw-r--r--engines/m4/m4_scene.cpp8
-rw-r--r--engines/m4/mads_anim.cpp8
-rw-r--r--engines/m4/mads_menus.cpp2
-rw-r--r--engines/m4/rails.cpp4
-rw-r--r--engines/m4/resource.cpp26
-rw-r--r--engines/m4/script.cpp190
-rw-r--r--engines/m4/script.h2
-rw-r--r--engines/m4/sound.cpp16
-rw-r--r--engines/m4/woodscript.cpp10
-rw-r--r--engines/m4/ws_machine.cpp54
-rw-r--r--engines/m4/ws_sequence.cpp96
20 files changed, 408 insertions, 405 deletions
diff --git a/engines/m4/assets.cpp b/engines/m4/assets.cpp
index 23122eb960..091187d844 100644
--- a/engines/m4/assets.cpp
+++ b/engines/m4/assets.cpp
@@ -147,9 +147,9 @@ void SpriteAsset::loadM4SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream
uint32 header = _stream->readUint32LE();
if (header == HEAD_M4SS) {
- printf("LE-encoded sprite\n");
+ debugC(kDebugGraphics, "LE-encoded sprite\n");
} else {
- printf("BE-encoded sprite\n");
+ debugC(kDebugGraphics, "BE-encoded sprite\n");
isBigEndian = true;
}
@@ -163,7 +163,7 @@ void SpriteAsset::loadM4SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream
_stream->skip(6 * 4);
_frameCount = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
- printf("SpriteAsset::SpriteAsset() srcSize = %d; frameRate = %04X; pixelSpeed = %04X; maxWidth = %d; maxHeight = %d; frameCount = %d\n", _srcSize, _frameRate, _pixelSpeed, _maxWidth, _maxHeight, _frameCount);
+ debugC(kDebugGraphics, "SpriteAsset::SpriteAsset() srcSize = %d; frameRate = %04X; pixelSpeed = %04X; maxWidth = %d; maxHeight = %d; frameCount = %d\n", _srcSize, _frameRate, _pixelSpeed, _maxWidth, _maxHeight, _frameCount);
for (int curFrame = 0; curFrame < _frameCount; curFrame++) {
frameOffset = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
@@ -345,7 +345,7 @@ int32 SpriteAsset::parseSprite(bool isBigEndian) {
if (chunkType == CELS___SS) {
chunkSize = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
} else {
- warning("SpriteAsset::parseSprite() Expected chunk type %08X, got %08X", CELS___SS, chunkType);
+ debugC(kDebugGraphics, "SpriteAsset::parseSprite() Expected chunk type %08X, got %08X", CELS___SS, chunkType);
}
return chunkSize;
@@ -362,14 +362,14 @@ void SpriteAsset::loadFrameHeader(SpriteAssetFrame &frameHeader, bool isBigEndia
frameHeader.comp = (!isBigEndian) ? _stream->readUint32LE() : _stream->readUint32BE();
frameHeader.frame = NULL;
_stream->seek(8 * 4, SEEK_CUR);
- //printf("SpriteAsset::loadFrameHeader() stream = %d; x = %d; y = %d; w = %d; h = %d; comp = %d\n", frameHeader.stream, frameHeader.x, frameHeader.y, frameHeader.w, frameHeader.h, frameHeader.comp);
+ //debugC(kDebugGraphics, "SpriteAsset::loadFrameHeader() stream = %d; x = %d; y = %d; w = %d; h = %d; comp = %d\n", frameHeader.stream, frameHeader.x, frameHeader.y, frameHeader.w, frameHeader.h, frameHeader.comp);
}
M4Sprite *SpriteAsset::getFrame(int frameIndex) {
if ((uint)frameIndex < _frames.size()) {
return _frames[frameIndex].frame;
} else {
- warning("SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size());
+ debugC(kDebugGraphics, "SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size());
return _frames[_frames.size() - 1].frame;
}
}
@@ -486,7 +486,7 @@ bool AssetManager::clearAssets(AssetType assetType, int32 minHash, int32 maxHash
bool AssetManager::loadAsset(const char *assetName, RGB8 *palette) {
- printf("AssetManager::loadAsset() %s\n", assetName);
+ debugC(kDebugGraphics, "AssetManager::loadAsset() %s\n", assetName);
// TODO, better use MemoryReadStreamEndian?
//convertAssetToLE(assetData, assetSize);
@@ -500,34 +500,34 @@ bool AssetManager::loadAsset(const char *assetName, RGB8 *palette) {
chunkSize = assetS->readUint32LE() - 12; // sub 12 for the chunk header
chunkHash = assetS->readUint32LE();
- printf("hash = %d\n", chunkHash);
+ debugC(kDebugGraphics, "hash = %d\n", chunkHash);
// Until loading code is complete, so that chunks not fully read are skipped correctly
uint32 nextOfs = assetS->pos() + chunkSize;
switch (chunkType) {
case CHUNK_MACH:
- printf("MACH\n");
+ debugC(kDebugGraphics, "MACH\n");
clearAssets(kAssetTypeMACH, chunkHash, chunkHash);
_MACH[chunkHash] = new MachineAsset(_vm, assetS, chunkSize, assetName);
break;
case CHUNK_SEQU:
- printf("SEQU\n");
+ debugC(kDebugGraphics, "SEQU\n");
clearAssets(kAssetTypeSEQU, chunkHash, chunkHash);
_SEQU[chunkHash] = new SequenceAsset(_vm, assetS, chunkSize, assetName);
break;
case CHUNK_DATA:
- printf("DATA\n");
+ debugC(kDebugGraphics, "DATA\n");
clearAssets(kAssetTypeDATA, chunkHash, chunkHash);
_DATA[chunkHash] = new DataAsset(_vm, assetS, chunkSize, assetName);
break;
case CHUNK_CELS:
- printf("CELS\n");
+ debugC(kDebugGraphics, "CELS\n");
clearAssets(kAssetTypeCELS, chunkHash, chunkHash);
_CELS[chunkHash] = new SpriteAsset(_vm, assetS, chunkSize, assetName);
break;
default:
- printf("AssetManager::loadAsset() Unknown chunk type %08X\n", chunkType);
+ debug(kDebugGraphics, "AssetManager::loadAsset() Unknown chunk type %08X\n", chunkType);
}
// Until loading code is complete (see above)
@@ -568,7 +568,7 @@ int32 AssetManager::addSpriteAsset(const char *assetName, int32 hash, RGB8 *pale
if (!alreadyLoaded) {
- printf("AssetManager::addSpriteAsset() asset %s not loaded, loading into %d\n", assetName, hash);
+ debugC(kDebugGraphics, "AssetManager::addSpriteAsset() asset %s not loaded, loading into %d\n", assetName, hash);
clearAssets(kAssetTypeCELS, hash, hash);
@@ -578,7 +578,7 @@ int32 AssetManager::addSpriteAsset(const char *assetName, int32 hash, RGB8 *pale
} else {
- printf("AssetManager::addSpriteAsset() asset %s already loaded in %d\n", assetName, hash);
+ debugC(kDebugGraphics, "AssetManager::addSpriteAsset() asset %s already loaded in %d\n", assetName, hash);
/* TODO/FIXME
if (_CELS[hash].palOffset >= 0 && palette)
diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp
index 6a11c328ff..e53b3cd603 100644
--- a/engines/m4/converse.cpp
+++ b/engines/m4/converse.cpp
@@ -118,7 +118,7 @@ void ConversationView::setNode(int32 nodeIndex) {
_activeItems.push_back(node->entries[i]);
if (node->entries[i]->autoSelect || strlen(node->entries[i]->text) == 0) {
- //printf("Auto selecting entry %i of node %i\n", i, nodeIndex);
+ //warning(kDebugConversations, "Auto selecting entry %i of node %i\n", i, nodeIndex);
selectEntry(i);
return;
}
@@ -134,11 +134,11 @@ void ConversationView::setNode(int32 nodeIndex) {
// Fallthrough
if (node->fallthroughMinEntries >= 0 && node->fallthroughOffset >= 0) {
- //printf("Current node falls through node at offset %i when entries are less or equal than %i\n",
+ //warning(kDebugConversations, "Current node falls through node at offset %i when entries are less or equal than %i\n",
// node->fallthroughOffset, node->fallthroughMinEntries);
if (_activeItems.size() <= (uint32)node->fallthroughMinEntries) {
const EntryInfo *entryInfo = _m4Vm->_converse->getEntryInfo(node->fallthroughOffset);
- //printf("Entries are less than or equal to %i, falling through to node at offset %i, index %i\n",
+ //warning(kDebugConversations, "Entries are less than or equal to %i, falling through to node at offset %i, index %i\n",
// node->fallthroughMinEntries, node->fallthroughOffset, entryInfo->nodeIndex);
setNode(entryInfo->nodeIndex);
return;
@@ -227,10 +227,10 @@ void ConversationView::selectEntry(int entryIndex) {
// Hide selected entry, unless it has a persistent flag set
if (!(_activeItems[entryIndex]->flags & kEntryPersists)) {
- //printf("Hiding selected entry\n");
+ //debug(kDebugConversations, "Hiding selected entry\n");
_m4Vm->_converse->getNode(_currentNodeIndex)->entries[entryIndex]->visible = false;
} else {
- //printf("Selected entry is persistent, not hiding it\n");
+ //debug(kDebugConversations, "Selected entry is persistent, not hiding it\n");
}
}
@@ -286,7 +286,7 @@ void ConversationView::playNextReply() {
}
} else {
int selectedWeight = _vm->_random->getRandomNumber(currentEntry->totalWeight - 1) + 1;
- //printf("Selected weight: %i\n", selectedWeight);
+ //debug(kDebugConversations, "Selected weight: %i\n", selectedWeight);
int previousWeight = 1;
int currentWeight = 0;
@@ -313,7 +313,7 @@ void ConversationView::playNextReply() {
// If we reached here, there are no more replies, so perform the active entry's actions
- //printf("Current selection does %i actions\n", _activeItems[entryIndex]->actions.size());
+ //debug(kDebugConversations, "Current selection does %i actions\n", _activeItems[entryIndex]->actions.size());
for (uint32 i = 0; i < _activeItems[_highlightedIndex]->actions.size(); i++) {
if (!_m4Vm->_converse->performAction(_activeItems[_highlightedIndex]->actions[i]))
break;
@@ -399,30 +399,30 @@ void Converse::loadConversation(const char *convName) {
return;
}
size = convS->readUint32LE(); // is this used at all?
- if (debugFlag) printf("Conv chunk size (external header): %i\n", size);
+ if (debugFlag) debug(kDebugConversations, "Conv chunk size (external header): %i\n", size);
// Conversation name, which is the conversation file's name
// without the extension
convS->read(buffer, 8);
- if (debugFlag) printf("Conversation name: %s\n", buffer);
+ if (debugFlag) debug(kDebugConversations, "Conversation name: %s\n", buffer);
while (true) {
chunkPos = convS->pos();
chunk = convS->readUint32LE(); // read chunk
if (convS->eos()) break;
- if (debugFlag) printf("***** Pos: %i -> ", chunkPos);
+ if (debugFlag) debug(kDebugConversations, "***** Pos: %i -> ", chunkPos);
switch (chunk) {
case CHUNK_DECL: // Declare
- if (debugFlag) printf("DECL chunk\n");
+ if (debugFlag) debug(kDebugConversations, "DECL chunk\n");
data = convS->readUint32LE();
- if (debugFlag) printf("Tag: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Tag: %i\n", data);
if (data > 0)
warning("Tag > 0 in DECL chunk, value is: %i", data); // TODO
val = convS->readUint32LE();
- if (debugFlag) printf("Value: %i\n", val);
+ if (debugFlag) debug(kDebugConversations, "Value: %i\n", val);
data = convS->readUint32LE();
- if (debugFlag) printf("Flags: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Flags: %i\n", data);
if (data > 0)
warning("Flags != 0 in DECL chunk, value is %i", data); // TODO
setValue(chunkPos, val);
@@ -437,23 +437,23 @@ void Converse::loadConversation(const char *convName) {
curEntry->fallthroughMinEntries = -1;
curEntry->fallthroughOffset = -1;
if (chunk == CHUNK_NODE) {
- if (debugFlag) printf("NODE chunk\n");
+ if (debugFlag) debug(kDebugConversations, "NODE chunk\n");
} else {
- if (debugFlag) printf("LNOD chunk\n");
+ if (debugFlag) debug(kDebugConversations, "LNOD chunk\n");
}
curNode = convS->readUint32LE();
- if (debugFlag) printf("Node number: %i\n", curNode);
+ if (debugFlag) debug(kDebugConversations, "Node number: %i\n", curNode);
data = convS->readUint32LE();
- if (debugFlag) printf("Tag: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Tag: %i\n", data);
if (chunk == CHUNK_LNOD) {
autoSelectIndex = convS->readUint32LE();
- if (debugFlag) printf("Autoselect entry number: %i\n", autoSelectIndex);
+ if (debugFlag) debug(kDebugConversations, "Autoselect entry number: %i\n", autoSelectIndex);
}
size = convS->readUint32LE();
- if (debugFlag) printf("Number of entries: %i\n", size);
+ if (debugFlag) debug(kDebugConversations, "Number of entries: %i\n", size);
for (i = 0; i < size; i++) {
data = convS->readUint32LE();
- if (debugFlag) printf("Entry %i: %i\n", i + 1, data);
+ if (debugFlag) debug(kDebugConversations, "Entry %i: %i\n", i + 1, data);
}
_convNodes.push_back(curEntry);
setEntryInfo(curEntry->offset, curEntry->entryType, curNode, -1);
@@ -465,14 +465,14 @@ void Converse::loadConversation(const char *convName) {
curEntry->entryType = kEntry;
strcpy(curEntry->voiceFile, "");
strcpy(curEntry->text, "");
- if (debugFlag) printf("ETRY chunk\n");
+ if (debugFlag) debug(kDebugConversations, "ETRY chunk\n");
data = convS->readUint32LE();
- if (debugFlag) printf("Unknown (attributes perhaps?): %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Unknown (attributes perhaps?): %i\n", data);
data = convS->readUint32LE();
- if (debugFlag) printf("Entry flags: ");
+ if (debugFlag) debug(kDebugConversations, "Entry flags: ");
if (debugFlag) if (data & kEntryInitial) printf ("Initial ");
if (debugFlag) if (data & kEntryPersists) printf ("Persists ");
- if (debugFlag) printf("\n");
+ if (debugFlag) debug(kDebugConversations, "\n");
curEntry->flags = data;
curEntry->visible = (curEntry->flags & kEntryInitial) ? true : false;
if (autoSelectIndex >= 0) {
@@ -517,28 +517,28 @@ void Converse::loadConversation(const char *convName) {
if (chunk == CHUNK_WPRL || chunk == CHUNK_WRPL) {
replyEntry->entryType = kWeightedReply;
replyEntry->totalWeight = 0;
- if (debugFlag) printf("WRPL chunk\n");
+ if (debugFlag) debug(kDebugConversations, "WRPL chunk\n");
size = convS->readUint32LE();
- if (debugFlag) printf("Weighted reply %i - %i entries:\n", i, size);
+ if (debugFlag) debug(kDebugConversations, "Weighted reply %i - %i entries:\n", i, size);
for (i = 0; i < size; i++) {
weightedEntry = new ConvEntry();
weightedEntry->offset = chunkPos;
strcpy(weightedEntry->voiceFile, "");
weightedEntry->entryType = kWeightedReply;
data = convS->readUint32LE();
- if (debugFlag) printf("- Weight: %i ", data);
+ if (debugFlag) debug(kDebugConversations, "- Weight: %i ", data);
weightedEntry->weight = data;
replyEntry->totalWeight += weightedEntry->weight;
data = convS->readUint32LE();
- if (debugFlag) printf("offset: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "offset: %i\n", data);
replyEntry->entries.push_back(weightedEntry);
}
currentWeightedEntry = 0;
} else {
replyEntry->entryType = kReply;
- if (debugFlag) printf("RPLY chunk\n");
+ if (debugFlag) debug(kDebugConversations, "RPLY chunk\n");
data = convS->readUint32LE();
- if (debugFlag) printf("Reply data offset: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Reply data offset: %i\n", data);
}
if (!curEntry)
@@ -563,9 +563,9 @@ void Converse::loadConversation(const char *convName) {
{
ConvEntry* parentEntry = NULL;
if (chunk == CHUNK_TEXT) {
- if (debugFlag) printf("TEXT chunk\n");
+ if (debugFlag) debug(kDebugConversations, "TEXT chunk\n");
} else {
- if (debugFlag) printf("MESG chunk\n");
+ if (debugFlag) debug(kDebugConversations, "MESG chunk\n");
}
if (replyEntry == NULL) {
@@ -580,22 +580,22 @@ void Converse::loadConversation(const char *convName) {
}
size = convS->readUint32LE();
- if (debugFlag) printf("Entry data size: %i\n", size);
+ if (debugFlag) debug(kDebugConversations, "Entry data size: %i\n", size);
convS->read(buffer, 8);
size -= 8; // subtract maximum length of voice file name
// If the file name is 8 characters, it will not be 0-terminated, so use strncpy
strncpy(parentEntry->voiceFile, buffer, 8);
parentEntry->voiceFile[8] = '\0';
- if (debugFlag) printf("Voice file: %s\n", parentEntry->voiceFile);
+ if (debugFlag) debug(kDebugConversations, "Voice file: %s\n", parentEntry->voiceFile);
if (chunk == CHUNK_TEXT) {
convS->read(buffer, size);
- if (debugFlag) printf("Text: %s\n", buffer);
+ if (debugFlag) debug(kDebugConversations, "Text: %s\n", buffer);
sprintf(parentEntry->text, "%s", buffer);
} else {
while (size > 0) {
data = convS->readUint32LE();
- if (debugFlag) printf("Unknown: %i\n", data); // TODO
+ if (debugFlag) debug(kDebugConversations, "Unknown: %i\n", data); // TODO
size -= 4;
}
}
@@ -612,7 +612,7 @@ void Converse::loadConversation(const char *convName) {
case CHUNK_CASN: // Conditional assign
case CHUNK_ASGN: // Assign
curAction = new EntryAction();
- if (debugFlag) printf("ASGN chunk\n");
+ if (debugFlag) debug(kDebugConversations, "ASGN chunk\n");
curAction->actionType = kAssignValue;
// Conditional part
@@ -655,32 +655,32 @@ void Converse::loadConversation(const char *convName) {
if (chunk == CHUNK_GOTO || chunk == CHUNK_CCGO) {
curAction->actionType = kGotoEntry;
- if (debugFlag) printf("GOTO chunk\n");
+ if (debugFlag) debug(kDebugConversations, "GOTO chunk\n");
} else if (chunk == CHUNK_HIDE || chunk == CHUNK_CHDE) {
curAction->actionType = kHideEntry;
- if (debugFlag) printf("HIDE chunk\n");
+ if (debugFlag) debug(kDebugConversations, "HIDE chunk\n");
} else if (chunk == CHUNK_UHID || chunk == CHUNK_CUHD) {
curAction->actionType = kUnhideEntry;
- if (debugFlag) printf("UHID chunk\n");
+ if (debugFlag) debug(kDebugConversations, "UHID chunk\n");
} else if (chunk == CHUNK_DSTR || chunk == CHUNK_CDST) {
curAction->actionType = kDestroyEntry;
- if (debugFlag) printf("DSTR chunk\n");
+ if (debugFlag) debug(kDebugConversations, "DSTR chunk\n");
} else if (chunk == CHUNK_EXIT || chunk == CHUNK_CEGO) {
curAction->actionType = kExitConv;
- if (debugFlag) printf("EXIT chunk\n");
+ if (debugFlag) debug(kDebugConversations, "EXIT chunk\n");
}
data = convS->readUint32LE();
- if (debugFlag) printf("Offset: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Offset: %i\n", data);
curAction->targetOffset = data;
curEntry->actions.push_back(curAction);
break;
case CHUNK_FALL: // Fallthrough
- if (debugFlag) printf("FALL chunk\n");
+ if (debugFlag) debug(kDebugConversations, "FALL chunk\n");
size = convS->readUint32LE();
- if (debugFlag) printf("Minimum nodes: %i\n", size);
+ if (debugFlag) debug(kDebugConversations, "Minimum nodes: %i\n", size);
_convNodes[curNode]->fallthroughMinEntries = size;
data = convS->readUint32LE();
- if (debugFlag) printf("Offset: %i\n", data);
+ if (debugFlag) debug(kDebugConversations, "Offset: %i\n", data);
_convNodes[curNode]->fallthroughOffset = data;
break;
// ----------------------------------------------------------------------------
@@ -718,35 +718,35 @@ void Converse::loadConversationMads(const char *convName) {
// ------------------------------------------------------------
// Chunk 0
convS = convDataD.getItemStream(0);
- printf("Chunk 0\n");
- printf("Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "Chunk 0\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
while (!convS->eos()) { // FIXME (eos changed)
- printf("%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
}
- printf("\n");
+ debug(kDebugConversations, "\n");
// ------------------------------------------------------------
// Chunk 1
convS = convDataD.getItemStream(1);
- printf("Chunk 1\n");
- printf("Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "Chunk 1\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
while (!convS->eos()) { // FIXME (eos changed)
- printf("%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
}
- printf("\n");
+ debug(kDebugConversations, "\n");
// ------------------------------------------------------------
// Chunk 2
convS = convDataD.getItemStream(2);
- printf("Chunk 2\n");
- printf("Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "Chunk 2\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
while (!convS->eos()) { // FIXME (eos changed)
- printf("%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
}
- printf("\n");
+ debug(kDebugConversations, "\n");
// ------------------------------------------------------------
// CNV file
@@ -769,46 +769,46 @@ void Converse::loadConversationMads(const char *convName) {
// TODO: finish this
// Chunk 0
convS = convData.getItemStream(0);
- printf("Chunk 0\n");
- printf("Conv stream size: %i\n", convS->size());
- printf("%i ", convS->readUint16LE());
- printf("%i ", convS->readUint16LE());
- printf("%i ", convS->readUint16LE());
- printf("%i ", convS->readUint16LE());
- printf("%i ", convS->readUint16LE());
- printf("%i ", convS->readUint16LE());
- printf("\n");
+ debug(kDebugConversations, "Chunk 0\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
+ debug(kDebugConversations, "\n");
count = convS->readUint16LE(); // conversation face count (usually 2)
- printf("Conversation faces: %i\n", count);
+ debug(kDebugConversations, "Conversation faces: %i\n", count);
for (i = 0; i < 5; i++) {
convS->read(buffer, 16);
- printf("Face %i: %s ", i + 1, buffer);
+ debug(kDebugConversations, "Face %i: %s ", i + 1, buffer);
}
- printf("\n");
+ debug(kDebugConversations, "\n");
// 5 face slots
// 1 = face slot has a face (with the filename specified above)
// 0 = face slot doesn't contain face data
for (i = 0; i < 5; i++) {
- printf("%i ", convS->readUint16LE());
+ debug(kDebugConversations, "%i ", convS->readUint16LE());
}
- printf("\n");
+ debug(kDebugConversations, "\n");
convS->read(buffer, 14); // speech file
- printf("Speech file: %s\n", buffer);
+ debug(kDebugConversations, "Speech file: %s\n", buffer);
while (!convS->eos()) { // FIXME: eos changed
- printf("%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
}
- printf("\n");
+ debug(kDebugConversations, "\n");
delete convS;
// ------------------------------------------------------------
// Chunk 1: Conversation nodes
convS = convData.getItemStream(1);
- printf("Chunk 1: conversation nodes\n");
- printf("Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "Chunk 1: conversation nodes\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
while (true) {
uint16 id = convS->readUint16LE();
@@ -828,12 +828,12 @@ void Converse::loadConversationMads(const char *convName) {
unk = convS->readUint16LE();
assert (unk == 65535);
_convNodes.push_back(curEntry);
- printf("Node %i, ID %i, entries %i\n", _convNodes.size(), curEntry->id, curEntry->entryCount);
+ debug(kDebugConversations, "Node %i, ID %i, entries %i\n", _convNodes.size(), curEntry->id, curEntry->entryCount);
// flags = 0: node has more than 1 entry
// flags = 65535: node has 1 entry
}
- printf("Conversation has %i nodes\n", _convNodes.size());
- printf("\n");
+ debug(kDebugConversations, "Conversation has %i nodes\n", _convNodes.size());
+ debug(kDebugConversations, "\n");
delete convS;
@@ -844,14 +844,14 @@ void Converse::loadConversationMads(const char *convName) {
// ------------------------------------------------------------
// Chunk 5 contains the conversation strings
convS = convData.getItemStream(5);
- //printf("Chunk 5: conversation strings\n");
- //printf("Conv stream size: %i\n", convS->size());
+ //debug(kDebugConversations, "Chunk 5: conversation strings\n");
+ //debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
*buffer = 0;
while (true) {
//if (curPos == 0)
- // printf("%i: Offset %i: ", _convStrings.size(), convS->pos());
+ // debug(kDebugConversations, "%i: Offset %i: ", _convStrings.size(), convS->pos());
uint8 b = convS->readByte();
if (convS->eos()) break;
@@ -862,7 +862,7 @@ void Converse::loadConversationMads(const char *convName) {
}
if (buffer[curPos - 1] == '\0') {
// end of string
- //printf("%s\n", buffer);
+ //debug(kDebugConversations, "%s\n", buffer);
buf = new char[strlen(buffer) + 1];
strcpy(buf, buffer);
_convStrings.push_back(buf);
@@ -876,8 +876,8 @@ void Converse::loadConversationMads(const char *convName) {
// ------------------------------------------------------------
// Chunk 2: entry data
convS = convData.getItemStream(2);
- //printf("Chunk 2 - entry data\n");
- //printf("Conv stream size: %i\n", convS->size());
+ //debug(kDebugConversations, "Chunk 2 - entry data\n");
+ //debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
for (i = 0; i < _convNodes.size(); i++) {
for (j = 0; j < _convNodes[i]->entryCount; j++) {
@@ -892,7 +892,7 @@ void Converse::loadConversationMads(const char *convName) {
curEntry->size = convS->readUint16LE();
_convNodes[i]->entries.push_back(curEntry);
- //printf("Node %i, entry %i, id %i, offset %i, size %i, text: %s\n",
+ //debug(kDebugConversations, "Node %i, entry %i, id %i, offset %i, size %i, text: %s\n",
// i, j, curEntry->id, curEntry->offset, curEntry->size, curEntry->text);
}
}
@@ -902,8 +902,8 @@ void Converse::loadConversationMads(const char *convName) {
// ------------------------------------------------------------
// Chunk 3: message (MESG) chunks, created from the strings of chunk 5
convS = convData.getItemStream(3);
- //printf("Chunk 3 - MESG chunk data\n");
- //printf("Conv stream size: %i\n", convS->size());
+ //debug(kDebugConversations, "Chunk 3 - MESG chunk data\n");
+ //debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
while (true) {
uint16 index = convS->readUint16LE();
@@ -913,15 +913,15 @@ void Converse::loadConversationMads(const char *convName) {
stringIndex = index;
stringCount = convS->readUint16LE();
*buffer = 0;
- //printf("Message: %i\n", _madsMessageList.size());
+ //debug(kDebugConversations, "Message: %i\n", _madsMessageList.size());
for (i = stringIndex; i < stringIndex + stringCount; i++) {
- //printf("%i: %s\n", i, _convStrings[i]);
+ //debug(kDebugConversations, "%i: %s\n", i, _convStrings[i]);
curMessage->messageStrings.push_back(_convStrings[i]);
}
_madsMessageList.push_back(curMessage);
- //printf("----------\n");
+ //debug(kDebugConversations, "----------\n");
}
- //printf("\n");
+ //debug(kDebugConversations, "\n");
delete convS;
@@ -929,31 +929,31 @@ void Converse::loadConversationMads(const char *convName) {
// TODO: finish this
// Chunk 6: conversation script
convS = convData.getItemStream(6);
- printf("Chunk 6\n");
- printf("Conv stream size: %i\n", convS->size());
+ debug(kDebugConversations, "Chunk 6\n");
+ debug(kDebugConversations, "Conv stream size: %i\n", convS->size());
/*while (!convS->eos()) { // FIXME (eos changed)
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("%i ", convS->readByte());
- printf("\n");
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "%i ", convS->readByte());
+ debug(kDebugConversations, "\n");
}
return;*/
for (i = 0; i < _convNodes.size(); i++) {
for (j = 0; j < _convNodes[i]->entryCount; j++) {
- printf("*** Node %i entry %i data size %i\n", i, j, _convNodes[i]->entries[j]->size);
- printf("Entry ID %i, text %s\n", _convNodes[i]->entries[j]->id, _convNodes[i]->entries[j]->text);
+ debug(kDebugConversations, "*** Node %i entry %i data size %i\n", i, j, _convNodes[i]->entries[j]->size);
+ debug(kDebugConversations, "Entry ID %i, text %s\n", _convNodes[i]->entries[j]->id, _convNodes[i]->entries[j]->text);
Common::SubReadStream *entryStream = new Common::SubReadStream(convS, _convNodes[i]->entries[j]->size);
readConvEntryActions(entryStream, _convNodes[i]->entries[j]);
delete entryStream;
- printf("--------------------\n");
+ debug(kDebugConversations, "--------------------\n");
}
}
@@ -978,50 +978,50 @@ void Converse::readConvEntryActions(Common::SubReadStream *convS, ConvEntry *cur
switch (chunk) {
case 1:
- printf("TODO: chunk type %i\n", chunk);
+ debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
break;
case 2:
- printf("HIDE\n");
+ debug(kDebugConversations, "HIDE\n");
convS->readByte();
count = convS->readByte();
- printf("%i entries: ", count);
+ debug(kDebugConversations, "%i entries: ", count);
for (int i = 0; i < count; i++)
- printf("%i %d", i, convS->readUint16LE());
- printf("\n");
+ debug(kDebugConversations, "%i %d", i, convS->readUint16LE());
+ debug(kDebugConversations, "\n");
break;
case 3:
- printf("UNHIDE\n");
+ debug(kDebugConversations, "UNHIDE\n");
convS->readByte();
count = convS->readByte();
- printf("%i entries: ", count);
+ debug(kDebugConversations, "%i entries: ", count);
for (int i = 0; i < count; i++)
- printf("%i %d", i, convS->readUint16LE());
- printf("\n");
+ debug(kDebugConversations, "%i %d", i, convS->readUint16LE());
+ debug(kDebugConversations, "\n");
break;
case 4: // MESSAGE
- printf("MESSAGE\n");
+ debug(kDebugConversations, "MESSAGE\n");
if (type == 255) {
- //printf("unconditional\n");
+ //debug(kDebugConversations, "unconditional\n");
} else if (type == 11) {
- //printf("conditional\n");
+ //debug(kDebugConversations, "conditional\n");
} else {
- printf("unknown type: %i\n", type);
+ debug(kDebugConversations, "unknown type: %i\n", type);
}
// Conditional part
if (type == 11) {
unk = convS->readUint16LE(); // 1
if (unk != 1)
- printf("Message: unk != 1 (it's %i)\n", unk);
+ debug(kDebugConversations, "Message: unk != 1 (it's %i)\n", unk);
var = convS->readUint16LE();
val = convS->readUint16LE();
- printf("Var %i == %i\n", var, val);
+ debug(kDebugConversations, "Var %i == %i\n", var, val);
}
unk = convS->readUint16LE(); // 256
if (unk != 256)
- printf("Message: unk != 256 (it's %i)\n", unk);
+ debug(kDebugConversations, "Message: unk != 256 (it's %i)\n", unk);
// it seems that the first text entry is set when the message
// chunk is supposed to be shown unconditionally, whereas the second text
@@ -1031,74 +1031,74 @@ void Converse::readConvEntryActions(Common::SubReadStream *convS, ConvEntry *cur
if (hasText1 == 1) {
messageIndex = convS->readUint16LE();
- printf("Message 1 index: %i, text:\n", messageIndex);
+ debug(kDebugConversations, "Message 1 index: %i, text:\n", messageIndex);
for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
- printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+ debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
}
}
if (hasText2 == 1) {
messageIndex = convS->readUint16LE();
if (hasText1 == 0) {
- printf("Message 2 index: %i, text:\n", messageIndex);
+ debug(kDebugConversations, "Message 2 index: %i, text:\n", messageIndex);
for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
- printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+ debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
}
}
}
break;
case 5: // AUTO
- printf("AUTO\n");
+ debug(kDebugConversations, "AUTO\n");
for (int k = 0; k < 4; k++)
convS->readByte();
messageIndex = convS->readUint16LE();
- printf("Message index: %i, text:\n", messageIndex);
+ debug(kDebugConversations, "Message index: %i, text:\n", messageIndex);
for (uint32 i = 0; i < _madsMessageList[messageIndex]->messageStrings.size(); i++) {
- printf("%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
+ debug(kDebugConversations, "%s\n", _madsMessageList[messageIndex]->messageStrings[i]);
}
convS->readUint16LE();
break;
case 6:
- printf("TODO: chunk type %i\n", chunk);
+ debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
break;
case 7: // GOTO
unk = convS->readUint32LE(); // 0
if (unk != 0 && unk != 1)
- printf("Goto: unk != 0 or 1 (it's %i)\n", unk);
+ debug(kDebugConversations, "Goto: unk != 0 or 1 (it's %i)\n", unk);
target = convS->readUint16LE();
convS->readUint16LE(); // 255
if (unk != 0)
- printf("Goto: unk != 0 (it's %i)\n", unk);
+ debug(kDebugConversations, "Goto: unk != 0 (it's %i)\n", unk);
if (target != 65535)
- printf("GOTO node %i\n", target);
+ debug(kDebugConversations, "GOTO node %i\n", target);
else
- printf("GOTO exit\n");
+ debug(kDebugConversations, "GOTO exit\n");
break;
case 8:
- printf("TODO: chunk type %i\n", chunk);
+ debug(kDebugConversations, "TODO: chunk type %i\n", chunk);
break;
case 9: // ASSIGN
- //printf("ASSIGN\n");
+ //debug(kDebugConversations, "ASSIGN\n");
unk = convS->readUint32LE(); // 0
if (unk != 0)
- printf("Assign: unk != 0 (it's %i)\n", unk);
+ debug(kDebugConversations, "Assign: unk != 0 (it's %i)\n", unk);
val = convS->readUint16LE();
var = convS->readUint16LE();
- //printf("Var %i = %i\n", var, val);
+ //debug(kDebugConversations, "Var %i = %i\n", var, val);
break;
default:
printf ("Unknown chunk type! (%i)\n", chunk);
break;
}
}
- printf("\n");
+ debug(kDebugConversations, "\n");
}
void Converse::setEntryInfo(int32 offset, EntryType type, int32 nodeIndex, int32 entryIndex) {
@@ -1109,7 +1109,7 @@ void Converse::setEntryInfo(int32 offset, EntryType type, int32 nodeIndex, int32
info.nodeIndex = nodeIndex;
info.entryIndex = entryIndex;
_offsetMap[hashOffset] = info;
- //printf("Set entry info: offset %i, type %i, node %i, entry %i\n", offset, type, nodeIndex, entryIndex);
+ //debug(kDebugConversations, "Set entry info: offset %i, type %i, node %i, entry %i\n", offset, type, nodeIndex, entryIndex);
}
const EntryInfo* Converse::getEntryInfo(int32 offset) {
@@ -1172,7 +1172,7 @@ bool Converse::performAction(EntryAction *action) {
}
if (action->actionType == kAssignValue) {
- //printf("Assigning variable at offset %i to value %i\n",
+ //debug(kDebugConversations, "Assigning variable at offset %i to value %i\n",
// action->targetOffset, action->value);
setValue(action->targetOffset, action->value);
return true; // nothing else to do in an assignment action
@@ -1190,24 +1190,24 @@ bool Converse::performAction(EntryAction *action) {
switch (action->actionType) {
case kGotoEntry:
- //printf("Goto entry at offset %i. Associated node is %i, entry %i\n",
+ //debug(kDebugConversations, "Goto entry at offset %i. Associated node is %i, entry %i\n",
// action->targetOffset, entryInfo->nodeIndex, entryInfo->entryIndex);
_vm->_conversationView->setNode(entryInfo->nodeIndex);
if (entryInfo->entryIndex >= 0)
_vm->_conversationView->selectEntry(entryInfo->entryIndex);
return false;
case kHideEntry:
- //printf("Hide entry at offset %i. Associated node is %i, entry %i\n",
+ //debug(kDebugConversations, "Hide entry at offset %i. Associated node is %i, entry %i\n",
// targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
targetEntry->visible = false;
return true;
case kUnhideEntry:
- //printf("Show entry at offset %i. Associated node is %i, entry %i\n",
+ //debug(kDebugConversations, "Show entry at offset %i. Associated node is %i, entry %i\n",
// targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
targetEntry->visible = true;
return true;
case kDestroyEntry:
- //printf("Destroy entry at offset %i. Associated node is %i, entry %i\n",
+ //debug(kDebugConversations, "Destroy entry at offset %i. Associated node is %i, entry %i\n",
// targetEntry->offset, entryInfo->nodeIndex, entryInfo->entryIndex);
if (entryInfo->entryIndex >= 0)
getNode(entryInfo->nodeIndex)->entries.remove_at(entryInfo->entryIndex);
@@ -1216,7 +1216,7 @@ bool Converse::performAction(EntryAction *action) {
targetEntry->visible = true;
return true;
case kExitConv:
- //printf("Exit conversation\n");
+ //debug(kDebugConversations, "Exit conversation\n");
endConversation();
return false;
default:
diff --git a/engines/m4/events.cpp b/engines/m4/events.cpp
index c66609844a..0d6ce907bf 100644
--- a/engines/m4/events.cpp
+++ b/engines/m4/events.cpp
@@ -235,7 +235,7 @@ bool Mouse::init(const char *seriesName, RGB8 *palette) {
cursorPalette = _cursorSprites->getPalette();
_vm->_palette->setPalette(cursorPalette, 0, colorCount);
- //printf("Cursor count: %d\n", _cursorSprites->getCount());
+ //debug(kDebugCore, "Cursor count: %d\n", _cursorSprites->getCount());
_vm->res()->toss(seriesName);
diff --git a/engines/m4/font.cpp b/engines/m4/font.cpp
index b5965732e5..1d4ec14525 100644
--- a/engines/m4/font.cpp
+++ b/engines/m4/font.cpp
@@ -82,7 +82,7 @@ void Font::setFontM4(const char *filename) {
Common::SeekableReadStream *fontFile = _vm->res()->openFile(filename);
if (fontFile->readUint32LE() != MKID_BE('FONT')) {
- printf("Font::Font: FONT tag expected\n");
+ debug(kDebugGraphics, "Font::Font: FONT tag expected\n");
return;
}
@@ -90,10 +90,10 @@ void Font::setFontM4(const char *filename) {
_maxWidth = fontFile->readByte();
uint32 fontSize = fontFile->readUint32LE();
- //printf("Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
+ //debug(kDebugGraphics, "Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
if (fontFile->readUint32LE() != MKID_BE('WIDT')) {
- printf("Font::Font: WIDT tag expected\n");
+ debug(kDebugGraphics, "Font::Font: WIDT tag expected\n");
return;
}
@@ -101,7 +101,7 @@ void Font::setFontM4(const char *filename) {
fontFile->read(_charWidths, 256);
if (fontFile->readUint32LE() != MKID_BE('OFFS')) {
- printf("Font::Font: OFFS tag expected\n");
+ debug(kDebugGraphics, "Font::Font: OFFS tag expected\n");
return;
}
@@ -111,7 +111,7 @@ void Font::setFontM4(const char *filename) {
_charOffs[i] = fontFile->readUint16LE();
if (fontFile->readUint32LE() != MKID_BE('PIXS')) {
- printf("Font::Font: PIXS tag expected\n");
+ debug(kDebugGraphics, "Font::Font: PIXS tag expected\n");
return;
}
diff --git a/engines/m4/globals.cpp b/engines/m4/globals.cpp
index a96229a0b3..40055d2af4 100644
--- a/engines/m4/globals.cpp
+++ b/engines/m4/globals.cpp
@@ -75,7 +75,7 @@ bool Kernel::sendTrigger(int32 triggerNum) {
bool Kernel::handleTrigger(int32 triggerNum) {
- printf("betweenRooms = %d; triggerNum = %08X\n", betweenRooms, (uint)triggerNum);
+ debug(kDebugScript, "betweenRooms = %d; triggerNum = %08X\n", betweenRooms, (uint)triggerNum);
if (betweenRooms)
return true;
@@ -89,10 +89,10 @@ bool Kernel::handleTrigger(int32 triggerNum) {
int room = (triggerNum >> 16) & 0xFFF;
- printf("room = %d; currentRoom = %d\n", room, currentRoom); fflush(stdout);
+ debug(kDebugScript, "room = %d; currentRoom = %d\n", room, currentRoom); fflush(stdout);
if (room != currentRoom) {
- printf("Kernel::handleTrigger() Trigger from another room\n");
+ debug(kDebugScript, "Kernel::handleTrigger() Trigger from another room\n");
return false;
}
@@ -123,7 +123,7 @@ bool Kernel::handleTrigger(int32 triggerNum) {
break;
case KT_DAEMON:
- printf("KT_DAEMON\n");
+ debug(kDebugScript, "KT_DAEMON\n");
fflush(stdout);
triggerMode = KT_DAEMON;
daemonTriggerAvailable = false;
@@ -140,7 +140,7 @@ bool Kernel::handleTrigger(int32 triggerNum) {
break;
default:
- printf("Kernel::handleTrigger() Unknown trigger mode %d\n", mode);
+ debug(kDebugScript, "Kernel::handleTrigger() Unknown trigger mode %d\n", mode);
}
@@ -181,7 +181,7 @@ void Kernel::globalDaemon() {
if (_globalDaemonFn)
_vm->_script->runFunction(_globalDaemonFn);
else {
- printf("Kernel::globalDaemon() _globalDaemonFn is NULL\n");
+ debug(kDebugScript, "Kernel::globalDaemon() _globalDaemonFn is NULL\n");
}
}
@@ -189,7 +189,7 @@ void Kernel::globalParser() {
if (_globalParserFn)
_vm->_script->runFunction(_globalParserFn);
else {
- printf("Kernel::globalParser() _globalParserFn is NULL\n");
+ debug(kDebugScript, "Kernel::globalParser() _globalParserFn is NULL\n");
}
}
@@ -197,7 +197,7 @@ void Kernel::sectionInit() {
if (_sectionInitFn)
_vm->_script->runFunction(_sectionInitFn);
else {
- printf("Kernel::sectionInit() _sectionInitFn is NULL\n");
+ debug(kDebugScript, "Kernel::sectionInit() _sectionInitFn is NULL\n");
}
}
@@ -205,7 +205,7 @@ void Kernel::sectionDaemon() {
if (_sectionDaemonFn)
_vm->_script->runFunction(_sectionDaemonFn);
else {
- printf("Kernel::sectionDaemon() _sectionDaemonFn is NULL\n");
+ debug(kDebugScript, "Kernel::sectionDaemon() _sectionDaemonFn is NULL\n");
}
}
@@ -213,7 +213,7 @@ void Kernel::sectionParser() {
if (_sectionParserFn)
_vm->_script->runFunction(_sectionParserFn);
else {
- printf("Kernel::sectionParser() _sectionParserFn is NULL\n");
+ debug(kDebugScript, "Kernel::sectionParser() _sectionParserFn is NULL\n");
}
}
@@ -221,7 +221,7 @@ void Kernel::roomInit() {
if (_roomInitFn)
_vm->_script->runFunction(_roomInitFn);
else {
- printf("Kernel::roomInit() _roomInitFn is NULL\n");
+ debug(kDebugScript, "Kernel::roomInit() _roomInitFn is NULL\n");
}
}
@@ -229,7 +229,7 @@ void Kernel::roomDaemon() {
if (_roomDaemonFn)
_vm->_script->runFunction(_roomDaemonFn);
else {
- printf("Kernel::roomDaemon() _roomDaemonFn is NULL\n");
+ debug(kDebugScript, "Kernel::roomDaemon() _roomDaemonFn is NULL\n");
}
}
@@ -237,7 +237,7 @@ void Kernel::roomPreParser() {
if (_roomPreParserFn)
_vm->_script->runFunction(_roomPreParserFn);
else {
- printf("Kernel::roomPreParser() _roomPreParserFn is NULL\n");
+ debug(kDebugScript, "Kernel::roomPreParser() _roomPreParserFn is NULL\n");
}
}
@@ -245,7 +245,7 @@ void Kernel::roomParser() {
if (_roomParserFn)
_vm->_script->runFunction(_roomParserFn);
else {
- printf("Kernel::roomParser() _roomParserFn is NULL\n");
+ debug(kDebugScript, "Kernel::roomParser() _roomParserFn is NULL\n");
}
}
@@ -351,7 +351,7 @@ void MadsGlobals::loadMadsMessagesInfo() {
Common::SeekableReadStream *messageS = _vm->res()->get("messages.dat");
int16 count = messageS->readUint16LE();
- //printf("%i messages\n", count);
+ //debug(kDebugScript, "%i messages\n", count);
for (int i = 0; i < count; i++) {
MessageItem curMessage;
@@ -365,7 +365,7 @@ void MadsGlobals::loadMadsMessagesInfo() {
if (i == count - 1)
curMessage.compSize = messageS->size() - curMessage.offset;
- //printf("id: %i, offset: %i, uncomp size: %i\n", curMessage->id, curMessage->offset, curMessage->uncompSize);
+ //debug(kDebugScript, "id: %i, offset: %i, uncomp size: %i\n", curMessage->id, curMessage->offset, curMessage->uncompSize);
_madsMessages.push_back(curMessage);
}
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index 423dda5e7e..f69a887d65 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -213,7 +213,7 @@ void M4Surface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &c
int scaledHeight = scaleValue(info.height, info.scaleY, errY);
/*
- printf("M4Surface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
+ debug(kDebugGraphics, "M4Surface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
info.width, info.scaleX, info.height, info.scaleY, scaledWidth, scaledHeight); fflush(stdout);
*/
@@ -233,7 +233,7 @@ void M4Surface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &c
scaledHeight = y + scaledHeight;
}
- //printf("M4Surface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
+ //debug(kDebugGraphics, "M4Surface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
// Check if sprite is inside the screen. If it's not, there's no need to draw it
if (scaledWidth + x <= 0 || scaledHeight + y <= 0) // check left and top (in case x,y are negative)
@@ -703,7 +703,7 @@ void M4Surface::madsLoadBackground(int roomNumber, RGBList **palData) {
else
compressedTileDataSize = tileDataUncomp->readUint32LE() - tileOfs;
- //printf("Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
+ //debug(kDebugGraphics, "Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
newTile->clear();
@@ -787,7 +787,7 @@ void M4Surface::m4LoadBackground(Common::SeekableReadStream *source) {
uint8 blackIndex = 0;
// Debug
- //printf("loadBackground(): %dx%d picture (%d bytes) - %dx%d tiles of size %dx%d\n",
+ //debug(kDebugGraphics, "loadBackground(): %dx%d picture (%d bytes) - %dx%d tiles of size %dx%d\n",
// widthVal, heightVal, size, tilesX, tilesY, tileWidth, tileHeight);
// BGR data, which is converted to RGB8
@@ -807,7 +807,7 @@ void M4Surface::m4LoadBackground(Common::SeekableReadStream *source) {
// note that the height of the scene in game scenes is smaller than 480, as the bottom part of the
// screen is the inventory
assert(width() == (int)widthVal);
- //printf("width(): %d, widthVal: %d, height(): %d, heightVal: %d\n", width(), widthVal, height(), heightVal);
+ //debug(kDebugGraphics, "width(): %d, widthVal: %d, height(): %d, heightVal: %d\n", width(), widthVal, height(), heightVal);
tileBuffer->create(tileWidth, tileHeight, 1);
diff --git a/engines/m4/hotspot.cpp b/engines/m4/hotspot.cpp
index 27180c5eb8..3132d6e4de 100644
--- a/engines/m4/hotspot.cpp
+++ b/engines/m4/hotspot.cpp
@@ -227,7 +227,7 @@ void HotSpotList::loadHotSpots(Common::SeekableReadStream* hotspotStream, int ho
// This looks to be some sort of bitmask. Perhaps it signifies
// the valid verbs for this hotspot
index = hotspotStream->readUint16LE(); // unknown
- //printf("%i ", index);
+ //debug(kDebugCore, "%i ", index);
}
if (_vm->isM4())
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 718daa571a..e5ffb7a633 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -121,6 +121,7 @@ MadsM4Engine::MadsM4Engine(OSystem *syst, const M4GameDescription *gameDesc) :
DebugMan.addDebugChannel(kDebugScript, "script", "Script debug level");
DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics debug level");
DebugMan.addDebugChannel(kDebugConversations, "conversations", "Conversations debugging");
+ DebugMan.addDebugChannel(kDebugSound, "sound", "Sounds debug level");
_resourceManager = NULL;
_globals = NULL;
@@ -289,7 +290,7 @@ void MadsM4Engine::dumpFile(const char* filename, bool uncompress) {
Common::MemoryReadStream *sourceUnc;
for (int i = 0; i < packData.getCount(); i++) {
sourceUnc = packData.getItemStream(i);
- printf("Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
+ debug(kDebugCore, "Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
while (!sourceUnc->eos()) {
bytesRead = sourceUnc->read(buffer, DUMP_BUFFER_SIZE);
f.write(buffer, bytesRead);
@@ -344,7 +345,7 @@ Common::Error M4Engine::run() {
for (int i = 1; i < 58; i++) {
_vm->_kernel->trigger = i;
_script->runFunction(func);
- printf("=================================\n");
+ debug(kDebugCore, "=================================\n");
fflush(stdout);
}
#endif
@@ -541,7 +542,7 @@ Common::Error MadsEngine::run() {
// Test code to dump all messages to the console
//for (int i = 0; i < _globals->getMessagesSize(); i++)
- //printf("%s\n----------\n", _globals->loadMessage(i));
+ //debug(kDebugCore, "%s\n----------\n", _globals->loadMessage(i));
if (getGameType() == GType_RexNebular) {
MadsGameLogic::initialiseGlobals();
diff --git a/engines/m4/m4.h b/engines/m4/m4.h
index 8dfae754ef..8069c960f1 100644
--- a/engines/m4/m4.h
+++ b/engines/m4/m4.h
@@ -116,7 +116,9 @@ enum {
enum {
kDebugScript = 1 << 0,
kDebugConversations = 1 << 1,
- kDebugGraphics = 1 << 2
+ kDebugGraphics = 1 << 2,
+ kDebugSound = 1 << 3,
+ kDebugCore = 1 << 4
};
#define MESSAGE_BASIC 1
diff --git a/engines/m4/m4_scene.cpp b/engines/m4/m4_scene.cpp
index 475fdba653..de6c5bddad 100644
--- a/engines/m4/m4_scene.cpp
+++ b/engines/m4/m4_scene.cpp
@@ -61,7 +61,7 @@ void M4Scene::loadSceneSprites(int sceneNumber) {
_sceneSprites = new SpriteAsset(_vm, sceneS, sceneS->size(), filename);
_vm->res()->toss(filename);
- printf("Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
+ debug(kDebugGraphics, "Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
}
void M4Scene::loadSceneResources(int sceneNumber) {
@@ -136,7 +136,7 @@ void M4Scene::loadSceneSpriteCodes(int sceneNumber) {
// RGB8* spritePalette = _sceneSpriteCodes->getPalette();
//_vm->_palette->setPalette(spritePalette, 0, colorCount);
- printf("Scene has %d sprite codes, each one having %d colors\n", _sceneSpriteCodes->getCount(), colorCount);
+ debug(kDebugGraphics, "Scene has %d sprite codes, each one having %d colors\n", _sceneSpriteCodes->getCount(), colorCount);
// Note that toss() deletes the MemoryReadStream
_vm->res()->toss(filename);
@@ -252,7 +252,7 @@ void M4Scene::leftClick(int x, int y) {
*/
// Player said.... (for scene scripts)
- printf("Player said: %s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
+ debug(kDebugGraphics, "Player said: %s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
// FIXME: This should be moved somewhere else, and is incomplete
if (_m4Vm->scene()->getInterface()->_inventory.getSelectedIndex() == -1) {
@@ -268,7 +268,7 @@ void M4Scene::leftClick(int x, int y) {
strcpy(_vm->_player->object, "");
_vm->_player->commandReady = true;
- printf("## Player said: %s %s\n", _vm->_player->verb, _vm->_player->noun);
+ debug(kDebugGraphics, "## Player said: %s %s\n", _vm->_player->verb, _vm->_player->noun);
}
}
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index ca53bdca75..1d15cbbaf7 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -721,21 +721,21 @@ void AnimviewView::processCommand() {
case 'O':
param = param + 2;
- //printf("O:%i ", atoi(param));
+ //warning(kDebugGraphics, "O:%i ", atoi(param));
_transition = atoi(param);
break;
case 'R':
param = param + 2;
- //printf("R:%s ", param);
+ //warning(kDebugGraphics, "R:%s ", param);
break;
case 'W':
- //printf("W ");
+ //warning(kDebugGraphics, "W ");
break;
case 'X':
- //printf("X ");
+ //warning(kDebugGraphics, "X ");
break;
default:
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index 7e2e6f500b..e2aa19171f 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -546,7 +546,7 @@ int DragonMainMenuView::getHighlightedItem(int x, int y) {
M4Sprite *spr = _menuItem->getFrame(0);
if ((x >= pt.x - 25) && (y >= pt.y - spr->height()) && (x < (pt.x - 25 + spr->width())) && (y < (pt.y))) {
- printf("x = %d, y = %d, index = %d\n", x, y, index);
+ debug(kDebugGraphics, "x = %d, y = %d, index = %d\n", x, y, index);
return index;
}
}
diff --git a/engines/m4/rails.cpp b/engines/m4/rails.cpp
index 11b9bcdbb9..3bff7cb234 100644
--- a/engines/m4/rails.cpp
+++ b/engines/m4/rails.cpp
@@ -233,7 +233,7 @@ void Rails::createEdge(int32 node1, int32 node2) {
valid = isLineWalkable(_nodes[node1]->x, _nodes[node1]->y,
_nodes[node2]->x, _nodes[node2]->y);
- printf("test code says: %d\n", valid);
+ debug(kDebugCore, "test code says: %d\n", valid);
// Check if the line passes through a forbidden rectangle
if (valid) {
@@ -255,7 +255,7 @@ void Rails::createEdge(int32 node1, int32 node2) {
_edges.insert_at(index, (int16*)(distance >> 16));
}
- printf("node1 = %d, node2 = %d, valid = %d\n", node1, node2, valid);
+ debug(kDebugCore, "node1 = %d, node2 = %d, valid = %d\n", node1, node2, valid);
}
diff --git a/engines/m4/resource.cpp b/engines/m4/resource.cpp
index eee1214e7f..cc8fc3b055 100644
--- a/engines/m4/resource.cpp
+++ b/engines/m4/resource.cpp
@@ -43,12 +43,12 @@ FileSystem::FileSystem(const char *hashFilename) {
hashFile.open(hashFilename);
if (!hashFile.isOpen()) {
- printf("FileSystem::FileSystem: error opening hash %s\n", hashFilename);
+ debug(kDebugCore, "FileSystem::FileSystem: error opening hash %s\n", hashFilename);
}
hashSize = hashFile.readUint32LE();
- //printf("FileSystem::FileSystem: hashSize = %d\n", hashSize);
+ //debug(kDebugCore, "FileSystem::FileSystem: hashSize = %d\n", hashSize);
/* load file records and add them to the hash list */
for (uint i = 0; i < hashSize; i++) {
@@ -63,12 +63,12 @@ FileSystem::FileSystem(const char *hashFilename) {
if (entry.filename[0]) {
/*
- printf(" filename: %s\n", entry.filename);
- printf(" hagfile: %d\n", entry.hagfile);
- printf(" disks: %d\n", entry.disks);
- printf(" offset: %08X\n", entry.offset);
- printf(" size: %d\n", entry.size);
- printf(" next: %08X\n", entry.next);
+ debug(kDebugCore, " filename: %s\n", entry.filename);
+ debug(kDebugCore, " hagfile: %d\n", entry.hagfile);
+ debug(kDebugCore, " disks: %d\n", entry.disks);
+ debug(kDebugCore, " offset: %08X\n", entry.offset);
+ debug(kDebugCore, " size: %d\n", entry.size);
+ debug(kDebugCore, " next: %08X\n", entry.next);
*/
_fileEntries[entry.filename] = entry;
}
@@ -90,7 +90,7 @@ FileSystem::FileSystem(const char *hashFilename) {
_hagEntries[entry.fileIndex].hagFile->open(_hagEntries[entry.fileIndex].filename);
if (!_hagEntries[entry.fileIndex].hagFile->isOpen()) {
- printf("FileSystem::FileSystem: error opening hag %s\n", _hagEntries[entry.fileIndex].filename);
+ debug(kDebugCore, "FileSystem::FileSystem: error opening hag %s\n", _hagEntries[entry.fileIndex].filename);
}
}
@@ -113,7 +113,7 @@ Common::SeekableReadStream *FileSystem::loadFile(const char *resourceName, bool
Common::SeekableReadStream *result = NULL;
if (hfe) {
- //printf("FileSystem::loadFile() success opening %s\n", filename);
+ //debug(kDebugCore, "FileSystem::loadFile() success opening %s\n", filename);
HashHagEntry *hagEntry = &_hagEntries[hfe->hagfile];
if (preloadFlag) {
@@ -128,7 +128,7 @@ Common::SeekableReadStream *FileSystem::loadFile(const char *resourceName, bool
hfe->offset + hfe->size);
} else {
- printf("FileSystem::loadFile() error opening %s\n", resourceName);
+ debug(kDebugCore, "FileSystem::loadFile() error opening %s\n", resourceName);
}
return result;
@@ -207,7 +207,7 @@ void ResourceManager::toss(const char *resourceName) {
if (!strcmp(r->name, resourceName)) {
r->flags |= kResourcePurge;
- //printf("M4ResourceManager::toss: mark resource %s to be purged\n", resourceName);
+ //debug(kDebugCore, "M4ResourceManager::toss: mark resource %s to be purged\n", resourceName);
}
}
}
@@ -510,7 +510,7 @@ M4ResourceManager::~M4ResourceManager() {
}
Common::SeekableReadStream *M4ResourceManager::loadResource(const char *resourceName, bool preloadFlag) {
- //printf("M4ResourceManager::loadResource() loading resource %s\n", resourceName);
+ //debug(kDebugCore, "M4ResourceManager::loadResource() loading resource %s\n", resourceName);
Common::SeekableReadStream* result = NULL;
if (_hfs) {
// actually load the resource
diff --git a/engines/m4/script.cpp b/engines/m4/script.cpp
index 412707d95e..776411df62 100644
--- a/engines/m4/script.cpp
+++ b/engines/m4/script.cpp
@@ -121,7 +121,7 @@ SeriesStreamBreakList::~SeriesStreamBreakList() {
void SeriesStreamBreakList::load(Common::File *fd) {
uint32 count = fd->readUint32LE();
- printf("SeriesStreamBreakList::load() count = %d\n", count);
+ debug(kDebugScript, "SeriesStreamBreakList::load() count = %d\n", count);
for (uint32 i = 0; i < count; i++) {
SeriesStreamBreakItem *item = new SeriesStreamBreakItem();
item->frameNum = fd->readUint32LE();
@@ -135,7 +135,7 @@ void SeriesStreamBreakList::load(Common::File *fd) {
item->value = fd->readUint32LE();
_items.push_back(item);
- printf("%02d: frameNum = %d; digiName = %s; digiChannel = %d; digiVolume = %d; trigger = %d; flags = %d; variable = %d; value = %d\n",
+ debug(kDebugScript, "%02d: frameNum = %d; digiName = %s; digiChannel = %d; digiVolume = %d; trigger = %d; flags = %d; variable = %d; value = %d\n",
i, item->frameNum, item->digiName, item->digiChannel, item->digiVolume, item->trigger, item->flags, item->variable.value, item->value);
}
@@ -146,7 +146,7 @@ SaidArray::~SaidArray() {
void SaidArray::load(Common::File *fd) {
uint32 count = fd->readUint32LE();
- printf("SaidArray::load() count = %d\n", count);
+ debug(kDebugScript, "SaidArray::load() count = %d\n", count);
for (uint32 i = 0; i < count; i++) {
SaidArrayItem *item = new SaidArrayItem();
item->itemName = _inter->loadGlobalString(fd);
@@ -155,7 +155,7 @@ void SaidArray::load(Common::File *fd) {
item->digiNameGear = _inter->loadGlobalString(fd);
_items.push_back(item);
- printf("itemName = %s; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
+ debug(kDebugScript, "itemName = %s; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
item->itemName, item->digiNameLook, item->digiNameTake, item->digiNameGear);
}
@@ -166,7 +166,7 @@ ParserArray::~ParserArray() {
void ParserArray::load(Common::File *fd) {
uint32 count = fd->readUint32LE();
- printf("ParserArray::load() count = %d\n", count);
+ debug(kDebugScript, "ParserArray::load() count = %d\n", count);
for (uint32 i = 0; i < count; i++) {
ParserArrayItem *item = new ParserArrayItem();
item->w0 = _inter->loadGlobalString(fd);
@@ -180,7 +180,7 @@ void ParserArray::load(Common::File *fd) {
item->value = fd->readUint32LE();
_items.push_back(item);
- printf("w0 = %s; w1 = %s; trigger = %d; testVariable = %d; testValue = %d; variable = %d; value = %d\n",
+ debug(kDebugScript, "w0 = %s; w1 = %s; trigger = %d; testVariable = %d; testValue = %d; variable = %d; value = %d\n",
item->w0, item->w1, item->trigger, item->testVariable.value, item->testValue, item->variable.value, item->value);
}
@@ -194,9 +194,9 @@ ScriptFunction::~ScriptFunction() {
}
void ScriptFunction::load(Common::File *fd) {
- printf("ScriptFunction::load()\n");
+ debug(kDebugScript, "ScriptFunction::load()\n");
uint32 size = fd->readUint32LE();
- printf("ScriptFunction::load() size = %d\n", size);
+ debug(kDebugScript, "ScriptFunction::load() size = %d\n", size);
_code = fd->readStream(size);
}
@@ -243,16 +243,16 @@ void ScriptInterpreter::open(const char *filename) {
}
int functionCount = _scriptFile->readUint32LE();
- printf("functionCount = %d\n", functionCount);
+ debug(kDebugScript, "functionCount = %d\n", functionCount);
for (int i = 0; i < functionCount; i++) {
uint32 offset = _scriptFile->readUint32LE();
- printf("func(%d) offset = %08X\n", i, offset);
+ debug(kDebugScript, "func(%d) offset = %08X\n", i, offset);
uint32 len = _scriptFile->readUint32LE();
if (len > 0) {
char *funcName = new char[len + 1];
_scriptFile->read(funcName, len);
funcName[len] = '\0';
- printf("func(%d) name = %s\n", i, funcName);
+ debug(kDebugScript, "func(%d) name = %s\n", i, funcName);
_functionNames[Common::String(funcName)] = _functions.size();
// DEBUG
_scriptFunctionNames.push_back(Common::String(funcName));
@@ -262,16 +262,16 @@ void ScriptInterpreter::open(const char *filename) {
}
int dataCount = _scriptFile->readUint32LE();
- printf("dataCount = %d\n", dataCount);
+ debug(kDebugScript, "dataCount = %d\n", dataCount);
for (int i = 0; i < dataCount; i++) {
uint32 offset = _scriptFile->readUint32LE();
ScriptDataType type = (ScriptDataType)_scriptFile->readUint32LE();
- printf("data(%d) offset = %08X; type = %d\n", i, offset, type);
+ debug(kDebugScript, "data(%d) offset = %08X; type = %d\n", i, offset, type);
_data.push_back(new ScriptDataEntry(offset, type));
}
_globalVarCount = _scriptFile->readUint32LE();
- printf("_globalVarCount = %d\n", _globalVarCount);
+ debug(kDebugScript, "_globalVarCount = %d\n", _globalVarCount);
uint32 stringOfs = _scriptFile->readUint32LE();
_scriptFile->seek(stringOfs);
@@ -324,11 +324,11 @@ ScriptFunction *ScriptInterpreter::loadFunction(uint32 index) {
ScriptFunction *ScriptInterpreter::loadFunction(const Common::String &name) {
FunctionNameMap::iterator iter = _functionNames.find(name);
if (iter == _functionNames.end()) {
- printf("ScriptInterpreter::loadFunction() Function '%s' not found!\n", name.c_str());
+ debug(kDebugScript, "ScriptInterpreter::loadFunction() Function '%s' not found!\n", name.c_str());
return NULL;
}
uint32 funcIndex = (*iter)._value;
- printf("ScriptInterpreter::loadFunction() index('%s') = %d\n", name.c_str(), funcIndex);
+ debug(kDebugScript, "ScriptInterpreter::loadFunction() index('%s') = %d\n", name.c_str(), funcIndex);
return loadFunction(funcIndex);
}
@@ -376,24 +376,24 @@ void ScriptInterpreter::pop(ScriptValue &value) {
}
void ScriptInterpreter::dumpStack() {
- printf("ScriptInterpreter::dumpStack()\n");
+ debug(kDebugScript, "ScriptInterpreter::dumpStack()\n");
for (int i = 0; i < _stackPtr; i++) {
- printf("%03d. type = %02d; value = %d\n", i, _stack[i].type, _stack[i].value);
+ debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _stack[i].type, _stack[i].value);
}
}
void ScriptInterpreter::dumpRegisters() {
- printf("ScriptInterpreter::dumpRegisters()\n");
+ debug(kDebugScript, "ScriptInterpreter::dumpRegisters()\n");
for (int i = 0; i < ARRAYSIZE(_registers); i++) {
- printf("%03d. type = %02d; value = %d\n", i, _registers[i].type, _registers[i].value);
+ debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _registers[i].type, _registers[i].value);
}
}
void ScriptInterpreter::dumpGlobalVars() {
- printf("ScriptInterpreter::dumpGlobalVars()\n");
+ debug(kDebugScript, "ScriptInterpreter::dumpGlobalVars()\n");
for (int i = 0; i < ARRAYSIZE(_globalVars); i++) {
if (_globalVars[i].type != -1)
- printf("%03d. type = %02d; value = %d\n", i, _globalVars[i].type, _globalVars[i].value);
+ debug(kDebugScript, "%03d. type = %02d; value = %d\n", i, _globalVars[i].type, _globalVars[i].value);
}
}
@@ -405,7 +405,7 @@ int ScriptInterpreter::toInteger(const ScriptValue &value) {
return value.value;
default:
- printf("ScriptInterpreter::toInteger() Invalid type %d!\n", value.type);
+ debug(kDebugScript, "ScriptInterpreter::toInteger() Invalid type %d!\n", value.type);
return 0;
}
@@ -423,7 +423,7 @@ const char *ScriptInterpreter::toString(const ScriptValue &value) {
return _constStrings[value.value];
default:
- printf("ScriptInterpreter::toString() Invalid type %d!\n", value.type);
+ debug(kDebugScript, "ScriptInterpreter::toString() Invalid type %d!\n", value.type);
return NULL;
}
@@ -462,7 +462,7 @@ void ScriptInterpreter::loadValue(ScriptValue &value) {
break;
default:
- printf("ScriptInterpreter::loadValue() Invalid value type %d!\n", value.type);
+ debug(kDebugScript, "ScriptInterpreter::loadValue() Invalid value type %d!\n", value.type);
}
@@ -471,7 +471,7 @@ void ScriptInterpreter::loadValue(ScriptValue &value) {
void ScriptInterpreter::copyValue(ScriptValue &destValue, ScriptValue &sourceValue) {
if (sourceValue.type == -1) {
- printf("ScriptInterpreter::copyValue() Trying to read uninitialized value!\n");
+ debug(kDebugScript, "ScriptInterpreter::copyValue() Trying to read uninitialized value!\n");
}
switch (destValue.type) {
@@ -489,7 +489,7 @@ void ScriptInterpreter::copyValue(ScriptValue &destValue, ScriptValue &sourceVal
if (sourceValue.type == kInteger) {
_logicGlobals[destValue.value] = sourceValue.value;
} else {
- printf("ScriptInterpreter::copyValue() Invalid source value type %d!\n", sourceValue.type);
+ debug(kDebugScript, "ScriptInterpreter::copyValue() Invalid source value type %d!\n", sourceValue.type);
}
break;
@@ -498,7 +498,7 @@ void ScriptInterpreter::copyValue(ScriptValue &destValue, ScriptValue &sourceVal
break;
default:
- printf("ScriptInterpreter::copyValue() Invalid dest value type %d!\n", destValue.type);
+ debug(kDebugScript, "ScriptInterpreter::copyValue() Invalid dest value type %d!\n", destValue.type);
}
@@ -533,7 +533,7 @@ void ScriptInterpreter::derefValue(ScriptValue &value) {
break;
default:
- printf("ScriptInterpreter::derefValue() Invalid value type %d!\n", value.type);
+ debug(kDebugScript, "ScriptInterpreter::derefValue() Invalid value type %d!\n", value.type);
}
@@ -541,21 +541,21 @@ void ScriptInterpreter::derefValue(ScriptValue &value) {
void ScriptInterpreter::callKernelFunction(uint32 index) {
- printf("ScriptInterpreter::callKernelFunction() index = %d\n", index);
+ debug(kDebugScript, "ScriptInterpreter::callKernelFunction() index = %d\n", index);
if (index > _kernelFunctionsMax) {
- printf("ScriptInterpreter::callKernelFunction() Invalid kernel functionindex (%d)\n", index);
+ debug(kDebugScript, "ScriptInterpreter::callKernelFunction() Invalid kernel functionindex (%d)\n", index);
return;
}
- printf("ScriptInterpreter::callKernelFunction() name = %s\n", _kernelFunctions[index].desc);
+ debug(kDebugScript, "ScriptInterpreter::callKernelFunction() name = %s\n", _kernelFunctions[index].desc);
int args = (this->*(_kernelFunctions[index].proc))();
// Now remove values from the stack if the function used any
if (args > 4)
_stackPtr -= args - 4;
- printf("-------------\n");
+ debug(kDebugScript, "-------------\n");
}
@@ -569,30 +569,30 @@ ScriptValue ScriptInterpreter::getArg(uint32 index) {
}
void ScriptInterpreter::dumpArgs(uint32 count) {
- printf("ScriptInterpreter::dumpArgs() ");
+ debug(kDebugScript, "ScriptInterpreter::dumpArgs() ");
for (uint32 i = 0; i < count; i++) {
ScriptValue argValue = getArg(i);
if (argValue.type == kConstString) {
- printf("'%s'", toString(argValue));
+ debug(kDebugScript, "'%s'", toString(argValue));
} else {
- printf("%d", argValue.value);
+ debug(kDebugScript, "%d", argValue.value);
}
if (i + 1 < count)
- printf(", ");
+ debug(kDebugScript, ", ");
}
- printf("\n");
+ debug(kDebugScript, "\n");
}
void ScriptInterpreter::callFunction(uint32 index) {
// NOTE: This is a temporary hack for script functions not yet in the m4.dat
if (index == 0xFFFFFFFF)
return;
- printf("ScriptInterpreter::callFunction() index = %d [%s]\n", index, _scriptFunctionNames[index].c_str());
+ debug(kDebugScript, "ScriptInterpreter::callFunction() index = %d [%s]\n", index, _scriptFunctionNames[index].c_str());
fflush(stdout);
ScriptFunction *subFunction = loadFunction(index);
if (!subFunction) {
// This *should* never happen since the linker checks this
- printf("ScriptInterpreter::callFunction() Function %d could not be loaded!\n", index);
+ debug(kDebugScript, "ScriptInterpreter::callFunction() Function %d could not be loaded!\n", index);
return;
}
runFunction(subFunction);
@@ -600,7 +600,7 @@ void ScriptInterpreter::callFunction(uint32 index) {
bool ScriptInterpreter::execOpcode(byte opcode) {
- printf("opcode = %d (%s)\n", opcode, opcodeNames[opcode]);
+ debug(kDebugScript, "opcode = %d (%s)\n", opcode, opcodeNames[opcode]);
ScriptValue value1, value2, value3;
uint32 temp;
@@ -649,14 +649,14 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJmp:
temp = _runningFunction->readUint32();
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
return true;
case opJl:
temp = _runningFunction->readUint32();
if (_cmpFlags < 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
@@ -664,7 +664,7 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJle:
temp = _runningFunction->readUint32();
if (_cmpFlags <= 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
@@ -672,7 +672,7 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJg:
temp = _runningFunction->readUint32();
if (_cmpFlags > 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
@@ -680,7 +680,7 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJge:
temp = _runningFunction->readUint32();
if (_cmpFlags >= 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
@@ -688,7 +688,7 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJz:
temp = _runningFunction->readUint32();
if (_cmpFlags == 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
@@ -696,17 +696,17 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
case opJnz:
temp = _runningFunction->readUint32();
if (_cmpFlags != 0) {
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
}
return true;
case opJmpByTable:
temp = _runningFunction->readUint32();
- printf("-> index = %d\n", _registers[0].value);
+ debug(kDebugScript, "-> index = %d\n", _registers[0].value);
_runningFunction->jumpRelative(_registers[0].value * 4);
temp = _runningFunction->readUint32();
- printf("-> ofs = %08X\n", temp);
+ debug(kDebugScript, "-> ofs = %08X\n", temp);
_runningFunction->jumpAbsolute(temp);
return true;
@@ -718,8 +718,8 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
if (value1.type != kInteger || value2.type != kInteger)
warning("ScriptInterpreter::execOpcode() Trying to compare non-integer values (%d, %d, line %d)", value1.type, value2.type, _lineNum);
_cmpFlags = value1.value - value2.value;
- printf("-> cmp %d, %d\n", value1.value, value2.value);
- printf("-> _cmpFlags = %d\n", _cmpFlags);
+ debug(kDebugScript, "-> cmp %d, %d\n", value1.value, value2.value);
+ debug(kDebugScript, "-> _cmpFlags = %d\n", _cmpFlags);
return true;
case opCall:
@@ -773,7 +773,7 @@ bool ScriptInterpreter::execOpcode(byte opcode) {
return true;
default:
- printf("Invalid opcode %d!\n", opcode);
+ debug(kDebugScript, "Invalid opcode %d!\n", opcode);
return false;
}
@@ -922,14 +922,14 @@ int ScriptInterpreter::o1_wilburFinishedTalking() {
int ScriptInterpreter::o1_preloadSound() {
const char *name = STRING(0);
int room = INTEGER(1);
- printf("name = %s; room = %d\n", name, room);
+ debug(kDebugScript, "name = %s; room = %d\n", name, room);
return 2;
}
int ScriptInterpreter::o1_unloadSound() {
const char *name = STRING(0);
int room = INTEGER(1);
- printf("name = %s; room = %d\n", name, room);
+ debug(kDebugScript, "name = %s; room = %d\n", name, room);
return 2;
}
@@ -939,7 +939,7 @@ int ScriptInterpreter::o1_playSound() {
int volume = INTEGER(2);
int trigger = INTEGER(3);
int room = INTEGER(4);
- printf("name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
+ debug(kDebugScript, "name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
name, channel, volume, trigger, room);
Common::String soundName = Common::String(name) + ".raw";
@@ -957,7 +957,7 @@ int ScriptInterpreter::o1_playLoopingSound() {
int volume = INTEGER(2);
int trigger = INTEGER(3);
int room = INTEGER(4);
- printf("name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
+ debug(kDebugScript, "name = %s; channel = %d; volume = %d; trigger = %d; room = %d\n",
name, channel, volume, trigger, room);
// HACK until fixed
@@ -968,14 +968,14 @@ int ScriptInterpreter::o1_playLoopingSound() {
int ScriptInterpreter::o1_stopSound() {
int channel = INTEGER(0);
- printf("channel = %d\n", channel);
+ debug(kDebugScript, "channel = %d\n", channel);
return 1;
}
int ScriptInterpreter::o1_fadeSetStart() {
// skip arg 0: palette ptr
int percent = INTEGER(1);
- printf("percent = %d\n", percent);
+ debug(kDebugScript, "percent = %d\n", percent);
return 2;
}
@@ -986,7 +986,7 @@ int ScriptInterpreter::o1_fadeInit() {
int percent = INTEGER(3);
int ticks = INTEGER(4);
int trigger = INTEGER(5);
- printf("first = %d; last = %d; percent = %d; ticks = %d; trigger = %d\n",
+ debug(kDebugScript, "first = %d; last = %d; percent = %d; ticks = %d; trigger = %d\n",
first, last, percent, ticks, trigger);
// HACK until palette fading is implemented
@@ -1005,7 +1005,7 @@ int ScriptInterpreter::o1_initPaletteCycle() {
int delay = INTEGER(2);
int ticks = INTEGER(3);
int trigger = INTEGER(4);
- printf("first = %d; last = %d; delay = %d; ticks = %d; trigger = %d\n",
+ debug(kDebugScript, "first = %d; last = %d; delay = %d; ticks = %d; trigger = %d\n",
first, last, delay, ticks, trigger);
// HACK until palette cycling is implemented
@@ -1022,11 +1022,11 @@ int ScriptInterpreter::o1_hasPlayerSaid() {
const char *words[3];
for (int i = 0; i < 3; i++)
words[i] = STRING(i);
- printf("'%s', '%s', '%s'\n", words[0], words[1], words[2]);
+ debug(kDebugScript, "'%s', '%s', '%s'\n", words[0], words[1], words[2]);
int result = _vm->_player->said(words[0], words[1], words[2]);
- printf(" -> '%d'\n", result);
+ debug(kDebugScript, " -> '%d'\n", result);
fflush(stdout);
RETURN(result);
@@ -1038,11 +1038,11 @@ int ScriptInterpreter::o1_hasPlayerSaidAny() {
for (int i = 0; i < 10; i++)
words[i] = STRING(i);
- printf("'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'\n",
+ debug(kDebugScript, "'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'\n",
words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
int result = _vm->_player->saidAny(words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9]);
- printf(" -> '%d'\n", result);
+ debug(kDebugScript, " -> '%d'\n", result);
fflush(stdout);
RETURN(result);
@@ -1059,13 +1059,13 @@ int ScriptInterpreter::o1_playerHotspotWalkOverride() {
int y1 = INTEGER(1);
int x2 = INTEGER(2);
int y2 = INTEGER(3);
- printf("(%d, %d); (%d, %d)\n", x1, y1, x2, y2);
+ debug(kDebugScript, "(%d, %d); (%d, %d)\n", x1, y1, x2, y2);
return 4;
}
int ScriptInterpreter::o1_playerHasItem() {
const char *name = STRING(0);
- printf("item = '%s'\n", name);
+ debug(kDebugScript, "item = '%s'\n", name);
// TODO
RETURN(0);
return 1;
@@ -1075,14 +1075,14 @@ int ScriptInterpreter::o1_setWalkerLocation() {
// skip arg 0: walker
int x = INTEGER(1);
int y = INTEGER(2);
- printf("x = %d; y = %d\n", x, y);
+ debug(kDebugScript, "x = %d; y = %d\n", x, y);
return 3;
}
int ScriptInterpreter::o1_setWalkerFacing() {
// skip arg 0: walker
int facing = INTEGER(1);
- printf("facing = %d\n", facing);
+ debug(kDebugScript, "facing = %d\n", facing);
return 2;
}
@@ -1090,7 +1090,7 @@ int ScriptInterpreter::o1_setHotspot() {
// skip arg 0: hotspot list
const char *name = STRING(1);
int value = INTEGER(2);
- printf("name = '%s' -> %d\n", name, value);
+ debug(kDebugScript, "name = '%s' -> %d\n", name, value);
_vm->_scene->getSceneResources().hotspots->setActive(name, (value != 0));
@@ -1121,7 +1121,7 @@ int ScriptInterpreter::o1_playSeries() {
int firstFrame = INTEGER(9);
int lastFrame = INTEGER(10);
- printf("name = %s; layer = %04X; flags = %08X; trigger = %d; frameRate = %d; loopCount = %d; scale = %d; x = %d; y = %d: firstFrame = %d; lastFrame = %d\n",
+ debug(kDebugScript, "name = %s; layer = %04X; flags = %08X; trigger = %d; frameRate = %d; loopCount = %d; scale = %d; x = %d; y = %d: firstFrame = %d; lastFrame = %d\n",
name, layer, flags, trigger, frameRate, loopCount, scale, x, y, firstFrame, lastFrame);
fflush(stdout);
@@ -1142,7 +1142,7 @@ int ScriptInterpreter::o1_showSeries() {
int x = INTEGER(7);
int y = INTEGER(8);
- printf("name = %s; layer = %04X; flags = %08X; trigger = %d; duration = %d; frameIndex = %d; scale = %d; x = %d; y = %d\n",
+ debug(kDebugScript, "name = %s; layer = %04X; flags = %08X; trigger = %d; duration = %d; frameIndex = %d; scale = %d; x = %d; y = %d\n",
name, layer, flags, trigger, duration, frameIndex, scale, x, y);
fflush(stdout);
@@ -1157,7 +1157,7 @@ int ScriptInterpreter::o1_loadSeries() {
int hash = INTEGER(1);
// skip arg 3: palette ptr
- printf("name = %s; hash = %d\n", name, hash);
+ debug(kDebugScript, "name = %s; hash = %d\n", name, hash);
fflush(stdout);
int result = _vm->_ws->loadSeries(name, hash, NULL);
@@ -1189,7 +1189,7 @@ int ScriptInterpreter::o1_globalTriggerProc() {
int value1 = INTEGER(0);
int value2 = INTEGER(1);
int value3 = INTEGER(2);
- printf("%d; %d; %d\n", value1, value2, value3);
+ debug(kDebugScript, "%d; %d; %d\n", value1, value2, value3);
return 3;
}
@@ -1197,13 +1197,13 @@ int ScriptInterpreter::o1_triggerTimerProc() {
int value1 = INTEGER(0);
int value2 = INTEGER(1);
int value3 = INTEGER(2);
- printf("%d; %d; %d\n", value1, value2, value3);
+ debug(kDebugScript, "%d; %d; %d\n", value1, value2, value3);
return 3;
}
int ScriptInterpreter::o1_dispatchTrigger() {
int trigger = INTEGER(0);
- printf("trigger = %d\n", trigger);
+ debug(kDebugScript, "trigger = %d\n", trigger);
_vm->_kernel->sendTrigger(trigger);
//g_system->delayMillis(5000);
@@ -1229,7 +1229,7 @@ int ScriptInterpreter::o1_wilburSaid() {
SaidArrayItem *item = saidArray[i];
if (_vm->_player->said("LOOK AT", item->itemName) && item->digiNameLook) {
- printf(" -> LOOK AT: '%s'\n", item->digiNameLook);
+ debug(kDebugScript, " -> LOOK AT: '%s'\n", item->digiNameLook);
Common::String soundName = Common::String(item->digiNameLook) + ".raw";
_vm->_sound->playVoice(soundName.c_str(), 100);
result = 1;
@@ -1237,7 +1237,7 @@ int ScriptInterpreter::o1_wilburSaid() {
}
if (_vm->_player->said("TAKE", item->itemName) && item->digiNameTake) {
- printf(" -> TAKE: '%s'\n", item->digiNameTake);
+ debug(kDebugScript, " -> TAKE: '%s'\n", item->digiNameTake);
Common::String soundName = Common::String(item->digiNameTake) + ".raw";
_vm->_sound->playVoice(soundName.c_str(), 100);
result = 1;
@@ -1245,7 +1245,7 @@ int ScriptInterpreter::o1_wilburSaid() {
}
if (_vm->_player->said("GEAR", item->itemName) && item->digiNameGear) {
- printf(" -> GEAR: '%s'\n", item->digiNameGear);
+ debug(kDebugScript, " -> GEAR: '%s'\n", item->digiNameGear);
Common::String soundName = Common::String(item->digiNameGear) + ".raw";
_vm->_sound->playVoice(soundName.c_str(), 100);
result = 1;
@@ -1253,11 +1253,11 @@ int ScriptInterpreter::o1_wilburSaid() {
}
/*
- printf("##### itemName = '%s'; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
+ debug(kDebugScript, "##### itemName = '%s'; digiNameLook = %s; digiNameTake = %s; digiNameGear = %s\n",
item->itemName, item->digiNameLook, item->digiNameTake, item->digiNameGear);
*/
}
- printf(" -> '%d'\n", result);
+ debug(kDebugScript, " -> '%d'\n", result);
fflush(stdout);
RETURN(result);
@@ -1278,7 +1278,7 @@ int ScriptInterpreter::o1_wilburSpeech() {
int volume = INTEGER(4);
int slot = INTEGER(5);
- printf("%s; %d; %d; %d; %d; %d\n", name, trigger, room, flag, volume, slot);
+ debug(kDebugScript, "%s; %d; %d; %d; %d; %d\n", name, trigger, room, flag, volume, slot);
fflush(stdout);
//g_system->delayMillis(5000);
@@ -1297,14 +1297,14 @@ int ScriptInterpreter::o1_wilburSpeech() {
void ScriptInterpreter::getKernelVar(int index, ScriptValue &value) {
- printf("ScriptInterpreter::getKernelVar() index = %d\n", index);
+ debug(kDebugScript, "ScriptInterpreter::getKernelVar() index = %d\n", index);
if (index > _kernelVarsMax) {
- printf("ScriptInterpreter::getKernelVar() Invalid kernel var index %d!\n", index);
+ debug(kDebugScript, "ScriptInterpreter::getKernelVar() Invalid kernel var index %d!\n", index);
return;
}
- printf("ScriptInterpreter::getKernelVar() name = %s\n", _kernelVars[index].desc);
+ debug(kDebugScript, "ScriptInterpreter::getKernelVar() name = %s\n", _kernelVars[index].desc);
ScriptKernelVariable var = _kernelVars[index].var;
@@ -1342,7 +1342,7 @@ void ScriptInterpreter::getKernelVar(int index, ScriptValue &value) {
break;
default:
- printf("ScriptInterpreter::getKernelVar() Invalid kernel var %d!\n", var);
+ debug(kDebugScript, "ScriptInterpreter::getKernelVar() Invalid kernel var %d!\n", var);
//g_system->delayMillis(2000);
}
@@ -1351,14 +1351,14 @@ void ScriptInterpreter::getKernelVar(int index, ScriptValue &value) {
void ScriptInterpreter::setKernelVar(int index, const ScriptValue &value) {
- printf("ScriptInterpreter::setKernelVar() index = %d\n", index);
+ debug(kDebugScript, "ScriptInterpreter::setKernelVar() index = %d\n", index);
if (index > _kernelVarsMax) {
- printf("ScriptInterpreter::setKernelVar() Invalid kernel var index %d!\n", index);
+ debug(kDebugScript, "ScriptInterpreter::setKernelVar() Invalid kernel var index %d!\n", index);
return;
}
- printf("ScriptInterpreter::setKernelVar() name = %s\n", _kernelVars[index].desc);
+ debug(kDebugScript, "ScriptInterpreter::setKernelVar() name = %s\n", _kernelVars[index].desc);
ScriptKernelVariable var = _kernelVars[index].var;
@@ -1366,31 +1366,31 @@ void ScriptInterpreter::setKernelVar(int index, const ScriptValue &value) {
case kKernelTrigger:
_vm->_kernel->trigger = toInteger(value);
- printf("kKernelTrigger -> %d\n", toInteger(value));
+ debug(kDebugScript, "kKernelTrigger -> %d\n", toInteger(value));
break;
case kKernelTriggerMode:
_vm->_kernel->triggerMode = (KernelTriggerType)toInteger(value);
- printf("kKernelTrigger -> %d\n", toInteger(value));
+ debug(kDebugScript, "kKernelTrigger -> %d\n", toInteger(value));
break;
case kKernelContinueHandlingTrigger:
_vm->_kernel->daemonTriggerAvailable = (toInteger(value) != 0);
- printf("kKernelContinueHandlingTrigger -> %d\n", toInteger(value));
+ debug(kDebugScript, "kKernelContinueHandlingTrigger -> %d\n", toInteger(value));
break;
case kGameNewRoom:
_vm->_kernel->newRoom = toInteger(value);
- printf("kGameNewRoom -> %d\n", toInteger(value));
+ debug(kDebugScript, "kGameNewRoom -> %d\n", toInteger(value));
break;
case kPlayerCommandReady:
// TODO
- printf("kPlayerCommandReady -> %d\n", toInteger(value));
+ debug(kDebugScript, "kPlayerCommandReady -> %d\n", toInteger(value));
break;
default:
- printf("ScriptInterpreter::setKernelVar() Invalid kernel var %d!\n", var);
+ debug(kDebugScript, "ScriptInterpreter::setKernelVar() Invalid kernel var %d!\n", var);
//g_system->delayMillis(2000);
}
diff --git a/engines/m4/script.h b/engines/m4/script.h
index 7382c05b67..d57dbf2639 100644
--- a/engines/m4/script.h
+++ b/engines/m4/script.h
@@ -305,7 +305,7 @@ public:
// Is this ok?
template<class T>
const T& toData(const ScriptValue &value) {
- printf("ScriptInterpreter::toData() index = %d; type = %d; max = %d\n", value.value, _data[value.value]->type, _data.size());
+ debug(kDebugScript, "ScriptInterpreter::toData() index = %d; type = %d; max = %d\n", value.value, _data[value.value]->type, _data.size());
assert((uint32)value.value < _data.size());
T *result = 0;
_dataCache->load(_scriptFile, _data[value.value]->offset, result);
diff --git a/engines/m4/sound.cpp b/engines/m4/sound.cpp
index e0fbd2f7a9..76f0cded46 100644
--- a/engines/m4/sound.cpp
+++ b/engines/m4/sound.cpp
@@ -194,7 +194,7 @@ void Sound::loadDSRFile(const char *fileName) {
// Read header
_dsrFile.entryCount = fileStream->readUint16LE();
- //printf("DSR has %i entries\n", _dsrFile.entryCount);
+ //warning(kDebugSound, "DSR has %i entries\n", _dsrFile.entryCount);
for (int i = 0; i < _dsrFile.entryCount; i++) {
DSREntry newEntry;
@@ -206,13 +206,13 @@ void Sound::loadDSRFile(const char *fileName) {
_dsrFile.dsrEntries.push_back(newEntry);
/*
- printf("%i: ", i);
- printf("frequency: %i ", newEntry->frequency);
- printf("channels: %i ", newEntry->channels);
- printf("comp: %i ", newEntry.compSize);
- printf("uncomp: %i ", newEntry.uncompSize);
- printf("offset: %i ", newEntry->offset);
- printf("\n");
+ warning(kDebugSound, "%i: ", i);
+ warning(kDebugSound, "frequency: %i ", newEntry->frequency);
+ warning(kDebugSound, "channels: %i ", newEntry->channels);
+ warning(kDebugSound, "comp: %i ", newEntry.compSize);
+ warning(kDebugSound, "uncomp: %i ", newEntry.uncompSize);
+ warning(kDebugSound, "offset: %i ", newEntry->offset);
+ warning(kDebugSound, "\n");
*/
}
diff --git a/engines/m4/woodscript.cpp b/engines/m4/woodscript.cpp
index 3ce0fa0f2f..52e19ef540 100644
--- a/engines/m4/woodscript.cpp
+++ b/engines/m4/woodscript.cpp
@@ -46,7 +46,7 @@ Bytecode::~Bytecode() {
int Bytecode::loadInstruction(Instruction &instruction) {
- //printf("Bytecode::loadInstruction() ip = %08X\n", _code->pos());
+ //debug(kDebugScript, "Bytecode::loadInstruction() ip = %08X\n", _code->pos());
int32 format, data;
uint32 code, code2;
@@ -90,7 +90,7 @@ int Bytecode::loadInstruction(Instruction &instruction) {
void Bytecode::jumpAbsolute(int32 ofs) {
_code->seek(ofs * 4);
- //printf("Bytecode::jumpAbsolute() ofs = %08X\n", _code->pos());
+ //debug(kDebugScript, "Bytecode::jumpAbsolute() ofs = %08X\n", _code->pos());
}
void Bytecode::jumpRelative(int32 ofs) {
@@ -200,7 +200,7 @@ void WoodScript::runTimerSequenceRequests() {
Machine *WoodScript::createMachine(int32 machineHash, Sequence *parentSeq,
int32 dataHash, int32 dataRowIndex, int callbackHandler, const char *machineName) {
- //printf("WoodScript::createMachine(%d)\n", machineHash); fflush(stdout);
+ //debug(kDebugScript, "WoodScript::createMachine(%d)\n", machineHash); fflush(stdout);
Machine *machine = new Machine(this, machineHash, parentSeq, dataHash, dataRowIndex, callbackHandler, machineName, _machineId);
_machineId++;
@@ -228,7 +228,7 @@ Machine *WoodScript::playSeries(const char *seriesName, long layer, uint32 flags
int32 frameRate, int32 loopCount, int32 s, int32 x, int32 y,
int32 firstFrame, int32 lastFrame) {
- //printf("WoodScript::playSeries(%s)\n", seriesName);
+ //debug(kDebugScript, "WoodScript::playSeries(%s)\n", seriesName);
RGB8 *palette = NULL;
if (flags & SERIES_LOAD_PALETTE)
@@ -282,7 +282,7 @@ Machine *WoodScript::showSeries(const char *seriesName, long layer, uint32 flags
}
Machine *WoodScript::streamSeries(const char *seriesName, int32 frameRate, long layer, int32 triggerNum) {
- //printf("WoodScript::streamSeries(%s)\n", seriesName);
+ //debug(kDebugScript, "WoodScript::streamSeries(%s)\n", seriesName);
_globals[kGlobTemp1] = frameRate << 16;
/* FIXME: Single frames from a stream series will be decompressed on-the-fly, contrary to
"normal" sprite series, to save some memory, and since no random access to single
diff --git a/engines/m4/ws_machine.cpp b/engines/m4/ws_machine.cpp
index cb791026c9..04ec1ee50b 100644
--- a/engines/m4/ws_machine.cpp
+++ b/engines/m4/ws_machine.cpp
@@ -147,7 +147,7 @@ void Machine::enterState() {
int32 Machine::execInstruction() {
- //printf("Machine::execInstruction()\n"); fflush(stdout);
+ //debug(kDebugScript, "Machine::execInstruction()\n"); fflush(stdout);
bool done = false;
Instruction instruction;
@@ -199,7 +199,7 @@ void Machine::execBlock(int32 offset, int32 count) {
int32 instruction = -1;
- //printf("---------------------------------------\n"); fflush(stdout);
+ //debug(kDebugScript, "---------------------------------------\n"); fflush(stdout);
while (instruction && instruction != 4 && _id == oldId && _recursionLevel == oldRecursionLevel &&
_code->pos() >= (uint32)startOffset && _code->pos() < (uint32)endOffset) {
@@ -208,7 +208,7 @@ void Machine::execBlock(int32 offset, int32 count) {
//g_system->delayMillis(500);
}
- //printf("---------------------------------------\n"); fflush(stdout);
+ //debug(kDebugScript, "---------------------------------------\n"); fflush(stdout);
if (instruction == 3) {
execInstruction();
@@ -221,7 +221,7 @@ void Machine::execBlock(int32 offset, int32 count) {
}
bool Machine::m1_gotoState(Instruction &instruction) {
- //printf("Machine::m1_gotoState() state = %d\n", (int32)instruction.argv[0] >> 16);
+ //debug(kDebugScript, "Machine::m1_gotoState() state = %d\n", (int32)instruction.argv[0] >> 16);
_currentState = (int32)instruction.argv[0] >> 16;
_recursionLevel = 0;
@@ -229,14 +229,14 @@ bool Machine::m1_gotoState(Instruction &instruction) {
}
bool Machine::m1_jump(Instruction &instruction) {
- //printf("Machine::m1_jump() ofs = %08X\n", (int32)instruction.argv[0] >> 16);
+ //debug(kDebugScript, "Machine::m1_jump() ofs = %08X\n", (int32)instruction.argv[0] >> 16);
_code->jumpRelative((int32)instruction.argv[0] >> 16);
return true;
}
bool Machine::m1_terminate(Instruction &instruction) {
- //printf("Machine::m1_terminate()\n"); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_terminate()\n"); fflush(stdout);
_currentState = -1;
_recursionLevel = 0;
@@ -244,15 +244,15 @@ bool Machine::m1_terminate(Instruction &instruction) {
}
bool Machine::m1_startSequence(Instruction &instruction) {
- //printf("Machine::m1_startSequence() sequence hash = %d\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_startSequence() sequence hash = %d\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
int32 sequenceHash = instruction.argv[0] >> 16;
if (_sequence == NULL) {
- //printf("Machine::m1_startSequence() creating new sequence\n");
+ //debug(kDebugScript, "Machine::m1_startSequence() creating new sequence\n");
_sequence = _ws->createSequence(this, sequenceHash);
_code->setSequence(_sequence);
} else {
- //printf("Machine::m1_startSequence() using existing sequence\n");
+ //debug(kDebugScript, "Machine::m1_startSequence() using existing sequence\n");
_sequence->changeProgram(sequenceHash);
//_code->setSequence(_sequence);
}
@@ -260,28 +260,28 @@ bool Machine::m1_startSequence(Instruction &instruction) {
}
bool Machine::m1_pauseSequence(Instruction &instruction) {
- //printf("Machine::m1_pauseSequence()\n"); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_pauseSequence()\n"); fflush(stdout);
_sequence->pause();
return true;
}
bool Machine::m1_resumeSequence(Instruction &instruction) {
- //printf("Machine::m1_resumeSequence()\n"); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_resumeSequence()\n"); fflush(stdout);
_sequence->resume();
return true;
}
bool Machine::m1_storeValue(Instruction &instruction) {
- //printf("Machine::m1_storeValue() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+ //debug(kDebugScript, "Machine::m1_storeValue() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
*instruction.argp[0] = instruction.getValue();
return true;
}
bool Machine::m1_sendMessage(Instruction &instruction) {
- //printf("Machine::m1_sendMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+ //debug(kDebugScript, "Machine::m1_sendMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
#if 0
//TODO
@@ -300,7 +300,7 @@ bool Machine::m1_sendMessage(Instruction &instruction) {
}
bool Machine::m1_broadcastMessage(Instruction &instruction) {
- //printf("Machine::m1_broadcastMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
+ //debug(kDebugScript, "Machine::m1_broadcastMessage() %p = %d (%08X)\n", (void*)instruction.argp[0], (uint32)instruction.argv[1], (uint32)instruction.argv[1]);
#if 0
//TODO
@@ -317,7 +317,7 @@ bool Machine::m1_broadcastMessage(Instruction &instruction) {
}
bool Machine::m1_replyMessage(Instruction &instruction) {
- //printf("Machine::m1_replyMessage() messageHash = %d; messageValue = %d\n", (uint32)instruction.argv[0], (uint32)instruction.argv[1]);
+ //debug(kDebugScript, "Machine::m1_replyMessage() messageHash = %d; messageValue = %d\n", (uint32)instruction.argv[0], (uint32)instruction.argv[1]);
#if 0
if (myArg2) {
msgValue = *myArg2;
@@ -331,28 +331,28 @@ bool Machine::m1_replyMessage(Instruction &instruction) {
}
bool Machine::m1_sendSystemMessage(Instruction &instruction) {
- //printf("Machine::m1_sendSystemMessage() messageValue = %d\n", (uint32)instruction.argv[0]);
+ //debug(kDebugScript, "Machine::m1_sendSystemMessage() messageValue = %d\n", (uint32)instruction.argv[0]);
#if 0
#endif
return true;
}
bool Machine::m1_createMachine(Instruction &instruction) {
- //printf("Machine::m1_createMachine()\n");
+ //debug(kDebugScript, "Machine::m1_createMachine()\n");
#if 0
#endif
return true;
}
bool Machine::m1_createMachineEx(Instruction &instruction) {
- //printf("Machine::m1_createMachineEx()\n");
+ //debug(kDebugScript, "Machine::m1_createMachineEx()\n");
#if 0
#endif
return true;
}
bool Machine::m1_clearVars(Instruction &instruction) {
- //printf("Machine::m1_clearVars()\n"); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_clearVars()\n"); fflush(stdout);
_sequence->clearVars();
return true;
@@ -360,7 +360,7 @@ bool Machine::m1_clearVars(Instruction &instruction) {
void Machine::m1_onEndSequence(Instruction &instruction) {
- //printf("Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
int32 count = instruction.argv[0] >> 16;
_sequence->issueEndOfSequenceRequest(_code->pos(), count);
@@ -368,7 +368,7 @@ void Machine::m1_onEndSequence(Instruction &instruction) {
}
void Machine::m1_onMessage(Instruction &instruction) {
- //printf("Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_onEndSequence() count = %08X\n", (uint32)instruction.argv[0] >> 16); fflush(stdout);
// TODO: Add message to list
@@ -378,42 +378,42 @@ void Machine::m1_onMessage(Instruction &instruction) {
}
void Machine::m1_switchLt(Instruction &instruction) {
- //printf("Machine::m1_switchLt() %d < %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchLt() %d < %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] >= instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
}
void Machine::m1_switchLe(Instruction &instruction) {
- //printf("Machine::m1_switchLe() %d <= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchLe() %d <= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] > instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
}
void Machine::m1_switchEq(Instruction &instruction) {
- //printf("Machine::m1_switchEq() %d == %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchEq() %d == %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] != instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
}
void Machine::m1_switchNe(Instruction &instruction) {
- //printf("Machine::m1_switchNe() %d != %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchNe() %d != %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] == instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
}
void Machine::m1_switchGe(Instruction &instruction) {
- //printf("Machine::m1_switchGe() %d >= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchGe() %d >= %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] < instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
}
void Machine::m1_switchGt(Instruction &instruction) {
- //printf("Machine::m1_switchGt() %d > %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
+ //debug(kDebugScript, "Machine::m1_switchGt() %d > %d -> %08X\n", (uint32)instruction.argv[1], (uint32)instruction.argv[2], (uint32)instruction.argv[0] >> 16); fflush(stdout);
if (instruction.argv[1] <= instruction.argv[2])
_code->jumpRelative(instruction.argv[0] >> 16);
diff --git a/engines/m4/ws_sequence.cpp b/engines/m4/ws_sequence.cpp
index 79869a81d0..0f2634c91e 100644
--- a/engines/m4/ws_sequence.cpp
+++ b/engines/m4/ws_sequence.cpp
@@ -201,7 +201,7 @@ void Sequence::resume() {
void Sequence::issueEndOfSequenceRequest(int32 codeOffset, int32 count) {
- //printf("Sequence::issueEndOfSequenceRequest(%04X, %04X)\n", codeOffset, count); fflush(stdout);
+ //debug(kDebugScript, "Sequence::issueEndOfSequenceRequest(%04X, %04X)\n", codeOffset, count); fflush(stdout);
//g_system->delayMillis(5000);
_endOfSequenceRequest.codeOffset = codeOffset;
@@ -216,7 +216,7 @@ bool Sequence::runProgram() {
bool done = true;
- //printf("_ws->getGlobal(kGlobTime) = %ld, _switchTime = %d\n", _ws->getGlobal(kGlobTime), _switchTime);
+ //debug(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld, _switchTime = %d\n", _ws->getGlobal(kGlobTime), _switchTime);
if (_switchTime >= 0 && _ws->getGlobal(kGlobTime) >= _switchTime)
done = false;
@@ -246,7 +246,7 @@ bool Sequence::changeProgram(int32 sequenceHash) {
SequenceAsset *sequenceAsset = _ws->assets()->getSequence(sequenceHash);
if (sequenceAsset->localVarCount() > _localVarCount) {
- //printf("Sequence::changeProgram(%d) sequenceAsset->localVarCount() > _localVarCount\n", sequenceHash);
+ //debug(kDebugScript, "Sequence::changeProgram(%d) sequenceAsset->localVarCount() > _localVarCount\n", sequenceHash);
return false;
}
@@ -301,14 +301,14 @@ void Sequence::draw(M4Surface *surface, const Common::Rect &clipRect, Common::Re
}
bool Sequence::s1_end(Instruction &instruction) {
- //printf("Sequence::s1_end()\n");
+ //debug(kDebugScript, "Sequence::s1_end()\n");
_terminated = true;
return false;
}
bool Sequence::s1_clearVars(Instruction &instruction) {
- //printf("Sequence::s1_clearVars()\n");
+ //debug(kDebugScript, "Sequence::s1_clearVars()\n");
clearVars();
_vars[kSeqVarMachineID] = _machine->getId();
@@ -316,14 +316,14 @@ bool Sequence::s1_clearVars(Instruction &instruction) {
}
bool Sequence::s1_set(Instruction &instruction) {
- //printf("Sequence::s1_set()\n");
+ //debug(kDebugScript, "Sequence::s1_set()\n");
*instruction.argp[0] = instruction.getValue();
return true;
}
bool Sequence::s1_compare(Instruction &instruction) {
- //printf("Sequence::s1_compare()\n");
+ //debug(kDebugScript, "Sequence::s1_compare()\n");
long value = instruction.getValue();
if (instruction.argv[0] < value)
@@ -336,28 +336,28 @@ bool Sequence::s1_compare(Instruction &instruction) {
}
bool Sequence::s1_add(Instruction &instruction) {
- //printf("Sequence::s1_add()\n");
+ //debug(kDebugScript, "Sequence::s1_add()\n");
*instruction.argp[0] += instruction.getValue();
return true;
}
bool Sequence::s1_sub(Instruction &instruction) {
- //printf("Sequence::s1_sub()\n");
+ //debug(kDebugScript, "Sequence::s1_sub()\n");
*instruction.argp[0] -= instruction.getValue();
return true;
}
bool Sequence::s1_mul(Instruction &instruction) {
- //printf("Sequence::s1_mul()\n");
+ //debug(kDebugScript, "Sequence::s1_mul()\n");
*instruction.argp[0] = FixedMul(instruction.argv[0], instruction.getValue());
return true;
}
bool Sequence::s1_div(Instruction &instruction) {
- //printf("Sequence::s1_div()\n");
+ //debug(kDebugScript, "Sequence::s1_div()\n");
// TODO: Catch divisor = 0 in FixedDiv
*instruction.argp[0] = FixedDiv(instruction.argv[0], instruction.getValue());
@@ -365,7 +365,7 @@ bool Sequence::s1_div(Instruction &instruction) {
}
bool Sequence::s1_and(Instruction &instruction) {
- //printf("Sequence::s1_and()\n");
+ //debug(kDebugScript, "Sequence::s1_and()\n");
*instruction.argp[0] = instruction.argv[0] & instruction.getValue();
if (*instruction.argp[0])
@@ -376,7 +376,7 @@ bool Sequence::s1_and(Instruction &instruction) {
}
bool Sequence::s1_or(Instruction &instruction) {
- //printf("Sequence::s1_or()\n");
+ //debug(kDebugScript, "Sequence::s1_or()\n");
*instruction.argp[0] = instruction.argv[0] | instruction.getValue();
if (*instruction.argp[0])
@@ -387,7 +387,7 @@ bool Sequence::s1_or(Instruction &instruction) {
}
bool Sequence::s1_not(Instruction &instruction) {
- //printf("Sequence::s1_not()\n");
+ //debug(kDebugScript, "Sequence::s1_not()\n");
if (instruction.argv[0] == 0) {
*instruction.argp[0] = 0x10000;
@@ -400,7 +400,7 @@ bool Sequence::s1_not(Instruction &instruction) {
}
bool Sequence::s1_sin(Instruction &instruction) {
- //printf("Sequence::s1_sin()\n");
+ //debug(kDebugScript, "Sequence::s1_sin()\n");
int32 tempAngle = *instruction.argp[1] >> 16;
if (tempAngle < 0)
@@ -417,7 +417,7 @@ bool Sequence::s1_sin(Instruction &instruction) {
}
bool Sequence::s1_cos(Instruction &instruction) {
- //printf("Sequence::s1_cos()\n");
+ //debug(kDebugScript, "Sequence::s1_cos()\n");
int32 tempAngle = *instruction.argp[1] >> 16;
if (tempAngle < 0)
@@ -434,42 +434,42 @@ bool Sequence::s1_cos(Instruction &instruction) {
}
bool Sequence::s1_abs(Instruction &instruction) {
- //printf("Sequence::s1_abs()\n");
+ //debug(kDebugScript, "Sequence::s1_abs()\n");
*instruction.argp[0] = ABS(instruction.argv[1]);
return true;
}
bool Sequence::s1_min(Instruction &instruction) {
- //printf("Sequence::s1_min()\n");
+ //debug(kDebugScript, "Sequence::s1_min()\n");
*instruction.argp[0] = MIN(instruction.argv[1], instruction.argv[2]);
return true;
}
bool Sequence::s1_max(Instruction &instruction) {
- //printf("Sequence::s1_max()\n");
+ //debug(kDebugScript, "Sequence::s1_max()\n");
*instruction.argp[0] = MAX(instruction.argv[1], instruction.argv[2]);
return true;
}
bool Sequence::s1_mod(Instruction &instruction) {
- //printf("Sequence::s1_mod()\n");
+ //debug(kDebugScript, "Sequence::s1_mod()\n");
*instruction.argp[0] = instruction.argv[0] % instruction.getValue();
return true;
}
bool Sequence::s1_floor(Instruction &instruction) {
- //printf("Sequence::s1_floor()\n");
+ //debug(kDebugScript, "Sequence::s1_floor()\n");
*instruction.argp[0] = instruction.getValue() & 0xffff0000;
return true;
}
bool Sequence::s1_round(Instruction &instruction) {
- //printf("Sequence::s1_round()\n");
+ //debug(kDebugScript, "Sequence::s1_round()\n");
if ((*instruction.argp[1] & 0xffff) >= 0x8000)
*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -479,7 +479,7 @@ bool Sequence::s1_round(Instruction &instruction) {
}
bool Sequence::s1_ceil(Instruction &instruction) {
- //printf("Sequence::s1_ceil()\n");
+ //debug(kDebugScript, "Sequence::s1_ceil()\n");
if ((*instruction.argp[1] & 0xffff) >= 0)
*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -489,19 +489,19 @@ bool Sequence::s1_ceil(Instruction &instruction) {
}
bool Sequence::s1_point(Instruction &instruction) {
- printf("Sequence::s1_point()\n");
+ debug(kDebugScript, "Sequence::s1_point()\n");
// TODO
return true;
}
bool Sequence::s1_dist2d(Instruction &instruction) {
- printf("Sequence::s1_dist2d()\n");
+ debug(kDebugScript, "Sequence::s1_dist2d()\n");
// TODO
return true;
}
bool Sequence::s1_crunch(Instruction &instruction) {
- //printf("Sequence::s1_crunch()\n");
+ //debug(kDebugScript, "Sequence::s1_crunch()\n");
long deltaTime;
@@ -515,12 +515,12 @@ bool Sequence::s1_crunch(Instruction &instruction) {
_startTime = _ws->getGlobal(kGlobTime);
- //printf("deltaTime = %ld\n", deltaTime >> 16); fflush(stdout);
+ //debug(kDebugScript, "deltaTime = %ld\n", deltaTime >> 16); fflush(stdout);
//g_system->delayMillis(5000);
if (deltaTime >= 0) {
_switchTime = _ws->getGlobal(kGlobTime) + (deltaTime >> 16);
- //printf("_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime)); fflush(stdout);
+ //debug(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime)); fflush(stdout);
//g_system->delayMillis(5000);
} else {
_switchTime = -1;
@@ -532,7 +532,7 @@ bool Sequence::s1_crunch(Instruction &instruction) {
}
bool Sequence::s1_branch(Instruction &instruction) {
- //printf("Sequence::s1_branch()\n");
+ //debug(kDebugScript, "Sequence::s1_branch()\n");
uint32 ofs = instruction.argv[1] >> 16;
switch (instruction.argv[0] >> 16) {
@@ -569,7 +569,7 @@ bool Sequence::s1_branch(Instruction &instruction) {
}
bool Sequence::s1_setFrame(Instruction &instruction) {
- //printf("Sequence::s1_setFrame()\n");
+ //debug(kDebugScript, "Sequence::s1_setFrame()\n");
int32 frameIndex;
if (instruction.argc == 3) {
@@ -580,8 +580,8 @@ bool Sequence::s1_setFrame(Instruction &instruction) {
frameIndex = (instruction.argv[0] & 0xFF0000) >> 16;
}
- //printf("Sequence::s1_setFrame() spriteHash = %d\n", (uint32)instruction.argv[0] >> 24);
- //printf("Sequence::s1_setFrame() frameIndex = %d\n", frameIndex);
+ //debug(kDebugScript, "Sequence::s1_setFrame() spriteHash = %d\n", (uint32)instruction.argv[0] >> 24);
+ //debug(kDebugScript, "Sequence::s1_setFrame() frameIndex = %d\n", frameIndex);
SpriteAsset *spriteAsset = _ws->assets()->getSprite((uint32)instruction.argv[0] >> 24);
_curFrame = spriteAsset->getFrame(frameIndex);
@@ -590,25 +590,25 @@ bool Sequence::s1_setFrame(Instruction &instruction) {
}
bool Sequence::s1_sendMessage(Instruction &instruction) {
- printf("Sequence::s1_sendMessage()\n");
+ debug(kDebugScript, "Sequence::s1_sendMessage()\n");
// TODO
return true;
}
bool Sequence::s1_push(Instruction &instruction) {
- printf("Sequence::s1_push()\n");
+ debug(kDebugScript, "Sequence::s1_push()\n");
// TODO
return true;
}
bool Sequence::s1_pop(Instruction &instruction) {
- printf("Sequence::s1_pop()\n");
+ debug(kDebugScript, "Sequence::s1_pop()\n");
// TODO
return true;
}
bool Sequence::s1_jumpSub(Instruction &instruction) {
- //printf("Sequence::s1_jumpSub()\n");
+ //debug(kDebugScript, "Sequence::s1_jumpSub()\n");
_returnHashes[_returnStackIndex] = _sequenceHash;
_returnOffsets[_returnStackIndex] = _code->pos();
@@ -628,7 +628,7 @@ bool Sequence::s1_jumpSub(Instruction &instruction) {
}
bool Sequence::s1_return(Instruction &instruction) {
- //printf("Sequence::s1_return()\n");
+ //debug(kDebugScript, "Sequence::s1_return()\n");
if (_returnStackIndex <= 0)
return s1_end(instruction);
@@ -652,7 +652,7 @@ bool Sequence::s1_return(Instruction &instruction) {
}
bool Sequence::s1_getFrameCount(Instruction &instruction) {
- //printf("Sequence::s1_getFrameCount()\n");
+ //debug(kDebugScript, "Sequence::s1_getFrameCount()\n");
SpriteAsset *spriteAsset = _ws->assets()->getSprite(instruction.argv[1] >> 24);
*instruction.argp[0] = spriteAsset->getCount() << 16;
@@ -660,7 +660,7 @@ bool Sequence::s1_getFrameCount(Instruction &instruction) {
}
bool Sequence::s1_getFrameRate(Instruction &instruction) {
- //printf("Sequence::s1_getFrameRate()\n");
+ //debug(kDebugScript, "Sequence::s1_getFrameRate()\n");
SpriteAsset *spriteAsset = _ws->assets()->getSprite(instruction.argv[1] >> 24);
*instruction.argp[0] = spriteAsset->getFrameRate();
@@ -668,37 +668,37 @@ bool Sequence::s1_getFrameRate(Instruction &instruction) {
}
bool Sequence::s1_getCelsPixSpeed(Instruction &instruction) {
- printf("Sequence::s1_getCelsPixSpeed()\n");
+ debug(kDebugScript, "Sequence::s1_getCelsPixSpeed()\n");
// TODO
return true;
}
bool Sequence::s1_setIndex(Instruction &instruction) {
- printf("Sequence::s1_setIndex()\n");
+ debug(kDebugScript, "Sequence::s1_setIndex()\n");
// TODO
return true;
}
bool Sequence::s1_setLayer(Instruction &instruction) {
- printf("Sequence::s1_setLayer()\n");
+ debug(kDebugScript, "Sequence::s1_setLayer()\n");
//TODO
return true;
}
bool Sequence::s1_setDepth(Instruction &instruction) {
- printf("Sequence::s1_setDepth()\n");
+ debug(kDebugScript, "Sequence::s1_setDepth()\n");
//TODO
return true;
}
bool Sequence::s1_setData(Instruction &instruction) {
- printf("Sequence::s1_setData()\n");
+ debug(kDebugScript, "Sequence::s1_setData()\n");
//TODO
return true;
}
bool Sequence::s1_openStream(Instruction &instruction) {
- //printf("Sequence::s1_openStream()\n");
+ //debug(kDebugScript, "Sequence::s1_openStream()\n");
_stream = _vm->res()->openFile(_machine->name().c_str());
streamOpen();
@@ -706,14 +706,14 @@ bool Sequence::s1_openStream(Instruction &instruction) {
}
bool Sequence::s1_streamNextFrame(Instruction &instruction) {
- //printf("Sequence::s1_streamNextFrame()\n");
+ //debug(kDebugScript, "Sequence::s1_streamNextFrame()\n");
streamNextFrame();
return true;
}
bool Sequence::s1_closeStream(Instruction &instruction) {
- printf("Sequence::s1_closeStream()\n");
+ debug(kDebugScript, "Sequence::s1_closeStream()\n");
//TODO
return true;
}
@@ -726,7 +726,7 @@ bool Sequence::streamOpen() {
_vars[kSeqVarSpriteFrameCount] = _streamSpriteAsset->getCount() << 16;
_vars[kSeqVarSpriteFrameRate] = _streamSpriteAsset->getFrameRate() << 16;
- //printf("Sequence::streamOpen() frames = %d; max = %d x %d\n", _streamSpriteAsset->getCount(), _streamSpriteAsset->getMaxFrameWidth(), _streamSpriteAsset->getMaxFrameHeight());
+ //debug(kDebugScript, "Sequence::streamOpen() frames = %d; max = %d x %d\n", _streamSpriteAsset->getCount(), _streamSpriteAsset->getMaxFrameWidth(), _streamSpriteAsset->getMaxFrameHeight());
//fflush(stdout);
_curFrame = new M4Sprite(_vm, _streamSpriteAsset->getMaxFrameWidth(), _streamSpriteAsset->getMaxFrameHeight());