diff options
author | Max Horn | 2003-05-04 02:10:49 +0000 |
---|---|---|
committer | Max Horn | 2003-05-04 02:10:49 +0000 |
commit | 488d5fe351d4546023770cfee3e2bd76973614c7 (patch) | |
tree | e6cd22e539cdb87ddb5f5a8aa210cbad064d0034 | |
parent | 3b77249ab073515832eb8b2d628ba71d9fd1655c (diff) | |
download | scummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.tar.gz scummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.tar.bz2 scummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.zip |
more v2 fixes; cleanup
svn-id: r7301
-rw-r--r-- | scumm/intern.h | 2 | ||||
-rw-r--r-- | scumm/script.cpp | 9 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 75 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 4 |
4 files changed, 47 insertions, 43 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 0d7a5798ed..1b6c1e805d 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -197,6 +197,8 @@ protected: virtual void decodeParseString(); + virtual int readVar(uint var); + virtual void ifStateCommon(byte type); virtual void ifNotStateCommon(byte type); virtual void setStateCommon(byte type); diff --git a/scumm/script.cpp b/scumm/script.cpp index 70fa45bd8c..181aad737a 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -371,11 +371,7 @@ int Scumm::readVar(uint var) { checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); - if ((_features & GF_AFTER_V2) && (var >= 14) && (var <= 16)) { - return _vars[_vars[var]]; - } else { - return _vars[var]; - } + return _vars[var]; } if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) { @@ -387,9 +383,6 @@ int Scumm::readVar(uint var) { var &= ~0x2000; } - if (!(var & 0xF000)) - return _vars[var]; - if (var & 0x8000) { if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE)) { // Emulate a wierd hack in Zak256 to read individual diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 3248150bb8..bff981c378 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -366,6 +366,42 @@ const char *Scumm_v2::getOpcodeDesc(int i) { return _opcodesV2[i].desc; } +void Scumm_v2::decodeParseString() { + byte buffer[256]; // FIXME + byte *ptr = buffer; + byte c; + while ((c = fetchScriptByte())) { + if (c & 0x80) { + *ptr++ = c & 0x7f; + *ptr++ = ' '; + } else if (c < 8) { + // Special codes as seen in CHARSET_1 etc. My guess is that they + // have a similar function as the corresponding embedded stuff in modern + // games. Hence for now we convert them to the modern format. + // This might allow us to reuse the existing code. + *ptr++ = 0xFF; + *ptr++ = c; + if (c > 3) { + *ptr++ = 0; + *ptr++ = fetchScriptByte(); + } + } else + *ptr++ = c; + } + *ptr = 0; + + printf("TODO: Scumm_v2::decodeParseString(\"%s\")\n", buffer); +} + +int Scumm_v2::readVar(uint var) { + debug(6, "readvar=%d", var); + if (var >= 14 && var <= 16) + var = _vars[var]; + + checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); + return _vars[var]; +} + void Scumm_v2::setStateCommon(byte type) { int obj = getVarOrDirectWord(0x80); putState(obj, getState(obj) | type); @@ -457,15 +493,15 @@ void Scumm_v2::o2_getObjY() { } void Scumm_v2::o2_setBitVar() { - byte hi = fetchScriptByte(); byte lo = fetchScriptByte(); + byte hi = fetchScriptByte(); byte a = getVarOrDirectByte(0x80); int bit_var = (hi << 8) + lo + a; int bit_offset = bit_var & 0x0f; bit_var >>= 4; - if (getVarOrDirectByte(0x80)) + if (getVarOrDirectByte(0x40)) _vars[bit_var] |= (1 << bit_offset); else _vars[bit_var] &= ~(1 << bit_offset); @@ -473,8 +509,8 @@ void Scumm_v2::o2_setBitVar() { void Scumm_v2::o2_getBitVar() { getResultPos(); - byte hi = fetchScriptByte(); byte lo = fetchScriptByte(); + byte hi = fetchScriptByte(); byte a = getVarOrDirectByte(0x80); int bit_var = (hi << 8) + lo + a; @@ -561,12 +597,12 @@ void Scumm_v2::o2_actorSet() { Actor *a = derefActorSafe(act, "actorSet"); int i; + _opcode = fetchScriptByte(); if (!a) { - fetchScriptByte(); return; } - switch (fetchScriptByte()) { + switch (_opcode) { case 1: // Actor Sound a->sound[0] = arg; break; @@ -588,6 +624,8 @@ void Scumm_v2::o2_actorSet() { case 5: // Talk Color a->talkColor = arg; break; + default: + warning("o2_actorSet: opcode %d not yet supported", _opcode); } } @@ -832,33 +870,6 @@ void Scumm_v2::o2_doSentence() { } } -void Scumm_v2::decodeParseString() { - byte buffer[256]; // FIXME - byte *ptr = buffer; - byte c; - while ((c = fetchScriptByte())) { - if (c & 0x80) { - *ptr++ = c & 0x7f; - *ptr++ = ' '; - } else if (c < 8) { - // Special codes as seen in CHARSET_1 etc. My guess is that they - // have a similar function as the corresponding embedded stuff in modern - // games. Hence for now we convert them to the modern format. - // This might allow us to reuse the existing code. - *ptr++ = 0xFF; - *ptr++ = c; - if (c > 3) { - *ptr++ = 0; - *ptr++ = fetchScriptByte(); - } - } else - *ptr++ = c; - } - *ptr = 0; - - printf("TODO: Scumm_v2::decodeParseString(\"%s\")\n", buffer); -} - void Scumm_v2::o2_ifClassOfIs() { int act = getVarOrDirectWord(0x80); int clsop = getVarOrDirectByte(0x40); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 3ae999289d..d8c7c7f0cf 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1746,9 +1746,7 @@ Actor *Scumm::derefActor(int id) { Actor *Scumm::derefActorSafe(int id, const char *errmsg) { if (id < 1 || id >= NUM_ACTORS) { - if (_debugLevel > 1) - warning - ("Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.", + debug(2, "Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.", id, errmsg, vm.slot[_curExecScript].number, _opcode); return NULL; } |