diff --git a/asm/nonmatchings/code_303c0_len_3e10/func_80055F58.s b/asm/nonmatchings/code_303c0_len_3e10/func_80055F58.s deleted file mode 100644 index 9ec70efa82..0000000000 --- a/asm/nonmatchings/code_303c0_len_3e10/func_80055F58.s +++ /dev/null @@ -1,38 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80055F58 -/* 31358 80055F58 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 3135C 80055F5C AFB00018 */ sw $s0, 0x18($sp) -/* 31360 80055F60 00A0802D */ daddu $s0, $a1, $zero -/* 31364 80055F64 AFB1001C */ sw $s1, 0x1c($sp) -/* 31368 80055F68 00C0882D */ daddu $s1, $a2, $zero -/* 3136C 80055F6C 27A50010 */ addiu $a1, $sp, 0x10 -/* 31370 80055F70 27A60014 */ addiu $a2, $sp, 0x14 -/* 31374 80055F74 AFBF0024 */ sw $ra, 0x24($sp) -/* 31378 80055F78 0C01573A */ jal func_80055CE8 -/* 3137C 80055F7C AFB20020 */ sw $s2, 0x20($sp) -/* 31380 80055F80 0040902D */ daddu $s2, $v0, $zero -/* 31384 80055F84 1640000D */ bnez $s2, .L80055FBC -/* 31388 80055F88 0240102D */ daddu $v0, $s2, $zero -/* 3138C 80055F8C 2E220080 */ sltiu $v0, $s1, 0x80 -/* 31390 80055F90 50400001 */ beql $v0, $zero, .L80055F98 -/* 31394 80055F94 2411007F */ addiu $s1, $zero, 0x7f -.L80055F98: -/* 31398 80055F98 2E020010 */ sltiu $v0, $s0, 0x10 -/* 3139C 80055F9C 50400001 */ beql $v0, $zero, .L80055FA4 -/* 313A0 80055FA0 2410000F */ addiu $s0, $zero, 0xf -.L80055FA4: -/* 313A4 80055FA4 8FA40014 */ lw $a0, 0x14($sp) -/* 313A8 80055FA8 0200282D */ daddu $a1, $s0, $zero -/* 313AC 80055FAC 24060060 */ addiu $a2, $zero, 0x60 -/* 313B0 80055FB0 0C01420F */ jal func_8005083C -/* 313B4 80055FB4 322700FF */ andi $a3, $s1, 0xff -/* 313B8 80055FB8 0240102D */ daddu $v0, $s2, $zero -.L80055FBC: -/* 313BC 80055FBC 8FBF0024 */ lw $ra, 0x24($sp) -/* 313C0 80055FC0 8FB20020 */ lw $s2, 0x20($sp) -/* 313C4 80055FC4 8FB1001C */ lw $s1, 0x1c($sp) -/* 313C8 80055FC8 8FB00018 */ lw $s0, 0x18($sp) -/* 313CC 80055FCC 03E00008 */ jr $ra -/* 313D0 80055FD0 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/asm/nonmatchings/code_303c0_len_3e10/func_80055FD4.s b/asm/nonmatchings/code_303c0_len_3e10/func_80055FD4.s deleted file mode 100644 index 3bde86a368..0000000000 --- a/asm/nonmatchings/code_303c0_len_3e10/func_80055FD4.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80055FD4 -/* 313D4 80055FD4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 313D8 80055FD8 AFBF0010 */ sw $ra, 0x10($sp) -/* 313DC 80055FDC 0C0157D6 */ jal func_80055F58 -/* 313E0 80055FE0 0000302D */ daddu $a2, $zero, $zero -/* 313E4 80055FE4 8FBF0010 */ lw $ra, 0x10($sp) -/* 313E8 80055FE8 03E00008 */ jr $ra -/* 313EC 80055FEC 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_303c0_len_3e10/func_80055FF0.s b/asm/nonmatchings/code_303c0_len_3e10/func_80055FF0.s deleted file mode 100644 index 3c2b7ba36f..0000000000 --- a/asm/nonmatchings/code_303c0_len_3e10/func_80055FF0.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80055FF0 -/* 313F0 80055FF0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 313F4 80055FF4 AFBF0010 */ sw $ra, 0x10($sp) -/* 313F8 80055FF8 0C0157D6 */ jal func_80055F58 -/* 313FC 80055FFC 2406003F */ addiu $a2, $zero, 0x3f -/* 31400 80056000 8FBF0010 */ lw $ra, 0x10($sp) -/* 31404 80056004 03E00008 */ jr $ra -/* 31408 80056008 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_303c0_len_3e10/func_8005600C.s b/asm/nonmatchings/code_303c0_len_3e10/func_8005600C.s deleted file mode 100644 index 22e31486e7..0000000000 --- a/asm/nonmatchings/code_303c0_len_3e10/func_8005600C.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8005600C -/* 3140C 8005600C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 31410 80056010 AFBF0010 */ sw $ra, 0x10($sp) -/* 31414 80056014 0C0157D6 */ jal func_80055F58 -/* 31418 80056018 2406007F */ addiu $a2, $zero, 0x7f -/* 3141C 8005601C 8FBF0010 */ lw $ra, 0x10($sp) -/* 31420 80056020 03E00008 */ jr $ra -/* 31424 80056024 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/format.sh b/format.sh index 7ce4d215ff..ba64effa51 100755 --- a/format.sh +++ b/format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash COMPILER_OPTS="-std=gnu89 -Iinclude -Isrc -D_LANGUAGE_C -DSCRIPT(...)={}" diff --git a/src/audio.h b/src/audio.h index 87a24c5d44..640b548728 100644 --- a/src/audio.h +++ b/src/audio.h @@ -382,8 +382,8 @@ void func_8004E158(UnkAlA9C*, s32, s32, UnkAl19E0*); void func_8004E3A4(UnkAlA9C*); void func_8004E444(UnkAlA9C*); s16 func_8004E4B8(UnkAlA9C*); -void func_80056068(s32, u8); -void func_800506C8(s32, s32); +s32 func_80056068(s32, u8); +s32 func_800506C8(s32, s32); s32 func_80050C30(u32); void func_800511BC(UnkAl834*); @@ -404,9 +404,11 @@ void func_80054CE0(s32, s32); void func_8005610C(void); void func_80055110(UnkAlA9C*); -void func_80056028(s32, u8); -void func_80056044(s32, u8); -void func_80056068(s32, u8); +s32 func_80055FF0(s32, s32); +s32 func_8005600C(s32, s32); +s32 func_80056028(s32, u8); +s32 func_80056044(s32, u8); +s32 func_80056068(s32, u8); void func_8005608C(s32*, s32*); void func_800560A8(void); void func_8005610C(void); diff --git a/src/code_25f00_len_940.c b/src/code_25f00_len_940.c index 7b36a5c16c..f46f1710b7 100644 --- a/src/code_25f00_len_940.c +++ b/src/code_25f00_len_940.c @@ -19,7 +19,7 @@ INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AE08); s32 nuAuDmaCallBack(s32 addr, s32 len, void* state); INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaCallBack, s32 addr, s32 len, void* state); -ALDMAproc nuAuDmaNew(NUDMAState **state) { +ALDMAproc nuAuDmaNew(NUDMAState** state) { if (!nuAuDmaState.initialized) { nuAuDmaState.firstFree = &nuAuDmaBuf; nuAuDmaState.firstUsed = NULL; diff --git a/src/code_26840_len_20d0.c b/src/code_26840_len_20d0.c index a2a99109a8..91f048f574 100644 --- a/src/code_26840_len_20d0.c +++ b/src/code_26840_len_20d0.c @@ -5,7 +5,7 @@ INCLUDE_ASM(void, "code_26840_len_20d0", func_8004B440, UnkAl6CC* arg0, u8 arg1, INCLUDE_ASM(void, "code_26840_len_20d0", func_8004B62C, UnkAl6CC* arg0); -void func_8004B698(UnkAl6CC *arg0) { +void func_8004B698(UnkAl6CC* arg0) { s32 i; for (i = 0; i < ARRAY_COUNT(arg0->unk_C2); i++) { @@ -22,7 +22,7 @@ void func_8004B698(UnkAl6CC *arg0) { arg0->unk_162 = 0; } -void func_8004B6D8(UnkAl6CC *arg0, s32 arg1, s16 arg2, s16 arg3, u8 arg4) { +void func_8004B6D8(UnkAl6CC* arg0, s32 arg1, s16 arg2, s16 arg3, u8 arg4) { u8 temp_v1 = arg0->unk_164; s32 temp_v0 = temp_v1 - (u8) arg0->unk_163; u32 temp_t0; @@ -51,7 +51,7 @@ void func_8004B6D8(UnkAl6CC *arg0, s32 arg1, s16 arg2, s16 arg3, u8 arg4) { INCLUDE_ASM(void, "code_26840_len_20d0", func_8004B748, UnkAl6CC* arg0); -s32 func_8004B9E4(UnkAl6CC *arg0, s32 arg1) { +s32 func_8004B9E4(UnkAl6CC* arg0, s32 arg1) { s32 a1 = (u8) arg1; if (a1 != 0xF0) { diff --git a/src/code_28910_len_5090.c b/src/code_28910_len_5090.c index 980fa48ab5..43aa7431da 100644 --- a/src/code_28910_len_5090.c +++ b/src/code_28910_len_5090.c @@ -78,7 +78,7 @@ INCLUDE_ASM(void, "code_28910_len_5090", func_8004E158, UnkAlA9C* arg0, s32 arg1 INCLUDE_ASM(s32, "code_28910_len_5090", func_8004E344); -void func_8004E3A4(UnkAlA9C *arg0) { +void func_8004E3A4(UnkAlA9C* arg0) { arg0->unk_2C.unk_0A--; if (arg0->unk_2C.unk_0A != 0) { @@ -186,7 +186,7 @@ INCLUDE_ASM(s32, "code_28910_len_5090", func_80050654); INCLUDE_ASM(s32, "code_28910_len_5090", func_8005068C); -INCLUDE_ASM(void, "code_28910_len_5090", func_800506C8, s32 arg0, s32 arg1); +INCLUDE_ASM(s32, "code_28910_len_5090", func_800506C8, s32 arg0, s32 arg1); INCLUDE_ASM(s32, "code_28910_len_5090", func_80050770); diff --git a/src/code_2e230_len_2190.c b/src/code_2e230_len_2190.c index 500e99eaa8..dcc59a3422 100644 --- a/src/code_2e230_len_2190.c +++ b/src/code_2e230_len_2190.c @@ -274,7 +274,7 @@ void func_800535C0(void) { func_8004B748(temp_s2); } -void func_80053654(UnkAl19E0 *arg0) { +void func_80053654(UnkAl19E0* arg0) { u32 i; if (arg0->unk_130C == 2) { @@ -309,7 +309,7 @@ void func_80053654(UnkAl19E0 *arg0) { func_80056DCC(1, arg0->unk_40[1].unk_00); arg0->unk_40[1].unk_01 = 0; - }if (arg0->unk_40[2].unk_01 != 0) { + } if (arg0->unk_40[2].unk_01 != 0) { func_80056DCC(2, arg0->unk_40[2].unk_00); arg0->unk_40[2].unk_01 = 0; } @@ -390,7 +390,7 @@ void func_80053A28(UnkAl1* arg0) { } void func_80053A98(u8 arg0, u16 arg1, s32 arg2) { - func_80056D78(arg0, (u32) (arg1 * arg2) >> 15); + func_80056D78(arg0, (u32)(arg1 * arg2) >> 15); } void func_80053AC8(UnkAl1* arg0) { @@ -408,7 +408,7 @@ void func_80053AEC(UnkAl1* arg0, s16 arg1) { arg0->unk_14 = 0; } -void func_80053B04(UnkAl1 *arg0, u32 arg1, s16 arg2) { +void func_80053B04(UnkAl1* arg0, u32 arg1, s16 arg2) { s16 temp_a0; s32 temp_v1; @@ -425,7 +425,7 @@ void func_80053B04(UnkAl1 *arg0, u32 arg1, s16 arg2) { } } -void func_80053BA8(UnkAl1 *arg0) { +void func_80053BA8(UnkAl1* arg0) { arg0->unk_1A--; if (arg0->unk_1A != 0) { diff --git a/src/code_303c0_len_3e10.c b/src/code_303c0_len_3e10.c index 517097c11c..63b9cfdf61 100644 --- a/src/code_303c0_len_3e10.c +++ b/src/code_303c0_len_3e10.c @@ -22,7 +22,7 @@ void func_80055050(void) { INCLUDE_ASM(void, "code_303c0_len_3e10", func_80055068, u32 arg0); -void func_80055110(UnkAlA9C *arg0) { +void func_80055110(UnkAlA9C* arg0) { s32 i; for (i = 0; i < 8; i++) { @@ -335,7 +335,7 @@ INCLUDE_ASM(s32, "code_303c0_len_3e10", func_80055E48); s32* func_80055EB4(s32 arg0) { s32* ret = NULL; - switch(arg0) { + switch (arg0) { case 0: ret = &D_80078DB8; break; @@ -368,28 +368,49 @@ s32* func_80055EB4(s32 arg0) { INCLUDE_ASM(s32, "code_303c0_len_3e10", func_80055EB4); #endif -INCLUDE_ASM(s32, "code_303c0_len_3e10", func_80055F58); +s32 func_80055F58(s32 arg0, u32 arg1, u32 arg2) { + s32* subroutine_arg4; + s32* subroutine_arg5; + s32 temp_s2 = func_80055CE8(arg0, &subroutine_arg4, &subroutine_arg5); -INCLUDE_ASM(s32, "code_303c0_len_3e10", func_80055FD4); - -INCLUDE_ASM(s32, "code_303c0_len_3e10", func_80055FF0); - -INCLUDE_ASM(s32, "code_303c0_len_3e10", func_8005600C); - -void func_80056028(s32 arg0, u8 arg1) { - func_800506C8(arg0, arg1); + if (temp_s2 == 0) { + if (arg2 > 0x7F) { + arg2 = 0x7F; + } + if (arg1 > 0xF) { + arg1 = 0xF; + } + func_8005083C(subroutine_arg5, arg1, 0x60, (u8)arg2); // todo remove cast when func is defined + } + return temp_s2; } -void func_80056044(s32 arg0, u8 arg1) { - func_800506C8(arg0, arg1 | 0x57000000); +s32 func_80055FD4(s32 arg0, s32 arg1) { + return func_80055F58(arg0, arg1, 0); } -void func_80056068(s32 arg0, u8 arg1) { - func_800506C8(arg0, arg1 | 0x7F000000); +s32 func_80055FF0(s32 arg0, s32 arg1) { + return func_80055F58(arg0, arg1, 0x3F); } -void func_8005608C(s32 *arg0, s32 *arg1) { - UnkAl19E0 *temp_v0 = D_8009A5C0; +s32 func_8005600C(s32 arg0, s32 arg1) { + return func_80055F58(arg0, arg1, 0x7F); +} + +s32 func_80056028(s32 arg0, u8 arg1) { + return func_800506C8(arg0, arg1); +} + +s32 func_80056044(s32 arg0, u8 arg1) { + return func_800506C8(arg0, arg1 | 0x57000000); +} + +s32 func_80056068(s32 arg0, u8 arg1) { + return func_800506C8(arg0, arg1 | 0x7F000000); +} + +void func_8005608C(s32* arg0, s32* arg1) { + UnkAl19E0* temp_v0 = D_8009A5C0; *arg0 = temp_v0->unk_94; *arg1 = temp_v0->unk_98; diff --git a/src/code_31650.c b/src/code_31650.c index 87c4e710c2..fd92e57395 100644 --- a/src/code_31650.c +++ b/src/code_31650.c @@ -7,15 +7,16 @@ s8 D_80078E58 = 0; s16 D_80078E5A = 0x7FFF; s8 D_80078E5C = 0; s32 D_80078E60[] = { 0x7FFF7FFC, 0x7FF57FE8, 0x7FD77FC0, 0x7FA57F84, 0x7F5F7F34, 0x7F057ED0, 0x7E977E58, 0x7E157DCD, - 0x7D7F7D2D, 0x7CD67C7A, 0x7C1A7BB4, 0x7B497ADA, 0x7A6679ED, 0x796F78ED, 0x786677DA, 0x774976B4, 0x761A757B, - 0x74D87430, 0x738472D3, 0x721E7164, 0x70A66FE3, 0x6F1C6E51, 0x6D816CAD, 0x6BD56AF9, 0x6A186933, 0x684A675D, - 0x666C6577, 0x647E6381, 0x6280617C, 0x60735F67, 0x5E575D43, 0x5C2C5B11, }; + 0x7D7F7D2D, 0x7CD67C7A, 0x7C1A7BB4, 0x7B497ADA, 0x7A6679ED, 0x796F78ED, 0x786677DA, 0x774976B4, 0x761A757B, + 0x74D87430, 0x738472D3, 0x721E7164, 0x70A66FE3, 0x6F1C6E51, 0x6D816CAD, 0x6BD56AF9, 0x6A186933, 0x684A675D, + 0x666C6577, 0x647E6381, 0x6280617C, 0x60735F67, 0x5E575D43, 0x5C2C5B11, + }; INCLUDE_ASM(s32, "code_31650", func_80056250); void func_800565A4(void) { - s32 *sym = &D_80078E50; + s32* sym = &D_80078E50; if (*sym != 0) { *sym = 0; @@ -73,7 +74,8 @@ void func_80056F78(u8 arg0) { al7C->unk_70 = 1; } -INCLUDE_ASM(void, "code_31650", func_80056FA4, u8 arg0, u8 arg1, s32 arg2, f32 arg3, s16 arg4, u8 arg5, u8 arg6, s32 arg7); +INCLUDE_ASM(void, "code_31650", func_80056FA4, u8 arg0, u8 arg1, s32 arg2, f32 arg3, s16 arg4, u8 arg5, u8 arg6, + s32 arg7); INCLUDE_ASM(void, "code_31650", func_80057224, u8 arg0, UnkAl30* arg1); @@ -161,7 +163,7 @@ INCLUDE_ASM(s32, "code_31650", func_80057ED0); INCLUDE_ASM(s32, "code_31650", func_80057F20); -void* alHeapAlloc(ALHeap *heap, s32 arg1, s32 size) { +void* alHeapAlloc(ALHeap* heap, s32 arg1, s32 size) { void* ret = NULL; u8* newCur = &heap->cur[ALIGN16(arg1 * size)];