diff --git a/src/genie.rs b/src/genie.rs index 8a1fe39a42bd11b94bdf2591881a6808c294d97f..7a2ca2e158af53ef075050ba1d1914ccd08a9fa3 100644 --- a/src/genie.rs +++ b/src/genie.rs @@ -3,7 +3,11 @@ use std::{ fmt::{self, Display, Formatter}, }; +#[cfg(feature = "wasm")] +use wasm_bindgen::prelude::*; + #[derive(Clone)] +#[cfg_attr(feature = "wasm", wasm_bindgen)] pub struct GameGenie { /// Hash map that contains the complete set of Game Genie /// codes that have been registered for the current ROM. diff --git a/src/rom.rs b/src/rom.rs index 8a4d4d1dfeb5f6c04304d158c284d4692144c38c..350003a978f75878e046cefd5fcf5f7e53f3f9d7 100644 --- a/src/rom.rs +++ b/src/rom.rs @@ -564,6 +564,16 @@ impl Cartridge { self.ram_data = ram_data; } + pub fn attach_genie(&mut self, game_genie: GameGenie) { + self.game_genie = Some(game_genie); + self.handler = &GAME_GENIE; + } + + pub fn detach_genie(&mut self) { + self.game_genie = None; + self.handler = self.mbc; + } + pub fn description(&self, column_length: usize) -> String { let name_l = format!("{:width$}", "Name", width = column_length); let type_l = format!("{:width$}", "Type", width = column_length); @@ -586,18 +596,6 @@ impl Cartridge { } } -impl Cartridge { - pub fn attach_genie(&mut self, game_genie: GameGenie) { - self.game_genie = Some(game_genie); - self.handler = &GAME_GENIE; - } - - pub fn detach_genie(&mut self) { - self.game_genie = None; - self.handler = self.mbc; - } -} - impl Default for Cartridge { fn default() -> Self { Self::new()