BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
BrawlLib.Internal.ByteExtension Class Reference

Static Public Member Functions

static byte GetUpper (this byte b)
 
static void SetUpper (ref this byte b, byte value)
 
static byte GetLower (this byte b)
 
static void SetLower (ref this byte b, byte value)
 
static int CompareBits (this byte b1, byte b2)
 
static int CountBits (this byte b)
 
static byte Clamp (this byte value, byte min, byte max)
 
static sbyte Clamp (this sbyte value, sbyte min, sbyte max)
 

Member Function Documentation

◆ Clamp() [1/2]

static byte BrawlLib.Internal.ByteExtension.Clamp ( this byte  value,
byte  min,
byte  max 
)
inlinestatic
53 {
54 return value <= min ? min : value >= max ? max : value;
55 }

◆ Clamp() [2/2]

static sbyte BrawlLib.Internal.ByteExtension.Clamp ( this sbyte  value,
sbyte  min,
sbyte  max 
)
inlinestatic
58 {
59 return value <= min ? min : value >= max ? max : value;
60 }

◆ CompareBits()

static int BrawlLib.Internal.ByteExtension.CompareBits ( this byte  b1,
byte  b2 
)
inlinestatic
26 {
27 for (int i = 8, b = 0x80; i-- != 0; b >>= 1)
28 {
29 if ((b1 & b) != (b2 & b))
30 {
31 return i;
32 }
33 }
34
35 return 0;
36 }

◆ CountBits()

static int BrawlLib.Internal.ByteExtension.CountBits ( this byte  b)
inlinestatic
39 {
40 int count = 0;
41 for (int i = 0; i < 8; i++)
42 {
43 if (((b >> i) & 1) != 0)
44 {
45 count++;
46 }
47 }
48
49 return count;
50 }

◆ GetLower()

static byte BrawlLib.Internal.ByteExtension.GetLower ( this byte  b)
inlinestatic
16 {
17 return (byte) (b & 0x0F);
18 }

◆ GetUpper()

static byte BrawlLib.Internal.ByteExtension.GetUpper ( this byte  b)
inlinestatic
6 {
7 return (byte) ((b & 0xF0) / 0x10);
8 }

◆ SetLower()

static void BrawlLib.Internal.ByteExtension.SetLower ( ref this byte  b,
byte  value 
)
inlinestatic
21 {
22 b = (byte)(value + b.GetUpper() * 0x10);
23 }

◆ SetUpper()

static void BrawlLib.Internal.ByteExtension.SetUpper ( ref this byte  b,
byte  value 
)
inlinestatic
11 {
12 b = (byte)(value * 0x10 + b.GetLower());
13 }

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