aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kernel.cpp1
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/klists.cpp63
3 files changed, 66 insertions, 0 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 76d83a615f..0351ef0ae4 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -359,6 +359,7 @@ SciKernelFunction kfunct_mappers[] = {
// SCI2.1 Kernel Functions
DEFUN("Save", kSave, ".*"),
+ DEFUN("List", kList, ".*"),
#endif
// its a stub, but its needed for Pharkas to work
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 9b3a2e9dbe..9cf39e7e7a 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -414,6 +414,8 @@ reg_t kOnMe(EngineState *s, int argc, reg_t *argv);
// SCI2.1 Kernel Functions
reg_t kSave(EngineState *s, int argc, reg_t *argv);
+reg_t kList(EngineState *s, int argc, reg_t *argv);
+
#endif
} // End of namespace Sci
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index f19cc88dac..dcee89f01a 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -632,6 +632,69 @@ reg_t kListAllTrue(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
+// In SCI2.1, all the list functions were merged in one
+reg_t kList(EngineState *s, int argc, reg_t *argv) {
+
+ switch (argv[0].toUint16()) {
+ case 0:
+ return kNewList(s, argc - 1, argv + 1);
+ case 1:
+ return kDisposeList(s, argc - 1, argv + 1);
+ case 2:
+ return kNewNode(s, argc - 1, argv + 1);
+ case 3:
+ return kFirstNode(s, argc - 1, argv + 1);
+ case 4:
+ return kLastNode(s, argc - 1, argv + 1);
+ case 5:
+ return kEmptyList(s, argc - 1, argv + 1);
+ case 6:
+ return kNextNode(s, argc - 1, argv + 1);
+ case 7:
+ return kPrevNode(s, argc - 1, argv + 1);
+ case 8:
+ return kNodeValue(s, argc - 1, argv + 1);
+ case 9:
+ return kAddAfter(s, argc - 1, argv + 1);
+ case 10:
+ return kAddToFront(s, argc - 1, argv + 1);
+ case 11:
+ return kAddToEnd(s, argc - 1, argv + 1);
+ case 12:
+ warning("kList: unimplemented subfunction kAddBefore");
+ //return kAddBefore(s, argc - 1, argv + 1);
+ return NULL_REG;
+ case 13:
+ warning("kList: unimplemented subfunction kMoveToFront");
+ //return kMoveToFront(s, argc - 1, argv + 1);
+ return NULL_REG;
+ case 14:
+ warning("kList: unimplemented subfunction kMoveToEnd");
+ //return kMoveToEnd(s, argc - 1, argv + 1);
+ return NULL_REG;
+ case 15:
+ return kFindKey(s, argc - 1, argv + 1);
+ case 16:
+ return kDeleteKey(s, argc - 1, argv + 1);
+ case 17:
+ return kListAt(s, argc - 1, argv + 1);
+ case 18:
+ return kListIndexOf(s, argc - 1, argv + 1);
+ case 19:
+ return kListEachElementDo(s, argc - 1, argv + 1);
+ case 20:
+ return kListFirstTrue(s, argc - 1, argv + 1);
+ case 21:
+ return kListAllTrue(s, argc - 1, argv + 1);
+ case 22:
+ return kSort(s, argc - 1, argv + 1);
+ default:
+ warning("kList: Unhandled case %d");
+ return NULL_REG;
+ }
+
+}
+
#endif
} // End of namespace Sci