diff options
-rw-r--r-- | engines/agos/agos.h | 8 | ||||
-rw-r--r-- | engines/agos/contain.cpp | 29 | ||||
-rw-r--r-- | engines/agos/debug.h | 2 | ||||
-rw-r--r-- | engines/agos/items.cpp | 56 |
4 files changed, 75 insertions, 20 deletions
diff --git a/engines/agos/agos.h b/engines/agos/agos.h index a7288c2755..2937b25f90 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -928,7 +928,6 @@ public: void o_mod(); void o_modf(); void o_random(); - void o_moveDirn(); void o_goto(); void o_oset(); void o_oclear(); @@ -1041,6 +1040,10 @@ public: int sizeOfRec(Item *o, int d); int sizeRec(Item *x, int d); + int weighUp(Item *x); + int weightRec(Item *x, int d); + int weightOf(Item *x); + int canPlace(Item *x, Item *y); void xPlace(Item *x, Item *y); @@ -1058,7 +1061,9 @@ public: void oe1_copyof(); void oe1_copyfo(); void oe1_whatO(); + void oe1_weigh(); void oe1_setFF(); + void oe1_moveDirn(); void oe1_score(); void oe1_doClass(); void oe1_pobj(); @@ -1088,6 +1093,7 @@ public: void oe1_setStore(); // Opcodes, Elvira 2 only + void oe2_moveDirn(); void oe2_loadUserGame(); void oe2_setDoorOpen(); void oe2_setDoorClosed(); diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index b7950f7034..043e48feb4 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -98,4 +98,33 @@ int AGOSEngine::sizeOfRec(Item *o, int d) { return 0; } +int AGOSEngine::weighUp(Item *x) { + return weightRec(x, 0); +} + +int AGOSEngine::weightRec(Item *x, int d) { + int n = weightOf(x); + Item *o; + + if (d > 32) + return 0; + o = derefItem(x->child); + while (o) { + n += weightRec(o, d + 1); + o = derefItem(o->next); + } + + return n; +} + +int AGOSEngine::weightOf(Item *x) { + SubObject *o = (SubObject *)findChildOfType(x, 2); + SubPlayer *p = (SubPlayer *)findChildOfType(x, 3); + if (o) + return o->objectWeight; + if (p) + return p->weight; + return 0; +} + } // End of namespace AGOS diff --git a/engines/agos/debug.h b/engines/agos/debug.h index f585b841a1..096b05c2e3 100644 --- a/engines/agos/debug.h +++ b/engines/agos/debug.h @@ -101,7 +101,7 @@ static const char *const elvira1_opcodeNameTable[300] = { "WW|MOVE", "W|WHAT_O", NULL, - NULL, + "IW|WEIGH", /* 60 */ "W|SET_FF", "W|ZERO", diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 39d23ea195..5718025a13 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -209,6 +209,7 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) { op[56] = &AGOSEngine::o_copyff; op[57] = &AGOSEngine::oe1_whatO; + op[59] = &AGOSEngine::oe1_weigh; op[60] = &AGOSEngine::oe1_setFF; op[61] = &AGOSEngine::o_clear; @@ -225,7 +226,7 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) { op[74] = &AGOSEngine::o_modf; op[75] = &AGOSEngine::o_random; - op[76] = &AGOSEngine::o_moveDirn; + op[76] = &AGOSEngine::oe1_moveDirn; op[77] = &AGOSEngine::o_goto; op[80] = &AGOSEngine::o_oset; @@ -350,7 +351,7 @@ void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) { op[34] = &AGOSEngine::oe1_copyof; op[35] = &AGOSEngine::oe1_copyfo; op[37] = &AGOSEngine::oe1_whatO; - op[54] = &AGOSEngine::o_moveDirn; + op[54] = &AGOSEngine::oe2_moveDirn; op[73] = &AGOSEngine::oe1_pobj; op[74] = &AGOSEngine::oe1_pName; op[75] = &AGOSEngine::oe1_pcName; @@ -406,7 +407,7 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) { op[34] = &AGOSEngine::oe1_copyof; op[37] = &AGOSEngine::oe1_whatO; op[35] = &AGOSEngine::oe1_copyfo; - op[54] = &AGOSEngine::o_moveDirn; + op[54] = &AGOSEngine::oww_moveDirn; op[55] = &AGOSEngine::oww_goto; op[70] = &AGOSEngine::o1_printLongText; op[73] = &AGOSEngine::oe1_pobj; @@ -892,20 +893,6 @@ void AGOSEngine::o_random() { writeVariable(var, _rnd.getRandomNumber(value - 1)); } -void AGOSEngine::o_moveDirn() { - // 54: move direction - int16 d = getVarOrByte(); - - if (getGameType() == GType_WW) { - moveDirn_ww(me(), d); - } else if (getGameType() == GType_ELVIRA2) { - moveDirn_e2(me(), d); - } else { - moveDirn_e1(me(), d); - } - -} - void AGOSEngine::o_goto() { // 55: set itemA parent uint item = getNextItemID(); @@ -1867,11 +1854,23 @@ void AGOSEngine::oe1_whatO() { _objectItem = findMaster(levelOf(me()), _scriptAdj2, _scriptNoun2); } +void AGOSEngine::oe1_weigh() { + // 59: weight + Item *item = getNextItemPtr(); + writeVariable(getVarOrWord(), weighUp(item)); +} + void AGOSEngine::oe1_setFF() { // 60: set FF writeNextVarContents(0xFF); } +void AGOSEngine::oe1_moveDirn() { + // 54: move direction + int16 d = readVariable(getVarOrWord()); + moveDirn_e1(me(), d); +} + void AGOSEngine::oe1_score() { // 90: score SubPlayer *p = (SubPlayer *) findChildOfType(me(), 3); @@ -1937,7 +1936,16 @@ void AGOSEngine::oe1_cFlag() { } void AGOSEngine::oe1_means() { - // 165: TODO + // 165: means + _scriptVerb = getNextWord(); + _scriptNoun1 = getNextWord(); + _scriptNoun2 = getNextWord(); + + if (getVarOrWord()) { + int16 tmp = _scriptNoun1; + _scriptNoun1 = _scriptNoun2; + _scriptNoun2 = tmp; + } } void AGOSEngine::oe1_setUserItem() { @@ -2125,6 +2133,12 @@ void AGOSEngine::oe1_setStore() { // Elvira 2 Opcodes // ----------------------------------------------------------------------- +void AGOSEngine::oe2_moveDirn() { + // 54: move direction + int16 d = getVarOrByte(); + moveDirn_e2(me(), d); +} + void AGOSEngine::oe2_loadUserGame() { // 89: load user game getStringPtrByID(getNextStringID()); @@ -2193,6 +2207,12 @@ void AGOSEngine::oe2_getSuperRoom() { // Waxworks Opcodes // ----------------------------------------------------------------------- +void AGOSEngine::oww_moveDirn() { + // 54: move direction + int16 d = getVarOrByte(); + moveDirn_ww(me(), d); +} + void AGOSEngine::oww_goto() { // 55: set itemA parent uint item = getNextItemID(); |