Match SetCamEnabled, SetCamFlag80, SetCamPerspective, func_802CA90C. WIP func_802CA988. Modified Camera struct.

This commit is contained in:
Jdog 2020-08-20 09:41:42 -07:00
parent 56928c3089
commit e8ed3ae03f
6 changed files with 101 additions and 206 deletions

View File

@ -1,54 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SetCamEnabled
/* 0EF070 802CA6C0 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0EF074 802CA6C4 AFB00010 */ sw $s0, 0x10($sp)
/* 0EF078 802CA6C8 0080802D */ daddu $s0, $a0, $zero
/* 0EF07C 802CA6CC AFBF0018 */ sw $ra, 0x18($sp)
/* 0EF080 802CA6D0 AFB10014 */ sw $s1, 0x14($sp)
/* 0EF084 802CA6D4 8E11000C */ lw $s1, 0xc($s0)
/* 0EF088 802CA6D8 8E250000 */ lw $a1, ($s1)
/* 0EF08C 802CA6DC 0C0B1EAF */ jal get_variable
/* 0EF090 802CA6E0 26310004 */ addiu $s1, $s1, 4
/* 0EF094 802CA6E4 0200202D */ daddu $a0, $s0, $zero
/* 0EF098 802CA6E8 8E250000 */ lw $a1, ($s1)
/* 0EF09C 802CA6EC 0C0B1EAF */ jal get_variable
/* 0EF0A0 802CA6F0 0040802D */ daddu $s0, $v0, $zero
/* 0EF0A4 802CA6F4 1440000D */ bnez $v0, .L802CA72C
/* 0EF0A8 802CA6F8 00101080 */ sll $v0, $s0, 2
/* 0EF0AC 802CA6FC 3C04800B */ lui $a0, 0x800b
/* 0EF0B0 802CA700 24841D80 */ addiu $a0, $a0, 0x1d80
/* 0EF0B4 802CA704 00501021 */ addu $v0, $v0, $s0
/* 0EF0B8 802CA708 00021080 */ sll $v0, $v0, 2
/* 0EF0BC 802CA70C 00501023 */ subu $v0, $v0, $s0
/* 0EF0C0 802CA710 000218C0 */ sll $v1, $v0, 3
/* 0EF0C4 802CA714 00431021 */ addu $v0, $v0, $v1
/* 0EF0C8 802CA718 000210C0 */ sll $v0, $v0, 3
/* 0EF0CC 802CA71C 00441021 */ addu $v0, $v0, $a0
/* 0EF0D0 802CA720 94430000 */ lhu $v1, ($v0)
/* 0EF0D4 802CA724 080B29D6 */ j .L802CA758
/* 0EF0D8 802CA728 34630002 */ ori $v1, $v1, 2
.L802CA72C:
/* 0EF0DC 802CA72C 3C04800B */ lui $a0, 0x800b
/* 0EF0E0 802CA730 24841D80 */ addiu $a0, $a0, 0x1d80
/* 0EF0E4 802CA734 00501021 */ addu $v0, $v0, $s0
/* 0EF0E8 802CA738 00021080 */ sll $v0, $v0, 2
/* 0EF0EC 802CA73C 00501023 */ subu $v0, $v0, $s0
/* 0EF0F0 802CA740 000218C0 */ sll $v1, $v0, 3
/* 0EF0F4 802CA744 00431021 */ addu $v0, $v0, $v1
/* 0EF0F8 802CA748 000210C0 */ sll $v0, $v0, 3
/* 0EF0FC 802CA74C 00441021 */ addu $v0, $v0, $a0
/* 0EF100 802CA750 94430000 */ lhu $v1, ($v0)
/* 0EF104 802CA754 3063FFFD */ andi $v1, $v1, 0xfffd
.L802CA758:
/* 0EF108 802CA758 A4430000 */ sh $v1, ($v0)
/* 0EF10C 802CA75C 8FBF0018 */ lw $ra, 0x18($sp)
/* 0EF110 802CA760 8FB10014 */ lw $s1, 0x14($sp)
/* 0EF114 802CA764 8FB00010 */ lw $s0, 0x10($sp)
/* 0EF118 802CA768 24020002 */ addiu $v0, $zero, 2
/* 0EF11C 802CA76C 03E00008 */ jr $ra
/* 0EF120 802CA770 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,54 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SetCamFlag80
/* 0EF124 802CA774 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0EF128 802CA778 AFB00010 */ sw $s0, 0x10($sp)
/* 0EF12C 802CA77C 0080802D */ daddu $s0, $a0, $zero
/* 0EF130 802CA780 AFBF0018 */ sw $ra, 0x18($sp)
/* 0EF134 802CA784 AFB10014 */ sw $s1, 0x14($sp)
/* 0EF138 802CA788 8E11000C */ lw $s1, 0xc($s0)
/* 0EF13C 802CA78C 8E250000 */ lw $a1, ($s1)
/* 0EF140 802CA790 0C0B1EAF */ jal get_variable
/* 0EF144 802CA794 26310004 */ addiu $s1, $s1, 4
/* 0EF148 802CA798 0200202D */ daddu $a0, $s0, $zero
/* 0EF14C 802CA79C 8E250000 */ lw $a1, ($s1)
/* 0EF150 802CA7A0 0C0B1EAF */ jal get_variable
/* 0EF154 802CA7A4 0040802D */ daddu $s0, $v0, $zero
/* 0EF158 802CA7A8 1440000D */ bnez $v0, .L802CA7E0
/* 0EF15C 802CA7AC 00101080 */ sll $v0, $s0, 2
/* 0EF160 802CA7B0 3C04800B */ lui $a0, 0x800b
/* 0EF164 802CA7B4 24841D80 */ addiu $a0, $a0, 0x1d80
/* 0EF168 802CA7B8 00501021 */ addu $v0, $v0, $s0
/* 0EF16C 802CA7BC 00021080 */ sll $v0, $v0, 2
/* 0EF170 802CA7C0 00501023 */ subu $v0, $v0, $s0
/* 0EF174 802CA7C4 000218C0 */ sll $v1, $v0, 3
/* 0EF178 802CA7C8 00431021 */ addu $v0, $v0, $v1
/* 0EF17C 802CA7CC 000210C0 */ sll $v0, $v0, 3
/* 0EF180 802CA7D0 00441021 */ addu $v0, $v0, $a0
/* 0EF184 802CA7D4 94430000 */ lhu $v1, ($v0)
/* 0EF188 802CA7D8 080B2A03 */ j .L802CA80C
/* 0EF18C 802CA7DC 34630080 */ ori $v1, $v1, 0x80
.L802CA7E0:
/* 0EF190 802CA7E0 3C04800B */ lui $a0, 0x800b
/* 0EF194 802CA7E4 24841D80 */ addiu $a0, $a0, 0x1d80
/* 0EF198 802CA7E8 00501021 */ addu $v0, $v0, $s0
/* 0EF19C 802CA7EC 00021080 */ sll $v0, $v0, 2
/* 0EF1A0 802CA7F0 00501023 */ subu $v0, $v0, $s0
/* 0EF1A4 802CA7F4 000218C0 */ sll $v1, $v0, 3
/* 0EF1A8 802CA7F8 00431021 */ addu $v0, $v0, $v1
/* 0EF1AC 802CA7FC 000210C0 */ sll $v0, $v0, 3
/* 0EF1B0 802CA800 00441021 */ addu $v0, $v0, $a0
/* 0EF1B4 802CA804 94430000 */ lhu $v1, ($v0)
/* 0EF1B8 802CA808 3063FF7F */ andi $v1, $v1, 0xff7f
.L802CA80C:
/* 0EF1BC 802CA80C A4430000 */ sh $v1, ($v0)
/* 0EF1C0 802CA810 8FBF0018 */ lw $ra, 0x18($sp)
/* 0EF1C4 802CA814 8FB10014 */ lw $s1, 0x14($sp)
/* 0EF1C8 802CA818 8FB00010 */ lw $s0, 0x10($sp)
/* 0EF1CC 802CA81C 24020002 */ addiu $v0, $zero, 2
/* 0EF1D0 802CA820 03E00008 */ jr $ra
/* 0EF1D4 802CA824 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -2,97 +2,7 @@
.set noreorder # don't insert nops after branches
glabel SetCamPerspective
/* 0EF1D8 802CA828 27BDFFD0 */ addiu $sp, $sp, -0x30
/* 0EF1DC 802CA82C AFB10014 */ sw $s1, 0x14($sp)
/* 0EF1E0 802CA830 0080882D */ daddu $s1, $a0, $zero
/* 0EF1E4 802CA834 AFBF0020 */ sw $ra, 0x20($sp)
/* 0EF1E8 802CA838 AFB3001C */ sw $s3, 0x1c($sp)
/* 0EF1EC 802CA83C AFB20018 */ sw $s2, 0x18($sp)
/* 0EF1F0 802CA840 AFB00010 */ sw $s0, 0x10($sp)
/* 0EF1F4 802CA844 F7B40028 */ sdc1 $f20, 0x28($sp)
/* 0EF1F8 802CA848 8E30000C */ lw $s0, 0xc($s1)
/* 0EF1FC 802CA84C 8E050000 */ lw $a1, ($s0)
/* 0EF200 802CA850 0C0B1EAF */ jal get_variable
/* 0EF204 802CA854 26100004 */ addiu $s0, $s0, 4
/* 0EF208 802CA858 8E050000 */ lw $a1, ($s0)
/* 0EF20C 802CA85C 26100004 */ addiu $s0, $s0, 4
/* 0EF210 802CA860 0220202D */ daddu $a0, $s1, $zero
/* 0EF214 802CA864 0C0B1EAF */ jal get_variable
/* 0EF218 802CA868 0040902D */ daddu $s2, $v0, $zero
/* 0EF21C 802CA86C 8E050000 */ lw $a1, ($s0)
/* 0EF220 802CA870 26100004 */ addiu $s0, $s0, 4
/* 0EF224 802CA874 0220202D */ daddu $a0, $s1, $zero
/* 0EF228 802CA878 0C0B210B */ jal get_float_variable
/* 0EF22C 802CA87C 0040982D */ daddu $s3, $v0, $zero
/* 0EF230 802CA880 8E050000 */ lw $a1, ($s0)
/* 0EF234 802CA884 26100004 */ addiu $s0, $s0, 4
/* 0EF238 802CA888 0220202D */ daddu $a0, $s1, $zero
/* 0EF23C 802CA88C 0C0B1EAF */ jal get_variable
/* 0EF240 802CA890 46000506 */ mov.s $f20, $f0
/* 0EF244 802CA894 0220202D */ daddu $a0, $s1, $zero
/* 0EF248 802CA898 8E050000 */ lw $a1, ($s0)
/* 0EF24C 802CA89C 0C0B1EAF */ jal get_variable
/* 0EF250 802CA8A0 0040802D */ daddu $s0, $v0, $zero
/* 0EF254 802CA8A4 3C05800B */ lui $a1, 0x800b
/* 0EF258 802CA8A8 24A51D80 */ addiu $a1, $a1, 0x1d80
/* 0EF25C 802CA8AC 00121880 */ sll $v1, $s2, 2
/* 0EF260 802CA8B0 00721821 */ addu $v1, $v1, $s2
/* 0EF264 802CA8B4 00031880 */ sll $v1, $v1, 2
/* 0EF268 802CA8B8 00721823 */ subu $v1, $v1, $s2
/* 0EF26C 802CA8BC 000320C0 */ sll $a0, $v1, 3
/* 0EF270 802CA8C0 00641821 */ addu $v1, $v1, $a0
/* 0EF274 802CA8C4 000318C0 */ sll $v1, $v1, 3
/* 0EF278 802CA8C8 00651821 */ addu $v1, $v1, $a1
/* 0EF27C 802CA8CC 24040001 */ addiu $a0, $zero, 1
/* 0EF280 802CA8D0 A4620014 */ sh $v0, 0x14($v1)
/* 0EF284 802CA8D4 A4730004 */ sh $s3, 4($v1)
/* 0EF288 802CA8D8 A4640006 */ sh $a0, 6($v1)
/* 0EF28C 802CA8DC A4640008 */ sh $a0, 8($v1)
/* 0EF290 802CA8E0 E4740018 */ swc1 $f20, 0x18($v1)
/* 0EF294 802CA8E4 A4700012 */ sh $s0, 0x12($v1)
/* 0EF298 802CA8E8 8FBF0020 */ lw $ra, 0x20($sp)
/* 0EF29C 802CA8EC 8FB3001C */ lw $s3, 0x1c($sp)
/* 0EF2A0 802CA8F0 8FB20018 */ lw $s2, 0x18($sp)
/* 0EF2A4 802CA8F4 8FB10014 */ lw $s1, 0x14($sp)
/* 0EF2A8 802CA8F8 8FB00010 */ lw $s0, 0x10($sp)
/* 0EF2AC 802CA8FC D7B40028 */ ldc1 $f20, 0x28($sp)
/* 0EF2B0 802CA900 24020002 */ addiu $v0, $zero, 2
/* 0EF2B4 802CA904 03E00008 */ jr $ra
/* 0EF2B8 802CA908 27BD0030 */ addiu $sp, $sp, 0x30
/* 0EF2BC 802CA90C 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0EF2C0 802CA910 AFB10014 */ sw $s1, 0x14($sp)
/* 0EF2C4 802CA914 0080882D */ daddu $s1, $a0, $zero
/* 0EF2C8 802CA918 AFBF0018 */ sw $ra, 0x18($sp)
/* 0EF2CC 802CA91C AFB00010 */ sw $s0, 0x10($sp)
/* 0EF2D0 802CA920 8E30000C */ lw $s0, 0xc($s1)
/* 0EF2D4 802CA924 8E050000 */ lw $a1, ($s0)
/* 0EF2D8 802CA928 0C0B1EAF */ jal get_variable
/* 0EF2DC 802CA92C 26100004 */ addiu $s0, $s0, 4
/* 0EF2E0 802CA930 0220202D */ daddu $a0, $s1, $zero
/* 0EF2E4 802CA934 8E050000 */ lw $a1, ($s0)
/* 0EF2E8 802CA938 0C0B1EAF */ jal get_variable
/* 0EF2EC 802CA93C 0040802D */ daddu $s0, $v0, $zero
/* 0EF2F0 802CA940 3C05800B */ lui $a1, 0x800b
/* 0EF2F4 802CA944 24A51D80 */ addiu $a1, $a1, 0x1d80
/* 0EF2F8 802CA948 00101880 */ sll $v1, $s0, 2
/* 0EF2FC 802CA94C 00701821 */ addu $v1, $v1, $s0
/* 0EF300 802CA950 00031880 */ sll $v1, $v1, 2
/* 0EF304 802CA954 00701823 */ subu $v1, $v1, $s0
/* 0EF308 802CA958 000320C0 */ sll $a0, $v1, 3
/* 0EF30C 802CA95C 00641821 */ addu $v1, $v1, $a0
/* 0EF310 802CA960 000318C0 */ sll $v1, $v1, 3
/* 0EF314 802CA964 00651821 */ addu $v1, $v1, $a1
/* 0EF318 802CA968 A4620004 */ sh $v0, 4($v1)
/* 0EF31C 802CA96C A4600006 */ sh $zero, 6($v1)
/* 0EF320 802CA970 8FBF0018 */ lw $ra, 0x18($sp)
/* 0EF324 802CA974 8FB10014 */ lw $s1, 0x14($sp)
/* 0EF328 802CA978 8FB00010 */ lw $s0, 0x10($sp)
/* 0EF32C 802CA97C 24020002 */ addiu $v0, $zero, 2
/* 0EF330 802CA980 03E00008 */ jr $ra
/* 0EF334 802CA984 27BD0020 */ addiu $sp, $sp, 0x20
glabel func_802CA988
/* 0EF338 802CA988 27BDFFD0 */ addiu $sp, $sp, -0x30
/* 0EF33C 802CA98C AFB20018 */ sw $s2, 0x18($sp)
/* 0EF340 802CA990 0080902D */ daddu $s2, $a0, $zero
@ -194,4 +104,3 @@ glabel SetCamPerspective
/* 0EF4BC 802CAB0C 24020002 */ addiu $v0, $zero, 2
/* 0EF4C0 802CAB10 03E00008 */ jr $ra
/* 0EF4C4 802CAB14 27BD0030 */ addiu $sp, $sp, 0x30

