through ov61_021E6AE0

This commit is contained in:
PikalaxALT 2022-03-29 18:30:36 -04:00
parent 42bee1df26
commit a9aaa8b525
7 changed files with 177 additions and 397 deletions

View File

@ -8,396 +8,6 @@
.text
thumb_func_start ov61_021E684C
ov61_021E684C: ; 0x021E684C
push {r3, r4}
ldr r4, [r0, #4]
mov r2, #1
ldr r3, [r4]
lsl r2, r2, #0xc
add r2, r3, r2
str r2, [r4]
cmp r1, #2
bne _021E686E
ldr r4, [r0, #4]
mov r2, #0xa
ldr r3, [r4]
lsl r2, r2, #0xe
cmp r3, r2
bne _021E686E
lsl r2, r2, #1
str r2, [r4]
_021E686E:
ldr r3, [r0, #4]
ldr r0, [r3, #8]
ldr r2, [r3]
ldrh r0, [r0, #4]
lsl r0, r0, #0xc
cmp r2, r0
blt _021E688E
cmp r1, #2
bne _021E688A
mov r0, #5
lsl r0, r0, #0x10
str r0, [r3]
pop {r3, r4}
bx lr
_021E688A:
mov r0, #0
str r0, [r3]
_021E688E:
pop {r3, r4}
bx lr
.balign 4, 0
thumb_func_end ov61_021E684C
thumb_func_start ov61_021E6894
ov61_021E6894: ; 0x021E6894
push {r3, r4, r5, lr}
mov r1, #0xe5
add r5, r0, #0
lsl r1, r1, #2
add r0, r1, #0
ldr r4, [r5, r1]
sub r0, #0x54
add r2, r5, r0
lsl r0, r4, #0x18
add r1, #0x18
lsr r0, r0, #0x15
ldr r1, [r5, r1]
add r0, r2, r0
bl ov61_021E684C
add r0, r4, #1
mov r1, #3
bl _u32_div_f
lsl r1, r1, #0x18
lsr r1, r1, #0x15
add r2, r5, r1
mov r1, #0xd1
lsl r1, r1, #2
ldr r1, [r2, r1]
mov r0, #0
str r0, [r1]
add r0, r4, #2
mov r1, #3
bl _u32_div_f
lsl r0, r1, #0x18
lsr r0, r0, #0x15
add r1, r5, r0
mov r0, #0xd1
lsl r0, r0, #2
ldr r0, [r1, r0]
mov r2, #0
str r2, [r0]
pop {r3, r4, r5, pc}
thumb_func_end ov61_021E6894
thumb_func_start ov61_021E68E4
ov61_021E68E4: ; 0x021E68E4
mov r2, #0xe5
lsl r2, r2, #2
ldr r1, [r0, r2]
sub r2, #0x50
lsl r1, r1, #0x18
lsr r1, r1, #0x15
add r0, r0, r1
ldr r0, [r0, r2]
ldr r1, [r0]
mov r0, #5
lsl r0, r0, #0x10
cmp r1, r0
blt _021E6902
mov r0, #1
bx lr
_021E6902:
mov r0, #0
bx lr
.balign 4, 0
thumb_func_end ov61_021E68E4
thumb_func_start ov61_021E6908
ov61_021E6908: ; 0x021E6908
push {r3, lr}
ldr r0, [r0]
cmp r0, #0
beq _021E6914
bl FreeToHeap
_021E6914:
pop {r3, pc}
.balign 4, 0
thumb_func_end ov61_021E6908
thumb_func_start ov61_021E6918
ov61_021E6918: ; 0x021E6918
push {r4, lr}
add r4, r0, #0
ldr r0, [r4]
cmp r0, #0
beq _021E6930
add r0, r1, #0
ldr r1, [r4, #4]
bl NNS_G3dFreeAnmObj
ldr r0, [r4]
bl FreeToHeap
_021E6930:
pop {r4, pc}
.balign 4, 0
thumb_func_end ov61_021E6918
thumb_func_start ov61_021E6934
ov61_021E6934: ; 0x021E6934
str r1, [r0, #0x5c]
str r2, [r0, #0x60]
str r3, [r0, #0x64]
bx lr
thumb_func_end ov61_021E6934
thumb_func_start ov61_021E693C
ov61_021E693C: ; 0x021E693C
str r1, [r0, #0x68]
str r2, [r0, #0x6c]
str r3, [r0, #0x70]
bx lr
thumb_func_end ov61_021E693C
thumb_func_start ov61_021E6944
ov61_021E6944: ; 0x021E6944
push {r4, r5, r6, r7, lr}
sub sp, #0x4c
ldr r3, _021E6A20 ; =ov61_021E73B0
add r7, r0, #0
ldmia r3!, {r0, r1}
add r2, sp, #0x34
str r2, [sp, #8]
stmia r2!, {r0, r1}
ldr r0, [r3]
mov r5, #0
str r0, [r2]
mov r0, #0xe5
lsl r0, r0, #2
ldr r0, [r7, r0]
str r5, [sp, #4]
lsl r0, r0, #0x18
lsr r4, r0, #0x18
add r0, r7, #0
str r0, [sp, #0xc]
add r0, #0x70
str r0, [sp, #0xc]
_021E696E:
add r0, r5, #0
mov r1, #3
bl _s32_div_f
lsl r0, r0, #0x10
lsr r0, r0, #0x10
str r0, [sp]
asr r0, r0, #4
lsl r1, r0, #2
ldr r0, _021E6A24 ; =FX_SinCosTable_
ldr r3, _021E6A24 ; =FX_SinCosTable_
add r2, r0, r1
ldrsh r1, [r3, r1]
mov r3, #2
ldrsh r2, [r2, r3]
add r0, sp, #0x10
bl MTX_RotY33_
ldr r0, [sp, #8]
add r1, sp, #0x10
add r2, sp, #0x40
bl MTX_MultVec33
mov r0, #0xc
mul r0, r4
add r6, r7, r0
mov r0, #0x37
lsl r0, r0, #4
add r3, sp, #0x40
add r2, r6, r0
ldmia r3!, {r0, r1}
stmia r2!, {r0, r1}
ldr r0, [r3]
str r0, [r2]
mov r0, #0xdd
lsl r0, r0, #2
ldr r1, [r6, r0]
mov r0, #0xd
lsl r0, r0, #0xc
add r1, r1, r0
mov r0, #0xdd
lsl r0, r0, #2
str r1, [r6, r0]
add r1, r4, #3
add r6, r1, #0
mov r0, #0x78
mul r6, r0
ldr r0, [sp, #0xc]
ldr r1, [sp, #0x40]
ldr r2, [sp, #0x44]
ldr r3, [sp, #0x48]
add r0, r0, r6
bl ov61_021E6934
ldr r0, [sp, #0xc]
mov r1, #1
lsl r1, r1, #0xc
add r0, r0, r6
add r2, r1, #0
add r3, r1, #0
bl ov61_021E693C
mov r0, #0x78
mul r0, r4
mov r1, #0x93
ldr r2, [sp]
add r0, r7, r0
lsl r1, r1, #2
strh r2, [r0, r1]
mov r2, #0
add r1, r1, #2
strh r2, [r0, r1]
add r0, r4, #1
mov r1, #3
bl _s32_div_f
lsl r0, r1, #0x18
lsr r4, r0, #0x18
mov r0, #1
lsl r0, r0, #0x10
add r5, r5, r0
ldr r0, [sp, #4]
add r0, r0, #1
str r0, [sp, #4]
cmp r0, #3
blt _021E696E
add sp, #0x4c
pop {r4, r5, r6, r7, pc}
nop
_021E6A20: .word ov61_021E73B0
_021E6A24: .word FX_SinCosTable_
thumb_func_end ov61_021E6944
thumb_func_start ov61_021E6A28
ov61_021E6A28: ; 0x021E6A28
push {r4, lr}
sub sp, #0x30
add r1, sp, #0
add r4, r0, #0
bl ov61_021E6A48
mov r0, #0x19
add r1, sp, #0
mov r2, #0xc
bl NNS_G3dGeBufferOP_N
add r0, r4, #0
bl NNS_G3dDraw
add sp, #0x30
pop {r4, pc}
thumb_func_end ov61_021E6A28
thumb_func_start ov61_021E6A48
ov61_021E6A48: ; 0x021E6A48
push {r4, r5, lr}
sub sp, #0x94
add r4, r1, #0
add r5, r0, #0
add r0, r4, #0
bl MTX_Identity43_
ldr r0, [r5, #0x64]
add r1, r4, #0
str r0, [sp]
ldr r2, [r5, #0x5c]
ldr r3, [r5, #0x60]
add r0, r4, #0
bl MTX_TransApply43
add r0, sp, #0x64
bl MTX_Identity43_
add r0, r5, #0
add r0, #0x76
ldrh r0, [r0]
ldr r3, _021E6ADC ; =FX_SinCosTable_
asr r0, r0, #4
lsl r2, r0, #1
lsl r1, r2, #1
add r2, r2, #1
lsl r2, r2, #1
ldrsh r1, [r3, r1]
ldrsh r2, [r3, r2]
add r0, sp, #4
bl MTX_RotX43_
add r1, sp, #0x64
add r0, sp, #4
add r2, r1, #0
bl MTX_Concat43
add r0, r5, #0
add r0, #0x74
ldrh r0, [r0]
ldr r3, _021E6ADC ; =FX_SinCosTable_
asr r0, r0, #4
lsl r2, r0, #1
lsl r1, r2, #1
add r2, r2, #1
lsl r2, r2, #1
ldrsh r1, [r3, r1]
ldrsh r2, [r3, r2]
add r0, sp, #4
bl MTX_RotY43_
add r1, sp, #0x64
add r0, sp, #4
add r2, r1, #0
bl MTX_Concat43
ldr r1, [r5, #0x68]
ldr r2, [r5, #0x6c]
ldr r3, [r5, #0x70]
add r0, sp, #0x34
bl MTX_Scale43_
add r0, sp, #0x64
add r1, r4, #0
add r2, r4, #0
bl MTX_Concat43
add r0, sp, #0x34
add r1, r4, #0
add r2, r4, #0
bl MTX_Concat43
add sp, #0x94
pop {r4, r5, pc}
.balign 4, 0
_021E6ADC: .word FX_SinCosTable_
thumb_func_end ov61_021E6A48
thumb_func_start ov61_021E6AE0
ov61_021E6AE0: ; 0x021E6AE0
push {r4, lr}
mov r3, #0xe6
lsl r3, r3, #2
ldrsh r4, [r0, r3]
mov r2, #0
add r4, r4, r1
strh r4, [r0, r3]
cmp r1, #0
ldrsh r4, [r0, r3]
blt _021E6B0A
ldr r1, _021E6B24 ; =0x00005555
cmp r4, r1
blt _021E6B1E
strh r2, [r0, r3]
add r1, r3, #2
strh r2, [r0, r1]
mov r1, #1
bl ov61_021E6B2C
mov r2, #1
b _021E6B1E
_021E6B0A:
ldr r1, _021E6B28 ; =0xFFFFAAAB
cmp r4, r1
bgt _021E6B1E
strh r2, [r0, r3]
add r1, r3, #2
strh r2, [r0, r1]
mov r1, #2
bl ov61_021E6B2C
mov r2, #1
_021E6B1E:
add r0, r2, #0
pop {r4, pc}
nop
_021E6B24: .word 0x00005555
_021E6B28: .word 0xFFFFAAAB
thumb_func_end ov61_021E6AE0
thumb_func_start ov61_021E6B2C
ov61_021E6B2C: ; 0x021E6B2C
push {r4, lr}

View File

@ -5,5 +5,6 @@
#include <nitro/fx/fx_trig.h>
#include <nitro/fx/fx_mtx22.h>
#include <nitro/fx/fx_mtx33.h>
#include <nitro/fx/fx_mtx43.h>
#endif //NITRO_FX_H_

View File

@ -8,6 +8,7 @@ static inline void MTX_Copy33(const MtxFx33 *pSrc, MtxFx33 *pDst) {
void MTX_Identity33_(register MtxFx33 *pDst);
void MTX_RotY33_(register MtxFx33 *pDst, register fx32 sinVal, register fx32 cosVal);
void MTX_Concat33(const MtxFx33 *a, const MtxFx33 *b, MtxFx33 *ab);
void MTX_MultVec33(const VecFx32 *vec, const MtxFx33 *m, VecFx32 *dst);
static inline void MTX_Identity33(MtxFx33 *pDst) {
MTX_Identity33_(pDst);

View File

@ -0,0 +1,27 @@
#ifndef NITRO_FX_FX_MTX43_H_
#define NITRO_FX_FX_MTX43_H_
void MTX_Identity43_(register MtxFx43 *pDst);
void MTX_TransApply43(const MtxFx43 *pSrc, MtxFx43 *pDst, fx32 x, fx32 y, fx32 z);
void MTX_Concat43(const MtxFx43 *a, const MtxFx43 *b, MtxFx43 *ab);
void MTX_RotX43_(register MtxFx43 *pDst, register fx32 sinVal, register fx32 cosVal);
void MTX_RotY43_(register MtxFx43 *pDst, register fx32 sinVal, register fx32 cosVal);
void MTX_Scale43_(register MtxFx43 *pDst, register fx32 x, register fx32 y, register fx32 z);
static inline void MTX_Identity43(MtxFx43 *pDst) {
MTX_Identity43_(pDst);
}
static inline void MTX_RotX43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal) {
MTX_RotX43_(pDst, sinVal, cosVal);
}
static inline void MTX_RotY43(MtxFx43 *pDst, fx32 sinVal, fx32 cosVal) {
MTX_RotY43_(pDst, sinVal, cosVal);
}
static inline void MTX_Scale43(MtxFx43 *pDst, fx32 x, fx32 y, fx32 z) {
MTX_Scale43_(pDst, x, y, z);
}
#endif //NITRO_FX_FX_MTX43_H_

View File

@ -140,6 +140,13 @@ typedef enum {
GX_LIGHTID_3 = 3
} GXLightId;
typedef enum {
GX_MTXMODE_PROJECTION = 0,
GX_MTXMODE_POSITION = 1,
GX_MTXMODE_POSITION_VECTOR = 2,
GX_MTXMODE_TEXTURE = 3
} GXMtxMode;
#define GX_PACK_VIEWPORT_PARAM(x1, y1, x2, y2) ((u32)((x1) | ((y1) << 8) | ((x2) << 16) | ((y2) << 24)))
#endif //NITRO_GX_G3_H_

View File

@ -1,6 +1,10 @@
#ifndef NNSYS_G3D_GECOM_INLINE_H_
#define NNSYS_G3D_GECOM_INLINE_H_
static inline void NNS_G3dGeMtxMode(GXMtxMode mode) {
NNS_G3dGeBufferOP_N(G3OP_MTX_MODE, (u32*)&mode, G3OP_MTX_MODE_NPARAMS);
}
static inline void NNS_G3dGePushMtx(void) {
NNS_G3dGeBufferOP_N(G3OP_MTX_PUSH, NULL, G3OP_MTX_PUSH_NPARAMS);
}
@ -9,4 +13,8 @@ static inline void NNS_G3dGePopMtx(int num) {
NNS_G3dGeBufferOP_N(G3OP_MTX_POP, (u32*)&num, G3OP_MTX_POP_NPARAMS);
}
static inline void NNS_G3dGeMultMtx43(const MtxFx43* m) {
NNS_G3dGeBufferOP_N(G3OP_MTX_MULT_4x3, (u32*) m, G3OP_MTX_MULT_4x3_NPARAMS);
}
#endif //NNSYS_G3D_GECOM_INLINE_H_

View File

@ -28,6 +28,7 @@ struct ChooseStarterRnd {
VecFx32 unk_5C;
VecFx32 unk_68;
u16 unk_74;
u16 unk_76;
}; // size=0x78
struct ChooseStarterAnm {
@ -87,10 +88,10 @@ struct ChooseStarterAppWork {
struct ChooseStarter3dRes unk_030[4];
struct ChooseStarterRnd unk_070[6];
struct ChooseStarterAnm unk_340[6];
u8 filler_370[0x24];
VecFx32 unk_370[3];
int unk_394;
u16 unk_398;
s16 unk_39A;
fx16 unk_398;
fx16 unk_39A;
WINDOW *unk_39C;
WINDOW *unk_3A0;
u8 frame; // 3A4
@ -130,11 +131,12 @@ void ov61_021E6894(struct ChooseStarterAppWork *work);
BOOL ov61_021E68E4(struct ChooseStarterAppWork *work);
void ov61_021E6908(struct ChooseStarter3dRes *a0);
void ov61_021E6918(struct ChooseStarterAnm *anm, NNSFndAllocator *alloc);
void ov61_021E6934(struct ChooseStarterRnd *, fx32, fx32, fx32);
void ov61_021E693C(struct ChooseStarterRnd *, fx32, fx32, fx32);
void ov61_021E6934(struct ChooseStarterRnd *rnd, fx32 x, fx32 y, fx32 z);
void ov61_021E693C(struct ChooseStarterRnd *rnd, fx32 x, fx32 y, fx32 z);
void ov61_021E6944(struct ChooseStarterAppWork *work);
void ov61_021E6A28(struct ChooseStarterRnd *render);
BOOL ov61_021E6AE0(struct ChooseStarterAppWork *work, s16 a1);
void ov61_021E6A48(struct ChooseStarterRnd *render, MtxFx43 *mtx);
BOOL ov61_021E6AE0(struct ChooseStarterAppWork *work, fx16 a1);
void ov61_021E6B2C(struct ChooseStarterAppWork *work, int a1);
void ov61_021E6B6C(struct ChooseStarterAppWork *work);
void ov61_021E6C3C(BGCONFIG *bgConfig, HeapID heapId);
@ -531,7 +533,7 @@ void ov61_021E61FC(struct ChooseStarterAppWork *work) {
sub_02026E50(0, 0);
}
static inline void id_roty_mtx33(MtxFx33 *mtx, int index) {
static inline void id_roty_mtx33(MtxFx33 *mtx, u16 index) {
MTX_Identity33(mtx);
MTX_RotY33(mtx, FX_SinIdx(index), FX_CosIdx(index));
}
@ -743,3 +745,127 @@ BOOL ov61_021E682C(struct ChooseStarterAnm *anm) {
}
return ret;
}
void ov61_021E684C(struct ChooseStarterAnm *anm, int a1) {
NNS_G3dAnmObjSetFrame(anm->obj, anm->obj->frame + FX32_ONE);
if (a1 == 2 && anm->obj->frame == (FX32_ONE * 40)) {
NNS_G3dAnmObjSetFrame(anm->obj, FX32_ONE * 80);
}
if (anm->obj->frame >= NNS_G3dAnmObjGetNumFrame(anm->obj)) {
if (a1 == 2) {
NNS_G3dAnmObjSetFrame(anm->obj, FX32_ONE * 80);
} else {
NNS_G3dAnmObjSetFrame(anm->obj, 0);
}
}
}
static inline struct ChooseStarterAnm *GetAnmByIdx(struct ChooseStarterAppWork *work, u8 idx) {
return &work->unk_340[idx];
}
void ov61_021E6894(struct ChooseStarterAppWork *work) {
u32 idx = work->unk_394;
ov61_021E684C(GetAnmByIdx(work, idx), work->unk_3AC);
NNS_G3dAnmObjSetFrame(GetAnmByIdx(work, (idx + 1) % 3)->obj, 0);
NNS_G3dAnmObjSetFrame(GetAnmByIdx(work, (idx + 2) % 3)->obj, 0);
}
BOOL ov61_021E68E4(struct ChooseStarterAppWork *work) {
u32 idx = work->unk_394;
return GetAnmByIdx(work, idx)->obj->frame >= 80 * FX32_ONE;
}
void ov61_021E6908(struct ChooseStarter3dRes *a0) {
if (a0->header != NULL) {
FreeToHeap(a0->header);
}
}
void ov61_021E6918(struct ChooseStarterAnm *anm, NNSFndAllocator *alloc) {
if (anm->hdr != NULL) {
NNS_G3dFreeAnmObj(alloc, anm->obj);
FreeToHeap(anm->hdr);
}
}
void ov61_021E6934(struct ChooseStarterRnd *rnd, fx32 x, fx32 y, fx32 z) {
rnd->unk_5C.x = x;
rnd->unk_5C.y = y;
rnd->unk_5C.z = z;
}
void ov61_021E693C(struct ChooseStarterRnd *rnd, fx32 x, fx32 y, fx32 z) {
rnd->unk_68.x = x;
rnd->unk_68.y = y;
rnd->unk_68.z = z;
}
void ov61_021E6944(struct ChooseStarterAppWork *work) {
extern const VecFx32 ov61_021E73B0;
VecFx32 sp40;
const VecFx32 sp34 = ov61_021E73B0;
MtxFx33 sp10;
int i;
u16 sp0;
u8 r4 = work->unk_394;
int angle = 0;
for (i = 0; i < 3; i++) {
sp0 = angle / 3;
MTX_RotY33(&sp10, FX_SinIdx(sp0), FX_CosIdx(sp0));
MTX_MultVec33(&sp34, &sp10, &sp40);
work->unk_370[r4] = sp40;
work->unk_370[r4].y += 13 * FX32_ONE;
ov61_021E6934(&work->unk_070[r4 + 3], sp40.x, sp40.y, sp40.z);
ov61_021E693C(&work->unk_070[r4 + 3], FX32_ONE, FX32_ONE, FX32_ONE);
work->unk_070[r4 + 3].unk_74 = sp0;
work->unk_070[r4 + 3].unk_76 = 0;
r4 = (r4 + 1) % 3;
angle += 16 * FX32_ONE;
}
}
void ov61_021E6A28(struct ChooseStarterRnd *render) {
MtxFx43 sp0;
ov61_021E6A48(render, &sp0);
NNS_G3dGeMultMtx43(&sp0);
NNS_G3dDraw(&render->obj);
}
void ov61_021E6A48(struct ChooseStarterRnd *render, MtxFx43 *mtx) {
MtxFx43 sp64;
MtxFx43 sp34;
MtxFx43 sp04;
MTX_Identity43(mtx);
MTX_TransApply43(mtx, mtx, render->unk_5C.x, render->unk_5C.y, render->unk_5C.z);
MTX_Identity43(&sp64);
MTX_RotX43(&sp04, FX_SinIdx(render->unk_76), FX_CosIdx(render->unk_76));
MTX_Concat43(&sp04, &sp64, &sp64);
MTX_RotY43(&sp04, FX_SinIdx(render->unk_74), FX_CosIdx(render->unk_74));
MTX_Concat43(&sp04, &sp64, &sp64);
MTX_Scale43(&sp34, render->unk_68.x, render->unk_68.y, render->unk_68.z);
MTX_Concat43(&sp64, mtx, mtx);
MTX_Concat43(&sp34, mtx, mtx);
}
BOOL ov61_021E6AE0(struct ChooseStarterAppWork *work, fx16 a1) {
BOOL ret = FALSE;
work->unk_398 += a1;
if (a1 >= 0) {
if (work->unk_398 >= 0x5555) {
work->unk_398 = 0;
work->unk_39A = 0;
ov61_021E6B2C(work, 1);
ret = TRUE;
}
} else {
if (work->unk_398 <= -0x5555) {
work->unk_398 = 0;
work->unk_39A = 0;
ov61_021E6B2C(work, 2);
ret = TRUE;
}
}
return ret;
}