diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts index d95d500678de2f3235e5b4f3c7b17544eb575641..f691ce0dbae09909fd836265c27dd8c6525ec8ab 100644 --- a/frontends/web/ts/gb.ts +++ b/frontends/web/ts/gb.ts @@ -442,7 +442,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { // inference logic to try to infer the best mode from the // GBC header in the cartridge data if (this.autoMode) { - this.gameBoy.infer_mode_ws(romData); + this.gameBoy.infer_mode_wa(romData); } // resets the Game Boy engine to restore it into @@ -452,12 +452,12 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { // loads the ROM file into the system and retrieves // the cartridge instance associated with it - const cartridge = this.gameBoy.load_rom_ws(romData); + const cartridge = this.gameBoy.load_rom_wa(romData); // loads the callbacks so that the Typescript code // gets notified about the various events triggered // in the WASM side - this.gameBoy.load_callbacks_ws(); + this.gameBoy.load_callbacks_wa(); // in case there's a serial device involved tries to load // it and initialize for the current Game Boy machine @@ -691,7 +691,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { get wasmEngine(): string | null { if (!this.gameBoy) return null; - return this.gameBoy.wasm_engine_ws() ?? null; + return this.gameBoy.wasm_engine_wa() ?? null; } get framerate(): number { @@ -804,22 +804,22 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { serializeState(): Uint8Array { if (!this.gameBoy) throw new Error("Unable to serialize state"); - return StateManager.save_ws(this.gameBoy, SaveStateFormat.Bos); + return StateManager.save_wa(this.gameBoy, SaveStateFormat.Bos); } unserializeState(data: Uint8Array) { if (!this.gameBoy) throw new Error("Unable to unserialize state"); - StateManager.load_ws(data, this.gameBoy, SaveStateFormat.Bos); + StateManager.load_wa(data, this.gameBoy, SaveStateFormat.Bos); } buildState(index: number, data: Uint8Array): SaveState { - const state = StateManager.read_bos_ws(data); + const state = StateManager.read_bos_wa(data); return { index: index, - timestamp: Number(state.timestamp_ws()), - agent: state.agent_ws(), - model: state.model_ws(), - thumbnail: state.image_eager_ws() + timestamp: Number(state.timestamp_wa()), + agent: state.agent_wa(), + model: state.model_wa(), + thumbnail: state.image_eager_wa() }; } @@ -904,17 +904,17 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { } loadNullDevice(set = true) { - this.gameBoy?.load_null_ws(); + this.gameBoy?.load_null_wa(); if (set) this.serialDevice = SerialDevice.Null; } loadLoggerDevice(set = true) { - this.gameBoy?.load_logger_ws(); + this.gameBoy?.load_logger_wa(); if (set) this.serialDevice = SerialDevice.Logger; } loadPrinterDevice(set = true) { - this.gameBoy?.load_printer_ws(); + this.gameBoy?.load_printer_wa(); if (set) this.serialDevice = SerialDevice.Printer; } @@ -967,7 +967,7 @@ export class GameboyEmulator extends EmulatorBase implements Emulator { private updatePalette() { const palette = PALETTES[this.paletteIndex]; - this.gameBoy?.set_palette_colors_ws(palette.colors); + this.gameBoy?.set_palette_colors_wa(palette.colors); this.storeSettings(); } @@ -1066,7 +1066,7 @@ const wasm = async (setHook = true) => { // wrap the call around try/catch if (setHook) { try { - GameBoy.set_panic_hook_ws(); + GameBoy.set_panic_hook_wa(); } catch (err) { console.error(err); } diff --git a/src/gb.rs b/src/gb.rs index d8c40a8cd38224ed6e2cf1e68f41c40418f2fa2f..712877c576730f5f8716676856ee4643f3a528e1 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -1168,7 +1168,7 @@ impl GameBoy { #[cfg(feature = "wasm")] #[cfg_attr(feature = "wasm", wasm_bindgen)] impl GameBoy { - pub fn set_panic_hook_ws() { + pub fn set_panic_hook_wa() { let prev = take_hook(); set_hook(Box::new(move |info| { hook_impl(info); @@ -1176,7 +1176,7 @@ impl GameBoy { })); } - pub fn load_rom_ws(&mut self, data: &[u8]) -> Cartridge { + pub fn load_rom_wa(&mut self, data: &[u8]) -> Cartridge { let rom = self.load_rom(data, None); rom.set_rumble_cb(|active| { rumble_callback(active); @@ -1184,18 +1184,18 @@ impl GameBoy { rom.clone() } - pub fn load_callbacks_ws(&mut self) { + pub fn load_callbacks_wa(&mut self) { self.set_speed_callback(|speed| { speed_callback(speed); }); } - pub fn load_null_ws(&mut self) { + pub fn load_null_wa(&mut self) { let null = Box::<NullDevice>::default(); self.attach_serial(null); } - pub fn load_logger_ws(&mut self) { + pub fn load_logger_wa(&mut self) { let mut logger = Box::<StdoutDevice>::default(); logger.set_callback(|data| { logger_callback(data.to_vec()); @@ -1203,7 +1203,7 @@ impl GameBoy { self.attach_serial(logger); } - pub fn load_printer_ws(&mut self) { + pub fn load_printer_wa(&mut self) { let mut printer = Box::<PrinterDevice>::default(); printer.set_callback(|image_buffer| { printer_callback(image_buffer.to_vec()); @@ -1213,12 +1213,12 @@ impl GameBoy { /// Updates the emulation mode using the cartridge /// of the provided data to obtain the CGB flag value. - pub fn infer_mode_ws(&mut self, data: &[u8]) { + pub fn infer_mode_wa(&mut self, data: &[u8]) { let mode = Cartridge::from_data(data).gb_mode(); self.set_mode(mode); } - pub fn set_palette_colors_ws(&mut self, value: Vec<JsValue>) { + pub fn set_palette_colors_wa(&mut self, value: Vec<JsValue>) { let palette: Palette = value .into_iter() .map(|v| Self::js_to_pixel(&v)) @@ -1228,7 +1228,7 @@ impl GameBoy { self.ppu().set_palette_colors(&palette); } - pub fn wasm_engine_ws(&self) -> Option<String> { + pub fn wasm_engine_wa(&self) -> Option<String> { let dependencies = dependencies_map(); if !dependencies.contains_key("wasm-bindgen") { return None; diff --git a/src/state.rs b/src/state.rs index 166289b28abf2fe60c87790417e66244d3283aa8..d597273668d121268d4e0b1d88d682c8aee24d01 100644 --- a/src/state.rs +++ b/src/state.rs @@ -165,19 +165,19 @@ impl BosState { #[cfg(feature = "wasm")] #[cfg_attr(feature = "wasm", wasm_bindgen)] impl BosState { - pub fn timestamp_ws(&self) -> Result<u64, String> { + pub fn timestamp_wa(&self) -> Result<u64, String> { Self::timestamp(self).map_err(|e| e.to_string()) } - pub fn agent_ws(&self) -> Result<String, String> { + pub fn agent_wa(&self) -> Result<String, String> { Self::agent(self).map_err(|e| e.to_string()) } - pub fn model_ws(&self) -> Result<String, String> { + pub fn model_wa(&self) -> Result<String, String> { Self::model(self).map_err(|e| e.to_string()) } - pub fn image_eager_ws(&self) -> Result<Vec<u8>, String> { + pub fn image_eager_wa(&self) -> Result<Vec<u8>, String> { Self::image_eager(self).map_err(|e| e.to_string()) } } @@ -1584,11 +1584,11 @@ impl StateManager { #[cfg(feature = "wasm")] #[cfg_attr(feature = "wasm", wasm_bindgen)] impl StateManager { - pub fn save_ws(gb: &mut GameBoy, format: Option<SaveStateFormat>) -> Result<Vec<u8>, String> { + pub fn save_wa(gb: &mut GameBoy, format: Option<SaveStateFormat>) -> Result<Vec<u8>, String> { Self::save(gb, format).map_err(|e| e.to_string()) } - pub fn load_ws( + pub fn load_wa( data: &[u8], gb: &mut GameBoy, format: Option<SaveStateFormat>, @@ -1596,15 +1596,15 @@ impl StateManager { Self::load(data, gb, format).map_err(|e| e.to_string()) } - pub fn read_bos_ws(data: &[u8]) -> Result<BosState, String> { + pub fn read_bos_wa(data: &[u8]) -> Result<BosState, String> { Self::read_bos(data).map_err(|e| e.to_string()) } - pub fn read_bess_ws(data: &[u8]) -> Result<BessState, String> { + pub fn read_bess_wa(data: &[u8]) -> Result<BessState, String> { Self::read_bess(data).map_err(|e| e.to_string()) } - pub fn thumbnail_ws(data: &[u8], format: Option<SaveStateFormat>) -> Result<Vec<u8>, String> { + pub fn thumbnail_wa(data: &[u8], format: Option<SaveStateFormat>) -> Result<Vec<u8>, String> { Self::thumbnail(data, format).map_err(|e| e.to_string()) } }