Debugger: Add options to save rom edits (as .sfc or .ips) and generate stripped roms based on CDL data
This commit is contained in:
parent
4e6e7d7264
commit
55db5e9fb7
18 changed files with 187 additions and 32 deletions
|
@ -463,6 +463,6 @@ uint32_t Assembler::AssembleCode(string code, uint32_t startAddress, int16_t* as
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(assembledCode, output.data(), std::min<int>(100000, output.size()) * sizeof(uint16_t));
|
||||
memcpy(assembledCode, output.data(), std::min<int>(100000, (int)output.size()) * sizeof(uint16_t));
|
||||
return (uint32_t)output.size();
|
||||
}
|
||||
|
|
|
@ -142,8 +142,9 @@ void BaseCartridge::LoadRom()
|
|||
isLoRom = (baseAddress & 0x8000) == 0;
|
||||
isExRom = (baseAddress & 0x400000) != 0;
|
||||
hasHeader = (baseAddress & 0x200) != 0;
|
||||
uint32_t headerOffset = std::min(baseAddress + 0x7FB0, _prgRomSize - 0x40);
|
||||
uint32_t headerOffset = std::min(baseAddress + 0x7FB0, (uint32_t)(_prgRomSize - sizeof(SnesCartInformation)));
|
||||
memcpy(&_cartInfo, _prgRom + headerOffset, sizeof(SnesCartInformation));
|
||||
_headerOffset = headerOffset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +165,7 @@ void BaseCartridge::LoadRom()
|
|||
//Remove the copier header
|
||||
memmove(_prgRom, _prgRom + 512, _prgRomSize - 512);
|
||||
_prgRomSize -= 512;
|
||||
_headerOffset -= 512;
|
||||
}
|
||||
|
||||
if((flags & CartFlags::HiRom) && (_cartInfo.MapMode & 0x27) == 0x25) {
|
||||
|
@ -265,6 +267,7 @@ RomInfo BaseCartridge::GetRomInfo()
|
|||
{
|
||||
RomInfo info;
|
||||
info.Header = _cartInfo;
|
||||
info.HeaderOffset = _headerOffset;
|
||||
info.RomFile = static_cast<VirtualFile>(_romPath);
|
||||
info.PatchFile = static_cast<VirtualFile>(_patchPath);
|
||||
info.Coprocessor = _coprocessorType;
|
||||
|
|
|
@ -24,6 +24,7 @@ private:
|
|||
vector<unique_ptr<IMemoryHandler>> _prgRomHandlers;
|
||||
vector<unique_ptr<IMemoryHandler>> _saveRamHandlers;
|
||||
SnesCartInformation _cartInfo = {};
|
||||
uint32_t _headerOffset = 0;
|
||||
|
||||
unique_ptr<BaseCoprocessor> _coprocessor;
|
||||
NecDsp *_necDsp = nullptr;
|
||||
|
|
|
@ -23,6 +23,7 @@ struct SnesCartInformation
|
|||
|
||||
uint8_t ChecksumComplement[2];
|
||||
uint8_t Checksum[2];
|
||||
uint8_t CpuVectors[0x20];
|
||||
};
|
||||
|
||||
enum class CoprocessorType
|
||||
|
@ -49,6 +50,7 @@ enum class CoprocessorType
|
|||
struct RomInfo
|
||||
{
|
||||
SnesCartInformation Header;
|
||||
uint32_t HeaderOffset;
|
||||
VirtualFile RomFile;
|
||||
VirtualFile PatchFile;
|
||||
CoprocessorType Coprocessor;
|
||||
|
|
|
@ -150,3 +150,20 @@ void CodeDataLogger::MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags)
|
|||
_cdlData[i] = (_cdlData[i] & 0xFC) | (int)flags;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeDataLogger::StripData(uint8_t* romBuffer, CdlStripOption flag)
|
||||
{
|
||||
if(flag == CdlStripOption::StripUnused) {
|
||||
for(uint32_t i = 0; i < _prgSize; i++) {
|
||||
if(_cdlData[i] == 0) {
|
||||
romBuffer[i] = 0;
|
||||
}
|
||||
}
|
||||
} else if(flag == CdlStripOption::StripUsed) {
|
||||
for(uint32_t i = 0; i < _prgSize; i++) {
|
||||
if(_cdlData[i] != 0) {
|
||||
romBuffer[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,4 +38,5 @@ public:
|
|||
void GetCdlData(uint32_t offset, uint32_t length, SnesMemoryType memoryType, uint8_t *cdlData);
|
||||
|
||||
void MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags);
|
||||
void StripData(uint8_t* romBuffer, CdlStripOption flag);
|
||||
};
|
|
@ -101,7 +101,7 @@ namespace CdlFlags
|
|||
};
|
||||
}
|
||||
|
||||
enum class CdlStripFlag
|
||||
enum class CdlStripOption
|
||||
{
|
||||
StripNone = 0,
|
||||
StripUnused,
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "Assembler.h"
|
||||
#include "../Utilities/HexUtilities.h"
|
||||
#include "../Utilities/FolderUtilities.h"
|
||||
#include "../Utilities/IpsPatcher.h"
|
||||
|
||||
Debugger::Debugger(shared_ptr<Console> console)
|
||||
{
|
||||
|
@ -520,6 +521,31 @@ void Debugger::SetBreakpoints(Breakpoint breakpoints[], uint32_t length)
|
|||
}
|
||||
}
|
||||
|
||||
void Debugger::SaveRomToDisk(string filename, bool saveAsIps, CdlStripOption stripOption)
|
||||
{
|
||||
RomInfo romInfo = _cart->GetRomInfo();
|
||||
vector<uint8_t> rom(_cart->DebugGetPrgRom(), _cart->DebugGetPrgRom() + _cart->DebugGetPrgRomSize());
|
||||
vector<uint8_t> output;
|
||||
if(saveAsIps) {
|
||||
shared_ptr<BaseCartridge> originalCart = BaseCartridge::CreateCartridge(_console.get(), romInfo.RomFile, romInfo.PatchFile);
|
||||
vector<uint8_t> originalRom(originalCart->DebugGetPrgRom(), originalCart->DebugGetPrgRom() + originalCart->DebugGetPrgRomSize());
|
||||
output = IpsPatcher::CreatePatch(originalRom, rom);
|
||||
} else {
|
||||
if(stripOption != CdlStripOption::StripNone) {
|
||||
_codeDataLogger->StripData(rom.data(), stripOption);
|
||||
//Preserve SNES rom header regardless of CDL file contents
|
||||
memcpy(rom.data()+romInfo.HeaderOffset, &romInfo.Header, sizeof(SnesCartInformation));
|
||||
}
|
||||
output = rom;
|
||||
}
|
||||
|
||||
ofstream file(filename, ios::out | ios::binary);
|
||||
if(file) {
|
||||
file.write((char*)output.data(), output.size());
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<TraceLogger> Debugger::GetTraceLogger()
|
||||
{
|
||||
return _traceLogger;
|
||||
|
|
|
@ -125,6 +125,8 @@ public:
|
|||
void RefreshCodeCache();
|
||||
|
||||
void SetBreakpoints(Breakpoint breakpoints[], uint32_t length);
|
||||
|
||||
void SaveRomToDisk(string filename, bool saveAsIps, CdlStripOption stripOption);
|
||||
|
||||
shared_ptr<TraceLogger> GetTraceLogger();
|
||||
shared_ptr<MemoryDumper> GetMemoryDumper();
|
||||
|
|
|
@ -103,4 +103,6 @@ extern "C"
|
|||
//DllExport void __stdcall DebugSetScriptTimeout(uint32_t timeout) { LuaScriptingContext::SetScriptTimeout(timeout); }
|
||||
|
||||
DllExport uint32_t __stdcall AssembleCode(char* code, uint32_t startAddress, int16_t* assembledOutput) { return GetDebugger()->GetAssembler()->AssembleCode(code, startAddress, assembledOutput); }
|
||||
|
||||
DllExport void __stdcall SaveRomToDisk(char* filename, bool saveIpsFile, CdlStripOption cdlStripOption) { GetDebugger()->SaveRomToDisk(filename, saveIpsFile, cdlStripOption); }
|
||||
};
|
|
@ -128,8 +128,8 @@ namespace Mesen.GUI.Debugger
|
|||
GetMember(nameof(DebuggerShortcutsConfig.WatchList_MoveUp)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.WatchList_MoveDown)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.SaveRom)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.SaveRomAs)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.SaveEditAsIps)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.SaveRomAs)),
|
||||
GetMember(nameof(DebuggerShortcutsConfig.SaveEditAsIps)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.RevertPrgChrChanges)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.ToggleVerifiedData)),
|
||||
//GetMember(nameof(DebuggerShortcutsConfig.ToggleUnidentifiedCodeData))
|
||||
|
|
107
UI/Debugger/frmDebugger.Designer.cs
generated
107
UI/Debugger/frmDebugger.Designer.cs
generated
|
@ -34,11 +34,18 @@
|
|||
this.ctrlDisassemblyView = new Mesen.GUI.Debugger.Controls.ctrlDisassemblyView();
|
||||
this.ctrlMesenMenuStrip1 = new Mesen.GUI.Controls.ctrlMesenMenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuSaveRomAs = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuSaveAsIps = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem14 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.importExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuDbgIntegrationSettings = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.codeDataLoggerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuResetCdlLog = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuCdlGenerateRom = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuCdlStripUnusedData = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuCdlStripUsedData = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem13 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuExit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -115,6 +122,7 @@
|
|||
this.toolStripMenuItem21 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuSelectFont = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuPreferences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctrlSplitContainer = new Mesen.GUI.Controls.ctrlSplitContainer();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
|
@ -132,7 +140,6 @@
|
|||
this.grpCallstack = new System.Windows.Forms.GroupBox();
|
||||
this.ctrlCallstack = new Mesen.GUI.Debugger.Controls.ctrlCallstack();
|
||||
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
|
||||
this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctrlMesenMenuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ctrlSplitContainer)).BeginInit();
|
||||
this.ctrlSplitContainer.Panel1.SuspendLayout();
|
||||
|
@ -170,6 +177,9 @@
|
|||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuSaveRomAs,
|
||||
this.mnuSaveAsIps,
|
||||
this.toolStripMenuItem14,
|
||||
this.importExportToolStripMenuItem,
|
||||
this.toolStripMenuItem7,
|
||||
this.codeDataLoggerToolStripMenuItem,
|
||||
|
@ -179,13 +189,32 @@
|
|||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// mnuSaveRomAs
|
||||
//
|
||||
this.mnuSaveRomAs.Image = global::Mesen.GUI.Properties.Resources.SaveFloppy;
|
||||
this.mnuSaveRomAs.Name = "mnuSaveRomAs";
|
||||
this.mnuSaveRomAs.Size = new System.Drawing.Size(201, 22);
|
||||
this.mnuSaveRomAs.Text = "Save ROM as...";
|
||||
//
|
||||
// mnuSaveAsIps
|
||||
//
|
||||
this.mnuSaveAsIps.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
|
||||
this.mnuSaveAsIps.Name = "mnuSaveAsIps";
|
||||
this.mnuSaveAsIps.Size = new System.Drawing.Size(201, 22);
|
||||
this.mnuSaveAsIps.Text = "Save edits as IPS patch...";
|
||||
//
|
||||
// toolStripMenuItem14
|
||||
//
|
||||
this.toolStripMenuItem14.Name = "toolStripMenuItem14";
|
||||
this.toolStripMenuItem14.Size = new System.Drawing.Size(198, 6);
|
||||
//
|
||||
// importExportToolStripMenuItem
|
||||
//
|
||||
this.importExportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuDbgIntegrationSettings});
|
||||
this.importExportToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.Import;
|
||||
this.importExportToolStripMenuItem.Name = "importExportToolStripMenuItem";
|
||||
this.importExportToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||
this.importExportToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.importExportToolStripMenuItem.Text = "Import/Export";
|
||||
//
|
||||
// mnuDbgIntegrationSettings
|
||||
|
@ -199,35 +228,64 @@
|
|||
// toolStripMenuItem7
|
||||
//
|
||||
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
|
||||
this.toolStripMenuItem7.Size = new System.Drawing.Size(168, 6);
|
||||
this.toolStripMenuItem7.Size = new System.Drawing.Size(198, 6);
|
||||
//
|
||||
// codeDataLoggerToolStripMenuItem
|
||||
//
|
||||
this.codeDataLoggerToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuResetCdlLog});
|
||||
this.mnuResetCdlLog,
|
||||
this.toolStripSeparator1,
|
||||
this.mnuCdlGenerateRom});
|
||||
this.codeDataLoggerToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.VerifiedData;
|
||||
this.codeDataLoggerToolStripMenuItem.Name = "codeDataLoggerToolStripMenuItem";
|
||||
this.codeDataLoggerToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
|
||||
this.codeDataLoggerToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.codeDataLoggerToolStripMenuItem.Text = "Code/Data Logger";
|
||||
//
|
||||
// mnuResetCdlLog
|
||||
//
|
||||
this.mnuResetCdlLog.Image = global::Mesen.GUI.Properties.Resources.Refresh;
|
||||
this.mnuResetCdlLog.Name = "mnuResetCdlLog";
|
||||
this.mnuResetCdlLog.Size = new System.Drawing.Size(122, 22);
|
||||
this.mnuResetCdlLog.Size = new System.Drawing.Size(197, 22);
|
||||
this.mnuResetCdlLog.Text = "Reset log";
|
||||
this.mnuResetCdlLog.Click += new System.EventHandler(this.mnuResetCdlLog_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(194, 6);
|
||||
//
|
||||
// mnuCdlGenerateRom
|
||||
//
|
||||
this.mnuCdlGenerateRom.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.mnuCdlStripUnusedData,
|
||||
this.mnuCdlStripUsedData});
|
||||
this.mnuCdlGenerateRom.Image = global::Mesen.GUI.Properties.Resources.Copy;
|
||||
this.mnuCdlGenerateRom.Name = "mnuCdlGenerateRom";
|
||||
this.mnuCdlGenerateRom.Size = new System.Drawing.Size(197, 22);
|
||||
this.mnuCdlGenerateRom.Text = "Generate stripped ROM";
|
||||
//
|
||||
// mnuCdlStripUnusedData
|
||||
//
|
||||
this.mnuCdlStripUnusedData.Name = "mnuCdlStripUnusedData";
|
||||
this.mnuCdlStripUnusedData.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuCdlStripUnusedData.Text = "Strip unused data";
|
||||
//
|
||||
// mnuCdlStripUsedData
|
||||
//
|
||||
this.mnuCdlStripUsedData.Name = "mnuCdlStripUsedData";
|
||||
this.mnuCdlStripUsedData.Size = new System.Drawing.Size(166, 22);
|
||||
this.mnuCdlStripUsedData.Text = "Strip used data";
|
||||
//
|
||||
// toolStripMenuItem13
|
||||
//
|
||||
this.toolStripMenuItem13.Name = "toolStripMenuItem13";
|
||||
this.toolStripMenuItem13.Size = new System.Drawing.Size(168, 6);
|
||||
this.toolStripMenuItem13.Size = new System.Drawing.Size(198, 6);
|
||||
//
|
||||
// mnuExit
|
||||
//
|
||||
this.mnuExit.Image = global::Mesen.GUI.Properties.Resources.Exit;
|
||||
this.mnuExit.Name = "mnuExit";
|
||||
this.mnuExit.Size = new System.Drawing.Size(171, 22);
|
||||
this.mnuExit.Size = new System.Drawing.Size(201, 22);
|
||||
this.mnuExit.Text = "Exit";
|
||||
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
|
||||
//
|
||||
|
@ -745,32 +803,32 @@
|
|||
//
|
||||
this.mnuIncreaseFontSize.Name = "mnuIncreaseFontSize";
|
||||
this.mnuIncreaseFontSize.ShortcutKeyDisplayString = "";
|
||||
this.mnuIncreaseFontSize.Size = new System.Drawing.Size(180, 22);
|
||||
this.mnuIncreaseFontSize.Size = new System.Drawing.Size(157, 22);
|
||||
this.mnuIncreaseFontSize.Text = "Increase Size";
|
||||
//
|
||||
// mnuDecreaseFontSize
|
||||
//
|
||||
this.mnuDecreaseFontSize.Name = "mnuDecreaseFontSize";
|
||||
this.mnuDecreaseFontSize.ShortcutKeyDisplayString = "";
|
||||
this.mnuDecreaseFontSize.Size = new System.Drawing.Size(180, 22);
|
||||
this.mnuDecreaseFontSize.Size = new System.Drawing.Size(157, 22);
|
||||
this.mnuDecreaseFontSize.Text = "Decrease Size";
|
||||
//
|
||||
// mnuResetFontSize
|
||||
//
|
||||
this.mnuResetFontSize.Name = "mnuResetFontSize";
|
||||
this.mnuResetFontSize.ShortcutKeyDisplayString = "";
|
||||
this.mnuResetFontSize.Size = new System.Drawing.Size(180, 22);
|
||||
this.mnuResetFontSize.Size = new System.Drawing.Size(157, 22);
|
||||
this.mnuResetFontSize.Text = "Reset to Default";
|
||||
//
|
||||
// toolStripMenuItem21
|
||||
//
|
||||
this.toolStripMenuItem21.Name = "toolStripMenuItem21";
|
||||
this.toolStripMenuItem21.Size = new System.Drawing.Size(177, 6);
|
||||
this.toolStripMenuItem21.Size = new System.Drawing.Size(154, 6);
|
||||
//
|
||||
// mnuSelectFont
|
||||
//
|
||||
this.mnuSelectFont.Name = "mnuSelectFont";
|
||||
this.mnuSelectFont.Size = new System.Drawing.Size(180, 22);
|
||||
this.mnuSelectFont.Size = new System.Drawing.Size(157, 22);
|
||||
this.mnuSelectFont.Text = "Select Font...";
|
||||
this.mnuSelectFont.Click += new System.EventHandler(this.mnuSelectFont_Click);
|
||||
//
|
||||
|
@ -779,6 +837,14 @@
|
|||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(206, 6);
|
||||
//
|
||||
// mnuConfigureColors
|
||||
//
|
||||
this.mnuConfigureColors.Image = global::Mesen.GUI.Properties.Resources.PipetteSmall;
|
||||
this.mnuConfigureColors.Name = "mnuConfigureColors";
|
||||
this.mnuConfigureColors.Size = new System.Drawing.Size(209, 22);
|
||||
this.mnuConfigureColors.Text = "Configure colors";
|
||||
this.mnuConfigureColors.Click += new System.EventHandler(this.mnuConfigureColors_Click);
|
||||
//
|
||||
// mnuPreferences
|
||||
//
|
||||
this.mnuPreferences.Image = global::Mesen.GUI.Properties.Resources.Settings;
|
||||
|
@ -964,14 +1030,6 @@
|
|||
this.tsToolbar.TabIndex = 3;
|
||||
this.tsToolbar.Text = "ctrlMesenToolStrip1";
|
||||
//
|
||||
// mnuConfigureColors
|
||||
//
|
||||
this.mnuConfigureColors.Image = global::Mesen.GUI.Properties.Resources.PipetteSmall;
|
||||
this.mnuConfigureColors.Name = "mnuConfigureColors";
|
||||
this.mnuConfigureColors.Size = new System.Drawing.Size(209, 22);
|
||||
this.mnuConfigureColors.Text = "Configure colors";
|
||||
this.mnuConfigureColors.Click += new System.EventHandler(this.mnuConfigureColors_Click);
|
||||
//
|
||||
// frmDebugger
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -1107,5 +1165,12 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuGoToAll;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem11;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuConfigureColors;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuSaveRomAs;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuSaveAsIps;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem14;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuCdlGenerateRom;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuCdlStripUnusedData;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuCdlStripUsedData;
|
||||
}
|
||||
}
|
|
@ -181,6 +181,14 @@ namespace Mesen.GUI.Debugger
|
|||
mnuIncreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.IncreaseFontSize));
|
||||
mnuDecreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.DecreaseFontSize));
|
||||
mnuResetFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.ResetFontSize));
|
||||
|
||||
mnuSaveRomAs.InitShortcut(this, nameof(DebuggerShortcutsConfig.SaveRomAs));
|
||||
mnuSaveAsIps.InitShortcut(this, nameof(DebuggerShortcutsConfig.SaveEditAsIps));
|
||||
|
||||
mnuSaveRomAs.Click += (s, e) => { SaveRomAs(false, CdlStripOption.StripNone); };
|
||||
mnuSaveAsIps.Click += (s, e) => { SaveRomAs(true, CdlStripOption.StripNone); };
|
||||
mnuCdlStripUnusedData.Click += (s, e) => { SaveRomAs(false, CdlStripOption.StripUnused); };
|
||||
mnuCdlStripUsedData.Click += (s, e) => { SaveRomAs(false, CdlStripOption.StripUsed); };
|
||||
|
||||
mnuStepInto.Click += (s, e) => { DebugApi.Step(_cpuType, 1, StepType.Step); };
|
||||
mnuStepOver.Click += (s, e) => { DebugApi.Step(_cpuType, 1, StepType.StepOver); };
|
||||
|
@ -581,6 +589,24 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
ctrlDisassemblyView.GoToDestination(dest);
|
||||
}
|
||||
|
||||
private void SaveRomAs(bool saveAsIps, CdlStripOption cdlStripOption)
|
||||
{
|
||||
using(SaveFileDialog sfd = new SaveFileDialog()) {
|
||||
if(saveAsIps) {
|
||||
sfd.SetFilter("IPS files (*.ips)|*.ips");
|
||||
sfd.FileName = EmuApi.GetRomInfo().GetRomName() + ".ips";
|
||||
} else {
|
||||
sfd.SetFilter("SFC files (*.sfc)|*.sfc");
|
||||
sfd.FileName = EmuApi.GetRomInfo().GetRomName() + "_Modified.sfc";
|
||||
}
|
||||
|
||||
sfd.InitialDirectory = ConfigManager.DebuggerFolder;
|
||||
if(sfd.ShowDialog() == DialogResult.OK) {
|
||||
DebugApi.SaveRomToDisk(sfd.FileName, saveAsIps, cdlStripOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum CpuVector
|
||||
|
|
|
@ -77,6 +77,8 @@ namespace Mesen.GUI
|
|||
|
||||
[DllImport(DllPath)] public static extern void SetBreakpoints([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]InteropBreakpoint[] breakpoints, UInt32 length);
|
||||
|
||||
[DllImport(DllPath)] public static extern void SaveRomToDisk([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filename, [MarshalAs(UnmanagedType.I1)]bool saveAsIps, CdlStripOption cdlStripOption);
|
||||
|
||||
[DllImport(DllPath, EntryPoint = "GetMemoryState")] private static extern void GetMemoryStateWrapper(SnesMemoryType type, [In, Out] byte[] buffer);
|
||||
public static byte[] GetMemoryState(SnesMemoryType type)
|
||||
{
|
||||
|
@ -546,6 +548,13 @@ namespace Mesen.GUI
|
|||
public Int32 BreakpointId;
|
||||
}
|
||||
|
||||
public enum CdlStripOption
|
||||
{
|
||||
StripNone = 0,
|
||||
StripUnused = 1,
|
||||
StripUsed = 2
|
||||
}
|
||||
|
||||
public enum CdlFlags : byte
|
||||
{
|
||||
None = 0x00,
|
||||
|
|
|
@ -180,6 +180,9 @@ namespace Mesen.GUI
|
|||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] Checksum;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
|
||||
public byte[] CpuVectors;
|
||||
}
|
||||
|
||||
public enum CoprocessorType
|
||||
|
|
|
@ -127,9 +127,11 @@ bool IpsPatcher::PatchBuffer(std::istream &ipsFile, vector<uint8_t> &input, vect
|
|||
|
||||
vector<uint8_t> IpsPatcher::CreatePatch(vector<uint8_t> originalData, vector<uint8_t> newData)
|
||||
{
|
||||
assert(originalData.size() == newData.size());
|
||||
|
||||
vector<uint8_t> patchFile;
|
||||
if(originalData.size() != newData.size()) {
|
||||
return patchFile;
|
||||
}
|
||||
|
||||
uint8_t header[5] = { 'P', 'A', 'T', 'C', 'H' };
|
||||
patchFile.insert(patchFile.end(), header, header + sizeof(header));
|
||||
|
||||
|
|
|
@ -463,7 +463,6 @@
|
|||
<ClInclude Include="SimpleLock.h" />
|
||||
<ClInclude Include="Socket.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="Timer.h" />
|
||||
<ClInclude Include="UpsPatcher.h" />
|
||||
<ClInclude Include="UTF8Util.h" />
|
||||
|
|
|
@ -40,9 +40,6 @@
|
|||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Timer.h">
|
||||
<Filter>Misc</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Add table
Reference in a new issue