ngp: connect saveram. due to the way this is implemented in neopop, connecting it greatly increased the size of savestates, which may or may not be worth fixing.
This commit is contained in:
parent
edde51bea9
commit
f96a7abb94
|
@ -31,6 +31,7 @@ using BizHawk.Client.EmuHawk.CoreExtensions;
|
|||
using BizHawk.Client.ApiHawk;
|
||||
using BizHawk.Emulation.Common.Base_Implementations;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
|
||||
using BizHawk.Emulation.Cores.Consoles.SNK;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -1686,7 +1687,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// GBA meteor core might not know how big the saveram ought to be, so just send it the whole file
|
||||
// GBA vba-next core will try to eat anything, regardless of size
|
||||
if (Emulator is VBANext || Emulator is MGBAHawk)
|
||||
if (Emulator is VBANext || Emulator is MGBAHawk || Emulator is NeoGeoPort)
|
||||
{
|
||||
sram = File.ReadAllBytes(PathManager.SaveRamPath(Global.Game));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
{
|
||||
Japanese, English
|
||||
}
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
public delegate void SaveRamCallback(IntPtr data, int length);
|
||||
|
||||
[BizImport(CC)]
|
||||
public abstract bool LoadSystem(byte[] rom, int romlength, Language language);
|
||||
|
@ -46,5 +48,11 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
public abstract void GetMemoryArea(int which, ref IntPtr ptr, ref int size, ref bool writable);
|
||||
[BizImport(CC)]
|
||||
public abstract void SetCommsCallbacks(IntPtr readcb, IntPtr pollcb, IntPtr writecb);
|
||||
[BizImport(CC)]
|
||||
public abstract bool HasSaveRam();
|
||||
[BizImport(CC)]
|
||||
public abstract bool PutSaveRam(byte[] data, int length);
|
||||
[BizImport(CC)]
|
||||
public abstract void GetSaveRam(SaveRamCallback callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
[CoreAttributes("NeoPop", "Thomas Klausner", true, false, "0.9.44.1",
|
||||
"https://mednafen.github.io/releases/", false)]
|
||||
public class NeoGeoPort : IEmulator, IVideoProvider, ISoundProvider, IStatable, IInputPollable,
|
||||
ISettable<object, NeoGeoPort.SyncSettings>
|
||||
ISettable<object, NeoGeoPort.SyncSettings>, ISaveRam
|
||||
{
|
||||
private PeRunner _exe;
|
||||
internal LibNeoGeoPort _neopop;
|
||||
|
@ -34,6 +34,9 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
|
||||
internal NeoGeoPort(CoreComm comm, byte[] rom, SyncSettings syncSettings, bool deterministic, ulong startAddress)
|
||||
{
|
||||
if (rom.Length > 4 * 1024 * 1024)
|
||||
throw new InvalidOperationException("ROM too big!");
|
||||
|
||||
ServiceProvider = new BasicServiceProvider(this);
|
||||
CoreComm = comm;
|
||||
_syncSettings = syncSettings ?? new SyncSettings();
|
||||
|
@ -43,9 +46,9 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
Path = comm.CoreFileProvider.DllPath(),
|
||||
Filename = "ngp.wbx",
|
||||
SbrkHeapSizeKB = 256,
|
||||
SealedHeapSizeKB = 10 * 1024, // must be a bit larger than twice the ROM size
|
||||
SealedHeapSizeKB = 5 * 1024, // must be a bit larger than the ROM size
|
||||
InvisibleHeapSizeKB = 4,
|
||||
PlainHeapSizeKB = 4,
|
||||
PlainHeapSizeKB = 5 * 1024, // must be a bit larger than the ROM size
|
||||
StartAddress = startAddress
|
||||
});
|
||||
|
||||
|
@ -374,5 +377,28 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISaveram
|
||||
|
||||
public bool SaveRamModified => _neopop.HasSaveRam();
|
||||
|
||||
public byte[] CloneSaveRam()
|
||||
{
|
||||
byte[] ret = null;
|
||||
_neopop.GetSaveRam((data, size) =>
|
||||
{
|
||||
ret = new byte[size];
|
||||
Marshal.Copy(data, ret, 0, size);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void StoreSaveRam(byte[] data)
|
||||
{
|
||||
if (!_neopop.PutSaveRam(data, data.Length))
|
||||
throw new InvalidOperationException("Core rejected the saveram");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -29,8 +29,8 @@ $(TARGET).in: $(OBJS)
|
|||
@$(CC) -o $@ $(LDFLAGS) $(CCFLAGS) $(OBJS) ../emulibc/libemuhost.so
|
||||
|
||||
$(TARGET): $(TARGET).in
|
||||
# strip $< -o $@ -R /4 -R /14 -R /29 -R /41 -R /55 -R /67 -R /78 -R /89 -R /104
|
||||
cp $< $@
|
||||
strip $< -o $@ -R /4 -R /14 -R /29 -R /41 -R /55 -R /67 -R /78 -R /89 -R /104
|
||||
# cp $< $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR)
|
||||
|
|
|
@ -202,11 +202,11 @@ bool FLASH_LoadNV(const uint8* data, uint32 size)
|
|||
//throw MDFN_Error(0, _("FLASH header total_file_length is bad!"));
|
||||
}
|
||||
|
||||
if (size < sizeof(FlashFileHeader) + header.total_file_length)
|
||||
if (size < header.total_file_length)
|
||||
return false;
|
||||
|
||||
flashdata.resize(header.total_file_length);
|
||||
memcpy(&flashdata[0], data + sizeof(FlashFileHeader), flashdata.size());
|
||||
memcpy(&flashdata[0], data, flashdata.size());
|
||||
|
||||
if (!do_flash_read(&flashdata[0]))
|
||||
return false;
|
||||
|
@ -219,7 +219,7 @@ bool FLASH_LoadNV(const uint8* data, uint32 size)
|
|||
//-----------------------------------------------------------------------------
|
||||
void flash_write(uint32 start_address, uint16 length)
|
||||
{
|
||||
/*uint16 i;
|
||||
uint16 i;
|
||||
|
||||
//Now we need a new flash command before the next flash write will work!
|
||||
memory_flash_command = FALSE;
|
||||
|
@ -255,7 +255,7 @@ void flash_write(uint32 start_address, uint16 length)
|
|||
blocks[block_count].start_address = start_address;
|
||||
blocks[block_count].data_length = length;
|
||||
block_count++;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
static void make_flash_commit(std::vector<uint8> &flashdata)
|
||||
|
@ -304,6 +304,11 @@ static void make_flash_commit(std::vector<uint8> &flashdata)
|
|||
}
|
||||
}
|
||||
|
||||
bool FLASH_IsModified()
|
||||
{
|
||||
return block_count > 0;
|
||||
}
|
||||
|
||||
void FLASH_SaveNV(void (*callback)(const uint8* data, uint32 size))
|
||||
{
|
||||
std::vector<uint8> flashdata;
|
||||
|
|
|
@ -24,6 +24,7 @@ void flash_write(uint32 start_address, uint16 length);
|
|||
|
||||
bool FLASH_LoadNV(const uint8* data, uint32 size);
|
||||
void FLASH_SaveNV(void (*callback)(const uint8* data, uint32 size));
|
||||
bool FLASH_IsModified();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -143,7 +143,7 @@ static MDFN_COLD bool Load(const uint8* romdata, int32 romlength)
|
|||
//throw MDFN_Error(0, _("NGP/NGPC ROM image is too large."));
|
||||
|
||||
ngpc_rom.length = fp_size;
|
||||
ngpc_rom.data = (uint8*)alloc_sealed(ngpc_rom.length);
|
||||
ngpc_rom.data = (uint8*)alloc_plain(ngpc_rom.length);
|
||||
memcpy(ngpc_rom.data, romdata, romlength);
|
||||
|
||||
rom_loaded();
|
||||
|
@ -240,3 +240,18 @@ EXPORT void GetMemoryArea(int which, void **ptr, int *size, int *writable)
|
|||
}
|
||||
}
|
||||
|
||||
EXPORT bool HasSaveRam()
|
||||
{
|
||||
return FLASH_IsModified();
|
||||
}
|
||||
|
||||
EXPORT bool PutSaveRam(const uint8* data, uint32 length)
|
||||
{
|
||||
return FLASH_LoadNV(data, length);
|
||||
}
|
||||
|
||||
EXPORT void GetSaveRam(void (*callback)(const uint8* data, uint32 length))
|
||||
{
|
||||
FLASH_SaveNV(callback);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue