fixes for gambatte and picodrive

This commit is contained in:
lif 2019-11-16 22:04:15 -08:00
parent ae4cebef6f
commit 140f988e99
1 changed files with 22 additions and 5 deletions

View File

@ -56,12 +56,23 @@ impl MyEmulator {
.to_string_lossy()
);
let av_info = retro.as_ref().get_system_av_info();
let mut av_info = retro.as_ref().get_system_av_info();
let pixel_format = sdl2::pixels::PixelFormatEnum::ABGR1555;
// HACK: some cores don't report this 'til we get an environ call to set_system_av_info...
// which is too late for this constructor to pass along to SDL.
if av_info.timing.sample_rate == 0.0 {
av_info.timing.sample_rate = 32040.0;
}
// similar hack, this one making sure we don't divide by zero in our frame limiter.
if av_info.timing.fps == 0.0 {
av_info.timing.fps = 60.0;
}
let sdl_context = sdl2::init().unwrap();
let (width, height) = (av_info.geometry.base_width, av_info.geometry.base_height);
let window = sdl_context
.video()
.unwrap()
@ -76,14 +87,11 @@ impl MyEmulator {
let (audio_sender, audio_receiver) = crossbeam_channel::bounded(2);
let audio = sdl_context.audio().unwrap();
let mut desired_spec = AudioSpecDesired {
let desired_spec = AudioSpecDesired {
freq: Some(av_info.timing.sample_rate.round() as i32),
channels: Some(2),
samples: None,
};
if let Some(0) = desired_spec.freq {
desired_spec.freq = Some(32040); // old default, fix for cores that don't report it
}
let mut audio_spec = None;
let audio_device = audio
.open_playback(None, &desired_spec, |spec| {
@ -183,6 +191,7 @@ impl retro::wrapper::Handler for MyEmulator {
.create_texture_static(self.pixel_format, width, height)
{
if tex.update(rect, data, pitch as usize).is_ok() {
self.canvas.clear();
self.canvas.copy(&tex, None, None).unwrap();
}
}
@ -226,6 +235,8 @@ impl retro::wrapper::Handler for MyEmulator {
}
}
fn get_can_dupe(&mut self) -> Option<bool> { Some(true) }
fn set_pixel_format(&mut self, pix_fmt: retro::ffi::PixelFormat) -> bool {
self.pixel_format = match pix_fmt {
retro::ffi::PixelFormat::ARGB1555 => sdl2::pixels::PixelFormatEnum::RGB555,
@ -236,11 +247,17 @@ impl retro::wrapper::Handler for MyEmulator {
}
fn set_system_av_info(&mut self, av_info: SystemAvInfo) -> bool {
let (width, height) = (av_info.geometry.base_width, av_info.geometry.base_height);
self.canvas.window_mut().set_size(width, height);
self.canvas.set_logical_size(width, height);
self.av_info = av_info;
true
}
fn set_geometry(&mut self, geom: GameGeometry) -> bool {
let (width, height) = (geom.base_width, geom.base_height);
self.canvas.window_mut().set_size(width, height);
self.canvas.set_logical_size(width, height);
self.av_info.geometry = geom;
true
}