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

Update to SDK 2.5.0 #363

Merged
merged 30 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a3b9d67
Update `sound` for SDK 2.5.0 (breaking changes 🚨)
boozook May 20, 2024
0a1698a
Automated build pre-built bindings for 2.5.0-beta.3 on Linux-X64 with…
boozook May 20, 2024
95ef54d
Automated build pre-built bindings for 2.5.0-beta.3 on Linux-X64 with…
boozook May 20, 2024
d775c9f
Automated build pre-built bindings for 2.5.0-beta.3 on macOS-ARM64 wi…
boozook May 20, 2024
76014f4
Automated build pre-built bindings for 2.5.0-beta.3 on macOS-ARM64 wi…
boozook May 20, 2024
6a5ea83
Automated build pre-built bindings for 2.5.0-beta.3 on Windows-X64 wi…
boozook May 20, 2024
8e7efb9
Automated build pre-built bindings for 2.5.0-beta.3 on Windows-X64 wi…
boozook May 20, 2024
a1e099f
CI: tests on beta only
boozook May 20, 2024
c41e34a
Automated bump sys crate version
boozook May 20, 2024
3ff7bb9
fix `gfx::set_draw_mode`
boozook May 20, 2024
58e13a7
Merge pull request #364 from boozook/api/sys/pre-build/main
boozook May 20, 2024
6265756
`sys`: fix min existing version
boozook May 20, 2024
87f96e9
fix crates versions
boozook May 20, 2024
638d79f
`sys`: fix min existing version (beta ⚠️)
boozook May 20, 2024
7659f21
CI: set missed `custom-url`
boozook May 20, 2024
22b1954
update SDK version in README
boozook May 20, 2024
98dfbce
fix `set_draw_mode`
boozook May 20, 2024
ef44b74
add `get_pixel` & `set_pixel`
boozook May 20, 2024
9e5b824
add table `info`
boozook May 20, 2024
715c081
CI: update minimal SDK version for tests
boozook May 20, 2024
b2a52c9
Automated build pre-built bindings for 2.5.0 on macOS-ARM64 with feat…
boozook May 24, 2024
e495836
Automated build pre-built bindings for 2.5.0 on macOS-ARM64 with feat…
boozook May 24, 2024
f9238eb
Automated build pre-built bindings for 2.5.0 on Linux-X64 with featur…
boozook May 24, 2024
cebcdf4
Automated build pre-built bindings for 2.5.0 on Linux-X64 with featur…
boozook May 24, 2024
69c4bd5
Automated build pre-built bindings for 2.5.0 on Windows-X64 with feat…
boozook May 24, 2024
aff44d8
Automated build pre-built bindings for 2.5.0 on Windows-X64 with feat…
boozook May 24, 2024
312b3ce
Automated bump sys crate version
boozook May 24, 2024
23bfaea
Merge pull request #365 from boozook/api/sys/pre-build/sdk/2.5.0
boozook May 24, 2024
9ea236c
remove legacy bindings, bump crate version, fix `SDK_VER_EXISTING`
boozook May 24, 2024
41c7245
CI: fix missed change - test with beta only beta
boozook May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
- 2.5.0
# - beta

steps:
- run: arch
Expand Down Expand Up @@ -158,7 +158,8 @@ jobs:
- ubuntu-latest
- windows-latest
sdk:
- latest
# - latest
- beta

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -186,6 +187,7 @@ jobs:
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
custom-url: ${{ matrix.sdk == 'beta' && ((runner.os == 'macOS' && secrets.SDK_BETA_MACOS) || (runner.os == 'Linux' && secrets.SDK_BETA_LINUX) || (runner.os == 'Windows' && secrets.SDK_BETA_WINDOWS)) || '' }}

- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
Expand All @@ -212,9 +214,9 @@ jobs:
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
- 2.5.0
# - beta

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -267,9 +269,9 @@ jobs:
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
- 2.5.0
# - beta

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -325,9 +327,9 @@ jobs:
os:
- macos-14
sdk:
# - beta
- latest
- 2.4.0
- 2.5.0
# - beta

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -392,9 +394,9 @@ jobs:
- ubuntu-latest
- windows-latest
sdk:
# - beta
- latest
- 2.4.0
- 2.5.0
# - beta

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ color = { version = "0.2", path = "api/color", package = "playdate-color", defau
ctrl = { version = "0.3", path = "api/ctrl", package = "playdate-controls", default-features = false }
display = { version = "0.3", path = "api/display", package = "playdate-display", default-features = false }
fs = { version = "0.2", path = "api/fs", package = "playdate-fs", default-features = false }
gfx = { version = "0.3", path = "api/gfx", package = "playdate-graphics", default-features = false }
gfx = { version = "0.4", path = "api/gfx", package = "playdate-graphics", default-features = false }
lua = { version = "0.1", path = "api/lua", package = "playdate-lua", default-features = false }
menu = { version = "0.2", path = "api/menu", package = "playdate-menu", default-features = false }
scoreboards = { version = "0.1", path = "api/scoreboards", package = "playdate-scoreboards", default-features = false }
sound = { version = "0.3", path = "api/sound", package = "playdate-sound", default-features = false }
sound = { version = "0.4", path = "api/sound", package = "playdate-sound", default-features = false }
sprite = { version = "0.2", path = "api/sprite", package = "playdate-sprite", default-features = false }
system = { version = "0.3", path = "api/system", package = "playdate-system", default-features = false }
sys = { version = "0.3", path = "api/sys", package = "playdate-sys", default-features = false }
sys = { version = "0.4", path = "api/sys", package = "playdate-sys", default-features = false }

tool = { version = "0.1", path = "support/tool", package = "playdate-tool" }
build = { version = "0.3", path = "support/build", package = "playdate-build", default-features = false }
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ Follow the instructions for:

## Compatibility

* __Minimal__ supported versions of Playdate SDK is `2.4.0` because of breaking changes in `2.4.0`.

* __Latest__ version of SDK is `2.4.0`.
* __Minimal__ supported versions of Playdate SDK is `2.5.0` because of breaking changes in `2.5.0`.



Expand Down
2 changes: 1 addition & 1 deletion api/gfx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-graphics"
version = "0.3.14"
version = "0.4.0"
readme = "README.md"
description = "High-level graphics API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand Down
18 changes: 16 additions & 2 deletions api/gfx/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl Api for Cache {
/// Equivalent to [`sys::ffi::playdate_graphics::setDrawMode`]
#[doc(alias = "sys::ffi::playdate_graphics::setDrawMode")]
#[inline(always)]
fn set_draw_mode(&self) -> unsafe extern "C" fn(mode: LCDBitmapDrawMode) {
fn set_draw_mode(&self) -> unsafe extern "C" fn(mode: LCDBitmapDrawMode) -> LCDBitmapDrawMode {
self.0.setDrawMode.expect("setDrawMode")
}

Expand Down Expand Up @@ -482,6 +482,13 @@ impl Api for Cache {
self.0.fillEllipse.expect("fillEllipse")
}

/// Equivalent to [`sys::ffi::playdate_graphics::setPixel`]
#[doc(alias = "sys::ffi::playdate_graphics::setPixel")]
#[inline(always)]
fn set_pixel(&self) -> unsafe extern "C" fn(x: c_int, y: c_int, c: LCDColor) {
self.0.setPixel.expect("setPixel")
}

/// Equivalent to [`sys::ffi::playdate_graphics::getFrame`]
#[doc(alias = "sys::ffi::playdate_graphics::getFrame")]
#[inline(always)]
Expand Down Expand Up @@ -578,7 +585,9 @@ pub trait Api: crate::bitmap::api::Api + crate::bitmap::table::api::Api + crate:
/// Equivalent to [`sys::ffi::playdate_graphics::setDrawMode`]
#[doc(alias = "sys::ffi::playdate_graphics::setDrawMode")]
#[inline(always)]
fn set_draw_mode(&self) -> unsafe extern "C" fn(mode: LCDBitmapDrawMode) { *sys::api!(graphics.setDrawMode) }
fn set_draw_mode(&self) -> unsafe extern "C" fn(mode: LCDBitmapDrawMode) -> LCDBitmapDrawMode {
*sys::api!(graphics.setDrawMode)
}

/// Equivalent to [`sys::ffi::playdate_graphics::setDrawOffset`]
#[doc(alias = "sys::ffi::playdate_graphics::setDrawOffset")]
Expand Down Expand Up @@ -677,6 +686,11 @@ pub trait Api: crate::bitmap::api::Api + crate::bitmap::table::api::Api + crate:
*sys::api!(graphics.fillEllipse)
}

/// Equivalent to [`sys::ffi::playdate_graphics::setPixel`]
#[doc(alias = "sys::ffi::playdate_graphics::setPixel")]
#[inline(always)]
fn set_pixel(&self) -> unsafe extern "C" fn(x: c_int, y: c_int, c: LCDColor) { *sys::api!(graphics.setPixel) }

/// Equivalent to [`sys::ffi::playdate_graphics::getFrame`]
#[doc(alias = "sys::ffi::playdate_graphics::getFrame")]
#[inline(always)]
Expand Down
9 changes: 9 additions & 0 deletions api/gfx/src/bitmap/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use sys::ffi::LCDColor;
use sys::ffi::LCDBitmap;
use sys::ffi::LCDBitmapFlip;
use sys::ffi::LCDRect;
use sys::ffi::LCDSolidColor;


/// Default graphics bitmap api end-point, ZST.
Expand Down Expand Up @@ -167,4 +168,12 @@ pub trait Api {
y: core::ffi::c_int) {
*sys::api!(graphics.setColorToPattern)
}


/// Equivalent to [`sys::ffi::playdate_graphics::getBitmapPixel`]
#[doc(alias = "sys::ffi::playdate_graphics::getBitmapPixel")]
#[inline(always)]
fn get_pixel(&self) -> unsafe extern "C" fn(bitmap: *mut LCDBitmap, x: c_int, y: c_int) -> LCDSolidColor {
*sys::api!(graphics.getBitmapPixel)
}
}
23 changes: 20 additions & 3 deletions api/gfx/src/bitmap/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use alloc::boxed::Box;

use sys::error::OkOrNullFnErr;
use sys::ffi::LCDPattern;
use sys::ffi::LCDSolidColor;
use sys::traits::AsRaw;
use sys::ffi::CString;
use sys::ffi::LCDColor;
Expand Down Expand Up @@ -512,6 +513,20 @@ impl<Api: api::Api, const FOD: bool> Bitmap<Api, FOD> {
let f = self.1.set_color_to_pattern();
unsafe { f(color as _, self.0, x, y) }
}

/// Gets the color of the pixel at `(x,y)` in this bitmap.
/// If the coordinate is outside the bounds of the bitmap,
/// or if the bitmap has a mask and the pixel is marked transparent,
/// the function returns [`Clear`][LCDSolidColor::kColorClear];
/// otherwise the return value is [`White`][LCDSolidColor::kColorWhite] or [`Black`][LCDSolidColor::kColorBlack].
///
/// Calls [`sys::ffi::playdate_graphics::getBitmapPixel`].
#[doc(alias = "sys::ffi::playdate_graphics::getBitmapPixel")]
#[inline(always)]
pub fn pixel_at(&self, x: c_int, y: c_int) -> LCDSolidColor {
let f = self.1.get_pixel();
unsafe { f(self.0, x, y) }
}
}


