From 998c480d08ad51bc4baeb889e2267c35b28c7253 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Mon, 10 Aug 2020 03:42:50 -0400 Subject: [PATCH] 4 more --- .../code_80850_len_3060/enforce_hpfp_limits.s | 61 ------------------- .../code_e92d0_len_5da0/CloneModel.s | 29 --------- .../code_e92d0_len_5da0/GetMapID.s | 19 ------ .../UpdateColliderTransform.s | 19 ------ papermario/include/common_structs.h | 4 +- papermario/include/functions.h | 2 + papermario/src/code_362a0_len_2f70.c | 2 +- papermario/src/code_80850_len_3060.c | 21 ++++++- papermario/src/code_a5dd0_len_114e0.c | 2 +- papermario/src/code_e92d0_len_5da0.c | 21 ++++++- 10 files changed, 45 insertions(+), 135 deletions(-) delete mode 100644 papermario/asm/nonmatchings/code_80850_len_3060/enforce_hpfp_limits.s delete mode 100644 papermario/asm/nonmatchings/code_e92d0_len_5da0/CloneModel.s delete mode 100644 papermario/asm/nonmatchings/code_e92d0_len_5da0/GetMapID.s delete mode 100644 papermario/asm/nonmatchings/code_e92d0_len_5da0/UpdateColliderTransform.s diff --git a/papermario/asm/nonmatchings/code_80850_len_3060/enforce_hpfp_limits.s b/papermario/asm/nonmatchings/code_80850_len_3060/enforce_hpfp_limits.s deleted file mode 100644 index 04f49fe50f..0000000000 --- a/papermario/asm/nonmatchings/code_80850_len_3060/enforce_hpfp_limits.s +++ /dev/null @@ -1,61 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel enforce_hpfp_limits -/* 080D1C 800E786C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 080D20 800E7870 24040004 */ addiu $a0, $zero, 4 -/* 080D24 800E7874 AFBF0018 */ sw $ra, 0x18($sp) -/* 080D28 800E7878 AFB10014 */ sw $s1, 0x14($sp) -/* 080D2C 800E787C 0C03A752 */ jal is_ability_active -/* 080D30 800E7880 AFB00010 */ sw $s0, 0x10($sp) -/* 080D34 800E7884 3C108011 */ lui $s0, 0x8011 -/* 080D38 800E7888 2610F290 */ addiu $s0, $s0, -0xd70 -/* 080D3C 800E788C 00022080 */ sll $a0, $v0, 2 -/* 080D40 800E7890 00822021 */ addu $a0, $a0, $v0 -/* 080D44 800E7894 92030004 */ lbu $v1, 4($s0) -/* 080D48 800E7898 00641821 */ addu $v1, $v1, $a0 -/* 080D4C 800E789C A2030003 */ sb $v1, 3($s0) -/* 080D50 800E78A0 00031E00 */ sll $v1, $v1, 0x18 -/* 080D54 800E78A4 00031E03 */ sra $v1, $v1, 0x18 -/* 080D58 800E78A8 2863004C */ slti $v1, $v1, 0x4c -/* 080D5C 800E78AC 14600003 */ bnez $v1, .L800E78BC -/* 080D60 800E78B0 0200882D */ daddu $s1, $s0, $zero -/* 080D64 800E78B4 2402004B */ addiu $v0, $zero, 0x4b -/* 080D68 800E78B8 A2020003 */ sb $v0, 3($s0) -.L800E78BC: -/* 080D6C 800E78BC 82030002 */ lb $v1, 2($s0) -/* 080D70 800E78C0 82020003 */ lb $v0, 3($s0) -/* 080D74 800E78C4 0043102A */ slt $v0, $v0, $v1 -/* 080D78 800E78C8 92030003 */ lbu $v1, 3($s0) -/* 080D7C 800E78CC 54400001 */ bnezl $v0, .L800E78D4 -/* 080D80 800E78D0 A2030002 */ sb $v1, 2($s0) -.L800E78D4: -/* 080D84 800E78D4 0C03A752 */ jal is_ability_active -/* 080D88 800E78D8 2404000C */ addiu $a0, $zero, 0xc -/* 080D8C 800E78DC 00022080 */ sll $a0, $v0, 2 -/* 080D90 800E78E0 92030007 */ lbu $v1, 7($s0) -/* 080D94 800E78E4 00822021 */ addu $a0, $a0, $v0 -/* 080D98 800E78E8 00641821 */ addu $v1, $v1, $a0 -/* 080D9C 800E78EC A2030006 */ sb $v1, 6($s0) -/* 080DA0 800E78F0 00031E00 */ sll $v1, $v1, 0x18 -/* 080DA4 800E78F4 00031E03 */ sra $v1, $v1, 0x18 -/* 080DA8 800E78F8 2863004C */ slti $v1, $v1, 0x4c -/* 080DAC 800E78FC 14600002 */ bnez $v1, .L800E7908 -/* 080DB0 800E7900 2402004B */ addiu $v0, $zero, 0x4b -/* 080DB4 800E7904 A2020006 */ sb $v0, 6($s0) -.L800E7908: -/* 080DB8 800E7908 82230005 */ lb $v1, 5($s1) -/* 080DBC 800E790C 82220006 */ lb $v0, 6($s1) -/* 080DC0 800E7910 0043102A */ slt $v0, $v0, $v1 -/* 080DC4 800E7914 92230006 */ lbu $v1, 6($s1) -/* 080DC8 800E7918 54400001 */ bnezl $v0, .L800E7920 -/* 080DCC 800E791C A2230005 */ sb $v1, 5($s1) -.L800E7920: -/* 080DD0 800E7920 8FBF0018 */ lw $ra, 0x18($sp) -/* 080DD4 800E7924 8FB10014 */ lw $s1, 0x14($sp) -/* 080DD8 800E7928 8FB00010 */ lw $s0, 0x10($sp) -/* 080DDC 800E792C 03E00008 */ jr $ra -/* 080DE0 800E7930 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/papermario/asm/nonmatchings/code_e92d0_len_5da0/CloneModel.s b/papermario/asm/nonmatchings/code_e92d0_len_5da0/CloneModel.s deleted file mode 100644 index 10df0ff231..0000000000 --- a/papermario/asm/nonmatchings/code_e92d0_len_5da0/CloneModel.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel CloneModel -/* 0ED8D8 802C8F28 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0ED8DC 802C8F2C AFB10014 */ sw $s1, 0x14($sp) -/* 0ED8E0 802C8F30 0080882D */ daddu $s1, $a0, $zero -/* 0ED8E4 802C8F34 AFBF0018 */ sw $ra, 0x18($sp) -/* 0ED8E8 802C8F38 AFB00010 */ sw $s0, 0x10($sp) -/* 0ED8EC 802C8F3C 8E30000C */ lw $s0, 0xc($s1) -/* 0ED8F0 802C8F40 8E050000 */ lw $a1, ($s0) -/* 0ED8F4 802C8F44 0C0B1EAF */ jal get_variable -/* 0ED8F8 802C8F48 26100004 */ addiu $s0, $s0, 4 -/* 0ED8FC 802C8F4C 0220202D */ daddu $a0, $s1, $zero -/* 0ED900 802C8F50 8E050000 */ lw $a1, ($s0) -/* 0ED904 802C8F54 0C0B1EAF */ jal get_variable -/* 0ED908 802C8F58 0040802D */ daddu $s0, $v0, $zero -/* 0ED90C 802C8F5C 3204FFFF */ andi $a0, $s0, 0xffff -/* 0ED910 802C8F60 0C046DBC */ jal clone_model -/* 0ED914 802C8F64 3045FFFF */ andi $a1, $v0, 0xffff -/* 0ED918 802C8F68 8FBF0018 */ lw $ra, 0x18($sp) -/* 0ED91C 802C8F6C 8FB10014 */ lw $s1, 0x14($sp) -/* 0ED920 802C8F70 8FB00010 */ lw $s0, 0x10($sp) -/* 0ED924 802C8F74 24020002 */ addiu $v0, $zero, 2 -/* 0ED928 802C8F78 03E00008 */ jr $ra -/* 0ED92C 802C8F7C 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/papermario/asm/nonmatchings/code_e92d0_len_5da0/GetMapID.s b/papermario/asm/nonmatchings/code_e92d0_len_5da0/GetMapID.s deleted file mode 100644 index 39f9154b0d..0000000000 --- a/papermario/asm/nonmatchings/code_e92d0_len_5da0/GetMapID.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel GetMapID -/* 0EEE40 802CA490 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0EEE44 802CA494 AFBF0010 */ sw $ra, 0x10($sp) -/* 0EEE48 802CA498 8C82000C */ lw $v0, 0xc($a0) -/* 0EEE4C 802CA49C 3C038007 */ lui $v1, 0x8007 -/* 0EEE50 802CA4A0 8C63419C */ lw $v1, 0x419c($v1) -/* 0EEE54 802CA4A4 8C450000 */ lw $a1, ($v0) -/* 0EEE58 802CA4A8 0C0B2026 */ jal set_variable -/* 0EEE5C 802CA4AC 8466008C */ lh $a2, 0x8c($v1) -/* 0EEE60 802CA4B0 8FBF0010 */ lw $ra, 0x10($sp) -/* 0EEE64 802CA4B4 24020002 */ addiu $v0, $zero, 2 -/* 0EEE68 802CA4B8 03E00008 */ jr $ra -/* 0EEE6C 802CA4BC 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/papermario/asm/nonmatchings/code_e92d0_len_5da0/UpdateColliderTransform.s b/papermario/asm/nonmatchings/code_e92d0_len_5da0/UpdateColliderTransform.s deleted file mode 100644 index e794725188..0000000000 --- a/papermario/asm/nonmatchings/code_e92d0_len_5da0/UpdateColliderTransform.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel UpdateColliderTransform -/* 0EEB38 802CA188 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0EEB3C 802CA18C AFBF0010 */ sw $ra, 0x10($sp) -/* 0EEB40 802CA190 8C82000C */ lw $v0, 0xc($a0) -/* 0EEB44 802CA194 0C0B1EAF */ jal get_variable -/* 0EEB48 802CA198 8C450000 */ lw $a1, ($v0) -/* 0EEB4C 802CA19C 00021400 */ sll $v0, $v0, 0x10 -/* 0EEB50 802CA1A0 0C016E89 */ jal update_collider_transform -/* 0EEB54 802CA1A4 00022403 */ sra $a0, $v0, 0x10 -/* 0EEB58 802CA1A8 8FBF0010 */ lw $ra, 0x10($sp) -/* 0EEB5C 802CA1AC 24020002 */ addiu $v0, $zero, 2 -/* 0EEB60 802CA1B0 03E00008 */ jr $ra -/* 0EEB64 802CA1B4 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/papermario/include/common_structs.h b/papermario/include/common_structs.h index 6992c05497..4457c3e45e 100644 --- a/papermario/include/common_structs.h +++ b/papermario/include/common_structs.h @@ -27,7 +27,9 @@ typedef struct { /* 0x081 */ s8 unk_81; /* 0x082 */ s8 unk_82; /* 0x083 */ s8 unk_83; - /* 0x084 */ char unk_84[0x24]; + /* 0x084 */ char unk_84[0x8]; + /* 0x08C */ s16 mapID; + /* 0x08E */ char unk_8E[0x1A]; /* 0x0A8 */ s8 unk_A8; /* 0x0A9 */ char unk_A9; /* 0x0AA */ s8 unk_AA; diff --git a/papermario/include/functions.h b/papermario/include/functions.h index e72f858b87..2c21d3691b 100644 --- a/papermario/include/functions.h +++ b/papermario/include/functions.h @@ -6,6 +6,8 @@ void osCleanupThread(void); +void clone_model(u16 srcModelID, u16 newModelID); +void update_collider_transform(s16 colliderID); s32 get_variable(script_context* script, s32 pos); f32 get_float_variable(script_context* script, s32 pos); f32 sin_deg(f32 x); diff --git a/papermario/src/code_362a0_len_2f70.c b/papermario/src/code_362a0_len_2f70.c index 8623785d33..8dced7c86b 100644 --- a/papermario/src/code_362a0_len_2f70.c +++ b/papermario/src/code_362a0_len_2f70.c @@ -20,7 +20,7 @@ INCLUDE_ASM(code_362a0_len_2f70, _add_hit_vert_to_buffer); INCLUDE_ASM(code_362a0_len_2f70, _get_hit_vert_index_from_buffer); -INCLUDE_ASM(code_362a0_len_2f70, update_collider_transform); +void INCLUDE_ASM(code_362a0_len_2f70, update_collider_transform, s16 colliderID); INCLUDE_ASM(code_362a0_len_2f70, get_collider_type_by_id); diff --git a/papermario/src/code_80850_len_3060.c b/papermario/src/code_80850_len_3060.c index aac8ca1455..30ba81095a 100644 --- a/papermario/src/code_80850_len_3060.c +++ b/papermario/src/code_80850_len_3060.c @@ -251,7 +251,26 @@ s32 get_stored_empty_count(void) { return ARRAY_COUNT(gPlayerData.storedItems) - get_stored_count(); } -INCLUDE_ASM(code_80850_len_3060, enforce_hpfp_limits); +void enforce_hpfp_limits(void) { + player_data* playerData = &gPlayerData; + player_data* playerData2 = &gPlayerData; + + playerData->curMaxHP = playerData->hardMaxHP + (is_ability_active(4) * 5); + if (playerData->curMaxHP > 75) { + playerData->curMaxHP = 75; + } + if (playerData->curHP > playerData->curMaxHP) { + playerData->curHP = playerData->curMaxHP; + } + + playerData2->curMaxFP = playerData2->hardMaxFP + (is_ability_active(12) * 5); + if (playerData2->curMaxFP > 75) { + playerData2->curMaxFP = 75; + } + if (playerData2->curFP > playerData2->curMaxFP) { + playerData2->curFP = playerData2->curMaxFP; + } +} INCLUDE_ASM(code_80850_len_3060, initialize_status_menu); diff --git a/papermario/src/code_a5dd0_len_114e0.c b/papermario/src/code_a5dd0_len_114e0.c index be84578032..8db96b5df2 100644 --- a/papermario/src/code_a5dd0_len_114e0.c +++ b/papermario/src/code_a5dd0_len_114e0.c @@ -176,7 +176,7 @@ INCLUDE_ASM(code_a5dd0_len_114e0, func_8011B5D0); INCLUDE_ASM(code_a5dd0_len_114e0, func_8011B660); -INCLUDE_ASM(code_a5dd0_len_114e0, clone_model); +void INCLUDE_ASM(code_a5dd0_len_114e0, clone_model, u16 srcModelID, u16 newModelID); INCLUDE_ASM(code_a5dd0_len_114e0, func_8011B7C0); diff --git a/papermario/src/code_e92d0_len_5da0.c b/papermario/src/code_e92d0_len_5da0.c index 80735a9db0..07984a89b5 100644 --- a/papermario/src/code_e92d0_len_5da0.c +++ b/papermario/src/code_e92d0_len_5da0.c @@ -230,7 +230,14 @@ INCLUDE_ASM(code_e92d0_len_5da0, ScaleModel); INCLUDE_ASM(code_e92d0_len_5da0, GetModelIndex); -INCLUDE_ASM(code_e92d0_len_5da0, CloneModel); +s32 CloneModel(script_context* script) { + s32* thisPos = script->ptrReadPos; + s32 srcModelID = get_variable(script, *thisPos++); + s32 newModelID = get_variable(script, *thisPos++); + + clone_model(srcModelID, newModelID); + return 2; +} INCLUDE_ASM(code_e92d0_len_5da0, GetModelCenter); @@ -268,7 +275,10 @@ INCLUDE_ASM(code_e92d0_len_5da0, GetColliderCenter); INCLUDE_ASM(code_e92d0_len_5da0, ParentColliderToModel); -INCLUDE_ASM(code_e92d0_len_5da0, UpdateColliderTransform); +s32 UpdateColliderTransform(script_context* script) { + update_collider_transform(get_variable(script, *script->ptrReadPos)); + return 2; +} INCLUDE_ASM(code_e92d0_len_5da0, func_802CA1B8); @@ -291,7 +301,12 @@ s32 GotoMapByID(script_context* script) { INCLUDE_ASM(code_e92d0_len_5da0, GetEntryID); -INCLUDE_ASM(code_e92d0_len_5da0, GetMapID); +s32 GetMapID(script_context* script) { + game_status* gameStatus = *gGameStatusPtr; + + set_variable(script, *script->ptrReadPos, gameStatus->mapID); + return 2; +} INCLUDE_ASM(code_e92d0_len_5da0, GetLoadType);