3 releases

0.1.2 Feb 24, 2025
0.1.1 Feb 23, 2025
0.1.0 Feb 23, 2025

#932 in Hardware support

Download history 294/week @ 2025-02-19 92/week @ 2025-02-26

386 downloads per month

MIT OR GPL-3.0

19KB
66 lines

turbine

Rust wrapper for the Playdate C API.

Using

The first step is to tell Rust to build your program as a cdylib and staticlib. This will result in the target directory containing both a libmyproject.so and a libmyproject.a when building for the simulator, and a libmyproject.a when building for real hardware. Add this to your Cargo.toml:

[lib]
crate-type = ["cdylib", "staticlib"]

You then must tell Rust to disable unwinding, as arm-none-eabi doesn't support it, and I'm sure the simulator will freak out if you try, so put this in your Cargo.toml:

[profile.release]
panic = 'abort'

[profile.dev]
panic = 'abort'

Finally, you need to tell Rust to depend on turbine and panic-halt.

Again, in your Cargo.toml:

[dependencies]
panic-halt = "*"
turbine = "^0.1"

Now, put this in your src/lib.rs file:

#![no_std] // tell rust we don't want to import `std`, since Playdate doesn't support it
use turbine::playdate_main;

use panic_halt as _; // endlessly loop on panic.

#[playdate_main] // make this our update function
fn main(api: &mut turbine::core::PlaydateAPI) -> u8 {
    0
}

Building a PDX for your game

Once you've configured your project, you then need to compile it. You can do this using cargo-carbide, so install it with cargo install cargo-carbide. You then need to configure your package metadata to tell Playdate about your game. It should look something like this:

[package.metadata.playdate]
name = "Playdate Rust Example"
bundle_id = "com.example.playdate.game"
build_number = 1

You can then use cargo carbide build to compile it.

Dependencies

~0.2–2.4MB
~50K SLoC