View File

@ -418,7 +418,8 @@ typedef struct Camera {
/* 0x000 */ s16 flags;
/* 0x002 */ s16 moveFlags;
/* 0x004 */ s16 mode;
/* 0x006 */ char unk_06[4];
/* 0x006 */ u16 unk_06;
/* 0x008 */ u16 unk_08;
/* 0x00A */ s16 viewportW;
/* 0x00C */ s16 viewportH;
/* 0x00E */ s16 viewportStartX;
@ -427,7 +428,11 @@ typedef struct Camera {
/* 0x014 */ s16 farClip;
/* 0x016 */ char unk_16[2];
/* 0x018 */ f32 vfov;
/* 0x01C */ char unk_1C[14];
/* 0x01C */ s16 unk_1C;
/* 0x01E */ s16 unk_1E;
/* 0x020 */ s16 unk_20;
/* 0x022 */ s16 unk_22;
/* 0x024 */ char unk_24[6];
/* 0x02A */ s16 zoomPercent;
/* 0x02C */ s16 backgroundColor[3];
/* 0x032 */ s16 targetScreenCoords[3];
@ -435,7 +440,9 @@ typedef struct Camera {
/* 0x03A */ char unk_3A[2];
/* 0x03C */ f32 lookAt_eye[3];
/* 0x048 */ f32 lookAt_obj[3];
/* 0x054 */ char unk_54[12];
/* 0x054 */ f32 unk_54;
/* 0x058 */ f32 unk_58;
/* 0x05C */ f32 unk_5C;
/* 0x060 */ struct Vec3f targetPos;
/* 0x06C */ f32 currentYaw;
/* 0x070 */ char unk_70[4];

View File

@ -1,10 +1,96 @@
#include "common.h"
INCLUDE_API_ASM("code_ef070_len_3400", SetCamEnabled);
ApiStatus SetCamEnabled(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode enabled = get_variable(script, *ptrReadPos++);
if (!enabled) {
(&gCameras[id])->flags |= 0x2;
} else {
(&gCameras[id])->flags &= ~0x2;
}
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_ef070_len_3400", SetCamFlag80);
ApiStatus SetCamFlag80(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode enabled = get_variable(script, *ptrReadPos++);
INCLUDE_API_ASM("code_ef070_len_3400", SetCamPerspective);
if (!enabled) {
(&gCameras[id])->flags |= 0x80;
} else {
(&gCameras[id])->flags &= ~0x80;
}
return ApiStatus_DONE2;
}
ApiStatus SetCamPerspective(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode mode = get_variable(script, *ptrReadPos++);
f32 vfov = get_float_variable(script, *ptrReadPos++);
Bytecode nearClip = get_variable(script, *ptrReadPos++);
Bytecode farClip = get_variable(script, *ptrReadPos++);
(&gCameras[id])->farClip = farClip;
(&gCameras[id])->mode = mode;
(&gCameras[id])->unk_06 = 1;
(&gCameras[id])->unk_08 = 1;
(&gCameras[id])->vfov = vfov;
(&gCameras[id])->nearClip = nearClip;
return ApiStatus_DONE2;
}
ApiStatus func_802CA90C(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode mode = get_variable(script, *ptrReadPos++);
(&gCameras[id])->mode = mode;
(&gCameras[id])->unk_06 = 0;
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_ef070_len_3400", func_802CA988);
/*
ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode outVar1 = *ptrReadPos++;
Bytecode outVar2 = *ptrReadPos++;
Bytecode outVar3 = *ptrReadPos++;
Bytecode outVar4 = *ptrReadPos++;
f32 temp1, temp2, temp3;
f32 tempSqrt;
(&gCameras[id])->mode = 2;
(&gCameras[id])->unk_06 = 0;
(&gCameras[id])->unk_1C = -1 * round((&gCameras[id])->currentPitch);
(&gCameras[id])->unk_1E = -1 * (&gCameras[id])->currentBlendedYawNegated;
temp1 = (&gCameras[id])->lookAt_obj[0] - (&gCameras[id])->lookAt_eye[0];
temp2 = (&gCameras[id])->lookAt_obj[1] - (&gCameras[id])->lookAt_eye[1];
temp3 = (&gCameras[id])->lookAt_obj[2] - (&gCameras[id])->lookAt_eye[2];
tempSqrt = sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3));
if (tempSqrt != tempSqrt) {
(&gCameras[id])->unk_20 = round(tempSqrt);
}
(&gCameras[id])->unk_22 = 0;
(&gCameras[id])->unk_54 = (&gCameras[id])->lookAt_obj[0];
(&gCameras[id])->unk_58 = (&gCameras[id])->lookAt_obj[1];
(&gCameras[id])->unk_5C = (&gCameras[id])->lookAt_obj[2];
set_variable(script, outVar1, (&gCameras[id])->unk_1C);
set_variable(script, outVar2, (&gCameras[id])->unk_1E);
set_variable(script, outVar3, (&gCameras[id])->unk_20);
set_variable(script, outVar4, (&gCameras[id])->unk_22);
return ApiStatus_DONE2;
}
*/
INCLUDE_API_ASM("code_ef070_len_3400", SetCamViewport);

1
tools/n64splitter Submodule

@ -0,0 +1 @@
Subproject commit 678acb2ea026162039be6700486499db526dfba6