SNES saveram: check for existance
checks if SGB saveram exists before attempting to assign it to the buffer pointer. Also return null if no saveram is found, which conforms to what other cores are doing and what EMUHawk expects
This commit is contained in:
parent
4e1decfa21
commit
5b731cf8b8
|
@ -15,11 +15,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
byte* buf = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM);
|
||||
var size = Api.QUERY_get_memory_size(LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM);
|
||||
if (buf == null)
|
||||
|
||||
if (buf == null && Api.QUERY_get_memory_size(LibsnesApi.SNES_MEMORY.SGB_CARTRAM)>0)
|
||||
{
|
||||
buf = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.SGB_CARTRAM);
|
||||
size = Api.QUERY_get_memory_size(LibsnesApi.SNES_MEMORY.SGB_CARTRAM);
|
||||
}
|
||||
if (buf==null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ret = new byte[size];
|
||||
Marshal.Copy((IntPtr)buf, ret, 0, size);
|
||||
|
|
Loading…
Reference in New Issue