Refactor IMemoryDomains and MemoryDomains to have setters for MainMemory and SystemBus, so a core can customize instead of using a one size fits all assumption. Remove constructor that sets main memory and refactor accordingly
This commit is contained in:
parent
7b87f666a1
commit
ac442130ae
|
@ -209,19 +209,14 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public class MemoryDomainList : ReadOnlyCollection<MemoryDomain>, IMemoryDomains
|
||||
{
|
||||
private readonly int _mainMemoryIndex;
|
||||
private MemoryDomain _mainMemory;
|
||||
private MemoryDomain _systemBus;
|
||||
|
||||
public MemoryDomainList(IList<MemoryDomain> domains)
|
||||
: base(domains)
|
||||
{
|
||||
}
|
||||
|
||||
public MemoryDomainList(IList<MemoryDomain> domains, int mainMemoryIndex)
|
||||
: this(domains)
|
||||
{
|
||||
_mainMemoryIndex = mainMemoryIndex;
|
||||
}
|
||||
|
||||
public MemoryDomain this[string name]
|
||||
{
|
||||
get
|
||||
|
@ -234,7 +229,17 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
return this[_mainMemoryIndex];
|
||||
if (_mainMemory != null)
|
||||
{
|
||||
return _mainMemory;
|
||||
}
|
||||
|
||||
return this.First();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_mainMemory = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,6 +247,11 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.Any(x => x.Name == "System Bus");
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +260,18 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_systemBus != null)
|
||||
{
|
||||
return _systemBus;
|
||||
}
|
||||
|
||||
return this.FirstOrDefault(x => x.Name == "System Bus");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_systemBus = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
MemoryDomain this[string name] { get; }
|
||||
|
||||
MemoryDomain MainMemory { get; }
|
||||
MemoryDomain MainMemory { get; set; }
|
||||
|
||||
bool HasSystemBus { get; }
|
||||
|
||||
MemoryDomain SystemBus { get; }
|
||||
MemoryDomain SystemBus { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
|
|||
if (s1 > 0 && p1 != IntPtr.Zero)
|
||||
mms.Add(MemoryDomain.FromIntPtr("Cart B", s1, MemoryDomain.Endian.Little, p1, false));
|
||||
|
||||
_memoryDomains = new MemoryDomainList(mms, 0);
|
||||
_memoryDomains = new MemoryDomainList(mms);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
mm.Add(cr);
|
||||
}
|
||||
|
||||
_memoryDomains = new MemoryDomainList(mm, 0);
|
||||
_memoryDomains = new MemoryDomainList(mm);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
}
|
||||
));
|
||||
|
||||
_memoryDomains = new MemoryDomainList(mm, 0);
|
||||
_memoryDomains = new MemoryDomainList(mm);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
|
|||
}
|
||||
|
||||
// main memory is in position 2
|
||||
_memoryDomains = new MemoryDomainList(ret, 2);
|
||||
_memoryDomains = new MemoryDomainList(ret);
|
||||
_memoryDomains.MainMemory = _memoryDomains["Work Ram Low"];
|
||||
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -619,7 +619,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
mm.Add(MemoryDomain.FromIntPtrSwap16(name, size, MemoryDomain.Endian.Big, area));
|
||||
}
|
||||
}
|
||||
MemoryDomains = new MemoryDomainList(mm, 0);
|
||||
MemoryDomains = new MemoryDomainList(mm);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
}
|
||||
|
||||
|
|
|
@ -618,7 +618,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
OctoshockDll.shock_GetMemData(psx, out ptr, out size, OctoshockDll.eMemType.DCache);
|
||||
mmd.Add(MemoryDomain.FromIntPtr("DCache", size, MemoryDomain.Endian.Little, ptr, true));
|
||||
|
||||
MemoryDomains = new MemoryDomainList(mmd, 0);
|
||||
MemoryDomains = new MemoryDomainList(mmd);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
string sname = Marshal.PtrToStringAnsi(name);
|
||||
mmd.Add(MemoryDomain.FromIntPtr(sname, size, MemoryDomain.Endian.Little, data));
|
||||
}
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(new MemoryDomainList(mmd, 0));
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(new MemoryDomainList(mmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue