2019-11-04 09:14:16 +01:00
|
|
|
extern crate failure;
|
|
|
|
extern crate libloading;
|
|
|
|
|
|
|
|
#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code)]
|
2019-11-11 01:24:29 +01:00
|
|
|
mod libretro_ffi;
|
2019-11-04 09:14:16 +01:00
|
|
|
mod libretro_loading;
|
2019-11-08 03:43:14 +01:00
|
|
|
mod libretro_convert;
|
2019-11-11 01:24:29 +01:00
|
|
|
mod libretro_wrapper;
|
|
|
|
|
2019-11-11 08:21:38 +01:00
|
|
|
use std::ffi::CStr;
|
2019-11-11 01:24:29 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
2019-11-12 08:56:28 +01:00
|
|
|
use crate::libretro_convert::Handler;
|
2019-11-11 01:24:29 +01:00
|
|
|
|
|
|
|
struct Foo;
|
2019-11-12 08:56:28 +01:00
|
|
|
impl Handler for Foo {
|
2019-11-11 01:24:29 +01:00
|
|
|
fn video_refresh(&mut self, data: &[u8], width: u32, height: u32, pitch: u32) {
|
|
|
|
println!("video_refresh {}x{}", width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(StructOpt)]
|
|
|
|
struct Opt {
|
|
|
|
/// Core module to use.
|
|
|
|
#[structopt(short, long, parse(from_os_str))]
|
|
|
|
core: PathBuf,
|
|
|
|
/// Rom to load using the core.
|
|
|
|
#[structopt(short, long, parse(from_os_str))]
|
|
|
|
rom: PathBuf,
|
|
|
|
}
|
2019-11-04 09:14:16 +01:00
|
|
|
|
|
|
|
fn main() -> failure::Fallible<()> {
|
2019-11-11 01:24:29 +01:00
|
|
|
let opt: Opt = Opt::from_args();
|
|
|
|
let lib = libloading::Library::new(&opt.core)?;
|
2019-11-04 09:14:16 +01:00
|
|
|
let retro = libretro_loading::LibretroApi::from_library(&lib)?;
|
2019-11-11 01:24:29 +01:00
|
|
|
let wrapper = libretro_wrapper::LibretroWrapper::from(retro);
|
|
|
|
let mut foo = Foo{};
|
2019-11-12 08:56:28 +01:00
|
|
|
wrapper.register_handler(&mut foo);
|
2019-11-11 01:24:29 +01:00
|
|
|
println!("api version: {}", wrapper.as_ref().api_version());
|
|
|
|
println!("name: {}", unsafe { CStr::from_ptr(wrapper.as_ref().get_system_info().library_name) }.to_string_lossy());
|
|
|
|
wrapper.as_ref().init();
|
|
|
|
wrapper.as_ref().load_game(Some(&opt.rom), None, None);
|
|
|
|
wrapper.as_ref().run();
|
2019-11-04 09:14:16 +01:00
|
|
|
Ok(())
|
|
|
|
}
|