Example #1
0
        public static void RefreshAndKeepDomains()
        {
            List <string> MemoryBanks = new List <string>(); //Saves current targetted zones

            foreach (object oneItem in RTC_MemoryZones.SelectedDomains)
            {
                MemoryBanks.Add(oneItem.ToString());
            }

            RTC_MemoryZones.RefreshDomains(); //refresh and reload zones

            int nbZones = RTC_Core.coreForm.lbMemoryZones.Items.Count;

            for (int i = 0; i < nbZones; i++)
            {
                foreach (string SelectedItem in MemoryBanks)
                {
                    if (RTC_Core.coreForm.lbMemoryZones.Items[i].ToString() == SelectedItem)
                    {
                        RTC_Core.coreForm.lbMemoryZones.SetSelected(i, true);
                        break;
                    }
                }
            }
        }
        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);
            }
        }
Example #3
0
        private void btnSelectAll_Click(object sender, EventArgs e)
        {
            RTC_MemoryZones.RefreshDomains();

            for (int i = 0; i < lbMemoryZones.Items.Count; i++)
            {
                lbMemoryZones.SetSelected(i, true);
            }

            RTC_Restore.SaveRestore();
        }
Example #4
0
        public static void LoadRom(string RomFile)
        {
            List <string> MemoryBanks = null;

            if (isLoaded)
            {
                MemoryBanks = new List <string>(); //Saves current targetted zones
                foreach (object oneItem in RTC_MemoryZones.SelectedDomains)
                {
                    MemoryBanks.Add(oneItem.ToString());
                }
            }

            GlobalWin.Sound.StopSound();
            GlobalWin.DisplayManager.NeedsToPaint = false;

            var args = new BizHawk.Client.EmuHawk.MainForm.LoadRomArgs();

            if (RomFile == null)
            {
                RomFile = GlobalWin.MainForm.CurrentlyOpenRom;
            }

            var lra = new BizHawk.Client.EmuHawk.MainForm.LoadRomArgs {
                OpenAdvanced = new OpenAdvanced_OpenRom {
                    Path = RomFile
                }
            };

            GlobalWin.MainForm.LoadRom(RomFile, lra);

            GlobalWin.DisplayManager.NeedsToPaint = true;
            GlobalWin.Sound.StartSound();

            if (isLoaded)
            {
                RTC_MemoryZones.RefreshDomains(); //refresh and reload zones
                int nbZones = coreForm.lbMemoryZones.Items.Count;

                for (int i = 0; i < nbZones; i++)
                {
                    foreach (string SelectedItem in MemoryBanks)
                    {
                        if (coreForm.lbMemoryZones.Items[i].ToString() == SelectedItem)
                        {
                            coreForm.lbMemoryZones.SetSelected(i, true);
                            break;
                        }
                    }
                }
            }
        }
        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;
            }
        }
Example #7
0
        public static void LOAD_GAME_DONE()
        {
            if (!RTC_Core.isLoaded)
            {
                return;
            }

            if (RTC_Core.currentGameName == lastGameName)
            {
                RTC_MemoryZones.RefreshAndKeepDomains();
            }

            RTC_HellgenieEngine.ClearCheats();


            //Load Game vars into RTC_Core
            PathEntry pathEntry = Global.Config.PathEntries[Global.Game.System, "Savestates"] ??
                                  Global.Config.PathEntries[Global.Game.System, "Base"];

            RTC_Core.currentGameSystem = RTC_Core.EmuFolderCheck(pathEntry.SystemDisplayName);
            RTC_Core.currentGameName   = PathManager.FilesystemSafeName(Global.Game);
            RTC_Core.lastOpenRom       = GlobalWin.MainForm.CurrentlyOpenRom;
            RTC_RPC.RefreshPlugin();

            if (RTC_Core.currentGameName != lastGameName)
            {
                RTC_TimeStack.Reset();
                RTC_MemoryZones.AutoSelectDomains();
            }

            if (RTC_MemoryZones.pendingSelectedDomains != null)
            {
                RTC_MemoryZones.setSelectedDomains(RTC_MemoryZones.pendingSelectedDomains);
                RTC_MemoryZones.pendingSelectedDomains = null;
            }
            lastGameName = RTC_Core.currentGameName;

            //RTC_Restore.SaveRestore();

            RTC_RPC.SendToKillSwitch("UNFREEZE");
        }