Expand Down Expand Up @@ -666,7 +681,7 @@ pub fn set_stencil(image: &impl AnyBitmap) { Graphics::Default().set_stencil(ima
/// Equivalent to [`sys::ffi::playdate_graphics::setDrawMode`].
#[doc(alias = "sys::ffi::playdate_graphics::setDrawMode")]
#[inline(always)]
pub fn set_draw_mode(mode: BitmapDrawMode) { Graphics::Default().set_draw_mode(mode) }
pub fn set_draw_mode(mode: BitmapDrawMode) -> BitmapDrawMode { Graphics::Default().set_draw_mode(mode) }

/// Push a new drawing context for drawing into the given bitmap.
///
Expand Down Expand Up @@ -785,13 +800,15 @@ impl<Api: crate::api::Api> Graphics<Api> {

/// Sets the mode used for drawing bitmaps.
///
/// Returns the previous draw mode.
///
/// Note that text drawing uses bitmaps, so this affects how fonts are displayed as well.
///
/// Equivalent to [`sys::ffi::playdate_graphics::setDrawMode`].
#[doc(alias = "sys::ffi::playdate_graphics::setDrawMode")]
pub fn set_draw_mode(&self, mode: BitmapDrawMode) {
pub fn set_draw_mode(&self, mode: BitmapDrawMode) -> BitmapDrawMode {
let f = self.0.set_draw_mode();
unsafe { f(mode) };
unsafe { f(mode) }
}

/// Push a new drawing context for drawing into the given bitmap.
Expand Down
25 changes: 25 additions & 0 deletions api/gfx/src/bitmap/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ impl<Api: api::Api, const FOD: bool> BitmapTable<Api, FOD> {
Some(Bitmap(ptr, api))
}
}

/// Returns the bitmap table’s image count in the `count` if not `None`
/// and number of cells across in the `width` (ditto) if not `None` .
///
/// Equivalent to [`sys::ffi::playdate_graphics::getTableBitmap`].
#[doc(alias = "sys::ffi::playdate_graphics::getTableBitmap")]
pub fn info<'table, BitApi: BitmapApi>(&'table self, count: Option<&mut c_int>, width: Option<&mut c_int>) {
let f = self.1.get_bitmap_table_info();
unsafe {
use core::ptr::null_mut;
f(
self.0,
count.map_or(null_mut() as _, |v| v as *mut _),
width.map_or(null_mut() as _, |v| v as *mut _),
)
}
}
}


Expand Down Expand Up @@ -213,5 +230,13 @@ pub mod api {
-> unsafe extern "C" fn(table: *mut LCDBitmapTable, idx: c_int) -> *mut LCDBitmap {
*sys::api!(graphics.getTableBitmap)
}

/// Equivalent to [`sys::ffi::playdate_graphics::getBitmapTableInfo`]
#[doc(alias = "sys::ffi::playdate_graphics::getBitmapTableInfo")]
fn get_bitmap_table_info(
&self)
-> unsafe extern "C" fn(table: *mut LCDBitmapTable, count: *mut c_int, width: *mut c_int) {
*sys::api!(graphics.getBitmapTableInfo)
}
}
}
20 changes: 20 additions & 0 deletions api/gfx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@ impl<Api: api::Api> Graphics<Api> {
}

