68 lines
2.0 KiB
Rust
68 lines
2.0 KiB
Rust
extern crate crossbeam_channel;
|
|
extern crate ferretro;
|
|
extern crate sdl2;
|
|
extern crate serde;
|
|
extern crate serde_bytes;
|
|
|
|
use structopt::StructOpt;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use ferretro_synced::emulator::emulator::MyEmulator;
|
|
use ferretro_synced::emulator::libretro_memory_map::LibRetroMemoryMap;
|
|
use ferretro_synced::sync::game::{SyncableGame, KnownGames, read_game_name, create_game};
|
|
use ferretro_synced::sync::comms::CommunicationSettings;
|
|
|
|
pub fn main() -> failure::Fallible<()> {
|
|
let opt: Opt = Opt::from_args();
|
|
let mut emu = MyEmulator::new(&opt.core, &opt.system);
|
|
emu.load_game(&opt.rom);
|
|
|
|
// memory map should be ready after init & loading game.
|
|
let ffi_memory_map = emu.memory_map.as_ref().expect("Memory map was not set by emulator core, cannot continue.");
|
|
let memory_map = LibRetroMemoryMap::create(ffi_memory_map);
|
|
|
|
match (&opt.state) {
|
|
Some(s) => emu.load_state(s),
|
|
None => ()
|
|
}
|
|
|
|
let which_game = read_game_name("assume you can get it from emu".to_string());
|
|
|
|
let comms_settings = CommunicationSettings {
|
|
connection: "ws://127.0.0.1:8765".to_string()
|
|
};
|
|
|
|
match which_game {
|
|
Some(which_game) => {
|
|
let synced_game = create_game(which_game, comms_settings, &memory_map);
|
|
|
|
emu.begin_sync(synced_game);
|
|
},
|
|
None => {
|
|
println!("Game is unknown, not syncing.")
|
|
}
|
|
|
|
}
|
|
//let mut comms = Communication::new::<ferretro_synced::sync::pokemon_rb::Message>();
|
|
|
|
emu.run();
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[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,
|
|
/// System directory, often containing BIOS files
|
|
#[structopt(short, long, parse(from_os_str))]
|
|
system: Option<PathBuf>,
|
|
/// Serialized game state to load
|
|
#[structopt(long, parse(from_os_str))]
|
|
state: Option<PathBuf>,
|
|
}
|