Exemplo n.º 1
0
			public virtualInp(Inp mapTo, KeyCode low, KeyCode high)
			{
				Type = type.KeyAxis;
				MapTo = mapTo;
				High = high;
				Low = low;
			}
Exemplo n.º 2
0
// Return 'false' to quit unpacking the current file or 'true' to continue.
        bool ReadEndOfBlock()
        {
            uint BitField = Inp.getbits();
            bool NewTable, NewFile = false;

            // "1"  - no new file, new table just here.
            // "00" - new file,    no new table.
            // "01" - new file,    new table (in beginning of next file).

            if ((BitField & 0x8000) != 0)
            {
                NewTable = true;
                Inp.addbits(1);
            }
            else
            {
                NewFile  = true;
                NewTable = (BitField & 0x4000) != 0;
                Inp.addbits(2);
            }
            TablesRead3 = !NewTable;

            // Quit immediately if "new file" flag is set. If "new table" flag
            // is present, we'll read the table in beginning of next file
            // based on 'TablesRead3' 'false' value.
            if (NewFile)
            {
                return(false);
            }
            return(ReadTables30()); // Quit only if we failed to read tables.
        }
Exemplo n.º 3
0
        private bool ReadBlockHeader()
        {
            Header.HeaderSize = 0;

            if (!Inp.ExternalBuffer && Inp.InAddr > ReadTop - 7)
            {
                if (!UnpReadBuf())
                {
                    return(false);
                }
            }

            //Inp.faddbits((8-Inp.InBit)&7);
            Inp.faddbits((uint)((8 - Inp.InBit) & 7));

            byte BlockFlags = (byte)(Inp.fgetbits() >> 8);

            Inp.faddbits(8);
            //uint ByteCount=((BlockFlags>>3)&3)+1; // Block size byte count.
            uint ByteCount = (uint)(((BlockFlags >> 3) & 3) + 1); // Block size byte count.

            if (ByteCount == 4)
            {
                return(false);
            }

            //Header.HeaderSize=2+ByteCount;
            Header.HeaderSize = (int)(2 + ByteCount);

            Header.BlockBitSize = (BlockFlags & 7) + 1;

            byte SavedCheckSum = (byte)(Inp.fgetbits() >> 8);

            Inp.faddbits(8);

            int BlockSize = 0;

            //for (uint I=0;I<ByteCount;I++)
            for (int I = 0; I < ByteCount; I++)
            {
                //BlockSize+=(Inp.fgetbits()>>8)<<(I*8);
                BlockSize += (int)(Inp.fgetbits() >> 8) << (I * 8);
                Inp.AddBits(8);
            }

            Header.BlockSize = BlockSize;
            byte CheckSum = (byte)(0x5a ^ BlockFlags ^ BlockSize ^ (BlockSize >> 8) ^ (BlockSize >> 16));

            if (CheckSum != SavedCheckSum)
            {
                return(false);
            }

            Header.BlockStart = Inp.InAddr;
            ReadBorder        = Math.Min(ReadBorder, Header.BlockStart + Header.BlockSize - 1);

            Header.LastBlockInFile = (BlockFlags & 0x40) != 0;
            Header.TablePresent    = (BlockFlags & 0x80) != 0;
            return(true);
        }
Exemplo n.º 4
0
    void Awake()
    {
        //make this singleton persistent & don't allow any other gameobject to have this component
        if (instance != null && instance != this)
        {
            Destroy(this); return;
        }
        instance = this; DontDestroyOnLoad(this.gameObject);

        inputHistory       = new Dictionary <int, Vector2[]>();
        inputHistoryIndex  = new Dictionary <int, int>();
        inputHistoryCount  = new Dictionary <int, int>();
        inputOverUIHistory = new Dictionary <int, bool>();
        inputStart         = new Dictionary <int, PositionAtTime>();
        inputToBeRemoved   = new List <int>();

                #if UNITY_TVOS
        if (Application.platform == RuntimePlatform.tvOS)
        {
            UnityEngine.Apple.TV.Remote.touchesEnabled = true;
        }
                #endif

        if (!Input.touchSupported && !Input.mousePresent)
        {
            Debug.LogError("This platform is currently not supported by Inp.ut.");
        }
    }
Exemplo n.º 5
0
        private void UnpInitData(bool Solid)
        {
            if (!Solid)
            {
                Utility.Memset <uint>(OldDist, 0, OldDist.Length);
                OldDistPtr = 0;
                LastDist   = LastLength = 0;
//    memset(Window,0,MaxWinSize);
                //memset(&BlockTables,0,sizeof(BlockTables));
                BlockTables = new UnpackBlockTables();
                // sharpcompress: no default ctor for struct
                BlockTables.Init();
                UnpPtr      = WrPtr = 0;
                WriteBorder = Math.Min(MaxWinSize, UNPACK_MAX_WRITE) & MaxWinMask;
            }
            // Filters never share several solid files, so we can safely reset them
            // even in solid archive.
            InitFilters();

            Inp.InitBitInput();
            WrittenFileSize = 0;
            ReadTop         = 0;
            ReadBorder      = 0;

            //memset(&BlockHeader,0,sizeof(BlockHeader));
            BlockHeader           = new UnpackBlockHeader();
            BlockHeader.BlockSize = -1; // '-1' means not defined yet.
#if !RarV2017_SFX_MODULE
            UnpInitData20(Solid);
#endif
            //UnpInitData30(Solid);
            UnpInitData50(Solid);
        }
Exemplo n.º 6
0
        private bool ReadFilter(UnpackFilter Filter)
        {
            if (!Inp.ExternalBuffer && Inp.InAddr > ReadTop - 16)
            {
                if (!UnpReadBuf())
                {
                    return(false);
                }
            }

            Filter.uBlockStart  = ReadFilterData();
            Filter.uBlockLength = ReadFilterData();
            if (Filter.BlockLength > MAX_FILTER_BLOCK_SIZE)
            {
                Filter.BlockLength = 0;
            }

            //Filter.Type=Inp.fgetbits()>>13;
            Filter.Type = (byte)(Inp.fgetbits() >> 13);
            Inp.faddbits(3);

            if (Filter.Type == (byte)FilterType.FILTER_DELTA)
            {
                //Filter.Channels=(Inp.fgetbits()>>11)+1;
                Filter.Channels = (byte)((Inp.fgetbits() >> 11) + 1);
                Inp.faddbits(5);
            }

            return(true);
        }
Exemplo n.º 7
0
        public void GameOver(int score, Games gamein)
        {
            switch (gamein)
            {
            case Games.SNAKE:
                SnakeGrid.Visibility = Visibility.Hidden;
                Inp.Visibility       = Visibility.Visible;
                InpScroll.Visibility = Visibility.Hidden;
                Inp.Focus();
                ((TermBind)DataContext).CurTerm = "Hypothalamic Terminal";

                ((TermBind)DataContext).WriteToDisp("\n\nFinal score of " + Snake.Score.ToString() + "\n\nEnter Name:");
                Thread nameThread = new Thread(CommandList.CmdName);
                nameThread.IsBackground = true;
                nameThread.Start();
                break;

            case Games.CURVE:
                ClearCanvas();
                CurveCanvas.Visibility = Visibility.Hidden;
                Inp.Visibility         = Visibility.Visible;
                InpScroll.Visibility   = Visibility.Hidden;
                Inp.Focus();
                ((TermBind)DataContext).CurTerm = "Hypothalamic Terminal";
                TermBind.IsOpen = false;
                break;
            }
        }
Exemplo n.º 8
0
        private void GetFlagsBuf()
        {
            uint Flags, NewFlagsPlace;
            uint FlagsPlace = DecodeNum(Inp.fgetbits(), STARTHF2, DecHf2, PosHf2);

            // Our Huffman table stores 257 items and needs all them in other parts
            // of code such as when StMode is on, so the first item is control item.
            // While normally we do not use the last item to code the flags byte here,
            // we need to check for value 256 when unpacking in case we unpack
            // a corrupt archive.
            if (FlagsPlace >= ChSetC.Length)
            {
                return;
            }

            while (true)
            {
                Flags         = ChSetC[FlagsPlace];
                FlagBuf       = Flags >> 8;
                NewFlagsPlace = NToPlC[Flags++ & 0xff]++;
                if ((Flags & 0xff) != 0)
                {
                    break;
                }
                CorrHuff(ChSetC, NToPlC);
            }

            ChSetC[FlagsPlace]    = ChSetC[NewFlagsPlace];
            ChSetC[NewFlagsPlace] = (ushort)Flags;
        }
Exemplo n.º 9
0
			public virtualInp(Inp mapTo, string axis, bool invert = false)
			{
				Type = type.Axis;
				MapTo = mapTo;
				Axis = axis;
				Invert = invert;
			}
