Gambatte: Properly dispose of GPUViewer memory pointers

-Still doesn't point to correct memory but at least doesn't crash
This commit is contained in:
alyosha-tas 2017-11-26 09:25:16 -05:00
parent 3e4ebb0dbd
commit 34a17570d6
2 changed files with 12 additions and 6 deletions

View File

@ -2,6 +2,7 @@
using System.Diagnostics; using System.Diagnostics;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{ {
@ -99,6 +100,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
GambatteState = IntPtr.Zero; GambatteState = IntPtr.Zero;
} }
_vram = IntPtr.Zero;
_oam = IntPtr.Zero;
_sppal = IntPtr.Zero;
_bgpal = IntPtr.Zero;
DisposeSound(); DisposeSound();
} }
} }

View File

@ -408,12 +408,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
#region ppudebug #region ppudebug
public IntPtr _vram = IntPtr.Zero;
public IntPtr _bgpal = IntPtr.Zero;
public IntPtr _sppal = IntPtr.Zero;
public IntPtr _oam = IntPtr.Zero;
public GPUMemoryAreas GetGPU() public GPUMemoryAreas GetGPU()
{ {
IntPtr _vram = IntPtr.Zero;
IntPtr _bgpal = IntPtr.Zero;
IntPtr _sppal = IntPtr.Zero;
IntPtr _oam = IntPtr.Zero;
int unused = 0; int unused = 0;
if (!LibGambatte.gambatte_getmemoryarea(GambatteState, LibGambatte.MemoryAreas.vram, ref _vram, ref unused) if (!LibGambatte.gambatte_getmemoryarea(GambatteState, LibGambatte.MemoryAreas.vram, ref _vram, ref unused)
|| !LibGambatte.gambatte_getmemoryarea(GambatteState, LibGambatte.MemoryAreas.bgpal, ref _bgpal, ref unused) || !LibGambatte.gambatte_getmemoryarea(GambatteState, LibGambatte.MemoryAreas.bgpal, ref _bgpal, ref unused)
@ -423,7 +424,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
throw new InvalidOperationException("Unexpected error in gambatte_getmemoryarea"); throw new InvalidOperationException("Unexpected error in gambatte_getmemoryarea");
} }
return new GPUMemoryAreas(_vram, _oam, _sppal, _bgpal); return new GPUMemoryAreas(_vram, _oam, _sppal, _bgpal);
} }
/// <summary> /// <summary>