aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2004-08-30 11:52:33 +0000
committerTravis Howell2004-08-30 11:52:33 +0000
commite0bb88b91cad7e753c18476df3cfbf35097c4fcf (patch)
treee0e7c56fcf1d3b088faca22fabe6af18bf4ca257 /scumm
parentd5e5c54fefc0667cd4c1a33e9e2c9d9bed18b41c (diff)
downloadscummvm-rg350-e0bb88b91cad7e753c18476df3cfbf35097c4fcf.tar.gz
scummvm-rg350-e0bb88b91cad7e753c18476df3cfbf35097c4fcf.tar.bz2
scummvm-rg350-e0bb88b91cad7e753c18476df3cfbf35097c4fcf.zip
Add some WIP code for HE games.
Add some music adjustments svn-id: r14839
Diffstat (limited to 'scumm')
-rw-r--r--scumm/charset.cpp24
-rw-r--r--scumm/charset.h1
-rw-r--r--scumm/intern.h5
-rw-r--r--scumm/script.cpp1
-rw-r--r--scumm/script_v72he.cpp64
-rw-r--r--scumm/script_v7he.cpp154
-rw-r--r--scumm/sound.cpp6
7 files changed, 192 insertions, 63 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp
index 8fbdaa79bc..1fd22ffe17 100644
--- a/scumm/charset.cpp
+++ b/scumm/charset.cpp
@@ -50,6 +50,30 @@ CharsetRenderer::CharsetRenderer(ScummEngine *vm) {
_curId = 0;
}
+int CharsetRenderer::getLetter(int letter) {
+ int offset, result;
+
+ byte *ptr = _vm->getResourceAddress(rtCharset, _curId);
+ if (!ptr)
+ error("CharsetRenderer::getLetter: charset %d not found!", _curId);
+
+ offset = READ_LE_UINT32(ptr + 29 + letter);
+ if (offset == 0)
+ return 0;
+
+ ptr += offset;
+
+ result = READ_LE_UINT16(ptr + 2);
+ byte start = *ptr;
+
+ if (result >= 0x80) {
+ result = result - 256 + start;
+ } else {
+ result += start;
+ };
+ return (result);
+}
+
void CharsetRendererCommon::setCurID(byte id) {
checkRange(_vm->_numCharsets - 1, 0, id, "Printing with bad charset %d");
diff --git a/scumm/charset.h b/scumm/charset.h
index 66c506e73c..2613c934a6 100644
--- a/scumm/charset.h
+++ b/scumm/charset.h
@@ -71,6 +71,7 @@ public:
virtual void printChar(int chr) = 0;
virtual void drawChar(int chr, const Graphics::Surface &s, int x, int y) {}
+ int getLetter(int letter);
int getStringWidth(int a, const byte *str);
void addLinebreaks(int a, byte *str, int pos, int maxwidth);
diff --git a/scumm/intern.h b/scumm/intern.h
index 249e0dc1f8..8d58fa9dc6 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -629,10 +629,12 @@ protected:
void o7_unknownEF();
void o7_readINI();
void o7_unknownF4();
+ void o7_unknownF5();
void o7_unknownF6();
void o7_unknownF9();
void o7_unknownFA();
void o7_unknownFB();
+ void o7_unknownFC();
};
class ScummEngine_v72he : public ScummEngine_v7he {
@@ -692,6 +694,7 @@ protected:
void o72_compareStackList();
void o72_unknown1C();
void o72_unknown50();
+ void o72_unknown5A();
void o72_wordArrayInc();
void o72_objectX();
void o72_objectY();
@@ -720,12 +723,12 @@ protected:
void o72_pickVarRandom();
void o72_redimArray();
void o72_readINI();
+ void o72_unknownF1();
void o72_unknownF4();
void o72_unknownF8();
void o72_unknownF9();
void o72_unknownFA();
void o72_unknownFB();
- void o72_unknownFC();
};
class ScummEngine_v7 : public ScummEngine_v6 {
diff --git a/scumm/script.cpp b/scumm/script.cpp
index f7995e68f8..c8f2ec364d 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -1065,6 +1065,7 @@ void ScummEngine::copyScriptString(byte *dst, bool override) {
while (len--)
*dst++ = fetchScriptByte();
}
+ *dst = 0;
}
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp
index 93c30836b4..ec1a914bd3 100644
--- a/scumm/script_v72he.cpp
+++ b/scumm/script_v72he.cpp
@@ -158,7 +158,7 @@ void ScummEngine_v72he::setupOpcodes() {
/* 58 */
OPCODE(o72_getTimer),
OPCODE(o72_setTimer),
- OPCODE(o6_invalid),
+ OPCODE(o72_unknown5A),
OPCODE(o72_wordArrayDec),
/* 5C */
OPCODE(o6_if),
@@ -347,7 +347,7 @@ void ScummEngine_v72he::setupOpcodes() {
OPCODE(o6_invalid),
/* F0 */
OPCODE(o6_invalid),
- OPCODE(o6_invalid),
+ OPCODE(o72_unknownF1),
OPCODE(o6_invalid),
OPCODE(o72_readINI),
/* F4 */
@@ -361,7 +361,7 @@ void ScummEngine_v72he::setupOpcodes() {
OPCODE(o72_unknownFA),
OPCODE(o72_unknownFB),
/* FC */
- OPCODE(o72_unknownFC),
+ OPCODE(o7_unknownFC),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
@@ -661,6 +661,12 @@ void ScummEngine_v72he::o72_setTimer() {
}
}
+void ScummEngine_v72he::o72_unknown5A() {
+ int value = pop();
+ push(4);
+ warning("o72_unknown5A stub (%d)", value);
+}
+
void ScummEngine_v72he::o72_wordArrayDec() {
int var = fetchScriptWord();
int base = pop();
@@ -798,6 +804,7 @@ void ScummEngine_v72he::o72_arrayOps() {
case 194: // SO_ASSIGN_STRING
array = fetchScriptWord();
len = getStackList(list, ARRAYSIZE(list));
+ pop();
ah = defineArray(array, kStringArray, 0, 0, 0, 1024);
copyScriptString(ah->data);
break;
@@ -941,15 +948,15 @@ void ScummEngine_v72he::o72_openFile() {
int mode, slot, l, r;
byte filename[100];
+ mode = pop();
copyScriptString(filename, true);
- printf("File %s\n", filename);
+ debug(1,"File %s\n", filename);
for (r = strlen((char*)filename); r != 0; r--) {
if (filename[r - 1] == '\\')
break;
}
- mode = pop();
slot = -1;
for (l = 0; l < 17; l++) {
if (_hFileTable[l].isOpen() == false) {
@@ -959,9 +966,9 @@ void ScummEngine_v72he::o72_openFile() {
}
if (slot != -1) {
- if (mode == -1)
+ if (mode == 1)
_hFileTable[slot].open((char*)filename + r, File::kFileReadMode);
- else if (mode == -2)
+ else if (mode == 2)
_hFileTable[slot].open((char*)filename + r, File::kFileWriteMode);
else
error("o6_openFile(): wrong open file mode %d", mode);
@@ -1212,21 +1219,29 @@ void ScummEngine_v72he::o72_readINI() {
int retval;
// we pretend that we don't have .ini file
+ copyScriptString(name);
type = fetchScriptByte();
switch (type) {
case 6: // number
push(0);
break;
case 7: // string
- copyScriptString(name);
defineArray(0, kStringArray, 0, 0, 0, 0);
retval = readVar(0);
writeArray(0, 0, 0, 0);
push(retval); // var ID string
break;
default:
- warning("o72_readINI(..., %d): read-ini string not implemented", type);
+ warning("o72_readINI( read-ini string not implemented", type);
}
+ debug(1, "o72_readINI (%d) %s", type, name);
+}
+
+void ScummEngine_v72he::o72_unknownF1() {
+ int a = pop();
+ int b = pop();
+ debug(1,"o7_unknownF1 stub (%d, %d)", b, a);
+ push(-1);
}
void ScummEngine_v72he::o72_unknownF4() {
@@ -1249,14 +1264,6 @@ void ScummEngine_v72he::o72_unknownF4() {
}
}
-void ScummEngine_v72he::o72_unknownFA() {
- byte name[100];
- int id = fetchScriptByte();
- copyScriptString(name);
-
- debug(1,"o72_unknownFA: (%d) %s", id, name);
-}
-
void ScummEngine_v72he::o72_unknownF8() {
int a = fetchScriptByte();
push(1);
@@ -1266,17 +1273,15 @@ void ScummEngine_v72he::o72_unknownF8() {
void ScummEngine_v72he::o72_unknownF9() {
// File related
- int r;
- byte filename[255];
-
- copyScriptString(filename);
+ warning("stub o72_unknownF9");
+}
- for (r = strlen((char*)filename); r != 0; r--) {
- if (filename[r - 1] == '\\')
- break;
- }
+void ScummEngine_v72he::o72_unknownFA() {
+ byte name[100];
+ int id = fetchScriptByte();
+ copyScriptString(name);
- warning("stub o72_unknownF9(\"%s\")", filename + r);
+ debug(1,"o72_unknownFA: (%d) %s", id, name);
}
void ScummEngine_v72he::o72_unknownFB() {
@@ -1304,11 +1309,4 @@ void ScummEngine_v72he::o72_unknownFB() {
debug(1, "o72_unknownFB stub");
}
-void ScummEngine_v72he::o72_unknownFC() {
- int a = pop();
- int b = pop();
- debug(1,"o7_unknownFC stub (%d, %d)", b, a);
- push(0);
-}
-
} // End of namespace Scumm
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index b61b6c00f3..0f04aafe30 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -352,7 +352,7 @@ void ScummEngine_v7he::setupOpcodes() {
OPCODE(o7_readINI),
/* F4 */
OPCODE(o7_unknownF4),
- OPCODE(o6_invalid),
+ OPCODE(o7_unknownF5),
OPCODE(o7_unknownF6),
OPCODE(o6_invalid),
/* F8 */
@@ -361,7 +361,7 @@ void ScummEngine_v7he::setupOpcodes() {
OPCODE(o7_unknownFA),
OPCODE(o7_unknownFB),
/* FC */
- OPCODE(o6_invalid),
+ OPCODE(o7_unknownFC),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
@@ -711,12 +711,28 @@ void ScummEngine_v7he::o7_quitPauseRestart() {
}
void ScummEngine_v7he::o7_unknownED() {
- int a, b, c;
- a = pop();
- b = pop();
- c = pop();
- push(-1);
- warning("stub o7_unknownED (%d, %d, %d)", c, b, a);
+ int array, pos, len;
+ int letter = 0, result = 0;
+
+ len = pop();
+ pos = pop();
+ array = pop();
+
+ if (len == -1) {
+ pos = 0;
+ len = resStrLen(getStringAddress(array));
+ }
+
+ writeVar(0, array);
+ while (len >= pos) {
+ letter = readArray(0, 0, pos);
+ if (letter)
+ result += _charset->getLetter(letter);
+ pos++;
+ }
+
+ push(result);
+ debug(1,"stub o7_unknownED");
}
void ScummEngine_v7he::o7_kernelSetFunctions() {
@@ -772,17 +788,48 @@ void ScummEngine_v7he::o7_stringLen() {
if (!addr)
error("o72_stringLen: Reference to zeroed array pointer (%d)", id);
- len = strlen((char *)getStringAddress(id));
+ len = resStrLen(getStringAddress(id));
push(len);
}
void ScummEngine_v7he::o7_unknownEF() {
- int a, b, c;
- a = pop();
+ int value;
+ int array, array2, len, len2, len3, offset;
+ int b, size;
+ len = pop();
b = pop();
- c = pop();
- push(1);
- warning("stub o7_unknownEF (%d, %d, %d)", c, b, a);
+ array2 = pop();
+
+ size = len - b + 2;
+
+ defineArray(0, kStringArray, 0, size);
+ writeArray(0, 0, 0, 0);
+
+ array = readVar(0);
+
+ if (len = -1) {
+ len2 = resStrLen(getStringAddress(array2));
+ len = 0;
+ } else {
+ len = b;
+ }
+ len3 = resStrLen(getStringAddress(array));
+
+ offset = 0;
+ len2 -= len;
+ len2++;
+ while (offset <= len2) {
+ writeVar(0, array2);
+ value = readArray(0, 0, offset + len);
+ writeVar(0, array);
+ writeArray(0, 0, len3 + offset, value);
+ offset++;
+ }
+
+ writeArray(0, 0, len3 + offset, 0);
+
+ push(array);
+ debug(1,"stub o7_unknownEF (array %d, array2 %d)", array, array2);
}
void ScummEngine_v7he::o7_readINI() {
@@ -805,7 +852,7 @@ void ScummEngine_v7he::o7_readINI() {
push(retval); // var ID string
break;
default:
- warning("o7_readINI(..., %d): read-ini string not implemented", type);
+ warning("o7_readINI(%d): read-ini string not implemented", type);
}
}
@@ -839,17 +886,65 @@ void ScummEngine_v7he::o7_unknownF4() {
debug(1, "o7_unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2);
break;
}
- warning("o7_unknownF4 stub");
+ debug(1,"o7_unknownF4 stub");
+}
+
+void ScummEngine_v7he::o7_unknownF5() {
+ int letter, ebx;
+ int array, len, pos, result = 0;
+ ebx = pop();
+ pos = pop();
+ array = pop();
+
+ len = resStrLen(getStringAddress(array));
+ writeVar(0, array);
+
+ while (len <= pos) {
+ letter = readArray(0, 0, pos);
+ result += _charset->getLetter(letter);
+ if (result >= ebx)
+ break;
+ pos++;
+ }
+
+ push(result);
+ debug(1,"stub o7_unknownF5");
}
void ScummEngine_v7he::o7_unknownF6() {
- int a, b, c, d;
- a = pop();
- b = pop();
- c = pop();
- d = pop();
- push(0);
- warning("stub o7_unknownF6 (%d, %d, %d, %d)", d, c, b, a);
+ int len, pos, value, array;
+ value = pop();
+ len = pop();
+ pos = pop();
+ array = pop();
+
+ if (len < 0)
+ len = resStrLen(getStringAddress(array));
+
+ if (pos < 0)
+ pos = 0;
+
+ writeVar(0, array);
+ if (len < pos) {
+ while (len < pos) {
+ if (readArray(0, 0, pos) == value) {
+ push(pos);
+ return;
+ }
+ pos--;
+ }
+ } else {
+ while (len >= pos) {
+ if (readArray(0, 0, pos) == value) {
+ push(pos);
+ return;
+ }
+ pos++;
+ }
+ }
+
+ push(-1);
+ debug(1,"stub o7_unknownF6");
}
void ScummEngine_v7he::o7_unknownF9() {
@@ -867,13 +962,13 @@ void ScummEngine_v7he::o7_unknownF9() {
break;
}
- warning("stub o7_unknownF9(\"%s\")", filename + r);
+ debug(1,"stub o7_unknownF9(\"%s\")", filename + r);
}
void ScummEngine_v7he::o7_unknownFA() {
int num = fetchScriptByte();
int len = resStrLen(_scriptPointer);
- warning("stub o7_unknownFA(%d, \"%s\")", num, _scriptPointer);
+ debug(1,"stub o7_unknownFA(%d, \"%s\")", num, _scriptPointer);
_scriptPointer += len + 1;
}
@@ -899,7 +994,14 @@ void ScummEngine_v7he::o7_unknownFB() {
pop();
break;
}
- warning("o7_unknownFB stub");
+ debug(1,"o7_unknownFB stub");
+}
+
+void ScummEngine_v7he::o7_unknownFC() {
+ int a = pop();
+ int b = pop();
+ debug(1,"o7_unknownFC (%d, %d) stub", b, a);
+ push(1);
}
} // End of namespace Scumm
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index e91e55c57b..c92af46e2a 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -754,7 +754,7 @@ int Sound::isSoundRunning(int sound) const {
} else if (sound == -1 || sound == 10000 || sound == _currentMusic) {
// getSoundStatus(), with a -1, will return the
// ID number of the first active music it finds.
- if (_currentMusic)
+ if (_vm->_heversion >= 70 || _currentMusic)
return (_musicChannelHandle.isActive()) ? 1 : 0;
else if (_vm->_imuse)
return (_vm->_imuse->getSoundStatus(sound));
@@ -834,9 +834,9 @@ void Sound::stopSound(int a) {
// Stop current sfx
} else if (a == -1 || a == 10000) {
// Stop current music
- if (_currentMusic)
+ if (_vm->_heversion >= 70 || _currentMusic)
_vm->_mixer->stopID(_currentMusic);
- else
+ else if (_vm->_imuse)
_vm->_imuse->stopSound(_vm->_imuse->getSoundStatus(-1));
}
}