Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

void Scumm::ScummEngine::startScene ( int  room,
Actor *  a,
int  objectNr 
) [protected, inherited]

Start a 'scene' by loading the specified room with the given main actor. The actor is placed next to the object indicated by objectNr.

Definition at line 46 of file room.cpp.

References Scumm::CameraData::_cur, Scumm::CameraData::_dest, Scumm::CameraData::_follows, Scumm::CameraData::_mode, Scumm::ScummEngine::_res, Scumm::GameSettings::features, Scumm::GameSettings::heversion, Scumm::GameSettings::id, Scumm::ResourceManager::increaseResourceCounter(), OSystem::kFeatureVirtualKeyboard, Scumm::ScummEngine::resetRoomSubBlocks(), Scumm::ScummEngine::setupRoomSubBlocks(), Scumm::GameSettings::version, Common::Point::x, and Common::Point::y.

                                                             {
      int i, where;

      debugC(DEBUG_GENERAL, "Loading room %d", room);

      stopTalk();

      fadeOut(_switchRoomEffect2);
      _newEffect = _switchRoomEffect;

      ScriptSlot *ss =  &vm.slot[_currentScript];

      if (_currentScript != 0xFF) {
            if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) {
                  if (ss->cutsceneOverride && _game.version >= 5)
                        error("Object %d stopped with active cutscene/override in exit", ss->number);

                  nukeArrays(_currentScript);
                  _currentScript = 0xFF;
            } else if (ss->where == WIO_LOCAL) {
                  if (ss->cutsceneOverride && _game.version >= 5)
                        error("Script %d stopped with active cutscene/override in exit", ss->number);

                  nukeArrays(_currentScript);
                  _currentScript = 0xFF;
            }
      }

      if (VAR_NEW_ROOM != 0xFF)
            VAR(VAR_NEW_ROOM) = room;

      runExitScript();

      killScriptsAndResources();
      if (_game.version >= 4 && _game.heversion <= 61)
            stopCycle(0);

      if (_game.id == GID_SAMNMAX) {
            // WORKAROUND bug #85373 SAM: Overlapping music at Bigfoot convention
            // Added sound queue processing between execution of exit
            // script and entry script. In the case of this bug, the
            // entry script required that the iMuse state be fully up
            // to  date, including last-moment changes from the previous
            // exit script.
            _sound->processSound();
      }

      clearDrawQueues();

      // For HE80+ games
      for (i = 0; i < _numRoomVariables; i++)
            _roomVars[i] = 0;
      nukeArrays(0xFF);

      for (i = 1; i < _numActors; i++) {
            _actors[i]->hideActor();
      }

      if (_game.version >= 7) {
            // Set the shadow palette(s) to all black. This fixes
            // bug #795940, and actually makes some sense (after all,
            // shadows tend to be rather black, don't they? ;-)
            memset(_shadowPalette, 0, NUM_SHADOW_PALETTE * 256);
      } else {
            for (i = 0; i < 256; i++) {
                  _roomPalette[i] = i;
                  if (_shadowPalette)
                        _shadowPalette[i] = i;
            }
            if (_game.features & GF_SMALL_HEADER)
                  setDirtyColors(0, 255);
      }

      VAR(VAR_ROOM) = room;
      _fullRedraw = true;

      _res->increaseResourceCounter();

      _currentRoom = room;
      VAR(VAR_ROOM) = room;

      if (room >= 0x80 && _game.version < 7 && _game.heversion <= 71)
            _roomResource = _resourceMapper[room & 0x7F];
      else
            _roomResource = room;

      if (VAR_ROOM_RESOURCE != 0xFF)
            VAR(VAR_ROOM_RESOURCE) = _roomResource;

      if (room != 0)
            ensureResourceLoaded(rtRoom, room);

      clearRoomObjects();

      if (_currentRoom == 0) {
            _ENCD_offs = _EXCD_offs = 0;
            _numObjectsInRoom = 0;
            return;
      }

      setupRoomSubBlocks();
      resetRoomSubBlocks();

      initBGBuffers(_roomHeight);

      resetRoomObjects();

      if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) {
            VAR(VAR_ROOM_WIDTH) = _roomWidth;
            VAR(VAR_ROOM_HEIGHT) = _roomHeight;
      }

      if (VAR_CAMERA_MIN_X != 0xFF)
            VAR(VAR_CAMERA_MIN_X) = _screenWidth / 2;
      if (VAR_CAMERA_MAX_X != 0xFF)
            VAR(VAR_CAMERA_MAX_X) = _roomWidth - (_screenWidth / 2);

      if (_game.version >= 7) {
            VAR(VAR_CAMERA_MIN_Y) = _screenHeight / 2;
            VAR(VAR_CAMERA_MAX_Y) = _roomHeight - (_screenHeight / 2);
            setCameraAt(_screenWidth / 2, _screenHeight / 2);
      } else {
            camera._mode = kNormalCameraMode;
            if (_game.version > 2)
                  camera._cur.x = camera._dest.x = _screenWidth / 2;
            camera._cur.y = camera._dest.y = _screenHeight / 2;
      }

      if (_roomResource == 0)
            return;

      memset(gfxUsageBits, 0, sizeof(gfxUsageBits));

      if (_game.version >= 5 && a) {
            where = whereIsObject(objectNr);
            if (where != WIO_ROOM && where != WIO_FLOBJECT)
                  error("startScene: Object %d is not in room %d", objectNr,
                              _currentRoom);
            int x, y, dir;
            getObjectXYPos(objectNr, x, y, dir);
            a->putActor(x, y, _currentRoom);
            a->setDirection(dir + 180);
            a->stopActorMoving();
            if (_game.id == GID_SAMNMAX) {
                  camera._cur.x = camera._dest.x = a->getPos().x;
                  setCameraAt(a->getPos().x, a->getPos().y);
            }
      }

      showActors();

      _egoPositioned = false;
      runEntryScript();
      if (_game.version >= 1 && _game.version <= 2) {
            runScript(5, 0, 0, 0);
      } else if (_game.version >= 5 && _game.version <= 6) {
            if (a && !_egoPositioned) {
                  int x, y;
                  getObjectXYPos(objectNr, x, y);
                  a->putActor(x, y, _currentRoom);
                  a->_moving = 0;
            }
      } else if (_game.version >= 7) {
            if (camera._follows) {
                  a = derefActor(camera._follows, "startScene: follows");
                  setCameraAt(a->getPos().x, a->getPos().y);
            }
      }

      _doEffect = true;

      // Hint the backend about the virtual keyboard during copy protection screens
      if (_game.id == GID_MONKEY2) {
            if (_system->getFeatureState(OSystem::kFeatureVirtualKeyboard)) {
                  if (room != 108)
                        _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
            } else if (room == 108)
                  _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
      } else if (_game.id == GID_MONKEY_EGA) {  // this is my estimation that the room code is 90 (untested)
            if (_system->getFeatureState(OSystem::kFeatureVirtualKeyboard)) {
                  if (room != 90)
                        _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
            } else if (room == 90)
                  _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
      }

}


Generated by  Doxygen 1.6.0   Back to index