-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from DizzyEggg/sub_80869E4
Match sub_80869E4 and sub_8002A70 with correct params
- Loading branch information
Showing
8 changed files
with
587 additions
and
683 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef GUARD_CODE_8002774_H | ||
#define GUARD_CODE_8002774_H | ||
|
||
s32 sub_8002A70(s32 a0, s32 a1, s32 a2); | ||
s32 sub_8002B04(s32, s32); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "global.h" | ||
#include "code_8002774.h" | ||
#include "constants/direction.h" | ||
|
||
s32 sub_8002A70(s32 _direction1, s32 _direction2, s32 _caseId) | ||
{ | ||
s32 direction1 = (s8)(_direction1); | ||
s32 direction2 = (s8)(_direction2); | ||
s32 caseId = (u8)(_caseId); | ||
|
||
if (direction1 == direction2) | ||
return direction1; | ||
|
||
switch (caseId) { | ||
case 1: | ||
if (direction1 >= 0) { | ||
direction1 += 7; | ||
direction1 &= DIRECTION_MASK; | ||
} | ||
break; | ||
case 2: | ||
if (direction1 >= 0) { | ||
direction1 += 1; | ||
direction1 &= DIRECTION_MASK; | ||
} | ||
break; | ||
case 3: | ||
if (direction1 >= 0) { | ||
direction1 += 6; | ||
direction1 &= DIRECTION_MASK; | ||
} | ||
break; | ||
case 4: | ||
if (direction1 >= 0) { | ||
direction1 += 2; | ||
direction1 &= DIRECTION_MASK; | ||
} | ||
break; | ||
case 11: | ||
direction1 = sub_8002B04(direction1, direction2); | ||
// Fallthrough | ||
case 10: | ||
direction1 = sub_8002B04(direction1, direction2); | ||
break; | ||
} | ||
return direction1; | ||
} | ||
|
||
s32 sub_8002B04(s32 _direction1, s32 _direction2) | ||
{ | ||
s32 direction1 = (s8)(_direction1); | ||
s32 direction2 = (s8)(_direction2); | ||
|
||
if (direction2 != -1) | ||
{ | ||
s32 newDirection = ((direction2 + NUM_DIRECTIONS) - direction1) % NUM_DIRECTIONS; | ||
|
||
if (newDirection != 0) { | ||
if (newDirection < 4) | ||
newDirection = (direction1 + 1) % NUM_DIRECTIONS; | ||
else | ||
newDirection = (direction1 + 7) % NUM_DIRECTIONS; | ||
|
||
direction1 = (s8)newDirection; | ||
} | ||
} | ||
return direction1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters