mirror of
https://github.com/libretro/Mesen-S.git
synced 2024-11-23 08:19:40 +00:00
Debugger: Fixed crash when using event viewer in PAL mode
This commit is contained in:
parent
f2f692e984
commit
60a8abcbd5
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
patreon: Mesen
|
@ -334,6 +334,7 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom)
|
||||
return true;
|
||||
}
|
||||
|
||||
MessageManager::DisplayMessage("Error", "CouldNotLoadFile", romFile.GetFileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ void EventManager::DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t
|
||||
int iMax = drawBackground ? 3 : 1;
|
||||
int jMin = drawBackground ? -2 : 0;
|
||||
int jMax = drawBackground ? 3 : 1;
|
||||
uint32_t y = std::min(evt.Scanline * 2, 262 * 2);
|
||||
uint32_t y = std::min<uint32_t>(evt.Scanline * 2, _scanlineCount * 2);
|
||||
uint32_t x = evt.Cycle * 2;
|
||||
|
||||
for(int i = iMin; i <= iMax; i++) {
|
||||
for(int j = jMin; j <= jMax; j++) {
|
||||
int32_t pos = (y + i) * 340 * 2 + x + j;
|
||||
if(pos < 0 || pos > 340 * 2 * 262 * 2) {
|
||||
if(pos < 0 || pos >= 340 * 2 * _scanlineCount * 2) {
|
||||
continue;
|
||||
}
|
||||
buffer[pos] = color;
|
||||
@ -156,7 +156,7 @@ void EventManager::DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::TakeEventSnapshot(EventViewerDisplayOptions options)
|
||||
uint32_t EventManager::TakeEventSnapshot(EventViewerDisplayOptions options)
|
||||
{
|
||||
DebugBreakHelper breakHelper(_debugger);
|
||||
auto lock = _lock.AcquireSafe();
|
||||
@ -180,6 +180,9 @@ void EventManager::TakeEventSnapshot(EventViewerDisplayOptions options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_scanlineCount = _ppu->GetVblankEndScanline() + 1;
|
||||
return _scanlineCount;
|
||||
}
|
||||
|
||||
void EventManager::GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions options)
|
||||
@ -187,7 +190,7 @@ void EventManager::GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions
|
||||
auto lock = _lock.AcquireSafe();
|
||||
_sentEvents.clear();
|
||||
|
||||
for(int i = 0; i < 340 * 2 * 262 * 2; i++) {
|
||||
for(int i = 0; i < 340 * 2 * _scanlineCount * 2; i++) {
|
||||
buffer[i] = 0xFF555555;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
|
||||
bool _overscanMode = false;
|
||||
bool _useHighResOutput = false;
|
||||
uint32_t _scanlineCount = 262;
|
||||
uint16_t *_ppuBuffer;
|
||||
|
||||
void DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t *buffer, EventViewerDisplayOptions &options);
|
||||
@ -44,7 +45,7 @@ public:
|
||||
uint32_t GetEventCount(bool getPreviousFrameData);
|
||||
void ClearFrameEvents();
|
||||
|
||||
void TakeEventSnapshot(EventViewerDisplayOptions options);
|
||||
uint32_t TakeEventSnapshot(EventViewerDisplayOptions options);
|
||||
void GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions options);
|
||||
DebugEventInfo GetEvent(uint16_t scanline, uint16_t cycle, EventViewerDisplayOptions &options);
|
||||
};
|
||||
|
13
Core/Ppu.cpp
13
Core/Ppu.cpp
@ -401,6 +401,10 @@ bool Ppu::ProcessEndOfScanline(uint16_t hClock)
|
||||
|
||||
if(_scanline == 0) {
|
||||
_mosaicScanlineCounter = _mosaicEnabled ? _mosaicSize + 1 : 0;
|
||||
if(!_skipRender) {
|
||||
//If we're not skipping this frame, reset the high resolution flag
|
||||
_useHighResOutput = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(_mosaicScanlineCounter) {
|
||||
@ -483,10 +487,6 @@ bool Ppu::ProcessEndOfScanline(uint16_t hClock)
|
||||
(_settings->GetEmulationSpeed() == 0 || _settings->GetEmulationSpeed() > 150) &&
|
||||
_frameSkipTimer.GetElapsedMS() < 10
|
||||
);
|
||||
if(!_skipRender) {
|
||||
//If we're not skipping this frame, reset the high resolution flag
|
||||
_useHighResOutput = false;
|
||||
}
|
||||
|
||||
//Update overclock timings once per frame
|
||||
UpdateNmiScanline();
|
||||
@ -564,6 +564,11 @@ uint16_t Ppu::GetRealScanline()
|
||||
return _scanline;
|
||||
}
|
||||
|
||||
uint16_t Ppu::GetVblankEndScanline()
|
||||
{
|
||||
return _vblankEndScanline;
|
||||
}
|
||||
|
||||
uint16_t Ppu::GetLastScanline()
|
||||
{
|
||||
return _baseVblankEndScanline;
|
||||
|
@ -262,6 +262,7 @@ public:
|
||||
|
||||
uint32_t GetFrameCount();
|
||||
uint16_t GetRealScanline();
|
||||
uint16_t GetVblankEndScanline();
|
||||
uint16_t GetScanline();
|
||||
uint16_t GetCycle();
|
||||
uint16_t GetNmiScanline();
|
||||
|
@ -90,7 +90,7 @@ extern "C"
|
||||
DllExport uint32_t __stdcall GetDebugEventCount(bool getPreviousFrameData) { return GetDebugger()->GetEventManager()->GetEventCount(getPreviousFrameData); }
|
||||
DllExport void __stdcall GetEventViewerOutput(uint32_t *buffer, EventViewerDisplayOptions options) { GetDebugger()->GetEventManager()->GetDisplayBuffer(buffer, options); }
|
||||
DllExport DebugEventInfo __stdcall GetEventViewerEvent(uint16_t scanline, uint16_t cycle, EventViewerDisplayOptions options) { return GetDebugger()->GetEventManager()->GetEvent(scanline, cycle, options); }
|
||||
DllExport void __stdcall TakeEventSnapshot(EventViewerDisplayOptions options) { GetDebugger()->GetEventManager()->TakeEventSnapshot(options); }
|
||||
DllExport uint32_t __stdcall TakeEventSnapshot(EventViewerDisplayOptions options) { return GetDebugger()->GetEventManager()->TakeEventSnapshot(options); }
|
||||
|
||||
DllExport int32_t __stdcall LoadScript(char* name, char* content, int32_t scriptId) { return GetDebugger()->GetScriptManager()->LoadScript(name, content, scriptId); }
|
||||
DllExport void __stdcall RemoveScript(int32_t scriptId) { GetDebugger()->GetScriptManager()->RemoveScript(scriptId); }
|
||||
|
@ -106,7 +106,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
DllExport void __stdcall LoadRom(char* filename, char* patchFile) { _console->LoadRom((VirtualFile)filename, patchFile ? (VirtualFile)patchFile : VirtualFile()); }
|
||||
DllExport bool __stdcall LoadRom(char* filename, char* patchFile) { return _console->LoadRom((VirtualFile)filename, patchFile ? (VirtualFile)patchFile : VirtualFile()); }
|
||||
//DllExport void __stdcall AddKnownGameFolder(char* folder) { FolderUtilities::AddKnownGameFolder(folder); }
|
||||
|
||||
DllExport void __stdcall GetRomInfo(InteropRomInfo &info)
|
||||
|
@ -19,7 +19,6 @@ namespace Mesen.GUI.Debugger
|
||||
public partial class ctrlEventViewerPpuView : BaseControl
|
||||
{
|
||||
private int _baseWidth = 340 * 2;
|
||||
private int _baseHeight = 262 * 2;
|
||||
|
||||
private EntityBinder _entityBinder = new EntityBinder();
|
||||
private Point _lastPos = new Point(-1, -1);
|
||||
@ -29,6 +28,7 @@ namespace Mesen.GUI.Debugger
|
||||
private Bitmap _displayBitmap = null;
|
||||
private byte[] _pictureData = null;
|
||||
private Font _overlayFont;
|
||||
private UInt32 _scanlineCount = 262;
|
||||
|
||||
public int ImageScale { get { return picViewer.ImageScale; } set { picViewer.ImageScale = value; } }
|
||||
|
||||
@ -105,16 +105,16 @@ namespace Mesen.GUI.Debugger
|
||||
}));
|
||||
|
||||
EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
|
||||
DebugApi.TakeEventSnapshot(options);
|
||||
_scanlineCount = DebugApi.TakeEventSnapshot(options);
|
||||
}
|
||||
|
||||
public void RefreshViewer()
|
||||
{
|
||||
_entityBinder.UpdateObject();
|
||||
EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
|
||||
_pictureData = DebugApi.GetEventViewerOutput(options);
|
||||
_pictureData = DebugApi.GetEventViewerOutput(_scanlineCount, options);
|
||||
|
||||
int picHeight = _baseHeight;
|
||||
int picHeight = (int)_scanlineCount*2;
|
||||
if(_screenBitmap == null || _screenBitmap.Height != picHeight) {
|
||||
_screenBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb);
|
||||
_overlayBitmap = new Bitmap(_baseWidth, picHeight, PixelFormat.Format32bppPArgb);
|
||||
@ -123,7 +123,7 @@ namespace Mesen.GUI.Debugger
|
||||
|
||||
GCHandle handle = GCHandle.Alloc(this._pictureData, GCHandleType.Pinned);
|
||||
try {
|
||||
Bitmap source = new Bitmap(_baseWidth, _baseHeight, _baseWidth*4, PixelFormat.Format32bppPArgb, handle.AddrOfPinnedObject());
|
||||
Bitmap source = new Bitmap(_baseWidth, (int)_scanlineCount*2, _baseWidth*4, PixelFormat.Format32bppPArgb, handle.AddrOfPinnedObject());
|
||||
using(Graphics g = Graphics.FromImage(_screenBitmap)) {
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
|
||||
@ -164,7 +164,7 @@ namespace Mesen.GUI.Debugger
|
||||
}
|
||||
}
|
||||
|
||||
picViewer.ImageSize = new Size(_baseWidth, _baseHeight);
|
||||
picViewer.ImageSize = new Size(_baseWidth, (int)_scanlineCount*2);
|
||||
picViewer.Image = _displayBitmap;
|
||||
_needUpdate = false;
|
||||
}
|
||||
|
@ -34,9 +34,10 @@ namespace Mesen.GUI.Emulation
|
||||
}
|
||||
|
||||
_romPath = romPath;
|
||||
EmuApi.LoadRom(romPath, patchPath);
|
||||
ConfigManager.Config.RecentFiles.AddRecentFile(romPath, patchPath);
|
||||
StartEmulation();
|
||||
if(EmuApi.LoadRom(romPath, patchPath)) {
|
||||
ConfigManager.Config.RecentFiles.AddRecentFile(romPath, patchPath);
|
||||
StartEmulation();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadPatchFile(string patchFile)
|
||||
|
@ -108,12 +108,12 @@ namespace Mesen.GUI
|
||||
}
|
||||
|
||||
[DllImport(DllPath)] public static extern DebugEventInfo GetEventViewerEvent(UInt16 scanline, UInt16 cycle, EventViewerDisplayOptions options);
|
||||
[DllImport(DllPath)] public static extern void TakeEventSnapshot(EventViewerDisplayOptions options);
|
||||
[DllImport(DllPath)] public static extern UInt32 TakeEventSnapshot(EventViewerDisplayOptions options);
|
||||
|
||||
[DllImport(DllPath, EntryPoint = "GetEventViewerOutput")] private static extern void GetEventViewerOutputWrapper([In, Out]byte[] buffer, EventViewerDisplayOptions options);
|
||||
public static byte[] GetEventViewerOutput(EventViewerDisplayOptions options)
|
||||
public static byte[] GetEventViewerOutput(UInt32 scanlineCount, EventViewerDisplayOptions options)
|
||||
{
|
||||
byte[] buffer = new byte[340*2 * 262*2 * 4];
|
||||
byte[] buffer = new byte[340*2 * scanlineCount*2 * 4];
|
||||
DebugApi.GetEventViewerOutputWrapper(buffer, options);
|
||||
return buffer;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace Mesen.GUI
|
||||
|
||||
[DllImport(DllPath)] public static extern void TakeScreenshot();
|
||||
|
||||
[DllImport(DllPath)] public static extern void LoadRom(
|
||||
[DllImport(DllPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool LoadRom(
|
||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath,
|
||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string patchFile = ""
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user