1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00

Finish z_lib.c

This commit is contained in:
wed 2020-03-20 08:48:38 +11:00
parent c5f388b2ac
commit a01f868a1a
4 changed files with 10 additions and 128 deletions

View file

@ -1,26 +0,0 @@
glabel Lib_MemSet
/* AEE980 800777E0 AFA60008 */ sw $a2, 8($sp)
/* AEE984 800777E4 30C600FF */ andi $a2, $a2, 0xff
/* AEE988 800777E8 10A00010 */ beqz $a1, .L8007782C
/* AEE98C 800777EC 00001025 */ move $v0, $zero
/* AEE990 800777F0 30A70003 */ andi $a3, $a1, 3
/* AEE994 800777F4 10E00006 */ beqz $a3, .L80077810
/* AEE998 800777F8 00E01825 */ move $v1, $a3
.L800777FC:
/* AEE99C 800777FC 24420001 */ addiu $v0, $v0, 1
/* AEE9A0 80077800 A0860000 */ sb $a2, ($a0)
/* AEE9A4 80077804 1462FFFD */ bne $v1, $v0, .L800777FC
/* AEE9A8 80077808 24840001 */ addiu $a0, $a0, 1
/* AEE9AC 8007780C 10450007 */ beq $v0, $a1, .L8007782C
.L80077810:
/* AEE9B0 80077810 24420004 */ addiu $v0, $v0, 4
/* AEE9B4 80077814 A0860000 */ sb $a2, ($a0)
/* AEE9B8 80077818 A0860001 */ sb $a2, 1($a0)
/* AEE9BC 8007781C A0860002 */ sb $a2, 2($a0)
/* AEE9C0 80077820 A0860003 */ sb $a2, 3($a0)
/* AEE9C4 80077824 1445FFFA */ bne $v0, $a1, .L80077810
/* AEE9C8 80077828 24840004 */ addiu $a0, $a0, 4
.L8007782C:
/* AEE9CC 8007782C 03E00008 */ jr $ra
/* AEE9D0 80077830 00000000 */ nop

View file

