teach libretrobridge stuff how to check for changed serialize size
This commit is contained in:
parent
6db010e384
commit
64e9a70d26
|
@ -150,6 +150,7 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
{
|
{
|
||||||
public retro_system_info retro_system_info;
|
public retro_system_info retro_system_info;
|
||||||
public retro_system_av_info retro_system_av_info;
|
public retro_system_av_info retro_system_av_info;
|
||||||
|
public uint retro_serialize_size_initial; //size_t :(
|
||||||
public uint retro_serialize_size; //size_t :(
|
public uint retro_serialize_size; //size_t :(
|
||||||
public uint retro_region;
|
public uint retro_region;
|
||||||
public uint retro_api_version;
|
public uint retro_api_version;
|
||||||
|
|
|
@ -58,6 +58,13 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint CMD_UpdateSerializeSize()
|
||||||
|
{
|
||||||
|
Message(eMessage.CMD_UpdateSerializeSize);
|
||||||
|
WaitForCMD();
|
||||||
|
return comm->env.retro_serialize_size;
|
||||||
|
}
|
||||||
|
|
||||||
public bool CMD_Serialize(byte[] data)
|
public bool CMD_Serialize(byte[] data)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
CMD_Deinit,
|
CMD_Deinit,
|
||||||
CMD_Reset,
|
CMD_Reset,
|
||||||
CMD_Run,
|
CMD_Run,
|
||||||
|
CMD_UpdateSerializeSize,
|
||||||
CMD_Serialize,
|
CMD_Serialize,
|
||||||
CMD_Unserialize,
|
CMD_Unserialize,
|
||||||
CMD_LAST,
|
CMD_LAST,
|
||||||
|
|
|
@ -374,6 +374,7 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
|
|
||||||
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||||
{
|
{
|
||||||
|
api.CMD_UpdateSerializeSize();
|
||||||
if (savebuff == null || savebuff.Length != api.comm->env.retro_serialize_size)
|
if (savebuff == null || savebuff.Length != api.comm->env.retro_serialize_size)
|
||||||
{
|
{
|
||||||
savebuff = new byte[api.comm->env.retro_serialize_size];
|
savebuff = new byte[api.comm->env.retro_serialize_size];
|
||||||
|
@ -404,6 +405,7 @@ namespace BizHawk.Emulation.Cores.Libretro
|
||||||
|
|
||||||
public byte[] SaveStateBinary()
|
public byte[] SaveStateBinary()
|
||||||
{
|
{
|
||||||
|
api.CMD_UpdateSerializeSize();
|
||||||
if (savebuff == null || savebuff.Length != api.comm->env.retro_serialize_size)
|
if (savebuff == null || savebuff.Length != api.comm->env.retro_serialize_size)
|
||||||
{
|
{
|
||||||
savebuff = new byte[api.comm->env.retro_serialize_size];
|
savebuff = new byte[api.comm->env.retro_serialize_size];
|
||||||
|
|
|
@ -89,6 +89,7 @@ enum eMessage : s32
|
||||||
CMD_Deinit,
|
CMD_Deinit,
|
||||||
CMD_Reset,
|
CMD_Reset,
|
||||||
CMD_Run,
|
CMD_Run,
|
||||||
|
CMD_UpdateSerializeSize,
|
||||||
CMD_Serialize,
|
CMD_Serialize,
|
||||||
CMD_Unserialize,
|
CMD_Unserialize,
|
||||||
CMD_LAST,
|
CMD_LAST,
|
||||||
|
@ -140,6 +141,7 @@ struct CommStruct
|
||||||
//set by the core
|
//set by the core
|
||||||
retro_system_info retro_system_info;
|
retro_system_info retro_system_info;
|
||||||
retro_system_av_info retro_system_av_info;
|
retro_system_av_info retro_system_av_info;
|
||||||
|
size_t retro_serialize_size_initial;
|
||||||
size_t retro_serialize_size;
|
size_t retro_serialize_size;
|
||||||
u32 retro_region;
|
u32 retro_region;
|
||||||
u32 retro_api_version;
|
u32 retro_api_version;
|
||||||
|
@ -694,7 +696,7 @@ static void LoadHandler(eMessage msg)
|
||||||
|
|
||||||
//Between calls to retro_load_game() and retro_unload_game(), the returned size is never allowed to be larger than a previous returned
|
//Between calls to retro_load_game() and retro_unload_game(), the returned size is never allowed to be larger than a previous returned
|
||||||
//value, to ensure that the frontend can allocate a save state buffer once.
|
//value, to ensure that the frontend can allocate a save state buffer once.
|
||||||
comm.env.retro_serialize_size = comm.funs.retro_serialize_size();
|
comm.env.retro_serialize_size_initial = comm.env.retro_serialize_size = comm.funs.retro_serialize_size();
|
||||||
|
|
||||||
//not sure when this can be called, but it's surely safe here
|
//not sure when this can be called, but it's surely safe here
|
||||||
comm.env.retro_region = comm.funs.retro_get_region();
|
comm.env.retro_region = comm.funs.retro_get_region();
|
||||||
|
@ -722,6 +724,11 @@ void cmd_Run()
|
||||||
comm.funs.retro_run();
|
comm.funs.retro_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_UpdateSerializeSize()
|
||||||
|
{
|
||||||
|
comm.env.retro_serialize_size = comm.funs.retro_serialize_size();
|
||||||
|
}
|
||||||
|
|
||||||
void cmd_Serialize()
|
void cmd_Serialize()
|
||||||
{
|
{
|
||||||
comm.value = !!comm.funs.retro_serialize(comm.buf[BufId::Param0], comm.buf_size[BufId::Param0]);
|
comm.value = !!comm.funs.retro_serialize(comm.buf[BufId::Param0], comm.buf_size[BufId::Param0]);
|
||||||
|
@ -765,6 +772,7 @@ const Action kHandlers_CMD[] = {
|
||||||
cmd_Deinit,
|
cmd_Deinit,
|
||||||
cmd_Reset,
|
cmd_Reset,
|
||||||
cmd_Run,
|
cmd_Run,
|
||||||
|
cmd_UpdateSerializeSize,
|
||||||
cmd_Serialize,
|
cmd_Serialize,
|
||||||
cmd_Unserialize,
|
cmd_Unserialize,
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue