completing the trifecta: fix the terrible nondeterminisms that made series of snes romloads act wacky
This commit is contained in:
parent
a6caa8680d
commit
8e42658702
|
@ -32,6 +32,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
public static extern void snes_run();
|
public static extern void snes_run();
|
||||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_term();
|
public static extern void snes_term();
|
||||||
|
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void snes_unload_cartridge();
|
||||||
|
|
||||||
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void snes_load_cartridge_normal(
|
public static extern void snes_load_cartridge_normal(
|
||||||
|
@ -190,6 +192,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_input_state(null);
|
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_input_state(null);
|
||||||
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_audio_sample(null);
|
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_audio_sample(null);
|
||||||
|
|
||||||
|
LibsnesDll.snes_unload_cartridge();
|
||||||
LibsnesDll.snes_term();
|
LibsnesDll.snes_term();
|
||||||
|
|
||||||
resampler.Dispose();
|
resampler.Dispose();
|
||||||
|
@ -232,6 +235,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
}
|
}
|
||||||
LibsnesDll.snes_load_cartridge_normal(null, romData, romData.Length);
|
LibsnesDll.snes_load_cartridge_normal(null, romData, romData.Length);
|
||||||
|
|
||||||
|
LibsnesDll.snes_power();
|
||||||
|
|
||||||
SetupMemoryDomains(romData);
|
SetupMemoryDomains(romData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -126,32 +126,34 @@ void snes_set_cartridge_basename(const char *basename) {
|
||||||
interface.basename = basename;
|
interface.basename = basename;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <setjmp.h>
|
template<typename T> inline void reconstruct(T* t) {
|
||||||
static jmp_buf buf;
|
t->~T();
|
||||||
|
new(t) T();
|
||||||
void second(void) {
|
|
||||||
printf("second\n"); // prints
|
|
||||||
longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
void first(void) {
|
|
||||||
second();
|
|
||||||
printf("first\n"); // does not print
|
|
||||||
}
|
|
||||||
|
|
||||||
void test() {
|
|
||||||
if ( ! setjmp(buf) ) {
|
|
||||||
first(); // when executed, setjmp returns 0
|
|
||||||
} else { // when longjmp jumps back, setjmp returns 1
|
|
||||||
printf("main\n"); // prints
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void snes_init(void) {
|
void snes_init(void) {
|
||||||
test();
|
|
||||||
SNES::interface = &interface;
|
SNES::interface = &interface;
|
||||||
|
|
||||||
|
//because we're tasers and we didnt make this core, and we're paranoid, lets reconstruct everything so we know subsequent runs are as similar as possible
|
||||||
|
reconstruct(&SNES::icd2);
|
||||||
|
reconstruct(&SNES::nss);
|
||||||
|
reconstruct(&SNES::superfx);
|
||||||
|
reconstruct(&SNES::sa1);
|
||||||
|
reconstruct(&SNES::necdsp);
|
||||||
|
reconstruct(&SNES::hitachidsp);
|
||||||
|
reconstruct(&SNES::armdsp);
|
||||||
|
reconstruct(&SNES::bsxsatellaview);
|
||||||
|
reconstruct(&SNES::bsxcartridge);
|
||||||
|
reconstruct(&SNES::bsxflash);
|
||||||
|
reconstruct(&SNES::srtc);
|
||||||
|
reconstruct(&SNES::sdd1);
|
||||||
|
reconstruct(&SNES::spc7110);
|
||||||
|
reconstruct(&SNES::obc1);
|
||||||
|
reconstruct(&SNES::msu1);
|
||||||
|
reconstruct(&SNES::link);
|
||||||
|
reconstruct(&SNES::video);
|
||||||
|
reconstruct(&SNES::audio);
|
||||||
|
|
||||||
SNES::system.init();
|
SNES::system.init();
|
||||||
SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad);
|
SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad);
|
||||||
SNES::input.connect(SNES::Controller::Port2, SNES::Input::Device::Joypad);
|
SNES::input.connect(SNES::Controller::Port2, SNES::Input::Device::Joypad);
|
||||||
|
|
Loading…
Reference in New Issue