Merge pull request #29 from nanaian/match-floats

match commented functions which use floats
This commit is contained in:
Ethan Roseman 2020-08-18 15:43:05 -04:00 committed by GitHub
commit 5507d9f196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 89 deletions

View File

@ -1,27 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel fixed_var_to_float
/* 0E92D0 802C4920 3C02F2E3 */ lui $v0, 0xf2e3
/* 0E92D4 802C4924 34421100 */ ori $v0, $v0, 0x1100
/* 0E92D8 802C4928 0044102A */ slt $v0, $v0, $a0
/* 0E92DC 802C492C 10400005 */ beqz $v0, .L802C4944
/* 0E92E0 802C4930 3C020DB5 */ lui $v0, 0xdb5
/* 0E92E4 802C4934 44840000 */ mtc1 $a0, $f0
/* 0E92E8 802C4938 00000000 */ nop
/* 0E92EC 802C493C 03E00008 */ jr $ra
/* 0E92F0 802C4940 46800020 */ cvt.s.w $f0, $f0
.L802C4944:
/* 0E92F4 802C4944 34428580 */ ori $v0, $v0, 0x8580
/* 0E92F8 802C4948 00821021 */ addu $v0, $a0, $v0
/* 0E92FC 802C494C 3C013A80 */ lui $at, 0x3a80
/* 0E9300 802C4950 44811000 */ mtc1 $at, $f2
/* 0E9304 802C4954 44820000 */ mtc1 $v0, $f0
/* 0E9308 802C4958 00000000 */ nop
/* 0E930C 802C495C 46800020 */ cvt.s.w $f0, $f0
/* 0E9310 802C4960 46020002 */ mul.s $f0, $f0, $f2
/* 0E9314 802C4964 03E00008 */ jr $ra
/* 0E9318 802C4968 00000000 */ nop

View File

@ -1,17 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel float_to_fixed_var
/* 0E931C 802C496C 3C014480 */ lui $at, 0x4480
/* 0E9320 802C4970 44810000 */ mtc1 $at, $f0
/* 0E9324 802C4974 00000000 */ nop
/* 0E9328 802C4978 46006302 */ mul.s $f12, $f12, $f0
/* 0E932C 802C497C 00000000 */ nop
/* 0E9330 802C4980 3C03F24A */ lui $v1, 0xf24a
/* 0E9334 802C4984 34637A80 */ ori $v1, $v1, 0x7a80
/* 0E9338 802C4988 4600608D */ trunc.w.s $f2, $f12
/* 0E933C 802C498C 44021000 */ mfc1 $v0, $f2
/* 0E9340 802C4990 03E00008 */ jr $ra
/* 0E9344 802C4994 00431021 */ addu $v0, $v0, $v1

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_802D4CC4
/* 0F9674 802D4CC4 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F9678 802D4CC8 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F967C 802D4CCC 8C82000C */ lw $v0, 0xc($a0)
/* 0F9680 802D4CD0 0C0B1EAF */ jal get_variable
/* 0F9684 802D4CD4 8C450000 */ lw $a1, ($v0)
/* 0F9688 802D4CD8 04410004 */ bgez $v0, .L802D4CEC
/* 0F968C 802D4CDC 2404000A */ addiu $a0, $zero, 0xa
/* 0F9690 802D4CE0 3C05BF80 */ lui $a1, 0xbf80
/* 0F9694 802D4CE4 080B533F */ j .L802D4CFC
/* 0F9698 802D4CE8 240400FF */ addiu $a0, $zero, 0xff
.L802D4CEC:
/* 0F969C 802D4CEC 44820000 */ mtc1 $v0, $f0
/* 0F96A0 802D4CF0 00000000 */ nop
/* 0F96A4 802D4CF4 46800020 */ cvt.s.w $f0, $f0
/* 0F96A8 802D4CF8 44050000 */ mfc1 $a1, $f0
.L802D4CFC:
/* 0F96AC 802D4CFC 0C04DF69 */ jal func_80137DA4
/* 0F96B0 802D4D00 00000000 */ nop
/* 0F96B4 802D4D04 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F96B8 802D4D08 24020002 */ addiu $v0, $zero, 2
/* 0F96BC 802D4D0C 03E00008 */ jr $ra
/* 0F96C0 802D4D10 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -255,7 +255,7 @@ typedef struct ScriptInstance {
/* 0x14C */ u32 ownerID; /* can be an npcID, a triggerID, a trigger ptr */
/* 0x150 */ f32 timeScale;
/* 0x154 */ f32 frameCounter;
/* 0x158 */ char unk_158[4];
/* 0x158 */ s32 unk_158;
/* 0x15C */ Bytecode* ptrFirstLine;
/* 0x160 */ Bytecode* ptrSavedPosition;
/* 0x164 */ Bytecode* ptrCurrentLine;

View File

@ -19,25 +19,24 @@ INCLUDE_ASM(code_e79b0_len_1920, start_child_script);
INCLUDE_ASM(code_e79b0_len_1920, func_802C39F8);
INCLUDE_ASM(code_e79b0_len_1920, restart_script);
// TODO: Find out why things break when script->timeScale = 1 goes after the previous lines
/*
ScriptInstance* restart_script(ScriptInstance* script) {
script->loopDepth = -1;
script->switchDepth = -1;
script->currentOpcode = 0;
script->frameCounter = 0;
script->frameCounter = 0; // TODO: force compiler to not optimise away this
script->frameCounter = 0;
script->unk_158 = 0;
//script->timeScale = 1;
script->ptrNextLine = script->ptrFirstLine;
script->ptrCurrentLine = script->ptrFirstLine;
script->timeScale = 1.0f;
script->timeScale = gGlobalTimeSpace;
find_script_labels();
func_802C3390(script);
return script;
}
*/

View File

@ -1,17 +1,15 @@
#include "common.h"
INCLUDE_ASM(code_e92d0_len_5da0, fixed_var_to_float);
/*f32 fixed_var_to_float(s32 scriptVar) {
f32 fixed_var_to_float(s32 scriptVar) {
if (scriptVar <= -220000000) {
return (scriptVar + 230000000) * (1 / 1024.f);
return (scriptVar + 230000000) * (1 / 1024.0f);
}
return scriptVar;
}*/
}
INCLUDE_ASM(code_e92d0_len_5da0, float_to_fixed_var);
/*s32 float_to_fixed_var(f32 arg0) {
return (s32)(arg0 * (f32)1024.0f) + -230000000;
}*/
s32 float_to_fixed_var(f32 value) {
return (s32)(value * 1024.0f) - 230000000;
}
ApiStatus si_handle_return(ScriptInstance* script) {
kill_script(script);

View File

@ -222,8 +222,6 @@ ApiStatus func_802D4BDC(ScriptInstance* script, s32 initialCall) {
// Very similar to func_802D4BDC
INCLUDE_API_ASM(code_f8f60_len_1560, func_802D4C4C);
INCLUDE_API_ASM(code_f8f60_len_1560, func_802D4CC4);
/*
ApiStatus func_802D4CC4(ScriptInstance* script, s32 initialCall) {
s32 value = get_variable(script, *script->ptrReadPos);
if (value < 0) {
@ -234,7 +232,7 @@ ApiStatus func_802D4CC4(ScriptInstance* script, s32 initialCall) {
return ApiStatus_DONE2;
}
*/
ApiStatus func_802D4D18(ScriptInstance* script, s32 initialCall) {
s32 value = get_float_variable(script, *script->ptrReadPos);