diff --git a/src/entity/Chest.c b/src/entity/Chest.c index b87e59daac..cabd941414 100644 --- a/src/entity/Chest.c +++ b/src/entity/Chest.c @@ -103,46 +103,45 @@ void entity_Chest_begin_opening(Entity* entity) { INCLUDE_ASM(s32, "entity/Chest", entity_Chest_open); -// regalloc after sin_rad -#ifdef NON_MATCHING void entity_Chest_close(Entity* entity) { Chest* data = (Chest*)entity->dataBuf; + f32 delta; + switch (data->unk_04) { - case 0: - data->unk_0C = 0.0f; - data->unk_04++; - // fallthrough - case 1: - data->unk_0C += 5.0f; - if (data->unk_0C >= 180.0f) { - data->unk_0C = 180.0f; - data->unk_04++; - } - data->unk_08 += 2.6f * sin_rad(data->unk_0C * TAU / 360.0f); - break; - case 2: - data->unk_0C += 1.0f; - if (data->unk_0C >= 185.0f) { - data->unk_0C = 185.0f; - data->unk_06 = 10; - data->unk_04++; - } - data->unk_08 += 2.0f * sin_rad(data->unk_0C * TAU / 360.0f); - break; - case 3: - data->unk_06--; - if (data->unk_06 == 0) { - data->unk_04++; - entity->flags |= 0x4000; - } - break; - case 4: // needed to make gcc create a jumptable - break; + case 0: + data->unk_0C = 0.0f; + data->unk_04++; + // fallthrough + case 1: + data->unk_0C += 5.0f; + if (data->unk_0C >= 180.0f) { + data->unk_0C = 180.0f; + data->unk_04++; + } + delta = 2.6f * sin_rad(data->unk_0C * TAU / 360.0f); + data->unk_08 += delta; + break; + case 2: + data->unk_0C += 1.0f; + if (data->unk_0C >= 185.0f) { + data->unk_0C = 185.0f; + data->unk_06 = 10; + data->unk_04++; + } + delta = 2.0f * sin_rad(data->unk_0C * TAU / 360.0f); + data->unk_08 += delta; + break; + case 3: + data->unk_06--; + if (data->unk_06 == 0) { + data->unk_04++; + entity->flags |= 0x4000; + } + break; + case 4: + break; } } -#else -INCLUDE_ASM(s32, "entity/Chest", entity_Chest_close); -#endif INCLUDE_ASM(s32, "entity/Chest", entity_GiantChest_hide_effect); diff --git a/ver/us/asm/nonmatchings/entity/Chest/entity_Chest_close.s b/ver/us/asm/nonmatchings/entity/Chest/entity_Chest_close.s deleted file mode 100644 index fe8dec53d8..0000000000 --- a/ver/us/asm/nonmatchings/entity/Chest/entity_Chest_close.s +++ /dev/null @@ -1,120 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.section .rodata - -glabel jtbl_802EB308 -.word L802E7460_108CE0, L802E7470_108CF0, L802E74F8_108D78, L802E7580_108E00, L802E75B0_108E30, 0 - -.section .text - -glabel entity_Chest_close -/* 108CAC 802E742C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 108CB0 802E7430 AFBF0014 */ sw $ra, 0x14($sp) -/* 108CB4 802E7434 AFB00010 */ sw $s0, 0x10($sp) -/* 108CB8 802E7438 8C900040 */ lw $s0, 0x40($a0) -/* 108CBC 802E743C 92030004 */ lbu $v1, 4($s0) -/* 108CC0 802E7440 2C620005 */ sltiu $v0, $v1, 5 -/* 108CC4 802E7444 1040005A */ beqz $v0, L802E75B0_108E30 -/* 108CC8 802E7448 00031080 */ sll $v0, $v1, 2 -/* 108CCC 802E744C 3C01802F */ lui $at, %hi(jtbl_802EB308) -/* 108CD0 802E7450 00220821 */ addu $at, $at, $v0 -/* 108CD4 802E7454 8C22B308 */ lw $v0, %lo(jtbl_802EB308)($at) -/* 108CD8 802E7458 00400008 */ jr $v0 -/* 108CDC 802E745C 00000000 */ nop -glabel L802E7460_108CE0 -/* 108CE0 802E7460 92020004 */ lbu $v0, 4($s0) -/* 108CE4 802E7464 AE00000C */ sw $zero, 0xc($s0) -/* 108CE8 802E7468 24420001 */ addiu $v0, $v0, 1 -/* 108CEC 802E746C A2020004 */ sb $v0, 4($s0) -glabel L802E7470_108CF0 -/* 108CF0 802E7470 C600000C */ lwc1 $f0, 0xc($s0) -/* 108CF4 802E7474 3C0140A0 */ lui $at, 0x40a0 -/* 108CF8 802E7478 44811000 */ mtc1 $at, $f2 -/* 108CFC 802E747C 00000000 */ nop -/* 108D00 802E7480 46020000 */ add.s $f0, $f0, $f2 -/* 108D04 802E7484 3C014334 */ lui $at, 0x4334 -/* 108D08 802E7488 44811000 */ mtc1 $at, $f2 -/* 108D0C 802E748C 00000000 */ nop -/* 108D10 802E7490 4600103E */ c.le.s $f2, $f0 -/* 108D14 802E7494 00000000 */ nop -/* 108D18 802E7498 45000005 */ bc1f .L802E74B0 -/* 108D1C 802E749C E600000C */ swc1 $f0, 0xc($s0) -/* 108D20 802E74A0 92020004 */ lbu $v0, 4($s0) -/* 108D24 802E74A4 E602000C */ swc1 $f2, 0xc($s0) -/* 108D28 802E74A8 24420001 */ addiu $v0, $v0, 1 -/* 108D2C 802E74AC A2020004 */ sb $v0, 4($s0) -.L802E74B0: -/* 108D30 802E74B0 C60C000C */ lwc1 $f12, 0xc($s0) -/* 108D34 802E74B4 3C0140C9 */ lui $at, 0x40c9 -/* 108D38 802E74B8 34210FD0 */ ori $at, $at, 0xfd0 -/* 108D3C 802E74BC 44810000 */ mtc1 $at, $f0 -/* 108D40 802E74C0 00000000 */ nop -/* 108D44 802E74C4 46006302 */ mul.s $f12, $f12, $f0 -/* 108D48 802E74C8 00000000 */ nop -/* 108D4C 802E74CC 3C0143B4 */ lui $at, 0x43b4 -/* 108D50 802E74D0 44810000 */ mtc1 $at, $f0 -/* 108D54 802E74D4 0C00A85B */ jal sin_rad -/* 108D58 802E74D8 46006303 */ div.s $f12, $f12, $f0 -/* 108D5C 802E74DC 3C014026 */ lui $at, 0x4026 -/* 108D60 802E74E0 34216666 */ ori $at, $at, 0x6666 -/* 108D64 802E74E4 44811000 */ mtc1 $at, $f2 -/* 108D68 802E74E8 00000000 */ nop -/* 108D6C 802E74EC 46020082 */ mul.s $f2, $f0, $f2 -/* 108D70 802E74F0 080B9D5C */ j .L802E7570 -/* 108D74 802E74F4 00000000 */ nop -glabel L802E74F8_108D78 -/* 108D78 802E74F8 C600000C */ lwc1 $f0, 0xc($s0) -/* 108D7C 802E74FC 3C013F80 */ lui $at, 0x3f80 -/* 108D80 802E7500 44811000 */ mtc1 $at, $f2 -/* 108D84 802E7504 00000000 */ nop -/* 108D88 802E7508 46020000 */ add.s $f0, $f0, $f2 -/* 108D8C 802E750C 3C014339 */ lui $at, 0x4339 -/* 108D90 802E7510 44811000 */ mtc1 $at, $f2 -/* 108D94 802E7514 00000000 */ nop -/* 108D98 802E7518 4600103E */ c.le.s $f2, $f0 -/* 108D9C 802E751C 00000000 */ nop -/* 108DA0 802E7520 45000007 */ bc1f .L802E7540 -/* 108DA4 802E7524 E600000C */ swc1 $f0, 0xc($s0) -/* 108DA8 802E7528 92020004 */ lbu $v0, 4($s0) -/* 108DAC 802E752C 2403000A */ addiu $v1, $zero, 0xa -/* 108DB0 802E7530 E602000C */ swc1 $f2, 0xc($s0) -/* 108DB4 802E7534 A2030006 */ sb $v1, 6($s0) -/* 108DB8 802E7538 24420001 */ addiu $v0, $v0, 1 -/* 108DBC 802E753C A2020004 */ sb $v0, 4($s0) -.L802E7540: -/* 108DC0 802E7540 C60C000C */ lwc1 $f12, 0xc($s0) -/* 108DC4 802E7544 3C0140C9 */ lui $at, 0x40c9 -/* 108DC8 802E7548 34210FD0 */ ori $at, $at, 0xfd0 -/* 108DCC 802E754C 44810000 */ mtc1 $at, $f0 -/* 108DD0 802E7550 00000000 */ nop -/* 108DD4 802E7554 46006302 */ mul.s $f12, $f12, $f0 -/* 108DD8 802E7558 00000000 */ nop -/* 108DDC 802E755C 3C0143B4 */ lui $at, 0x43b4 -/* 108DE0 802E7560 44810000 */ mtc1 $at, $f0 -/* 108DE4 802E7564 0C00A85B */ jal sin_rad -/* 108DE8 802E7568 46006303 */ div.s $f12, $f12, $f0 -/* 108DEC 802E756C 46000080 */ add.s $f2, $f0, $f0 -.L802E7570: -/* 108DF0 802E7570 C6000008 */ lwc1 $f0, 8($s0) -/* 108DF4 802E7574 46020000 */ add.s $f0, $f0, $f2 -/* 108DF8 802E7578 080B9D6C */ j L802E75B0_108E30 -/* 108DFC 802E757C E6000008 */ swc1 $f0, 8($s0) -glabel L802E7580_108E00 -/* 108E00 802E7580 92020006 */ lbu $v0, 6($s0) -/* 108E04 802E7584 2442FFFF */ addiu $v0, $v0, -1 -/* 108E08 802E7588 A2020006 */ sb $v0, 6($s0) -/* 108E0C 802E758C 00021600 */ sll $v0, $v0, 0x18 -/* 108E10 802E7590 14400007 */ bnez $v0, L802E75B0_108E30 -/* 108E14 802E7594 00000000 */ nop -/* 108E18 802E7598 92020004 */ lbu $v0, 4($s0) -/* 108E1C 802E759C 24420001 */ addiu $v0, $v0, 1 -/* 108E20 802E75A0 A2020004 */ sb $v0, 4($s0) -/* 108E24 802E75A4 8C820000 */ lw $v0, ($a0) -/* 108E28 802E75A8 34424000 */ ori $v0, $v0, 0x4000 -/* 108E2C 802E75AC AC820000 */ sw $v0, ($a0) -glabel L802E75B0_108E30 -/* 108E30 802E75B0 8FBF0014 */ lw $ra, 0x14($sp) -/* 108E34 802E75B4 8FB00010 */ lw $s0, 0x10($sp) -/* 108E38 802E75B8 03E00008 */ jr $ra -/* 108E3C 802E75BC 27BD0018 */ addiu $sp, $sp, 0x18