Exemplo n.º 1
0
        async Task <bool> doCheckSplit(Split split)
        {
            var addressSizePairs = new List <Tuple <uint, uint> >();

            addressSizePairs.Add(new Tuple <uint, uint>(split.addressInt, 2));
            if (split.more != null)
            {
                foreach (var moreSplit in split.more)
                {
                    addressSizePairs.Add(new Tuple <uint, uint>(moreSplit.addressInt, 2));
                }
            }
            List <byte[]> data = null;

            try
            {
                data = await _usb2snes.GetAddress(addressSizePairs);
            }
            catch
            {
                Debug.WriteLine("doCheckSplit: Exception getting address");
                CheckConnection();
                return(false);
            }

            if ((null == data) || (data.Count != addressSizePairs.Count))
            {
                Debug.WriteLine("doCheckSplit: Get address failed to return result");
                CheckConnection();
                return(false);
            }

            uint value  = (uint)data[0][0];
            uint word   = value + ((uint)data[0][1] << 8);
            bool result = split.check(value, word);

            if (result && (split.more != null))
            {
                int dataIndex = 1;
                foreach (var moreSplit in split.more)
                {
                    value = (uint)data[dataIndex][0];
                    word  = value + ((uint)data[dataIndex][1] << 8);
                    if (!moreSplit.check(value, word))
                    {
                        return(false);
                    }
                    dataIndex++;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        async Task <bool> doCheckSplit(Split split)
        {
            byte[] data;
            try
            {
                uint numBytes = 2u;
                if (split.type == "smboss")
                {
                    numBytes = 0x10u;
                }

                data = await _usb2snes.GetAddress((0xF50000 + split.addressInt), numBytes);
            }
            catch
            {
                Debug.WriteLine("doCheckSplit: Exception getting address");
                return(false);
            }

            if (data.Count() == 0)
            {
                Debug.WriteLine("doCheckSplit: Get address failed to return result");
                return(false);
            }

            uint value = (uint)data[0];
            uint word  = (uint)(data[0] + (data[1] << 8));

            Debug.WriteLine("Address checked : " + split.address + " - value : " + value);

            if (split.type == "smboss")
            {
                if (!data.SequenceEqual(_smEventFlags))
                {
                    _smEventFlags = data;
                    int[] bosses    = new int[] { 0x9, 0xB, 0xC, 0xA }; // offsets from 0xD820
                    int   bossCount = 0;
                    foreach (int idx in bosses)
                    {
                        bossCount += data[idx] & 0x01;
                    }
                    if (bossCount > _smBossCount)
                    {
                        _smBossCount = bossCount;
                        return(true);
                    }
                }
                return(false);
            }
            return(split.check(value, word));
        }
        async Task <bool> doCheckSplit(Split split)
        {
            byte[] data;
            try
            {
                data = await _usb2snes.GetAddress((0xF50000 + split.addressint), (uint)2);
            }
            catch
            {
                return(false);
            }
            if (data.Count() == 0)
            {
                Console.WriteLine("Get address failed to return result");
                return(false);
            }
            uint value = (uint)data[0];
            uint word  = (uint)(data[0] + (data[1] << 8));

            Debug.WriteLine("Address checked : " + split.address + " - value : " + value);
            return(split.check(value, word));
        }