[Scummvm-cvs-logs] SF.net SVN: scummvm:[54340] scummvm/trunk/engines/sci/engine/klists.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Nov 18 20:18:11 CET 2010
Revision: 54340
http://scummvm.svn.sourceforge.net/scummvm/?rev=54340&view=rev
Author: thebluegr
Date: 2010-11-18 19:18:11 +0000 (Thu, 18 Nov 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/klists.cpp
Modified: scummvm/trunk/engines/sci/engine/klists.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/klists.cpp 2010-11-18 19:12:14 UTC (rev 54339)
+++ scummvm/trunk/engines/sci/engine/klists.cpp 2010-11-18 19:18:11 UTC (rev 54340)
@@ -618,6 +618,23 @@
}
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 @@
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 @@
// 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list