/* Our probe, not part of Nuked-MD. md.c is compiled with -DAudio_Update=probe_audio_update, so this runs once per main-loop pass, just before Nuked-MD's own Audio_Update. At mcycles == stop_at it writes the whole state with Nuked-MD's save_state (the six pointers zeroed first, since they differ between processes by design) and ends the process. */ #include #include #include #include #include "fc1004.h" #include "savestate.h" #include "audio.h" extern fc1004_t ym; extern uint64_t mcycles; uint64_t stop_at; uintptr_t probe_ym_addr(void) { return (uintptr_t)&ym; } int probe_off_target(void) { return (ym.arb.ext_data_out != &ym.o_vdata) + (ym.arb.ext_vaddress_out != &ym.o_vaddress) + (ym.ioc.ext_vdata_out != &ym.o_vdata) + (ym.ioc.ext_zdata_out != &ym.o_zdata) + (ym.ioc.ext_vaddress_out != &ym.o_vaddress) + (ym.tmss.ext_data_out != &ym.o_vdata); } void probe_audio_update(void) { if (stop_at && mcycles == stop_at) { fprintf(stderr, "stop at mcycles=%llu, pointers off target %d/6\n", (unsigned long long)mcycles, probe_off_target()); ym.arb.ext_data_out = ym.arb.ext_vaddress_out = 0; ym.ioc.ext_vdata_out = ym.ioc.ext_zdata_out = ym.ioc.ext_vaddress_out = 0; ym.tmss.ext_data_out = 0; save_state(getenv("DUMP")); fflush(NULL); _exit(0); } Audio_Update(); }