Skip to content

Commit

Permalink
Decomp (#197)
Browse files Browse the repository at this point in the history
* Lang_Change on Decomp

* Decomp progress

* 2 / 4 WarpBall funcs remaining

* RefreshCard
  • Loading branch information
FRDS authored Oct 17, 2024
1 parent f70ed7d commit ae2add5
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 7 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
int RefreshCard_BoolGhostForLEV(u_short trackID)
{
short numGhost = 0;

// if ghost profiles are present
if (sdata->numGhostProfilesSaved){
// loop through ghost profiles
for (char i = 0; i < sdata->numGhostProfilesSaved - 1; i++)
{
// Check trackID of each profile
if (sdata->ghostProfile_memcard[i].trackID == trackID)
{
numGhost++;
}
}
}
return numGhost;
}
23 changes: 23 additions & 0 deletions decompile/WorkInProgress/src/RefreshCard/RefreshCard_GetResult.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <common.h>

u_int RefreshCard_GetResult(short searchResult)
{
// MC_RESULT_FINISHED
if ((searchResult == 8) &&
((sdata->memcardUnk1 & 6) != 0))
{
return true;
}

u_int boolFound = false;

if (((sdata->memcardUnk1 & 6) == 0) &&
// if frame3 == frame4
(sdata->frame3_memcardAction == sdata->frame4_memcardAction) &&
(sdata->frame3_memcardSlot == sdata->frame4_memcardSlot))
{
// is desired_memcardResult == WhatYouLookFor?
boolFound = (sdata->desired_memcardResult == searchResult);
}
return boolFound;
}
Loading

0 comments on commit ae2add5

Please sign in to comment.