void AGOSEngine_Feeble::resetVerbs() { _verbHitArea = 300; int cursor = 0; int animMax = 16; if (getBitFlag(203)) { cursor = 14; animMax = 9; } else if (getBitFlag(204)) { cursor = 15; animMax = 9; } else if (getBitFlag(207)) { cursor = 26; animMax = 2; } _mouseCursor = cursor; _mouseAnimMax = animMax; _mouseAnim = 1; _needHitAreaRecalc++; if (getBitFlag(99)) { setVerb(NULL); } }
void AGOSEngine::centerScroll() { int16 x, y, tmp; if (_scrollXMax != 0) { _scrollCount = 0; x = _variableArray[15] - _scrollX; if (x < 17 || (getBitFlag(85) && x < 320)) { x -= 320; if (_scrollX < -x) x = -_scrollX; _scrollCount = x; } else if ((getBitFlag(85) && x >= 320) || x >= 624) { x -= 320; tmp = _scrollXMax - _scrollX; if (tmp < x) x = tmp; _scrollCount = x; } } else if (_scrollYMax != 0) { _scrollCount = 0; y = _variableArray[16] - _scrollY; if (y < 30) { y -= 240; if (_scrollY < -y) y = -_scrollY; _scrollCount = y; } else if (y >= 460) { y -= 240; tmp = _scrollYMax - _scrollY; if (tmp < y) y = tmp; _scrollCount = y; } } }
void AGOSEngine_Feeble::doOutput(const byte *src, uint len) { if (_textWindow == NULL) return; while (len-- != 0 && !shouldQuit()) { if (getBitFlag(93)) { if (_curWindow == 3) { if ((_newLines >= _textWindow->scrollY) && (_newLines < (_textWindow->scrollY + 3))) sendWindow(*src); if (*src == '\n') // Do two top lines of text only _newLines++; src++; } } else { if (getBitFlag(94)) { if (_curWindow == 3) { if (_newLines == (_textWindow->scrollY + 7)) sendWindow(*src); if (*src == '\n') // Do two top lines of text only _newLines++; src++; } } else { if (getBitFlag(92)) delay(50); sendWindow(*src++); } } } }
void AGOSEngine_Feeble::setVerb(HitArea *ha) { int cursor = _mouseCursor; if (_noRightClick) return; if (cursor > 13) cursor = 0; cursor++; if (cursor == 5) cursor = 1; if (cursor == 4) { if (getBitFlag(72)) { cursor = 1; } } else if (cursor == 2) { if (getBitFlag(99)) { cursor = 3; } } _mouseCursor = cursor; _mouseAnimMax = (cursor == 4) ? 14: 16; _mouseAnim = 1; _needHitAreaRecalc++; _verbHitArea = cursor + 300; }
void AGOSEngine_Feeble::windowNewLine(WindowBlock *window) { if (_noOracleScroll == 0) { if (window->height < window->textRow + 30) { if (!getBitFlag(94)) { _noOracleScroll = 1; if (getBitFlag(92)) { _noOracleScroll = 0; checkLinkBox(); scrollOracle(); linksUp(); window->scrollY++; _oracleMaxScrollY++; } else { _oracleMaxScrollY++; checkLinkBox(); } } } else { window->textRow += 15; checkLinkBox(); } } else { _oracleMaxScrollY++; checkLinkBox(); } window->textColumn = 0; window->textColumnOffset = 0; window->textLength = 0; }
void AGOSEngine_Simon2::playSpeech(uint16 speech_id, uint16 vgaSpriteId) { if (speech_id == 0xFFFF) { if (_subtitles) return; if (!getBitFlag(14) && !getBitFlag(28)) { setBitFlag(14, true); _variableArray[100] = 5; animate(4, 1, 30, 0, 0, 0); waitForSync(130); } _skipVgaWait = true; } else { if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HE_ISR) { loadVoice(speech_id); return; } if (_subtitles && _scriptVar2) { animate(4, 2, 5, 0, 0, 0); waitForSync(205); stopAnimateSimon2(2,5); } stopAnimateSimon2(2, vgaSpriteId + 2); loadVoice(speech_id); animate(4, 2, vgaSpriteId + 2, 0, 0, 0); } }
void AGOSEngine_Simon1::playSpeech(uint16 speech_id, uint16 vgaSpriteId) { if (speech_id == 9999) { if (_subtitles) return; if (!getBitFlag(14) && !getBitFlag(28)) { setBitFlag(14, true); _variableArray[100] = 15; animate(4, 1, 130, 0, 0, 0); waitForSync(130); } _skipVgaWait = true; } else { if (_subtitles && _scriptVar2) { animate(4, 2, 204, 0, 0, 0); waitForSync(204); stopAnimate(204); } if (vgaSpriteId < 100) stopAnimate(201 + vgaSpriteId); loadVoice(speech_id); if (vgaSpriteId < 100) animate(4, 2, 201 + vgaSpriteId, 0, 0, 0); } }
void AGOSEngine_Feeble::drawMousePointer() { uint cursor; int image, offs; if (_animatePointer) { if (getBitFlag(99)) { _mouseToggle = !_mouseToggle; if (_mouseToggle) _mouseAnim++; } else { _mouseAnim++; } if (_mouseAnim == _mouseAnimMax) _mouseAnim = 1; } cursor = _mouseCursor; if (!_animatePointer && getBitFlag(99)) { _mouseAnim = 1; cursor = 6; } else if (_mouseCursor != 5 && getBitFlag(72)) { cursor += 7; } if (cursor != _currentMouseCursor || _mouseAnim != _currentMouseAnim) { _currentMouseCursor = cursor; _currentMouseAnim = _mouseAnim; memset(_mouseData, 0, _maxCursorWidth * _maxCursorHeight); image = cursor * 16 + 1; offs = cursor * 32; drawMousePart(image, _mouseOffs[offs], _mouseOffs[offs + 1]); image = cursor * 16 + 1 + _mouseAnim; offs = cursor * 32 + _mouseAnim * 2; drawMousePart(image, _mouseOffs[offs], _mouseOffs[offs + 1]); int hotspotX = 19; int hotspotY = 19; if (_mouseCursor == 14) { // Finger pointing away from screen. Not sure where // this is used. hotspotX += 4; hotspotY -= 6; } else if (_mouseCursor == 15) { // Finger pointing down. Used for the oh-so-annoying // Cygnus Alpha tile puzzle. hotspotY += 18; } CursorMan.replaceCursor(_mouseData, _maxCursorWidth, _maxCursorHeight, hotspotX, hotspotY, 0); } }
void AGOSEngine::waitForSync(uint a) { const uint maxCount = (getGameType() == GType_SIMON1) ? 1000 : 2500; if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE)) { if (a != 200) { uint16 tmp = _lastVgaWaitFor; _lastVgaWaitFor = 0; if (tmp == a) return; } } _vgaWaitFor = a; _syncCount = 0; _exitCutscene = false; _rightButtonDown = false; while (_vgaWaitFor != 0 && !shouldQuit()) { if (_rightButtonDown) { if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) { skipSpeech(); break; } } if (_exitCutscene) { if (getGameType() == GType_ELVIRA1) { if (_variableArray[105] == 0) { _variableArray[105] = 255; break; } } else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) { if (_vgaWaitFor == 51) { setBitFlag(244, 1); break; } } else { if (getBitFlag(9)) { endCutscene(); break; } } } processSpecialKeys(); if (_syncCount >= maxCount) { warning("waitForSync: wait timed out"); break; } delay(1); } }
void AGOSEngine_Feeble::timerProc() { if (_videoLockOut & 0x80E9 || _videoLockOut & 2) return; _syncCount++; _videoLockOut |= 2; if (!(_videoLockOut & 0x10)) { _syncFlag2 = !_syncFlag2; if (!_syncFlag2) { processVgaEvents(); } else { // Double speed on Oracle if (getGameType() == GType_FF && getBitFlag(99)) { processVgaEvents(); } else if (_scrollCount == 0) { _videoLockOut &= ~2; return; } } if (getGameType() == GType_FF && _interactiveVideo) { // Controls Omni TV videos if (getBitFlag(42)) { stopInteractiveVideo(); } else { _moviePlayer->nextFrame(); } } animateSprites(); } if (_displayFlag) { if (getGameType() == GType_FF && !(getFeatures() & GF_DEMO)) { if (!getBitFlag(78)) { oracleLogo(); } if (getBitFlag(76)) { swapCharacterLogo(); } } handleMouseMoved(); displayScreen(); _displayFlag = 0; } _videoLockOut &= ~2; }
void AGOSEngine_PuzzlePack::vc63_fastFadeIn() { _fastFadeInFlag = 256; _fastFadeOutFlag = false; if (getGameId() == GID_DIMP) return; if (getBitFlag(100)) { startOverlayAnims(); } else if (getBitFlag(103)) { debug("vc63_fastFadeIn: NameAndTime"); } else if (getBitFlag(104)) { debug("vc63_fastFadeIn: HiScoreTable"); } }
bool SimonEngine::printTextOf(uint a, uint x, uint y) { const byte *stringPtr; uint16 pixels, w; if (getGameType() == GType_SIMON2) { if (getBitFlag(79)) { Subroutine *sub; _variableArray[84] = a; sub = getSubroutineByID(5003); if (sub != NULL) startSubroutineEx(sub); return true; } } if (a >= _numTextBoxes) return false; stringPtr = getStringPtrByID(_stringIdArray2[a]); if (getGameType() == GType_FF) { getPixelLength((const char *)stringPtr, 400, pixels); w = pixels + 1; x -= w / 2; printScreenText(6, 0, (const char *)stringPtr, x, y, w); } else { showActionString(stringPtr); } return true; }
void AGOSEngine_Feeble::oracleTextDown() { Subroutine *sub; int i = 0; changeWindow(3); _noOracleScroll = 0; if (_textWindow->scrollY > _oracleMaxScrollY) // For scroll up _oracleMaxScrollY = _textWindow->scrollY; while (1) { if (_textWindow->scrollY == 0) break; for (i = 0; i < 5; i++) { _newLines = 0; _textWindow->textColumn = 0; _textWindow->textRow = (i + 1) * 3; if (i == 4) { _textWindow->scrollY -= 1; _textWindow->textRow = 0; linksDown(); } scrollOracleDown(); setBitFlag(93, true); sub = getSubroutineByID(_variableArray[104]); if (sub) startSubroutineEx(sub); setBitFlag(93, false); } if (_currentBoxNum != 600 || !getBitFlag(89)) break; delay(100); } }
void AGOSEngine_Feeble::animateSprites() { VgaSprite *vsp; VgaPointersEntry *vpe; if (_paletteFlag == 2) _paletteFlag = 1; if (_scrollCount) { scrollEvent(); } if (getBitFlag(84)) { animateSpritesByY(); return; } vsp = _vgaSprites; while (vsp->id) { vsp->windowNum &= ~0x8000; vpe = &_vgaBufferPointers[vsp->zoneNum]; _curVgaFile1 = vpe->vgaFile1; _curVgaFile2 = vpe->vgaFile2; _curSfxFile = vpe->sfxFile; _windowNum = vsp->windowNum; _vgaCurSpriteId = vsp->id; _vgaCurSpritePriority = vsp->priority; drawImage_init(vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags); vsp++; } _displayFlag++; }
void AGOSEngine_Simon2::os2_mouseOn() { // 180: force mouseOn if (getGameType() == GType_SIMON2 && getBitFlag(79)) { _mouseCursor = 0; } _mouseHideCount = 0; }
void AGOSEngine::resetVerbs() { if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) return; uint id; HitArea *ha; if (getGameType() == GType_SIMON2) { id = 2; if (!getBitFlag(79)) id = (_mouse.y >= 136) ? 102 : 101; } else { id = (_mouse.y >= 136) ? 102 : 101; } _defaultVerb = id; ha = findBox(id); if (ha == NULL) return; if (ha->flags & kBFBoxDead) { _defaultVerb = 999; _currentVerbBox = NULL; } else { _verbHitArea = ha->verb; setVerb(ha); } }
void AGOSEngine_Feeble::hyperLinkOn(uint16 x) { if (!getBitFlag(51)) return; _hyperLink = x; _variableArray[50] = _textWindow->textColumn + _textWindow->x; _variableArray[51] = _textWindow->textRow + _textWindow->y + (_oracleMaxScrollY - _textWindow->scrollY) * 15; }
void AGOSEngine_PuzzlePack::vc3_loadSprite() { if (getGameId() != GID_DIMP && getBitFlag(100)) { startAnOverlayAnim(); return; } AGOSEngine::vc3_loadSprite(); }
void AGOSEngine_Feeble::hyperLinkOff() { if (!getBitFlag(51)) return; _variableArray[52] = _textWindow->x + _textWindow->textColumn - _variableArray[50]; defineBox(_variableArray[53], _variableArray[50], _variableArray[51], _variableArray[52], 15, 145, 208, _dummyItem2); _variableArray[53]++; _hyperLink = 0; }
void AGOSEngine_Simon2::clearName() { if (getBitFlag(79)) { sendSync(202); _lastNameOn = NULL; return; } AGOSEngine_Simon1::clearName(); }
void AGOSEngine::writeVariable(uint16 variable, uint16 contents) { if (variable >= _numVars) error("writeVariable: Variable %d out of range", variable); if (getGameType() == GType_FF && getBitFlag(83)) _variableArray2[variable] = contents; else _variableArray[variable] = contents; }
void AGOSEngine::displayName(HitArea *ha) { if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_PP) return; bool result; int x = 0, y = 0; if (getGameType() == GType_FF) { if (ha->flags & kBFHyperBox) { _lastNameOn = ha; return; } if (findBox(50)) return; if (getBitFlag(99)) _animatePointer = ((ha->flags & kBFTextBox) == 0); else _animatePointer = true; if (!getBitFlag(73)) return; y = ha->y; if (getBitFlag(99) && y > 288) y = 288; y -= 17; if (y < 0) y = 0; y += 2; x = ha->width / 2 + ha->x; } else { resetNameWindow(); } if (ha->flags & kBFTextBox) { result = printTextOf(ha->flags / 256, x, y); } else { result = printNameOf(ha->itemPtr, x, y); } if (result) _lastNameOn = ha; }
void AGOSEngine_Feeble::off_resetPVCount() { // 191 if (getBitFlag(83)) { _PVCount1 = 0; _GPVCount1 = 0; } else { _PVCount = 0; _GPVCount = 0; } }
void AGOSEngine_Feeble::invertBox(HitArea *ha, bool state) { if (getBitFlag(205) || getBitFlag(206)) { if (state != 0) { _mouseAnimMax = _oldMouseAnimMax; _mouseCursor = _oldMouseCursor; } else if (_mouseCursor != 18) { _oldMouseCursor = _mouseCursor; _animatePointer = false; _oldMouseAnimMax = _mouseAnimMax; _mouseAnimMax = 2; _mouseCursor = 18; } } else { if (getBitFlag(207)) { if (state != 0) { _noRightClick = 0; resetVerbs(); } else { int cursor = ha->id + 9; if (cursor >= 23) cursor = 21; _mouseCursor = cursor; _mouseAnimMax = 8; _noRightClick = 1; } } else { VgaSprite *vsp = _vgaSprites; int id = ha->id - 43; while (vsp->id) { if (vsp->id == id && vsp->zoneNum == 2) { if (state == 0) vsp->flags |= kDFShaded; else vsp->flags &= ~kDFShaded; break; } vsp++; } } } }
void AGOSEngine_Elvira2::oe2_bNotZero() { // 156: is bit set uint bit = getVarWrapper(); // WORKAROUND: Enable copy protection again, in cracked version. if (getGameType() == GType_SIMON1 && _currentTable && _currentTable->id == 2962 && bit == 63) { bit = 50; } setScriptCondition(getBitFlag(bit)); }
void AGOSEngine_PuzzlePack::opp_message() { // 63: show string nl if (getBitFlag(105)) { // Swampy adventures getStringPtrByID(getNextStringID()); // printInfoText(getStringPtrByID(getNextStringID())); } else { showMessageFormat("%s\n", getStringPtrByID(getNextStringID())); } }
// Scrolling functions for Feeble Files void AGOSEngine::checkScrollX(int16 x, int16 xpos) { if (_scrollXMax == 0 || x == 0) return; if (getGameType() == GType_FF && (getBitFlag(80) || getBitFlag(82))) return; int16 tmp; if (x > 0) { if (_scrollCount != 0) { if (_scrollCount >= 0) return; _scrollCount = 0; } else { if (_scrollFlag != 0) return; } if (xpos - _scrollX >= 480) { _scrollCount = 320; tmp = _scrollXMax - _scrollX; if (tmp < 320) _scrollCount = tmp; } } else { if (_scrollCount != 0) { if (_scrollCount < 0) return; _scrollCount = 0; } else { if (_scrollFlag != 0) return; } if (xpos - _scrollX < 161) { _scrollCount = -320; if (_scrollX < 320) _scrollCount = -_scrollX; } } }
void AGOSEngine_Simon2::os2_rescan() { // 83: restart subroutine if (_exitCutscene) { if (getBitFlag(9)) { endCutscene(); } } else { processSpecialKeys(); } setScriptReturn(-10); }
void AGOSEngine_PuzzlePack::opp_saveUserGame() { // 132: save game if (_clockStopped != 0) _gameTime += getTime() - _clockStopped; _clockStopped = 0; if (!getBitFlag(110)) { // Swampy adventures saveGame(1, NULL); } //saveHiScores() }
void AGOSEngine_PuzzlePack::opp_loadUserGame() { // 133: load usergame // NoPatience or Jumble if (getBitFlag(110)) { //getHiScoreName(); return; } // XXX loadGame(genSaveName(1)); }