summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMade <made111@gmx.de>2020-05-15 03:29:32 +0200
committerMade <made111@gmx.de>2020-05-15 03:29:32 +0200
commit14a5ca7ae49912305b1bcbaa180cfc9fdf8ff17a (patch)
treef7488358fc0e296944722bee11bfa77e04f121e6
parent42adea6c97323f7e5738dc05c062af0d6fddd66d (diff)
Decompile GX_g2.s
-rw-r--r--arm9/asm/GX_g2.s121
-rw-r--r--arm9/lib/include/gx.h7
-rw-r--r--arm9/lib/src/GX_g2.c66
3 files changed, 73 insertions, 121 deletions
diff --git a/arm9/asm/GX_g2.s b/arm9/asm/GX_g2.s
deleted file mode 100644
index 7ed2f124..00000000
--- a/arm9/asm/GX_g2.s
+++ /dev/null
@@ -1,121 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .text
-
- arm_func_start G2x_ChangeBlendBrightness_
-G2x_ChangeBlendBrightness_: ; 0x020C7418
- cmp r1, #0x0
- ldrh r3, [r0, #0x0]
- bge _020C7444
- and r2, r3, #0xc0
- cmp r2, #0x80
- biceq r2, r3, #0xc0
- orreq r2, r2, #0xc0
- streqh r2, [r0, #0x0]
- rsb r1, r1, #0x0
- strh r1, [r0, #0x4]
- bx lr
-_020C7444:
- and r2, r3, #0xc0
- cmp r2, #0xc0
- biceq r2, r3, #0xc0
- orreq r2, r2, #0x80
- streqh r2, [r0, #0x0]
- strh r1, [r0, #0x4]
- bx lr
-
- arm_func_start G2x_SetBlendBrightnessExt_
-G2x_SetBlendBrightnessExt_: ; 0x020C7460
- stmdb sp!, {lr}
- sub sp, sp, #0x4
- ldr lr, [sp, #0x8]
- ldr r12, [sp, #0xc]
- orr r3, r3, lr, lsl #0x8
- cmp r12, #0x0
- orrge r1, r1, #0x80
- strh r3, [r0, #0x2]
- orrge r1, r1, r2, lsl #0x8
- strgeh r1, [r0, #0x0]
- strgeh r12, [r0, #0x4]
- addge sp, sp, #0x4
- ldmgeia sp!, {lr}
- bxge lr
- orr r1, r1, #0xc0
- orr r1, r1, r2, lsl #0x8
- strh r1, [r0, #0x0]
- rsb r1, r12, #0x0
- strh r1, [r0, #0x4]
- add sp, sp, #0x4
- ldmia sp!, {lr}
- bx lr
-
- arm_func_start G2x_SetBlendBrightness_
-G2x_SetBlendBrightness_: ; 0x020C74B8
- cmp r2, #0x0
- orrlt r1, r1, #0xc0
- strlth r1, [r0, #0x0]
- rsblt r1, r2, #0x0
- strlth r1, [r0, #0x4]
- orrge r1, r1, #0x80
- strgeh r1, [r0, #0x0]
- strgeh r2, [r0, #0x4]
- bx lr
-
- arm_func_start G2x_SetBlendAlpha_
-G2x_SetBlendAlpha_: ; 0x020C74DC
- ldr r12, [sp, #0x0]
- orr r1, r1, #0x40
- orr r2, r1, r2, lsl #0x8
- orr r1, r3, r12, lsl #0x8
- orr r1, r2, r1, lsl #0x10
- str r1, [r0, #0x0]
- bx lr
-
- arm_func_start G2x_SetBGyAffine_
-G2x_SetBGyAffine_: ; 0x020C74F8
- stmdb sp!, {r4-r6,lr}
- ldr r5, [r1, #0x0]
- ldr r4, [r1, #0x4]
- mov r12, r5, lsl #0xc
- mov lr, r4, lsl #0xc
- mov r5, r12, asr #0x10
- mov r4, lr, asr #0x10
- mov r12, r5, lsl #0x10
- mov lr, r4, lsl #0x10
- mov r5, r12, lsr #0x10
- mov r4, lr, lsr #0x10
- orr r4, r5, r4, lsl #0x10
- str r4, [r0, #0x0]
- ldr r5, [r1, #0x8]
- ldr r4, [r1, #0xc]
- mov r12, r5, lsl #0xc
- mov lr, r4, lsl #0xc
- mov r5, r12, asr #0x10
- mov r4, lr, asr #0x10
- mov r12, r5, lsl #0x10
- mov lr, r4, lsl #0x10
- ldr r4, [sp, #0x14]
- ldr r6, [sp, #0x10]
- mov r12, r12, lsr #0x10
- mov r5, lr, lsr #0x10
- orr r5, r12, r5, lsl #0x10
- str r5, [r0, #0x4]
- ldr r12, [r1, #0x4]
- sub r5, r4, r3
- ldr r4, [r1, #0xc]
- mul lr, r12, r5
- mul r5, r4, r5
- ldr r12, [r1, #0x0]
- sub r6, r6, r2
- ldr r4, [r1, #0x8]
- mla r1, r12, r6, lr
- mla r5, r4, r6, r5
- add r1, r1, r2, lsl #0xc
- add r2, r5, r3, lsl #0xc
- mov r1, r1, asr #0x4
- str r1, [r0, #0x8]
- mov r1, r2, asr #0x4
- str r1, [r0, #0xc]
- ldmia sp!, {r4-r6,lr}
- bx lr
diff --git a/arm9/lib/include/gx.h b/arm9/lib/include/gx.h
index f3016f44..a17132ed 100644
--- a/arm9/lib/include/gx.h
+++ b/arm9/lib/include/gx.h
@@ -300,6 +300,13 @@ void GX_SetGraphicsMode(u32 mode1, u32 mode2, u32 mode3);
void GXS_SetGraphicsMode(u32 mode);
void GXx_SetMasterBrightness_(vu16 *dst, s32 brightness);
+//GX_g2
+void G2x_SetBGyAffine_(u32 *ptr, 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);
+
//GXi_NopClearFifo128_ probably asm
#endif //GUARD_GX_H
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;
+ }
+}