Example #1
0
        public ScummScreen(Game game, GameSettings info)
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.0);
            TransitionOffTime = TimeSpan.FromSeconds(1.0);

            this.game = game;
            this.info = info;
        }
Example #2
0
        public ScummGame(GameSettings settings)
        {
            IsMouseVisible = false;
            IsFixedTimeStep = false;
            Window.AllowUserResizing = true;

            Content.RootDirectory = "Content";

            GraphicsDeviceManager = new GraphicsDeviceManager(this);
#if !WINDOWS_UWP
            Settings = settings;
            GraphicsDeviceManager.PreferredBackBufferWidth = 800;
            GraphicsDeviceManager.PreferredBackBufferHeight = (int)(800.0 * Settings.Game.Height / Settings.Game.Width);
#else
            Settings = new GameSettings(GamePage.Info.Game, GamePage.Info.Engine);
            GraphicsDeviceManager.PreferredBackBufferWidth = Settings.Game.Width;
            GraphicsDeviceManager.PreferredBackBufferHeight = Settings.Game.Height;
#endif
            _screenManager = new ScreenManager(this);
            Components.Add(_screenManager);
        }
Example #3
0
        public ScummEngine7(GameSettings game, IGraphicsManager graphicsManager, IInputManager inputManager, IMixer mixer)
            : base(game, graphicsManager, inputManager, mixer)
        {
            if (Game.GameId == GameId.Dig && (Game.Features.HasFlag(GameFeatures.Demo)))
                _smushFrameRate = 15;
            else
                _smushFrameRate = (Game.GameId == GameId.FullThrottle) ? 10 : 12;

            for (int i = 0; i < _subtitleQueue.Length; i++)
            {
                _subtitleQueue[i] = new SubtitleText();
            }

            int dimuseTempo = 10;
            MusicEngine = IMuseDigital = new IMuseDigital(this, mixer, dimuseTempo);
            IMuseDigital.SetAudioNames(ResourceManager.AudioNames);

            // Create FT INSANE object
            if (Game.GameId == GameId.FullThrottle)
                Insane = new Insane.Insane(this);

            SmushMixer = new SmushMixer(Mixer);
            SmushPlayer = new SmushPlayer(this);
        }
Example #4
0
        public ScummEngine2(GameSettings game, IGraphicsManager graphicsManager, IInputManager inputManager, IMixer mixer)
            : base(game, graphicsManager, inputManager, mixer)
        {
            _flashlight.XStrips = 7;
            _flashlight.YStrips = 7;

            /*if (Game.Platform == Platform.NES) {
                InitNESMouseOver();
                _switchRoomEffect2 = _switchRoomEffect = 6;
            } else*/
            {
                InitV2MouseOver();
                // Seems in V2 there was only a single room effect (iris),
                // so we set that here.
                _switchRoomEffect2 = 1;
                _switchRoomEffect = 5;
            }

            _inventoryOffset = 0;

            VariableSentenceVerb = null;
            VariableSentenceObject1 = null;
            VariableSentenceObject2 = null;
            VariableSentencePreposition = null;
            VariableBackupVerb = null;

            VariableClickArea = null;
            VariableClickVerb = null;
            VariableClickObject = null;
        }
Example #5
0
        public SkyEngine(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager, IAudioOutput output, ISaveFileManager saveFileManager, bool debugMode = false)
        {
            _system = new SkySystem(gfxManager, inputManager, saveFileManager);

            _mixer = new Mixer(44100);
            // HACK:
            _mixer.Read(new byte[0], 0);
            output.SetSampleProvider(_mixer);

            var directory = ServiceLocator.FileStorage.GetDirectoryName(settings.Game.Path);
            _skyDisk = new Disk(directory);
            _skySound = new Sound(_mixer, _skyDisk, Mixer.MaxChannelVolume);

            SystemVars.Instance.GameVersion = _skyDisk.DetermineGameVersion();

            // TODO: music
            var dev = MidiDriver.DetectDevice(MusicDriverTypes.AdLib | MusicDriverTypes.Midi /*| MDT_PREFER_MT32*/, settings.AudioDevice);
            if (MidiDriver.GetMusicType(dev) == MusicType.AdLib)
            {
                SystemVars.Instance.SystemFlags |= SystemFlags.Sblaster;
                _skyMusic = new AdLibMusic(_mixer, _skyDisk);
            }
            else
            {
                SystemVars.Instance.SystemFlags |= SystemFlags.Roland;
                if ((MidiDriver.GetMusicType(dev) == MusicType.MT32)/* || ConfMan.getBool("native_mt32")*/)
                    _skyMusic = new Mt32Music((MidiDriver)MidiDriver.CreateMidi(_mixer, dev), _mixer, _skyDisk);
                else
                    _skyMusic = new GmMusic((MidiDriver)MidiDriver.CreateMidi(_mixer, dev), _mixer, _skyDisk);
            }

            if (IsCDVersion)
            {
                // TODO: configuration
                //if (ConfMan.hasKey("nosubtitles"))
                //{
                //    warning("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead");
                //    if (!ConfMan.getBool("nosubtitles"))
                //        _systemVars.systemFlags |= SF_ALLOW_TEXT;
                //}

                //if (ConfMan.getBool("subtitles"))
                //    _systemVars.systemFlags |= SF_ALLOW_TEXT;

                //if (!ConfMan.getBool("speech_mute"))
                //    _systemVars.systemFlags |= SF_ALLOW_SPEECH;

            }
            else
                SystemVars.Instance.SystemFlags |= SystemFlags.AllowText;

            SystemVars.Instance.SystemFlags |= SystemFlags.PlayVocs;
            SystemVars.Instance.GameSpeed = 80;

            _skyCompact = new SkyCompact();
            _skyText = new Text(_skyDisk, _skyCompact);
            _skyMouse = new Mouse(_system, _skyDisk, _skyCompact);
            _skyScreen = new Screen(_system, _skyDisk, _skyCompact);

            InitVirgin();
            InitItemList();
            LoadFixedItems();
            _skyLogic = new Logic(_skyCompact, _skyScreen, _skyDisk, _skyText, _skyMusic, _skyMouse, _skySound);
            _skyMouse.Logic = _skyLogic;
            _skyScreen.Logic = _skyLogic;
            _skySound.Logic = _skyLogic;
            _skyText.Logic = _skyLogic;

            _skyControl = new Control(_skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _skyCompact, _system);
            _skyLogic.Control = _skyControl;

            // TODO: language

            // TODO: Setup mixer
            //SyncSoundSettings();

            // TODO: debugger
            //_debugger = new Debugger(_skyLogic, _skyMouse, _skyScreen, _skyCompact);
        }
