1pub mod cartridge; 2pub mod debug; 3pub mod memory; 4pub(crate) mod svp; 5pub mod vdp; 6pub mod ym2612; 7 8use crate::vdp::{DarkenColors, Vdp, VdpConfig}; 9use genesis_config::GenesisEmulatorConfig; 10use jgenesis_common::frontend::TimingMode; 11 12pub const NTSC_GENESIS_MCLK_FREQUENCY: f64 = 53_693_175.0; 13pub const PAL_GENESIS_MCLK_FREQUENCY: f64 = 53_203_424.0; 14 15pub const SPRITE_LIMITS_MODAL_MESSAGE: &str = "Sprite limits are disabled; may cause glitches"; 16 17pub trait GenesisEmulatorConfigExt { 18 #[must_use] 19 fn to_vdp_config(&self, s32x_present: bool) -> VdpConfig; 20} 21 22impl GenesisEmulatorConfigExt for GenesisEmulatorConfig { 23 fn to_vdp_config(&self, s32x_present: bool) -> VdpConfig { 24 VdpConfig { 25 enforce_sprite_limits: !self.remove_sprite_limits, 26 non_linear_color_scale: self.non_linear_color_scale, 27 deinterlace: self.deinterlace, 28 render_vertical_border: self.render_vertical_border, 29 render_horizontal_border: self.render_horizontal_border, 30 plane_a_enabled: self.plane_a_enabled, 31 plane_b_enabled: self.plane_b_enabled, 32 sprites_enabled: self.sprites_enabled, 33 window_enabled: self.window_enabled, 34 color_adjustment: if s32x_present && self.sega_32x.darken_genesis_colors { 35 DarkenColors::Yes 36 } else { 37 DarkenColors::No 38 }, 39 } 40 } 41} 42 43#[inline] 44#[must_use] 45pub fn target_framerate(vdp: &Vdp, timing_mode: TimingMode) -> f64 { 46 let mclk_frequency = match timing_mode { 47 TimingMode::Ntsc => NTSC_GENESIS_MCLK_FREQUENCY, 48 TimingMode::Pal => PAL_GENESIS_MCLK_FREQUENCY, 49 }; 50 51 mclk_frequency / (vdp::MCLK_CYCLES_PER_SCANLINE as f64) / vdp.average_scanlines_per_frame() 52}