This commit is contained in:
Ethan Roseman 2021-01-17 23:40:02 +09:00
parent 5aad7d8e41
commit 545a655d40
6 changed files with 105 additions and 196 deletions

View File

@ -11,7 +11,8 @@
"-DSCRIPT(...)={}",
],
"clang-tidy.blacklist": [
"include/PR"
"include/PR",
"include/gcc"
],
"git.ignoreLimitWarning": true,
"search.exclude": {

View File

@ -1,102 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel OnDefeatEnemy
/* 1A980 8003F580 27BDFFC8 */ addiu $sp, $sp, -0x38
/* 1A984 8003F584 AFB20028 */ sw $s2, 0x28($sp)
/* 1A988 8003F588 0080902D */ daddu $s2, $a0, $zero
/* 1A98C 8003F58C AFBF0030 */ sw $ra, 0x30($sp)
/* 1A990 8003F590 AFB3002C */ sw $s3, 0x2c($sp)
/* 1A994 8003F594 AFB10024 */ sw $s1, 0x24($sp)
/* 1A998 8003F598 AFB00020 */ sw $s0, 0x20($sp)
/* 1A99C 8003F59C 8E530148 */ lw $s3, 0x148($s2)
/* 1A9A0 8003F5A0 86640008 */ lh $a0, 8($s3)
/* 1A9A4 8003F5A4 0C00EABB */ jal get_npc_unsafe
/* 1A9A8 8003F5A8 00A0802D */ daddu $s0, $a1, $zero
/* 1A9AC 8003F5AC 12000004 */ beqz $s0, .L8003F5C0
/* 1A9B0 8003F5B0 0040882D */ daddu $s1, $v0, $zero
/* 1A9B4 8003F5B4 24020014 */ addiu $v0, $zero, 0x14
/* 1A9B8 8003F5B8 AE400070 */ sw $zero, 0x70($s2)
/* 1A9BC 8003F5BC AE420074 */ sw $v0, 0x74($s2)
.L8003F5C0:
/* 1A9C0 8003F5C0 8E420074 */ lw $v0, 0x74($s2)
/* 1A9C4 8003F5C4 30420001 */ andi $v0, $v0, 1
/* 1A9C8 8003F5C8 10400004 */ beqz $v0, .L8003F5DC
/* 1A9CC 8003F5CC 2403FFFD */ addiu $v1, $zero, -3
/* 1A9D0 8003F5D0 8E220000 */ lw $v0, ($s1)
/* 1A9D4 8003F5D4 0800FD79 */ j .L8003F5E4
/* 1A9D8 8003F5D8 00431024 */ and $v0, $v0, $v1
.L8003F5DC:
/* 1A9DC 8003F5DC 8E220000 */ lw $v0, ($s1)
/* 1A9E0 8003F5E0 34420002 */ ori $v0, $v0, 2
.L8003F5E4:
/* 1A9E4 8003F5E4 AE220000 */ sw $v0, ($s1)
/* 1A9E8 8003F5E8 8E430074 */ lw $v1, 0x74($s2)
/* 1A9EC 8003F5EC 2402000F */ addiu $v0, $zero, 0xf
/* 1A9F0 8003F5F0 1462001A */ bne $v1, $v0, .L8003F65C
/* 1A9F4 8003F5F4 00000000 */ nop
/* 1A9F8 8003F5F8 0C05272D */ jal play_sound
/* 1A9FC 8003F5FC 240403E5 */ addiu $a0, $zero, 0x3e5
/* 1AA00 8003F600 962300A8 */ lhu $v1, 0xa8($s1)
/* 1AA04 8003F604 C624003C */ lwc1 $f4, 0x3c($s1)
/* 1AA08 8003F608 3C01BF80 */ lui $at, 0xbf80
/* 1AA0C 8003F60C 44811000 */ mtc1 $at, $f2
/* 1AA10 8003F610 2402000A */ addiu $v0, $zero, 0xa
/* 1AA14 8003F614 AFA00010 */ sw $zero, 0x10($sp)
/* 1AA18 8003F618 AFA00018 */ sw $zero, 0x18($sp)
/* 1AA1C 8003F61C AFA2001C */ sw $v0, 0x1c($sp)
/* 1AA20 8003F620 00031C00 */ sll $v1, $v1, 0x10
/* 1AA24 8003F624 00031403 */ sra $v0, $v1, 0x10
/* 1AA28 8003F628 00031FC2 */ srl $v1, $v1, 0x1f
/* 1AA2C 8003F62C 00431021 */ addu $v0, $v0, $v1
/* 1AA30 8003F630 00021043 */ sra $v0, $v0, 1
/* 1AA34 8003F634 44820000 */ mtc1 $v0, $f0
/* 1AA38 8003F638 00000000 */ nop
/* 1AA3C 8003F63C 46800020 */ cvt.s.w $f0, $f0
/* 1AA40 8003F640 46002100 */ add.s $f4, $f4, $f0
/* 1AA44 8003F644 E7A20014 */ swc1 $f2, 0x14($sp)
/* 1AA48 8003F648 8E250038 */ lw $a1, 0x38($s1)
/* 1AA4C 8003F64C 8E270040 */ lw $a3, 0x40($s1)
/* 1AA50 8003F650 44062000 */ mfc1 $a2, $f4
/* 1AA54 8003F654 0C01C064 */ jal func_80070190
/* 1AA58 8003F658 24040001 */ addiu $a0, $zero, 1
.L8003F65C:
/* 1AA5C 8003F65C 8E500074 */ lw $s0, 0x74($s2)
/* 1AA60 8003F660 2402000A */ addiu $v0, $zero, 0xa
/* 1AA64 8003F664 1602000F */ bne $s0, $v0, .L8003F6A4
/* 1AA68 8003F668 00000000 */ nop
/* 1AA6C 8003F66C 3C014120 */ lui $at, 0x4120
/* 1AA70 8003F670 44811000 */ mtc1 $at, $f2
/* 1AA74 8003F674 C6200040 */ lwc1 $f0, 0x40($s1)
/* 1AA78 8003F678 46020000 */ add.s $f0, $f0, $f2
/* 1AA7C 8003F67C C62E003C */ lwc1 $f14, 0x3c($s1)
/* 1AA80 8003F680 C62C0038 */ lwc1 $f12, 0x38($s1)
/* 1AA84 8003F684 44060000 */ mfc1 $a2, $f0
/* 1AA88 8003F688 0C01BE3C */ jal func_8006F8F0
/* 1AA8C 8003F68C 46027380 */ add.s $f14, $f14, $f2
/* 1AA90 8003F690 8E420074 */ lw $v0, 0x74($s2)
/* 1AA94 8003F694 14500005 */ bne $v0, $s0, .L8003F6AC
/* 1AA98 8003F698 2442FFFF */ addiu $v0, $v0, -1
/* 1AA9C 8003F69C 0C0120A0 */ jal spawn_drops
/* 1AAA0 8003F6A0 0260202D */ daddu $a0, $s3, $zero
.L8003F6A4:
/* 1AAA4 8003F6A4 8E420074 */ lw $v0, 0x74($s2)
/* 1AAA8 8003F6A8 2442FFFF */ addiu $v0, $v0, -1
.L8003F6AC:
/* 1AAAC 8003F6AC 10400003 */ beqz $v0, .L8003F6BC
/* 1AAB0 8003F6B0 AE420074 */ sw $v0, 0x74($s2)
/* 1AAB4 8003F6B4 0800FDB3 */ j .L8003F6CC
/* 1AAB8 8003F6B8 0000102D */ daddu $v0, $zero, $zero
.L8003F6BC:
/* 1AABC 8003F6BC 8E230000 */ lw $v1, ($s1)
/* 1AAC0 8003F6C0 24020001 */ addiu $v0, $zero, 1
/* 1AAC4 8003F6C4 34630002 */ ori $v1, $v1, 2
/* 1AAC8 8003F6C8 AE230000 */ sw $v1, ($s1)
.L8003F6CC:
/* 1AACC 8003F6CC 8FBF0030 */ lw $ra, 0x30($sp)
/* 1AAD0 8003F6D0 8FB3002C */ lw $s3, 0x2c($sp)
/* 1AAD4 8003F6D4 8FB20028 */ lw $s2, 0x28($sp)
/* 1AAD8 8003F6D8 8FB10024 */ lw $s1, 0x24($sp)
/* 1AADC 8003F6DC 8FB00020 */ lw $s0, 0x20($sp)
/* 1AAE0 8003F6E0 03E00008 */ jr $ra
/* 1AAE4 8003F6E4 27BD0038 */ addiu $sp, $sp, 0x38

View File

@ -1,89 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_8004309C
/* 1E49C 8004309C 3C03800A */ lui $v1, %hi(D_8009A5D0)
/* 1E4A0 800430A0 8C63A5D0 */ lw $v1, %lo(D_8009A5D0)($v1)
/* 1E4A4 800430A4 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 1E4A8 800430A8 AFB10014 */ sw $s1, 0x14($sp)
/* 1E4AC 800430AC 3C11800B */ lui $s1, %hi(gCurrentEncounter)
/* 1E4B0 800430B0 26310F10 */ addiu $s1, $s1, %lo(gCurrentEncounter)
/* 1E4B4 800430B4 AFBF0018 */ sw $ra, 0x18($sp)
/* 1E4B8 800430B8 10600006 */ beqz $v1, .L800430D4
/* 1E4BC 800430BC AFB00010 */ sw $s0, 0x10($sp)
/* 1E4C0 800430C0 24020001 */ addiu $v0, $zero, 1
/* 1E4C4 800430C4 1062001B */ beq $v1, $v0, .L80043134
/* 1E4C8 800430C8 00000000 */ nop
/* 1E4CC 800430CC 08010C70 */ j .L800431C0
/* 1E4D0 800430D0 00000000 */ nop
.L800430D4:
/* 1E4D4 800430D4 8E30008C */ lw $s0, 0x8c($s1)
/* 1E4D8 800430D8 8E020038 */ lw $v0, 0x38($s0)
/* 1E4DC 800430DC 10400007 */ beqz $v0, .L800430FC
/* 1E4E0 800430E0 0000882D */ daddu $s1, $zero, $zero
/* 1E4E4 800430E4 8E040050 */ lw $a0, 0x50($s0)
/* 1E4E8 800430E8 0C0B1059 */ jal does_script_exist
/* 1E4EC 800430EC 00000000 */ nop
/* 1E4F0 800430F0 50400002 */ beql $v0, $zero, .L800430FC
/* 1E4F4 800430F4 AE000038 */ sw $zero, 0x38($s0)
/* 1E4F8 800430F8 24110001 */ addiu $s1, $zero, 1
.L800430FC:
/* 1E4FC 800430FC 8E020040 */ lw $v0, 0x40($s0)
/* 1E500 80043100 10400006 */ beqz $v0, .L8004311C
/* 1E504 80043104 00000000 */ nop
/* 1E508 80043108 0C0B1059 */ jal does_script_exist
/* 1E50C 8004310C 8E040058 */ lw $a0, 0x58($s0)
/* 1E510 80043110 50400002 */ beql $v0, $zero, .L8004311C
/* 1E514 80043114 AE000040 */ sw $zero, 0x40($s0)
/* 1E518 80043118 24110001 */ addiu $s1, $zero, 1
.L8004311C:
/* 1E51C 8004311C 16200028 */ bnez $s1, .L800431C0
/* 1E520 80043120 24020001 */ addiu $v0, $zero, 1
/* 1E524 80043124 3C01800A */ lui $at, %hi(D_8009A5D0)
/* 1E528 80043128 AC22A5D0 */ sw $v0, %lo(D_8009A5D0)($at)
/* 1E52C 8004312C 08010C70 */ j .L800431C0
/* 1E530 80043130 00000000 */ nop
.L80043134:
/* 1E534 80043134 0C0B1192 */ jal resume_all_group
/* 1E538 80043138 24040001 */ addiu $a0, $zero, 1
/* 1E53C 8004313C 8E30008C */ lw $s0, 0x8c($s1)
/* 1E540 80043140 12000006 */ beqz $s0, .L8004315C
/* 1E544 80043144 00000000 */ nop
/* 1E548 80043148 8E02003C */ lw $v0, 0x3c($s0)
/* 1E54C 8004314C 10400003 */ beqz $v0, .L8004315C
/* 1E550 80043150 00000000 */ nop
/* 1E554 80043154 0C0B1123 */ jal resume_all_script
/* 1E558 80043158 8E040054 */ lw $a0, 0x54($s0)
.L8004315C:
/* 1E55C 8004315C 0C038069 */ jal enable_player_input
/* 1E560 80043160 00000000 */ nop
/* 1E564 80043164 0C03BD80 */ jal func_800EF600
/* 1E568 80043168 00000000 */ nop
/* 1E56C 8004316C 3C028011 */ lui $v0, %hi(gPlayerStatus)
/* 1E570 80043170 2442EFC8 */ addiu $v0, $v0, %lo(gPlayerStatus)
/* 1E574 80043174 804300B4 */ lb $v1, 0xb4($v0)
/* 1E578 80043178 2402000C */ addiu $v0, $zero, 0xc
/* 1E57C 8004317C 14620003 */ bne $v1, $v0, .L8004318C
/* 1E580 80043180 00000000 */ nop
/* 1E584 80043184 0C039769 */ jal set_action_state
/* 1E588 80043188 0000202D */ daddu $a0, $zero, $zero
.L8004318C:
/* 1E58C 8004318C 0C03BCF5 */ jal func_800EF3D4
/* 1E590 80043190 0000202D */ daddu $a0, $zero, $zero
/* 1E594 80043194 24040010 */ addiu $a0, $zero, 0x10
/* 1E598 80043198 0C0B1192 */ jal resume_all_group
/* 1E59C 8004319C A2200005 */ sb $zero, 5($s1)
/* 1E5A0 800431A0 24020002 */ addiu $v0, $zero, 2
/* 1E5A4 800431A4 3C01800A */ lui $at, %hi(gGameState)
/* 1E5A8 800431A8 AC22A600 */ sw $v0, %lo(gGameState)($at)
/* 1E5AC 800431AC 24020001 */ addiu $v0, $zero, 1
/* 1E5B0 800431B0 3C01800A */ lui $at, %hi(D_8009A678)
/* 1E5B4 800431B4 AC22A678 */ sw $v0, %lo(D_8009A678)($at)
/* 1E5B8 800431B8 3C01800A */ lui $at, %hi(D_8009A5D0)
/* 1E5BC 800431BC AC20A5D0 */ sw $zero, %lo(D_8009A5D0)($at)
.L800431C0:
/* 1E5C0 800431C0 8FBF0018 */ lw $ra, 0x18($sp)
/* 1E5C4 800431C4 8FB10014 */ lw $s1, 0x14($sp)
/* 1E5C8 800431C8 8FB00010 */ lw $s0, 0x10($sp)
/* 1E5CC 800431CC 03E00008 */ jr $ra
/* 1E5D0 800431D0 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -81,7 +81,10 @@ void get_model_center_and_size(s32 modelID, f32* centerX, f32* centerY, f32* cen
void func_80027088(s32);
void func_8006F8F0(f32, f32, f32);
void func_8006FEF0(s32, f32, f32, f32, f32);
void func_80070190(s32, f32, f32, f32, s32, f32, s32, s32);
void func_80071090(s32, f32, f32, f32, s32);
void func_80071750(s32, f32, f32, f32, f32, s32);
void func_800720B0(s32, f32, f32, f32, f32, s32);

View File

@ -1,4 +1,8 @@
#include "common.h"
#include "map.h"
extern s32 D_8009A5D0;
extern s32 D_8009A678;
s32 get_defeated(s32 mapID, s32 encounterID) {
EncounterStatus* currentEncounter = &gCurrentEncounter;
@ -144,7 +148,44 @@ ApiStatus func_8003F4CC(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "code_1a1f0_len_5390", OnDefeatEnemy, ScriptInstance* script, s32 isInitialCall);
ApiStatus OnDefeatEnemy(ScriptInstance* script, s32 isInitialCall) {
Enemy* enemy = script->owner1.enemy;
Npc* npc = get_npc_unsafe(enemy->npcID);
s32 temp1;
if (isInitialCall) {
script->functionTemp[0].s = 0;
script->functionTemp[1].s = 20;
}
if (script->functionTemp[1].s & 1) {
npc->flags &= ~2;
} else {
npc->flags |= 2;
}
if (script->functionTemp[1].s == 15) {
play_sound(SoundId_DEATH);
func_80070190(1, npc->pos.x, npc->pos.y + (npc->collisionHeight / 2), npc->pos.z, 0, -1.0f, 0, 10);
}
temp1 = script->functionTemp[1].s;
if (script->functionTemp[1].s == 10) {
func_8006F8F0(npc->pos.x, npc->pos.y + 10.0f, npc->pos.z + 10.0f);
if (script->functionTemp[1].s == temp1) { // what? (never can be false, seemingly)
spawn_drops(enemy);
}
}
script->functionTemp[1].s -= 1;
if (script->functionTemp[1].s == 0) {
npc->flags |= 2;
return ApiStatus_DONE1;
}
return ApiStatus_BLOCK;
}
ApiStatus OnFleeBattleDrops(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus;
@ -196,7 +237,61 @@ s32 func_8004304C(void) {
return ret;
}
INCLUDE_ASM(s32, "code_1a1f0_len_5390", func_8004309C);
void func_8004309C(void) {
EncounterStatus* encounter = &gCurrentEncounter;
PlayerStatus* playerStatus = PLAYER_STATUS;
Enemy* currentEnemy;
s32 flag;
switch (D_8009A5D0) {
case 0:
currentEnemy = encounter->currentEnemy;
flag = FALSE;
if (currentEnemy->interactScript != NULL) {
if (does_script_exist(currentEnemy->interactScriptID)) {
flag = TRUE;
} else {
currentEnemy->interactScript = NULL;
}
}
if (currentEnemy->hitScript != NULL) {
if (does_script_exist(currentEnemy->hitScriptID)) {
flag = TRUE;
} else {
currentEnemy->hitScript = NULL;
}
}
if (!flag) {
D_8009A5D0 = 1;
}
break;
case 1:
resume_all_group(1);
currentEnemy = encounter->currentEnemy;
if (currentEnemy != NULL && currentEnemy->aiScript != NULL) {
resume_all_script(currentEnemy->aiScriptID);
}
enable_player_input();
func_800EF600();
if (playerStatus->actionState == ActionState_CONVERSATION) {
set_action_state(ActionState_IDLE);
}
func_800EF3D4(0);
encounter->hitType = 0;
resume_all_group(16);
gGameState = 2;
D_8009A678 = 1;
D_8009A5D0 = 0;
break;
}
}
void func_800431D4() {
}

View File

@ -4,7 +4,7 @@ extern EffectTableEntry D_8007F210[135];
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_8006F890);
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_8006F8F0);
INCLUDE_ASM(void, "os/code_4ac90_len_3910", func_8006F8F0, f32 arg0, f32 arg1, f32 arg2);
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_8006F950);
@ -51,7 +51,8 @@ INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_800700D0);
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_80070130);
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_80070190);
INCLUDE_ASM(void, "os/code_4ac90_len_3910", func_80070190, s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4, f32 arg5,
s32 arg6, s32 arg7);
INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_800701F0);