Decomp btl_are_all_enemies_defeated (#337)

* Initial decomp

* Rearrange variable definitions and if-statements

* Getting closer to matching

* Only address matching left

* Rename variables for clarity

* Search and replace was too eager...

* Rewrite as a for-loop. Matches!

* Removed and renamed variables

* Rearrange statements for neatness. Remove unneccessary comments

* Ran coverage

* Change the typing to Actor*

* Rename variables, don't be so literal with return values, and compare pointer to NULL, you dunce

* Move variable definitions around
This commit is contained in:
Nalfein (Kenny) 2021-07-21 10:37:24 -04:00 committed by GitHub
parent d23a6cabdf
commit 22fa63e393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 27 deletions

View File

@ -1072,7 +1072,26 @@ INCLUDE_ASM(s32, "190B20", func_80263268);
INCLUDE_ASM(s32, "190B20", func_80263300);
INCLUDE_ASM(s32, "190B20", btl_are_all_enemies_defeated);
s32 btl_are_all_enemies_defeated(void) {
BattleStatus* battleStatus = &gBattleStatus;
Actor* enemy;
s32 enemiesStillAlive = FALSE;
s32 i;
for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
s32 flagEnemyDefeated = 0x404000;
enemy = battleStatus->enemyActors[i];
// If currentEnemyFlags signify that the enemy isn't dead yet...
if (enemy != NULL) {
if (!(enemy->flags & flagEnemyDefeated)) {
// Countinue the battle
enemiesStillAlive = TRUE;
}
}
}
return !enemiesStillAlive;
}
s32 btl_check_enemies_defeated(void) {
if (btl_are_all_enemies_defeated()) {

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel btl_are_all_enemies_defeated
/* 191CC8 802633E8 0000282D */ daddu $a1, $zero, $zero
/* 191CCC 802633EC 00A0202D */ daddu $a0, $a1, $zero
/* 191CD0 802633F0 3C060040 */ lui $a2, 0x40
/* 191CD4 802633F4 34C64000 */ ori $a2, $a2, 0x4000
/* 191CD8 802633F8 3C03800E */ lui $v1, %hi(gBattleStatus)
/* 191CDC 802633FC 2463C070 */ addiu $v1, $v1, %lo(gBattleStatus)
.L80263400:
/* 191CE0 80263400 8C6200E0 */ lw $v0, 0xe0($v1)
/* 191CE4 80263404 50400006 */ beql $v0, $zero, .L80263420
/* 191CE8 80263408 24840001 */ addiu $a0, $a0, 1
/* 191CEC 8026340C 8C420000 */ lw $v0, ($v0)
/* 191CF0 80263410 00461024 */ and $v0, $v0, $a2
/* 191CF4 80263414 50400001 */ beql $v0, $zero, .L8026341C
/* 191CF8 80263418 24050001 */ addiu $a1, $zero, 1
.L8026341C:
/* 191CFC 8026341C 24840001 */ addiu $a0, $a0, 1
.L80263420:
/* 191D00 80263420 28820018 */ slti $v0, $a0, 0x18
/* 191D04 80263424 1440FFF6 */ bnez $v0, .L80263400
/* 191D08 80263428 24630004 */ addiu $v1, $v1, 4
/* 191D0C 8026342C 03E00008 */ jr $ra
/* 191D10 80263430 38A20001 */ xori $v0, $a1, 1