Two hot-path optimizations for the device's Cortex-M7 (and debug simulator
builds):
- The ten sub-API pointers are cached once in Playdate.initialize(with:);
wrapper accessors now return UnsafePointer and call sites read a single
field through it, instead of unwrapping the optional API struct and
copying a whole sub-API struct of function pointers on every call.
Nested sub-APIs (sound classes, effects, video, tilemap, http/tcp)
derive from the cached pointers with one field load.
- String -> C conversions (withPlaydateCString, and a new withPlaydateUTF8
used by the text drawing/measuring APIs) use withUnsafeTemporaryAllocation
instead of building a ContiguousArray, so logging and drawText in the
update loop no longer heap-allocate per call. Verified within the
Embedded Swift subset by the device cross-compile.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Callback-based sound sources are kept alive in a static registry while the
C side may still invoke their trampoline, but nothing ever removed them:
every callback source leaked its wrapper and closure permanently, and a
source retained only by a transient Channel.default wrapper relied on that
leak for safety. The registry is now the single source of truth and is
purged on Sound.removeSource, Channel.removeSource, and when an owned
channel is freed (its sources can no longer be pulled).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- DocC catalog (Sources/PlayDate/PlayDate.docc) with a curated landing
page and a Getting Started article; swift-docc-plugin wired up for
`swift package generate-documentation`, and a GitHub Pages deployment
workflow renders docs on every push to main.
- Examples/HelloPlaydate: a minimal game (bouncing box, crank needle,
button handling, system menu item) whose build.sh compiles the game as
a dylib and produces a runnable simulator .pdx via the SDK's pdc.
Verified: the pdx builds and exports the eventHandler entry point.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
System, Display, Graphics, Sprite, Sound, File, JSON, Lua, Scoreboards,
Network, Rect, SystemEvent, and AccessReply now live at module scope
instead of being nested in the Playdate enum; consumers write
System.log(...) instead of Playdate.System.log(...), and can qualify with
the module name (PlayDate.System) on collision. The Playdate enum remains
only as the raw C API bootstrap (initialize(with:), api, apiPointer), and
Playdate.Error is renamed PlaydateError so no top-level type shadows
Swift.Error.
Breaking change for any existing consumers.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Wraps all ten subsystems of the Playdate SDK 3.1.1 C API (system, display,
graphics, sprites, sound, file, JSON, Lua, scoreboards, network) in
idiomatic Swift: namespaced APIs, wrapper types with ownership semantics,
closures for callbacks, and typed throws. Written within the Embedded Swift
subset so the same code can target the device.
The SDK headers are resolved through a "playdate" pkg-config module
(Scripts/install-pkgconfig.sh), so the package works as a normal SwiftPM
dependency without unsafe build flags.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>