-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/CTR-tools/CTR-ModSDK
- Loading branch information
Showing
19 changed files
with
796 additions
and
208 deletions.
There are no files selected for viewing
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
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
60 changes: 60 additions & 0 deletions
60
decompile/WorkInProgress/src/231/231_028_RB_Warpball_NewPathNode.c
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,60 @@ | ||
#include <common.h> | ||
|
||
struct CheckpointNode* DECOMP_RB_Warpball_NewPathNode(struct CheckpointNode *cn, struct Driver *d) | ||
{ | ||
u_char currPoint; | ||
u_int currIndex; | ||
u_char boolPointExists = false; | ||
|
||
struct GameTracker *gGT = sdata->gGT; | ||
|
||
// if no driver is chased | ||
if (d == NULL) | ||
{ | ||
RETURN_NEXT_INDEX: | ||
return &gGT->level1->ptr_restart_points[cn->nextIndex_forward]; | ||
} | ||
|
||
// pathPoint -> left index | ||
currIndex = cn->nextIndex_left; | ||
|
||
// if driver is not near that point | ||
if (d->unknown_lap_related[0] != currIndex) | ||
{ | ||
// if left point is valid | ||
if (cn->nextIndex_left != 0xff) | ||
{ | ||
struct CheckpointNode *currNode = cn; | ||
for (int i = 0; i < 3; i++) | ||
{ | ||
// path index | ||
if (currNode->nextIndex_left == -1) | ||
{ | ||
currPoint = currNode->nextIndex_forward; | ||
} | ||
|
||
// path index | ||
else | ||
{ | ||
currPoint = currNode->nextIndex_left; | ||
} | ||
|
||
// path node | ||
currNode = gGT->level1->ptr_restart_points[currPoint]; | ||
|
||
// compare path index | ||
if (d->unknown_lap_related[0] == currNode->nextIndex_forward) | ||
{ | ||
boolPointExists = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (!boolPointExists) | ||
goto RETURN_NEXT_INDEX; | ||
currIndex = cn->nextIndex_left; | ||
} | ||
|
||
// new path node | ||
return &gGT->level1->ptr_restart_points[currIndex]; | ||
} |
119 changes: 119 additions & 0 deletions
119
decompile/WorkInProgress/src/231/231_030_RB_Warpball_GetDriverTarget.c
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,119 @@ | ||
#include <common.h> | ||
|
||
struct Driver* RB_Warpball_GetDriverTarget(struct TrackerWeapon *tw, struct Instance *inst) | ||
{ | ||
u_int distToFinish; | ||
int currDistance; | ||
int index; | ||
int iVar4; | ||
|
||
struct Driver* currDriver = NULL; | ||
struct Driver* hitDriver = NULL; | ||
|
||
// if 10 wumpa fruit were not used | ||
if ((tw->flags & 1) == 0) | ||
{ | ||
for (index = 0; index < 8; index++) | ||
{ | ||
// check next driver until you get the driver | ||
// farthest in the lead, that has not finished race | ||
currDriver = sdata->gGT->drivers[index]; | ||
|
||
// if driver is valid | ||
if (((currDriver != NULL) && | ||
|
||
// if driver is not the same as driver that fired warpball | ||
(currDriver != tw->driverParent)) && | ||
|
||
// if the race is not over for this driver | ||
((currDriver->actionsFlagSet & 0x2000000) == 0)) | ||
{ | ||
return currDriver; | ||
} | ||
} | ||
} | ||
|
||
// if 10 wumpa fruit were used | ||
else | ||
{ | ||
// start of lev->path | ||
struct CheckpointNode* cn = &sdata->gGT->level1->ptr_restart_points[0]; | ||
|
||
// node1 | ||
struct CheckpointNode* node1 = &cn[tw->ptrNodeCurr->nextIndex_forward]; | ||
|
||
// node2 | ||
struct CheckpointNode* node2 = &cn[node1->nextIndex_forward]; | ||
|
||
u_int distToFinish = cn->distToFinish * 8; | ||
|
||
short vec1[4]; | ||
// direction from node1 to node2 | ||
vec1[0] = node1->pos[0] - node2->pos[0]; | ||
vec1[1] = node1->pos[1] - node2->pos[1]; | ||
vec1[2] = node1->pos[2] - node2->pos[2]; | ||
|
||
MATH_VectorNormalize(&vec1[0]); | ||
|
||
short vec2[4]; | ||
// direction from orb to node1 | ||
vec2[0] = inst->matrix.t[0] - node1.pos[0]; | ||
vec2[1] = inst->matrix.t[1] - node1.pos[1]; | ||
vec2[2] = inst->matrix.t[2] - node1.pos[2]; | ||
|
||
// replace R11R12 and R13R21 | ||
gte_ldsvrtrow0(&vec1[0]); | ||
|
||
gte_ldv0(&vec2[0]); | ||
|
||
gte_mvmva(0,0,0,3,0); | ||
|
||
// replace stMAC1 | ||
gte_stlvnl0(&iVar4); | ||
|
||
u_int maxDistance = 0x7fffffff; | ||
|
||
iVar4 = node1->distanceToFinish * 8 + (iVar4 >> 0xc) + 0x200; | ||
|
||
#if 0 | ||
if (uVar1 == 0) | ||
{ | ||
trap(0x1c00); | ||
} | ||
if ((distToFinish == -1) && (iVar4 == -0x80000000)) | ||
{ | ||
trap(0x1800); | ||
} | ||
#endif | ||
|
||
for (index = 0; index < 8; index++) | ||
{ | ||
// pointer to structure of each player | ||
currDriver = sdata->gGT->drivers[index]; | ||
|
||
// if driver is valid | ||
if (((currDriver != NULL) && | ||
((tw->driversHit & 1 << (index & 0x1fU)) == 0)) && | ||
(( | ||
// If the race is not over for this player | ||
(currDriver->actionsFlagSet & 0x2000000) == 0 && | ||
|
||
// If you are not being mask-grabbed | ||
(currDriver->kartState != KS_MASK_GRABBED)))) | ||
{ | ||
currDistance = iVar4 % distToFinish - currDriver->distanceToFinish_curr; | ||
|
||
if (currDistance < 0) | ||
{ | ||
currDistance += distToFinish; | ||
} | ||
if (currDistance < maxDistance) | ||
{ | ||
maxDistance = currDistance; | ||
hitDriver = currDriver; | ||
} | ||
} | ||
} | ||
} | ||
return hitDriver; | ||
} |
79 changes: 79 additions & 0 deletions
79
decompile/WorkInProgress/src/231/231_031_RB_Warpball_SetTargetDriver.c
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,79 @@ | ||
#include <common.h> | ||
|
||
void RB_Warpball_SetTargetDriver(struct TrackerWeapon *tw) | ||
{ | ||
int distance; | ||
int i, j; | ||
int local_20; | ||
int local_1c; | ||
|
||
struct GameTracker *gGT = sdata->gGT; | ||
|
||
// driver being chased | ||
struct Driver *target = tw->driverTarget; | ||
|
||
// if driver is valid | ||
if (target == NULL) | ||
return; | ||
|
||
distance = target->distanceToFinish_curr; | ||
|
||
// path node | ||
struct CheckpointNode *firstNode = &gGT->level->ptr_restart_points[0]; | ||
struct CheckpointNode *currNode = &first[target->unknown_lap_related]; | ||
|
||
// distance is less than path node distance | ||
while ((distance <= (thisNode->distToFinish << 3) && | ||
|
||
// path node is not first node | ||
(currNode != firstNode))) | ||
{ | ||
currNode = RB_Warpball_NewPathNode(currNode, tw->driverTarget); | ||
} | ||
|
||
target = NULL; | ||
local_1c = 0; | ||
thisNode = tw->ptrNodeCurr; | ||
|
||
if ((tw->flags & 4) == 0) | ||
{ | ||
for (i = 0; i < 2; i++) | ||
{ | ||
distance = *(int *)((int)&local_20 + (distance >> 0xe)); | ||
if (distance != 0) | ||
{ | ||
thisNode = 0; | ||
for (j = 0; j < 3; j++) | ||
{ | ||
if (distance == currNode) | ||
{ | ||
tw->flags = tw->flags & 0xfff7 | 4; | ||
break; | ||
} | ||
if (*(byte *)(distance + 0xb) != 0xff) | ||
{ | ||
// path node | ||
local_1c = *(int *)(*(int *)(gGT + 0x160) + 0x14c) + | ||
(uint) * (byte *)(distance + 0xb) * 0xc; | ||
} | ||
|
||
// path node | ||
distance = *(int *)(*(int *)(gGT + 0x160) + 0x14c) + (uint) * (byte *)(distance + 10) * 0xc; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// path node | ||
thisNode = tw->ptrNodeCurr; | ||
|
||
for (i = 0; i < 3; i++) | ||
{ | ||
if (thisNode == currNode) | ||
{ | ||
tw->flags = tw->flags & ~(8) | 4; | ||
return; | ||
} | ||
target = RB_Warpball_NewPathNode(target, tw->driverTarget); | ||
} | ||
} |
31 changes: 16 additions & 15 deletions
31
decompile/WorkInProgress/src/CAM/CAM_18_MapRange_PosPoints.c
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 |
---|---|---|
@@ -1,30 +1,31 @@ | ||
#include <common.h> | ||
|
||
// get percentage [0 to 0x1000] of Driver between pos1 and pos2 | ||
int DECOMP_CAM_MapRange_PosPoints(short *pos1, short *pos2, short *currPos) | ||
int DECOMP_CAM_MapRange_PosPoints(SVec3 *pos1, SVec3 *pos2, SVec3 *currPos) | ||
{ | ||
int percent; | ||
int vectorDistMax; | ||
int vectorDistCurr; | ||
SVec3 vec1; | ||
SVec3 vec2; | ||
short distY; | ||
|
||
// vector distance between position1 and position2. | ||
vectorDistMax = CONCAT22(pos1[1] - pos2[1], pos1[0] - pos2[0]); | ||
|
||
distY = pos1[2] - pos2[2]; | ||
|
||
MATH_VectorNormalize(&vectorDistMax); | ||
vec1.x = pos1->x - pos2->x; | ||
vec1.y = pos1->y - pos2->y; | ||
vec1.z = pos1->z - pos2->z; | ||
|
||
MATH_VectorNormalize(&vec1); | ||
|
||
// vector distance between position1 and currentPosition. | ||
vectorDistCurr = CONCAT22(currPos[1] - pos1[1], currPos[0] - pos1[0]); | ||
vec2.x = pos1->x - currPos->x; | ||
vec2.y = pos1->y - currPos->y; | ||
vec2.z = pos1->z - currPos->z; | ||
|
||
gte_ldR11R12(vectorDistMax); | ||
gte_ldR13R21((int)distY); | ||
gte_ldVXY0(vectorDistCurr); | ||
gte_ldVZ0((int)(short)(currPos[2] - pos1[2])); | ||
// replace R11R12 and R13R21 | ||
gte_ldsvrtrow0(&vec1); | ||
gte_ldv0(&vec2); | ||
gte_mvmva(0, 0, 0, 3, 0); | ||
percent = gte_stMAC1(); | ||
gte_stlvnl0(&percent); | ||
|
||
// Shift by 12 bits to get the percentage between 0 and 0x1000. | ||
return percent >> 0xc; | ||
return FP_INT(percent); | ||
} |
Oops, something went wrong.