30 lines
986 B
Rust
30 lines
986 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: String) -> Option<KnownGames> {
|
|
Some(KnownGames::PokemonRedBlue) // todo: actually read the name of the game
|
|
}
|
|
|
|
|
|
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))
|
|
}
|
|
|
|
} |