BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
BrawlLib.Internal.Bin16 Struct Reference

Public Member Functions

 Bin16 (ushort val)
 
override string ToString ()
 

Static Public Member Functions

static implicit operator ushort (Bin16 val)
 
static implicit operator Bin16 (ushort val)
 
static Bin16 FromString (string s)
 

Public Attributes

bushort _data
 

Properties

bool this[int index] [get, set]
 
ushort this[int shift, int bitCount] [get, set]
 

Constructor & Destructor Documentation

◆ Bin16()

BrawlLib.Internal.Bin16.Bin16 ( ushort  val)
inline
240 {
241 _data = val;
242 }
bushort _data
Definition: BinaryHandlers.cs:237

Member Function Documentation

◆ FromString()

static Bin16 BrawlLib.Internal.Bin16.FromString ( string  s)
inlinestatic
319 {
320 char[] delims = new char[] {',', '(', ')', ' '};
321
322 ushort b = 0;
323 string[] arr = s.Split(delims, StringSplitOptions.RemoveEmptyEntries);
324
325 for (int len = 0; len < arr.Length; len++)
326 {
327 byte bit = 0;
328 for (int i = 0; i < arr[len].Length; i++)
329 {
330 b <<= 1;
331 byte.TryParse(arr[len][i].ToString(), out bit);
332 bit = bit.Clamp(0, 1);
333 b += bit;
334 }
335 }
336
337 return new Bin16(b);
338 }
override string ToString()
Definition: BinaryHandlers.cs:256
Bin16(ushort val)
Definition: BinaryHandlers.cs:239

◆ operator Bin16()

static implicit BrawlLib.Internal.Bin16.operator Bin16 ( ushort  val)
inlinestatic
250 {
251 return new Bin16(val);
252 }

◆ operator ushort()

static implicit BrawlLib.Internal.Bin16.operator ushort ( Bin16  val)
inlinestatic
245 {
246 return val._data;
247 }

◆ ToString()

override string BrawlLib.Internal.Bin16.ToString ( )
inline
257 {
258 int i = 0;
259 string val = "";
260 while (i++ < 16)
261 {
262 val += (_data >> (16 - i)) & 1;
263 if (i % 4 == 0 && i != 16)
264 {
265 val += " ";
266 }
267 }
268
269 return val;
270 }

Member Data Documentation

◆ _data

bushort BrawlLib.Internal.Bin16._data

Property Documentation

◆ this[int index]

bool BrawlLib.Internal.Bin16.this[int index]
getset
273 {
274 get => ((_data >> index) & 1) != 0;
275 set
276 {
277 if (value)
278 {
279 _data = (ushort) (_data | (ushort) (1 << index));
280 }
281 else
282 {
283 _data = (ushort) (_data & ~(ushort) (1 << index));
284 }
285 }
286 }

◆ this[int shift, int bitCount]

ushort BrawlLib.Internal.Bin16.this[int shift, int bitCount]
getset
295 {
296 get
297 {
298 int mask = 0;
299 for (int i = 0; i < bitCount; i++)
300 {
301 mask |= 1 << i;
302 }
303
304 return (ushort) ((_data >> shift) & mask);
305 }
306 set
307 {
308 int mask = 0;
309 for (int i = 0; i < bitCount; i++)
310 {
311 mask |= 1 << i;
312 }
313
314 _data = (ushort) ((_data & ~(mask << shift)) | ((value & mask) << shift));
315 }
316 }

The documentation for this struct was generated from the following file: