aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/ws_sequence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4/ws_sequence.cpp')
-rw-r--r--engines/m4/ws_sequence.cpp101
1 files changed, 51 insertions, 50 deletions
diff --git a/engines/m4/ws_sequence.cpp b/engines/m4/ws_sequence.cpp
index 79869a81d0..bb6230d041 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);
+ //debugCN(kDebugScript, "Sequence::issueEndOfSequenceRequest(%04X, %04X)\n", codeOffset, count);
//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);
+ //debugCN(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld, _switchTime = %d\n", _ws->getGlobal(kGlobTime), _switchTime);
if (_switchTime >= 0 && _ws->getGlobal(kGlobTime) >= _switchTime)
done = false;
@@ -228,7 +228,9 @@ bool Sequence::runProgram() {
_code->loadInstruction(instruction);
if (sequenceCommandsTable[instruction.instr] != 0)
done = !(this->*sequenceCommandsTable[instruction.instr])(instruction);
- else { fflush(stdout); /*g_system->delayMillis(1000);*/ }
+ else {
+ //g_system->delayMillis(1000);
+ }
}
return _terminated;
@@ -246,7 +248,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);
+ //debugCN(kDebugScript, "Sequence::changeProgram(%d) sequenceAsset->localVarCount() > _localVarCount\n", sequenceHash);
return false;
}
@@ -301,14 +303,14 @@ void Sequence::draw(M4Surface *surface, const Common::Rect &clipRect, Common::Re
}
bool Sequence::s1_end(Instruction &instruction) {
- //printf("Sequence::s1_end()\n");
+ //debugCN(kDebugScript, "Sequence::s1_end()\n");
_terminated = true;
return false;
}
bool Sequence::s1_clearVars(Instruction &instruction) {
- //printf("Sequence::s1_clearVars()\n");
+ //debugCN(kDebugScript, "Sequence::s1_clearVars()\n");
clearVars();
_vars[kSeqVarMachineID] = _machine->getId();
@@ -316,14 +318,14 @@ bool Sequence::s1_clearVars(Instruction &instruction) {
}
bool Sequence::s1_set(Instruction &instruction) {
- //printf("Sequence::s1_set()\n");
+ //debugCN(kDebugScript, "Sequence::s1_set()\n");
*instruction.argp[0] = instruction.getValue();
return true;
}
bool Sequence::s1_compare(Instruction &instruction) {
- //printf("Sequence::s1_compare()\n");
+ //debugCN(kDebugScript, "Sequence::s1_compare()\n");
long value = instruction.getValue();
if (instruction.argv[0] < value)
@@ -336,28 +338,28 @@ bool Sequence::s1_compare(Instruction &instruction) {
}
bool Sequence::s1_add(Instruction &instruction) {
- //printf("Sequence::s1_add()\n");
+ //debugCN(kDebugScript, "Sequence::s1_add()\n");
*instruction.argp[0] += instruction.getValue();
return true;
}
bool Sequence::s1_sub(Instruction &instruction) {
- //printf("Sequence::s1_sub()\n");
+ //debugCN(kDebugScript, "Sequence::s1_sub()\n");
*instruction.argp[0] -= instruction.getValue();
return true;
}
bool Sequence::s1_mul(Instruction &instruction) {
- //printf("Sequence::s1_mul()\n");
+ //debugCN(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");
+ //debugCN(kDebugScript, "Sequence::s1_div()\n");
// TODO: Catch divisor = 0 in FixedDiv
*instruction.argp[0] = FixedDiv(instruction.argv[0], instruction.getValue());
@@ -365,7 +367,7 @@ bool Sequence::s1_div(Instruction &instruction) {
}
bool Sequence::s1_and(Instruction &instruction) {
- //printf("Sequence::s1_and()\n");
+ //debugCN(kDebugScript, "Sequence::s1_and()\n");
*instruction.argp[0] = instruction.argv[0] & instruction.getValue();
if (*instruction.argp[0])
@@ -376,7 +378,7 @@ bool Sequence::s1_and(Instruction &instruction) {
}
bool Sequence::s1_or(Instruction &instruction) {
- //printf("Sequence::s1_or()\n");
+ //debugCN(kDebugScript, "Sequence::s1_or()\n");
*instruction.argp[0] = instruction.argv[0] | instruction.getValue();
if (*instruction.argp[0])
@@ -387,7 +389,7 @@ bool Sequence::s1_or(Instruction &instruction) {
}
bool Sequence::s1_not(Instruction &instruction) {
- //printf("Sequence::s1_not()\n");
+ //debugCN(kDebugScript, "Sequence::s1_not()\n");
if (instruction.argv[0] == 0) {
*instruction.argp[0] = 0x10000;
@@ -400,7 +402,7 @@ bool Sequence::s1_not(Instruction &instruction) {
}
bool Sequence::s1_sin(Instruction &instruction) {
- //printf("Sequence::s1_sin()\n");
+ //debugCN(kDebugScript, "Sequence::s1_sin()\n");
int32 tempAngle = *instruction.argp[1] >> 16;
if (tempAngle < 0)
@@ -417,7 +419,7 @@ bool Sequence::s1_sin(Instruction &instruction) {
}
bool Sequence::s1_cos(Instruction &instruction) {
- //printf("Sequence::s1_cos()\n");
+ //debugCN(kDebugScript, "Sequence::s1_cos()\n");
int32 tempAngle = *instruction.argp[1] >> 16;
if (tempAngle < 0)
@@ -434,42 +436,42 @@ bool Sequence::s1_cos(Instruction &instruction) {
}
bool Sequence::s1_abs(Instruction &instruction) {
- //printf("Sequence::s1_abs()\n");
+ //debugCN(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");
+ //debugCN(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");
+ //debugCN(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");
+ //debugCN(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");
+ //debugCN(kDebugScript, "Sequence::s1_floor()\n");
*instruction.argp[0] = instruction.getValue() & 0xffff0000;
return true;
}
bool Sequence::s1_round(Instruction &instruction) {
- //printf("Sequence::s1_round()\n");
+ //debugCN(kDebugScript, "Sequence::s1_round()\n");
if ((*instruction.argp[1] & 0xffff) >= 0x8000)
*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -479,7 +481,7 @@ bool Sequence::s1_round(Instruction &instruction) {
}
bool Sequence::s1_ceil(Instruction &instruction) {
- //printf("Sequence::s1_ceil()\n");
+ //debugCN(kDebugScript, "Sequence::s1_ceil()\n");
if ((*instruction.argp[1] & 0xffff) >= 0)
*instruction.argp[0] = (*instruction.argp[1] + 0x10000) & 0xffff0000;
@@ -489,19 +491,19 @@ bool Sequence::s1_ceil(Instruction &instruction) {
}
bool Sequence::s1_point(Instruction &instruction) {
- printf("Sequence::s1_point()\n");
+ debugCN(kDebugScript, "Sequence::s1_point()\n");
// TODO
return true;
}
bool Sequence::s1_dist2d(Instruction &instruction) {
- printf("Sequence::s1_dist2d()\n");
+ debugCN(kDebugScript, "Sequence::s1_dist2d()\n");
// TODO
return true;
}
bool Sequence::s1_crunch(Instruction &instruction) {
- //printf("Sequence::s1_crunch()\n");
+ //debugCN(kDebugScript, "Sequence::s1_crunch()\n");
long deltaTime;
@@ -515,12 +517,12 @@ bool Sequence::s1_crunch(Instruction &instruction) {
_startTime = _ws->getGlobal(kGlobTime);
- //printf("deltaTime = %ld\n", deltaTime >> 16); fflush(stdout);
+ //debugCN(kDebugScript, "deltaTime = %ld\n", deltaTime >> 16);
//g_system->delayMillis(5000);
if (deltaTime >= 0) {
_switchTime = _ws->getGlobal(kGlobTime) + (deltaTime >> 16);
- //printf("_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime)); fflush(stdout);
+ //debugCN(kDebugScript, "_ws->getGlobal(kGlobTime) = %ld\n", _ws->getGlobal(kGlobTime));
//g_system->delayMillis(5000);
} else {
_switchTime = -1;
@@ -532,7 +534,7 @@ bool Sequence::s1_crunch(Instruction &instruction) {
}
bool Sequence::s1_branch(Instruction &instruction) {
- //printf("Sequence::s1_branch()\n");
+ //debugCN(kDebugScript, "Sequence::s1_branch()\n");
uint32 ofs = instruction.argv[1] >> 16;
switch (instruction.argv[0] >> 16) {
@@ -569,7 +571,7 @@ bool Sequence::s1_branch(Instruction &instruction) {
}
bool Sequence::s1_setFrame(Instruction &instruction) {
- //printf("Sequence::s1_setFrame()\n");
+ //debugCN(kDebugScript, "Sequence::s1_setFrame()\n");
int32 frameIndex;
if (instruction.argc == 3) {
@@ -580,8 +582,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);
+ //debugCN(kDebugScript, "Sequence::s1_setFrame() spriteHash = %d\n", (uint32)instruction.argv[0] >> 24);
+ //debugCN(kDebugScript, "Sequence::s1_setFrame() frameIndex = %d\n", frameIndex);
SpriteAsset *spriteAsset = _ws->assets()->getSprite((uint32)instruction.argv[0] >> 24);
_curFrame = spriteAsset->getFrame(frameIndex);
@@ -590,25 +592,25 @@ bool Sequence::s1_setFrame(Instruction &instruction) {
}
bool Sequence::s1_sendMessage(Instruction &instruction) {
- printf("Sequence::s1_sendMessage()\n");
+ debugCN(kDebugScript, "Sequence::s1_sendMessage()\n");
// TODO
return true;
}
bool Sequence::s1_push(Instruction &instruction) {
- printf("Sequence::s1_push()\n");
+ debugCN(kDebugScript, "Sequence::s1_push()\n");
// TODO
return true;
}
bool Sequence::s1_pop(Instruction &instruction) {
- printf("Sequence::s1_pop()\n");
+ debugCN(kDebugScript, "Sequence::s1_pop()\n");
// TODO
return true;
}
bool Sequence::s1_jumpSub(Instruction &instruction) {
- //printf("Sequence::s1_jumpSub()\n");
+ //debugCN(kDebugScript, "Sequence::s1_jumpSub()\n");
_returnHashes[_returnStackIndex] = _sequenceHash;
_returnOffsets[_returnStackIndex] = _code->pos();
@@ -628,7 +630,7 @@ bool Sequence::s1_jumpSub(Instruction &instruction) {
}
bool Sequence::s1_return(Instruction &instruction) {
- //printf("Sequence::s1_return()\n");
+ //debugCN(kDebugScript, "Sequence::s1_return()\n");
if (_returnStackIndex <= 0)
return s1_end(instruction);
@@ -652,7 +654,7 @@ bool Sequence::s1_return(Instruction &instruction) {
}
bool Sequence::s1_getFrameCount(Instruction &instruction) {
- //printf("Sequence::s1_getFrameCount()\n");
+ //debugCN(kDebugScript, "Sequence::s1_getFrameCount()\n");
SpriteAsset *spriteAsset = _ws->assets()->getSprite(instruction.argv[1] >> 24);
*instruction.argp[0] = spriteAsset->getCount() << 16;
@@ -660,7 +662,7 @@ bool Sequence::s1_getFrameCount(Instruction &instruction) {
}
bool Sequence::s1_getFrameRate(Instruction &instruction) {
- //printf("Sequence::s1_getFrameRate()\n");
+ //debugCN(kDebugScript, "Sequence::s1_getFrameRate()\n");
SpriteAsset *spriteAsset = _ws->assets()->getSprite(instruction.argv[1] >> 24);
*instruction.argp[0] = spriteAsset->getFrameRate();
@@ -668,37 +670,37 @@ bool Sequence::s1_getFrameRate(Instruction &instruction) {
}
bool Sequence::s1_getCelsPixSpeed(Instruction &instruction) {
- printf("Sequence::s1_getCelsPixSpeed()\n");
+ debugCN(kDebugScript, "Sequence::s1_getCelsPixSpeed()\n");
// TODO
return true;
}
bool Sequence::s1_setIndex(Instruction &instruction) {
- printf("Sequence::s1_setIndex()\n");
+ debugCN(kDebugScript, "Sequence::s1_setIndex()\n");
// TODO
return true;
}
bool Sequence::s1_setLayer(Instruction &instruction) {
- printf("Sequence::s1_setLayer()\n");
+ debugCN(kDebugScript, "Sequence::s1_setLayer()\n");
//TODO
return true;
}
bool Sequence::s1_setDepth(Instruction &instruction) {
- printf("Sequence::s1_setDepth()\n");
+ debugCN(kDebugScript, "Sequence::s1_setDepth()\n");
//TODO
return true;
}
bool Sequence::s1_setData(Instruction &instruction) {
- printf("Sequence::s1_setData()\n");
+ debugCN(kDebugScript, "Sequence::s1_setData()\n");
//TODO
return true;
}
bool Sequence::s1_openStream(Instruction &instruction) {
- //printf("Sequence::s1_openStream()\n");
+ //debugCN(kDebugScript, "Sequence::s1_openStream()\n");
_stream = _vm->res()->openFile(_machine->name().c_str());
streamOpen();
@@ -706,14 +708,14 @@ bool Sequence::s1_openStream(Instruction &instruction) {
}
bool Sequence::s1_streamNextFrame(Instruction &instruction) {
- //printf("Sequence::s1_streamNextFrame()\n");
+ //debugCN(kDebugScript, "Sequence::s1_streamNextFrame()\n");
streamNextFrame();
return true;
}
bool Sequence::s1_closeStream(Instruction &instruction) {
- printf("Sequence::s1_closeStream()\n");
+ debugCN(kDebugScript, "Sequence::s1_closeStream()\n");
//TODO
return true;
}
@@ -726,8 +728,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());
- //fflush(stdout);
+ //debugCN(kDebugScript, "Sequence::streamOpen() frames = %d; max = %d x %d\n", _streamSpriteAsset->getCount(), _streamSpriteAsset->getMaxFrameWidth(), _streamSpriteAsset->getMaxFrameHeight());
_curFrame = new M4Sprite(_vm, _streamSpriteAsset->getMaxFrameWidth(), _streamSpriteAsset->getMaxFrameHeight());
streamNextFrame();