diff --git a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
index abd6fd5..210d54e 100644
--- a/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
+++ b/crates/servicepoint_binding_cs/ServicePoint/BindGen/ServicePoint.g.cs
@@ -19,224 +19,6 @@ namespace ServicePoint.BindGen
public const nuint SP_TILE_HEIGHT = 20;
- ///
- /// Creates a new [SPBitVec] instance.
- ///
- /// # Arguments
- ///
- /// - `size`: size in bits.
- ///
- /// returns: [SPBitVec] with all bits set to false. Will never return NULL.
- ///
- /// # Panics
- ///
- /// - when `size` is not divisible by 8.
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - the returned instance is freed in some way, either by using a consuming function or
- /// by explicitly calling `sp_bitvec_free`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern BitVec* sp_bitvec_new(nuint size);
-
- ///
- /// Interpret the data as a series of bits and load then into a new [SPBitVec] instance.
- ///
- /// returns: [SPBitVec] instance containing data. Will never return NULL.
- ///
- /// # Panics
- ///
- /// - when `data` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `data` points to a valid memory location of at least `data_length`
- /// bytes in size.
- /// - the returned instance is freed in some way, either by using a consuming function or
- /// by explicitly calling `sp_bitvec_free`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern BitVec* sp_bitvec_load(byte* data, nuint data_length);
-
- ///
- /// Clones a [SPBitVec].
- ///
- /// returns: new [SPBitVec] instance. Will never return NULL.
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - `bit_vec` is not written to concurrently
- /// - the returned instance is freed in some way, either by using a consuming function or
- /// by explicitly calling `sp_bitvec_free`.
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern BitVec* sp_bitvec_clone(BitVec* bit_vec);
-
- ///
- /// Deallocates a [SPBitVec].
- ///
- /// # Panics
- ///
- /// - when `but_vec` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - `bit_vec` is not used concurrently or after this call
- /// - `bit_vec` was not passed to another consuming function, e.g. to create a [SPCommand]
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern void sp_bitvec_free(BitVec* bit_vec);
-
- ///
- /// Gets the value of a bit from the [SPBitVec].
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to read from
- /// - `index`: the bit index to read
- ///
- /// returns: value of the bit
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- /// - when accessing `index` out of bounds
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - `bit_vec` is not written to concurrently
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- [return: MarshalAs(UnmanagedType.U1)]
- public static extern bool sp_bitvec_get(BitVec* bit_vec, nuint index);
-
- ///
- /// Sets the value of a bit in the [SPBitVec].
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to write to
- /// - `index`: the bit index to edit
- /// - `value`: the value to set the bit to
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- /// - when accessing `index` out of bounds
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - `bit_vec` is not written to or read from concurrently
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern void sp_bitvec_set(BitVec* bit_vec, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
-
- ///
- /// Sets the value of all bits in the [SPBitVec].
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to write to
- /// - `value`: the value to set all bits to
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - `bit_vec` is not written to or read from concurrently
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern void sp_bitvec_fill(BitVec* bit_vec, [MarshalAs(UnmanagedType.U1)] bool value);
-
- ///
- /// Gets the length of the [SPBitVec] in bits.
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to write to
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern nuint sp_bitvec_len(BitVec* bit_vec);
-
- ///
- /// Returns true if length is 0.
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to write to
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- ///
- /// # Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- [return: MarshalAs(UnmanagedType.U1)]
- public static extern bool sp_bitvec_is_empty(BitVec* bit_vec);
-
- ///
- /// Gets an unsafe reference to the data of the [SPBitVec] instance.
- ///
- /// # Arguments
- ///
- /// - `bit_vec`: instance to write to
- ///
- /// # Panics
- ///
- /// - when `bit_vec` is NULL
- ///
- /// ## Safety
- ///
- /// The caller has to make sure that:
- ///
- /// - `bit_vec` points to a valid [SPBitVec]
- /// - the returned memory range is never accessed after the passed [SPBitVec] has been freed
- /// - the returned memory range is never accessed concurrently, either via the [SPBitVec] or directly
- ///
- [DllImport(__DllName, EntryPoint = "sp_bitvec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
- public static extern ByteSlice sp_bitvec_unsafe_data_ref(BitVec* bit_vec);
-
///
/// Creates a new instance of [SPConnection].
///
@@ -1391,12 +1173,225 @@ namespace ServicePoint.BindGen
[DllImport(__DllName, EntryPoint = "sp_cp437_grid_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ByteSlice sp_cp437_grid_unsafe_data_ref(Cp437Grid* cp437_grid);
+ ///
+ /// Creates a new [SPBitVec] instance.
+ ///
+ /// # Arguments
+ ///
+ /// - `size`: size in bits.
+ ///
+ /// returns: [SPBitVec] with all bits set to false. Will never return NULL.
+ ///
+ /// # Panics
+ ///
+ /// - when `size` is not divisible by 8.
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - the returned instance is freed in some way, either by using a consuming function or
+ /// by explicitly calling `sp_bitvec_free`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern BitVec* sp_bitvec_new(nuint size);
+
+ ///
+ /// Interpret the data as a series of bits and load then into a new [SPBitVec] instance.
+ ///
+ /// returns: [SPBitVec] instance containing data. Will never return NULL.
+ ///
+ /// # Panics
+ ///
+ /// - when `data` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `data` points to a valid memory location of at least `data_length`
+ /// bytes in size.
+ /// - the returned instance is freed in some way, either by using a consuming function or
+ /// by explicitly calling `sp_bitvec_free`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern BitVec* sp_bitvec_load(byte* data, nuint data_length);
+
+ ///
+ /// Clones a [SPBitVec].
+ ///
+ /// returns: new [SPBitVec] instance. Will never return NULL.
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - `bit_vec` is not written to concurrently
+ /// - the returned instance is freed in some way, either by using a consuming function or
+ /// by explicitly calling `sp_bitvec_free`.
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_clone", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern BitVec* sp_bitvec_clone(BitVec* bit_vec);
+
+ ///
+ /// Deallocates a [SPBitVec].
+ ///
+ /// # Panics
+ ///
+ /// - when `but_vec` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - `bit_vec` is not used concurrently or after this call
+ /// - `bit_vec` was not passed to another consuming function, e.g. to create a [SPCommand]
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_bitvec_free(BitVec* bit_vec);
+
+ ///
+ /// Gets the value of a bit from the [SPBitVec].
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to read from
+ /// - `index`: the bit index to read
+ ///
+ /// returns: value of the bit
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ /// - when accessing `index` out of bounds
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - `bit_vec` is not written to concurrently
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_get", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ public static extern bool sp_bitvec_get(BitVec* bit_vec, nuint index);
+
+ ///
+ /// Sets the value of a bit in the [SPBitVec].
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to write to
+ /// - `index`: the bit index to edit
+ /// - `value`: the value to set the bit to
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ /// - when accessing `index` out of bounds
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - `bit_vec` is not written to or read from concurrently
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_set", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_bitvec_set(BitVec* bit_vec, nuint index, [MarshalAs(UnmanagedType.U1)] bool value);
+
+ ///
+ /// Sets the value of all bits in the [SPBitVec].
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to write to
+ /// - `value`: the value to set all bits to
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - `bit_vec` is not written to or read from concurrently
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_fill", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern void sp_bitvec_fill(BitVec* bit_vec, [MarshalAs(UnmanagedType.U1)] bool value);
+
+ ///
+ /// Gets the length of the [SPBitVec] in bits.
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to write to
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_len", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern nuint sp_bitvec_len(BitVec* bit_vec);
+
+ ///
+ /// Returns true if length is 0.
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to write to
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ ///
+ /// # Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_is_empty", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ [return: MarshalAs(UnmanagedType.U1)]
+ public static extern bool sp_bitvec_is_empty(BitVec* bit_vec);
+
+ ///
+ /// Gets an unsafe reference to the data of the [SPBitVec] instance.
+ ///
+ /// # Arguments
+ ///
+ /// - `bit_vec`: instance to write to
+ ///
+ /// # Panics
+ ///
+ /// - when `bit_vec` is NULL
+ ///
+ /// ## Safety
+ ///
+ /// The caller has to make sure that:
+ ///
+ /// - `bit_vec` points to a valid [SPBitVec]
+ /// - the returned memory range is never accessed after the passed [SPBitVec] has been freed
+ /// - the returned memory range is never accessed concurrently, either via the [SPBitVec] or directly
+ ///
+ [DllImport(__DllName, EntryPoint = "sp_bitvec_unsafe_data_ref", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
+ public static extern ByteSlice sp_bitvec_unsafe_data_ref(BitVec* bit_vec);
- }
- [StructLayout(LayoutKind.Sequential)]
- public unsafe partial struct BitVec
- {
}
[StructLayout(LayoutKind.Sequential)]
@@ -1436,6 +1431,11 @@ namespace ServicePoint.BindGen
{
}
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe partial struct BitVec
+ {
+ }
+
public enum CompressionCode : ushort
{
diff --git a/crates/servicepoint_binding_cs/ServicePoint/Constants.cs b/crates/servicepoint_binding_cs/ServicePoint/Constants.cs
index 9980f64..fea5c55 100644
--- a/crates/servicepoint_binding_cs/ServicePoint/Constants.cs
+++ b/crates/servicepoint_binding_cs/ServicePoint/Constants.cs
@@ -1,15 +1,17 @@
+using ServicePoint.BindGen;
+
namespace ServicePoint;
public static class Constants
{
/// size of a single tile in one dimension
- public const int TileSize = 8;
+ public const int TileSize = NativeMethods.SP_TILE_SIZE;
/// tile count in the x-direction
- public const int TileWidth = 56;
+ public const int TileWidth = NativeMethods.SP_TILE_WIDTH;
/// tile count in the y-direction
- public const int TileHeight = 20;
+ public const int TileHeight = NativeMethods.SP_TILE_SIZE;
/// screen width in pixels
public const int PixelWidth = TileWidth * TileSize;