public void FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; /* if the input poll callback is called, it will set this to false * this has to be done before we save the per-frame state in deterministic * mode, because in there, the core actually advances, and might advance * through the point in time where IsLagFrame gets set to false. makes sense? */ IsLagFrame = true; if (!_nocallbacks && _tracer.Enabled) { //Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.SMP, _tracecb); //TEST -- it works but theres no way to control it from the frontend now if (IsSGB) { Api.QUERY_set_trace_callback(1 << (int)LibsnesApi.eTRACE.GB, _tracecb); } else { Api.QUERY_set_trace_callback(1 << (int)LibsnesApi.eTRACE.CPU, _tracecb); } } else { Api.QUERY_set_trace_callback(0, null); } // for deterministic emulation, save the state we're going to use before frame advance // don't do this during nocallbacks though, since it's already been done if (!_nocallbacks && DeterministicEmulation) { var ms = new MemoryStream(); var bw = new BinaryWriter(ms); bw.Write(CoreSaveState()); bw.Write(false); // not framezero var ssc = new SaveController(); ssc.CopyFrom(controller); ssc.Serialize(bw); bw.Close(); _savestatebuff = ms.ToArray(); } // speedup when sound rendering is not needed Api.QUERY_set_audio_sample(rendersound ? _soundcb : null); bool resetSignal = controller.IsPressed("Reset"); if (resetSignal) { Api.CMD_reset(); } bool powerSignal = controller.IsPressed("Power"); if (powerSignal) { Api.CMD_power(); } var enables = new LibsnesApi.LayerEnables { BG1_Prio0 = _settings.ShowBG1_0, BG1_Prio1 = _settings.ShowBG1_1, BG2_Prio0 = _settings.ShowBG2_0, BG2_Prio1 = _settings.ShowBG2_1, BG3_Prio0 = _settings.ShowBG3_0, BG3_Prio1 = _settings.ShowBG3_1, BG4_Prio0 = _settings.ShowBG4_0, BG4_Prio1 = _settings.ShowBG4_1, Obj_Prio0 = _settings.ShowOBJ_0, Obj_Prio1 = _settings.ShowOBJ_1, Obj_Prio2 = _settings.ShowOBJ_2, Obj_Prio3 = _settings.ShowOBJ_3 }; Api.SetLayerEnables(ref enables); RefreshMemoryCallbacks(false); // apparently this is one frame? _timeFrameCounter++; Api.CMD_run(); // once upon a time we forwarded messages frmo bsnes here, by checking for queued text messages, but I don't think it's needed any longer if (IsLagFrame) { LagCount++; } }
public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; /* if the input poll callback is called, it will set this to false * this has to be done before we save the per-frame state in deterministic * mode, because in there, the core actually advances, and might advance * through the point in time where IsLagFrame gets set to false. makes sense? */ IsLagFrame = true; if (_tracer.Enabled) { //Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.SMP, _tracecb); //TEST -- it works but theres no way to control it from the frontend now if (IsSGB) { Api.QUERY_set_trace_callback(1 << (int)LibsnesApi.eTRACE.GB, _tracecb); } else { Api.QUERY_set_trace_callback(1 << (int)LibsnesApi.eTRACE.CPU, _tracecb); } } else { Api.QUERY_set_trace_callback(0, null); } // speedup when sound rendering is not needed Api.QUERY_set_audio_sample(renderSound ? _soundcb : null); bool resetSignal = controller.IsPressed("Reset"); if (resetSignal) { Api.CMD_reset(); } bool powerSignal = controller.IsPressed("Power"); if (powerSignal) { Api.CMD_power(); } var enables = new LibsnesApi.LayerEnables { BG1_Prio0 = _settings.ShowBG1_0, BG1_Prio1 = _settings.ShowBG1_1, BG2_Prio0 = _settings.ShowBG2_0, BG2_Prio1 = _settings.ShowBG2_1, BG3_Prio0 = _settings.ShowBG3_0, BG3_Prio1 = _settings.ShowBG3_1, BG4_Prio0 = _settings.ShowBG4_0, BG4_Prio1 = _settings.ShowBG4_1, Obj_Prio0 = _settings.ShowOBJ_0, Obj_Prio1 = _settings.ShowOBJ_1, Obj_Prio2 = _settings.ShowOBJ_2, Obj_Prio3 = _settings.ShowOBJ_3 }; Api.SetLayerEnables(ref enables); RefreshMemoryCallbacks(false); // apparently this is one frame? _timeFrameCounter++; Api.CMD_run(); // once upon a time we forwarded messages from bsnes here, by checking for queued text messages, but I don't think it's needed any longer if (IsLagFrame) { LagCount++; } return(true); }