aboutsummaryrefslogtreecommitdiff
path: root/scumm/script_v2.cpp
diff options
context:
space:
mode:
authorMax Horn2003-05-04 02:10:49 +0000
committerMax Horn2003-05-04 02:10:49 +0000
commit488d5fe351d4546023770cfee3e2bd76973614c7 (patch)
treee6cd22e539cdb87ddb5f5a8aa210cbad064d0034 /scumm/script_v2.cpp
parent3b77249ab073515832eb8b2d628ba71d9fd1655c (diff)
downloadscummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.tar.gz
scummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.tar.bz2
scummvm-rg350-488d5fe351d4546023770cfee3e2bd76973614c7.zip
more v2 fixes; cleanup
svn-id: r7301
Diffstat (limited to 'scumm/script_v2.cpp')
-rw-r--r--scumm/script_v2.cpp75
1 files changed, 43 insertions, 32 deletions
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);