public override BlastUnit GetBackup() { if (!IsEnabled) { return(null); } try { MemoryDomain md = RTC_MemoryZones.getDomain(Domain); if (md == null || Type == BlastByteType.NONE) { return(null); } return(new BlastByte(Domain, Address, BlastByteType.SET, md.PeekByte(Address), true)); } catch (Exception ex) { MessageBox.Show("The BlastByte apply() function threw up. \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 override void Apply() { if (!IsEnabled) { return; } try { MemoryDomain md = RTC_MemoryZones.getDomain(Domain); if (md == null || md.PokeByte == null) { return; } switch (Type) { case BlastByteType.SET: md.PokeByte(Address, (byte)Value); break; case BlastByteType.ADD: md.PokeByte(Address, (byte)(md.PeekByte(Address) + Value)); break; case BlastByteType.SUBSTRACT: md.PokeByte(Address, (byte)(md.PeekByte(Address) - Value)); break; case BlastByteType.NONE: return; } } catch (Exception ex) { MessageBox.Show("The BlastByte apply() function threw up. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return; } }
public override void Apply() { try { if (!IsEnabled) { return; } MemoryDomain md = RTC_MemoryZones.getDomain(Domain); if (md == null) { return; } string cheatName = "RTC Cheat|" + Domain + "|" + address.ToString() + "|" + displayType.ToString() + "|" + bigEndian.ToString() + "|" + value.ToString() + "|" + IsEnabled.ToString() + "|" + IsFreeze.ToString(); if (!IsFreeze) { Watch somewatch = Watch.GenerateWatch(md, address, size, displayType, bigEndian, cheatName, value, 0, 0); Cheat ch = new Cheat(somewatch, value, null, true); Global.CheatList.Add(ch); RTC_HellgenieEngine.RemoveExcessCheats(); } else { RTC_Core.hexeditor.FreezeAddress(address, cheatName); RTC_FreezeEngine.RemoveExcessCheats(); } } catch (Exception ex) { MessageBox.Show("The BlastCheat apply() function threw up. \n" + "This is not a BizHawk error so you should probably send a screenshot of this to the devs\n\n" + ex.ToString()); return; } }
public static BlastLayer GetLayer() { if (!File.Exists("CorruptedROM.rom")) { MessageBox.Show("Null Plugin: You must have CorruptedROM.rom in your BizHawk folder"); return(null); } CorruptedRom = "CorruptedROM.rom"; BlastLayer bl = new BlastLayer(); string thisSystem = Global.Game.System; string _domain = ""; string _seconddomain = ""; int skipbytes = 0; switch (thisSystem) { case "NES": _domain = "PRG ROM"; _seconddomain = "CHR VROM"; skipbytes = 16; break; case "SNES": _domain = "CARTROM"; break; case "N64": _domain = "ROM"; break; case "GB": case "GBC": _domain = "ROM"; break; case "SMS": // Sega Master System _domain = "ROM"; return(null); case "GEN": // Sega Genesis _domain = "MD CART"; break; case "PSX": // PlayStation MessageBox.Show("Unfortunately, Bizhawk doesn't support editing the PSX's ISO while it is running. Maybe in a future version..."); return(null); case "INTV": case "SG": case "GG": case "PCECD": case "PCE": case "SGX": case "TI83": case "A26": case "A78": case "C64": case "Coleco": case "GBA": case "SAT": case "DGB": default: MessageBox.Show("The selected system doesn't appear to have bridge configurations yet. This will not work. You could ask the devs to add it though."); break; } byte[] Original = File.ReadAllBytes(GlobalWin.MainForm.CurrentlyOpenRom); byte[] Corrupt = File.ReadAllBytes("CorruptedROM.rom"); if (Original.Length != Corrupt.Length) { MessageBox.Show("Error: The corrupted rom isn't the same size as the original one"); return(null); } long maxaddress = RTC_MemoryZones.getDomain(_domain).Size; for (int i = 0; i < Original.Length; i++) { if (Original[i] != Corrupt[i] && i >= skipbytes) { if (i - skipbytes >= maxaddress) { bl.Layer.Add(new BlastByte(_seconddomain, (i - skipbytes) - maxaddress, BlastByteType.SET, Convert.ToInt32(Corrupt[i]), true)); } else { bl.Layer.Add(new BlastByte(_domain, i - skipbytes, BlastByteType.SET, Convert.ToInt32(Corrupt[i]), true)); } } } if (bl.Layer.Count == 0) { return(null); } else { return(bl); } }
//Generates or queries a blast layer then applies it. public static BlastLayer Blast(BlastLayer _layer) { try { if (_layer != null) { _layer.Apply(); //If the BlastLayer was provided, there's no need to generate a new one. return(_layer); } else if (RTC_Core.SelectedEngine == CorruptionEngine.EXTERNALROM) { BlastLayer romLayer = RTC_ExternalRomPlugin.GetLayer(); if (romLayer == null) { return(null); } else { romLayer.Apply(); return(romLayer); } } else { BlastLayer bl = new BlastLayer(); if (RTC_Core.SelectedEngine != CorruptionEngine.FREEZE && RTC_MemoryZones.SelectedDomains.Count == 0) { return(null); } string Domain; long MaxAdress; long RandomAdress = 0; BlastUnit bu; if (RTC_Core.SelectedEngine == CorruptionEngine.DISTORTION && RTC_DistortionEngine.CurrentAge < RTC_DistortionEngine.MaxAge) { RTC_DistortionEngine.CurrentAge++; } switch (Radius) { case BlastRadius.SPREAD: for (int i = 0; i < Intensity; i++) //Randomly spreads all corruption bytes to all selected zones { if (RTC_Core.SelectedEngine != CorruptionEngine.FREEZE) { Domain = RTC_MemoryZones.SelectedDomains[RND.Next(RTC_MemoryZones.SelectedDomains.Count)]; } else { Domain = RTC_Core.hexeditor._domain.ToString(); } MaxAdress = RTC_MemoryZones.getDomain(Domain).Size; RandomAdress = LongRandom(MaxAdress); bu = getBlastUnit(Domain, RandomAdress); if (bu != null) { bl.Layer.Add(bu); } } break; case BlastRadius.CHUNK: //Randomly spreads the corruption bytes in one randomly selected zone if (RTC_Core.SelectedEngine != CorruptionEngine.FREEZE) { Domain = RTC_MemoryZones.SelectedDomains[RND.Next(RTC_MemoryZones.SelectedDomains.Count)]; } else { Domain = RTC_Core.hexeditor._domain.ToString(); } MaxAdress = RTC_MemoryZones.getDomain(Domain).Size; for (int i = 0; i < Intensity; i++) { RandomAdress = LongRandom(MaxAdress); bu = getBlastUnit(Domain, RandomAdress); if (bu != null) { bl.Layer.Add(bu); } } break; case BlastRadius.BURST: for (int j = 0; j < 10; j++) // 10 shots of 10% chunk { if (RTC_Core.SelectedEngine != CorruptionEngine.FREEZE) { Domain = RTC_MemoryZones.SelectedDomains[RND.Next(RTC_MemoryZones.SelectedDomains.Count)]; } else { Domain = RTC_Core.hexeditor._domain.ToString(); } MaxAdress = RTC_MemoryZones.getDomain(Domain).Size; for (int i = 0; i < (int)((double)Intensity / 10); i++) { RandomAdress = LongRandom(MaxAdress); bu = getBlastUnit(Domain, RandomAdress); if (bu != null) { bl.Layer.Add(bu); } } } break; case BlastRadius.NONE: return(null); } bl.Apply(); RTC_HellgenieEngine.RemoveExcessCheats(); if (bl.Layer.Count == 0) { return(null); } else { return(bl); } } } catch (Exception ex) { MessageBox.Show("Something went wrong in the RTC Core. \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); } }