fix mgba etc. (get_system_av_info does after load_game)
This commit is contained in:
parent
9db8822df9
commit
892fb361bf
|
@ -2,7 +2,7 @@
|
|||
name = "zretro"
|
||||
version = "0.1.0"
|
||||
authors = ["lifning"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[patch.'https://cybre.tech/lifning/ferretro.git']
|
||||
ferretro_base = { path = "../ferretro/ferretro_base" }
|
||||
|
|
|
@ -12,7 +12,6 @@ use sdl2::rect::{Rect, Point};
|
|||
use regex::Regex;
|
||||
|
||||
pub const BG_COLOR: Color = Color { r: 65, g: 44, b: 130, a: 255 };
|
||||
pub const LIFONT_PNG: &'static [u8] = include_bytes!("lifont.png");
|
||||
pub const MOUSE_PNG: &'static [u8] = include_bytes!("zmouse.png");
|
||||
pub const MOUSE_SHADOW_PNG: &'static [u8] = include_bytes!("zmouse-shadow.png");
|
||||
|
||||
|
@ -24,7 +23,7 @@ pub struct SurfaceFont<'a> {
|
|||
|
||||
impl<'a> SurfaceFont<'a> {
|
||||
pub fn load_lifont() -> Result<SurfaceFont<'a>> {
|
||||
let surf = surface_asset(LIFONT_PNG)?;
|
||||
let surf = surface_asset(include_bytes!("lifont.png"))?;
|
||||
let surf_rect = surf.rect();
|
||||
let canvas = surf.into_canvas()?;
|
||||
|
||||
|
|
34
src/main.rs
34
src/main.rs
|
@ -3,7 +3,7 @@ extern crate sdl2;
|
|||
|
||||
use std::ffi::CStr;
|
||||
use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
use core::pin::Pin;
|
||||
|
||||
use sdl2::{
|
||||
EventPump,
|
||||
|
@ -67,7 +67,6 @@ impl Zretro {
|
|||
fn new(opt: Opt) -> Result<Self> {
|
||||
let mut emu = RetroComponentBase::new(&opt.core);
|
||||
|
||||
let SystemAvInfo { geometry, .. } = emu.libretro_core().get_system_av_info();
|
||||
let sys_info = emu.libretro_core().get_system_info();
|
||||
let title = format!(
|
||||
"zretro - {}",
|
||||
|
@ -76,23 +75,11 @@ impl Zretro {
|
|||
|
||||
let mut sdl_context = sdl2::init()?;
|
||||
|
||||
let window = sdl_context
|
||||
.video()?
|
||||
.window(title.as_str(), geometry.base_width, geometry.base_height)
|
||||
.borderless()
|
||||
.build()?;
|
||||
let canvas = window.into_canvas().build()?;
|
||||
emu.register_component(Sdl2SurfaceComponent::new()?)?;
|
||||
|
||||
let event_pump = sdl_context.event_pump()?;
|
||||
emu.register_component(SimpleSdl2AudioComponent::new(&mut sdl_context)?)?;
|
||||
|
||||
let sdl2surf_comp = Sdl2SurfaceComponent::new(emu.libretro_core())?;
|
||||
emu.register_component(sdl2surf_comp)?;
|
||||
|
||||
let sdl2_audio = SimpleSdl2AudioComponent::new(&mut sdl_context, emu.libretro_core());
|
||||
emu.register_component(sdl2_audio)?;
|
||||
|
||||
let sleep_fps = SleepFramerateLimitComponent::new(emu.libretro_core());
|
||||
emu.register_component(sleep_fps)?;
|
||||
emu.register_component(SleepFramerateLimitComponent::default())?;
|
||||
|
||||
emu.register_component(PathBufComponent {
|
||||
sys_path: opt.system.clone(),
|
||||
|
@ -104,6 +91,17 @@ impl Zretro {
|
|||
emu.init().unwrap();
|
||||
emu.load_game(&opt.rom).unwrap(); // TODO: optional via CLI positional arg, menu-browsable
|
||||
|
||||
let SystemAvInfo { geometry, .. } = emu.libretro_core().get_system_av_info();
|
||||
|
||||
let window = sdl_context
|
||||
.video()?
|
||||
.window(title.as_str(), geometry.base_width, geometry.base_height)
|
||||
.borderless()
|
||||
.build()?;
|
||||
let canvas = window.into_canvas().build()?;
|
||||
|
||||
let event_pump = sdl_context.event_pump()?;
|
||||
|
||||
let font = SurfaceFont::load_zfont()?;
|
||||
|
||||
let mouse_surf = surface_asset(MOUSE_PNG)?;
|
||||
|
@ -169,10 +167,8 @@ impl Zretro {
|
|||
|
||||
fn toggle_mode(&mut self) -> Result<()> {
|
||||
self.mode.toggle();
|
||||
let audio: &SimpleSdl2AudioComponent = self.emu.component_ref()?;
|
||||
match self.mode {
|
||||
GuiState::Menus => {
|
||||
audio.silence_buffer();
|
||||
self.mouse_cursor.set();
|
||||
self.mouse_util.show_cursor(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue