LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Added support for PS1 emulators #33

Closed Jujstme closed 1 year ago

Jujstme commented 1 year ago

This adds support for coding auto splitters for Playstation 1 emulators.

Code and the general inner workings of the ps1::Emulator struct uses the same implementation seen in https://github.com/LiveSplit/asr/pull/26

So, in order to use it:

  1. Enable the ps1 feature in your Cargo.toml
  2. Attach to the supported PS1 emulators by running ps1::Emulator::attach()
  3. Run the internal update() -> bool to locate and update the address of the emulated game's memory
  4. Read from the game's memory via its read function

Supported Windows emulators are:

Example:

async fn main() {
    let settings = Settings::register();

    loop {
        let mut emulator = retry(ps1::Emulator::attach).await;
        let mut watchers = Watchers::default();

        loop {
            if !emulator.is_open() {
                break;
            }

            if emulator.update() {
                /// ...
                /// Your splitting code goes here
                /// Example:
                /// if let Ok(val) = emulator.read::<u8>(address) {
                ///     if val > 0 {
                ///         asr::timer::start();
                ///     }
                /// }
                /// etc...
            }
            next_tick().await;
        }
    }
}