From 64ef1bfc1704cd750d39ba7e1774a415258ee0a0 Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Mon, 24 Jun 2024 19:22:11 -0700 Subject: [PATCH] Make NDS sys bus hack work better fixes e6f8450685c731587528596b39dd480983560e61 --- .../Consoles/Nintendo/NDS/MelonDS.IDebuggable.cs | 5 +++-- .../Consoles/Nintendo/NDS/MelonDS.cs | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.IDebuggable.cs index a35d857290..0ecf734c2b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.IDebuggable.cs @@ -52,7 +52,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks; - private readonly MemoryCallbackSystem _memoryCallbacks = new(new[] { "System Bus" }); + // FIXME: internally the code actually just does this for either bus (probably don't want to bother adding support) + private readonly MemoryCallbackSystem _memoryCallbacks = new([ "ARM9 System Bus" ]); private LibMelonDS.MemoryCallback _readCallback; private LibMelonDS.MemoryCallback _writeCallback; @@ -67,7 +68,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS { if (getHasCBOfType()) { - MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, "System Bus"); + MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, "ARM9 System Bus"); } }; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index 71b59712e0..aba1a36105 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -576,7 +576,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS Size = 1L << 32; WordSize = 4; EndianType = Endian.Little; - Writable = false; + Writable = true; Arm9Bus = arm9; Arm7Bus = arm7; @@ -596,7 +596,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS public override byte PeekByte(long addr) => UseArm9 ? Arm9Bus.PeekByte(addr) : Arm7Bus.PeekByte(addr); - public override void PokeByte(long addr, byte val) => throw new InvalidOperationException(); + public override void PokeByte(long addr, byte val) + { + if (UseArm9) + { + Arm9Bus.PokeByte(addr, val); + } + else + { + Arm7Bus.PokeByte(addr, val); + } + } } } }