diff options
author | Filippos Karapetis | 2010-11-18 19:18:11 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-11-18 19:18:11 +0000 |
commit | c2bdba2ea66ad6ae1d1d3c5babaafff2692f7adb (patch) | |
tree | 4ae4d09e51bb875744efd400dd802e290ec26c66 /engines/sci/engine | |
parent | e1030e53a537677c234ad39de419fb97b88a37b7 (diff) | |
download | scummvm-rg350-c2bdba2ea66ad6ae1d1d3c5babaafff2692f7adb.tar.gz scummvm-rg350-c2bdba2ea66ad6ae1d1d3c5babaafff2692f7adb.tar.bz2 scummvm-rg350-c2bdba2ea66ad6ae1d1d3c5babaafff2692f7adb.zip |
SCI2: Treat SCI2 raw arrays (type 3) as strings in kArray
SCI2 strings inherit from arrays, plus kArray and kString are almost the
same, so this is all possible. This is needed, as SCI scripts copy
strings on arrays and then process them as such (e.g. in RAMA and LSL7)
However, we really need to merge SCI2 array types with the SCI2 string
types, and ultimately merge the code with the SCI1 array and string types.
svn-id: r54340
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/klists.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index ca23469e44..0b6fac4a17 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -618,6 +618,23 @@ reg_t kMoveToEnd(EngineState *s, int argc, reg_t *argv) { } reg_t kArray(EngineState *s, int argc, reg_t *argv) { + // Use kString when accessing strings + // This is possible, as strings inherit from arrays + // and in this case (type 3) arrays are of type char *. + // kString is almost exactly the same as kArray, so + // this call is possible + // TODO: we need to either merge SCI2 strings and + // arrays together, and in the future merge them with + // the SCI1 strings and arrays in the segment manager + if (argv[0].toUint16() == 0) { + // New, check if the target type is 3 (string) + if (argv[2].toUint16() == 3) + return kString(s, argc, argv); + } else { + if (s->_segMan->getSegmentType(argv[1].segment) == SEG_TYPE_STRING) + return kString(s, argc, argv); + } + switch (argv[0].toUint16()) { case 0: { // New reg_t arrayHandle; @@ -671,12 +688,14 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { return argv[1]; } case 6: { // Cpy +#if 0 if (s->_segMan->getSegmentObj(argv[1].segment)->getType() != SEG_TYPE_ARRAY || s->_segMan->getSegmentObj(argv[3].segment)->getType() != SEG_TYPE_ARRAY) { // Happens in the RAMA demo warning("kArray(Cpy): Request to copy a segment which isn't an array, ignoring"); return NULL_REG; } +#endif SciArray<reg_t> *array1 = s->_segMan->lookupArray(argv[1]); SciArray<reg_t> *array2 = s->_segMan->lookupArray(argv[3]); @@ -702,6 +721,12 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { // Not implemented in SSCI return s->r_acc; case 8: { // Dup + if (s->_segMan->getSegmentObj(argv[1].segment)->getType() != SEG_TYPE_ARRAY) { + // Happens in the RAMA demo and LSL7 + warning("kArray(Dup): Request to duplicate a segment which isn't an array, ignoring"); + return NULL_REG; + } + reg_t arrayHandle; SciArray<reg_t> *dupArray = s->_segMan->allocateArray(&arrayHandle); // This must occur after allocateArray, as inserting a new object |