@ -1,82 +0,0 @@
glabel Math_SmoothScaleMaxMinS
/* AEF83C 8007869C AFA50004 */ sw $a1, 4($sp)
/* AEF840 800786A0 AFA60008 */ sw $a2, 8($sp)
/* AEF844 800786A4 AFA7000C */ sw $a3, 0xc($sp)
/* AEF848 800786A8 84880000 */ lh $t0, ($a0)
/* AEF84C 800786AC 00052C00 */ sll $a1, $a1, 0x10
/* AEF850 800786B0 00052C03 */ sra $a1, $a1, 0x10
/* AEF854 800786B4 00A81823 */ subu $v1, $a1, $t0
/* AEF858 800786B8 00063400 */ sll $a2, $a2, 0x10
/* AEF85C 800786BC 00031C00 */ sll $v1, $v1, 0x10
/* AEF860 800786C0 00063403 */ sra $a2, $a2, 0x10
/* AEF864 800786C4 10A8003B */ beq $a1, $t0, .L800787B4
/* AEF868 800786C8 00031C03 */ sra $v1, $v1, 0x10
/* AEF86C 800786CC 0066001A */ div $zero, $v1, $a2
/* AEF870 800786D0 87A90012 */ lh $t1, 0x12($sp)
/* AEF874 800786D4 14C00002 */ bnez $a2, .L800786E0
/* AEF878 800786D8 00000000 */ nop
/* AEF87C 800786DC 0007000D */ break 7
.L800786E0:
/* AEF880 800786E0 2401FFFF */ li $at, -1
/* AEF884 800786E4 14C10004 */ bne $a2, $at, .L800786F8
/* AEF888 800786E8 3C018000 */ lui $at, 0x8000
/* AEF88C 800786EC 14610002 */ bne $v1, $at, .L800786F8
/* AEF890 800786F0 00000000 */ nop
/* AEF894 800786F4 0006000D */ break 6
.L800786F8:
/* AEF898 800786F8 00003812 */ mflo $a3
/* AEF89C 800786FC 00075400 */ sll $t2, $a3, 0x10
/* AEF8A0 80078700 000A5403 */ sra $t2, $t2, 0x10
/* AEF8A4 80078704 00071400 */ sll $v0, $a3, 0x10
/* AEF8A8 80078708 012A082A */ slt $at, $t1, $t2
/* AEF8AC 8007870C 14200005 */ bnez $at, .L80078724
/* AEF8B0 80078710 00021403 */ sra $v0, $v0, 0x10
/* AEF8B4 80078714 00097023 */ negu $t6, $t1
/* AEF8B8 80078718 014E082A */ slt $at, $t2, $t6
/* AEF8BC 8007871C 10200010 */ beqz $at, .L80078760
/* AEF8C0 80078720 00000000 */ nop
.L80078724:
/* AEF8C4 80078724 87AF000E */ lh $t7, 0xe($sp)
/* AEF8C8 80078728 87A5000E */ lh $a1, 0xe($sp)
/* AEF8CC 8007872C 01EA082A */ slt $at, $t7, $t2
/* AEF8D0 80078730 10200002 */ beqz $at, .L8007873C
/* AEF8D4 80078734 00052823 */ negu $a1, $a1
/* AEF8D8 80078738 01E01025 */ move $v0, $t7
.L8007873C:
/* AEF8DC 8007873C 0045082A */ slt $at, $v0, $a1
/* AEF8E0 80078740 50200004 */ beql $at, $zero, .L80078754
/* AEF8E4 80078744 0102C021 */ addu $t8, $t0, $v0
/* AEF8E8 80078748 00051400 */ sll $v0, $a1, 0x10
/* AEF8EC 8007874C 00021403 */ sra $v0, $v0, 0x10
/* AEF8F0 80078750 0102C021 */ addu $t8, $t0, $v0
.L80078754:
/* AEF8F4 80078754 A4980000 */ sh $t8, ($a0)
/* AEF8F8 80078758 03E00008 */ jr $ra
/* AEF8FC 8007875C 00601025 */ move $v0, $v1
.L80078760:
/* AEF900 80078760 0460000C */ bltz $v1, .L80078794
/* AEF904 80078764 01097823 */ subu $t7, $t0, $t1
/* AEF908 80078768 0109C821 */ addu $t9, $t0, $t1
/* AEF90C 8007876C A4990000 */ sh $t9, ($a0)
/* AEF910 80078770 848B0000 */ lh $t3, ($a0)
/* AEF914 80078774 00601025 */ move $v0, $v1
/* AEF918 80078778 00AB6023 */ subu $t4, $a1, $t3
/* AEF91C 8007877C 000C6C00 */ sll $t5, $t4, 0x10
/* AEF920 80078780 000D7403 */ sra $t6, $t5, 0x10
/* AEF924 80078784 1DC0000B */ bgtz $t6, .L800787B4
/* AEF928 80078788 00000000 */ nop
/* AEF92C 8007878C 03E00008 */ jr $ra
/* AEF930 80078790 A4850000 */ sh $a1, ($a0)
.L80078794:
/* AEF934 80078794 A48F0000 */ sh $t7, ($a0)
/* AEF938 80078798 84980000 */ lh $t8, ($a0)
/* AEF93C 8007879C 00B8C823 */ subu $t9, $a1, $t8
/* AEF940 800787A0 00195C00 */ sll $t3, $t9, 0x10
/* AEF944 800787A4 000B6403 */ sra $t4, $t3, 0x10
/* AEF948 800787A8 05800002 */ bltz $t4, .L800787B4
/* AEF94C 800787AC 00000000 */ nop
/* AEF950 800787B0 A4850000 */ sh $a1, ($a0)
.L800787B4:
/* AEF954 800787B4 03E00008 */ jr $ra
/* AEF958 800787B8 00601025 */ move $v0, $v1

View file

@ -846,7 +846,7 @@ void func_800775D8();
s32 func_800775E4();
void func_800775F0(u16);
// ? func_80077600(?);
void Lib_MemSet(void* dest, size_t size, u8 val);
void Lib_MemSet(u8 dest[], size_t size, u8 val);
f32 Math_Coss(s16 angle);
f32 Math_Sins(s16 angle);
s32 Math_ApproxUpdateScaledS(s16* fp, s16 target, s16 step);

View file

@ -1,20 +1,16 @@
#include <ultra64.h>
#include <global.h>
#ifdef NON_MATCHING
void Lib_MemSet(void* dest, size_t size, u8 val)
void Lib_MemSet(u8 dest[], size_t size, u8 val)
{
u8* destu = dest;
u32 i;
size_t i = 0;
for (i = 0; i < size; i++)
{
*destu++ = val;
}
if (i == size) return;
do {
*dest++ = val;
i++;
} while (i != size);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_lib/Lib_MemSet.s")
#endif
f32 Math_Coss(s16 angle)
{
@ -559,15 +555,12 @@ f32 func_800784D8(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep)
return step;
}
#ifdef NON_MATCHING
// regalloc differences
s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep, s16 minStep)
{
s16 step = 0;
s16 diff = (target - *pValue);
s32 baseStep;
s16 step;
baseStep = diff / invScale;
s32 baseStep = diff / invScale;
if (*pValue != target)
{
@ -604,9 +597,6 @@ s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep,
return diff;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_lib/Math_SmoothScaleMaxMinS.s")
#endif
void Math_SmoothScaleMaxS(s16* pValue, s16 target, s16 invScale, s16 maxStep)
{