Example #6
0
        public SwordEngine(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager,
            IAudioOutput output, ISaveFileManager saveFileManager, bool debugMode)
        {
            Settings = settings;
            GraphicsManager = gfxManager;
            _mixer = new Mixer(44100);
            // HACK:
            _mixer.Read(new byte[0], 0);
            output.SetSampleProvider(_mixer);
            System = new SwordSystem(gfxManager, inputManager, saveFileManager);

            var gameId = ((SwordGameDescriptor)settings.Game).GameId;
            _features = gameId == SwordGameId.Sword1Demo || gameId == SwordGameId.Sword1MacDemo ||
                        gameId == SwordGameId.Sword1PsxDemo
                ? 1U
                : 0;

            // TODO: debug
            // _console = new SwordConsole(this);

            SystemVars.Platform = settings.Game.Platform;

            // TODO:
            // CheckCdFiles();

            // TODO: debug(5, "Starting resource manager");
            var directory = ServiceLocator.FileStorage.GetDirectoryName(settings.Game.Path);
            var path = ServiceLocator.FileStorage.Combine(directory, "swordres.rif");
            _resMan = new ResMan(directory, path, SystemVars.Platform == Platform.Macintosh);
            // TODO: debug(5, "Starting object manager");

            _objectMan = new ObjectMan(_resMan);
            _mouse = new Mouse(System, _resMan, _objectMan);
            _screen = new Screen(directory, System, _resMan, _objectMan);
            _music = new Music(Mixer, directory);
            _sound = new Sound(settings, _mixer, _resMan);
            _menu = new Menu(_screen, _mouse);
            _logic = new Logic(this, _objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, Mixer);
            _mouse.UseLogicAndMenu(_logic, _menu);

            // TODO:
            //SyncSoundSettings();

            SystemVars.JustRestoredGame = 0;
            SystemVars.CurrentCd = 0;
            SystemVars.ControlPanelMode = ControlPanelMode.CP_NEWGAME;
            SystemVars.ForceRestart = false;
            SystemVars.WantFade = true;
            //_systemVars.realLanguage = Common::parseLanguage(ConfMan.get("language"));
            SystemVars.RealLanguage = new CultureInfo("en-GB");

            //switch (SystemVars.RealLanguage.TwoLetterISOLanguageName)
            //{
            //    case "de":
            //        SystemVars.Language = Language.BS1_GERMAN;
            //        break;
            //    case "fr":
            //        SystemVars.Language = Language.BS1_FRENCH;
            //        break;
            //    case "it":
            //        SystemVars.Language = Language.BS1_ITALIAN;
            //        break;
            //    case "es":
            //        SystemVars.Language = Language.BS1_SPANISH;
            //        break;
            //    case "pt":
            //        SystemVars.Language = Language.BS1_PORT;
            //        break;
            //    case "cz":
            //        SystemVars.Language = Language.BS1_CZECH;
            //        break;
            //    default:
            //        SystemVars.Language = Language.BS1_ENGLISH;
            //        break;
            //}

            // TODO:
            //_systemVars.showText = ConfMan.getBool("subtitles");

            SystemVars.PlaySpeech = 1;
            _mouseState = 0;

            // Some Mac versions use big endian for the speech files but not all of them.
            if (SystemVars.Platform == Platform.Macintosh)
                _sound.CheckSpeechFileEndianness();

            _logic.Initialize();
            _objectMan.Initialize();
            _mouse.Initialize();
            _control = new Control(saveFileManager, _resMan, _objectMan, System, _mouse, _sound, _music);
        }
