Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for future for emulators #84

Merged
merged 3 commits into from
Jan 20, 2024
Merged

Conversation

Jujstme
Copy link
Contributor

@Jujstme Jujstme commented Dec 26, 2023

This commit adds support for future when coding autosplitters for emulators, allowing to code similarly compared to native pc games.
The internal update() function, which is usually necessary in emulators to ensure correct updating of the main ram_base address, gets called automatically in this case, so this also removes the need to manually call said function on every iteration of the main loop.

The downside is using a internal mutability for the main state and ram_base variable, however they are not publicly accessible so this should not raise many concerns.

async fn main() {
    loop {
        let emulator = ps1::Emulator::wait_attach().await;
        emulator.until_closes(async {
            loop {
                // TODO: Do something on every tick.
               next_tick().await;
            }
        }).await;
    }
}

This commit adds support for `future` when coding autosplitters for emulators, allowing to code similarly compared to native pc games.
The internal `update()` function gets called automatically in this case, so this also removes the need to manually call said function on every iteration of the main loop.
The downside is using a internal mutability for the main `state` and `ram_base` variable, however they are not publicly accessible so this should not raise many concerns.

```rust
async fn main() {
    loop {
        let emulator = ps1::Emulator::wait_attach().await;
        emulator.until_closes(async {
            loop {
                // TODO: Do something on every tick.
               next_tick().await;
            }
        }).await;
    }
}
```
@CryZe CryZe merged commit 53d629d into LiveSplit:master Jan 20, 2024
4 checks passed
@CryZe CryZe added the enhancement New feature or request label Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants