add memory domains for Citra
This commit is contained in:
parent
67510f3b56
commit
89b387e50d
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
||||
{
|
||||
public partial class Citra
|
||||
{
|
||||
private IMemoryDomains _memoryDomains;
|
||||
|
||||
private MemoryDomainIntPtr _fcram;
|
||||
private MemoryDomainIntPtr _vram;
|
||||
private MemoryDomainIntPtr _dspRam;
|
||||
private MemoryDomainIntPtr _n3dsExRam;
|
||||
|
||||
private void InitMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>()
|
||||
{
|
||||
(_fcram = new("FCRAM", MemoryDomain.Endian.Little, IntPtr.Zero, 0, true, 4)),
|
||||
(_vram = new("VRAM", MemoryDomain.Endian.Little, IntPtr.Zero, 0, true, 4)),
|
||||
(_dspRam = new("DSP RAM", MemoryDomain.Endian.Little, IntPtr.Zero, 0, true, 4)),
|
||||
};
|
||||
|
||||
_n3dsExRam = new("N3DS Extra RAM", MemoryDomain.Endian.Little, IntPtr.Zero, 0, true, 4);
|
||||
if (_syncSettings.IsNew3ds)
|
||||
{
|
||||
domains.Add(_n3dsExRam);
|
||||
}
|
||||
|
||||
_memoryDomains = new MemoryDomainList(domains);
|
||||
_serviceProvider.Register(_memoryDomains);
|
||||
WireMemoryDomains();
|
||||
}
|
||||
|
||||
private void WireMemoryDomains()
|
||||
{
|
||||
void WireDomain(LibCitra.MemoryRegion region, MemoryDomainIntPtr domain)
|
||||
{
|
||||
_core.Citra_GetMemoryRegion(_context, region, out var ptr, out var size);
|
||||
domain.Data = ptr;
|
||||
domain.SetSize(size);
|
||||
}
|
||||
|
||||
WireDomain(LibCitra.MemoryRegion.FCRAM, _fcram);
|
||||
WireDomain(LibCitra.MemoryRegion.VRAM, _vram);
|
||||
WireDomain(LibCitra.MemoryRegion.DSP, _dspRam);
|
||||
WireDomain(LibCitra.MemoryRegion.N3DS, _n3dsExRam);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -78,6 +78,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
|||
_motionEmu.AngularRate.X = reader.ReadSingle();
|
||||
_motionEmu.AngularRate.Y = reader.ReadSingle();
|
||||
_motionEmu.AngularRate.Z = reader.ReadSingle();
|
||||
|
||||
// memory domain pointers are no longer valid, reset them
|
||||
WireMemoryDomains();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
|||
if (lp.Roms[0].Extension.ToLowerInvariant() == ".cia")
|
||||
{
|
||||
var message = new byte[1024];
|
||||
var res = _core.Citra_InstallCIA(_context, romPath, true, message, message.Length);
|
||||
var res = _core.Citra_InstallCIA(_context, romPath, message, message.Length);
|
||||
var outMsg = Encoding.UTF8.GetString(message).TrimEnd();
|
||||
if (res)
|
||||
{
|
||||
|
@ -129,6 +129,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
|||
Dispose();
|
||||
throw new($"{Encoding.UTF8.GetString(errorMessage).TrimEnd()}");
|
||||
}
|
||||
|
||||
InitMemoryDomains();
|
||||
}
|
||||
|
||||
private IntPtr RequestGLContextCallback()
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
|||
public abstract void Citra_DestroyContext(IntPtr context);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract bool Citra_InstallCIA(IntPtr context, string ciaPath, bool force, byte[] messageBuffer, int messageBufferLen);
|
||||
public abstract bool Citra_InstallCIA(IntPtr context, string ciaPath, byte[] messageBuffer, int messageBufferLen);
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract bool Citra_LoadROM(IntPtr context, string romPath, byte[] errorMessageBuffer, int errorMessageBufferLen);
|
||||
|
@ -149,5 +149,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo._3DS
|
|||
|
||||
[BizImport(cc)]
|
||||
public abstract void Citra_LoadState(IntPtr context, byte[] buffer, int stateLen);
|
||||
|
||||
public enum MemoryRegion
|
||||
{
|
||||
FCRAM,
|
||||
VRAM,
|
||||
DSP,
|
||||
N3DS
|
||||
}
|
||||
|
||||
[BizImport(cc)]
|
||||
public abstract void Citra_GetMemoryRegion(IntPtr context, MemoryRegion region, out IntPtr ptr, out int size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue