turbine-pd

Crates.ioturbine-pd
lib.rsturbine-pd
version0.1.2
created_at2025-02-23 00:57:36.104186+00
updated_at2025-02-24 21:00:21.890774+00
descriptionRust wrapper for the Playdate C API
homepage
repositoryhttps://codeberg.org/badeline/turbine
max_upload_size
id1565961
size51,895
jade (certified eepy) (jadeiseepy)

documentation

README

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.

Commit count: 0

cargo fmt