impl<Api: api::Api> Graphics<Api> {
/// Sets the pixel at `(x,y)` in the current drawing context (by default the screen) to the given `color`.
/// Be aware that setting a pixel at a time is not very efficient:
/// In our testing, more than around 20,000 calls in a tight loop will drop the frame rate below 30 fps.
///
/// Equivalent to [`sys::ffi::playdate_graphics::setPixel`]
#[doc(alias = "sys::ffi::playdate_graphics::setPixel")]
#[inline(always)]
pub fn set_pixel(&self, x: c_int, y: c_int, color: color::Color) { self.set_pixel_raw(x, y, color.into()) }

/// Same as [`set_pixel`][Graphics::set_pixel], but without conversion [`Color`][color::Color] -> [`LCDColor`].
///
/// Equivalent to [`sys::ffi::playdate_graphics::setPixel`]
#[doc(alias = "sys::ffi::playdate_graphics::setPixel")]
#[inline(always)]
pub fn set_pixel_raw(&self, x: c_int, y: c_int, color: LCDColor) {
let f = self.0.set_pixel();
unsafe { f(x, y, color) }
}


/// Returns the current display frame buffer.
/// Rows are 32-bit aligned, so the row stride is 52 bytes, with the extra 2 bytes per row ignored.
/// Bytes are MSB-ordered; i.e., the pixel in column 0 is the 0x80 bit of the first byte of the row.
Expand Down
2 changes: 1 addition & 1 deletion api/sound/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sound"
version = "0.3.0"
version = "0.4.0"
readme = "README.md"
description = "High-level sound API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand Down
8 changes: 5 additions & 3 deletions api/sound/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<Api: api::Api> Sample<Api> {
sample_rate: u32)
-> Result<SampleWithData<'t, Api>, Error> {
let f = api.new_sample_from_data();
let ptr = unsafe { f(data.as_mut_ptr(), format, sample_rate, data.len() as _) };
let ptr = unsafe { f(data.as_mut_ptr(), format, sample_rate, data.len() as _, 0) };

if ptr.is_null() {
Err(Error::Alloc)
Expand Down Expand Up @@ -276,7 +276,8 @@ pub mod api {
-> unsafe extern "C" fn(data: *mut u8,
format: SoundFormat,
sampleRate: u32,
byteCount: c_int) -> *mut AudioSample {
byteCount: c_int,
shouldFreeData: c_int) -> *mut AudioSample {
self.0.newSampleFromData.expect("newSampleFromData")
}

Expand Down Expand Up @@ -329,7 +330,8 @@ pub mod api {
-> unsafe extern "C" fn(data: *mut u8,
format: SoundFormat,
sampleRate: u32,
byteCount: c_int) -> *mut AudioSample {
byteCount: c_int,
shouldFreeData: c_int) -> *mut AudioSample {
*sys::api!(sound.sample.newSampleFromData)
}

Expand Down
2 changes: 1 addition & 1 deletion api/sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-sys"
version = "0.3.7"
version = "0.4.0"
build = "src/build.rs"
readme = "README.md"
description = "Low-level Playdate API bindings"
Expand Down
Loading
Loading