From 99a81611f6875d12a3cc931e9cd4e46986749f4e Mon Sep 17 00:00:00 2001 From: Technoman Date: Thu, 4 Nov 2021 02:08:36 -0400 Subject: [PATCH] Match ModifyActorDecoration, func_8026EA7C, get_coin_drop_amount (#516) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Match get_coin_drop_amount * Delete get_coin_drop_amount.s * Match func_8026EA7C * Delete func_8026EA7C.s * extern func_80266D6C * Match ModifyActorDecoration * Update DecorationTable * Update ModifyActorDecoration * Fixed DecorationTable * Delete ModifyActorDecoration.s * Update DecorationTable * Update DecorationTable * Fixed DecorationTable, Added DecorationUnk * Fixed DecorationTable? * Update func_80266dc, create_part_shadow_by_ref * Update get_coin_drop_amount * func_8026EA7C Co-authored-by: Alexander Faßbender <31699028+Brotenko@users.noreply.github.com> * Update DecorationTable * Update get_coin_drop_amount * Update DecorationUnk * Update get_coin_drop_amount * Update get_coin_drop_amount * Update DecorationUnk Co-authored-by: Alex Bates Co-authored-by: Alexander Faßbender <31699028+Brotenko@users.noreply.github.com> Co-authored-by: Alex Bates --- include/common_structs.h | 15 +++- include/functions.h | 4 +- src/197F40.c | 41 ++++++++++- src/23680.c | 30 +++----- .../197F40/ModifyActorDecoration.s | 68 ------------------ .../asm/nonmatchings/197F40/func_8026EA7C.s | 46 ------------ .../nonmatchings/23680/get_coin_drop_amount.s | 70 ------------------- 7 files changed, 66 insertions(+), 208 deletions(-) delete mode 100644 ver/us/asm/nonmatchings/197F40/ModifyActorDecoration.s delete mode 100644 ver/us/asm/nonmatchings/197F40/func_8026EA7C.s delete mode 100644 ver/us/asm/nonmatchings/23680/get_coin_drop_amount.s diff --git a/include/common_structs.h b/include/common_structs.h index 460db9ce2b..828870e306 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1426,6 +1426,17 @@ typedef struct CollisionStatus { /* 0x1C */ Vec3f bombetteExplosionPos; } CollisionStatus; // size = 0x28 +typedef struct DecorationUnk { + /* 0x00 */ s16 unk00; + /* 0x04 */ s16 unk04; + /* 0x08 */ s16 unk08; + /* 0x0C */ s16 unk0C; + /* 0x10 */ s16 unk10; + /* 0x14 */ s16 unk14; + /* 0x18 */ s16 unk18; + /* 0x1C */ s16 unk1C; +} DecorationUnk; // size = 0x20 + typedef struct DecorationTable { /* 0x000 */ char unk_00[1729]; /* 0x6C1 */ s8 unk_6C1; @@ -1465,8 +1476,8 @@ typedef struct DecorationTable { /* 0x8B8 */ s8 decorationType[2]; /* 0x8BA */ u8 unk_8BA[2]; /* 0x8BC */ u8 unk_8BC[2]; - /* 0x8C0 */ s16 unk_8C0[6]; - /* 0x8BE */ char unk_8BE[30]; + /* 0x8C0 */ s16 unk_8C0[4]; + /* 0x8C6 */ DecorationUnk unk_8C6[2]; } DecorationTable; // size = 0x8E8 typedef struct ShopOwner { diff --git a/include/functions.h b/include/functions.h index e09048a23a..f00bf19874 100644 --- a/include/functions.h +++ b/include/functions.h @@ -368,7 +368,9 @@ s32 player_team_is_ability_active(Actor* actor, s32 ability); void create_part_shadow(s32 actorID, s32 partIndex); void remove_part_shadow(s32 actorID, s32 partIndex); -void create_part_shadow_by_ref(UNK_TYPE arg0, ActorPart* part); // arg0 unused +void create_part_shadow_by_ref(s32 arg0, ActorPart* part); + +s32 func_80266D6C(ActorPart*, s32); Evt* get_script_by_index(s32 index); diff --git a/src/197F40.c b/src/197F40.c index b3a5bf3884..68bc3ce619 100644 --- a/src/197F40.c +++ b/src/197F40.c @@ -2277,7 +2277,23 @@ ApiStatus GetDistanceToGoal(Evt* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "197F40", func_8026EA7C); +ApiStatus func_8026EA7C(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 actorID = evt_get_variable(script, *args++); + s32 partIndex = evt_get_variable(script, *args++); + s32 temp_s3 = evt_get_variable(script, *args++); + Actor* actor; + ActorPart* actorPart; + + if (actorID == ACTOR_SELF) { + actorID = script->owner1.actorID; + } + + actor = get_actor(actorID); + actorPart = get_actor_part(actor, partIndex); + func_80266D6C(actorPart, temp_s3); + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "197F40", func_8026EB20); @@ -2324,7 +2340,28 @@ ApiStatus RemoveActorDecoration(Evt* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "197F40", ModifyActorDecoration); +ApiStatus ModifyActorDecoration(Evt* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 actorID = evt_get_variable(script, *args++); + s32 partIndex = evt_get_variable(script, *args++); + s32 temp_s4 = evt_get_variable(script, *args++); + ActorPart* actorPart; + DecorationTable* decorationtable; + Actor* actor; + + if (actorID == ACTOR_SELF) { + actorID = script->owner1.actorID; + } + + actor = get_actor(actorID); + actorPart = get_actor_part(actor, partIndex); + decorationtable = actorPart->decorationTable; + decorationtable->unk_8C6[temp_s4].unk00 = evt_get_variable(script, *args++); + decorationtable->unk_8C6[temp_s4].unk04 = evt_get_variable(script, *args++); + decorationtable->unk_8C6[temp_s4].unk08 = evt_get_variable(script, *args++); + decorationtable->unk_8C6[temp_s4].unk0C = evt_get_variable(script, *args++); + return ApiStatus_DONE2; +} ApiStatus UseIdleAnimation(Evt* script, s32 isInitialCall) { Actor* actor; diff --git a/src/23680.c b/src/23680.c index e438f52002..c0d9a89e7d 100644 --- a/src/23680.c +++ b/src/23680.c @@ -3,26 +3,21 @@ INCLUDE_ASM(s32, "23680", spawn_drops); -// The issues here are only in the beginning where max and min are flipped -#ifdef NON_MATCHING s32 get_coin_drop_amount(Enemy* enemy) { EncounterStatus* currentEncounter = &gCurrentEncounter; - s32 amt; - s32 mx; - s32 diff; + EnemyDrops* enemyDrops = enemy->drops; + s32 maxCoinBonus = enemyDrops->maxCoinBonus; + s32 amt = enemyDrops->minCoinBonus; + s32 minTemp = enemyDrops->minCoinBonus; - amt = enemy->drops->minCoinBonus; - mx = enemy->drops->maxCoinBonus; - - if (enemy->drops->minCoinBonus > enemy->drops->maxCoinBonus) { - amt = enemy->drops->maxCoinBonus; - mx = enemy->drops->minCoinBonus; + if (maxCoinBonus < amt) { + amt = enemyDrops->maxCoinBonus; + maxCoinBonus = enemyDrops->minCoinBonus; } - diff = mx - amt; - - if ((amt < 0) || (diff != 0)) { - amt = rand_int(diff) + amt; + minTemp = maxCoinBonus - amt; + if ((amt < 0) || (minTemp != 0)) { + amt = rand_int(minTemp) - -amt; } if (amt < 0) { @@ -33,7 +28,7 @@ s32 get_coin_drop_amount(Enemy* enemy) { amt += currentEncounter->damageTaken / 2; } - if (currentEncounter->merleeCoinBonus != 0) { + if (currentEncounter->merleeCoinBonus) { amt *= 3; } @@ -53,9 +48,6 @@ s32 get_coin_drop_amount(Enemy* enemy) { return amt; } -#else -INCLUDE_ASM(s32, "23680", get_coin_drop_amount); -#endif void func_80048E34(Enemy* enemy, s32 arg1, s32 arg2) { Evt* newScript; diff --git a/ver/us/asm/nonmatchings/197F40/ModifyActorDecoration.s b/ver/us/asm/nonmatchings/197F40/ModifyActorDecoration.s deleted file mode 100644 index c681158673..0000000000 --- a/ver/us/asm/nonmatchings/197F40/ModifyActorDecoration.s +++ /dev/null @@ -1,68 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel ModifyActorDecoration -/* 19D8D0 8026EFF0 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 19D8D4 8026EFF4 AFB20018 */ sw $s2, 0x18($sp) -/* 19D8D8 8026EFF8 0080902D */ daddu $s2, $a0, $zero -/* 19D8DC 8026EFFC AFBF0024 */ sw $ra, 0x24($sp) -/* 19D8E0 8026F000 AFB40020 */ sw $s4, 0x20($sp) -/* 19D8E4 8026F004 AFB3001C */ sw $s3, 0x1c($sp) -/* 19D8E8 8026F008 AFB10014 */ sw $s1, 0x14($sp) -/* 19D8EC 8026F00C AFB00010 */ sw $s0, 0x10($sp) -/* 19D8F0 8026F010 8E51000C */ lw $s1, 0xc($s2) -/* 19D8F4 8026F014 8E250000 */ lw $a1, ($s1) -/* 19D8F8 8026F018 0C0B1EAF */ jal evt_get_variable -/* 19D8FC 8026F01C 26310004 */ addiu $s1, $s1, 4 -/* 19D900 8026F020 0040802D */ daddu $s0, $v0, $zero -/* 19D904 8026F024 8E250000 */ lw $a1, ($s1) -/* 19D908 8026F028 26310004 */ addiu $s1, $s1, 4 -/* 19D90C 8026F02C 0C0B1EAF */ jal evt_get_variable -/* 19D910 8026F030 0240202D */ daddu $a0, $s2, $zero -/* 19D914 8026F034 8E250000 */ lw $a1, ($s1) -/* 19D918 8026F038 26310004 */ addiu $s1, $s1, 4 -/* 19D91C 8026F03C 0240202D */ daddu $a0, $s2, $zero -/* 19D920 8026F040 0C0B1EAF */ jal evt_get_variable -/* 19D924 8026F044 0040982D */ daddu $s3, $v0, $zero -/* 19D928 8026F048 0040A02D */ daddu $s4, $v0, $zero -/* 19D92C 8026F04C 2402FF81 */ addiu $v0, $zero, -0x7f -/* 19D930 8026F050 16020002 */ bne $s0, $v0, .L8026F05C -/* 19D934 8026F054 00000000 */ nop -/* 19D938 8026F058 8E500148 */ lw $s0, 0x148($s2) -.L8026F05C: -/* 19D93C 8026F05C 0C09A75B */ jal get_actor -/* 19D940 8026F060 0200202D */ daddu $a0, $s0, $zero -/* 19D944 8026F064 0040202D */ daddu $a0, $v0, $zero -/* 19D948 8026F068 0C099117 */ jal get_actor_part -/* 19D94C 8026F06C 0260282D */ daddu $a1, $s3, $zero -/* 19D950 8026F070 8E250000 */ lw $a1, ($s1) -/* 19D954 8026F074 26310004 */ addiu $s1, $s1, 4 -/* 19D958 8026F078 8C5000C0 */ lw $s0, 0xc0($v0) -/* 19D95C 8026F07C 0C0B1EAF */ jal evt_get_variable -/* 19D960 8026F080 0240202D */ daddu $a0, $s2, $zero -/* 19D964 8026F084 00141900 */ sll $v1, $s4, 4 -/* 19D968 8026F088 02038021 */ addu $s0, $s0, $v1 -/* 19D96C 8026F08C A60208C6 */ sh $v0, 0x8c6($s0) -/* 19D970 8026F090 8E250000 */ lw $a1, ($s1) -/* 19D974 8026F094 26310004 */ addiu $s1, $s1, 4 -/* 19D978 8026F098 0C0B1EAF */ jal evt_get_variable -/* 19D97C 8026F09C 0240202D */ daddu $a0, $s2, $zero -/* 19D980 8026F0A0 A60208C8 */ sh $v0, 0x8c8($s0) -/* 19D984 8026F0A4 8E250000 */ lw $a1, ($s1) -/* 19D988 8026F0A8 26310004 */ addiu $s1, $s1, 4 -/* 19D98C 8026F0AC 0C0B1EAF */ jal evt_get_variable -/* 19D990 8026F0B0 0240202D */ daddu $a0, $s2, $zero -/* 19D994 8026F0B4 A60208CA */ sh $v0, 0x8ca($s0) -/* 19D998 8026F0B8 8E250000 */ lw $a1, ($s1) -/* 19D99C 8026F0BC 0C0B1EAF */ jal evt_get_variable -/* 19D9A0 8026F0C0 0240202D */ daddu $a0, $s2, $zero -/* 19D9A4 8026F0C4 A60208CC */ sh $v0, 0x8cc($s0) -/* 19D9A8 8026F0C8 8FBF0024 */ lw $ra, 0x24($sp) -/* 19D9AC 8026F0CC 8FB40020 */ lw $s4, 0x20($sp) -/* 19D9B0 8026F0D0 8FB3001C */ lw $s3, 0x1c($sp) -/* 19D9B4 8026F0D4 8FB20018 */ lw $s2, 0x18($sp) -/* 19D9B8 8026F0D8 8FB10014 */ lw $s1, 0x14($sp) -/* 19D9BC 8026F0DC 8FB00010 */ lw $s0, 0x10($sp) -/* 19D9C0 8026F0E0 24020002 */ addiu $v0, $zero, 2 -/* 19D9C4 8026F0E4 03E00008 */ jr $ra -/* 19D9C8 8026F0E8 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/ver/us/asm/nonmatchings/197F40/func_8026EA7C.s b/ver/us/asm/nonmatchings/197F40/func_8026EA7C.s deleted file mode 100644 index eb26f4e8ec..0000000000 --- a/ver/us/asm/nonmatchings/197F40/func_8026EA7C.s +++ /dev/null @@ -1,46 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8026EA7C -/* 19D35C 8026EA7C 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 19D360 8026EA80 AFB20018 */ sw $s2, 0x18($sp) -/* 19D364 8026EA84 0080902D */ daddu $s2, $a0, $zero -/* 19D368 8026EA88 AFBF0020 */ sw $ra, 0x20($sp) -/* 19D36C 8026EA8C AFB3001C */ sw $s3, 0x1c($sp) -/* 19D370 8026EA90 AFB10014 */ sw $s1, 0x14($sp) -/* 19D374 8026EA94 AFB00010 */ sw $s0, 0x10($sp) -/* 19D378 8026EA98 8E50000C */ lw $s0, 0xc($s2) -/* 19D37C 8026EA9C 8E050000 */ lw $a1, ($s0) -/* 19D380 8026EAA0 0C0B1EAF */ jal evt_get_variable -/* 19D384 8026EAA4 26100004 */ addiu $s0, $s0, 4 -/* 19D388 8026EAA8 0040882D */ daddu $s1, $v0, $zero -/* 19D38C 8026EAAC 8E050000 */ lw $a1, ($s0) -/* 19D390 8026EAB0 26100004 */ addiu $s0, $s0, 4 -/* 19D394 8026EAB4 0C0B1EAF */ jal evt_get_variable -/* 19D398 8026EAB8 0240202D */ daddu $a0, $s2, $zero -/* 19D39C 8026EABC 0240202D */ daddu $a0, $s2, $zero -/* 19D3A0 8026EAC0 8E050000 */ lw $a1, ($s0) -/* 19D3A4 8026EAC4 0C0B1EAF */ jal evt_get_variable -/* 19D3A8 8026EAC8 0040802D */ daddu $s0, $v0, $zero -/* 19D3AC 8026EACC 0040982D */ daddu $s3, $v0, $zero -/* 19D3B0 8026EAD0 2402FF81 */ addiu $v0, $zero, -0x7f -/* 19D3B4 8026EAD4 16220002 */ bne $s1, $v0, .L8026EAE0 -/* 19D3B8 8026EAD8 00000000 */ nop -/* 19D3BC 8026EADC 8E510148 */ lw $s1, 0x148($s2) -.L8026EAE0: -/* 19D3C0 8026EAE0 0C09A75B */ jal get_actor -/* 19D3C4 8026EAE4 0220202D */ daddu $a0, $s1, $zero -/* 19D3C8 8026EAE8 0040202D */ daddu $a0, $v0, $zero -/* 19D3CC 8026EAEC 0C099117 */ jal get_actor_part -/* 19D3D0 8026EAF0 0200282D */ daddu $a1, $s0, $zero -/* 19D3D4 8026EAF4 0040202D */ daddu $a0, $v0, $zero -/* 19D3D8 8026EAF8 0C099B5B */ jal func_80266D6C -/* 19D3DC 8026EAFC 0260282D */ daddu $a1, $s3, $zero -/* 19D3E0 8026EB00 8FBF0020 */ lw $ra, 0x20($sp) -/* 19D3E4 8026EB04 8FB3001C */ lw $s3, 0x1c($sp) -/* 19D3E8 8026EB08 8FB20018 */ lw $s2, 0x18($sp) -/* 19D3EC 8026EB0C 8FB10014 */ lw $s1, 0x14($sp) -/* 19D3F0 8026EB10 8FB00010 */ lw $s0, 0x10($sp) -/* 19D3F4 8026EB14 24020002 */ addiu $v0, $zero, 2 -/* 19D3F8 8026EB18 03E00008 */ jr $ra -/* 19D3FC 8026EB1C 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/ver/us/asm/nonmatchings/23680/get_coin_drop_amount.s b/ver/us/asm/nonmatchings/23680/get_coin_drop_amount.s deleted file mode 100644 index 2c1bddb364..0000000000 --- a/ver/us/asm/nonmatchings/23680/get_coin_drop_amount.s +++ /dev/null @@ -1,70 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel get_coin_drop_amount -/* 24150 80048D50 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 24154 80048D54 AFB20018 */ sw $s2, 0x18($sp) -/* 24158 80048D58 0080902D */ daddu $s2, $a0, $zero -/* 2415C 80048D5C AFBF001C */ sw $ra, 0x1c($sp) -/* 24160 80048D60 AFB10014 */ sw $s1, 0x14($sp) -/* 24164 80048D64 AFB00010 */ sw $s0, 0x10($sp) -/* 24168 80048D68 8E4200D4 */ lw $v0, 0xd4($s2) -/* 2416C 80048D6C 3C11800B */ lui $s1, %hi(gCurrentEncounter) -/* 24170 80048D70 26310F10 */ addiu $s1, $s1, %lo(gCurrentEncounter) -/* 24174 80048D74 845000B2 */ lh $s0, 0xb2($v0) -/* 24178 80048D78 844300B4 */ lh $v1, 0xb4($v0) -/* 2417C 80048D7C 0070102A */ slt $v0, $v1, $s0 -/* 24180 80048D80 10400003 */ beqz $v0, .L80048D90 -/* 24184 80048D84 0200202D */ daddu $a0, $s0, $zero -/* 24188 80048D88 0060802D */ daddu $s0, $v1, $zero -/* 2418C 80048D8C 0080182D */ daddu $v1, $a0, $zero -.L80048D90: -/* 24190 80048D90 06000003 */ bltz $s0, .L80048DA0 -/* 24194 80048D94 00702023 */ subu $a0, $v1, $s0 -/* 24198 80048D98 10800004 */ beqz $a0, .L80048DAC -/* 2419C 80048D9C 00000000 */ nop -.L80048DA0: -/* 241A0 80048DA0 0C00A67F */ jal rand_int -/* 241A4 80048DA4 00000000 */ nop -/* 241A8 80048DA8 00508021 */ addu $s0, $v0, $s0 -.L80048DAC: -/* 241AC 80048DAC 06020001 */ bltzl $s0, .L80048DB4 -/* 241B0 80048DB0 0000802D */ daddu $s0, $zero, $zero -.L80048DB4: -/* 241B4 80048DB4 0C03A752 */ jal is_ability_active -/* 241B8 80048DB8 24040019 */ addiu $a0, $zero, 0x19 -/* 241BC 80048DBC 10400004 */ beqz $v0, .L80048DD0 -/* 241C0 80048DC0 00000000 */ nop -/* 241C4 80048DC4 9222000C */ lbu $v0, 0xc($s1) -/* 241C8 80048DC8 00021042 */ srl $v0, $v0, 1 -/* 241CC 80048DCC 02028021 */ addu $s0, $s0, $v0 -.L80048DD0: -/* 241D0 80048DD0 8222000B */ lb $v0, 0xb($s1) -/* 241D4 80048DD4 10400002 */ beqz $v0, .L80048DE0 -/* 241D8 80048DD8 00101040 */ sll $v0, $s0, 1 -/* 241DC 80048DDC 02028021 */ addu $s0, $s0, $v0 -.L80048DE0: -/* 241E0 80048DE0 0C03A752 */ jal is_ability_active -/* 241E4 80048DE4 24040010 */ addiu $a0, $zero, 0x10 -/* 241E8 80048DE8 54400001 */ bnel $v0, $zero, .L80048DF0 -/* 241EC 80048DEC 00108040 */ sll $s0, $s0, 1 -.L80048DF0: -/* 241F0 80048DF0 8622000E */ lh $v0, 0xe($s1) -/* 241F4 80048DF4 02028021 */ addu $s0, $s0, $v0 -/* 241F8 80048DF8 8E420000 */ lw $v0, ($s2) -/* 241FC 80048DFC 3C030084 */ lui $v1, 0x84 -/* 24200 80048E00 00431024 */ and $v0, $v0, $v1 -/* 24204 80048E04 54400001 */ bnel $v0, $zero, .L80048E0C -/* 24208 80048E08 0000802D */ daddu $s0, $zero, $zero -.L80048E0C: -/* 2420C 80048E0C 2A020015 */ slti $v0, $s0, 0x15 -/* 24210 80048E10 50400001 */ beql $v0, $zero, .L80048E18 -/* 24214 80048E14 24100014 */ addiu $s0, $zero, 0x14 -.L80048E18: -/* 24218 80048E18 0200102D */ daddu $v0, $s0, $zero -/* 2421C 80048E1C 8FBF001C */ lw $ra, 0x1c($sp) -/* 24220 80048E20 8FB20018 */ lw $s2, 0x18($sp) -/* 24224 80048E24 8FB10014 */ lw $s1, 0x14($sp) -/* 24228 80048E28 8FB00010 */ lw $s0, 0x10($sp) -/* 2422C 80048E2C 03E00008 */ jr $ra -/* 24230 80048E30 27BD0020 */ addiu $sp, $sp, 0x20