public static byte[] read32bits(MemoryDomainProxy mdp, long address) { return(new byte[] { mdp.PeekByte(address), mdp.PeekByte(address + 1), mdp.PeekByte(address + 2), mdp.PeekByte(address + 3) }); }
//The freeze engine is very similar to the Hellgenie and shares common functions with it. See RTC_HellgenieEngine.cs for cheat-related methods. public static BlastCheat GenerateUnit(string _domain, long _address) { try { MemoryDomainProxy mdp = RTC_MemoryDomains.getProxy(_domain, _address); BizHawk.Client.Common.DisplayType _displaytype = BizHawk.Client.Common.DisplayType.Unsigned; byte[] _value; if (RTC_Core.CustomPrecision == -1) { _value = new byte[mdp.WordSize]; } else { _value = new byte[RTC_Core.CustomPrecision]; } long safeAddress = _address - (_address % _value.Length); for (int i = 0; i < _value.Length; i++) { _value[i] = 0; } //_value[i] = mdp.PeekByte(safeAddress + i); return(new BlastCheat(_domain, safeAddress, _displaytype, mdp.BigEndian, _value, true, true)); } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Freeze Engine. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return(null); } }
public static BlastUnit GenerateUnit(string _domain, long _address) { // Randomly selects a memory operation according to the selected algorithm try { MemoryDomainProxy mdp = RTC_MemoryDomains.getProxy(_domain, _address); int pipeSize; if (RTC_Core.CustomPrecision == -1) { pipeSize = mdp.WordSize; } else { pipeSize = RTC_Core.CustomPrecision; } long safeAddress = _address - (_address % pipeSize); if (ChainedPipes) { if (lastDomain == null) // The first unit will always be null { lastDomain = _domain; lastAddress = safeAddress; return(null); } else { BlastPipe bp = new BlastPipe(_domain, safeAddress, lastDomain, lastAddress, tiltValue, pipeSize, true); lastDomain = _domain; lastAddress = safeAddress; return(bp); } } else { var pipeEnd = RTC_Core.GetBlastTarget(); long safepipeEndAddress = pipeEnd.address - (pipeEnd.address % pipeSize); BlastPipe bp = new BlastPipe(_domain, safeAddress, pipeEnd.domain, safepipeEndAddress, tiltValue, pipeSize, true); lastDomain = _domain; lastAddress = safeAddress; return(bp); } } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Pipe Engine. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return(null); } }
public static BlastUnit GenerateUnit(string _domain, long _address) { // Randomly selects a memory operation according to the selected algorithm //long safeAddress = _address - (_address % 8); //64-bit trunk long safeAddress = _address - (_address % 4); //32-bit trunk MemoryDomainProxy mdp = RTC_MemoryDomains.getProxy(_domain, safeAddress); if (mdp == null) { return(null); } try { BlastVector bv = null; lastValues = read32bits(mdp, safeAddress); lastDomain = _domain; if (isConstant(lastValues, limiterList)) { bv = new BlastVector(_domain, _address, getRandomConstant(valueList), true); } return(bv); } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Vector Engine. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return(null); } }
public static BlastUnit GenerateUnit(string _domain, long _address) { // Randomly selects a memory operation according to the selected algorithm try { MemoryDomainProxy mdp = RTC_MemoryDomains.getProxy(_domain, _address); BlastByteType Type = BlastByteType.SET; byte[] _value;; if (RTC_Core.CustomPrecision == -1) { _value = new byte[mdp.WordSize]; } else { _value = new byte[RTC_Core.CustomPrecision]; } for (int i = 0; i < _value.Length; i++) { _value[i] = 1; } long safeAddress = _address - (_address % _value.Length); BlastByte bb = new BlastByte(_domain, safeAddress, Type, _value, true); return(bb.GetBackup()); } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Distortion Engine. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return(null); } }
public static BlastUnit GenerateUnit(string _domain, long _address) { // Randomly selects a memory operation according to the selected algorithm try { MemoryDomainProxy mdp = RTC_MemoryDomains.getProxy(_domain, _address); BlastByteType Type = BlastByteType.NONE; switch (Algo) { case BlastByteAlgo.RANDOM: //RANDOM always sets a random value Type = BlastByteType.SET; break; case BlastByteAlgo.RANDOMTILT: //RANDOMTILT may add 1,substract 1 or set a random value int result = RTC_Core.RND.Next(1, 4); switch (result) { case 1: Type = BlastByteType.ADD; break; case 2: Type = BlastByteType.SUBSTRACT; break; case 3: Type = BlastByteType.SET; break; default: MessageBox.Show("Random returned an unexpected value (RTC_NightmareEngine switch(Algo) RANDOMTILT)"); return(null); } break; case BlastByteAlgo.TILT: //TILT can either add 1 or substract 1 result = RTC_Core.RND.Next(1, 3); switch (result) { case 1: Type = BlastByteType.ADD; break; case 2: Type = BlastByteType.SUBSTRACT; break; default: MessageBox.Show("Random returned an unexpected value (RTC_NightmareEngine switch(Algo) TILT)"); return(null); } break; } byte[] _value; if (RTC_Core.CustomPrecision == -1) { _value = new byte[mdp.WordSize]; } else { _value = new byte[RTC_Core.CustomPrecision]; } long safeAddress = _address - (_address % _value.Length); if (Type == BlastByteType.SET) { for (int i = 0; i < _value.Length; i++) { _value[i] = (byte)RTC_Core.RND.Next(0, 255); } } else //ADD, SUBSTRACT { for (int i = 0; i < _value.Length; i++) //1 by default because Add(1) or Substract(1) but more is still possible { _value[i] = 1; } } return(new BlastByte(_domain, safeAddress, Type, _value, true)); } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Nightmare Engine. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return(null); } }