Skip to main content

Crate shuyi_playdate

Crate shuyi_playdate 

Source
Expand description

Shuyi Engine’s Playdate backend (ADR-0008 §2, ADR-0062): the Platform on Panic’s SDK.

A game’s playdate feature names this crate, and its library says how it starts with main!; shuyi export playdate builds that library as a static library with --cfg shuyi_playdate_sdk, links it with shim/shim.c and the SDK’s setup.c, and packs the .pdx. The rest of the time the crate is the plain part, so the workspace’s host builds and tests never need the SDK:

  • sdk: the small trait of SDK calls the rest is written against, which the tests’ fake and the device’s real calls implement;
  • backend: Playdate, the Platform itself;
  • driver: Driver, the update callback’s body around App::frame;
  • input: the buttons and the crank; display: the frame buffer and its changed rows; storage: the game’s saves on the SDK’s files;
  • audio: the shared player’s backend, on the SDK’s sample and file players;
  • stack: the arithmetic of the game’s own stack, which every call from the SDK into the game runs on;
  • report: the run report a game may turn on, of its start and its speed, in the console.

Re-exports§

pub use backend::Playdate;
pub use driver::Driver;
pub use report::RunReport;

Modules§

audio
Speaker: the shared player’s Backend on the SDK’s sample players (sounds in memory, each playback a player of its own) and file players (music and voice clips streamed from the .pdx).
backend
Playdate: the Platform on the SDK (Sdk).
display
The frame on the Playdate’s screen: a game’s frame drawn with its one-bit look into a frame of our own (shuyi_ui::frame::onebit, redrawing only where it differs from the last), then the rows that differ from the SDK’s frame buffer copied into it and marked (markUpdatedRows). The loading card and the errors are the SDK’s text, in the system’s font.
driver
Driver: the body of the SDK’s update callback, around App::frame, with the backend’s device behind Sdk so the tests run all of it on the fake.
heap
The arithmetic of the allocator over the SDK’s realloc (crate::device).
input
The Playdate’s buttons and crank as the engine’s input: the SDK’s button bits are one controller of PadKind::Playdate, and the crank two more of its buttons, one press a notch. It only translates, as shuyi-app’s pads.rs does; the only file in this crate that names buttons.
report
RunReport: what a shipped game says in its console on every run, when it turns the report on (Driver::with_report): how its start went, and then how fast it runs, so a tester’s log shows a slow start or a stutter without a bench build.
sdk
Sdk: the calls of Panic’s SDK the backend is written against, small enough that a fake stands in for them in the tests (crate::fake) and crate::device puts them on the real SDK through shim/shim.c.
stack
The arithmetic of the game’s own stack (crate::device).
storage
The game’s Storage on the Playdate’s files: <key>.ron per key in the game’s data folder (Disk/Data/<bundle id>/ in the Simulator), kept as shuyi-app’s FileStorage keeps them (ticket 3045).
text
Text handed to the SDK, which takes C strings (NUL-terminated).

Macros§

main
The game’s entry points, for the crate shuyi export playdate builds: main!(start), with start a fn() -> Start<G>, or main!(start, stack_bytes = 128 * 1024) for a game’s own stack of another size than stack::DEFAULT_BYTES. report = RunReport::new() after either turns on the run report (report). Off the device it only checks they exist.

Functions§

pack
The game’s baked pack: off the device there is none.
stack_high_water
The bytes of the game’s stack it has ever used: on the device alone, since the Simulator runs on the computer’s stack.