From 14a5ca7ae49912305b1bcbaa180cfc9fdf8ff17a Mon Sep 17 00:00:00 2001 From: Made Date: Fri, 15 May 2020 03:29:32 +0200 Subject: Decompile GX_g2.s --- arm9/lib/src/GX_g2.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 arm9/lib/src/GX_g2.c (limited to 'arm9/lib/src/GX_g2.c') diff --git a/arm9/lib/src/GX_g2.c b/arm9/lib/src/GX_g2.c new file mode 100644 index 00000000..7441e302 --- /dev/null +++ b/arm9/lib/src/GX_g2.c @@ -0,0 +1,66 @@ +#include "global.h" +#include "main.h" +#include "gx.h" + +void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d){ + fx32 temp0, temp1, temp2, temp3; + ptr[0] = ((u16)(fx16)(mtx->_[0] >> 4) | (u16)(fx16)(mtx->_[1] >> 4)<< 0x10); + ptr[1] = ((u16)(fx16)(mtx->_[2] >> 4) | (u16)(fx16)(mtx->_[3] >> 4)<< 0x10); + temp0 = c - a; + temp1 = d - b; + temp2 = mtx->_[0] * temp0 + mtx->_[1] * temp1 + (a << 0xC); + temp3 = mtx->_[2] * temp0 + mtx->_[3] * temp1 + (b << 0xC); + ptr[2] = temp2 >> 4; + ptr[3] = temp3 >> 4; +} + +void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d){ + *ptr = ((a | 0x40) | (b << 0x8)) | ((c | (d << 0x8)) << 0x10); +} + +void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness){ + if (brightness < 0) + { + ptr[0] = a | 0xC0; + ptr[2] = -brightness; + } + else + { + ptr[0] = a | 0x80; + ptr[2] = brightness; + } +} + +void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness){ + ptr[1] = c | (d << 0x8); + if (brightness < 0) + { + ptr[0] = 0xC0 | a | (b << 0x8); + ptr[2] = -brightness; + } + else + { + ptr[0] = 0x80 | a | (b << 0x8); + ptr[2] = brightness; + } +} + +void *G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness){ + u32 temp = *ptr; + if (brightness < 0) + { + if ((temp & 0xC0) == 0x80) + { + ptr[0] = temp & ~0xC0 | 0xC0; + } + ptr[2] = -brightness; + } + else + { + if ((temp & 0xC0) == 0xC0) + { + ptr[0] = temp & ~0xC0 | 0x80; + } + ptr[2] = brightness; + } +} -- cgit v1.2.3 From a92d77224c8ec645752a56aa35cc8a8457cd4cd3 Mon Sep 17 00:00:00 2001 From: Made Date: Fri, 15 May 2020 04:14:48 +0200 Subject: Add ARM_FUNC to GX --- arm9/lib/src/GX_g2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arm9/lib/src/GX_g2.c') diff --git a/arm9/lib/src/GX_g2.c b/arm9/lib/src/GX_g2.c index 7441e302..5bced1ef 100644 --- a/arm9/lib/src/GX_g2.c +++ b/arm9/lib/src/GX_g2.c @@ -2,7 +2,7 @@ #include "main.h" #include "gx.h" -void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d){ +ARM_FUNC void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d){ fx32 temp0, temp1, temp2, temp3; ptr[0] = ((u16)(fx16)(mtx->_[0] >> 4) | (u16)(fx16)(mtx->_[1] >> 4)<< 0x10); ptr[1] = ((u16)(fx16)(mtx->_[2] >> 4) | (u16)(fx16)(mtx->_[3] >> 4)<< 0x10); @@ -14,11 +14,11 @@ void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 ptr[3] = temp3 >> 4; } -void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d){ +ARM_FUNC void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d){ *ptr = ((a | 0x40) | (b << 0x8)) | ((c | (d << 0x8)) << 0x10); } -void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness){ +ARM_FUNC void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness){ if (brightness < 0) { ptr[0] = a | 0xC0; @@ -31,7 +31,7 @@ void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness){ } } -void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness){ +ARM_FUNC void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness){ ptr[1] = c | (d << 0x8); if (brightness < 0) { @@ -45,7 +45,7 @@ void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 b } } -void *G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness){ +ARM_FUNC void *G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness){ u32 temp = *ptr; if (brightness < 0) { -- cgit v1.2.3 From 88e486100e449d8960894c9e30c4f21489ccbc31 Mon Sep 17 00:00:00 2001 From: Made Date: Mon, 18 May 2020 02:33:11 +0200 Subject: rename main GX header --- arm9/lib/src/GX_g2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arm9/lib/src/GX_g2.c') diff --git a/arm9/lib/src/GX_g2.c b/arm9/lib/src/GX_g2.c index 5bced1ef..66273541 100644 --- a/arm9/lib/src/GX_g2.c +++ b/arm9/lib/src/GX_g2.c @@ -1,6 +1,6 @@ #include "global.h" #include "main.h" -#include "gx.h" +#include "GX.h" ARM_FUNC void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d){ fx32 temp0, temp1, temp2, temp3; -- cgit v1.2.3