Example #7
0
 public IEngine Create(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager, IAudioOutput output, ISaveFileManager saveFileManager, bool debugMode = false)
 {
     return ScummEngine.Create(settings, gfxManager, inputManager, output, debugMode);
 }
Example #8
0
        public Sound(GameSettings settings, Mixer mixer, ResMan resMan)
        {
            _mixer = mixer;
            _resMan = resMan;
            _settings = settings;

            _speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
            _fxQueue = new QueueElement[MAX_FXQ_LENGTH];
            for (int i = 0; i < _fxQueue.Length; i++)
            {
                _fxQueue[i] = new QueueElement();
            }
        }
Example #9
0
        static int Main(string[] args)
        {
            var musicDriver = "adlib";
            var showVersion = false;
            var showHelp = false;
            var listAudioDevices = false;
            var bootParam = 0;
            var copyProtection = false;
            string switches = null;
            var options = new OptionSet
            {
                { "v|version", "Display NScumm version information and exit", v => showVersion = v != null },
                { "h|help", "Display a brief help text and exit", h => showHelp = h != null },
                { "e|music-driver=", "Select music driver", d => musicDriver = d },
                { "list-audio-devices", "List all available audio devices", b => listAudioDevices = b != null },
                { "b|boot-param=", "Pass number to the boot script (boot param)", (int b) => bootParam = b },
                { "debugflags=", "Enable engine specific debug flags (separated by commas)", d => switches = d },
                { "copy_protection", "Enable copy protection in SCUMM games, when NScumm disables it by default.", b => copyProtection = b != null }
            };

            try
            {
                var extras = options.Parse(args);
                Initialize(switches);
                if (showVersion)
                {
                    ShowVersion();
                }
                else if (showHelp)
                {
                    Usage(options);
                }
                else if (listAudioDevices)
                {
                    ListAudioDevices();
                }
                else if (extras.Count == 1)
                {
                    var path = ScummHelper.NormalizePath(extras[0]);
                    if (File.Exists(path))
                    {
                        var pluginsdDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins");
                        var gd = new GameDetector();
                        gd.AddPluginsFromDirectory(pluginsdDirectory);
                        var info = gd.DetectGame(path);
                        if (info == null)
                        {
                            Console.Error.WriteLine("This game is not supported, sorry please contact me if you want to support this game.");
                        }
                        else
                        {
                            ((AudioManager)ServiceLocator.AudioManager).Directory = Path.GetDirectoryName(info.Game.Path);
                            var settings = new GameSettings(info.Game, info.Engine) { AudioDevice = musicDriver, CopyProtection = copyProtection, BootParam = bootParam };
                            var game = new ScummGame(settings);
                            game.Services.AddService<IMenuService>(new MenuService(game));
                            game.Run();
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("The file {0} does not exist.", path);
                    }
                }
                else
                {
                    Usage(options);
                    return 1;
                }
            }
            catch (ArgumentException)
            {
                Usage(options);
                return 1;
            }
            catch (OptionException)
            {
                Usage(options);
                return 1;
            }
            return 0;
        }
Example #10
0
 public ScummEngine8(GameSettings game, IGraphicsManager graphicsManager, IInputManager inputManager, IMixer mixer)
     : base(game, graphicsManager, inputManager, mixer)
 {
 }
Example #11
0
        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];
            }
        }
Example #12
0
        public static ScummEngine Create(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager, IAudioOutput output, bool debugMode = false)
        {
            ScummEngine engine = null;
            var game = (GameInfo)settings.Game;
            var mixer = new Mixer(44100);
            output.SetSampleProvider(mixer);

            if (game.Version == 0)
            {
                engine = new ScummEngine0(settings, gfxManager, inputManager, mixer);
            }
            else if ((game.Version == 1) || (game.Version == 2))
            {
                engine = new ScummEngine2(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 3)
            {
                engine = new ScummEngine3(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 4)
            {
                engine = new ScummEngine4(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 5)
            {
                engine = new ScummEngine5(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 6)
            {
                engine = new ScummEngine6(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 7)
            {
                engine = new ScummEngine7(settings, gfxManager, inputManager, mixer);
            }
            else if (game.Version == 8)
            {
                engine = new ScummEngine8(settings, gfxManager, inputManager, mixer);
            }
            Instance = engine;
            engine.DebugMode = debugMode;
            engine.InitOpCodes();
            engine.SetupVars();
            engine.ResetScummVars();
            return engine;
        }
Example #13
0
        public ScummEngine0(GameSettings game, IGraphicsManager graphicsManager, IInputManager inputManager, IMixer mixer)
            : base(game, graphicsManager, inputManager, mixer)
        {
            VariableActiveObject2 = null;
            VariableIsSoundRunning = null;
            VariableActiveVerb = null;

            ResetVerbs();
        }