(spline) More progress; cleanup of other usages

This commit is contained in:
Eebit 2024-09-14 17:03:31 -04:00
parent 87e2ee5eb0
commit 98df6f30c7
13 changed files with 1302 additions and 2084 deletions

File diff suppressed because it is too large Load Diff

281
asm/spline_800A950.s Normal file
View File

@ -0,0 +1,281 @@
.INCLUDE "macro.inc"
.SYNTAX UNIFIED
THUMB_FUNC_START sub_800A950
sub_800A950: @ 0x0800A950
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, r9
mov r5, r8
push {r5, r6, r7}
sub sp, #0xb4
str r0, [sp, #0xac]
str r2, [sp, #0x88]
movs r2, #0
ldrsh r0, [r0, r2]
str r0, [sp, #0x8c]
ldr r3, [sp, #0xac]
ldr r3, [r3, #4]
mov r9, r3
ldr r7, [sp, #0xac]
ldr r7, [r7, #8]
str r7, [sp, #0x90]
ldr r0, [sp, #0xac]
ldr r0, [r0, #0xc]
mov r8, r0
add r0, sp, #0x80
str r1, [r0]
cmp r1, #0
bne _0800A986
movs r1, #0
str r1, [sp, #0x94]
b _0800A990
_0800A986:
ldr r2, [sp, #0xac]
movs r3, #2
ldrsh r0, [r2, r3]
subs r0, #1
str r0, [sp, #0x94]
_0800A990:
mov r7, sp
adds r7, #0x10
str r7, [sp, #0xa8]
ldr r1, [sp, #0xac]
ldrh r0, [r1, #2]
add r2, sp, #0x34
add r1, sp, #0xc
_0800A99E:
str r2, [r1]
subs r2, #0xc
subs r1, #4
cmp r1, sp
bge _0800A99E
lsls r0, r0, #0x10
cmp r0, #0
bne _0800A9B4
movs r0, #1
negs r0, r0
b _0800AB48
_0800A9B4:
ldr r2, [sp, #0xac]
movs r3, #2
ldrsh r1, [r2, r3]
add r4, sp, #0x84
mov r0, r9
add r2, sp, #0x80
adds r3, r4, #0
bl sub_800A8D8
ldr r1, [r4]
cmp r1, #0
bne _0800A9D2
movs r7, #1
str r7, [sp, #0x98]
b _0800A9E6
_0800A9D2:
ldr r2, [sp, #0xac]
movs r3, #2
ldrsh r0, [r2, r3]
subs r0, #1
movs r7, #0
str r7, [sp, #0x98]
cmp r1, r0
bne _0800A9E6
movs r0, #2
str r0, [sp, #0x98]
_0800A9E6:
ldr r1, [sp, #0xac]
ldr r0, [r1, #0x10]
ldr r4, _0800AA44 @ gUnknown_08591AB4
cmp r0, #0
beq _0800A9F2
adds r4, r0, #0
_0800A9F2:
movs r6, #0
ldr r2, [sp, #0xac]
ldrh r2, [r2]
add r3, sp, #0xa4
strh r2, [r3]
mov r7, sp
adds r7, #0x40
str r7, [sp, #0xa0]
add r0, sp, #0x84
mov sl, r0
add r3, sp, #0x18
add r2, sp, #0x14
ldr r5, [sp, #0xa8]
adds r5, #2
ldr r1, [sp, #0xa8]
mov ip, r1
ldr r0, [sp, #0x94]
ldr r1, [sp, #0x8c]
adds r7, r0, #0
muls r7, r1, r7
lsls r0, r7, #2
ldr r7, [sp, #0x90]
adds r0, r7, r0
str r0, [sp, #0x9c]
_0800AA22:
add r0, sp, #0xa4
ldrh r1, [r0]
mov r0, ip
strh r1, [r0]
mov r1, sl
ldr r0, [r1]
adds r0, r0, r6
subs r1, r0, #1
cmp r1, #0
bgt _0800AA48
mov r7, r9
ldrh r0, [r7]
strh r0, [r5]
ldr r0, [sp, #0x90]
str r0, [r2]
b _0800AAA0
.align 2, 0
_0800AA44: .4byte gUnknown_08591AB4
_0800AA48:
ldr r7, [sp, #0x94]
cmp r1, r7
blt _0800AA66
lsls r1, r7, #1
mov r0, r9
adds r0, r1, r0
ldrh r0, [r0]
strh r0, [r5]
ldr r7, [sp, #0x9c]
str r7, [r2]
mov r0, r8
cmp r0, #0
beq _0800AAA0
add r1, r8
b _0800AA90
_0800AA66:
lsls r0, r0, #1
add r0, r9
subs r0, #2
ldrh r0, [r0]
strh r0, [r5]
mov r1, sl
ldr r0, [r1]
adds r1, r0, r6
subs r0, r1, #1
ldr r7, [sp, #0x8c]
muls r0, r7, r0
lsls r0, r0, #2
ldr r7, [sp, #0x90]
adds r0, r7, r0
str r0, [r2]
mov r0, r8
cmp r0, #0
beq _0800AAA0
lsls r0, r1, #1
add r0, r8
subs r1, r0, #2
_0800AA90:
movs r7, #0
ldrsh r1, [r1, r7]
lsls r0, r1, #1
adds r0, r0, r1
lsls r0, r0, #2
adds r0, r4, r0
str r0, [r3]
b _0800AAA2
_0800AAA0:
str r4, [r3]
_0800AAA2:
adds r3, #0xc
adds r2, #0xc
adds r5, #0xc
movs r0, #0xc
add ip, r0
adds r6, #1
cmp r6, #3
ble _0800AA22
ldr r0, [sp]
ldr r1, [sp, #0xa0]
ldr r2, [sp, #0x98]
bl sub_800A7D8
ldr r2, [sp, #0xac]
movs r3, #2
ldrsh r1, [r2, r3]
ldr r2, [sp, #0x84]
adds r0, r2, #1
cmp r1, r0
ble _0800AAE6
lsls r1, r2, #1
add r1, r9
movs r7, #2
ldrsh r0, [r1, r7]
movs r3, #0
ldrsh r2, [r1, r3]
subs r0, r0, r2
lsls r2, r2, #0xc
ldr r1, [sp, #0x80]
subs r1, r1, r2
bl DivArm
adds r5, r0, #0
b _0800AAF4
_0800AAE6:
lsls r0, r2, #1
add r0, r9
movs r7, #0
ldrsh r0, [r0, r7]
lsls r0, r0, #0xc
ldr r1, [sp, #0x80]
subs r5, r1, r0
_0800AAF4:
ldr r4, [sp, #0xa0]
movs r6, #0
ldr r0, [sp, #0x8c]
cmp r6, r0
bcs _0800AB46
movs r7, #0x80
lsls r7, r7, #5
ldr r1, [sp, #0x88]
mov r8, r1
_0800AB06:
ldr r0, [r4]
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #4]
adds r0, r0, r1
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #8]
adds r0, r0, r1
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #0xc]
adds r0, r0, r1
mov r2, r8
adds r2, #4
mov r8, r2
subs r2, #4
stm r2!, {r0}
adds r4, #0x10
adds r6, #1
ldr r3, [sp, #0x8c]
cmp r6, r3
bcc _0800AB06
_0800AB46:
ldr r0, [sp, #0x84]
_0800AB48:
add sp, #0xb4
pop {r3, r4, r5}
mov r8, r3
mov r9, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r1}
bx r1
THUMB_FUNC_END sub_800A950
.align 2, 0

280
asm/spline_800AF64.s Normal file
View File

@ -0,0 +1,280 @@
.INCLUDE "macro.inc"
.SYNTAX UNIFIED
THUMB_FUNC_START sub_800AF64
sub_800AF64: @ 0x0800AF64
push {r4, r5, r6, r7, lr}
mov r7, sl
mov r6, r9
mov r5, r8
push {r5, r6, r7}
sub sp, #0xb0
adds r7, r0, #0
str r2, [sp, #0x88]
movs r2, #0
ldrsh r0, [r7, r2]
str r0, [sp, #0x8c]
ldr r3, [r7, #4]
mov r9, r3
ldr r4, [r7, #8]
str r4, [sp, #0x90]
ldr r0, [r7, #0xc]
mov r8, r0
ldr r2, [r7, #0x10]
mov sl, r2
add r0, sp, #0x80
str r1, [r0]
cmp r1, #0
bne _0800AF98
movs r3, #0
str r3, [sp, #0x94]
b _0800AFA0
_0800AF98:
movs r4, #2
ldrsh r0, [r7, r4]
subs r0, #1
str r0, [sp, #0x94]
_0800AFA0:
mov r0, sp
adds r0, #0x10
str r0, [sp, #0xa4]
ldrh r0, [r7, #2]
add r2, sp, #0x34
add r1, sp, #0xc
_0800AFAC:
str r2, [r1]
subs r2, #0xc
subs r1, #4
cmp r1, sp
bge _0800AFAC
lsls r0, r0, #0x10
cmp r0, #0
bne _0800AFC2
movs r0, #1
negs r0, r0
b _0800B15A
_0800AFC2:
movs r2, #2
ldrsh r1, [r7, r2]
add r4, sp, #0x84
mov r0, r9
add r2, sp, #0x80
adds r3, r4, #0
bl sub_800A8D8
ldr r1, [r4]
cmp r1, #0
bne _0800AFDC
movs r3, #1
b _0800AFEC
_0800AFDC:
movs r4, #2
ldrsh r0, [r7, r4]
subs r0, #1
movs r2, #0
str r2, [sp, #0x98]
cmp r1, r0
bne _0800AFEE
movs r3, #2
_0800AFEC:
str r3, [sp, #0x98]
_0800AFEE:
movs r6, #0
ldrh r4, [r7]
add r0, sp, #0xa8
strh r4, [r0]
mov r1, sp
adds r1, #0x40
str r1, [sp, #0xa0]
add r2, sp, #0x18
mov ip, r6
add r5, sp, #0x14
mov r3, sp
adds r3, #0x84
str r3, [sp, #0xac]
ldr r4, [sp, #0x94]
lsls r0, r4, #2
ldr r1, [sp, #0x90]
adds r0, r0, r1
str r0, [sp, #0x9c]
_0800B012:
ldr r3, [sp, #0xa4]
add r3, ip
add r4, sp, #0xa8
ldrh r4, [r4]
strh r4, [r3]
ldr r1, [sp, #0xac]
ldr r0, [r1]
adds r0, r0, r6
subs r1, r0, #1
cmp r1, #0
bgt _0800B048
mov r4, r9
ldrh r0, [r4]
strh r0, [r3, #2]
ldr r1, [sp, #0x90]
ldr r0, [r1]
str r0, [r5]
mov r3, sl
ldr r0, [r3]
cmp r0, #0
bne _0800B0AC
ldr r4, _0800B044 @ gUnknown_08591AB4
str r4, [r2]
b _0800B0B4
.align 2, 0
_0800B044: .4byte gUnknown_08591AB4
_0800B048:
ldr r4, [sp, #0x94]
cmp r1, r4
blt _0800B076
lsls r1, r4, #1
mov r4, r9
adds r0, r1, r4
ldrh r0, [r0]
strh r0, [r3, #2]
ldr r3, [sp, #0x9c]
ldr r0, [r3]
str r0, [r5]
mov r4, r8
cmp r4, #0
beq _0800B0B0
adds r0, r1, r4
movs r1, #0
ldrsh r0, [r0, r1]
lsls r0, r0, #2
add r0, sl
ldr r0, [r0]
cmp r0, #0
bne _0800B0AC
b _0800B0B0
_0800B076:
lsls r0, r0, #1
add r0, r9
subs r0, #2
ldrh r0, [r0]
strh r0, [r3, #2]
ldr r4, [sp, #0xac]
ldr r0, [r4]
adds r1, r0, r6
lsls r0, r1, #2
ldr r3, [sp, #0x90]
adds r0, r0, r3
subs r0, #4
ldr r0, [r0]
str r0, [r5]
mov r4, r8
cmp r4, #0
beq _0800B0B0
lsls r0, r1, #1
add r0, r8
subs r0, #2
movs r1, #0
ldrsh r0, [r0, r1]
lsls r0, r0, #2
add r0, sl
ldr r0, [r0]
cmp r0, #0
beq _0800B0B0
_0800B0AC:
str r0, [r2]
b _0800B0B4
_0800B0B0:
ldr r3, _0800B0F4 @ gUnknown_08591AB4
str r3, [r2]
_0800B0B4:
adds r2, #0xc
movs r4, #0xc
add ip, r4
adds r5, #0xc
adds r6, #1
cmp r6, #3
ble _0800B012
ldr r0, [sp]
ldr r1, [sp, #0xa0]
ldr r2, [sp, #0x98]
bl sub_800A7D8
movs r0, #2
ldrsh r1, [r7, r0]
ldr r2, [sp, #0x84]
adds r0, r2, #1
cmp r1, r0
ble _0800B0F8
lsls r1, r2, #1
add r1, r9
movs r2, #2
ldrsh r0, [r1, r2]
movs r3, #0
ldrsh r2, [r1, r3]
subs r0, r0, r2
lsls r2, r2, #0xc
ldr r1, [sp, #0x80]
subs r1, r1, r2
bl DivArm
adds r5, r0, #0
b _0800B106
.align 2, 0
_0800B0F4: .4byte gUnknown_08591AB4
_0800B0F8:
lsls r0, r2, #1
add r0, r9
movs r4, #0
ldrsh r0, [r0, r4]
lsls r0, r0, #0xc
ldr r1, [sp, #0x80]
subs r5, r1, r0
_0800B106:
ldr r4, [sp, #0xa0]
movs r6, #0
ldr r0, [sp, #0x8c]
cmp r6, r0
bcs _0800B158
movs r7, #0x80
lsls r7, r7, #5
ldr r1, [sp, #0x88]
mov r8, r1
_0800B118:
ldr r0, [r4]
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #4]
adds r0, r0, r1
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #8]
adds r0, r0, r1
adds r1, r5, #0
muls r1, r0, r1
adds r0, r7, #0
bl DivArm
ldr r1, [r4, #0xc]
adds r0, r0, r1
mov r2, r8
adds r2, #4
mov r8, r2
subs r2, #4
stm r2!, {r0}
adds r4, #0x10
adds r6, #1
ldr r3, [sp, #0x8c]
cmp r6, r3
bcc _0800B118
_0800B158:
ldr r0, [sp, #0x84]
_0800B15A:
add sp, #0xb0
pop {r3, r4, r5}
mov r8, r3
mov r9, r4
mov sl, r5
pop {r4, r5, r6, r7}
pop {r1}
bx r1
THUMB_FUNC_END sub_800AF64
.align 2, 0

View File

@ -1,29 +1,54 @@
#ifndef GUARD_SPLINE_H
#define GUARD_SPLINE_H
struct Struct0859E7D4
{
int x;
int y;
};
struct Struct02003BE8
{
/* 00 */ u16 unk_00;
/* 02 */ u16 unk_02;
/* 04 */ u16 * unk_04;
/* 08 */ struct Struct0859E7D4 * unk_08;
/* 08 */ int * unk_08;
/* 0C */ int * unk_0C;
/* 10 */ int * unk_10;
};
struct UnkSplineStruct1
{
/* 00 */ s16 unk_00;
/* 02 */ s16 unk_02;
/* 04 */ u32 * unk_04;
/* 08 */ s16 * unk_08;
};
struct UnkSplineStruct2
{
/* 00 */ s16 unk_00;
/* 02 */ s16 unk_02;
/* 04 */ s16 unk_04;
/* 06 */ s16 unk_06;
/* 08 */ u32 * unk_08;
/* 0C */ u32 * unk_0c;
/* 10 */ u32 * unk_10;
/* 14 */ s16 * unk_14;
/* 18 */ s16 * unk_18;
/* 1C */ s16 * unk_1c;
/* 20 */ s16 * unk_20;
};
struct UnkSplineStruct3
{
/* 00 */ int unk_00;
/* 04 */ int unk_04;
/* 08 */ int unk_08;
/* 0C */ int unk_0c;
};
int sub_800A42C(int a, int b, int c);
// ??? sub_800A4E8(???);
// ??? sub_800A518(???);
// ??? sub_800A680(???);
// ??? sub_800A7D8(???);
// ??? sub_800A8D8(???);
void sub_800A950(struct Struct02003BE8 *, int, int *);
int sub_800A950(void *, int, int *);
// ??? sub_800AB58(???);
// ??? sub_800ACEC(???);
// ??? sub_800AE7C(???);

View File

@ -826,7 +826,7 @@ int sub_80BCA1C(int);
// ??? sub_80BCBAC(???);
s8 sub_80BCCFC(s8, s8, s8);
// ??? sub_80BCDE4(???);
int sub_80BCE34(int, int, s16, u16 *, struct Struct0859E7D4 *, int);
int sub_80BCE34(int, int, s16, u16 *, int *, int);
void ResetGmStoryNode(void);
int GetPlayChapterId(u32);
int GetNextUnclearedNode(struct GMapData *);

View File

@ -312,8 +312,10 @@ SECTIONS
src/gamecontrol.o(.text);
src/msg.o(.text);
src/spline.o(.text);
asm/spline.o(.text);
src/spline_.o(.text);
asm/spline_800A950.o(.text);
src/spline_800AB58.o(.text);
asm/spline_800AF64.o(.text);
src/spline_800B16C.o(.text);
src/eventscr_utils.o(.text);
src/eventscr_gmap.o(.text);
src/event.o(.text);

View File

@ -1118,7 +1118,7 @@ void sub_8038F78(struct Text* th) {
extern struct Struct02003BE8 gUnknown_02003BE8;
extern u16 gUnknown_02003B88[];
extern struct Struct0859E7D4 gUnknown_02003BA8[];
extern int gUnknown_02003BA8[];
// obj data?
const u16 CONST_DATA obj_859E79C[] = {
@ -1135,20 +1135,21 @@ u16 CONST_DATA gUnknown_0859E7C8[] = {
0x0C00, 0x0DEB, 0x1000,
};
struct Struct0859E7D4 CONST_DATA gUnknown_0859E7D4[] = {
{ -56, 0, },
{ -70, 14, },
{ -74, 6, },
{ 38, -14, },
{ 42, -6, },
{ 24, 0, },
int CONST_DATA gUnknown_0859E7D4[] = {
-56, 0,
-70, 14,
-74, 6,
38, -14,
42, -6,
24, 0,
};
void sub_803901C(struct BMDifficultyProc* proc) {
void sub_803901C(struct BMDifficultyProc * proc)
{
int r7;
int r8;
u16* iter1;
struct Struct0859E7D4* iter2;
u16 * iter1;
int * iter2;
sub_8038F78(&gUnknown_020038C8[0].text[proc->labelIndex][0]);
@ -1163,11 +1164,12 @@ void sub_803901C(struct BMDifficultyProc* proc) {
gUnknown_02003BE8.unk_02 = r8 = 6;
for (r7 = 0; r7 < r8; r7++) {
for (r7 = 0; r7 < r8; r7++)
{
gUnknown_02003B88[r7] = DivArm(4096, iter1[r7] * 45);
gUnknown_02003BA8[r7].x = iter2[r7].x << 4;
gUnknown_02003BA8[r7].y = iter2[r7].y << 4;
gUnknown_02003BA8[r7 * 2 + 0] = iter2[r7 * 2 + 0] << 4;
gUnknown_02003BA8[r7 * 2 + 1] = iter2[r7 * 2 + 1] << 4;
}
proc->unk_34 = 0;
@ -1362,12 +1364,13 @@ u16 CONST_DATA gUnknown_0859E82C[] = {
0x16, 0x1E, 0x00,
};
struct Struct0859E7D4 CONST_DATA gUnknown_0859E838[] = {
{ 0x980, 0x380, },
{ 0x8D0, 0x430, },
{ 0x960, 0x320, },
{ 0xA30, 0x2D0, },
{ 0x980, 0x380, },
int CONST_DATA gUnknown_0859E838[] =
{
0x980, 0x380,
0x8D0, 0x430,
0x960, 0x320,
0xA30, 0x2D0,
0x980, 0x380,
};
void sub_803943C(struct BMDifficultyProc* proc) {

View File

@ -2,37 +2,6 @@
#include "spline.h"
struct UnkSplineStruct1
{
/* 00 */ s16 unk_00;
/* 02 */ s16 unk_02;
/* 04 */ u32 * unk_04;
/* 08 */ s16 * unk_08;
};
struct UnkSplineStruct2
{
/* 00 */ s16 unk_00;
/* 02 */ s16 unk_02;
/* 04 */ s16 unk_04;
/* 06 */ s16 unk_06;
/* 08 */ u32 * unk_08;
/* 0C */ u32 * unk_0c;
/* 10 */ u32 * unk_10;
/* 14 */ s16 * unk_14;
/* 18 */ s16 * unk_18;
/* 1C */ s16 * unk_1c;
/* 20 */ s16 * unk_20;
};
struct UnkSplineStruct3
{
/* 00 */ int unk_00;
/* 04 */ int unk_04;
/* 08 */ int unk_08;
/* 0C */ int unk_0c;
};
//! FE8U = 0x0800A42C
int sub_800A42C(int val, int start, int end)
{

View File

@ -1,98 +0,0 @@
#include "global.h"
#include "spline.h"
//! FE8U = 0x0800B7E0
int _DivArm1(int arg_0, int arg_1, int arg_2)
{
int r1;
int r4;
int r5;
int i;
if (arg_2 == 0)
{
return DivArm(arg_1, arg_0 << 12);
}
r4 = arg_0 * 0x1000;
if (0x1000 - DivArm(arg_1, r4) < 0)
{
r1 = DivArm(arg_1, r4) - 0x1000;
}
else
{
r1 = 0x1000 - DivArm(arg_1, r4);
}
r5 = r1;
for (i = 0; i < arg_2; i++)
{
r1 = DivArm(0x1000, r1 * r5);
}
return 0x1000 - r1;
}
//! FE8U = 0x0800B84C
int _DivArm2(int arg_0, int arg_1, int arg_2)
{
int r1;
#if NONMATCHING
int r5;
#else
register int r5 asm("r5");
#endif
int r6;
int i;
if (arg_2 == 0)
{
return DivArm(arg_1, arg_0 << 12);
}
r6 = arg_1 / 2;
if (arg_0 < r6)
{
if (DivArm(r6, arg_0 * 0x1000) < 0)
{
r1 = -DivArm(r6, arg_0 * 0x1000);
}
else
{
r1 = DivArm(r6, arg_0 * 0x1000);
}
}
else
{
if (0x1000 - DivArm(r6, (arg_0 - r6) * 0x1000) < 0)
{
r1 = DivArm(r6, (arg_0 - r6) * 0x1000) - 0x1000;
}
else
{
r1 = 0x1000 - DivArm(r6, (arg_0 - r6) * 0x1000);
}
}
r5 = r1;
for (i = 0; i < arg_2; i++)
{
r1 = DivArm(0x1000, r1 * r5);
}
if (arg_0 < r6)
{
r1 = r1 / 2;
}
else
{
r1 = (0x1000 - r1) / 2 + 0x800;
}
return r1;
}

251
src/spline_800AB58.c Normal file
View File

@ -0,0 +1,251 @@
#include "global.h"
#include "spline.h"
//! FE8U = 0x0800AB58
void sub_800AB58(struct UnkSplineStruct3 * arg_0, int * arg_1)
{
int r4;
int r5;
int r7;
int r8;
int pa;
int pb;
int pc;
int pd;
int var_1;
int var_2;
int var_3;
int var_4;
int var_5;
int var_6;
int var_7;
int var_8;
int var_9;
int sp_00;
int sp_04;
int sp_08;
int sp_0c;
pa = arg_0->unk_00;
pb = arg_0->unk_04;
pc = arg_0->unk_08;
pd = arg_0->unk_0c;
r4 = DivArm(
DivArm(0x1000, pa * pa) + DivArm(0x1000, pb * pb) + DivArm(0x1000, pc * pc) + DivArm(0x1000, pd * pd),
0x2000000);
r8 = DivArm(0x1000, pa * r4);
r5 = DivArm(0x1000, pb * r4);
r7 = DivArm(0x1000, pc * r4);
var_1 = DivArm(0x1000, pd * r8);
var_2 = DivArm(0x1000, pd * r5);
var_3 = DivArm(0x1000, pd * r7);
var_5 = DivArm(0x1000, pa * r8);
var_7 = DivArm(0x1000, pa * r5);
var_8 = DivArm(0x1000, pa * r7);
var_6 = DivArm(0x1000, pb * r5);
var_9 = DivArm(0x1000, pb * r7);
var_4 = DivArm(0x1000, pc * r7);
arg_1[0] = 0x1000 - (var_6 + var_4);
arg_1[1] = var_7 + var_3;
arg_1[2] = var_8 - var_2;
arg_1[4] = var_7 - var_3;
arg_1[5] = 0x1000 - (var_4 + var_5);
arg_1[6] = var_9 + var_1;
arg_1[8] = var_8 + var_2;
arg_1[9] = var_9 - var_1;
arg_1[10] = 0x1000 - (var_5 + var_6);
arg_1[14] = 0;
arg_1[13] = 0;
arg_1[12] = 0;
arg_1[11] = 0;
arg_1[7] = 0;
arg_1[3] = 0;
arg_1[15] = 0x1000;
return;
}
//! FE8U = 0x0800ACEC
void sub_800ACEC(struct UnkSplineStruct3 * arg_0, int * arg_1)
{
int r4;
int r5;
int r7;
int r8;
int p_a;
int p_b;
int p_c;
int p_d;
int var_1;
int var_2;
int var_3;
int var_4;
int var_5;
int var_6;
int var_7;
int var_8;
int var_9;
int sp_00;
int sp_04;
int sp_08;
int sp_0c;
p_a = arg_0->unk_00;
p_b = arg_0->unk_04;
p_c = arg_0->unk_08;
p_d = arg_0->unk_0c;
r4 = DivArm(
DivArm(0x1000, p_a * p_a) + DivArm(0x1000, p_b * p_b) + DivArm(0x1000, p_c * p_c) + DivArm(0x1000, p_d * p_d),
0x2000000);
r8 = DivArm(0x1000, p_a * r4);
r5 = DivArm(0x1000, p_b * r4);
r7 = DivArm(0x1000, p_c * r4);
var_1 = DivArm(0x1000, p_d * r8);
var_2 = DivArm(0x1000, p_d * r5);
var_3 = DivArm(0x1000, p_d * r7);
var_5 = DivArm(0x1000, p_a * r8);
var_7 = DivArm(0x1000, p_a * r5);
var_8 = DivArm(0x1000, p_a * r7);
var_6 = DivArm(0x1000, p_b * r5);
var_9 = DivArm(0x1000, p_b * r7);
var_4 = DivArm(0x1000, p_c * r7);
arg_1[0] = 0x1000 - (var_6 + var_4);
arg_1[1] = var_7 + var_3;
arg_1[2] = var_8 - var_2;
arg_1[3] = var_7 - var_3;
arg_1[4] = 0x1000 - (var_4 + var_5);
arg_1[5] = var_9 + var_1;
arg_1[6] = var_8 + var_2;
arg_1[7] = var_9 - var_1;
arg_1[8] = 0x1000 - (var_5 + var_6);
arg_1[11] = 0x1000;
arg_1[10] = 0x1000;
arg_1[9] = 0x1000;
return;
}
struct UnkSplineSub800AE7C
{
/* 00 */ int unk_00;
/* 04 */ int unk_04;
/* 08 */ u16 unk_08;
/* 0C */ s16 * unk_0c;
/* 10 */ int * unk_10;
/* 14 */ int * unk_14;
/* 18 */ int * unk_18;
/* 1C */ u16 unk_1c;
/* 20 */ s16 * unk_20;
/* 24 */ int * unk_24;
/* 28 */ int * unk_28;
/* 2C */ int * unk_2c;
/* 30 */ u16 unk_30;
/* 34 */ s16 * unk_34;
/* 38 */ int * unk_38;
/* 3C */ int * unk_3c;
/* 40 */ int * unk_40;
};
struct Struct02003BE8_B
{
/* 00 */ u16 unk_00;
/* 02 */ u16 unk_02;
/* 04 */ u16 * unk_04;
/* 08 */ void * unk_08;
/* 0C */ int * unk_0c;
/* 10 */ int * unk_10;
};
//! FE8U = 0x0800AE7C
int sub_800AE7C(struct UnkSplineSub800AE7C * arg_0, int arg_1, int * arg_2, int * arg_3, int * arg_4)
{
int ret;
struct Struct02003BE8_B local;
int flags = arg_0->unk_00;
if ((flags & 4) != 0)
{
local.unk_02 = arg_0->unk_08;
local.unk_00 = 3;
local.unk_04 = arg_0->unk_0c;
local.unk_08 = arg_0->unk_10;
local.unk_0c = arg_0->unk_14;
local.unk_10 = arg_0->unk_18;
ret = sub_800A950(&local, arg_1, arg_2);
if (ret < 0)
{
arg_2[2] = 0;
arg_2[1] = 0;
arg_2[0] = 0;
}
}
if ((flags & 8) != 0)
{
local.unk_02 = arg_0->unk_1c;
local.unk_00 = 4;
local.unk_04 = arg_0->unk_20;
local.unk_08 = arg_0->unk_24;
local.unk_0c = arg_0->unk_28;
local.unk_10 = arg_0->unk_2c;
ret = sub_800A950(&local, arg_1, arg_3);
if (ret < 0)
{
arg_3[2] = 0;
arg_3[1] = 0;
arg_3[0] = 0;
arg_3[3] = 1;
}
}
if ((flags & 0x10) != 0)
{
local.unk_02 = arg_0->unk_30;
local.unk_00 = 3;
local.unk_04 = arg_0->unk_34;
local.unk_08 = arg_0->unk_38;
local.unk_0c = arg_0->unk_3c;
local.unk_10 = arg_0->unk_40;
ret = sub_800A950(&local, arg_1, arg_4);
if (ret < 0)
{
arg_4[2] = 0;
arg_4[1] = 0;
arg_4[0] = 0;
}
}
return ret;
}

415
src/spline_800B16C.c Normal file
View File

@ -0,0 +1,415 @@
#include "global.h"
#include "spline.h"
struct InputStructA
{
/* 00 */ s16 unk_00;
/* 04 */ s16 * unk_04;
/* 08 */ void * unk_08;
/* 0C */ s16 * unk_0c;
/* 10 */ void * unk_10;
};
struct InputStructB
{
/* 00 */ int unk_00;
/* 04 */ s16 * unk_04;
/* 08 */ void ** unk_08;
/* 0C */ int unk_0c;
/* 10 */ void ** unk_10;
};
struct astruct_13
{
/* 00 */ int unk_00;
/* 04 */ struct InputStructB * unk_04;
/* 08 */ struct InputStructB * unk_08;
/* 0C */ int unk_0c;
/* 10 */ int * unk_10;
/* 14 */ int * unk_14;
};
struct astruct_12
{
/* 00 */ int unk_00;
/* 04 */ int unk_04;
/* 08 */ struct InputStructA unk_08;
/* 1C */ struct InputStructA unk_1c;
};
struct Struct02003BE8_B
{
/* 00 */ u16 unk_00;
/* 02 */ u16 unk_02;
/* 04 */ u16 * unk_04;
/* 08 */ void * unk_08;
/* 0C */ int * unk_0c;
/* 10 */ int * unk_10;
};
int sub_800A8D8(s16 *, s16, int *, int *);
struct Params
{
s16 count;
s16 index;
s16 * data;
int * coefficients;
u32 * intermediateResults;
u32 * unk_10;
};
int sub_800AF64(struct Params *, int, int *);
struct astruct_16
{
int unk_00;
struct Params * unk_04;
struct Params * unk_08;
int unk_0c;
int * unk_10;
int * unk_14;
};
//! FE8U = 0x0800B16C
int sub_800B16C(struct astruct_16 * arg_0)
{
int ret;
if (arg_0->unk_04 != 0)
{
ret = sub_800AF64(arg_0->unk_04, arg_0->unk_00, arg_0->unk_10);
}
if (arg_0->unk_08 != 0)
{
ret = sub_800AF64(arg_0->unk_08, arg_0->unk_00, arg_0->unk_14);
}
return ret;
}
//! FE8U = 0x0800B198
int sub_800B198(struct InputStructA * arg_0, struct InputStructB * arg_1, int * arg_2, int arg_3, s16 arg_4)
{
s16 * r8;
struct Struct02003BE8_B local;
int r9;
int sp_18;
sub_800A8D8(r8 = arg_0->unk_04, r9 = arg_0->unk_00, &arg_3, &sp_18);
arg_1->unk_04[1] = arg_4;
if ((sp_18 < r9 - 1) && (r8[sp_18 + 1] == (s16)DivArm(0x1000, arg_3)))
{
arg_1->unk_08[1] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
if (sp_18 < r9 - 2)
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 2]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 6;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 2] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
}
else
{
local.unk_02 = arg_0->unk_00;
local.unk_00 = 3;
local.unk_04 = arg_0->unk_04;
local.unk_08 = (void *)arg_0->unk_08;
local.unk_0c = (void *)arg_0->unk_0c;
local.unk_10 = (void *)arg_0->unk_10;
if (sub_800A950(&local, arg_3, arg_2) < 0)
{
arg_2[2] = 0;
arg_2[1] = 0;
arg_2[0] = 0;
}
arg_1->unk_08[1] = arg_2;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
if (sp_18 >= r9 - 1)
{
arg_1->unk_04[2] = arg_4 + 1;
arg_1->unk_08[2] = arg_2;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
return 1;
}
return 0;
}
//! FE8U = 0x0800B388
int sub_800B388(struct InputStructA * arg_0, struct InputStructB * arg_1, int * arg_2, int arg_3, s16 arg_4)
{
s16 * r8;
struct Struct02003BE8_B local;
int r9;
int sp_18;
sub_800A8D8(r8 = arg_0->unk_04, r9 = arg_0->unk_00, &arg_3, &sp_18);
arg_1->unk_04[1] = arg_4;
if ((sp_18 < r9 - 1) && (r8[sp_18 + 1] == (s16)DivArm(0x1000, arg_3)))
{
arg_1->unk_08[1] = &((int *)(arg_0->unk_08))[sp_18 * 4] + 4;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
if (sp_18 < r9 - 2)
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 2]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 4] + 8;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 2] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 4] + 4;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
}
else
{
local.unk_02 = arg_0->unk_00;
local.unk_00 = 4;
local.unk_04 = arg_0->unk_04;
local.unk_08 = (void *)arg_0->unk_08;
local.unk_0c = (void *)arg_0->unk_0c;
local.unk_10 = (void *)arg_0->unk_10;
if (sub_800A950(&local, arg_3, arg_2) < 0)
{
arg_2[2] = 0;
arg_2[1] = 0;
arg_2[0] = 0;
arg_2[3] = 1;
}
arg_1->unk_08[1] = arg_2;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
if (sp_18 >= r9 - 1)
{
arg_1->unk_04[2] = arg_4 + 1;
arg_1->unk_08[2] = arg_2;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 4] + 4;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
return 1;
}
return 0;
}
//! FE8U = 0x0800B574
int sub_800B574(struct InputStructA * arg_0, struct InputStructB * arg_1, int * arg_2, int arg_3, s16 arg_4)
{
s16 * r8;
struct Struct02003BE8_B local;
int r9;
int sp_18;
sub_800A8D8(r8 = arg_0->unk_04, r9 = arg_0->unk_00, &arg_3, &sp_18);
arg_1->unk_04[1] = arg_4;
if ((sp_18 < r9 - 1) && (r8[sp_18 + 1] == (s16)DivArm(0x1000, arg_3)))
{
arg_1->unk_08[1] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
if (sp_18 < r9 - 2)
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 2]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 6;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 2] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
}
else
{
local.unk_02 = arg_0->unk_00;
local.unk_00 = 3;
local.unk_04 = arg_0->unk_04;
local.unk_08 = (void *)arg_0->unk_08;
local.unk_0c = (void *)arg_0->unk_0c;
local.unk_10 = (void *)arg_0->unk_10;
if (sub_800A950(&local, arg_3, arg_2) < 0)
{
arg_2[2] = 0;
arg_2[1] = 0;
arg_2[0] = 0;
}
arg_1->unk_08[1] = arg_2;
arg_1->unk_10[1] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
if (sp_18 >= r9 - 1)
{
arg_1->unk_04[2] = arg_4 + 1;
arg_1->unk_08[2] = arg_2;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18] * 3];
}
else
{
arg_1->unk_04[2] = (arg_4 + arg_0->unk_04[sp_18 + 1]) - DivArm(0x1000, arg_3);
arg_1->unk_08[2] = &((int *)(arg_0->unk_08))[sp_18 * 3] + 3;
arg_1->unk_10[2] = &((int *)(arg_0->unk_10))[arg_0->unk_0c[sp_18 + 1] * 3];
}
return 1;
}
return 0;
}
//! FE8U = 0x0800B764
int sub_800B764(struct astruct_12 * arg_0, struct astruct_13 * arg_1, s16 arg_2)
{
int ret;
int flags = arg_0->unk_00;
struct InputStructB * ip = arg_1->unk_04;
struct InputStructB * r8 = arg_1->unk_08;
if ((flags & 4) != 0)
{
ip->unk_04[0] = 0;
ret = sub_800B198(&arg_0->unk_08, ip, arg_1->unk_10, arg_1->unk_00, arg_2);
}
if ((flags & 8) != 0)
{
r8->unk_04[0] = 0;
ret = sub_800B388(&arg_0->unk_1c, r8, arg_1->unk_14, arg_1->unk_00, arg_2);
}
return ret;
}
//! FE8U = 0x0800B7E0
int _DivArm1(int arg_0, int arg_1, int arg_2)
{
int r1;
int r4;
int r5;
int i;
if (arg_2 == 0)
{
return DivArm(arg_1, arg_0 << 12);
}
r4 = arg_0 * 0x1000;
if (0x1000 - DivArm(arg_1, r4) < 0)
{
r1 = DivArm(arg_1, r4) - 0x1000;
}
else
{
r1 = 0x1000 - DivArm(arg_1, r4);
}
r5 = r1;
for (i = 0; i < arg_2; i++)
{
r1 = DivArm(0x1000, r1 * r5);
}
return 0x1000 - r1;
}
//! FE8U = 0x0800B84C
int _DivArm2(int arg_0, int arg_1, int arg_2)
{
int r1;
#if NONMATCHING
int r5;
#else
register int r5 asm("r5");
#endif
int r6;
int i;
if (arg_2 == 0)
{
return DivArm(arg_1, arg_0 << 12);
}
r6 = arg_1 / 2;
if (arg_0 < r6)
{
if (DivArm(r6, arg_0 * 0x1000) < 0)
{
r1 = -DivArm(r6, arg_0 * 0x1000);
}
else
{
r1 = DivArm(r6, arg_0 * 0x1000);
}
}
else
{
if (0x1000 - DivArm(r6, (arg_0 - r6) * 0x1000) < 0)
{
r1 = DivArm(r6, (arg_0 - r6) * 0x1000) - 0x1000;
}
else
{
r1 = 0x1000 - DivArm(r6, (arg_0 - r6) * 0x1000);
}
}
r5 = r1;
for (i = 0; i < arg_2; i++)
{
r1 = DivArm(0x1000, r1 * r5);
}
if (arg_0 < r6)
{
r1 = r1 / 2;
}
else
{
r1 = (0x1000 - r1) / 2 + 0x800;
}
return r1;
}

View File

@ -22,7 +22,7 @@ extern u16 gUnknown_08A3E2F8[];
extern struct Struct02003BE8 gUnknown_0201B3A4[];
extern u16 gUnknown_0201B104[];
extern struct Struct0859E7D4 gUnknown_0201B1E4[];
extern int gUnknown_0201B1E4[];
int CONST_DATA gUnknown_08A3E22C[] =
{
@ -159,7 +159,7 @@ void GmMuPrim_80BD444(struct GMapMuPrimProc * proc)
unkSplineStruct->unk_00 = 0;
unkSplineStruct->unk_00 = 2;
unkSplineStruct->unk_04 = gUnknown_0201B104 + proc->unk_2a * 0x10;
unkSplineStruct->unk_08 = gUnknown_0201B1E4 + proc->unk_2a * 8;
unkSplineStruct->unk_08 = gUnknown_0201B1E4 + proc->unk_2a * 0x10;
unkSplineStruct->unk_0C = gUnknown_08A3E22C;
unkSplineStruct->unk_10 = gUnknown_08A3E23C;
unkSplineStruct->unk_02 = sub_80BCE34(proc->unk_2d, proc->unk_2e, proc->unk_50, unkSplineStruct->unk_04, unkSplineStruct->unk_08, 4);

View File

@ -1786,7 +1786,7 @@ int sub_80BCDE4(int nodeA, int nodeB, int * startingNode)
}
//! FE8U = 0x080BCE34
int sub_80BCE34(int nodeA, int nodeB, s16 c, u16 * d, struct Struct0859E7D4 * e, int f)
int sub_80BCE34(int nodeA, int nodeB, s16 c, u16 * d, int * e, int f)
{
int nodeId;
int pathId;
@ -1805,11 +1805,11 @@ int sub_80BCE34(int nodeA, int nodeB, s16 c, u16 * d, struct Struct0859E7D4 * e,
nodeId = pathId[gWMPathData].node[startingNodeIdx];
e->x = nodeId[gWMNodeData].x << (f);
e->y = nodeId[gWMNodeData].y << (f);
e[0] = nodeId[gWMNodeData].x << (f);
e[1] = nodeId[gWMNodeData].y << (f);
d++;
e++;
e += 2;
local_24 = sub_80BC3D4(pathId);
@ -1819,11 +1819,11 @@ int sub_80BCE34(int nodeA, int nodeB, s16 c, u16 * d, struct Struct0859E7D4 * e,
{
*d = DivArm(0x1000, pathId[gWMPathData].movementPath[i].elapsedTime * c);
e->x = pathId[gWMPathData].movementPath[i].x << (f);
e->y = pathId[gWMPathData].movementPath[i].y << (f);
e[0] = pathId[gWMPathData].movementPath[i].x << (f);
e[1] = pathId[gWMPathData].movementPath[i].y << (f);
d++;
e++;
e += 2;
}
}
else
@ -1832,19 +1832,19 @@ int sub_80BCE34(int nodeA, int nodeB, s16 c, u16 * d, struct Struct0859E7D4 * e,
{
*d = DivArm(0x1000, c * (0x1000 - (pathId[gWMPathData].movementPath[i].elapsedTime)));
e->x = pathId[gWMPathData].movementPath[i].x << (f);
e->y = pathId[gWMPathData].movementPath[i].y << (f);
e[0] = pathId[gWMPathData].movementPath[i].x << (f);
e[1] = pathId[gWMPathData].movementPath[i].y << (f);
d++;
e++;
e += 2;
}
}
*d = c;
nodeId = pathId[gWMPathData].node[1 - startingNodeIdx];
e->x = nodeId[gWMNodeData].x << (f);
e->y = nodeId[gWMNodeData].y << (f);
e[0] = nodeId[gWMNodeData].x << (f);
e[1] = nodeId[gWMNodeData].y << (f);
return local_24 + 2;
}