RedCore
Loading...
Searching...
No Matches
red::SpriteUtil Class Reference

#include <SpriteUtil.h>

Inherits Actor.

Static Public Member Functions

static u8 getNybble1 (Actor *target)
static u8 getNybble2 (Actor *target)
static u8 getNybble3 (Actor *target)
static u8 getNybble4 (Actor *target)
static u8 getNybble5 (Actor *target)
static u8 getNybble6 (Actor *target)
static u8 getNybble7 (Actor *target)
static u8 getNybble8 (Actor *target)
static u8 getNybble9 (Actor *target)
static u8 getNybble10 (Actor *target)
static u8 getNybble11 (Actor *target)
static u8 getNybble12 (Actor *target)
static u8 getNybble13 (Actor *target)
static u8 getNybble14 (Actor *target)
static u8 getNybble15 (Actor *target)
static u8 getNybble16 (Actor *target)
static u8 getNybble17 (Actor *target)
static u8 getNybble18 (Actor *target)
static u8 getNybble19 (Actor *target)
static u8 getNybble20 (Actor *target)
static u8 getNybble21 (Actor *target)
static u8 getNybble22 (Actor *target)
static u8 getNybble23 (Actor *target)
static u8 getNybble24 (Actor *target)
static u32 getNybbleRange (Actor *target, u8 from, u8 end)
 Extract the combined value of a range of up to 8 sequential nybbles from the given actor's full 24 nybbles of spritedata.
static u32 getBitRange (const Actor *target, u8 from, u8 end)
 Extract the value of an arbitrary 32-bit range of bits from the given actor's full 96 bits of spritedata which make up all nybbles 1-24. Bit layout cheatsheet: nybbles 1-4 (bits 0-15), nybbles 5-12 (bits 16-47), nybbles 13-20 (bits 48-79), nybbles 21-24 (bits 80-96)
template<u8 TFrom, u8 TEnd, s32 TOutBytes>
static void getBitRange (const Actor *target, u8(&out)[TOutBytes])
 Extract a compile-time defined range of bits (up to 96) from the given actor's spritedata. Bit layout cheatsheet: nybbles 1-4 (bits 0-15), nybbles 5-12 (bits 16-47), nybbles 13-20 (bits 48-79), nybbles 21-24 (bits 80-96)

Member Function Documentation

◆ getNybble1()

u8 red::SpriteUtil::getNybble1 ( Actor * target)
inlinestaticnodiscard

◆ getNybble2()

u8 red::SpriteUtil::getNybble2 ( Actor * target)
inlinestaticnodiscard

◆ getNybble3()

u8 red::SpriteUtil::getNybble3 ( Actor * target)
inlinestaticnodiscard

◆ getNybble4()

u8 red::SpriteUtil::getNybble4 ( Actor * target)
inlinestaticnodiscard

◆ getNybble5()

u8 red::SpriteUtil::getNybble5 ( Actor * target)
inlinestaticnodiscard

◆ getNybble6()

u8 red::SpriteUtil::getNybble6 ( Actor * target)
inlinestaticnodiscard

◆ getNybble7()

u8 red::SpriteUtil::getNybble7 ( Actor * target)
inlinestaticnodiscard

◆ getNybble8()

u8 red::SpriteUtil::getNybble8 ( Actor * target)
inlinestaticnodiscard

◆ getNybble9()

u8 red::SpriteUtil::getNybble9 ( Actor * target)
inlinestaticnodiscard

◆ getNybble10()

u8 red::SpriteUtil::getNybble10 ( Actor * target)
inlinestaticnodiscard

◆ getNybble11()

u8 red::SpriteUtil::getNybble11 ( Actor * target)
inlinestaticnodiscard

◆ getNybble12()

u8 red::SpriteUtil::getNybble12 ( Actor * target)
inlinestaticnodiscard

◆ getNybble13()

u8 red::SpriteUtil::getNybble13 ( Actor * target)
inlinestaticnodiscard

