From a4bbaae8b34545354a1d25bdcf1a5cca87c79923 Mon Sep 17 00:00:00 2001 From: Jujstme Date: Tue, 26 Dec 2023 11:28:39 +0100 Subject: [PATCH] Added `wait_attach()` functions to emulators --- src/emulator/gba/mod.rs | 17 ++++++++++++++++- src/emulator/gcn/mod.rs | 12 +++++++++++- src/emulator/genesis/mod.rs | 15 ++++++++++++++- src/emulator/ps1/mod.rs | 18 +++++++++++++++++- src/emulator/ps2/mod.rs | 12 +++++++++++- src/emulator/sms/mod.rs | 14 +++++++++++++- src/emulator/wii/mod.rs | 12 +++++++++++- 7 files changed, 93 insertions(+), 7 deletions(-) diff --git a/src/emulator/gba/mod.rs b/src/emulator/gba/mod.rs index 7cfe868..71847b3 100644 --- a/src/emulator/gba/mod.rs +++ b/src/emulator/gba/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Error, Process}; +use crate::{future::retry, Address, Error, Process}; use bytemuck::CheckedBitPattern; mod emuhawk; @@ -52,6 +52,21 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - VisualBoyAdvance + /// - VisualBoyAdvance-M + /// - mGBA + /// - NO$GBA + /// - BizHawk + /// - Retroarch, with one of the following cores: `vbam_libretro.dll`, `vba_next_libretro.dll`, + /// `mednafen_gba_libretro.dll`, `mgba_libretro.dll`, `gpsp_libretro.dll` + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/gcn/mod.rs b/src/emulator/gcn/mod.rs index 783205c..c6f13cf 100644 --- a/src/emulator/gcn/mod.rs +++ b/src/emulator/gcn/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Endian, Error, FromEndian, Process}; +use crate::{future::retry, Address, Endian, Error, FromEndian, Process}; use bytemuck::CheckedBitPattern; mod dolphin; @@ -46,6 +46,16 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - Dolphin + /// - Retroarch (using the `dolphin_libretro.dll` core) + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/genesis/mod.rs b/src/emulator/genesis/mod.rs index c96d69b..84d5c25 100644 --- a/src/emulator/genesis/mod.rs +++ b/src/emulator/genesis/mod.rs @@ -8,7 +8,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Endian, Error, FromEndian, Process}; +use crate::{future::retry, Address, Endian, Error, FromEndian, Process}; use bytemuck::CheckedBitPattern; mod blastem; @@ -53,6 +53,19 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - Retroarch + /// - SEGA Classics / SEGA Game Room + /// - Fusion + /// - Gens + /// - BlastEm + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/ps1/mod.rs b/src/emulator/ps1/mod.rs index e5d79f5..8a1250a 100644 --- a/src/emulator/ps1/mod.rs +++ b/src/emulator/ps1/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Error, Process}; +use crate::{future::retry, Address, Error, Process}; use bytemuck::CheckedBitPattern; mod duckstation; @@ -37,6 +37,7 @@ impl Emulator { /// - ePSXe /// - pSX /// - Duckstation + /// - Mednafen /// - Retroarch (supported cores: Beetle-PSX, Swanstation, PCSX ReARMed) /// - PCSX-redux /// - XEBRA @@ -52,6 +53,21 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - ePSXe + /// - pSX + /// - Duckstation + /// - Mednafen + /// - Retroarch (supported cores: Beetle-PSX, Swanstation, PCSX ReARMed) + /// - PCSX-redux + /// - XEBRA + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/ps2/mod.rs b/src/emulator/ps2/mod.rs index bd605a4..b734dd5 100644 --- a/src/emulator/ps2/mod.rs +++ b/src/emulator/ps2/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Error, Process}; +use crate::{future::retry, Address, Error, Process}; use bytemuck::CheckedBitPattern; mod pcsx2; @@ -43,6 +43,16 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - PCSX2 + /// - Retroarch (64-bit version, using the `pcsx2_libretro.dll` core) + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/sms/mod.rs b/src/emulator/sms/mod.rs index 22e66f0..8b81e24 100644 --- a/src/emulator/sms/mod.rs +++ b/src/emulator/sms/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Error, Process}; +use crate::{future::retry, Address, Error, Process}; use bytemuck::CheckedBitPattern; mod blastem; @@ -47,6 +47,18 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - Retroarch, with one of the following cores: `genesis_plus_gx_libretro.dll`, + /// `genesis_plus_gx_wide_libretro.dll`, `picodrive_libretro.dll`, `smsplus_libretro.dll`, `gearsystem_libretro.dll` + /// - Fusion + /// - BlastEm + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool { diff --git a/src/emulator/wii/mod.rs b/src/emulator/wii/mod.rs index 8e166a8..bf57084 100644 --- a/src/emulator/wii/mod.rs +++ b/src/emulator/wii/mod.rs @@ -7,7 +7,7 @@ use core::{ task::{Context, Poll}, }; -use crate::{Address, Endian, Error, FromEndian, Process}; +use crate::{future::retry, Address, Endian, Error, FromEndian, Process}; use bytemuck::CheckedBitPattern; mod dolphin; @@ -47,6 +47,16 @@ impl Emulator { }) } + /// Asynchronously awaits attaching to a target emulator, + /// yielding back to the runtime between each try. + /// + /// Supported emulators are: + /// - Dolphin + /// - Retroarch (using the `dolphin_libretro.dll` core) + pub async fn wait_attach() -> Self { + retry(Self::attach).await + } + /// Checks whether the emulator is still open. If it is not open anymore, /// you should drop the emulator. pub fn is_open(&self) -> bool {