diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 1 | ||||
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 41 |
3 files changed, 36 insertions, 9 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index b8385f72dc..d6c92c8e1a 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -341,7 +341,7 @@ SciKernelFunction kfunct_mappers[] = { // SCI2 Kernel Functions DEFUN("IsHiRes", kIsHiRes, ""), DEFUN("Array", kArray, ".*"), - DEFUN("ListAt", kListAt, ".*"), + DEFUN("ListAt", kListAt, "li"), DEFUN("String", kString, ".*"), DEFUN("AddScreenItem", kAddScreenItem, "o"), DEFUN("UpdateScreenItem", kUpdateScreenItem, "o"), @@ -352,6 +352,7 @@ SciKernelFunction kfunct_mappers[] = { DEFUN("RepaintPlane", kRepaintPlane, "o"), DEFUN("FrameOut", kFrameOut, ""), DEFUN("ListEachElementDo", kListEachElementDo, ".*"), + DEFUN("ListIndexOf", kListIndexOf, "lo"), DEFUN("OnMe", kOnMe, "iio.*"), // SCI2.1 Kernel Functions diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index b1c1ab738f..b7bd52eac2 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -406,6 +406,7 @@ reg_t kDeletePlane(EngineState *s, int argc, reg_t *argv); reg_t kUpdatePlane(EngineState *s, int argc, reg_t *argv); reg_t kRepaintPlane(EngineState *s, int argc, reg_t *argv); reg_t kFrameOut(EngineState *s, int argc, reg_t *argv); +reg_t kListIndexOf(EngineState *s, int argc, reg_t *argv); reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv); reg_t kOnMe(EngineState *s, int argc, reg_t *argv); diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index 513afdc67a..99b8dc8ca1 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -389,7 +389,8 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { return argv[1]; // We also have to return the handle } case 4: // Free - s->_segMan->freeArray(argv[1]); + if (!argv[1].isNull()) + s->_segMan->freeArray(argv[1]); return s->r_acc; case 5: { // Fill SciArray<reg_t> *array = s->_segMan->lookupArray(argv[1]); @@ -519,7 +520,8 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { return argv[1]; // We also have to return the handle } case 4: // Free - s->_segMan->freeString(argv[1]); + if (!argv[1].isNull()) + s->_segMan->freeString(argv[1]); return s->r_acc; case 5: { // Fill SciString *string = s->_segMan->lookupString(argv[1]); @@ -597,10 +599,10 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { // TODO: Store a formatted string in a specified string warning("kString(PrintfBuf)"); break; - case 13: // atoi - // TODO: String to integer - warning("kString(atoi)"); - break; + case 13: { // atoi + Common::String string = s->_segMan->getString(argv[1]); + return make_reg(0, (uint16)atoi(string.c_str())); + } default: error("Unknown kString subop %d", argv[0].toUint16()); } @@ -631,7 +633,8 @@ reg_t kAddScreenItem(EngineState *s, int argc, reg_t *argv) { //int16 control = 0; // HACK: just draw the view on screen - s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0); + if (viewId != 0xffff) + s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0); // TODO @@ -651,7 +654,8 @@ reg_t kUpdateScreenItem(EngineState *s, int argc, reg_t *argv) { //int16 control = 0; // HACK: just draw the view on screen - s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0); + if (viewId != 0xffff) + s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0); warning("kUpdateScreenItem, object %04x:%04x, view %d, loop %d, cel %d, pri %d", PRINT_REG(viewObj), viewId, loopNo, celNo, priority); return NULL_REG; @@ -724,6 +728,27 @@ reg_t kFrameOut(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } +reg_t kListIndexOf(EngineState *s, int argc, reg_t *argv) { + List *list = s->_segMan->lookupList(argv[0]); + + reg_t curAddress = list->first; + Node *curNode = s->_segMan->lookupNode(curAddress); + reg_t curObject; + uint16 curIndex = 0; + + while (curNode) { + curObject = curNode->value; + if (curObject == argv[1]) + return make_reg(0, curIndex); + + curAddress = curNode->succ; + curNode = s->_segMan->lookupNode(curAddress); + curIndex++; + } + + return SIGNAL_REG; +} + reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv) { List *list = s->_segMan->lookupList(argv[0]); |