diff options
author | Revo <projectrevotpp@hotmail.com> | 2021-07-22 20:46:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-22 20:46:10 -0400 |
commit | b5b9e57dcb55ee1a69ca86c30e90475bb80e3c28 (patch) | |
tree | 2e91e60bdb7a9174b16d8ca1b532809d4ae2e5b6 /arm9/lib/NitroSDK/include/GX_g2.h | |
parent | c2d91a2d997afd01fa4f40e1e16d5ee85557c9a8 (diff) | |
parent | 5bf13c7f48fe91c7902ce50250bc1a5a2398a2ae (diff) |
Merge pull request #435 from red031000/master
separate out libs to libc, libnns and NitroSDK
Diffstat (limited to 'arm9/lib/NitroSDK/include/GX_g2.h')
-rw-r--r-- | arm9/lib/NitroSDK/include/GX_g2.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/arm9/lib/NitroSDK/include/GX_g2.h b/arm9/lib/NitroSDK/include/GX_g2.h new file mode 100644 index 00000000..97fa0e10 --- /dev/null +++ b/arm9/lib/NitroSDK/include/GX_g2.h @@ -0,0 +1,126 @@ +#ifndef GUARD_GX_G2_H +#define GUARD_GX_G2_H + +#include "fx.h" +#include "registers.h" + +void G2x_SetBGyAffine_(u32 ptr, const struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d); +void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d); +void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness); +void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness); +void G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness); + +typedef struct +{ + u8 planeMask:5; + u8 effect:1; + u8 _reserve:2; +} + GXWndPlane; + +typedef enum +{ + GX_WND_PLANEMASK_NONE = 0x0000, + GX_WND_PLANEMASK_BG0 = 0x0001, + GX_WND_PLANEMASK_BG1 = 0x0002, + GX_WND_PLANEMASK_BG2 = 0x0004, + GX_WND_PLANEMASK_BG3 = 0x0008, + GX_WND_PLANEMASK_OBJ = 0x0010 +} + GXWndPlaneMask; + +static inline void G2_SetWndOutsidePlane(int wnd, BOOL effect) +{ + u32 tmp; + + tmp = ((reg_G2_WINOUT & ~REG_G2_WINOUT_WINOUT_MASK) | ((u32)wnd << REG_G2_WINOUT_WINOUT_SHIFT)); + + if (effect) + { + tmp |= (0x20 << REG_G2_WINOUT_WINOUT_SHIFT); // EFCT + } + + reg_G2_WINOUT = (u16)tmp; +} + +static inline void G2_SetBG0Offset(int hOffset, int vOffset) +{ + reg_G2_BG0OFS = (u32)(((hOffset << REG_G2_BG0OFS_HOFFSET_SHIFT) & REG_G2_BG0OFS_HOFFSET_MASK) | + ((vOffset << REG_G2_BG0OFS_VOFFSET_SHIFT) & REG_G2_BG0OFS_VOFFSET_MASK)); +} + +static inline void G2_SetBG1Offset(int hOffset, int vOffset) +{ + reg_G2_BG1OFS = (u32)(((hOffset << REG_G2_BG1OFS_HOFFSET_SHIFT) & REG_G2_BG1OFS_HOFFSET_MASK) | + ((vOffset << REG_G2_BG1OFS_VOFFSET_SHIFT) & REG_G2_BG1OFS_VOFFSET_MASK)); +} + +static inline void G2_SetBG2Offset(int hOffset, int vOffset) +{ + reg_G2_BG2OFS = (u32)(((hOffset << REG_G2_BG2OFS_HOFFSET_SHIFT) & REG_G2_BG2OFS_HOFFSET_MASK) | + ((vOffset << REG_G2_BG2OFS_VOFFSET_SHIFT) & REG_G2_BG2OFS_VOFFSET_MASK)); +} + +static inline void G2_SetBG3Offset(int hOffset, int vOffset) +{ + reg_G2_BG3OFS = (u32)(((hOffset << REG_G2_BG3OFS_HOFFSET_SHIFT) & REG_G2_BG3OFS_HOFFSET_MASK) | + ((vOffset << REG_G2_BG3OFS_VOFFSET_SHIFT) & REG_G2_BG3OFS_VOFFSET_MASK)); +} + +static inline void G2S_SetBG0Offset(int hOffset, int vOffset) +{ + reg_G2S_DB_BG0OFS = (u32)(((hOffset << REG_G2S_DB_BG0OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_HOFFSET_MASK) | + ((vOffset << REG_G2S_DB_BG0OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_VOFFSET_MASK)); +} + +static inline void G2S_SetBG1Offset(int hOffset, int vOffset) +{ + reg_G2S_DB_BG1OFS = (u32)(((hOffset << REG_G2S_DB_BG1OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_HOFFSET_MASK) | + ((vOffset << REG_G2S_DB_BG1OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_VOFFSET_MASK)); +} + +static inline void G2S_SetBG2Offset(int hOffset, int vOffset) +{ + reg_G2S_DB_BG2OFS = (u32)(((hOffset << REG_G2S_DB_BG2OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_HOFFSET_MASK) | + ((vOffset << REG_G2S_DB_BG2OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_VOFFSET_MASK)); +} + +static inline void G2S_SetBG3Offset(int hOffset, int vOffset) +{ + reg_G2S_DB_BG3OFS = (u32)(((hOffset << REG_G2S_DB_BG3OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_HOFFSET_MASK) | + ((vOffset << REG_G2S_DB_BG3OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_VOFFSET_MASK)); +} + +static inline void G2_SetBG2Affine(const struct Mtx22 *mtx, int centerX, int centerY, int x1, int y1) +{ + G2x_SetBGyAffine_((u32)®_G2_BG2PA, mtx, centerX, centerY, x1, y1); +} + +static inline void G2_SetBG3Affine(const struct Mtx22 *mtx, int centerX, int centerY, int x1, int y1) +{ + G2x_SetBGyAffine_((u32)®_G2_BG3PA, mtx, centerX, centerY, x1, y1); +} + +static inline void G2S_SetBG2Affine(const struct Mtx22 *mtx, int centerX, int centerY, int x1, int y1) +{ + G2x_SetBGyAffine_((u32)®_G2S_DB_BG2PA, mtx, centerX, centerY, x1, y1); +} + +static inline void G2S_SetBG3Affine(const struct Mtx22 *mtx, int centerX, int centerY, int x1, int y1) +{ + G2x_SetBGyAffine_((u32)®_G2S_DB_BG3PA, mtx, centerX, centerY, x1, y1); +} + +static inline void G2_BlendNone(void) +{ + reg_G2_BLDCNT = 0; +} + +static inline void G2S_BlendNone(void) +{ + reg_G2S_DB_BLDCNT = 0; +} + +//The g2 and g2_oam headers contain a lot of inline functions and enums that may want to be ported over at some point + +#endif //GUARD_GX_G2_H |