33 lines
1004 B
Rust
33 lines
1004 B
Rust
use crate::sync::pokemon_rb::SyncedPokemonRedBlue;
|
|
use crate::sync::comms::CommunicationSettings;
|
|
use crate::emulator::libretro_memory_map::LibRetroMemoryMap;
|
|
|
|
pub trait SyncableGame {
|
|
// Update internal state based on tracked memory and the emulator
|
|
fn update_state(&mut self);
|
|
|
|
// Check for messages and handle them
|
|
fn handle_inbound_messages(&mut self) -> Result<(), failure::Error>;
|
|
|
|
// Check for messages and handle them
|
|
fn send_state_messages(&mut self) -> Result<(), failure::Error>;
|
|
}
|
|
|
|
pub enum KnownGames {
|
|
PokemonRedBlue,
|
|
}
|
|
|
|
pub fn read_game_name(name: &str) -> Option<KnownGames> {
|
|
match name {
|
|
"POKEMON BLUE" => Some(KnownGames::PokemonRedBlue),
|
|
_ => None
|
|
}
|
|
}
|
|
|
|
|
|
pub fn create_game(which_game: KnownGames, comms_settings: CommunicationSettings, memory_map: &LibRetroMemoryMap) -> Box<dyn SyncableGame> {
|
|
match which_game {
|
|
KnownGames::PokemonRedBlue => Box::from(SyncedPokemonRedBlue::create(comms_settings, memory_map))
|
|
}
|
|
|
|
} |