public async Task <bool> waitNTRread(uint address) { Report("NTR: Read data at address 0x" + address.ToString("X8")); lastRead = 0; DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (timeout) { Report("NTR: Read failed"); return(false); } else { return(true); } }
public async Task <bool> waitNTRmultiread(uint address, uint size) { Report("NTR: Read " + size + " bytes of data starting at address 0x" + address.ToString("X8")); lastmultiread = new byte[] { }; DataReadyWaiting myArgs = new DataReadyWaiting(new byte[size], handlemulitMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, size, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (timeout) { Report("NTR: Read failed"); return(false); } else { return(true); } }
// Memory Read Handler private void handleMemoryRead(object args_obj) { DataReadyWaiting args = (DataReadyWaiting)args_obj; lastRead = BitConverter.ToUInt32(args.data, 0); Program.gCmdWindow.HandleRAMread(lastRead); }
public async Task <bool> memoryinrange(uint address, uint value, uint range) { lastRead = 0; WriteLastLog(""); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); int readcount = 0; for (readcount = 0; readcount < timeout * 10; readcount++) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (readcount < timeout * 10) { // Data received if (lastRead >= value && lastRead < value + range) { return(true); } else { return(false); } } else // No data received { return(false); } }
public async Task <long> waitPartyRead(uint partyOff, int slot) { uint dumpOff = Program.gCmdWindow.partyOff + Convert.ToUInt32(slot * 484); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[POKEBYTES], handlePokeRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(dumpOff, POKEBYTES, pid), myArgs); int readcount = 0; for (readcount = 0; readcount < timeout * 10; readcount++) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (readcount == timeout * 10) { return(-2); // No data received } else if (validator.Species != 0) { Program.gCmdWindow.dumpedPKHeX.Data = validator.Data; Program.gCmdWindow.updateTabs(); return(validator.PID); } else // Empty slot { return(-1); } }
public async Task <bool> waitNTRread(uint address) { lastRead = 0; WriteLastLog(""); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); int readcount = 0; for (readcount = 0; readcount < timeout * 10; readcount++) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (readcount == timeout * 10) { return(false); } else { return(true); } }
public async Task <PKM> waitPokeRead(NumericUpDown boxCtrl, NumericUpDown slotCtrl) { try { int box = (int)boxCtrl.Value - 1; int slot = (int)slotCtrl.Value - 1; Report("NTR: Read pokémon data at box " + (box + 1) + ", slot " + (slot + 1)); // Get offset uint dumpOff = Program.gCmdWindow.boxOff + (Convert.ToUInt32(box * BOXSIZE + slot) * POKEBYTES); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[POKEBYTES], handlePokeRead, null); Program.gCmdWindow.UpdateDumpBoxes(box, slot); Program.gCmdWindow.AddWaitingForData(Program.scriptHelper.data(dumpOff, POKEBYTES, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (timeout) { // No read Report("NTR: Read failed"); return(null); } if (validator.ChecksumValid && validator.Species > 0 && validator.Species <= Program.gCmdWindow.MAXSPECIES) { // Valid pokemon NTRtimer.Stop(); lastRead = validator.Checksum; Program.gCmdWindow.Pokemon = validator; Report("NTR: Read sucessful - PID 0x" + validator.PID.ToString("X8")); return(validator); } else if (validator.ChecksumValid && validator.Species == 0) { // Empty slot NTRtimer.Stop(); Report("NTR: Empty pokémon data"); return(Program.gCmdWindow.SAV.BlankPKM); } else { // Invalid pokémon NTRtimer.Stop(); Report("NTR: Invalid pokémon data"); return(null); } } catch (Exception ex) { NTRtimer.Stop(); Report("NTR: Read failed with exception:"); Report(ex.Message); return(null); // No data received } }
public async Task <PKM> waitPartyRead(uint slot) { try { Report("NTR: Read pokémon data at party slot " + slot); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[PARTYBYTES], handlePokeRead, null); uint offset = Program.gCmdWindow.partyOff + 484 * (slot - 1); Program.gCmdWindow.AddWaitingForData(Program.scriptHelper.data(offset, PARTYBYTES, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (timeout) { // No read Report("NTR: Read failed"); return(null); } if (validator.ChecksumValid && validator.Species > 0 && validator.Species <= Program.gCmdWindow.MAXSPECIES) { // Valid pokemon NTRtimer.Stop(); lastRead = validator.Checksum; Program.gCmdWindow.Pokemon = validator; Report("NTR: Read sucessful - PID 0x" + validator.PID.ToString("X8")); return(validator); } else if (validator.ChecksumValid && validator.Species == 0) { // Empty slot NTRtimer.Stop(); Report("NTR: Empty pokémon data"); return(Program.gCmdWindow.SAV.BlankPKM); } else { // Invalid pokémon NTRtimer.Stop(); Report("NTR: Invalid pokémon data"); return(null); } } catch (Exception ex) { NTRtimer.Stop(); Report("NTR: Read failed with exception:"); Report(ex.Message); return(null); // No data received } }
private void handlePokeRead(object args_obj) { DataReadyWaiting args = (DataReadyWaiting)args_obj; if (Program.gCmdWindow.SAV.Generation == 6) { validator = new PK6(PKX.DecryptArray(args.data)); } else { validator = new PK7(PKX.DecryptArray(args.data)); } }
public async Task <bool> timememoryinrange(uint address, uint value, uint range, int tick, int maxtime) { Report("NTR: Read data at address 0x" + address.ToString("X8") + " during " + maxtime + " ms"); Report("NTR: Expected value 0x" + value.ToString("X8") + " to 0x" + (value + range - 1).ToString("X8")); int readcount = 0; setTimer(maxtime); while (!timeout || readcount < 5) { // Ask for data lastRead = value + range; DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); // Wait for data while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } if (timeout && readcount < 5) { Report("NTR: Restarting timeout"); setTimer(maxtimeout); break; } } if (lastRead >= value && lastRead < value + range) { NTRtimer.Stop(); Report("NTR: Value in range: YES"); return(true); } else { Report("NTR: Value in range: No"); await Task.Delay(tick); } if (timeout && readcount < 5) { Report("NTR: Restarting timeout"); setTimer(maxtimeout); } readcount++; } Report("NTR: Read failed or outside of range"); return(false); }
public async Task <long> waitPokeRead(int box, int slot) { try { Report("NTR: Read pokémon data at box " + (box + 1) + ", slot " + (slot + 1)); // Get offset uint dumpOff = Program.gCmdWindow.boxOff + (Convert.ToUInt32(box * BOXSIZE + slot) * POKEBYTES); DataReadyWaiting myArgs = new DataReadyWaiting(new byte[POKEBYTES], handlePokeRead, null); Program.gCmdWindow.updateDumpBoxes(box, slot); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(dumpOff, POKEBYTES, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (timeout) { Report("NTR: Read failed"); return(-2); } else if (validator.Species > 0 && validator.Species <= Program.gCmdWindow.MAXSPECIES) { NTRtimer.Stop(); lastRead = (uint)validator.Species; Program.gCmdWindow.dumpedPKHeX.Data = validator.Data; Program.gCmdWindow.updateTabs(); Report("NTR: Read sucessful - PID 0x" + validator.PID.ToString("X8")); return(validator.PID); } else // Empty slot { NTRtimer.Stop(); Report("NTR: Empty pokémon data"); return(-1); } } catch (Exception ex) { NTRtimer.Stop(); Report("NTR: Read failed with exception:"); Report(ex.Message); return(-2); // No data received } }
public async Task <bool> memoryinrange(uint address, uint value, uint range) { Report("NTR: Read data at address 0x" + address.ToString("X8")); Report("NTR: Expected value 0x" + value.ToString("X8") + " to 0x" + (value + range - 1).ToString("X8")); lastRead = value + range; DataReadyWaiting myArgs = new DataReadyWaiting(new byte[0x04], handleMemoryRead, null); Program.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); setTimer(maxtimeout); while (!timeout) { await Task.Delay(100); if (CompareLastLog("finished")) { break; } } if (!timeout) { // Data received if (lastRead >= value && lastRead < value + range) { NTRtimer.Stop(); Report("NTR: Value in range: YES"); return(true); } else { Report("NTR: Value in range: NO"); return(false); } } else // No data received { Report("NTR: Read failed"); return(false); } }
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.gCmdWindow.addwaitingForData(Program.scriptHelper.data(address, 0x04, pid), myArgs); // Wait for data int readcount = 0; for (readcount = 0; readcount < timeout * 10; readcount++) { await Task.Delay(100); time += 100; if (CompareLastLog("finished")) { break; } } if (readcount < timeout * 10) { // 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); }
private void handlePokeRead(object args_obj) { DataReadyWaiting args = (DataReadyWaiting)args_obj; validator.Data = PKHeX.decryptArray(args.data); }
private void handlemulitMemoryRead(object args_obj) { DataReadyWaiting args = (DataReadyWaiting)args_obj; lastmultiread = args.data; }