all FX functions are now safe wrapped and I added the crate to the docs also it is added to the prelude

This commit is contained in:
ZennDev1337 2023-10-04 14:47:38 +02:00
parent 3f847e86a6
commit 522844499e
1272 changed files with 1371 additions and 61826 deletions

View file

@ -0,0 +1,53 @@
use core::ffi::{c_char, c_uchar, c_ulong};
use crate::library::progmem::Pstring;
pub trait DrawableString
where
Self: Sized,
{
fn draw(self);
}
impl DrawableString for &[u8] {
fn draw(self) {
unsafe {
arduboyfx_draw_string(self as *const [u8] as *const i8);
}
}
}
impl DrawableString for &str {
fn draw(self) {
unsafe {
arduboyfx_draw_string(self.as_bytes() as *const [u8] as *const i8);
}
}
}
impl<const N: usize> DrawableString for crate::heapless::String<N> {
fn draw(self) {
unsafe {
arduboyfx_draw_string(self.as_bytes() as *const [u8] as *const i8);
}
}
}
impl DrawableString for Pstring {
fn draw(self) {
unsafe {
arduboyfx_draw_string_buffer(self.pointer as *const u8);
}
}
}
impl DrawableString for u32 {
fn draw(self) {
unsafe {
arduboyfx_draw_string_fx(self);
}
}
}
extern "C" {
#[link_name = "arduboyfx_draw_string_fx"]
fn arduboyfx_draw_string_fx(address: c_ulong);
#[link_name = "arduboyfx_draw_string_buffer"]
fn arduboyfx_draw_string_buffer(buffer: *const c_uchar);
#[link_name = "arduboyfx_draw_string"]
fn arduboyfx_draw_string(cstr: *const c_char);
}