◆ getNybble14()

u8 red::SpriteUtil::getNybble14 ( Actor * target)
inlinestaticnodiscard

◆ getNybble15()

u8 red::SpriteUtil::getNybble15 ( Actor * target)
inlinestaticnodiscard

◆ getNybble16()

u8 red::SpriteUtil::getNybble16 ( Actor * target)
inlinestaticnodiscard

◆ getNybble17()

u8 red::SpriteUtil::getNybble17 ( Actor * target)
inlinestaticnodiscard

◆ getNybble18()

u8 red::SpriteUtil::getNybble18 ( Actor * target)
inlinestaticnodiscard

◆ getNybble19()

u8 red::SpriteUtil::getNybble19 ( Actor * target)
inlinestaticnodiscard

◆ getNybble20()

u8 red::SpriteUtil::getNybble20 ( Actor * target)
inlinestaticnodiscard

◆ getNybble21()

u8 red::SpriteUtil::getNybble21 ( Actor * target)
inlinestaticnodiscard

◆ getNybble22()

u8 red::SpriteUtil::getNybble22 ( Actor * target)
inlinestaticnodiscard

◆ getNybble23()

u8 red::SpriteUtil::getNybble23 ( Actor * target)
inlinestaticnodiscard

◆ getNybble24()

u8 red::SpriteUtil::getNybble24 ( Actor * target)
inlinestaticnodiscard

◆ getNybbleRange()

u32 red::SpriteUtil::getNybbleRange ( Actor * target,
u8 from,
u8 end )
inlinestaticnodiscard

Extract the combined value of a range of up to 8 sequential nybbles from the given actor's full 24 nybbles of spritedata.

Max. output is limited to a 32-bit value (8 nybbles) for performance, if the requested range exceeds 8 nybbles in size or is invalid, OSFatal is called. Use multiple getNybbleRange calls and manually combine their outputs for values greater than 32 bits.

Parameters
from1-indexed left-to-right inclusive nybble index to start the range at. (1-24)
end1-indexed left-to-right inclusive nybble index to end the range at. (1-24)

◆ getBitRange() [1/2]

u32 red::SpriteUtil::getBitRange ( const Actor * target,
u8 from,
u8 end )
inlinestaticnodiscard

Extract the value of an arbitrary 32-bit range of bits from the given actor's full 96 bits of spritedata which make up all nybbles 1-24. Bit layout cheatsheet: nybbles 1-4 (bits 0-15), nybbles 5-12 (bits 16-47), nybbles 13-20 (bits 48-79), nybbles 21-24 (bits 80-96)

Max. output is limited to a 32-bit value for performance, if the requested range exceeds 32 bits in size or is invalid, OSFatal is called. Use the other overload if you need to extract more than 32 bits.

Parameters
from0-indexed Big Endian (left-to-right) inclusive bit index to start the range at. (0-96)
end0-indexed Big Endian (left-to-right) exclusive bit index to end the range at. (0-96)

◆ getBitRange() [2/2]

template<u8 TFrom, u8 TEnd, s32 TOutBytes>
void red::SpriteUtil::getBitRange ( const Actor * target,
u8(&) out[TOutBytes] )
inlinestatic

Extract a compile-time defined range of bits (up to 96) from the given actor's spritedata. Bit layout cheatsheet: nybbles 1-4 (bits 0-15), nybbles 5-12 (bits 16-47), nybbles 13-20 (bits 48-79), nybbles 21-24 (bits 80-96)

The output is right-aligned in the provided buffer. All memory safety checks and bounds validations are resolved at compile-time. Fast/Slow paths are optimized statically.

Parameters
targetThe actor whose spritedata will be extracted.
outReference to a buffer where the extracted bits will be written (size deduced automatically).
Template Parameters
TFrom0-indexed Big Endian inclusive start bit index.
TEnd0-indexed Big Endian exclusive end bit index.
TOutBytesDeduced byte size of the provided output array.