snes-reset the libsnes core (with whatever serious re-initialization logic we've currently written in libsnes) every time loadstate occurs; and add memsetting to that re-initialization logic, under the theory that if there is a savestate nondeterminism due to fundamental serialization bugs, at least loadstates will be deterministically buggy, decreasing the odds that anyone will ever notice them. of course, i would rather increase the odds that we'll notice them to 100%, so we can fix them, instead of just masking them. but i don't make the rules, i just stfu the nags

This commit is contained in:
zeromus 2012-12-01 06:21:53 +00:00
parent 08c83a16fd
commit db37a6f64f
3 changed files with 3 additions and 1 deletions

View File

@ -951,7 +951,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
{
int size = LibsnesDll.snes_serialize_size();
if (data.Length != size)
throw new Exception("Libsnes internal savestate size mismatch!");
throw new Exception("Libsnes internal savestate size mismatch!");
LibsnesDll.snes_init();
fixed (byte* pbuf = &data[0])
LibsnesDll.snes_unserialize(new IntPtr(pbuf), size);
}

View File

@ -161,6 +161,7 @@ void snes_set_cartridge_basename(const char *basename) {
template<typename T> inline void reconstruct(T* t) {
t->~T();
memset(t,0,sizeof(*t));
new(t) T();
}