コード例 #1
0
        public async Task <bool> waitNTRread(uint address, uint size)
        {
            lastRead  = 0;
            lastArray = null;
            WriteLastLog("");
            DataReadyWaiting myArgs = new DataReadyWaiting(new byte[size], handleMemoryRead, null);

            Program.f1.addwaitingForData(Program.scriptHelper.data(address, size, pid), myArgs);
            int readcount = 0;

            for (readcount = 0; readcount < timeout * 100; readcount++)
            {
                await Task.Delay(10);

                if (CompareLastLog("finished"))
                {
                    break;
                }
            }
            if (readcount == timeout * 100)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #2
0
        public async Task <bool> memoryinrange(uint address, uint value, uint range)
        {
            lastRead = 0;
            WriteLastLog("");
            DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null);

            Program.f1.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs);
            int readcount = 0;

            for (readcount = 0; readcount < timeout * 100; readcount++)
            {
                await Task.Delay(10);

                if (CompareLastLog("finished"))
                {
                    break;
                }
            }
            if (readcount < timeout * 100)
            { // Data received
                if (lastRead >= value && lastRead < value + range)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else // No data received
            {
                return(false);
            }
        }
コード例 #3
0
        public async Task <long> waitPartyRead(uint partyOff, int slot)
        {
            uint             dumpOff = Program.f1.partyOff + Convert.ToUInt32(slot * 484);
            DataReadyWaiting myArgs  = new DataReadyWaiting(new byte[POKEBYTES], handlePokeRead, null);

            Program.f1.addwaitingForData(Program.scriptHelper.data(dumpOff, POKEBYTES, pid), myArgs);
            int readcount = 0;

            for (readcount = 0; readcount < timeout * 100; readcount++)
            {
                await Task.Delay(10);

                if (CompareLastLog("finished"))
                {
                    break;
                }
            }
            if (readcount == timeout * 100)
            {
                return(-2); // No data received
            }
            else if (validator.Species != 0)
            {
                Program.f1.dumpedPKHeX.Data = validator.Data;
                return(validator.PID);
            }
            else // Empty slot
            {
                return(-1);
            }
        }
コード例 #4
0
        // Memory Read Handler
        private void handleMemoryRead(object args_obj)
        {
            DataReadyWaiting args = (DataReadyWaiting)args_obj;

            if (args.data.Length == 4)
            {
                lastRead  = BitConverter.ToUInt32(args.data, 0);
                lastArray = args.data;
            }
            else
            {
                lastArray = args.data;
            }
        }
コード例 #5
0
        public async Task <bool> timememoryinrange(uint address, uint value, uint range, int tick, int maxtime)
        {
            int time = 0;

            while (time < maxtime)
            { // Ask for data
                lastRead = 0;
                WriteLastLog("");
                DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null);
                Program.f1.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs);
                // Wait for data
                int readcount = 0;
                for (readcount = 0; readcount < timeout * 100; readcount++)
                {
                    await Task.Delay(10);

                    time += 100;
                    if (CompareLastLog("finished"))
                    {
                        break;
                    }
                }
                if (readcount < timeout * 100)
                { // Data received
                    if (lastRead >= value && lastRead < value + range)
                    {
                        return(true);
                    }
                    else
                    {
                        await Task.Delay(tick);

                        time += tick;
                    }
                } // If no data received or not in range, try again
            }
            return(false);
        }
コード例 #6
0
 public void addwaitingForData(uint newkey, DataReadyWaiting newvalue)
 {
     waitingForData.Add(newkey, newvalue);
 }
コード例 #7
0
        private void handlePokeRead(object args_obj)
        {
            DataReadyWaiting args = (DataReadyWaiting)args_obj;

            validator.Data = PKHeX.decryptArray(args.data);
        }