Example #8
0
        public static void CLOSE_GAME(bool loadDefault = false)
        {
            if (CLOSE_GAME_loop_flag == true)
            {
                return;
            }

            CLOSE_GAME_loop_flag = true;

            //RTC_Core.AutoCorrupt = false;
            RTC_MemoryZones.Clear();

            RTC_Core.lastOpenRom = null;

            if (loadDefault)
            {
                RTC_Core.LoadDefaultRom();
            }

            //RTC_RPC.SendToKillSwitch("UNFREEZE");

            CLOSE_GAME_loop_flag = false;
        }
        public static void SaveRestore()
        {
            if (!RTC_Restore.IsEnabled)
            {
                return;
            }


            try
            {
                #region RTC_Core

                //Default Values
                RTC_Status.SelectedEngine      = RTC_Core.SelectedEngine;
                RTC_Status.IteratorSteps       = RTC_Core.IteratorSteps;
                RTC_Status.Radius              = RTC_Core.Radius;
                RTC_Status.Intensity           = RTC_Core.Intensity;
                RTC_Status.ClearCheatsOnRewind = RTC_Core.ClearCheatsOnRewind;

                //Flags
                RTC_Status.AutoCorrupt       = RTC_Core.AutoCorrupt;
                RTC_Status.ExtractBlastLayer = RTC_Core.ExtractBlastLayer;

                RTC_Status.lastOpenRom = RTC_Core.lastOpenRom;

                //General Values

                //Memory object references
                RTC_Status.currentStockpile = RTC_Core.currentStockpile;

                #endregion

                #region RTC_MemoryZones

                RTC_Status.SelectedDomains = RTC_MemoryZones.getSelectedDomains();

                #endregion

                #region RTC_NightmareEngine

                RTC_Status.Algo = RTC_NightmareEngine.Algo;

                #endregion

                #region RTC_HellgenieEngine

                RTC_Status.MaxCheats = RTC_HellgenieEngine.MaxCheats;

                #endregion

                #region RTC_FreezeEngine

                RTC_Status.MaxFreezes = RTC_FreezeEngine.MaxFreezes;

                #endregion

                #region RTC_DistortionEngine

                RTC_Status.MaxAge             = RTC_DistortionEngine.MaxAge;
                RTC_Status.CurrentAge         = RTC_DistortionEngine.CurrentAge;
                RTC_Status.AllDistortionBytes = RTC_DistortionEngine.AllDistortionBytes;

                #endregion

                #region RTC_ExternalRomPlugin

                RTC_Status.SelectedPlugin = RTC_ExternalRomPlugin.SelectedPlugin;

                #endregion

                #region RTC_coreForm

                RTC_WindowStatus.RTC_coreFormLocation    = RTC_Core.coreForm.Location;
                RTC_WindowStatus.RTC_coreFormWindowState = RTC_Core.coreForm.WindowState;

                #endregion

                #region RTC_GH_Form

                RTC_Status.currentSelectedState = RTC_Core.ghForm.currentSelectedState;
                RTC_Status.btnParentKeys        = RTC_Core.ghForm.btnParentKeys;
                RTC_Status.btnAttachedRom       = RTC_Core.ghForm.btnAttachedRom;

                RTC_Status.DontLoadSelectedStash     = RTC_Core.ghForm.DontLoadSelectedStash;
                RTC_Status.DontLoadSelectedStockpile = RTC_Core.ghForm.DontLoadSelectedStockpile;

                if (RTC_Core.ghForm.rbCorrupt.Checked)
                {
                    RTC_Status.ghMode = "CORRUPT";
                }
                else if (RTC_Core.ghForm.rbInject.Checked)
                {
                    RTC_Status.ghMode = "INJECT";
                }
                else
                {
                    RTC_Status.ghMode = "ORIGINAL";
                }

                RTC_Status.AutoLoadState        = RTC_Core.ghForm.cbAutoLoadState.Checked;
                RTC_Status.LoadOnSelect         = RTC_Core.ghForm.cbLoadOnSelect.Checked;
                RTC_Status.StashCorrupted       = RTC_Core.ghForm.cbStashCorrupted.Checked;
                RTC_Status.StashInjected        = RTC_Core.ghForm.cbStashInjected.Checked;
                RTC_Status.RenderAtLoad         = RTC_Core.ghForm.cbRenderAtLoad.Checked;
                RTC_Status.RenderAtCorrupt      = RTC_Core.ghForm.cbRenderAtCorrupt.Checked;
                RTC_Status.SavestateLoadOnClick = RTC_Core.ghForm.cbSavestateLoadOnClick.Checked;

                if (RTC_Core.ghForm.rbRenderNone.Checked)
                {
                    RTC_Status.ExportFormat = "NONE";
                }
                else if (RTC_Core.ghForm.rbRenderMPEG.Checked)
                {
                    RTC_Status.ExportFormat = "MPEG";
                }
                else if (RTC_Core.ghForm.rbRenderWAV.Checked)
                {
                    RTC_Status.ExportFormat = "WAV";
                }
                else if (RTC_Core.ghForm.rbRenderAVI.Checked)
                {
                    RTC_Status.ExportFormat = "AVI";
                }

                RTC_Status.StockpileListboxItems = new List <object>();

                foreach (object item in RTC_Core.ghForm.lbStockpile.Items)
                {
                    RTC_Status.StockpileListboxItems.Add(item);
                }

                RTC_Status.StashHistoryListboxItems = new List <object>();

                RTC_Status.BackupHistory = RTC_Core.ghForm.cbBackupHistory.Checked;

                if (RTC_Status.BackupHistory)
                {
                    foreach (object item in RTC_Core.ghForm.lbStashHistory.Items)
                    {
                        RTC_Status.StashHistoryListboxItems.Add(item);
                    }
                }



                RTC_WindowStatus.RTC_ghFormLocation    = RTC_Core.ghForm.Location;
                RTC_WindowStatus.IsRTC_ghFormOpen      = RTC_Core.ghForm.Visible;
                RTC_WindowStatus.RTC_tfFormWindowState = RTC_Core.ghForm.WindowState;

                #endregion

                #region RTC_TimeStack & RTC_TimeFlow

                RTC_Status.TimeStack      = RTC_Core.coreForm.cbUseTimeStack.Checked;
                RTC_Status.TimeStackDelay = RTC_TimeStack.TimeStackDelay;
                RTC_Status.TimeMap        = RTC_TimeFlow.Running;

                RTC_WindowStatus.RTC_tfFormLocation    = RTC_Core.tfForm.Location;
                RTC_WindowStatus.IsRTC_tfFormOpen      = RTC_Core.tfForm.Visible;
                RTC_WindowStatus.RTC_tfFormWindowState = RTC_Core.tfForm.WindowState;

                #endregion

                #region Bizhawk

                RTC_WindowStatus.MainFormLocation = GlobalWin.MainForm.Location;
                RTC_WindowStatus.MainFormSize     = GlobalWin.MainForm.Size;

                #endregion

                #region Saving the Restore Files

                lock (restoreLock)
                {
                    FileStream      FS;
                    BinaryFormatter bformatter = new BinaryFormatter();
                    FS = File.Open(RTC_Core.rtcDir + "\\SESSION\\Restore.dat", FileMode.OpenOrCreate);
                    bformatter.Serialize(FS, RTC_Status);
                    FS.Close();

                    bformatter = new BinaryFormatter();
                    FS         = File.Open(RTC_Core.rtcDir + "\\SESSION\\WindowRestore.dat", FileMode.OpenOrCreate);
                    bformatter.Serialize(FS, RTC_WindowStatus);
                    FS.Close();
                }

                GlobalWin.MainForm.SaveConfig();

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something wrong happenned in RTC_Restore -> SaveRestore() \n\n" + ex.ToString());
            }
        }
Example #10
0
        private void btnRefreshZones_Click(object sender, EventArgs e)
        {
            RTC_MemoryZones.RefreshDomains();

            //RTC_Restore.SaveRestore();
        }
Example #11
0
        private void btnAutoSelectZones_Click(object sender, EventArgs e)
        {
            RTC_MemoryZones.AutoSelectDomains();

            RTC_Restore.SaveRestore();
        }
Example #12
0
        private void lbMemoryZones_SelectedIndexChanged(object sender, EventArgs e)
        {
            RTC_MemoryZones.SelectDomains();

            //RTC_Restore.SaveRestore();
        }
        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);
            }
        }
Example #14
0
        //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);
            }
        }