예제 #1
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];
            }
        }
예제 #2
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];
            }
        }