protected override void PrepareDrawActorCostume(ICostumeRenderer bcr) { base.PrepareDrawActorCostume(bcr); bcr.ActorX = RealPosition.X; bcr.ActorY = RealPosition.Y - Elevation; if (_scumm.Game.Version <= 2) { bcr.ActorX *= V12_X_MULTIPLIER; bcr.ActorY *= V12_Y_MULTIPLIER; } bcr.ActorX -= _scumm.MainVirtScreen.XStart; // if (_scumm.Game.Platform == Common::kPlatformNES) { // // In the NES version, when the actor is facing right, // // we need to shift it 8 pixels to the left // if (Facing == 90) // bcr.ActorX -= 8; // } else if (_scumm.Game.Version == 0) { bcr.ActorX += 12; } else if (_scumm.Game.Version <= 2) { // HACK: We have to adjust the x position by one strip (8 pixels) in // V2 games. However, it is not quite clear to me why. And to fully // match the original, it seems we have to offset by 2 strips if the // actor is facing left (270 degree). // V1 games are once again slightly different, here we only have // to adjust the 270 degree case... if (Facing == 270) { bcr.ActorX += 16; } else if (_scumm.Game.Version == 2) { bcr.ActorX += 8; } } }
protected override void PrepareDrawActorCostume(ICostumeRenderer bcr) { base.PrepareDrawActorCostume(bcr); bcr.ActorX = RealPosition.X; bcr.ActorY = RealPosition.Y - Elevation; if (_scumm.Game.Version <= 2) { bcr.ActorX *= V12_X_MULTIPLIER; bcr.ActorY *= V12_Y_MULTIPLIER; } bcr.ActorX -= _scumm.MainVirtScreen.XStart; // if (_scumm.Game.Platform == Common::kPlatformNES) { // // In the NES version, when the actor is facing right, // // we need to shift it 8 pixels to the left // if (Facing == 90) // bcr.ActorX -= 8; // } else if (_scumm.Game.Version == 0) { bcr.ActorX += 12; } else if (_scumm.Game.Version <= 2) { // HACK: We have to adjust the x position by one strip (8 pixels) in // V2 games. However, it is not quite clear to me why. And to fully // match the original, it seems we have to offset by 2 strips if the // actor is facing left (270 degree). // V1 games are once again slightly different, here we only have // to adjust the 270 degree case... if (Facing == 270) bcr.ActorX += 16; else if (_scumm.Game.Version == 2) bcr.ActorX += 8; } }
protected ScummEngine(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager, IMixer mixer) { Settings = settings; var game = (GameInfo)settings.Game; _resManager = ResourceManager.Load(game); _game = game; InvalidBox = _game.Version < 5 ? (byte)255 : (byte)0; _gameMD5 = ToMd5Bytes(game.MD5); _gfxManager = gfxManager; _inputManager = inputManager; _inputState = inputManager.GetState(); _strings = new byte[_resManager.NumArray][]; _inventory = new ushort[_resManager.NumInventory]; _invData = new ObjectData[_resManager.NumInventory]; CurrentScript = 0xFF; Mixer = mixer; ScreenWidth = Game.Width; ScreenHeight = Game.Height; AudioCDManager = new DefaultAudioCDManager(this, mixer); Sound = new Sound(this, mixer); SetupMusic(); _variables = new int[_resManager.NumVariables]; _bitVars = new BitArray(_resManager.NumBitVariables); _slots = new ScriptSlot[NumScriptSlot]; for (int i = 0; i < NumScriptSlot; i++) { _slots[i] = new ScriptSlot(); } for (int i = 0; i < 200; i++) { _objs[i] = new ObjectData(); } for (int i = 0; i < 6; i++) { _string[i] = new TextSlot(); if (game.Version != 3) { _string[i].Default.Position = new Point(2, 5); } } _colorCycle = new ColorCycle[16]; for (int i = 0; i < _colorCycle.Length; i++) { _colorCycle[i] = new ColorCycle(); } _nest = new NestedScript[MaxScriptNesting + 1]; for (int i = 0; i < _nest.Length; i++) { _nest[i] = new NestedScript(); } _scaleSlots = new ScaleSlot[20]; for (int i = 0; i < _scaleSlots.Length; i++) { _scaleSlots[i] = new ScaleSlot(); } Gdi = Gdi.Create(this, game); switch (game.Version) { case 0: _costumeLoader = new CostumeLoader0(this); _costumeRenderer = new CostumeRenderer0(this); break; case 7: case 8: _costumeLoader = new AkosCostumeLoader(this); _costumeRenderer = new AkosRenderer(this); break; default: _costumeLoader = new ClassicCostumeLoader(this); _costumeRenderer = new ClassicCostumeRenderer(this); break; } CreateCharset(); ResetCursors(); // Create the text surface var pixelFormat = _game.Features.HasFlag(GameFeatures.Is16BitColor) ? PixelFormat.Rgb16 : PixelFormat.Indexed8; _textSurface = new Surface(ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, PixelFormat.Indexed8, false); ClearTextSurface(); if (Game.Platform == Platform.FMTowns) { _townsScreen = new TownsScreen(_gfxManager, ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, PixelFormat.Rgb16); _townsScreen.SetupLayer(0, ScreenWidth, ScreenHeight, 32767); _townsScreen.SetupLayer(1, ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, 16, _textPalette); } if (Game.Version == 0) { InitScreens(8, 144); } else if ((Game.GameId == GameId.Maniac) && (_game.Version <= 1) && _game.Platform != Platform.NES) { InitScreens(16, 152); } else if (Game.Version >= 7) { InitScreens(0, ScreenHeight); } else { InitScreens(16, 144); } // Allocate gfx compositing buffer (not needed for V7/V8 games). if (Game.Version < 7) { _composite = new Surface(ScreenWidth, ScreenHeight, pixelFormat, false); } InitActors(); OwnerRoom = Game.Version >= 7 ? 0x0FF : 0x0F; if (Game.Version < 7) { Camera.LeftTrigger = 10; Camera.RightTrigger = 30; } InitPalettes(); InitializeVerbs(); // WORKAROUND for bug in boot script of Loom (CD) // The boot script sets the characters of string 21, // before creating the string.resource. if (_game.GameId == GameId.Loom) { _strings[21] = new byte[13]; } }
protected virtual void PrepareDrawActorCostume(ICostumeRenderer bcr) { bcr.ActorID = Number; bcr.ActorX = _position.X - _scumm.MainVirtScreen.XStart; bcr.ActorY = _position.Y - _elevation; if (_scumm.Game.Version == 4 && (BoxScale & 0x8000) != 0) { bcr.ScaleX = bcr.ScaleY = (byte)_scumm.GetScaleFromSlot((BoxScale & 0x7fff) + 1, _position.X, _position.Y); } else { bcr.ScaleX = ScaleX; bcr.ScaleY = ScaleY; } bcr.ShadowMode = ShadowMode; if (_scumm.Game.Version >= 5) { bcr.ShadowTable = _scumm.ShadowPalette; } bcr.SetCostume(Costume, 0); bcr.SetPalette(_palette); bcr.SetFacing(this); if (_scumm.Game.Version >= 7) { bcr.ZBuffer = ForceClip; if (bcr.ZBuffer == 100) { bcr.ZBuffer = (byte)_scumm.GetBoxMask(Walkbox); if (bcr.ZBuffer > _scumm.Gdi.NumZBuffer - 1) bcr.ZBuffer = (byte)(_scumm.Gdi.NumZBuffer - 1); } } else { if (ForceClip > 0) bcr.ZBuffer = ForceClip; else if (IsInClass(ObjectClass.NeverClip)) bcr.ZBuffer = 0; else { bcr.ZBuffer = (byte)_scumm.GetBoxMask(Walkbox); if (_scumm.Game.Version == 0) bcr.ZBuffer &= 0x03; if (bcr.ZBuffer > _scumm.Gdi.NumZBuffer - 1) bcr.ZBuffer = (byte)(_scumm.Gdi.NumZBuffer - 1); } } bcr.DrawTop = 0x7fffffff; bcr.DrawBottom = 0; }