From 415ec670564a328a67648ddae7c42a7142a2f053 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 6 Nov 2006 13:59:11 +0000 Subject: Cleanup svn-id: r24639 --- engines/agos/agos.h | 11 +++++---- engines/agos/contain.cpp | 2 +- engines/agos/rooms.cpp | 22 ++++++++--------- engines/agos/script.cpp | 60 ++++++++++++++++++++-------------------------- engines/agos/script_e1.cpp | 6 ++--- engines/agos/script_ff.cpp | 11 ++++++++- engines/agos/script_s1.cpp | 8 ++++++- engines/agos/script_s2.cpp | 22 ++++++++++++++++- engines/agos/window.cpp | 7 ++++++ 9 files changed, 92 insertions(+), 57 deletions(-) (limited to 'engines/agos') diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 8eef317f22..72dd9984fb 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -666,8 +666,6 @@ protected: void waitForSync(uint a); uint getOffsetOfChild2Param(SubObject *child, uint prop); - void setTextColor(uint color); - void scriptMouseOn(); void scriptMouseOff(); void freezeBottom(); void unfreezeBottom(); @@ -685,8 +683,8 @@ protected: void setDoorState(Item *i, uint16 d, uint16 n); // Elvira 1 specific - uint16 getDoorOf(Item *item, uint16 d); - uint16 getExitOf_e1(Item *item, uint16 d); + Item *getDoorOf(Item *item, uint16 d); + Item *getExitOf_e1(Item *item, uint16 d); void moveDirn_e1(Item *i, uint x); // Elvira 2 specific @@ -778,6 +776,7 @@ protected: void clearWindow(WindowBlock *window); void changeWindow(uint a); void closeWindow(uint a); + void setTextColor(uint color); void windowPutChar(WindowBlock *window, byte c, byte b = 0); HitArea *findBox(uint hitarea_id); @@ -1133,6 +1132,8 @@ public: void oe1_printPlayerHit(); void oe1_printMonsterHit(); + void synchChain(Item *i); + // Opcodes, Elvira 2 void oe2_moveDirn(); void oe2_doClass(); @@ -1218,6 +1219,7 @@ public: void os2_stopAnimate(); void os2_playTune(); void os2_screenTextPObj(); + void os2_mouseOn(); void os2_mouseOff(); void os2_isShortText(); void os2_clearMarks(); @@ -1243,6 +1245,7 @@ public: void off_hyperLinkOff(); void off_checkPaths(); void off_screenTextPObj(); + void off_mouseOn(); void off_mouseOff(); void off_loadVideo(); void off_playVideo(); diff --git a/engines/agos/contain.cpp b/engines/agos/contain.cpp index 86d70c32cf..0362580e11 100644 --- a/engines/agos/contain.cpp +++ b/engines/agos/contain.cpp @@ -81,7 +81,7 @@ int AGOSEngine::canPlace(Item *x, Item *y) { } void AGOSEngine::xPlace(Item *x, Item *y) { - if (x->parent != 0) + if (derefItem(x->parent)) unlinkItem(x); linkItem(x, y); diff --git a/engines/agos/rooms.cpp b/engines/agos/rooms.cpp index 3612a63d15..bd66d43722 100644 --- a/engines/agos/rooms.cpp +++ b/engines/agos/rooms.cpp @@ -124,7 +124,7 @@ void AGOSEngine::setDoorState(Item *i, uint16 d, uint16 n) { } // Elvira 1 specific -uint16 AGOSEngine::getDoorOf(Item *i, uint16 d) { +Item *AGOSEngine::getDoorOf(Item *i, uint16 d) { SubGenExit *g; Item *x; @@ -137,10 +137,10 @@ uint16 AGOSEngine::getDoorOf(Item *i, uint16 d) { return 0; if (isRoom(x)) return 0; - return itemPtrToID(x); + return x; } -uint16 AGOSEngine::getExitOf_e1(Item *item, uint16 d) { +Item *AGOSEngine::getExitOf_e1(Item *item, uint16 d) { SubGenExit *g; Item *x; @@ -152,24 +152,22 @@ uint16 AGOSEngine::getExitOf_e1(Item *item, uint16 d) { if (x == NULL) return 0; if (isRoom(x)) - return itemPtrToID(x); + return x; if (x->state != 0) return 0; - return x->parent; + return derefItem(x->parent); } void AGOSEngine::moveDirn_e1(Item *i, uint x) { Item *d, *p; - uint16 n; - if (i->parent == 0) + p = derefItem(i->parent); + if (p == 0) return; - p = derefItem(i->parent); - n = getExitOf_e1(p, x); - d = derefItem(n); - if (n) { + d = getExitOf_e1(p, x); + if (d) { if (canPlace(i, d)) return; @@ -177,7 +175,7 @@ void AGOSEngine::moveDirn_e1(Item *i, uint x) { return; } - d = derefItem(getDoorOf(p, x)); + d = getDoorOf(p, x); if (d) { const byte *name = getStringPtrByID(d->itemName); if (d->state == 1) diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 3f7b99f96b..c79f0b9902 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -481,15 +481,19 @@ void AGOSEngine::o_putBy() { void AGOSEngine::o_inc() { // 59: item inc state Item *item = getNextItemPtr(); - if (item->state <= 30000) + if (item->state <= 30000) { setItemState(item, item->state + 1); + synchChain(item); + } } void AGOSEngine::o_dec() { // 60: item dec state Item *item = getNextItemPtr(); - if (item->state >= 0) + if (item->state >= 0) { setItemState(item, item->state - 1); + synchChain(item); + } } void AGOSEngine::o_setState() { @@ -501,6 +505,7 @@ void AGOSEngine::o_setState() { if (value > 30000) value = 30000; setItemState(item, value); + synchChain(item); } void AGOSEngine::o_print() { @@ -810,9 +815,13 @@ void AGOSEngine::o_doClassIcons() { // 126: do class icons Item *item = getNextItemPtr(); uint num = getVarOrByte(); - uint a = 1 << getVarOrByte(); + uint a = getVarOrByte(); + mouseOff(); - drawIconArray(num, item, 1, a); + if (getGameType() == GType_ELVIRA1) + drawIconArray(num, item, 0, a); + else + drawIconArray(num, item, 0, 1 << a); mouseOn(); } @@ -1085,20 +1094,22 @@ int AGOSEngine::runScript() { return getScriptReturn(); } -void AGOSEngine::scriptMouseOn() { - if ((getGameType() == GType_FF || getGameType() == GType_PP) && _mouseCursor != 5) { - resetVerbs(); - _noRightClick = 0; - } else if (getGameType() == GType_SIMON2 && getBitFlag(79)) { - _mouseCursor = 0; +Child *nextSub(Child *sub, int16 key) { + Child *a = sub->next; + while (a) { + if (a->type == key) + return a; + a = a->next; } - _mouseHideCount = 0; + return NULL; } -void AGOSEngine::scriptMouseOff() { - _lockWord |= 0x8000; - vc34_setMouseOff(); - _lockWord &= ~0x8000; +void AGOSEngine::synchChain(Item *i) { + SubUserChain *c = (SubUserChain *)findChildOfType(i, 8); + while (c) { + setItemState(derefItem(c->chChained), i->state); + c = (SubUserChain *)nextSub((Child *)c, 8); + } } void AGOSEngine::sendSync(uint a) { @@ -1109,13 +1120,6 @@ void AGOSEngine::sendSync(uint a) { _lockWord &= ~0x8000; } -void AGOSEngine::setTextColor(uint color) { - WindowBlock *window; - - window = _windowArray[_curWindow]; - window->text_color = color; -} - void AGOSEngine::stopAnimate(uint a) { uint16 b = to16Wrapper(a); _lockWord |= 0x8000; @@ -1124,18 +1128,6 @@ void AGOSEngine::stopAnimate(uint a) { _lockWord &= ~0x8000; } -void AGOSEngine::stopAnimateSimon2(uint a, uint b) { - uint16 items[2]; - - items[0] = to16Wrapper(a); - items[1] = to16Wrapper(b); - - _lockWord |= 0x8000; - _vcPtr = (byte *)&items; - vc60_stopAnimation(); - _lockWord &= ~0x8000; -} - void AGOSEngine::waitForSync(uint a) { const uint maxCount = (getGameType() == GType_SIMON1) ? 500 : 1000; diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index 4e95bc6555..42d86fe18a 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -436,9 +436,9 @@ void AGOSEngine::oe1_whereTo() { int16 f = getVarOrWord(); if (f == 1) - _subjectItem = derefItem(getExitOf_e1(i, d)); + _subjectItem = getExitOf_e1(i, d); else - _objectItem = derefItem(getExitOf_e1(i, d)); + _objectItem = getExitOf_e1(i, d); } void AGOSEngine::oe1_doorExit() { @@ -455,7 +455,7 @@ void AGOSEngine::oe1_doorExit() { if (c) a = derefItem(c->chChained); while (ct < 6) { - x = derefItem(getDoorOf(i, ct)); + x = getDoorOf(i, ct); if ((x == d) | (x == a)) { writeVariable(f, ct); return; diff --git a/engines/agos/script_ff.cpp b/engines/agos/script_ff.cpp index 9af80c7c19..a4bdc85c16 100644 --- a/engines/agos/script_ff.cpp +++ b/engines/agos/script_ff.cpp @@ -67,7 +67,7 @@ void AGOSEngine::setupFeebleOpcodes(OpcodeProc *op) { op[177] = &AGOSEngine::off_screenTextPObj; op[178] = &AGOSEngine::os1_getPathPosn; op[179] = &AGOSEngine::os1_scnTxtLongText; - op[180] = &AGOSEngine::os1_mouseOn; + op[180] = &AGOSEngine::off_mouseOn; op[181] = &AGOSEngine::off_mouseOff; op[182] = &AGOSEngine::off_loadVideo; op[183] = &AGOSEngine::off_playVideo; @@ -336,6 +336,15 @@ void AGOSEngine::off_screenTextPObj() { } } +void AGOSEngine::off_mouseOn() { + // 180: force mouseOn + if (_mouseCursor != 5) { + resetVerbs(); + _noRightClick = 0; + } + _mouseHideCount = 0; +} + void AGOSEngine::off_mouseOff() { // 181: force mouseOff scriptMouseOff(); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index ca0be02f4b..acc8ad64be 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -267,7 +267,7 @@ void AGOSEngine::os1_scnTxtLongText() { void AGOSEngine::os1_mouseOn() { // 180: force mouseOn - scriptMouseOn(); + _mouseHideCount = 0; } void AGOSEngine::os1_mouseOff() { @@ -340,4 +340,10 @@ void AGOSEngine::os1_specialFade() { memcpy(_displayPalette, _videoBuf1, 1024); } +void AGOSEngine::scriptMouseOff() { + _lockWord |= 0x8000; + vc34_setMouseOff(); + _lockWord &= ~0x8000; +} + } // End of namespace AGOS diff --git a/engines/agos/script_s2.cpp b/engines/agos/script_s2.cpp index f5bde3f506..f27ad9d139 100644 --- a/engines/agos/script_s2.cpp +++ b/engines/agos/script_s2.cpp @@ -54,7 +54,7 @@ void AGOSEngine::setupSimon2Opcodes(OpcodeProc *op) { op[177] = &AGOSEngine::os2_screenTextPObj; op[178] = &AGOSEngine::os1_getPathPosn; op[179] = &AGOSEngine::os1_scnTxtLongText; - op[180] = &AGOSEngine::os1_mouseOn; + op[180] = &AGOSEngine::os2_mouseOn; op[181] = &AGOSEngine::os2_mouseOff; op[184] = &AGOSEngine::os1_unloadZone; op[186] = &AGOSEngine::os1_unfreezeZones; @@ -215,6 +215,14 @@ void AGOSEngine::os2_screenTextPObj() { } } +void AGOSEngine::os2_mouseOn() { + // 180: force mouseOn + if (getGameType() == GType_SIMON2 && getBitFlag(79)) { + _mouseCursor = 0; + } + _mouseHideCount = 0; +} + void AGOSEngine::os2_mouseOff() { // 181: force mouseOff scriptMouseOff(); @@ -241,6 +249,18 @@ void AGOSEngine::os2_waitMark() { waitForMark(i); } +void AGOSEngine::stopAnimateSimon2(uint a, uint b) { + uint16 items[2]; + + items[0] = to16Wrapper(a); + items[1] = to16Wrapper(b); + + _lockWord |= 0x8000; + _vcPtr = (byte *)&items; + vc60_stopAnimation(); + _lockWord &= ~0x8000; +} + void AGOSEngine::waitForMark(uint i) { _exitCutscene = false; while (!(_marks & (1 << i))) { diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index 6008973083..51aabe9233 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -184,6 +184,13 @@ void AGOSEngine::restoreBlock(uint h, uint w, uint y, uint x) { } } +void AGOSEngine::setTextColor(uint color) { + WindowBlock *window; + + window = _windowArray[_curWindow]; + window->text_color = color; +} + void AGOSEngine::windowPutChar(uint a) { if (_textWindow != _windowArray[0]) windowPutChar(_textWindow, a); -- cgit v1.2.3