re-export constants from base lib
This commit is contained in:
parent
35cb42df48
commit
24ff341f9d
7 changed files with 98 additions and 92 deletions
|
@ -2,7 +2,6 @@
|
|||
|
||||
use std::ptr::NonNull;
|
||||
|
||||
#[repr(C)]
|
||||
/// Represents a span of memory (`&mut [u8]` ) as a struct usable by C code.
|
||||
///
|
||||
/// You should not create an instance of this type in your C code.
|
||||
|
@ -16,6 +15,7 @@ use std::ptr::NonNull;
|
|||
/// the function returning this type.
|
||||
/// - an instance of this created from C is never passed to a consuming function, as the rust code
|
||||
/// will try to free the memory of a potentially separate allocator.
|
||||
#[repr(C)]
|
||||
pub struct SPByteSlice {
|
||||
/// The start address of the memory
|
||||
pub start: NonNull<u8>,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//!
|
||||
//! prefix `sp_command_`
|
||||
|
||||
use crate::{SPBitVec, SPCompressionCode};
|
||||
use servicepoint::{BinaryOperation, BrightnessGrid, CharGrid, Cp437Grid, GlobalBrightnessCommand, Packet, TypedCommand};
|
||||
use crate::{SPBitVec};
|
||||
use servicepoint::{BinaryOperation, BrightnessGrid, CharGrid, CompressionCode, Cp437Grid, GlobalBrightnessCommand, Packet, TypedCommand};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
/// A low-level display command.
|
||||
|
@ -225,7 +225,7 @@ pub unsafe extern "C" fn sp_command_char_brightness(
|
|||
pub unsafe extern "C" fn sp_command_bitmap_linear(
|
||||
offset: usize,
|
||||
bit_vec: *mut SPBitVec,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
) -> *mut TypedCommand {
|
||||
unsafe {
|
||||
sp_command_bitmap_linear_internal(
|
||||
|
@ -266,7 +266,7 @@ pub unsafe extern "C" fn sp_command_bitmap_linear(
|
|||
pub unsafe extern "C" fn sp_command_bitmap_linear_and(
|
||||
offset: usize,
|
||||
bit_vec: *mut SPBitVec,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
) -> *mut TypedCommand {
|
||||
unsafe {
|
||||
sp_command_bitmap_linear_internal(
|
||||
|
@ -307,7 +307,7 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_and(
|
|||
pub unsafe extern "C" fn sp_command_bitmap_linear_or(
|
||||
offset: usize,
|
||||
bit_vec: *mut SPBitVec,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
) -> *mut TypedCommand {
|
||||
unsafe {
|
||||
sp_command_bitmap_linear_internal(
|
||||
|
@ -348,7 +348,7 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_or(
|
|||
pub unsafe extern "C" fn sp_command_bitmap_linear_xor(
|
||||
offset: usize,
|
||||
bit_vec: *mut SPBitVec,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
) -> *mut TypedCommand {
|
||||
unsafe {
|
||||
sp_command_bitmap_linear_internal(
|
||||
|
@ -364,7 +364,7 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_xor(
|
|||
unsafe fn sp_command_bitmap_linear_internal(
|
||||
offset: usize,
|
||||
bit_vec: *mut SPBitVec,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
operation: BinaryOperation,
|
||||
) -> *mut TypedCommand {
|
||||
assert!(!bit_vec.is_null());
|
||||
|
@ -480,7 +480,7 @@ pub unsafe extern "C" fn sp_command_bitmap_linear_win(
|
|||
x: usize,
|
||||
y: usize,
|
||||
bitmap: *mut servicepoint::Bitmap,
|
||||
compression: SPCompressionCode,
|
||||
compression: CompressionCode,
|
||||
) -> *mut TypedCommand {
|
||||
assert!(!bitmap.is_null());
|
||||
let bitmap = unsafe { *Box::from_raw(bitmap) };
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
//! re-exported constants for use in C
|
||||
|
||||
use servicepoint::CompressionCode;
|
||||
use std::time::Duration;
|
||||
|
||||
/// size of a single tile in one dimension
|
||||
pub const SP_TILE_SIZE: usize = 8;
|
||||
|
||||
/// Display tile count in the x-direction
|
||||
pub const SP_TILE_WIDTH: usize = 56;
|
||||
|
||||
/// Display tile count in the y-direction
|
||||
pub const SP_TILE_HEIGHT: usize = 20;
|
||||
|
||||
/// Display width in pixels
|
||||
pub const SP_PIXEL_WIDTH: usize = SP_TILE_WIDTH * SP_TILE_SIZE;
|
||||
|
||||
/// Display height in pixels
|
||||
pub const SP_PIXEL_HEIGHT: usize = SP_TILE_HEIGHT * SP_TILE_SIZE;
|
||||
|
||||
/// pixel count on whole screen
|
||||
pub const SP_PIXEL_COUNT: usize = SP_PIXEL_WIDTH * SP_PIXEL_HEIGHT;
|
||||
|
||||
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
|
||||
pub const SP_FRAME_PACING_MS: u128 = Duration::from_millis(30).as_millis();
|
||||
|
||||
/// Specifies the kind of compression to use.
|
||||
#[repr(u16)]
|
||||
pub enum SPCompressionCode {
|
||||
/// no compression
|
||||
Uncompressed = 0x0,
|
||||
/// compress using flate2 with zlib header
|
||||
Zlib = 0x677a,
|
||||
/// compress using bzip2
|
||||
Bzip2 = 0x627a,
|
||||
/// compress using lzma
|
||||
Lzma = 0x6c7a,
|
||||
/// compress using Zstandard
|
||||
Zstd = 0x7a73,
|
||||
}
|
||||
|
||||
impl TryFrom<SPCompressionCode> for CompressionCode {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: SPCompressionCode) -> Result<Self, Self::Error> {
|
||||
CompressionCode::try_from(value as u16).map_err(|_| ())
|
||||
}
|
||||
}
|
|
@ -32,7 +32,6 @@ pub use crate::byte_slice::*;
|
|||
pub use crate::char_grid::*;
|
||||
pub use crate::command::*;
|
||||
pub use crate::connection::*;
|
||||
pub use crate::constants::*;
|
||||
pub use crate::cp437_grid::*;
|
||||
pub use crate::packet::*;
|
||||
|
||||
|
@ -43,6 +42,11 @@ mod byte_slice;
|
|||
mod char_grid;
|
||||
mod command;
|
||||
mod connection;
|
||||
mod constants;
|
||||
mod cp437_grid;
|
||||
mod packet;
|
||||
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
|
||||
pub const SP_FRAME_PACING_MS: u128 = Duration::from_millis(30).as_millis();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue