void AGOSEngine::o_moveBox() { // 111: set hitarea xy uint hitarea_id = getVarOrWord(); uint x = getVarOrWord(); uint y = getVarOrWord(); moveBox(hitarea_id, x, y); }
void AGOSEngine_Feeble::off_screenTextBox() { // 161: setup text TextLocation *tl = getTextLocation(getVarOrByte()); tl->x = getVarOrWord(); tl->y = getVarOrWord(); tl->width = getVarOrWord(); }
void AGOSEngine::o_playTune() { // 127: play tune uint16 music = getVarOrWord(); uint16 track = getVarOrWord(); if (music != _lastMusicPlayed) { _lastMusicPlayed = music; playMusic(music, track); } }
void AGOSEngine_PuzzlePack::opp_setShortText() { // 66: set item name uint var = getVarOrByte(); uint stringId = getNextStringID(); if (var < _numTextBoxes) { _shortText[var] = stringId; _shortTextX[var] = getVarOrWord(); _shortTextY[var] = getVarOrWord(); } }
void AGOSEngine_Elvira2::oe2_drawItem() { // 113: draw item Item *i = getNextItemPtr(); int a = getVarOrByte(); int x = getVarOrWord(); int y = getVarOrWord(); mouseOff(); drawIcon(_windowArray[a % 8], itemGetIconNumber(i), x, y); mouseOn(); }
void AGOSEngine_Waxworks::oww_addTextBox() { // 65: add hit area uint id = getVarOrWord(); uint x = getVarOrWord(); uint y = getVarOrWord(); uint w = getVarOrWord(); uint h = getVarOrWord(); uint number = getVarOrByte(); if (number < _numTextBoxes) defineBox(id, x, y, w, h, (number << 8) + 129, 208, _dummyItem2); }
int AGOSEngine::runScript() { bool flag; if (shouldQuit()) return 1; do { if (DebugMan.isDebugChannelEnabled(kDebugOpcode)) dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } else { _opcode = getByte(); if (_opcode == 0xFF) return 0; } if (_runScriptReturn1) return 1; /* Invert condition? */ flag = false; if (getGameType() == GType_ELVIRA1) { if (_opcode == 203) { flag = true; _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } } else { if (_opcode == 0) { flag = true; _opcode = getByte(); if (_opcode == 0xFF) return 0; } } setScriptCondition(true); setScriptReturn(0); if (_opcode > _numOpcodes) error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); } while (getScriptCondition() != flag && !getScriptReturn() && !shouldQuit()); return (shouldQuit()) ? 1 : getScriptReturn(); }
void AGOSEngine_Simon2::os2_animate() { // 98: start vga uint16 zoneNum = getVarOrWord(); uint16 vgaSpriteId = getVarOrWord(); uint16 windowNum = getVarOrByte(); int16 x = getVarOrWord(); int16 y = getVarOrWord(); uint16 palette = (getVarOrWord() & 15); _videoLockOut |= 0x40; animate(windowNum, zoneNum, vgaSpriteId, x, y, palette); _videoLockOut &= ~0x40; }
void AGOSEngine_Simon1::os1_getPathPosn() { // 178: path find uint x = getVarOrWord(); uint y = getVarOrWord(); uint var_1 = getVarOrByte(); uint var_2 = getVarOrByte(); const uint16 *p; uint i, j; uint prev_i; uint x_diff, y_diff; uint best_i = 0, best_j = 0, best_dist = 0xFFFFFFFF; uint maxPath = (getGameType() == GType_FF || getGameType() == GType_PP) ? 100 : 20; if (getGameType() == GType_FF || getGameType() == GType_PP) { x += _scrollX; y += _scrollY; } else if (getGameType() == GType_SIMON2) { x += _scrollX * 8; } int end = (getGameType() == GType_FF) ? 9999 : 999; prev_i = maxPath + 1 - readVariable(12); for (i = maxPath; i != 0; --i) { p = (const uint16 *)_pathFindArray[maxPath - i]; if (!p) continue; for (j = 0; readUint16Wrapper(&p[0]) != end; j++, p += 2) { x_diff = ABS((int16)(readUint16Wrapper(&p[0]) - x)); y_diff = ABS((int16)(readUint16Wrapper(&p[1]) - 12 - y)); if (x_diff < y_diff) { x_diff /= 4; y_diff *= 4; } x_diff += y_diff /= 4; if ((x_diff < best_dist) || ((x_diff == best_dist) && (prev_i == i))) { best_dist = x_diff; best_i = maxPath + 1 - i; best_j = j; } } } writeVariable(var_1, best_i); writeVariable(var_2, best_j); }
void AGOSEngine_Elvira2::oe2_ifExitLocked() { // 173: if exit locked Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setScriptCondition(getExitState(i, n, d) == 3); }
void AGOSEngine_Elvira2::oe2_setExitOpen() { // 167: set exit open Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setExitState(i, n, d, 1); }
void AGOSEngine_Elvira2::oe2_setExitClosed() { // 168: set exit closed Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setExitState(i, n, d, 2); }
void AGOSEngine_Simon1::os1_animate() { // 98: animate uint16 vgaSpriteId = getVarOrWord(); uint16 windowNum = getVarOrByte(); int16 x = getVarOrWord(); int16 y = getVarOrWord(); uint16 palette = (getVarOrWord() & 15); if (getFeatures() & GF_TALKIE && vgaSpriteId >= 400) { _lastVgaWaitFor = 0; } _videoLockOut |= 0x40; animate(windowNum, vgaSpriteId / 100, vgaSpriteId, x, y, palette); _videoLockOut &= ~0x40; }
void AGOSEngine::o_chance() { // 23: chance int16 a = getVarOrWord(); if (a == 0) { setScriptCondition(false); return; } if (a == 100) { setScriptCondition(true); return; } a += _chanceModifier; if (a <= 0) { _chanceModifier = 0; setScriptCondition(false); } else if ((int16)_rnd.getRandomNumber(99) < a) { if (_chanceModifier <= 0) _chanceModifier -= 5; else _chanceModifier = 0; setScriptCondition(true); } else { if (_chanceModifier >= 0) _chanceModifier += 5; else _chanceModifier = 0; setScriptCondition(false); } }
void AGOSEngine_Simon1::os1_screenTextMsg() { // 162: print string uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); uint stringId = getNextStringID(); const byte *stringPtr = NULL; uint speechId = 0; TextLocation *tl; if (stringId != 0xFFFF) stringPtr = getStringPtrByID(stringId); if (getFeatures() & GF_TALKIE) { if (getGameType() == GType_FF || getGameType() == GType_PP) speechId = (uint16)getVarOrWord(); else speechId = (uint16)getNextWord(); } if (getGameType() == GType_FF || getGameType() == GType_PP) vgaSpriteId = 1; tl = getTextLocation(vgaSpriteId); if (_speech && speechId != 0) playSpeech(speechId, vgaSpriteId); if (((getGameType() == GType_SIMON2 && (getFeatures() & GF_TALKIE)) || getGameType() == GType_FF) && speechId == 0) { stopAnimateSimon2(2, vgaSpriteId + 2); } if (stringPtr != NULL && stringPtr[0] != 0 && (speechId == 0 || _subtitles)) printScreenText(vgaSpriteId, color, (const char *)stringPtr, tl->x, tl->y, tl->width); }
void AGOSEngine_Elvira2::oe2_setExitLocked() { // 169: set exit locked Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setExitState(i, n, d, 3); }
void AGOSEngine::o_process() { // 71: start subroutine uint16 id = getVarOrWord(); if (!_copyProtection && getGameType() == GType_WW && id == 71) { // Copy protection was disabled in Good Old Games release return; } Subroutine *sub = getSubroutineByID(id); if (sub != NULL) { #ifdef __DS__ // HACK: Skip scene of Simon reading letter from Calypso // due to speech segment been too large to fit into memory if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformWindows && sub->id == 2922) { // set parent special _noParentNotify = true; setItemParent(derefItem(16), me()); _noParentNotify = false; // set parent special _noParentNotify = true; setItemParent(derefItem(14), me()); _noParentNotify = false; // set item parent setItemParent(derefItem(12), me()); return; } #endif startSubroutine(sub); } }
void AGOSEngine_Elvira2::oe2_ifExitOpen() { // 171: if exit open Item *i = getNextItemPtr(); uint16 n = getVarOrWord(); uint16 d = getVarOrByte(); setScriptCondition(getExitState(i, n, d) == 1); }
void AGOSEngine_PuzzlePack::opp_sync() { // 120: sync uint a = getVarOrWord(); if (a == 8001 || a == 8101 || a == 8201 || a == 8301 || a == 8401) { _marks &= ~(1 << 2); } sendSync(a); }
void AGOSEngine::o_div() { // 48: div uint var = getVarWrapper(); int value = getVarOrWord(); if (value == 0) error("o_div: Division by zero"); writeVariable(var, readVariable(var) / value); }
void AGOSEngine::o_mod() { // 51: mod uint var = getVarWrapper(); int value = getVarOrWord(); if (value == 0) error("o_mod: Division by zero"); writeVariable(var, readVariable(var) % value); }
void AGOSEngine_Elvira2::oe2_setSRExit() { // 176: set super room exit Item *i = getNextItemPtr(); uint n = getVarOrWord(); uint d = getVarOrByte(); uint s = getVarOrByte(); setSRExit(i, n, d, s); }
void AGOSEngine_Simon1::os1_playEffect() { // 163: play sound uint16 soundId = getVarOrWord(); if (getGameId() == GID_SIMON1DOS) playSting(soundId); else _sound->playEffects(soundId); }
void AGOSEngine::o_waitSync() { // 119: wait vga uint var = getVarOrWord(); _scriptVar2 = (var == 200); if (var != 200 || !_skipVgaWait) waitForSync(var); _skipVgaWait = false; }
void AGOSEngine_Simon1::os1_unloadZone() { // 184: unload zone uint a = getVarOrWord(); VgaPointersEntry *vpe = &_vgaBufferPointers[a]; vpe->sfxFile = NULL; vpe->vgaFile1 = NULL; vpe->vgaFile2 = NULL; }
void AGOSEngine_Feeble::off_ifTime() { // 124: if time uint a = getVarOrWord(); uint32 t = getTime() - _gameStoppedClock - a; if (t >= _timeStore) setScriptCondition(true); else setScriptCondition(false); }
void AGOSEngine::o_add() { // 43: add uint var = getVarWrapper(); writeVariable(var, readVariable(var) + getVarOrWord()); // WORKAROUND: The conversation of the male in Vid-Phone Booth at Dave's Space Bar // is based on variable 116, but stops due to a missing option (37). if (getGameType() == GType_FF && _currentTable->id == 10538 && readVariable(116) == 37) writeVariable(116, 38); }
uint AGOSEngine::getVarOrByte() { if (getGameType() == GType_ELVIRA1) { return getVarOrWord(); } else { uint a = *_codePtr++; if (a != 255) return a; return readVariable(*_codePtr++); } }
void AGOSEngine_Simon1::os1_loadStrings() { // 185: load sound files _soundFileId = getVarOrWord(); if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_TALKIE)) { char buf[10]; sprintf(buf, "%d%s", _soundFileId, "Effects"); _sound->readSfxFile(buf); sprintf(buf, "%d%s", _soundFileId, "simon"); _sound->readVoiceFile(buf); } }
void AGOSEngine_Feeble::off_addTextBox() { // 65: add hit area uint flags = kBFTextBox | kBFBoxItem; uint id = getVarOrWord(); uint params = id / 1000; uint x, y, w, h, num; id %= 1000; if (params & 1) flags |= kBFInvertTouch; x = getVarOrWord(); y = getVarOrWord(); w = getVarOrWord(); h = getVarOrWord(); num = getVarOrByte(); if (num < _numTextBoxes) defineBox(id, x, y, w, h, flags + (num << 8), 208, _dummyItem2); }