From 1040a9124c9b4ceb2621404fa90ede1a79185cb3 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 15 Oct 2020 23:07:50 -0400 Subject: [PATCH] hey clover lol wudup --- .../code_18F340/HasMerleeCastsLeft.s | 13 --- .../code_18F340/IncrementPlayerFP.s | 19 ---- .../code_18F340/IncrementPlayerHP.s | 19 ---- asm/nonmatchings/code_18F340/func_80260DB8.s | 12 --- asm/nonmatchings/code_18F340/func_80260DD8.s | 29 ------ asm/nonmatchings/code_18F340/func_80260E38.s | 13 --- asm/nonmatchings/code_18F340/func_80260E5C.s | 17 ---- asm/nonmatchings/code_18F340/func_80261388.s | 13 --- asm/nonmatchings/code_18F340/func_802613A8.s | 9 -- asm/nonmatchings/code_18F340/func_80261D98.s | 19 ---- asm/nonmatchings/code_18F340/func_80261DD4.s | 12 --- include/common_structs.h | 6 +- src/code_18F340.c | 92 ++++++++++++++++--- 13 files changed, 84 insertions(+), 189 deletions(-) delete mode 100644 asm/nonmatchings/code_18F340/HasMerleeCastsLeft.s delete mode 100644 asm/nonmatchings/code_18F340/IncrementPlayerFP.s delete mode 100644 asm/nonmatchings/code_18F340/IncrementPlayerHP.s delete mode 100644 asm/nonmatchings/code_18F340/func_80260DB8.s delete mode 100644 asm/nonmatchings/code_18F340/func_80260DD8.s delete mode 100644 asm/nonmatchings/code_18F340/func_80260E38.s delete mode 100644 asm/nonmatchings/code_18F340/func_80260E5C.s delete mode 100644 asm/nonmatchings/code_18F340/func_80261388.s delete mode 100644 asm/nonmatchings/code_18F340/func_802613A8.s delete mode 100644 asm/nonmatchings/code_18F340/func_80261D98.s delete mode 100644 asm/nonmatchings/code_18F340/func_80261DD4.s diff --git a/asm/nonmatchings/code_18F340/HasMerleeCastsLeft.s b/asm/nonmatchings/code_18F340/HasMerleeCastsLeft.s deleted file mode 100644 index 5cf23f5b13..0000000000 --- a/asm/nonmatchings/code_18F340/HasMerleeCastsLeft.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel HasMerleeCastsLeft -/* 1902A8 802619C8 AC800084 */ sw $zero, 0x84($a0) -/* 1902AC 802619CC 3C028011 */ lui $v0, 0x8011 -/* 1902B0 802619D0 8042F51A */ lb $v0, -0xae6($v0) -/* 1902B4 802619D4 18400002 */ blez $v0, .L802619E0 -/* 1902B8 802619D8 24020001 */ addiu $v0, $zero, 1 -/* 1902BC 802619DC AC820084 */ sw $v0, 0x84($a0) -.L802619E0: -/* 1902C0 802619E0 03E00008 */ jr $ra -/* 1902C4 802619E4 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/IncrementPlayerFP.s b/asm/nonmatchings/code_18F340/IncrementPlayerFP.s deleted file mode 100644 index 833f5a1d7f..0000000000 --- a/asm/nonmatchings/code_18F340/IncrementPlayerFP.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel IncrementPlayerFP -/* 190640 80261D60 3C048011 */ lui $a0, %hi(gPlayerData) -/* 190644 80261D64 2484F290 */ addiu $a0, $a0, %lo(gPlayerData) -/* 190648 80261D68 90820005 */ lbu $v0, 5($a0) -/* 19064C 80261D6C 80830006 */ lb $v1, 6($a0) -/* 190650 80261D70 24420001 */ addiu $v0, $v0, 1 -/* 190654 80261D74 A0820005 */ sb $v0, 5($a0) -/* 190658 80261D78 00021600 */ sll $v0, $v0, 0x18 -/* 19065C 80261D7C 00021603 */ sra $v0, $v0, 0x18 -/* 190660 80261D80 0062182A */ slt $v1, $v1, $v0 -/* 190664 80261D84 90820006 */ lbu $v0, 6($a0) -/* 190668 80261D88 54600001 */ bnel $v1, $zero, .L80261D90 -/* 19066C 80261D8C A0820005 */ sb $v0, 5($a0) -.L80261D90: -/* 190670 80261D90 03E00008 */ jr $ra -/* 190674 80261D94 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/IncrementPlayerHP.s b/asm/nonmatchings/code_18F340/IncrementPlayerHP.s deleted file mode 100644 index b79c4d6097..0000000000 --- a/asm/nonmatchings/code_18F340/IncrementPlayerHP.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel IncrementPlayerHP -/* 190608 80261D28 3C048011 */ lui $a0, %hi(gPlayerData) -/* 19060C 80261D2C 2484F290 */ addiu $a0, $a0, %lo(gPlayerData) -/* 190610 80261D30 90820002 */ lbu $v0, 2($a0) -/* 190614 80261D34 80830003 */ lb $v1, 3($a0) -/* 190618 80261D38 24420001 */ addiu $v0, $v0, 1 -/* 19061C 80261D3C A0820002 */ sb $v0, 2($a0) -/* 190620 80261D40 00021600 */ sll $v0, $v0, 0x18 -/* 190624 80261D44 00021603 */ sra $v0, $v0, 0x18 -/* 190628 80261D48 0062182A */ slt $v1, $v1, $v0 -/* 19062C 80261D4C 90820003 */ lbu $v0, 3($a0) -/* 190630 80261D50 54600001 */ bnel $v1, $zero, .L80261D58 -/* 190634 80261D54 A0820002 */ sb $v0, 2($a0) -.L80261D58: -/* 190638 80261D58 03E00008 */ jr $ra -/* 19063C 80261D5C 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/func_80260DB8.s b/asm/nonmatchings/code_18F340/func_80260DB8.s deleted file mode 100644 index bbf8bb2671..0000000000 --- a/asm/nonmatchings/code_18F340/func_80260DB8.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80260DB8 -/* 18F698 80260DB8 3C02800E */ lui $v0, %hi(gBattleStatus) -/* 18F69C 80260DBC 2442C070 */ addiu $v0, $v0, %lo(gBattleStatus) -/* 18F6A0 80260DC0 8C430000 */ lw $v1, ($v0) -/* 18F6A4 80260DC4 3C040004 */ lui $a0, 4 -/* 18F6A8 80260DC8 00641825 */ or $v1, $v1, $a0 -/* 18F6AC 80260DCC AC430000 */ sw $v1, ($v0) -/* 18F6B0 80260DD0 03E00008 */ jr $ra -/* 18F6B4 80260DD4 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/func_80260DD8.s b/asm/nonmatchings/code_18F340/func_80260DD8.s deleted file mode 100644 index bb06c2a7b9..0000000000 --- a/asm/nonmatchings/code_18F340/func_80260DD8.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80260DD8 -/* 18F6B8 80260DD8 3C028011 */ lui $v0, 0x8011 -/* 18F6BC 80260DDC 8042F29A */ lb $v0, -0xd66($v0) -/* 18F6C0 80260DE0 3C03800E */ lui $v1, 0x800e -/* 18F6C4 80260DE4 8C63C148 */ lw $v1, -0x3eb8($v1) -/* 18F6C8 80260DE8 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 18F6CC 80260DEC AFB10014 */ sw $s1, 0x14($sp) -/* 18F6D0 80260DF0 0080882D */ daddu $s1, $a0, $zero -/* 18F6D4 80260DF4 AFBF0018 */ sw $ra, 0x18($sp) -/* 18F6D8 80260DF8 14400009 */ bnez $v0, .L80260E20 -/* 18F6DC 80260DFC AFB00010 */ sw $s0, 0x10($sp) -/* 18F6E0 80260E00 8C700088 */ lw $s0, 0x88($v1) -/* 18F6E4 80260E04 0C00A67F */ jal rand_int -/* 18F6E8 80260E08 24040064 */ addiu $a0, $zero, 0x64 -/* 18F6EC 80260E0C 0202802A */ slt $s0, $s0, $v0 -/* 18F6F0 80260E10 56000003 */ bnel $s0, $zero, .L80260E20 -/* 18F6F4 80260E14 AE200084 */ sw $zero, 0x84($s1) -/* 18F6F8 80260E18 24020001 */ addiu $v0, $zero, 1 -/* 18F6FC 80260E1C AE220084 */ sw $v0, 0x84($s1) -.L80260E20: -/* 18F700 80260E20 24020002 */ addiu $v0, $zero, 2 -/* 18F704 80260E24 8FBF0018 */ lw $ra, 0x18($sp) -/* 18F708 80260E28 8FB10014 */ lw $s1, 0x14($sp) -/* 18F70C 80260E2C 8FB00010 */ lw $s0, 0x10($sp) -/* 18F710 80260E30 03E00008 */ jr $ra -/* 18F714 80260E34 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_18F340/func_80260E38.s b/asm/nonmatchings/code_18F340/func_80260E38.s deleted file mode 100644 index 5592584fce..0000000000 --- a/asm/nonmatchings/code_18F340/func_80260E38.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80260E38 -/* 18F718 80260E38 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 18F71C 80260E3C 24040031 */ addiu $a0, $zero, 0x31 -/* 18F720 80260E40 AFBF0010 */ sw $ra, 0x10($sp) -/* 18F724 80260E44 0C093E58 */ jal show_battle_message -/* 18F728 80260E48 2405003C */ addiu $a1, $zero, 0x3c -/* 18F72C 80260E4C 8FBF0010 */ lw $ra, 0x10($sp) -/* 18F730 80260E50 24020002 */ addiu $v0, $zero, 2 -/* 18F734 80260E54 03E00008 */ jr $ra -/* 18F738 80260E58 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_18F340/func_80260E5C.s b/asm/nonmatchings/code_18F340/func_80260E5C.s deleted file mode 100644 index d614506961..0000000000 --- a/asm/nonmatchings/code_18F340/func_80260E5C.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80260E5C -/* 18F73C 80260E5C 3C03FFFF */ lui $v1, 0xffff -/* 18F740 80260E60 3C04800E */ lui $a0, %hi(gBattleStatus) -/* 18F744 80260E64 2484C070 */ addiu $a0, $a0, %lo(gBattleStatus) -/* 18F748 80260E68 8C820000 */ lw $v0, ($a0) -/* 18F74C 80260E6C 34637FFF */ ori $v1, $v1, 0x7fff -/* 18F750 80260E70 00431024 */ and $v0, $v0, $v1 -/* 18F754 80260E74 2403DFFF */ addiu $v1, $zero, -0x2001 -/* 18F758 80260E78 00431024 */ and $v0, $v0, $v1 -/* 18F75C 80260E7C 2403BFFF */ addiu $v1, $zero, -0x4001 -/* 18F760 80260E80 00431024 */ and $v0, $v0, $v1 -/* 18F764 80260E84 AC820000 */ sw $v0, ($a0) -/* 18F768 80260E88 03E00008 */ jr $ra -/* 18F76C 80260E8C 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/func_80261388.s b/asm/nonmatchings/code_18F340/func_80261388.s deleted file mode 100644 index 2890de26b3..0000000000 --- a/asm/nonmatchings/code_18F340/func_80261388.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80261388 -/* 18FC68 80261388 3C02800E */ lui $v0, 0x800e -/* 18FC6C 8026138C 8C42C14C */ lw $v0, -0x3eb4($v0) -/* 18FC70 80261390 10400003 */ beqz $v0, .L802613A0 -/* 18FC74 80261394 AC800084 */ sw $zero, 0x84($a0) -/* 18FC78 80261398 24020001 */ addiu $v0, $zero, 1 -/* 18FC7C 8026139C AC820084 */ sw $v0, 0x84($a0) -.L802613A0: -/* 18FC80 802613A0 03E00008 */ jr $ra -/* 18FC84 802613A4 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/func_802613A8.s b/asm/nonmatchings/code_18F340/func_802613A8.s deleted file mode 100644 index b39a4a93b9..0000000000 --- a/asm/nonmatchings/code_18F340/func_802613A8.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802613A8 -/* 18FC88 802613A8 24020095 */ addiu $v0, $zero, 0x95 -/* 18FC8C 802613AC 3C01800E */ lui $at, 0x800e -/* 18FC90 802613B0 A422C1EA */ sh $v0, -0x3e16($at) -/* 18FC94 802613B4 03E00008 */ jr $ra -/* 18FC98 802613B8 24020002 */ addiu $v0, $zero, 2 diff --git a/asm/nonmatchings/code_18F340/func_80261D98.s b/asm/nonmatchings/code_18F340/func_80261D98.s deleted file mode 100644 index b31c0ceeda..0000000000 --- a/asm/nonmatchings/code_18F340/func_80261D98.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80261D98 -/* 190678 80261D98 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 19067C 80261D9C AFBF0010 */ sw $ra, 0x10($sp) -/* 190680 80261DA0 0C09A75B */ jal get_actor -/* 190684 80261DA4 8C840148 */ lw $a0, 0x148($a0) -/* 190688 80261DA8 0040202D */ daddu $a0, $v0, $zero -/* 19068C 80261DAC 24050004 */ addiu $a1, $zero, 4 -/* 190690 80261DB0 0000302D */ daddu $a2, $zero, $zero -/* 190694 80261DB4 0C099B3C */ jal inflict_status_set_duration -/* 190698 80261DB8 24070001 */ addiu $a3, $zero, 1 -/* 19069C 80261DBC 0C099DDF */ jal func_8026777C -/* 1906A0 80261DC0 00000000 */ nop -/* 1906A4 80261DC4 8FBF0010 */ lw $ra, 0x10($sp) -/* 1906A8 80261DC8 24020002 */ addiu $v0, $zero, 2 -/* 1906AC 80261DCC 03E00008 */ jr $ra -/* 1906B0 80261DD0 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_18F340/func_80261DD4.s b/asm/nonmatchings/code_18F340/func_80261DD4.s deleted file mode 100644 index e9402addba..0000000000 --- a/asm/nonmatchings/code_18F340/func_80261DD4.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80261DD4 -/* 1906B4 80261DD4 3C038011 */ lui $v1, %hi(gPlayerData) -/* 1906B8 80261DD8 2463F290 */ addiu $v1, $v1, %lo(gPlayerData) -/* 1906BC 80261DDC 80620000 */ lb $v0, ($v1) -/* 1906C0 80261DE0 AC8200B0 */ sw $v0, 0xb0($a0) -/* 1906C4 80261DE4 80620001 */ lb $v0, 1($v1) -/* 1906C8 80261DE8 AC8200B4 */ sw $v0, 0xb4($a0) -/* 1906CC 80261DEC 03E00008 */ jr $ra -/* 1906D0 80261DF0 24020002 */ addiu $v0, $zero, 2 diff --git a/include/common_structs.h b/include/common_structs.h index bdcfd230f8..ad6649b18a 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -103,7 +103,7 @@ typedef struct Npc { } Npc; // size = 0x340 typedef struct PlayerData { - /* 0x000 */ u8 bootsLevel; + /* 0x000 */ s8 bootsLevel; /* 0x001 */ s8 hammerLevel; /* 0x002 */ s8 curHP; /* 0x003 */ s8 curMaxHP; @@ -113,7 +113,7 @@ typedef struct PlayerData { /* 0x007 */ u8 hardMaxFP; /* 0x008 */ u8 maxBP; /* 0x009 */ u8 level; - /* 0x00A */ u8 hasActionCommands; + /* 0x00A */ s8 hasActionCommands; /* 0x00B */ char unk_0B; /* 0x00C */ s16 coins; /* 0x00E */ s8 fortressKeyCount; @@ -1285,7 +1285,7 @@ typedef struct Actor { /* 0x211 */ u8 debuffDuration; /* 0x212 */ u8 staticStatus; /* 0B = yes */ /* 0x213 */ u8 staticDuration; - /* 0x214 */ u8 stoneStatus; /* 0C = yes */ + /* 0x214 */ s8 stoneStatus; /* 0C = yes */ /* 0x215 */ u8 stoneDuration; /* 0x216 */ u8 koStatus; /* 0D = yes */ /* 0x217 */ u8 koDuration; diff --git a/src/code_18F340.c b/src/code_18F340.c index b49f406471..dc8655c260 100644 --- a/src/code_18F340.c +++ b/src/code_18F340.c @@ -10,13 +10,38 @@ INCLUDE_ASM(s32, "code_18F340", func_80260B70); INCLUDE_ASM(s32, "code_18F340", func_80260BF4); -INCLUDE_ASM(s32, "code_18F340", func_80260DB8); +ApiStatus func_80260DB8(ScriptInstance* script, s32 isInitialCall) { + gBattleStatus.flags1 |= 0x40000; + return ApiStatus_DONE2; +} -INCLUDE_ASM(s32, "code_18F340", func_80260DD8); +ApiStatus func_80260DD8(ScriptInstance* script, s32 isInitialCall) { + Actor* player = gBattleStatus.playerActor; + + if (!gPlayerData.hasActionCommands) { + s32 var = player->varTable[0]; + + if (var >= rand_int(100)) { + script->varTable[0] = 1; + } else { + script->varTable[0] = 0; + } + } + return ApiStatus_DONE2; + do {} while (0); // necessary to match +} -INCLUDE_ASM(s32, "code_18F340", func_80260E38); +ApiStatus func_80260E38(ScriptInstance* script, s32 isInitialCall) { + show_battle_message(0x31, 60); + return ApiStatus_DONE2; +} -INCLUDE_ASM(s32, "code_18F340", func_80260E5C); +ApiStatus func_80260E5C(ScriptInstance* script, s32 isInitialCall) { + gBattleStatus.flags1 &= ~0x8000; + gBattleStatus.flags1 &= ~0x2000; + gBattleStatus.flags1 &= ~0x4000; + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_18F340", func_80260E90); @@ -30,9 +55,20 @@ INCLUDE_ASM(s32, "code_18F340", func_802611E8); INCLUDE_ASM(s32, "code_18F340", func_8026127C); -INCLUDE_ASM(s32, "code_18F340", func_80261388); +ApiStatus func_80261388(ScriptInstance* script, s32 isInitialCall) { + s32 partnerActorExists = gBattleStatus.partnerActor != NULL; + + script->varTable[0] = FALSE; + if (partnerActorExists) { + script->varTable[0] = TRUE; + } + return ApiStatus_DONE2; +} -INCLUDE_ASM(s32, "code_18F340", func_802613A8); +ApiStatus func_802613A8(ScriptInstance* script, s32 isInitialCall) { + gBattleStatus.selectedItemID = ItemId_LIFE_SHROOM; + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_18F340", func_802613BC); @@ -50,7 +86,15 @@ INCLUDE_ASM(s32, "code_18F340", func_802616F4); INCLUDE_ASM(s32, "code_18F340", func_802619B4); -INCLUDE_ASM(s32, "code_18F340", HasMerleeCastsLeft); +ApiStatus HasMerleeCastsLeft(ScriptInstance* script, s32 isInitialCall) { + PlayerData* playerData = &gPlayerData; + + script->varTable[0] = FALSE; + if (playerData->merleeCastsLeft > 0) { + script->varTable[0] = TRUE; + } + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_18F340", func_802619E8); @@ -60,13 +104,39 @@ INCLUDE_ASM(s32, "code_18F340", FXRecoverHP); INCLUDE_ASM(s32, "code_18F340", FXRecoverFP); -INCLUDE_ASM(s32, "code_18F340", IncrementPlayerHP); +ApiStatus IncrementPlayerHP(ScriptInstance* script, s32 isInitialCall) { + PlayerData* playerData = &gPlayerData; -INCLUDE_ASM(s32, "code_18F340", IncrementPlayerFP); + playerData->curHP++; + if (playerData->curHP > playerData->curMaxHP) { + playerData->curHP = playerData->curMaxHP; + } + return ApiStatus_DONE2; +} -INCLUDE_ASM(s32, "code_18F340", func_80261D98); +ApiStatus IncrementPlayerFP(ScriptInstance* script, s32 isInitialCall) { + PlayerData* playerData = &gPlayerData; -INCLUDE_ASM(s32, "code_18F340", func_80261DD4); + playerData->curFP++; + if (playerData->curFP > playerData->curMaxFP) { + playerData->curFP = playerData->curMaxFP; + } + return ApiStatus_DONE2; +} + +ApiStatus func_80261D98(ScriptInstance* script, s32 isInitialCall) { + inflict_status_set_duration(get_actor(script->ownerActorID), 4, 0, 1); + func_8026777C(); + return ApiStatus_DONE2; +} + +ApiStatus func_80261DD4(ScriptInstance* script, s32 isInitialCall) { + PlayerData* playerData = &gPlayerData; + + script->varTable[11] = playerData->bootsLevel; + script->varTable[12] = playerData->hammerLevel; + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "code_18F340", func_80261DF4);