Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Oct 30, 2024
2 parents b2028ac + 01b110e commit ed14cf6
Show file tree
Hide file tree
Showing 19 changed files with 796 additions and 208 deletions.
3 changes: 2 additions & 1 deletion decompile/General/LOAD/LOAD_A33_LangFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void DECOMP_LOAD_LangFile(int bigfilePtr, int lang)
char **strArray;

#if BUILD == EurRetail
// This is (probably) to turn the screen black for a bit until lng is loaded.
// This is to turn the screen black for a bit (optional)
DECOMP_CTR_ErrorScreen(0, 0, 0);
VSync(0);
#endif
Expand Down Expand Up @@ -51,6 +51,7 @@ void DECOMP_LOAD_LangFile(int bigfilePtr, int lang)
(unsigned int)lngFile;
}
#if BUILD == EurRetail
// set voicelines to new lang
DECOMP_CDSYS_SetXAToLang(lang);
#endif
}
6 changes: 6 additions & 0 deletions decompile/General/MAIN/MainMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ u_int DECOMP_main()
// Main Gameplay Update
// Makes up all normal interaction with the game
case 3:
#ifdef USE_LANG
if ((gGT->gameMode2 & LNG_CHANGE) != 0) {
LOAD_LangFile(sdata->ptrBigfileCdPos_2, gGT->langIndex);
gGT->gameMode2 &= ~(LNG_CHANGE);
}
#endif
// if loading, or gameplay interrupted
if (sdata->Loading.stage != -1)
{
Expand Down
5 changes: 3 additions & 2 deletions decompile/General/Vehicle/VehAfterColl_GetTerrain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ struct Terrain* DECOMP_VehAfterColl_GetTerrain(u_char terrainType)
{
struct Terrain* ter = &data.MetaDataTerrain[0];

if (terrainType < 0x15)
// if terrain is valid
if (terrainType < 21)
return &ter[terrainType];

return ter;
}
2 changes: 1 addition & 1 deletion decompile/General/Vehicle/VehBirth_TireSprites.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void DECOMP_VehBirth_TireSprites(struct Thread *t)
d->numFramesSpentSteering = 10000;

#ifndef REBUILD_PS1
d->terrainMeta1 = VehAfterColl_GetTerrain(10);
d->terrainMeta1 = VehAfterColl_GetTerrain(TERRAIN_NONE);
#endif

d->BattleHUD.numLives = gGT->battleLifeLimit;
Expand Down
60 changes: 60 additions & 0 deletions decompile/WorkInProgress/src/231/231_028_RB_Warpball_NewPathNode.c
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 decompile/WorkInProgress/src/231/231_030_RB_Warpball_GetDriverTarget.c
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;
}
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 decompile/WorkInProgress/src/CAM/CAM_18_MapRange_PosPoints.c
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);
}
Loading

0 comments on commit ed14cf6

Please sign in to comment.