Exemplo n.º 1
0
void Game::fini() {
	clearSceneData(-1);
	deallocateTables();
	unloadCommonSprites();
	_stub->destroy();
}
Exemplo n.º 2
0
void Game::mainLoop() {
	_stub->init(_gameWindowTitle, kGameScreenWidth, kGameScreenHeight);
	allocateTables();
	loadCommonSprites();
	_mixer->open();
	restart();
	if (_isDemo) {
		playBitmapSequenceDemo();
	} else {
		playVideo("DATA/LOGO.AVI");
		playVideo("DATA/INTRO.AVI");
	}
	_lastFrameTimeStamp = _stub->getTimeStamp();
	while (!_stub->_quit) {
		if (_switchScene) {
			_switchScene = false;
			if (stringEndsWith(_tempTextBuffer, "SCN")) {
				win16_sndPlaySound(6);
				debug(DBG_GAME, "switch to scene '%s'", _tempTextBuffer);
				if (strcmp(_tempTextBuffer, "PIC4.SCN") == 0) {
					debug(DBG_INFO, "End of game");
					break;
				}
				strcpy(_currentSceneScn, _tempTextBuffer);
				parseSCN(_tempTextBuffer);
			} else if (stringEndsWith(_tempTextBuffer, "SAV")) {
				if (_isDemo && strcmp(_tempTextBuffer, "A16.SAV") == 0) {
					debug(DBG_GAME, "End of demo interactive part");
					restart();
					continue;
				}
				warning("Ignoring savestate load '%s'", _tempTextBuffer);
				// should work though, as the original savestates load fine
				// now, but this "feature" is only used in the demo AFAICT,
				// so no need to bother...
			} else {
				debug(DBG_GAME, "load mov '%s'", _tempTextBuffer);
				loadMOV(_tempTextBuffer);
			}
			if (_loadState) {
				_loadState = false;
				loadState(_stateSlot, false);
				playMusic(_musicName);
				memset(_keysPressed, 0, sizeof(_keysPressed));
			}
			assert(_sceneObjectsCount != 0);
			if (_currentBagObject == -1) {
				_currentBagObject = _bagObjectsCount - 1;
				if (_currentBagObject > 0) {
					_currentBagObject = 0;
				}
			}
			if (_loadDataState != 0) {
				setupScreenPalette(_bitmapBuffer0 + kOffsetBitmapPalette);
			}
			_gameOver = false;
			_workaroundRaftFlySceneBug = strncmp(_currentSceneScn, "FLY", 3) == 0;
		}
		updateKeysPressedTable();
		updateMouseButtonsPressed();
		runObjectsScript();
		if (!_switchScene) {
			_stub->updateScreen();
			uint32 end = _lastFrameTimeStamp + kCycleDelay;
			do {
				_stub->sleep(10);
				_stub->processEvents();
			} while (!_stub->_pi.fastMode && _stub->getTimeStamp() < end);
			_lastFrameTimeStamp = _stub->getTimeStamp();
		}
		if (_startDialogue) {
			_startDialogue = false;
			handleDialogue();
		}
	}
	clearSceneData(-1);
	deallocateTables();
	unloadCommonSprites();
	_mixer->close();
	_stub->destroy();
}