Exemplo n.º 10
0
 void OnEnable()
 {
     //This should only ever get called on first load and after an Assembly reload in Unity.
     // (because instance should be set on awake)
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 11
0
        public MainWindow()
        {
            #region init
            InitializeComponent();
            DataContext      = new TermBind();
            Disp.Effect      = new SmoothMagnifyEffect();
            PixelGrid.Effect = new PixelateEffect();
            BloomGrid.Effect = new BloomEffect();
            Scan.Effect      = new SmoothMagnifyEffect();
            ((PixelateEffect)PixelGrid.Effect).HorizontalPixelCounts = 1200;
            ((PixelateEffect)PixelGrid.Effect).VerticalPixelCounts   = 800;
            ((SmoothMagnifyEffect)Disp.Effect).InnerRadius          -= 0.7;
            ((SmoothMagnifyEffect)Disp.Effect).OuterRadius          += 0.5;
            ((SmoothMagnifyEffect)Disp.Effect).Magnification        -= 0.7;
            ((BloomEffect)BloomGrid.Effect).BaseIntensity++;
            ((SmoothMagnifyEffect)Scan.Effect).InnerRadius   -= 0.7;
            ((SmoothMagnifyEffect)Scan.Effect).OuterRadius   += 0.5;
            ((SmoothMagnifyEffect)Scan.Effect).Magnification -= 0.7;
            ((TermBind)DataContext).CurTerm = "Hypothalamic Terminal";
            CurveCanvas.Children.Add(curveline);
            CurveCanvas.Visibility = Visibility.Hidden;
            InpScroll.Visibility   = Visibility.Hidden;
            Inp.Focus();
            #endregion

            /*
             #region intro
             * //
             * ((TermBind)DataContext).WriteToDisp("\n          ║                      __  ________ __  __\n     ╔═══╝║╚═══╗                 | \\ | |_   _|  \\/  |\n     ╚══╗▒╠═╔══╝                 |  \\| | | | | \\  / | \n   ╔════╩╗║░╠════╗               | . ` | | | | |\\/| | \n   ╚══╗░╔╩╬═╝░╔══╝               | |\\  |_| |_| |  | | \n╔═════╩═╗▒▓░╬═╩═════╗            |_|_\\_|_____|_|__|_| \n╚════╗░╗╚░▓▒╝░░╔════╝            |  _ \\| |  | |/ ____|\n ╔═══╝░╚══╩╗╔╗▒╚═══╗             | |_) | |  | | (___  \n ╚═════╗░▒░╠╝╠═════╝             |  _ <| |  | |\\___ \\ \n     ╔═╝▒░╔╝░╚═╗                 | |_) | |__| |____) |\n     ╚═══╗║╔═══╝                 |____/ \\____/|_____/\n          ║		");
             * ((TermBind)DataContext).Wait(2000);
             * ((TermBind)DataContext).ClearScroll(Inp);
             * ((TermBind)DataContext).WriteToDisp("\n███████╗██╗   ██╗███╗   ██╗ █████╗ ██████╗ ███████╗███████╗\n██╔════╝╚██╗ ██╔╝████╗  ██║██╔══██╗██╔══██╗██╔════╝██╔════╝\n███████╗ ╚████╔╝ ██╔██╗ ██║███████║██████╔╝███████╗█████╗  \n╚════██║  ╚██╔╝  ██║╚██╗██║██╔══██║██╔═══╝ ╚════██║██╔══╝  \n███████║   ██║   ██║ ╚████║██║  ██║██║     ███████║███████╗\n╚══════╝   ╚═╝   ╚═╝  ╚═══╝╚═╝  ╚═╝╚═╝     ╚══════╝╚══════╝\n\t\t\t\t\t\t\tv3.4");
             * ((TermBind)DataContext).WriteToDisp("Welcome Amber!\nSynapse System v3.4 (TM) booting up");
             * ((TermBind)DataContext).WriteToDisp("...\n", 1000);
             * ((TermBind)DataContext).WriteToDisp("Performing primary diagnosis");
             * ((TermBind)DataContext).Wait(2000);
             * ((TermBind)DataContext).WriteToDisp("Exit Status 74\n302 Errors and 5888 Warnings\nShutting d");
             * ((TermBind)DataContext).Wait(2000);
             * ((TermBind)DataContext).WriteToDisp("status:override");
             * ((TermBind)DataContext).WriteToDisp("value:'Force'\n");
             * ((TermBind)DataContext).WriteToDisp("Manual Override succesful. Booting up in Basic Mode.\n");
             * ((TermBind)DataContext).WriteToDisp("status:accesLevel");
             * ((TermBind)DataContext).WriteToDisp("value:0\n");
             * ((TermBind)DataContext).WriteToDisp("Flagging functions");
             * ((TermBind)DataContext).WriteToDisp("...\n", 1000);
             * ((TermBind)DataContext).WriteToDisp("Boot complete");
             * ((TermBind)DataContext).Wait(2000);
             * ((TermBind)DataContext).ClearScroll(Inp);
             * ((TermBind)DataContext).WriteToDisp(" ");
             *
             * // ((TermBind)DataContext).WriteToDisp("\n          ║                      __  ________ __  __\n     ╔═══╝║╚═══╗                 | \\ | |_   _|  \\/  |\n     ╚══╗▒╠═╔══╝                 |  \\| | | | | \\  / | \n   ╔════╩╗║░╠════╗               | . ` | | | | |\\/| | \n   ╚══╗░╔╩╬═╝░╔══╝               | |\\  |_| |_| |  | | \n╔═════╩═╗▒▓░╬═╩═════╗            |_|_\\_|_____|_|__|_| \n╚════╗░╗╚░▓▒╝░░╔════╝            |  _ \\| |  | |/ ____|\n ╔═══╝░╚══╩╗╔╗▒╚═══╗             | |_) | |  | | (___  \n ╚═════╗░▒░╠╝╠═════╝             |  _ <| |  | |\\___ \\ \n     ╔═╝▒░╔╝░╚═╗                 | |_) | |__| |____) |\n     ╚═══╗║╔═══╝                 |____/ \\____/|_____/\n          ║		");
             #endregion
             */
        }
Exemplo n.º 12
0
        private uint DecodeNum(uint Num, uint StartPos, uint[] DecTab, uint[] PosTab)
        {
            int I;

            for (Num &= 0xfff0, I = 0; DecTab[I] <= Num; I++)
            {
                StartPos++;
            }
            Inp.faddbits(StartPos);
            return(((Num - (I != 0 ? DecTab[I - 1]:0)) >> (int)(16 - StartPos)) + PosTab[StartPos]);
        }
Exemplo n.º 13
0
 public void ToggleScroll()
 {
     if (InpScroll.Visibility == Visibility.Visible)
     {
         InpScroll.Visibility = Visibility.Hidden;
         Inp.Visibility       = Visibility.Visible;
         Inp.Focus();
         return;
     }
     InpScroll.Visibility = Visibility.Visible;
     Inp.Visibility       = Visibility.Hidden;
     Inp.Focus();
 }
Exemplo n.º 14
0
    public void QueInput(Inp inp)
    {
        // check stack not full
        if (inpQue.Count < 2)
        {
            inpQue.Push(inp);
        }
        else
        {
            Debug.Log("Que full");
        }

        // ad input to stack
    }
Exemplo n.º 15
0
        private uint ReadFilterData()
        {
            uint ByteCount = (Inp.fgetbits() >> 14) + 1;

            Inp.AddBits(2);

            uint Data = 0;

            //for (uint I=0;I<ByteCount;I++)
            for (int I = 0; I < ByteCount; I++)
            {
                Data += (Inp.fgetbits() >> 8) << (I * 8);
                Inp.AddBits(8);
            }
            return(Data);
        }
Exemplo n.º 16
0
    public void PopInput()
    {
        if (inpQue.Count > 0)
        {
            Inp tarinp = inpQue.Pop();

            switch (tarinp)
            {
            case Inp.Left:
                Horizontal(-1);
                break;

            case Inp.Right:
                Horizontal(1);
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 17
0
        bool ReadVMCode()
        {
            // Entire VM code is guaranteed to fully present in block defined
            // by current Huffman table. Compressor checks that VM code does not cross
            // Huffman block boundaries.
            uint FirstByte = Inp.getbits() >> 8;

            Inp.addbits(8);
            uint Length = (FirstByte & 7) + 1;

            if (Length == 7)
            {
                Length = (Inp.getbits() >> 8) + 7;
                Inp.addbits(8);
            }
            else
            if (Length == 8)
            {
                Length = Inp.getbits();
                Inp.addbits(16);
            }
            if (Length == 0)
            {
                return(false);
            }
            Array <byte> VMCode(Length);

            for (uint I = 0; I < Length; I++)
            {
                // Try to read the new buffer if only one byte is left.
                // But if we read all bytes except the last, one byte is enough.
                if (Inp.InAddr >= ReadTop - 1 && !UnpReadBuf30() && I < Length - 1)
                {
                    return(false);
                }
                VMCode[I] = Inp.getbits() >> 8;
                Inp.addbits(8);
            }
            return(AddVMCode(FirstByte, &VMCode[0], Length));
        }
Exemplo n.º 18
0
        private void HuffDecode()
        {
            uint CurByte, NewBytePlace;
            uint Length;
            uint Distance;
            int  BytePlace;

            uint BitField = Inp.fgetbits();

            if (AvrPlc > 0x75ff)
            {
                BytePlace = (int)DecodeNum(BitField, STARTHF4, DecHf4, PosHf4);
            }
            else
            if (AvrPlc > 0x5dff)
            {
                BytePlace = (int)DecodeNum(BitField, STARTHF3, DecHf3, PosHf3);
            }
            else
            if (AvrPlc > 0x35ff)
            {
                BytePlace = (int)DecodeNum(BitField, STARTHF2, DecHf2, PosHf2);
            }
            else
            if (AvrPlc > 0x0dff)
            {
                BytePlace = (int)DecodeNum(BitField, STARTHF1, DecHf1, PosHf1);
            }
            else
            {
                BytePlace = (int)DecodeNum(BitField, STARTHF0, DecHf0, PosHf0);
            }
            BytePlace &= 0xff;
            if (StMode != 0)
            {
                if (BytePlace == 0 && BitField > 0xfff)
                {
                    BytePlace = 0x100;
                }
                if (--BytePlace == -1)
                {
                    BitField = Inp.fgetbits();
                    Inp.faddbits(1);
                    if ((BitField & 0x8000) != 0)
                    {
                        NumHuf = StMode = 0;
                        return;
                    }
                    else
                    {
                        Length = (BitField & 0x4000) != 0 ? 4U : 3;
                        Inp.faddbits(1);
                        Distance = DecodeNum(Inp.fgetbits(), STARTHF2, DecHf2, PosHf2);
                        Distance = (Distance << 5) | (Inp.fgetbits() >> 11);
                        Inp.faddbits(5);
                        CopyString15(Distance, Length);
                        return;
                    }
                }
            }
            else
            if (NumHuf++ >= 16 && FlagsCnt == 0)
            {
                StMode = 1;
            }
            AvrPlc += (uint)BytePlace;
            AvrPlc -= AvrPlc >> 8;
            Nhfb   += 16;
            if (Nhfb > 0xff)
            {
                Nhfb   = 0x90;
                Nlzb >>= 1;
            }

            Window[UnpPtr++] = (byte)(ChSet[BytePlace] >> 8);
            --DestUnpSize;

            while (true)
            {
                CurByte      = ChSet[BytePlace];
                NewBytePlace = NToPl[CurByte++ & 0xff]++;
                if ((CurByte & 0xff) > 0xa1)
                {
                    CorrHuff(ChSet, NToPl);
                }
                else
                {
                    break;
                }
            }

            ChSet[BytePlace]    = ChSet[NewBytePlace];
            ChSet[NewBytePlace] = (ushort)CurByte;
        }
Exemplo n.º 19
0
        private void LongLZ()
        {
            uint Length;
            uint Distance;
            uint DistancePlace, NewDistancePlace;
            uint OldAvr2, OldAvr3;

            NumHuf = 0;
            Nlzb  += 16;
            if (Nlzb > 0xff)
            {
                Nlzb   = 0x90;
                Nhfb >>= 1;
            }
            OldAvr2 = AvrLn2;

            uint BitField = Inp.fgetbits();

            if (AvrLn2 >= 122)
            {
                Length = DecodeNum(BitField, STARTL2, DecL2, PosL2);
            }
            else
            if (AvrLn2 >= 64)
            {
                Length = DecodeNum(BitField, STARTL1, DecL1, PosL1);
            }
            else
            if (BitField < 0x100)
            {
                Length = BitField;
                Inp.faddbits(16);
            }
            else
            {
                for (Length = 0; ((BitField << (int)Length) & 0x8000) == 0; Length++)
                {
                    ;
                }
                Inp.faddbits(Length + 1);
            }

            AvrLn2 += Length;
            AvrLn2 -= AvrLn2 >> 5;

            BitField = Inp.fgetbits();
            if (AvrPlcB > 0x28ff)
            {
                DistancePlace = DecodeNum(BitField, STARTHF2, DecHf2, PosHf2);
            }
            else
            if (AvrPlcB > 0x6ff)
            {
                DistancePlace = DecodeNum(BitField, STARTHF1, DecHf1, PosHf1);
            }
            else
            {
                DistancePlace = DecodeNum(BitField, STARTHF0, DecHf0, PosHf0);
            }

            AvrPlcB += DistancePlace;
            AvrPlcB -= AvrPlcB >> 8;
            while (true)
            {
                Distance         = ChSetB[DistancePlace & 0xff];
                NewDistancePlace = NToPlB[Distance++ & 0xff]++;
                if ((Distance & 0xff) != 0)
                {
                    CorrHuff(ChSetB, NToPlB);
                }
                else
                {
                    break;
                }
            }

            ChSetB[DistancePlace & 0xff] = ChSetB[NewDistancePlace];
            ChSetB[NewDistancePlace]     = (ushort)Distance;

            Distance = ((Distance & 0xff00) | (Inp.fgetbits() >> 8)) >> 1;
            Inp.faddbits(7);

            OldAvr3 = AvrLn3;
            if (Length != 1 && Length != 4)
            {
                if (Length == 0 && Distance <= MaxDist3)
                {
                    AvrLn3++;
                    AvrLn3 -= AvrLn3 >> 8;
                }
                else
                if (AvrLn3 > 0)
                {
                    AvrLn3--;
                }
            }
            Length += 3;
            if (Distance >= MaxDist3)
            {
                Length++;
            }
            if (Distance <= 256)
            {
                Length += 8;
            }
            if (OldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && OldAvr2 < 0x40)
            {
                MaxDist3 = 0x7f00;
            }
            else
            {
                MaxDist3 = 0x2001;
            }
            OldDist[OldDistPtr++] = Distance;
            OldDistPtr            = OldDistPtr & 3;
            LastLength            = Length;
            LastDist = Distance;
            CopyString15(Distance, Length);
        }
Exemplo n.º 20
0
        private void ShortLZ()
        {
            uint Length, SaveLength;
            uint LastDistance;
            uint Distance;
            int  DistancePlace;

            NumHuf = 0;

            uint BitField = Inp.fgetbits();

            if (LCount == 2)
            {
                Inp.faddbits(1);
                if (BitField >= 0x8000)
                {
                    CopyString15((uint)LastDist, LastLength);
                    return;
                }
                BitField <<= 1;
                LCount     = 0;
            }

            BitField >>= 8;

//  not thread safe, replaced by GetShortLen1 and GetShortLen2 macro
//  ShortLen1[1]=ShortLen2[3]=Buf60+3;

            if (AvrLn1 < 37)
            {
                for (Length = 0;; Length++)
                {
                    if (((BitField ^ ShortXor1[Length]) & (~(0xff >> (int)GetShortLen1(Length)))) == 0)
                    {
                        break;
                    }
                }
                Inp.faddbits(GetShortLen1(Length));
            }
            else
            {
                for (Length = 0;; Length++)
                {
                    if (((BitField ^ ShortXor2[Length]) & (~(0xff >> (int)GetShortLen2(Length)))) == 0)
                    {
                        break;
                    }
                }
                Inp.faddbits(GetShortLen2(Length));
            }

            if (Length >= 9)
            {
                if (Length == 9)
                {
                    LCount++;
                    CopyString15((uint)LastDist, LastLength);
                    return;
                }
                if (Length == 14)
                {
                    LCount   = 0;
                    Length   = DecodeNum(Inp.fgetbits(), STARTL2, DecL2, PosL2) + 5;
                    Distance = (Inp.fgetbits() >> 1) | 0x8000;
                    Inp.faddbits(15);
                    LastLength = Length;
                    LastDist   = Distance;
                    CopyString15(Distance, Length);
                    return;
                }

                LCount     = 0;
                SaveLength = Length;
                Distance   = OldDist[(OldDistPtr - (Length - 9)) & 3];
                Length     = DecodeNum(Inp.fgetbits(), STARTL1, DecL1, PosL1) + 2;
                if (Length == 0x101 && SaveLength == 10)
                {
                    Buf60 ^= 1;
                    return;
                }
                if (Distance > 256)
                {
                    Length++;
                }
                if (Distance >= MaxDist3)
                {
                    Length++;
                }

                OldDist[OldDistPtr++] = Distance;
                OldDistPtr            = OldDistPtr & 3;
                LastLength            = Length;
                LastDist = Distance;
                CopyString15(Distance, Length);
                return;
            }

            LCount  = 0;
            AvrLn1 += Length;
            AvrLn1 -= AvrLn1 >> 4;

            DistancePlace = (int)(DecodeNum(Inp.fgetbits(), STARTHF2, DecHf2, PosHf2) & 0xff);
            Distance      = ChSetA[DistancePlace];
            if (--DistancePlace != -1)
            {
                LastDistance = ChSetA[DistancePlace];
                ChSetA[DistancePlace + 1] = (ushort)LastDistance;
                ChSetA[DistancePlace]     = (ushort)Distance;
            }
            Length += 2;
            OldDist[OldDistPtr++] = ++Distance;
            OldDistPtr            = OldDistPtr & 3;
            LastLength            = Length;
            LastDist = Distance;
            CopyString15(Distance, Length);
        }
Exemplo n.º 21
0
        void Unpack20(bool Solid)
        {
            uint Bits;

            if (Suspended)
            {
                UnpPtr = WrPtr;
            }
            else
            {
                UnpInitData(Solid);
                if (!UnpReadBuf())
                {
                    return;
                }
                if ((!Solid || !TablesRead2) && !ReadTables20())
                {
                    return;
                }
                --DestUnpSize;
            }

            while (DestUnpSize >= 0)
            {
                UnpPtr &= MaxWinMask;

                if (Inp.InAddr > ReadTop - 30)
                {
                    if (!UnpReadBuf())
                    {
                        break;
                    }
                }
                if (((WrPtr - UnpPtr) & MaxWinMask) < 270 && WrPtr != UnpPtr)
                {
                    UnpWriteBuf20();
                    if (Suspended)
                    {
                        return;
                    }
                }
                if (UnpAudioBlock)
                {
                    uint AudioNumber = DecodeNumber(Inp, MD[UnpCurChannel]);

                    if (AudioNumber == 256)
                    {
                        if (!ReadTables20())
                        {
                            break;
                        }
                        continue;
                    }
                    Window[UnpPtr++] = DecodeAudio((int)AudioNumber);
                    if (++UnpCurChannel == UnpChannels)
                    {
                        UnpCurChannel = 0;
                    }
                    --DestUnpSize;
                    continue;
                }

                uint Number = DecodeNumber(Inp, BlockTables.LD);
                if (Number < 256)
                {
                    Window[UnpPtr++] = (byte)Number;
                    --DestUnpSize;
                    continue;
                }
                if (Number > 269)
                {
                    uint Length = (uint)(LDecode[Number -= 270] + 3);
                    if ((Bits = LBits[Number]) > 0)
                    {
                        Length += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }

                    uint DistNumber = DecodeNumber(Inp, BlockTables.DD);
                    uint Distance   = DDecode[DistNumber] + 1;
                    if ((Bits = DBits[DistNumber]) > 0)
                    {
                        Distance += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }

                    if (Distance >= 0x2000)
                    {
                        Length++;
                        if (Distance >= 0x40000L)
                        {
                            Length++;
                        }
                    }

                    CopyString20(Length, Distance);
                    continue;
                }
                if (Number == 269)
                {
                    if (!ReadTables20())
                    {
                        break;
                    }
                    continue;
                }
                if (Number == 256)
                {
                    CopyString20(LastLength, LastDist);
                    continue;
                }
                if (Number < 261)
                {
                    uint Distance     = OldDist[(OldDistPtr - (Number - 256)) & 3];
                    uint LengthNumber = DecodeNumber(Inp, BlockTables.RD);
                    uint Length       = (uint)(LDecode[LengthNumber] + 2);
                    if ((Bits = LBits[LengthNumber]) > 0)
                    {
                        Length += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }
                    if (Distance >= 0x101)
                    {
                        Length++;
                        if (Distance >= 0x2000)
                        {
                            Length++;
                            if (Distance >= 0x40000)
                            {
                                Length++;
                            }
                        }
                    }
                    CopyString20(Length, Distance);
                    continue;
                }
                if (Number < 270)
                {
                    uint Distance = (uint)(SDDecode[Number -= 261] + 1);
                    if ((Bits = SDBits[Number]) > 0)
                    {
                        Distance += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }
                    CopyString20(2, Distance);
                    continue;
                }
            }
            ReadLastTables();
            UnpWriteBuf20();
        }
Exemplo n.º 22
0
        bool ReadTables20()
        {
            byte[] BitLength = new byte[BC20];
            byte[] Table     = new byte[MC20 * 4];
            if (Inp.InAddr > ReadTop - 25)
            {
                if (!UnpReadBuf())
                {
                    return(false);
                }
            }
            uint BitField = Inp.getbits();

            UnpAudioBlock = (BitField & 0x8000) != 0;

            if ((BitField & 0x4000) != 0)
            {
                Utility.Memset(UnpOldTable20, 0, UnpOldTable20.Length);
            }
            Inp.addbits(2);

            uint TableSize;

            if (UnpAudioBlock)
            {
                UnpChannels = ((BitField >> 12) & 3) + 1;
                if (UnpCurChannel >= UnpChannels)
                {
                    UnpCurChannel = 0;
                }
                Inp.addbits(2);
                TableSize = MC20 * UnpChannels;
            }
            else
            {
                TableSize = NC20 + DC20 + RC20;
            }

            for (uint I = 0; I < BC20; I++)
            {
                BitLength[I] = (byte)(Inp.getbits() >> 12);
                Inp.addbits(4);
            }
            MakeDecodeTables(BitLength, 0, BlockTables.BD, BC20);
            for (uint I = 0; I < TableSize;)
            {
                if (Inp.InAddr > ReadTop - 5)
                {
                    if (!UnpReadBuf())
                    {
                        return(false);
                    }
                }
                uint Number = DecodeNumber(Inp, BlockTables.BD);
                if (Number < 16)
                {
                    Table[I] = (byte)((Number + this.UnpOldTable20[I]) & 0xf);
                    I++;
                }
                else
                if (Number == 16)
                {
                    uint N = (Inp.getbits() >> 14) + 3;
                    Inp.addbits(2);
                    if (I == 0)
                    {
                        return(false); // We cannot have "repeat previous" code at the first position.
                    }
                    else
                    {
                        while (N-- > 0 && I < TableSize)
                        {
                            Table[I] = Table[I - 1];
                            I++;
                        }
                    }
                }
                else
                {
                    uint N;
                    if (Number == 17)
                    {
                        N = (Inp.getbits() >> 13) + 3;
                        Inp.addbits(3);
                    }
                    else
                    {
                        N = (Inp.getbits() >> 9) + 11;
                        Inp.addbits(7);
                    }
                    while (N-- > 0 && I < TableSize)
                    {
                        Table[I++] = 0;
                    }
                }
            }
            TablesRead2 = true;
            if (Inp.InAddr > ReadTop)
            {
                return(true);
            }
            if (UnpAudioBlock)
            {
                for (uint I = 0; I < UnpChannels; I++)
                {
                    MakeDecodeTables(Table, (int)(I * MC20), MD[I], MC20);
                }
            }
            else
            {
                MakeDecodeTables(Table, 0, BlockTables.LD, NC20);
                MakeDecodeTables(Table, (int)NC20, BlockTables.DD, DC20);
                MakeDecodeTables(Table, (int)(NC20 + DC20), BlockTables.RD, RC20);
            }
            //x memcpy(UnpOldTable20,Table,sizeof(UnpOldTable20));
            Array.Copy(Table, 0, UnpOldTable20, 0, UnpOldTable20.Length);
            return(true);
        }
Exemplo n.º 23
0
		public static float Axis(Inp inp)
		{
			float val = 0f;
			for (int i = 0; i < virtuals.Length; ++i)
			{
				if (virtuals[i].MapTo == inp)
					val += virtuals[i].GetAxis();
			}

			if (val > 1f)
				return 1f;
			if (val < -1f)
				return -1f;
			return val;
		}
Exemplo n.º 24
0
		public static bool GetDown(Inp inp)
		{
			for (int i = 0; i < virtuals.Length; ++i)
				if (virtuals[i].MapTo == inp && virtuals[i].GetDown())
					return true;
			return false;
		}
Exemplo n.º 25
0
		public static bool Get(Inp inp)
		{
			return Axis(inp) >= 0.5f;
		}
Exemplo n.º 26
0
 public void Scroll()
 {
     Inp.CaretIndex = Inp.Text.Length;
     Inp.ScrollToEnd();
     InpScroll.ScrollToEnd();
 }
Exemplo n.º 27
0
			public virtualInp(Inp mapTo, KeyCode key)
			{
				Type = type.Key;
				MapTo = mapTo;
				High = key;
			}
Exemplo n.º 28
0
        private void Unpack5(bool Solid)
        {
            FileExtracted = true;

            if (!Suspended)
            {
                UnpInitData(Solid);
                if (!UnpReadBuf())
                {
                    return;
                }

                // Check TablesRead5 to be sure that we read tables at least once
                // regardless of current block header TablePresent flag.
                // So we can safefly use these tables below.
                if (!ReadBlockHeader(Inp, ref BlockHeader) ||
                    !ReadTables(Inp, ref BlockHeader, ref BlockTables) || !TablesRead5)
                {
                    return;
                }
            }

            while (true)
            {
                UnpPtr &= MaxWinMask;

                if (Inp.InAddr >= ReadBorder)
                {
                    bool FileDone = false;

                    // We use 'while', because for empty block containing only Huffman table,
                    // we'll be on the block border once again just after reading the table.
                    while (Inp.InAddr > BlockHeader.BlockStart + BlockHeader.BlockSize - 1 ||
                           Inp.InAddr == BlockHeader.BlockStart + BlockHeader.BlockSize - 1 &&
                           Inp.InBit >= BlockHeader.BlockBitSize)
                    {
                        if (BlockHeader.LastBlockInFile)
                        {
                            FileDone = true;
                            break;
                        }
                        if (!ReadBlockHeader(Inp, ref BlockHeader) || !ReadTables(Inp, ref BlockHeader, ref BlockTables))
                        {
                            return;
                        }
                    }
                    if (FileDone || !UnpReadBuf())
                    {
                        break;
                    }
                }

                if (((WriteBorder - UnpPtr) & MaxWinMask) < MAX_LZ_MATCH + 3 && WriteBorder != UnpPtr)
                {
                    UnpWriteBuf();
                    if (WrittenFileSize > DestUnpSize)
                    {
                        return;
                    }

                    if (Suspended)
                    {
                        FileExtracted = false;
                        return;
                    }
                }

                uint MainSlot = DecodeNumber(Inp, BlockTables.LD);
                if (MainSlot < 256)
                {
                    if (Fragmented)
                    {
                        FragWindow[UnpPtr++] = (byte)MainSlot;
                    }
                    else
                    {
                        Window[UnpPtr++] = (byte)MainSlot;
                    }

                    continue;
                }
                if (MainSlot >= 262)
                {
                    uint Length = SlotToLength(Inp, MainSlot - 262);

                    uint DBits, Distance = 1, DistSlot = DecodeNumber(Inp, BlockTables.DD);
                    if (DistSlot < 4)
                    {
                        DBits     = 0;
                        Distance += DistSlot;
                    }
                    else
                    {
                        DBits     = DistSlot / 2 - 1;
                        Distance += (2 | (DistSlot & 1)) << (int)DBits;
                    }

                    if (DBits > 0)
                    {
                        if (DBits >= 4)
                        {
                            if (DBits > 4)
                            {
                                Distance += ((Inp.getbits32() >> (int)(36 - DBits)) << 4);
                                Inp.addbits(DBits - 4);
                            }
                            uint LowDist = DecodeNumber(Inp, BlockTables.LDD);
                            Distance += LowDist;
                        }
                        else
                        {
                            Distance += Inp.getbits32() >> (int)(32 - DBits);
                            Inp.addbits(DBits);
                        }
                    }

                    if (Distance > 0x100)
                    {
                        Length++;
                        if (Distance > 0x2000)
                        {
                            Length++;
                            if (Distance > 0x40000)
                            {
                                Length++;
                            }
                        }
                    }

                    InsertOldDist(Distance);
                    LastLength = Length;
                    if (Fragmented)
                    {
                        FragWindow.CopyString(Length, Distance, ref UnpPtr, MaxWinMask);
                    }
                    else
                    {
                        CopyString(Length, Distance);
                    }

                    continue;
                }
                if (MainSlot == 256)
                {
                    UnpackFilter Filter = new UnpackFilter();
                    if (!ReadFilter(Inp, Filter) || !AddFilter(Filter))
                    {
                        break;
                    }

                    continue;
                }
                if (MainSlot == 257)
                {
                    if (LastLength != 0)
                    {
                        if (Fragmented)
                        {
                            FragWindow.CopyString(LastLength, OldDist[0], ref UnpPtr, MaxWinMask);
                        }
                        else
                        {
                            CopyString(LastLength, OldDist[0]);
                        }
                    }

                    continue;
                }
                if (MainSlot < 262)
                {
                    uint DistNum  = MainSlot - 258;
                    uint Distance = OldDist[DistNum];
                    for (uint I = DistNum; I > 0; I--)
                    {
                        OldDist[I] = OldDist[I - 1];
                    }

                    OldDist[0] = Distance;

                    uint LengthSlot = DecodeNumber(Inp, BlockTables.RD);
                    uint Length     = SlotToLength(Inp, LengthSlot);
                    LastLength = Length;
                    if (Fragmented)
                    {
                        FragWindow.CopyString(Length, Distance, ref UnpPtr, MaxWinMask);
                    }
                    else
                    {
                        CopyString(Length, Distance);
                    }

                    continue;
                }
            }
            UnpWriteBuf();
        }
Exemplo n.º 29
0
        void Unpack29(bool Solid)
        {
            uint Bits;

            if (DDecode[1] == 0)
            {
                int Dist = 0, BitLength = 0, Slot = 0;
                for (int I = 0; I < DBitLengthCounts.Length; I++, BitLength++)
                {
                    for (int J = 0; J < DBitLengthCounts[I]; J++, Slot++, Dist += (1 << BitLength))
                    {
                        DDecode[Slot] = Dist;
                        DBits[Slot]   = (byte)BitLength;
                    }
                }
            }

            FileExtracted = true;

            if (!Suspended)
            {
                UnpInitData(Solid);
                if (!UnpReadBuf30())
                {
                    return;
                }
                if ((!Solid || !TablesRead3) && !ReadTables30())
                {
                    return;
                }
            }

            while (true)
            {
                UnpPtr &= MaxWinMask;

                if (Inp.InAddr > ReadBorder)
                {
                    if (!UnpReadBuf30())
                    {
                        break;
                    }
                }
                if (((WrPtr - UnpPtr) & MaxWinMask) < 260 && WrPtr != UnpPtr)
                {
                    UnpWriteBuf30();
                    if (WrittenFileSize > DestUnpSize)
                    {
                        return;
                    }
                    if (Suspended)
                    {
                        FileExtracted = false;
                        return;
                    }
                }
                if (UnpBlockType == BLOCK_PPM)
                {
                    // Here speed is critical, so we do not use SafePPMDecodeChar,
                    // because sometimes even the inline function can introduce
                    // some additional penalty.
                    int Ch = PPM.DecodeChar();
                    if (Ch == -1)                // Corrupt PPM data found.
                    {
                        PPM.CleanUp();           // Reset possibly corrupt PPM data structures.
                        UnpBlockType = BLOCK_LZ; // Set faster and more fail proof LZ mode.
                        break;
                    }
                    if (Ch == PPMEscChar)
                    {
                        int NextCh = SafePPMDecodeChar();
                        if (NextCh == 0) // End of PPM encoding.
                        {
                            if (!ReadTables30())
                            {
                                break;
                            }
                            continue;
                        }
                        if (NextCh == -1) // Corrupt PPM data found.
                        {
                            break;
                        }
                        if (NextCh == 2) // End of file in PPM mode.
                        {
                            break;
                        }
                        if (NextCh == 3) // Read VM code.
                        {
                            if (!ReadVMCodePPM())
                            {
                                break;
                            }
                            continue;
                        }
                        if (NextCh == 4) // LZ inside of PPM.
                        {
                            uint Distance = 0, Length;
                            bool Failed = false;
                            for (int I = 0; I < 4 && !Failed; I++)
                            {
                                int _Ch = SafePPMDecodeChar();
                                if (_Ch == -1)
                                {
                                    Failed = true;
                                }
                                else
                                if (I == 3)
                                {
                                    Length = (byte)_Ch;
                                }
                                else
                                {
                                    Distance = (Distance << 8) + (byte)_Ch;
                                }
                            }
                            if (Failed)
                            {
                                break;
                            }

                            CopyString(Length + 32, Distance + 2);
                            continue;
                        }
                        if (NextCh == 5) // One byte distance match (RLE) inside of PPM.
                        {
                            int Length = SafePPMDecodeChar();
                            if (Length == -1)
                            {
                                break;
                            }
                            CopyString((uint)(Length + 4), 1);
                            continue;
                        }
                        // If we are here, NextCh must be 1, what means that current byte
                        // is equal to our 'escape' byte, so we just store it to Window.
                    }
                    Window[UnpPtr++] = (byte)Ch;
                    continue;
                }

                uint Number = DecodeNumber(Inp, BlockTables.LD);
                if (Number < 256)
                {
                    Window[UnpPtr++] = (byte)Number;
                    continue;
                }
                if (Number >= 271)
                {
                    uint Length = (uint)(LDecode[Number -= 271] + 3);
                    if ((Bits = LBits[Number]) > 0)
                    {
                        Length += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }

                    uint DistNumber = DecodeNumber(Inp, BlockTables.DD);
                    uint Distance   = (uint)(DDecode[DistNumber] + 1);
                    if ((Bits = DBits[DistNumber]) > 0)
                    {
                        if (DistNumber > 9)
                        {
                            if (Bits > 4)
                            {
                                Distance += ((Inp.getbits() >> (int)(20 - Bits)) << 4);
                                Inp.addbits(Bits - 4);
                            }
                            if (LowDistRepCount > 0)
                            {
                                LowDistRepCount--;
                                Distance += (uint)PrevLowDist;
                            }
                            else
                            {
                                uint LowDist = DecodeNumber(Inp, BlockTables.LDD);
                                if (LowDist == 16)
                                {
                                    LowDistRepCount = (int)(LOW_DIST_REP_COUNT - 1);
                                    Distance       += (uint)PrevLowDist;
                                }
                                else
                                {
                                    Distance   += LowDist;
                                    PrevLowDist = (int)LowDist;
                                }
                            }
                        }
                        else
                        {
                            Distance += Inp.getbits() >> (int)(16 - Bits);
                            Inp.addbits(Bits);
                        }
                    }

                    if (Distance >= 0x2000)
                    {
                        Length++;
                        if (Distance >= 0x40000)
                        {
                            Length++;
                        }
                    }

                    InsertOldDist(Distance);
                    LastLength = Length;
                    CopyString(Length, Distance);
                    continue;
                }
                if (Number == 256)
                {
                    if (!ReadEndOfBlock())
                    {
                        break;
                    }
                    continue;
                }
                if (Number == 257)
                {
                    if (!ReadVMCode())
                    {
                        break;
                    }
                    continue;
                }
                if (Number == 258)
                {
                    if (LastLength != 0)
                    {
                        CopyString(LastLength, OldDist[0]);
                    }
                    continue;
                }
                if (Number < 263)
                {
                    uint DistNum  = Number - 259;
                    uint Distance = OldDist[DistNum];
                    for (uint I = DistNum; I > 0; I--)
                    {
                        OldDist[I] = OldDist[I - 1];
                    }
                    OldDist[0] = Distance;

                    uint LengthNumber = DecodeNumber(Inp, BlockTables.RD);
                    int  Length       = LDecode[LengthNumber] + 2;
                    if ((Bits = LBits[LengthNumber]) > 0)
                    {
                        Length += (int)(Inp.getbits() >> (int)(16 - Bits));
                        Inp.addbits(Bits);
                    }
                    LastLength = (uint)Length;
                    CopyString((uint)Length, Distance);
                    continue;
                }
                if (Number < 272)
                {
                    uint Distance = (uint)(SDDecode[Number -= 263] + 1);
                    if ((Bits = SDBits[Number]) > 0)
                    {
                        Distance += Inp.getbits() >> (int)(16 - Bits);
                        Inp.addbits(Bits);
                    }
                    InsertOldDist(Distance);
                    LastLength = 2;
                    CopyString(2, Distance);
                    continue;
                }
            }
            UnpWriteBuf30();
        }
Exemplo n.º 30
0
		public static bool Axis(Inp inp, out float value)
		{
			value = Axis(inp);
			return value != 0f;
		}