示例#1
0
        public bool Decode(byte[] dst, byte[] src)
        {
            if ((_tableBig == null) || (_tableSmall == null) || (_deltaBuf == null))
            {
                return(false);
            }

            _offset1 = _deltaBufs[1] - _curBuf;
            _offset2 = _deltaBufs[0] - _curBuf;

            int seq_nb = BitConverter.ToUInt16(src, 0);

            int gfx_data = 26;

            if (seq_nb == 0)
            {
                MakeTables47(_width);
                ScummHelper.ArraySet(_deltaBuf, src[12], 0);
                ScummHelper.ArraySet(_deltaBuf, src[13], _frameSize);
                _prevSeqNb = -1;
            }

            if ((src[4] & 1) != 0)
            {
                gfx_data += 32896;
            }

            switch (src[2])
            {
            case 0:
                Array.Copy(src, gfx_data, _deltaBuf, _curBuf, _frameSize);
                break;

            case 1:
                // Used by Outlaws, but not by any SCUMM game.
                throw new NotImplementedException("codec47: not implemented decode1 proc");

            case 2:
                if (seq_nb == _prevSeqNb + 1)
                {
                    Decode2(_deltaBuf, _curBuf, src, gfx_data, _width, _height, src, 8);
                }
                break;

            case 3:
                Array.Copy(_deltaBuf, _deltaBufs[1], _deltaBuf, _curBuf, _frameSize);
                break;

            case 4:
                Array.Copy(_deltaBuf, _deltaBufs[0], _deltaBuf, _curBuf, _frameSize);
                break;

            case 5:
                Codec37Decoder.BompDecodeLine(src, gfx_data, _deltaBuf, _curBuf, BitConverter.ToInt32(src, 14));
                break;
            }

            Array.Copy(_deltaBuf, _curBuf, dst, 0, _frameSize);

            if (seq_nb == _prevSeqNb + 1)
            {
                if (src[3] == 1)
                {
                    ScummHelper.Swap(ref _curBuf, ref _deltaBufs[1]);
                }
                else if (src[3] == 2)
                {
                    ScummHelper.Swap(ref _deltaBufs[0], ref _deltaBufs[1]);
                    ScummHelper.Swap(ref _deltaBufs[1], ref _curBuf);
                }
            }
            _prevSeqNb = seq_nb;

            return(true);
        }
示例#2
0
        void DecodeFrameObject(int codec, byte[] src, int left, int top, int width, int height)
        {
            if ((height == 242) && (width == 384))
            {
                if (_specialBuffer == null)
                    _specialBuffer = new byte[242 * 384];
                _dst = _specialBuffer;
            }
            else if ((height > _vm.ScreenHeight) || (width > _vm.ScreenWidth))
                return;
            // FT Insane uses smaller frames to draw overlays with moving objects
            // Other .san files do have them as well but their purpose in unknown
            // and often it causes memory overdraw. So just skip those frames
            else if (!_insanity && ((height != _vm.ScreenHeight) || (width != _vm.ScreenWidth)))
                return;

            if ((height == 242) && (width == 384))
            {
                _width = width;
                _height = height;
            }
            else
            {
                _width = _vm.ScreenWidth;
                _height = _vm.ScreenHeight;
            }

            switch (codec)
            {
                case 1:
                case 3:
                    SmushDecodeCodec1(_dst, 0, src, 0, left, top, width, height, _vm.ScreenWidth);
                    break;
                case 37:
                    if (_codec37 == null)
                        _codec37 = new Codec37Decoder(width, height);
                    _codec37.Decode(_dst, src);
                    break;
                case 47:
                    if (_codec47 == null)
                        _codec47 = new Codec47Decoder(width, height);
                    _codec47.Decode(_dst, src);
                    break;
                default:
                    throw new InvalidOperationException(string.Format("Invalid codec for frame object : {0}", codec));
            }

            if (_storeFrame)
            {
                if (_frameBuffer == null)
                {
                    _frameBuffer = new byte[_width * _height];
                }
                Array.Copy(_dst, _frameBuffer, width * height);
                _storeFrame = false;
            }
        }
示例#3
0
        void DecodeFrameObject(int codec, byte[] src, int left, int top, int width, int height)
        {
            if ((height == 242) && (width == 384))
            {
                if (_specialBuffer == null)
                {
                    _specialBuffer = new byte[242 * 384];
                }
                _dst = _specialBuffer;
            }
            else if ((height > _vm.ScreenHeight) || (width > _vm.ScreenWidth))
            {
                return;
            }
            // FT Insane uses smaller frames to draw overlays with moving objects
            // Other .san files do have them as well but their purpose in unknown
            // and often it causes memory overdraw. So just skip those frames
            else if (!_insanity && ((height != _vm.ScreenHeight) || (width != _vm.ScreenWidth)))
            {
                return;
            }

            if ((height == 242) && (width == 384))
            {
                _width  = width;
                _height = height;
            }
            else
            {
                _width  = _vm.ScreenWidth;
                _height = _vm.ScreenHeight;
            }

            switch (codec)
            {
            case 1:
            case 3:
                SmushDecodeCodec1(_dst, 0, src, 0, left, top, width, height, _vm.ScreenWidth);
                break;

            case 37:
                if (_codec37 == null)
                {
                    _codec37 = new Codec37Decoder(width, height);
                }
                _codec37.Decode(_dst, src);
                break;

            case 47:
                if (_codec47 == null)
                {
                    _codec47 = new Codec47Decoder(width, height);
                }
                _codec47.Decode(_dst, src);
                break;

            default:
                throw new InvalidOperationException(string.Format("Invalid codec for frame object : {0}", codec));
            }

            if (_storeFrame)
            {
                if (_frameBuffer == null)
                {
                    _frameBuffer = new byte[_width * _height];
                }
                Array.Copy(_dst, _frameBuffer, width * height);
                _storeFrame = false;
            }
        }