summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortomas <93524600+TommiRommi@users.noreply.github.com>2023-08-04 19:04:49 +0000
committerGitHub <noreply@github.com>2023-08-04 13:04:49 -0600
commit9d716d921ab6e48e09813636be8acbe77fb26669 (patch)
tree5dab79f7a9a92d7962c478504c63cc1189582c9f /src
parent2e5b2737f3fa8bdde21f493ba3f807b4017b2394 (diff)
very cool debug display list (#348)
* added a very cool debug display list ^^ (prints variables to screen) * Decompiled various functions
Diffstat (limited to 'src')
-rw-r--r--src/actors.c540
-rw-r--r--src/actors.h11
-rw-r--r--src/actors_extended.c100
-rw-r--r--src/camera.c10
-rw-r--r--src/code_800029B0.c6
-rw-r--r--src/code_80005FD0.c50
-rw-r--r--src/code_80005FD0.h6
-rw-r--r--src/code_80027D00.c735
-rw-r--r--src/code_80057C60.c4
-rw-r--r--src/code_80057C60.h2
-rw-r--r--src/code_8006E9C0.c4
-rw-r--r--src/code_80091750.c32
-rw-r--r--src/code_800B45E0.c38
-rw-r--r--src/code_80280000.c6
-rw-r--r--src/code_80280650.c4
-rw-r--r--src/debug/all_variables.h78
-rw-r--r--src/debug/debug.c251
-rw-r--r--src/debug/debug.inc.c58
-rw-r--r--src/hud_renderer.c8
-rw-r--r--src/main.c33
-rw-r--r--src/main.h2
-rw-r--r--src/os/_Printf.c10
-rw-r--r--src/os/sprintf.c2
-rw-r--r--src/race_logic.c2
24 files changed, 1111 insertions, 881 deletions
diff --git a/src/actors.c b/src/actors.c
index 0a25b277c..93a5c8fac 100644
--- a/src/actors.c
+++ b/src/actors.c
@@ -20,7 +20,6 @@
#include "audio/external.h"
#include "common_textures.h"
-
// Appears to be textures
// or tluts
u8 *D_802BA050;
@@ -32,17 +31,21 @@ struct Actor *D_802BA05C;
s8 D_802BA060[512]; // tlut 256
u16 D_802BA260;
-void func_80296A50(struct ShellActor *shell) {
+/**
+ * Once the amount of spawned player red and green shell count has reached 21 or higher
+ * the game will cleanup any dead red or green shells by deleting their actors.
+ */
+void cleanup_red_and_green_shells(struct ShellActor *shell) {
s32 actorIndex;
struct ShellActor *compare;
for (actorIndex = gNumPermanentActors; actorIndex < ACTOR_LIST_SIZE; actorIndex++) {
compare = (struct ShellActor *)&gActorList[actorIndex];
- if ((shell != compare) && !(compare->flags & 0xF) && (compare->type == ACTOR_GREEN_SHELL)) {
- if (compare->state == 2) {
+ if ((shell != compare) && !(compare->flags & ACTOR_IS_NOT_EXPIRED) && (compare->type == ACTOR_GREEN_SHELL)) {
+ if (compare->state == MOVING_SHELL) {
func_8000EE58(actorIndex);
}
- D_8015F6FE -= 1;
+ gNumSpawnedShells -= 1;
destroy_actor((struct Actor *)compare);
return;
}
@@ -50,21 +53,21 @@ void func_80296A50(struct ShellActor *shell) {
for (actorIndex = gNumPermanentActors; actorIndex < ACTOR_LIST_SIZE; actorIndex++) {
compare = (struct ShellActor *) &gActorList[actorIndex];
- if ((shell != compare) && !(compare->flags & 0xF) && (compare->type == ACTOR_RED_SHELL)) {
+ if ((shell != compare) && !(compare->flags & ACTOR_IS_NOT_EXPIRED) && (compare->type == ACTOR_RED_SHELL)) {
switch(compare->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_8000EE58(actorIndex);
- case 7:
- D_8015F6FE -= 1;
- destroy_actor((struct Actor *)compare);
- return;
- default:
- break;
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ gNumSpawnedShells -= 1;
+ destroy_actor((struct Actor *)compare);
+ return;
+ default:
+ break;
}
}
}
@@ -73,12 +76,12 @@ void func_80296A50(struct ShellActor *shell) {
compare = (struct ShellActor *) &gActorList[actorIndex];
if ((shell != compare) && (compare->type == ACTOR_GREEN_SHELL)) {
switch(compare->state) {
- case 2:
- func_8000EE58(actorIndex);
- case 7:
- D_8015F6FE -= 1;
- destroy_actor((struct Actor *)compare);
- return;
+ case MOVING_SHELL:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ gNumSpawnedShells -= 1;
+ destroy_actor((struct Actor *)compare);
+ return;
}
}
}
@@ -87,17 +90,17 @@ void func_80296A50(struct ShellActor *shell) {
compare = (struct ShellActor *)&gActorList[actorIndex];
if ((shell != compare) && (compare->type == ACTOR_RED_SHELL)) {
switch(compare->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_8000EE58(actorIndex);
- case 7:
- D_8015F6FE -= 1;
- destroy_actor((struct Actor *)compare);
- return;
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ gNumSpawnedShells -= 1;
+ destroy_actor((struct Actor *)compare);
+ return;
}
}
}
@@ -119,7 +122,7 @@ void actor_init(struct Actor *actor, Vec3f startingPos, Vec3s startingRot, Vec3f
case ACTOR_BOX_TRUCK:
if ((s32) D_802BA260 >= 3) {
D_802BA260 = 0;
- }
+ }
actor->state = (s16) D_802BA260;
D_802BA260 += 1;
break;
@@ -150,25 +153,25 @@ void actor_init(struct Actor *actor, Vec3f startingPos, Vec3s startingRot, Vec3f
actor->boundingBoxSize = 2.0f;
break;
case ACTOR_GREEN_SHELL:
- D_8015F6FE += 1;
+ gNumSpawnedShells += 1;
actor->unk_04 = 0;
actor->boundingBoxSize = 4.0f;
actor->flags = actor->flags | 0x4000 | 0x2000 | 0x1000;
- if ((s32) D_8015F6FE >= 0x15) {
- func_80296A50((struct ShellActor *) actor);
+ if ((s32) gNumSpawnedShells >= 0x15) {
+ cleanup_red_and_green_shells((struct ShellActor *) actor);
}
break;
case ACTOR_RED_SHELL:
- D_8015F6FE += 1;
+ gNumSpawnedShells += 1;
actor->unk_04 = 0;
actor->boundingBoxSize = 4.0f;
actor->flags = actor->flags | 0x4000 | 0x2000 | 0x1000;
- if ((s32) D_8015F6FE >= 0x15) {
- func_80296A50((struct ShellActor *) actor);
+ if ((s32) gNumSpawnedShells >= 0x15) {
+ cleanup_red_and_green_shells((struct ShellActor *) actor);
}
break;
case 2:
- D_8015F6FE += 1;
+ gNumSpawnedShells += 1;
actor->flags |= 0x4000;
actor->state = 0x0043;
actor->boundingBoxSize = 3.0f;
@@ -286,7 +289,7 @@ void func_80297230(Camera *arg0, struct Actor *arg1) {
}
void func_802972B8(Camera *arg0, struct Actor *arg1) {
- switch(arg0 - camera1) {
+ switch(arg0 - camera1) {
case 0:
arg1->flags |= 1;
break;
@@ -881,7 +884,7 @@ void func_80298D7C(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) {
continue;
}
- if ((test & 0x0400) && ((D_800DC5FC == 0) || (camera == camera1))) {
+ if ((test & 0x0400) && ((gIsGamePaused == 0) || (camera == camera1))) {
var_s1->pos[1] += 0xA;
if (var_s1->pos[1] >= 0x321) {
var_s1->someId |= 0x0800;
@@ -1222,6 +1225,7 @@ void func_8029A3AC(Camera *camera, Mat4 matrix, struct ShellActor *shell) {
func_80297230(camera, (struct Actor *)shell);
return;
}
+
func_802972B8(camera, (struct Actor *) shell);
if (temp_f0 < 40000.0f) {
func_802979F8((struct Actor *) shell, 3.4f);
@@ -1297,6 +1301,7 @@ void func_8029A8F4(Camera *camera, UNUSED Mat4 arg1, struct BananaActor *banana)
func_80297230(camera, (struct Actor *) banana);
return;
}
+
func_802972B8(camera, (struct Actor *) banana);
if (banana->state == 5) {
@@ -2520,56 +2525,56 @@ s16 func_8029E890(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType) {
for (actorIndex = gNumPermanentActors; actorIndex < ACTOR_LIST_SIZE; actorIndex++) {
compare = (struct ShellActor *) &gActorList[actorIndex];
- if (!(compare->flags & 0xF)) {
+ if (!(compare->flags & ACTOR_IS_NOT_EXPIRED)) {
switch(compare->type) {
- case ACTOR_RED_SHELL:
- switch(compare->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_8000EE58(actorIndex);
- case 7:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- default:
- break;
- }
- break;
- case ACTOR_GREEN_SHELL:
- switch(compare->state) {
- case 2:
- func_8000EE58(actorIndex);
- case 7:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- case ACTOR_BANANA:
- switch(compare->state) {
- case 1:
- case 4:
- case 5:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- case ACTOR_FAKE_ITEM_BOX:
- switch(compare->state) {
- case 1:
- case 2:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- default:
- break;
+ case ACTOR_RED_SHELL:
+ switch(compare->state) {
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ default:
+ break;
+ }
+ break;
+ case ACTOR_GREEN_SHELL:
+ switch(compare->state) {
+ case MOVING_SHELL:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ case ACTOR_BANANA:
+ switch(compare->state) {
+ case DROPPED_BANANA:
+ case BANANA_ON_GROUND:
+ case DESTROYED_BANANA:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ case ACTOR_FAKE_ITEM_BOX:
+ switch(compare->state) {
+ case FAKE_ITEM_BOX_ON_GROUND:
+ case DESTROYED_FAKE_ITEM_BOX:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ default:
+ break;
}
}
}
@@ -2577,54 +2582,54 @@ s16 func_8029E890(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType) {
for (actorIndex = gNumPermanentActors; actorIndex < ACTOR_LIST_SIZE; actorIndex++) {
compare = (struct ShellActor *) &gActorList[actorIndex];
switch(compare->type) {
- case ACTOR_RED_SHELL:
- switch(compare->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_8000EE58(actorIndex);
- case 7:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- default:
- break;
- }
- break;
- case ACTOR_GREEN_SHELL:
- switch(compare->state) {
- case 2:
- func_8000EE58(actorIndex);
- case 7:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- case ACTOR_BANANA:
- switch(compare->state) {
- case 1:
- case 4:
- case 5:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- case ACTOR_FAKE_ITEM_BOX:
- switch(compare->state) {
- case 1:
- case 2:
- func_8029E7DC((struct Actor *) compare);
- actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
- return actorIndex;
- }
- break;
- default:
- break;
+ case ACTOR_RED_SHELL:
+ switch(compare->state) {
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ default:
+ break;
+ }
+ break;
+ case ACTOR_GREEN_SHELL:
+ switch(compare->state) {
+ case MOVING_SHELL:
+ func_8000EE58(actorIndex);
+ case DESTROYED_SHELL:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ case ACTOR_BANANA:
+ switch(compare->state) {
+ case DROPPED_BANANA:
+ case BANANA_ON_GROUND:
+ case DESTROYED_BANANA:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ case ACTOR_FAKE_ITEM_BOX:
+ switch(compare->state) {
+ case FAKE_ITEM_BOX_ON_GROUND:
+ case DESTROYED_FAKE_ITEM_BOX:
+ func_8029E7DC((struct Actor *) compare);
+ actor_init((struct Actor *) compare, pos, rot, velocity, actorType);
+ return actorIndex;
+ }
+ break;
+ default:
+ break;
}
}
@@ -3028,144 +3033,144 @@ void func_8029FDC8(struct Actor *actor) {
Player *player;
switch (actor->type) {
- case ACTOR_BANANA:
- banana = (struct BananaActor *)actor;
- switch (banana->state) {
- case 2:
- case 3:
- func_802B0570(banana);
- break;
- case 0:
- player = &gPlayers[banana->playerId];
- player->statusEffects &= ~0x00040000;
- /* fallthrough */
- case 4:
- banana->flags = -0x8000;
- banana->unk_04 = 0x003C;
- banana->state = 5;
- banana->velocity[1] = 3.0f;
- break;
- case 1:
- case 5:
- default:
- break;
- }
- break;
- case ACTOR_GREEN_SHELL:
- shell = (struct ShellActor *)actor;
- if (shell->state != 5) {
- switch (shell->state) {
- case 2:
- func_8000EE58(actor - gActorList);
- /* fallthrough */
- case 0:
- case 1:
- shell->flags = -0x8000;
- shell->rotAngle = 0;
- shell->someTimer = 0x003C;
- shell->state = 5;
- shell->velocity[1] = 3.0f;
- break;
- case 4:
- func_802B02B4(shell, ACTOR_GREEN_SHELL);
- break;
- default:
- break;
- }
- }
- break;
- case ACTOR_BLUE_SPINY_SHELL:
- shell = (struct ShellActor *)actor;
- if (shell->state != 7) {
- switch (shell->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_800C9EF4(shell->pos, 0x51018008);
- func_8000EE58(actor - gActorList);
- /* fallthrough */
- case 0:
- case 1:
- shell->flags = -0x8000;
- shell->rotAngle = 0;
- shell->someTimer = 0x003C;
- shell->state = 7;
- shell->velocity[1] = 3.0f;
- break;
- default:
- break;
- }
- }
- break;
- case ACTOR_RED_SHELL:
- shell = (struct ShellActor *)actor;
- if (shell->state != 7) {
- switch (shell->state) {
- case 2:
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- func_8000EE58(actor - gActorList);
- /* fallthrough */
- case 0:
- case 1:
- shell->flags = -0x8000;
- shell->rotAngle = 0;
- shell->someTimer = 0x003C;
- shell->state = 7;
- shell->velocity[1] = 3.0f;
- break;
- case 6:
- func_802B02B4(shell, ACTOR_RED_SHELL);
- break;
- default:
- break;
- }
- }
- break;
- case ACTOR_FAKE_ITEM_BOX:
- fakeItemBox = (struct FakeItemBox *)actor;
- player = &gPlayers[(s16)fakeItemBox->playerId];
- if (fakeItemBox->state == 0) {
- player->statusEffects &= ~0x00040000;
- }
- fakeItemBox->state = 2;
- fakeItemBox->flags = -0x8000;
- fakeItemBox->someTimer = 0;
- break;
+ case ACTOR_BANANA:
+ banana = (struct BananaActor *)actor;
+ switch (banana->state) {
+ case FIRST_BANANA_BUNCH_BANANA:
+ case BANANA_BUNCH_BANANA:
+ func_802B0570(banana);
+ break;
+ case HELD_BANANA:
+ player = &gPlayers[banana->playerId];
+ player->statusEffects &= ~0x00040000;
+ /* fallthrough */
+ case BANANA_ON_GROUND:
+ banana->flags = -0x8000;
+ banana->unk_04 = 0x003C;
+ banana->state = 5;
+ banana->velocity[1] = 3.0f;
+ break;
+ case DROPPED_BANANA:
+ case DESTROYED_BANANA:
+ default:
+ break;
+ }
+ break;
+ case ACTOR_GREEN_SHELL:
+ shell = (struct ShellActor *)actor;
+ if (shell->state != GREEN_SHELL_HIT_A_RACER) {
+ switch (shell->state) {
+ case MOVING_SHELL:
+ func_8000EE58(actor - gActorList);
+ /* fallthrough */
+ case HELD_SHELL:
+ case RELEASED_SHELL:
+ shell->flags = -0x8000;
+ shell->rotAngle = 0;
+ shell->someTimer = 0x003C;
+ shell->state = GREEN_SHELL_HIT_A_RACER;
+ shell->velocity[1] = 3.0f;
+ break;
+ case TRIPLE_GREEN_SHELL:
+ func_802B02B4(shell, ACTOR_GREEN_SHELL);
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case ACTOR_BLUE_SPINY_SHELL:
+ shell = (struct ShellActor *)actor;
+ if (shell->state != DESTROYED_SHELL) {
+ switch (shell->state) {
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_800C9EF4(shell->pos, 0x51018008);
+ func_8000EE58(actor - gActorList);
+ /* fallthrough */
+ case HELD_SHELL:
+ case RELEASED_SHELL:
+ shell->flags = -0x8000;
+ shell->rotAngle = 0;
+ shell->someTimer = 0x003C;
+ shell->state = DESTROYED_SHELL;
+ shell->velocity[1] = 3.0f;
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case ACTOR_RED_SHELL:
+ shell = (struct ShellActor *)actor;
+ if (shell->state != DESTROYED_SHELL) {
+ switch (shell->state) {
+ case MOVING_SHELL:
+ case RED_SHELL_LOCK_ON:
+ case TRIPLE_GREEN_SHELL:
+ case GREEN_SHELL_HIT_A_RACER:
+ case BLUE_SHELL_LOCK_ON:
+ case BLUE_SHELL_TARGET_ELIMINATED:
+ func_8000EE58(actor - gActorList);
+ /* fallthrough */
+ case HELD_SHELL:
+ case RELEASED_SHELL:
+ shell->flags = -0x8000;
+ shell->rotAngle = 0;
+ shell->someTimer = 0x003C;
+ shell->state = DESTROYED_SHELL;
+ shell->velocity[1] = 3.0f;
+ break;
+ case TRIPLE_RED_SHELL:
+ func_802B02B4(shell, ACTOR_RED_SHELL);
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case ACTOR_FAKE_ITEM_BOX:
+ fakeItemBox = (struct FakeItemBox *)actor;
+ player = &gPlayers[(s16)fakeItemBox->playerId];
+ if (fakeItemBox->state == HELD_FAKE_ITEM_BOX) {
+ player->statusEffects &= ~0x00040000;
+ }
+ fakeItemBox->state = DESTROYED_FAKE_ITEM_BOX;
+ fakeItemBox->flags = -0x8000;
+ fakeItemBox->someTimer = 0;
+ break;
}
}
void func_802A00E8(struct Actor *arg0, struct Actor *arg1) {
switch(arg0->type) {
case ACTOR_GREEN_SHELL:
- if ((arg0->state == 0) || (arg0->state == 4)) {
+ if ((arg0->state == HELD_SHELL) || (arg0->state == TRIPLE_GREEN_SHELL)) {
arg0->flags |= 0x200;
func_800C98B8(arg0->pos, arg0->velocity, 0x19019053);
return;
}
break;
case ACTOR_RED_SHELL:
- if ((arg0->state == 0) || (arg0->state == 6)) {
+ if ((arg0->state == HELD_SHELL) || (arg0->state == TRIPLE_RED_SHELL)) {
arg0->flags |= 0x200;
func_800C98B8(arg0->pos, arg0->velocity, 0x19019053);
- return;
+ return;
}
break;
case ACTOR_BLUE_SPINY_SHELL:
- if (arg0->state == 0) {
+ if (arg0->state == HELD_SHELL) {
arg0->flags |= 0x200;
func_800C98B8(arg0->pos, arg0->velocity, 0x19019053);
return;
}
break;
case ACTOR_FAKE_ITEM_BOX:
- if (arg0->state == 0) {
+ if (arg0->state == HELD_FAKE_ITEM_BOX) {
arg0->flags |= 0x200;
func_800C98B8(arg0->pos, arg0->velocity, 0x19019053);
return;
@@ -3175,28 +3180,28 @@ void func_802A00E8(struct Actor *arg0, struct Actor *arg1) {
switch(arg1->type) {
case ACTOR_GREEN_SHELL:
- if ((arg1->state == 0) || (arg1->state == 4)) {
- arg1->flags |= 0x200;
- func_800C98B8(arg1->pos, arg1->velocity, 0x19019053);
- return;
+ if ((arg1->state == HELD_SHELL) || (arg1->state == TRIPLE_GREEN_SHELL)) {
+ arg1->flags |= 0x200;
+ func_800C98B8(arg1->pos, arg1->velocity, 0x19019053);
+ return;
}
break;
case ACTOR_RED_SHELL:
- if ((arg1->state == 0) || (arg1->state == 6)) {
+ if ((arg1->state == HELD_SHELL) || (arg1->state == TRIPLE_RED_SHELL)) {
arg1->flags |= 0x200;
func_800C98B8(arg1->pos, arg1->velocity, 0x19019053);
return;
}
break;
case ACTOR_BLUE_SPINY_SHELL:
- if (arg1->state == 0) {
+ if (arg1->state == HELD_SHELL) {
arg1->flags |= 0x200;
func_800C98B8(arg1->pos, arg1->velocity, 0x19019053);
return;
}
break;
case ACTOR_FAKE_ITEM_BOX:
- if (arg1->state == 0) {
+ if (arg1->state == HELD_FAKE_ITEM_BOX) {
arg1->flags |= 0x200;
func_800C98B8(arg1->pos, arg1->velocity, 0x19019053);
return;
@@ -3218,14 +3223,14 @@ void func_802A0350(struct Actor *arg0, struct Actor *arg1) {
return;
}
if (arg0->type == ACTOR_BLUE_SPINY_SHELL) {
- if (arg0->state == 0) {
+ if (arg0->state == HELD_SHELL) {
func_8029FDC8(arg0);
}
} else {
func_8029FDC8(arg0);
}
if (arg1->type == ACTOR_BLUE_SPINY_SHELL) {
- if (arg1->state == 0) {
+ if (arg1->state == HELD_SHELL) {
func_8029FDC8(arg1);
}
} else {
@@ -3692,6 +3697,7 @@ void func_802A171C(Camera *camera, struct FakeItemBox *fakeItemBox) {
func_80297230(camera, (struct Actor *) fakeItemBox);
return;
}
+
func_802972B8(camera, (struct Actor *) fakeItemBox);
someRot[0] = 0;
someRot[1] = fakeItemBox->rot[1];
diff --git a/src/actors.h b/src/actors.h
index b40924865..7cb7ee21b 100644
--- a/src/actors.h
+++ b/src/actors.h
@@ -5,7 +5,7 @@
#include "actor_types.h"
void func_8029E158(void);
-void func_80296A50(struct ShellActor*);
+void cleanup_red_and_green_shells(struct ShellActor*);
void actor_init(struct Actor*, f32*, s16*, f32*, s16);
void func_80297230(Camera*, struct Actor*);
void func_802972B8(Camera*, struct Actor*);
@@ -129,7 +129,12 @@ extern struct Actor gActorList[];
extern Player gPlayers[];
extern u16 gNumActors;
extern u16 gNumPermanentActors;
-extern u16 D_8015F6FE; // Shell count? But why does actor type 2 (some kind of shrub?) increase it and not blue shells?
+
+/**
+ * Incremented by one every time the player spawns a new shell actor.
+ * A cleaning routine runs once twenty-one shells have spawned.
+ */
+extern u16 gNumSpawnedShells;
extern u16 D_802BA260; // Box Truck sub-type?
extern Player *gPlayerOne;
@@ -388,7 +393,7 @@ extern u8 gTextureShrub[];
extern s8 D_800DC628[];
extern s8 D_800DC630[];
-extern u16 D_800DC5FC;
+extern u16 gIsGamePaused;
extern s8 D_802B8864[];
extern u16 D_800DC5BC;
diff --git a/src/actors_extended.c b/src/actors_extended.c
index a52692893..2e022945d 100644
--- a/src/actors_extended.c
+++ b/src/actors_extended.c
@@ -54,10 +54,10 @@ void func_802B02B4(struct ShellActor *shell, s32 shellType) {
switch(shellType) {
case ACTOR_GREEN_SHELL:
- shell->state = 5;
+ shell->state = GREEN_SHELL_HIT_A_RACER;
break;
case ACTOR_RED_SHELL:
- shell->state = 7;
+ shell->state = DESTROYED_SHELL;
break;
}
}
@@ -65,7 +65,7 @@ void func_802B02B4(struct ShellActor *shell, s32 shellType) {
// Sets velocities for a banana, used when a racer runs into
// a banana bunch.
void func_802B039C(struct BananaActor *banana) {
- banana->state = 1;
+ banana->state = DROPPED_BANANA;
banana->unk_04 = 0x00B4;
banana->velocity[0] = ((f32) (random_int(0x00C8) - 0x64) * 0.015);
banana->velocity[1] = ((f32) random_int(0x00C8)) * 0.015;
@@ -103,7 +103,7 @@ void func_802B0570(struct BananaActor *banana) {
}
banana->flags = -0x8000;
banana->unk_04 = 0x003C;
- banana->state = 5;
+ banana->state = DESTROYED_BANANA;
banana->velocity[1] = 3.0f;
temp_v0_2 = (struct BananaBunchParent *) &gActorList[banana->parentIndex];
temp_v0_2->bananaIndices[0] = -1;
@@ -138,7 +138,7 @@ void func_802B0648(struct BananaBunchParent *banana_bunch) {
return;
}
- banana->state = 1;
+ banana->state = DROPPED_BANANA;
banana->unk_04 = 0x00B4;
banana->velocity[0] = 0.0f;
banana->velocity[1] = 1.5f;
@@ -177,7 +177,7 @@ void func_802B0788(s16 rawStickY, struct BananaBunchParent *banana_bunch, Player
return;
}
- banana->state = 1;
+ banana->state = DROPPED_BANANA;
banana->unk_04 = 0x001E;
if (banana->elderIndex != -1) {
elderBanana = (struct BananaActor*)&gActorList[banana->elderIndex];
@@ -203,10 +203,10 @@ s32 func_802B09C0(s16 bananaId) {
return 0;
}
banana = (struct BananaActor*) &gActorList[bananaId];
- if (banana->state == 2) {
+ if (banana->state == FIRST_BANANA_BUNCH_BANANA) {
return 1;
}
- if (banana->state == 3) {
+ if (banana->state == BANANA_BUNCH_BANANA) {
return 1;
}
return 0;
@@ -317,12 +317,12 @@ s32 func_802B0E14(s16 arg0) {
}
temp = (struct ShellActor*) &gActorList[arg0];
if (temp->type == ACTOR_GREEN_SHELL) {
- if (temp->state == 4) {
+ if (temp->state == TRIPLE_GREEN_SHELL) {
return 1;
}
return 0;
}
- if (temp->state == 6) {
+ if (temp->state == TRIPLE_RED_SHELL) {
return 1;
}
return 0;
@@ -432,7 +432,7 @@ void update_obj_triple_shell(TripleShellParent *parent, s16 shellType) {
shell->velocity[0] = someVelocity[0];
shell->velocity[1] = someVelocity[1];
shell->velocity[2] = someVelocity[2];
- shell->state = 2;
+ shell->state = MOVING_SHELL;
shell->someTimer = 0x001E;
func_800C9060(parent->playerId, 0x19008004);
func_800C90F4(parent->playerId, (player->characterId * 0x10) + 0x29008000);
@@ -457,7 +457,7 @@ void update_obj_triple_shell(TripleShellParent *parent, s16 shellType) {
shell->velocity[0] = someVelocity[0];
shell->velocity[1] = someVelocity[1];
shell->velocity[2] = someVelocity[2];
- shell->state = 2;
+ shell->state = MOVING_SHELL;
shell->someTimer = 0x001E;
func_800C90F4(parent->playerId, (player->characterId * 0x10) + 0x29008000);
func_800C9060(parent->playerId, 0x19008004);
@@ -482,7 +482,7 @@ void update_obj_triple_shell(TripleShellParent *parent, s16 shellType) {
shell->velocity[0] = someVelocity[0];
shell->velocity[1] = someVelocity[1];
shell->velocity[2] = someVelocity[2];
- shell->state = 2;
+ shell->state = MOVING_SHELL;
shell->someTimer = 0x001E;
func_800C9060(parent->playerId, 0x19008004);
func_800C90F4(parent->playerId, (player->characterId * 0x10) + 0x29008000);
@@ -576,10 +576,10 @@ s32 func_802B19EC(TripleShellParent *parent, Player *player, s16 shellType, u16
shell->flags = 0x9000;
switch (shellType) {
case ACTOR_GREEN_SHELL:
- shell->state = 4;
+ shell->state = TRIPLE_GREEN_SHELL;
break;
case ACTOR_RED_SHELL:
- shell->state = 6;
+ shell->state = TRIPLE_RED_SHELL;
break;
}
shell->rotVelocity = 0;
@@ -617,7 +617,7 @@ s32 func_802B1C9C(Player *player) {
startingPos[2] = player->pos[2];
func_802AD950(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]);
func_802B4E30((struct Actor *)shell);
- shell->state = 0;
+ shell->state = HELD_SHELL;
shell->rotVelocity = 0;
shell->rotAngle = -0x8000;
shell->playerId = player - gPlayerOne;
@@ -650,7 +650,7 @@ s32 func_802B1E48(Player *player) {
startingPos[2] = player->pos[2];
func_802AD950(&shell->unk30, shell->boundingBoxSize + 1.0f, shell->pos[0], shell->pos[1], shell->pos[2], startingPos[0], startingPos[1], startingPos[2]);
func_802B4E30((struct Actor *)shell);
- shell->state = 0;
+ shell->state = HELD_SHELL;
shell->rotVelocity = 0;
shell->rotAngle = player->unk_02C[1] - 0x8000;
shell->playerId = player - gPlayerOne;
@@ -686,7 +686,7 @@ void update_obj_banana(struct BananaActor *banana) {
player = &gPlayers[banana->rot[0]];
switch (banana->state) {
- case 0:
+ case HELD_BANANA:
temp_f2 = player->pos[0] - banana->pos[0];
temp_f14 = player->pos[1] - banana->pos[1];
temp_f16 = player->pos[2] - banana->pos[2];
@@ -739,7 +739,7 @@ void update_obj_banana(struct BananaActor *banana) {
}
}
break;
- case 1:
+ case DROPPED_BANANA:
if (banana->unk_04 != 0) {
banana->unk_04 -= 1;
if (banana->unk_04 == 0) {
@@ -769,7 +769,7 @@ void update_obj_banana(struct BananaActor *banana) {
}
}
break;
- case 2:
+ case FIRST_BANANA_BUNCH_BANANA:
someVelocity[0] = 0.0f;
someVelocity[1] = 0.0f;
someVelocity[2] = -5.0f;
@@ -796,7 +796,7 @@ void update_obj_banana(struct BananaActor *banana) {
func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
func_802B4E30((struct Actor *) banana);
break;
- case 3:
+ case BANANA_BUNCH_BANANA:
elderBanana = (struct BananaActor*)&gActorList[banana->elderIndex];
temp_f2 = elderBanana->pos[0] - banana->pos[0];
temp_f14 = elderBanana->pos[1] - banana->pos[1];
@@ -818,7 +818,7 @@ void update_obj_banana(struct BananaActor *banana) {
func_802ADDC8(&banana->unk30, banana->boundingBoxSize + 1.0f, banana->pos[0], banana->pos[1], banana->pos[2]);
func_802B4E30((struct Actor *) banana);
break;
- case 5:
+ case DESTROYED_BANANA:
banana->velocity[1] -= 0.3f;
if (banana->velocity[1] < -5.0f) {
banana->velocity[1] = -5.0f;
@@ -832,7 +832,7 @@ void update_obj_banana(struct BananaActor *banana) {
destroy_actor((struct Actor *) banana);
}
break;
- case 4:
+ case BANANA_ON_GROUND:
banana->flags |= 0xC000;
banana->flags &= ~0x1000;
break;
@@ -987,7 +987,7 @@ s32 func_802B2D70(Player *player) {
}
banana = (struct BananaActor *) &gActorList[actorIndex];
banana->playerId = playerId;
- banana->state = 0;
+ banana->state = HELD_BANANA;
banana->unk_04 = 0x0014;
player->statusEffects |= 0x40000;
return actorIndex;
@@ -1129,7 +1129,7 @@ void update_obj_green_shell(struct ShellActor *shell) {
}
shell->rotVelocity += 0x71C;
switch (shell->state) {
- case 0:
+ case HELD_SHELL:
player = &gPlayers[shell->playerId];
func_802B0210(&player->unk_110, &shell->unk30);
somePosVel[0] = 0.0f;
@@ -1178,7 +1178,7 @@ void update_obj_green_shell(struct ShellActor *shell) {
}
}
break;
- case 1:
+ case RELEASED_SHELL:
player = &gPlayers[shell->playerId];
if (shell->rotAngle > 0) {
shell->rotAngle -= 0xE38;
@@ -1221,7 +1221,7 @@ void update_obj_green_shell(struct ShellActor *shell) {
shell->pos[2] = player->pos[2] + somePosVel[2];
}
break;
- case 2:
+ case MOVING_SHELL:
if (shell->parentIndex > 0) {
shell->parentIndex -= 1;
if (shell->parentIndex == 0) {
@@ -1246,7 +1246,7 @@ void update_obj_green_shell(struct ShellActor *shell) {
shell->flags |= 0x80;
}
break;
- case 4:
+ case TRIPLE_GREEN_SHELL:
player = &gPlayers[shell->playerId];
parent = (TripleShellParent *) &gActorList[shell->parentIndex];
if (parent->type != ACTOR_TRIPLE_GREEN_SHELL) {
@@ -1267,7 +1267,7 @@ void update_obj_green_shell(struct ShellActor *shell) {
func_802B4E30((struct Actor *) shell);
}
break;
- case 5:
+ case GREEN_SHELL_HIT_A_RACER:
// Somehow, this fake match affects stack management up in case 2
shell->velocity[1] -= (0, 0.3f);
if (shell->velocity[1] < -5.0f) {
@@ -1508,7 +1508,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
shell->rotVelocity += 0x71C;
switch (shell->state) {
- case 0:
+ case HELD_SHELL:
player = &gPlayers[shell->playerId];
func_802B0210(&player->unk_110, &shell->unk30);
somePosVel[0] = 0.0f;
@@ -1539,7 +1539,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
if ((controller->buttonDepressed & 0x2000) != 0) {
controller->buttonDepressed &= ~0x2000;
- shell->state = 1;
+ shell->state = RELEASED_SHELL;
if (player->unk_0C0 > 0) {
shell->rotAngle = 0x78E3;
} else {
@@ -1547,12 +1547,12 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
}
}
break;
- case 1:
+ case RELEASED_SHELL:
player = &gPlayers[shell->playerId];
if (shell->rotAngle > 0) {
shell->rotAngle -= 0x71C;
if (shell->rotAngle < 0) {
- shell->state = 2;
+ shell->state = MOVING_SHELL;
func_800C9060(shell->playerId, 0x19008004U);
func_800C90F4(shell->playerId, (player->characterId * 0x10) + 0x29008000);
if (pad13 == ACTOR_RED_SHELL) {
@@ -1565,7 +1565,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
} else {
shell->rotAngle += 0x71C;
if (shell->rotAngle > 0) {
- shell->state = 2;
+ shell->state = MOVING_SHELL;
func_800C9060(shell->playerId, 0x19008004U);
func_800C90F4(shell->playerId, (player->characterId * 0x10) + 0x29008000);
if (pad13 == ACTOR_RED_SHELL) {
@@ -1576,7 +1576,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
}
}
}
- if (shell->state == 2) {
+ if (shell->state == MOVING_SHELL) {
shell->someTimer = 0x001E;
temp_f0 = 8.0f;
if (player->unk_094 > 8.0f) {
@@ -1599,14 +1599,14 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
shell->pos[2] = player->pos[2] + somePosVel[2];
}
break;
- case 2:
+ case MOVING_SHELL:
player = &gPlayers[shell->playerId];
shell->someTimer -= 1;
if (shell->someTimer == 0) {
shell->flags &= 0xEFFF;
if (shell->type == ACTOR_BLUE_SPINY_SHELL) {
shell->targetPlayer = gPlayerPositionLUT[0];
- shell->state = 8;
+ shell->state = BLUE_SHELL_LOCK_ON;
shell->shellId = 1000.0f;
temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8;
if ((s32) D_80164430 < temp_v0) {
@@ -1621,13 +1621,13 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
shell->velocity[1] = 3.0f;
shell->pathIndex = 0;
shell->someTimer = 0x003C;
- shell->state = 7;
+ shell->state = DESTROYED_SHELL;
} else {
- shell->state = 3;
+ shell->state = RED_SHELL_LOCK_ON;
}
} else {
if (player->currentRank == 0) {
- shell->state = 4;
+ shell->state = TRIPLE_GREEN_SHELL;
shell->someTimer = 0x0258;
temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8;
if ((s32) D_80164430 < temp_v0) {
@@ -1635,7 +1635,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
}
shell->pathIndex = temp_v0;
} else if (player->currentRank >= 5) {
- shell->state = 5;
+ shell->state = GREEN_SHELL_HIT_A_RACER;
shell->shellId = 1000.0f;
temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8;
if ((s32) D_80164430 < temp_v0) {
@@ -1644,7 +1644,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
shell->pathIndex = temp_v0;
shell->targetPlayer = gPlayerPositionLUT[player->currentRank - 1];
} else {
- shell->state = 3;
+ shell->state = RED_SHELL_LOCK_ON;
shell->shellId = 1000.0f;
shell->targetPlayer = gPlayerPositionLUT[player->currentRank - 1];
}
@@ -1664,10 +1664,10 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
func_802B4E30((struct Actor *) shell);
func_802B4104(shell);
break;
- case 3:
+ case RED_SHELL_LOCK_ON:
func_802B3E7C(shell, &gPlayers[shell->targetPlayer]);
break;
- case 4:
+ case TRIPLE_GREEN_SHELL:
func_802B3B44(shell);
if (shell->someTimer == 0) {
if ((shell->flags & 0xF) == 0) {
@@ -1677,7 +1677,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
}
}
break;
- case 5:
+ case GREEN_SHELL_HIT_A_RACER:
func_802B3B44(shell);
player = &gPlayers[shell->targetPlayer];
temp_f0 = player->pos[0];
@@ -1685,10 +1685,10 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
temp_f2 = player->pos[2];
temp_f2 -= shell->pos[2];
if (((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 40000.0f) {
- shell->state = 3;
+ shell->state = RED_SHELL_LOCK_ON;
}
break;
- case 6:
+ case TRIPLE_RED_SHELL:
player = &gPlayers[shell->playerId];
parent = (TripleShellParent *) &gActorList[shell->parentIndex];
if (parent->type != ACTOR_TRIPLE_RED_SHELL) {
@@ -1709,7 +1709,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
func_802B4E30((struct Actor *) shell);
}
break;
- case 7:
+ case DESTROYED_SHELL:
shell->velocity[1] -= 0.3f;
if (shell->velocity[1] < -5.0f) {
shell->velocity[1] = -5.0f;
@@ -1721,7 +1721,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
destroy_actor((struct Actor *) shell);
}
break;
- case 8:
+ case BLUE_SHELL_LOCK_ON:
func_802B3B44(shell);
shell->targetPlayer = gPlayerPositionLUT[0];
player = &gPlayers[gPlayerPositionLUT[0]];
@@ -1730,7 +1730,7 @@ void update_obj_red_blue_shell(struct ShellActor *shell) {
temp_f2 = player->pos[2];
temp_f2 -= shell->pos[2];
if (((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 40000.0f) {
- shell->state = 9;
+ shell->state = BLUE_SHELL_TARGET_ELIMINATED;
}
break;
case 9:
diff --git a/src/camera.c b/src/camera.c
index 56e713c74..6e405c97a 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -1099,7 +1099,7 @@ void func_8001EE98(Player *player, Camera *camera, s8 arg2) {
case 0:
if (((player->unk_000 & 0x800) == 0x800) || (D_800DC51C == 1)) {
D_80152300[var_s0] = 3;
- } else if (D_800DC5FC == 1) {
+ } else if (gIsGamePaused == 1) {
func_8001A0A4((s32) &D_80152300[var_s0], (s32) camera, (s32) player, (s32) arg2, var_s0);
} else {
func_8001A0DC((s16 *) &D_80152300[var_s0], camera, player, arg2, var_s0);
@@ -1117,7 +1117,7 @@ void func_8001EE98(Player *player, Camera *camera, s8 arg2) {
D_80152300->unk6 = 3U;
} else {
D_80164A88 = 0;
- if (D_800DC5FC == (u16) 1) {
+ if (gIsGamePaused == (u16) 1) {
temp_a0 = &D_80152300[var_s0];
sp2C = temp_a0;
func_8001A0A4((s32) temp_a0, (s32) camera, (s32) player, (s32) arg2, var_s0);
@@ -1136,7 +1136,7 @@ void func_8001EE98(Player *player, Camera *camera, s8 arg2) {
*(D_80152300 + 4) = 3;
*(D_80152300 + 6) = 3;
} else {
- if (D_800DC5FC == (u16) 1) {
+ if (gIsGamePaused == (u16) 1) {
temp_a0_3 = &D_80152300[var_s0];
sp2C = temp_a0_3;
func_8001A0A4((s32) temp_a0_3, (s32) camera, (s32) player, (s32) arg2, var_s0);
@@ -1152,7 +1152,7 @@ void func_8001EE98(Player *player, Camera *camera, s8 arg2) {
if (((player->unk_000 & 0x800) == 0x800) || (D_800DC51C == (u16) 1) || (D_8015F894 == 2)) {
D_80152300[var_s0] = 3;
} else {
- if (D_800DC5FC == (u16) 1) {
+ if (gIsGamePaused == (u16) 1) {
temp_a0_5 = &D_80152300[var_s0];
sp2C = temp_a0_5;
func_8001A0A4((s32) temp_a0_5, (s32) camera, (s32) player, (s32) arg2, var_s0);
@@ -1165,7 +1165,7 @@ void func_8001EE98(Player *player, Camera *camera, s8 arg2) {
}
break;
}
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
temp_a0_7 = &D_80152300[var_s0];
temp_v0 = *temp_a0_7;
switch (temp_v0) { /* switch 1; irregular */
diff --git a/src/code_800029B0.c b/src/code_800029B0.c
index f6337ac7a..b6e52112a 100644
--- a/src/code_800029B0.c
+++ b/src/code_800029B0.c
@@ -22,7 +22,7 @@
extern u16 D_800DC5A8;
extern s32 D_800DC510;
-extern u16 D_8015F6FE;
+extern u16 gNumSpawnedShells;
extern u16 D_80152308;
extern s32 D_802BA038;
extern s16 D_802BA048;
@@ -64,7 +64,7 @@ struct UnkStruct_800DC5EC *D_800DC5EC = &D_8015F480[0];
struct UnkStruct_800DC5EC *D_800DC5F0 = &D_8015F480[1];
struct UnkStruct_800DC5EC *D_800DC5F4 = &D_8015F480[2];
struct UnkStruct_800DC5EC *D_800DC5F8 = &D_8015F480[3];
-u16 D_800DC5FC = 0;
+u16 gIsGamePaused = 0;
u8 *pAppNmiBuffer = (u8 *) &osAppNmiBuffer;
s32 gIsMirrorMode = 0;
f32 vtxStretchY = 1.0f;
@@ -122,7 +122,7 @@ void setup_race(void) {
func_8003D080();
func_8006E9C0();
D_800DC510 = 0;
- D_8015F6FE = 0;
+ gNumSpawnedShells = 0;
D_800DC5B8 = 0;
D_80152308 = 0;
D_802BA038 = -1;
diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c
index 9a0cccb60..8ea69795d 100644
--- a/src/code_80005FD0.c
+++ b/src/code_80005FD0.c
@@ -4314,7 +4314,7 @@ GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000DBAC.s")
//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de
extern ? D_80163DE8;
extern UnkActorInner D_80164038;
-extern ? D_801641F8;
+extern ? gUnexpiredActorsList;
static struct _struct_D_800DCC08_0xA8 D_800DCC08[0]; /* unable to generate initializer */
s16 gCurrentCourseId; /* unable to generate initializer */
@@ -4380,7 +4380,7 @@ void func_8000DD78(void) {
var_s2 += 0x40;
var_s3 += 0x18;
var_s0 += 0x54;
- } while (var_s2 != &D_801641F8);
+ } while (var_s2 != &gUnexpiredActorsList);
}
#else
GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000DD78.s")
@@ -4736,17 +4736,17 @@ void func_8000DF8C(s32 arg0) {
GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000DF8C.s")
#endif
-s32 func_8000ED14(s32 arg0, s16 arg1) {
+s32 func_8000ED14(s32 actorIndex, s16 arg1) {
s32 i;
s32 a2 = 0;
for (i = 0; i < 8; i++) {
- if (D_801641F8[i].unkC == 0) {
- D_801641F8[i].unkC = 1;
- D_801641F8[i].unkE = arg0;
- D_801641F8[i].unk10 = arg1;
- D_801641F8[i].unk14 = 0;
+ if (gUnexpiredActorsList[i].unkC == 0) {
+ gUnexpiredActorsList[i].unkC = 1;
+ gUnexpiredActorsList[i].actorIndex = actorIndex;
+ gUnexpiredActorsList[i].unk10 = arg1;
+ gUnexpiredActorsList[i].unk14 = 0;
a2 = 1;
break;
}
@@ -4757,20 +4757,20 @@ s32 func_8000ED14(s32 arg0, s16 arg1) {
return 0;
}
-s32 func_8000ED80(s32 arg0) {
- struct Actor *actor = &gActorList[arg0];
+s32 func_8000ED80(s32 actorIndex) {
+ struct Actor *actor = &gActorList[actorIndex];
if (actor->type != 8) {
return -1;
}
- return func_8000ED14(arg0, 0);
+ return func_8000ED14(actorIndex, 0);
}
-s32 func_8000EDC8(s32 arg0) {
- struct Actor *actor = &gActorList[arg0];
+s32 func_8000EDC8(s32 actorIndex) {
+ struct Actor *actor = &gActorList[actorIndex];
if (actor->type != 7) {
return -1;
}
- return func_8000ED14(arg0, 1);
+ return func_8000ED14(actorIndex, 1);
}
s32 func_8000EE10(s32 arg0) {
@@ -4781,27 +4781,27 @@ s32 func_8000EE10(s32 arg0) {
return func_8000ED14(arg0, 2);
}
-void func_8000EE58(s32 arg0) {
- struct unk_41F8 *phi;
+void func_8000EE58(s32 actorIndex) {
+ struct unexpiredActors *phi;
s32 i;
for (i = 0; i < 8; i++) {
- phi = &D_801641F8[i];
- if (arg0 == phi->unkE) {
+ phi = &gUnexpiredActorsList[i];
+ if (actorIndex == phi->actorIndex) {
phi->unkC = 0;
- phi->unkE = 1000;
+ phi->actorIndex = 1000; // out of bounds
}
}
}
void func_8000EEDC(void) {
- struct unk_41F8 *phi;
+ struct unexpiredActors *phi;
s32 i;
for (i = 0; i < 8; i++) {
- phi = &D_801641F8[i];
+ phi = &gUnexpiredActorsList[i];
phi->unkC = 0;
- phi->unkE = 1000;
+ phi->actorIndex = 1000; // out of bounds
}
}
@@ -4809,12 +4809,12 @@ void func_8000EF20(void) {
s32 someIndex;
f32 var_f20;
struct Actor *temp_s1;
- struct unk_41F8 *var_s0;
+ struct unexpiredActors *var_s0;
for (someIndex = 0; someIndex < 8; someIndex++) {
- var_s0 = &D_801641F8[someIndex];
+ var_s0 = &gUnexpiredActorsList[someIndex];
if (var_s0->unkC == 1) {
- temp_s1 = &gActorList[var_s0->unkE];
+ temp_s1 = &gActorList[var_s0->actorIndex];
var_s0->unk14++;
switch (var_s0->unk10) {
case 0:
diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h
index ed2cca429..a57fe9ba4 100644
--- a/src/code_80005FD0.h
+++ b/src/code_80005FD0.h
@@ -14,12 +14,12 @@ struct struct_801642D8 {
/* 0xC */ s32 unkC;
};
-struct unk_41F8 {
+struct unexpiredActors {
s32 unk0;
s32 unk4;
s32 unk8;
u16 unkC;
- u16 unkE;
+ u16 actorIndex;
s16 unk10;
// s16 compilerPadding;
u32 unk14;
@@ -144,7 +144,7 @@ extern s32 D_80163488;
extern s32 D_8016337C;
extern s32 gModeSelection;
-extern struct unk_41F8 D_801641F8[];
+extern struct unexpiredActors gUnexpiredActorsList[];
extern s16 D_80164670;
extern s16 D_80164672;
extern s16 D_80164674;
diff --git a/src/code_80027D00.c b/src/code_80027D00.c
index 8fd72470a..044563507 100644
--- a/src/code_80027D00.c
+++ b/src/code_80027D00.c
@@ -12,8 +12,12 @@
#include "waypoints.h"
#include "audio/external.h"
+extern s8 D_80164A89;
+extern s16 D_801633F8;
+extern s32 D_8018D168;
+extern s32 D_800DC510;
+
void func_80028E70(Player*, Camera*, s8, s8);
-void func_800381AC(Player *, struct Controller*, u8);
s16 D_800E3810[] = {
1, 2, 3, 4, 5, 6, 7, 0
@@ -352,64 +356,33 @@ s32 get_player_index_for_player(Player *player) {
return index;
}
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-void func_800C94A4(s32, s8, u16 *); // extern
-void func_800C9A88(s32, s8, u16 *); // extern
-extern s32 D_8018D168;
-
-void func_80027DA8(u16 *arg0, s8 arg1) {
- u16 *temp_a2;
- u16 temp_v0;
- u16 temp_v0_2;
-
- temp_a2 = arg0;
+void func_80027DA8(Player *arg0, s8 arg1) {
if (D_8015F890 != 1) {
- temp_v0 = *arg0;
- if ((temp_v0 & 0x10) != 0x10) {
- if ((D_8018D168 == 1) && ((temp_v0 & 0x4000) == 0x4000) && ((temp_v0 & 0x100) != 0x100)) {
- arg0 = temp_a2;
- func_800C94A4(arg1 & 0xFF, arg1, temp_a2);
- *arg0 = *arg0 | 0x10;
- return;
+ if ((arg0->unk_000 & 0x10) != 0x10) {
+ if (((D_8018D168 == 1) && ((arg0->unk_000 & 0x4000) == 0x4000)) && ((arg0->unk_000 & 0x100) != 0x100)) {
+ func_800C94A4(arg1 & 0xFF);
+ arg0->unk_000 |= 0x10;
+ } else if ((arg0->unk_000 & 0x2000) == 0) {
+ func_800C9A88(arg1);
+ arg0->unk_000 |= 0x10;
}
- if ((temp_v0 & 0x2000) == 0) {
- arg0 = temp_a2;
- func_800C9A88(arg1 & 0xFF, arg1, temp_a2);
- *arg0 = *arg0 | 0x10;
- return;
- }
- // Duplicate return node #14. Try simplifying control flow for better match
- return;
}
- // Duplicate return node #14. Try simplifying control flow for better match
- return;
- }
- temp_v0_2 = *temp_a2;
- if ((temp_v0_2 & 0x10) != 0x10) {
- if ((D_8018D168 == 1) && (temp_a2 == gPlayerOne)) {
- arg0 = temp_a2;
- func_800C94A4(arg1 & 0xFF, arg1, temp_a2);
- *arg0 = *arg0 | 0x10;
- return;
- }
- if ((temp_v0_2 & 0x2000) == 0) {
- arg0 = temp_a2;
- func_800C9A88(arg1 & 0xFF, arg1, temp_a2);
- *arg0 = *arg0 | 0x10;
+ } else if ((arg0->unk_000 & 0x10) != 0x10) {
+ if ((D_8018D168 == 1) && (arg0 == gPlayerOne)) {
+ func_800C94A4(arg1 & 0xFF);
+ arg0->unk_000 |= 0x10;
+ } else if ((arg0->unk_000 & 0x2000) == 0) {
+ func_800C9A88(arg1);
+ arg0->unk_000 |= 0x10;
}
- // Duplicate return node #14. Try simplifying control flow for better match
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80027DA8.s")
-#endif
void func_80027EDC(Player *player, s8 playerId) {
s32 stackPadding;
if (((player->unk_000 & 0x4000) == 0x4000) && ((player->unk_000 & 0x100) != 0x100)) {
- switch (gCurrentCourseId) { /* switch 1 */
- case COURSE_MARIO_RACEWAY: /* switch 1 */
+ switch (gCurrentCourseId) {
+ case COURSE_MARIO_RACEWAY:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x19B) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1B9)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x55);
@@ -422,7 +395,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_CHOCO_MOUNTAIN: /* switch 1 */
+ case COURSE_CHOCO_MOUNTAIN:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0xA0) && ((s16)gNearestWaypointByPlayerId[playerId] < 0xB4)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x55);
@@ -435,7 +408,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_BOWSER_CASTLE: /* switch 1 */
+ case COURSE_BOWSER_CASTLE:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x29) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1D2)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x41);
@@ -448,7 +421,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_BANSHEE_BOARDWALK: /* switch 1 */
+ case COURSE_BANSHEE_BOARDWALK:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x180) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1E1)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x41);
@@ -461,7 +434,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_LUIGI_RACEWAY: /* switch 1 */
+ case COURSE_LUIGI_RACEWAY:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x145) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x18B)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x55);
@@ -474,7 +447,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_TOADS_TURNPIKE: /* switch 1 */
+ case COURSE_TOADS_TURNPIKE:
if ((player->unk_000 & 0x800) != 0x800) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x1e);
@@ -487,7 +460,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_SHERBET_LAND: /* switch 1 */
+ case COURSE_SHERBET_LAND:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x11C) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x209)) {
if (D_80165300[playerId] != 1) {
func_800CA288(playerId, 0x55);
@@ -500,7 +473,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_DK_JUNGLE: /* switch 1 */
+ case COURSE_DK_JUNGLE:
if ((((s16)gNearestWaypointByPlayerId[playerId] >= 0) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x65)) ||
(((s16)gNearestWaypointByPlayerId[playerId] >= 0x14A) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x21F))) {
if (D_80165300[playerId] != 2) {
@@ -526,12 +499,12 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- default: /* switch 1 */
+ default:
break;
}
} else {
- switch (gCurrentCourseId) { /* switch 2 */
- case COURSE_MARIO_RACEWAY: /* switch 2 */
+ switch (gCurrentCourseId) {
+ case COURSE_MARIO_RACEWAY:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x19B) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1B9)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x55);
@@ -544,7 +517,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_CHOCO_MOUNTAIN: /* switch 2 */
+ case COURSE_CHOCO_MOUNTAIN:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0xA0) && ((s16)gNearestWaypointByPlayerId[playerId] < 0xB4)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x55);
@@ -557,7 +530,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_BOWSER_CASTLE: /* switch 2 */
+ case COURSE_BOWSER_CASTLE:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x29) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1D2)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x41);
@@ -570,7 +543,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_BANSHEE_BOARDWALK: /* switch 2 */
+ case COURSE_BANSHEE_BOARDWALK:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x180) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x1E1)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x41);
@@ -583,7 +556,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_LUIGI_RACEWAY: /* switch 2 */
+ case COURSE_LUIGI_RACEWAY:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x145) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x18B)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x55);
@@ -596,7 +569,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_TOADS_TURNPIKE: /* switch 2 */
+ case COURSE_TOADS_TURNPIKE:
if ((player->unk_000 & 0x800) != 0x800) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x1E);
@@ -609,7 +582,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_SHERBET_LAND: /* switch 2 */
+ case COURSE_SHERBET_LAND:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x11C) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x209)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x55);
@@ -622,7 +595,7 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- case COURSE_DK_JUNGLE: /* switch 2 */
+ case COURSE_DK_JUNGLE:
if (((s16)gNearestWaypointByPlayerId[playerId] >= 0x288) && ((s16)gNearestWaypointByPlayerId[playerId] < 0x305)) {
if (D_80165300[playerId] != 1) {
func_800CA2E4(playerId, 0x55);
@@ -635,188 +608,150 @@ void func_80027EDC(Player *player, s8 playerId) {
}
}
break;
- default: /* switch 2 */
+ default:
break;
}
}
}
-#ifdef MIPS_TO_C
-//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
-void control_cpu_movement(Player *, Camera *, s8, s8); /* extern */
-void func_8002D028(s8); /* extern */
-void func_8002E594(Player *, Camera *, s8, s8); /* extern */
-void func_8002F730(Player *, Camera *, s8, s8); /* extern */
-extern s16 D_801633F8;
-
void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) {
u16 sp1E;
- s16 temp_v0_7;
- s32 temp_t4;
- s32 temp_v0_2;
- u16 temp_v0;
- u16 temp_v0_3;
- u16 temp_v0_4;
- u16 temp_v0_5;
- u16 temp_v0_6;
-
- temp_v0 = player->unk_000;
- if (!(temp_v0 & 0x2000)) {
- switch (gActiveScreenMode) { /* irregular */
- case SCREEN_MODE_1P:
- sp1E = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
- break;
- case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL:
- case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
- temp_v0_3 = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
- sp1E = temp_v0_3;
- if (temp_v0_3 == 1) {
-
- } else {
+
+ if (!(player->unk_000 & 0x2000)) {
+ switch (gActiveScreenMode) {
+ case 0:
+ sp1E = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
+ break;
+ case 1:
+ case 2:
+ sp1E = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
+ if (sp1E == 1) break;
sp1E = func_8001FB0C(player, camera2, (f32) D_8016557C, 0.0f);
- }
- break;
- case SCREEN_MODE_3P_4P_SPLITSCREEN:
- temp_v0_4 = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
- sp1E = temp_v0_4;
- if (temp_v0_4 == 1) {
-
- } else {
- temp_v0_5 = func_8001FB0C(player, camera2, (f32) D_8016557C, 0.0f);
- sp1E = temp_v0_5;
- if (temp_v0_5 == 1) {
-
+ break;
+ case 3:
+ sp1E = func_8001FB0C(player, camera1, (f32) D_8016557C, 0.0f);
+ if (sp1E == 1) break;
+ sp1E = func_8001FB0C(player, camera2, (f32) D_8016557C, 0.0f);
+ if (sp1E == 1) break;
+ sp1E = func_8001FB0C(player, camera3, (f32) D_8016557C, 0.0f);
+ if (sp1E == 1) break;
+ sp1E = func_8001FB0C(player, camera4, (f32) D_8016557C, 0.0f);
+ break;
+ }
+ if ((sp1E == 1) ||
+ ((player->unk_000 & 0x100) == 0x100) ||
+ (gModeSelection == 3) ||
+ ((player->unk_0CA & 2) != 0) ||
+ (player->unk_0CA & 8) ||
+ ((*((&D_801633F8) + (arg2))) == ((s16) 1U))) {
+ player->unk_0BC &= ~0x1000;
+ if (((player->unk_0BC & 0x80) == 0x80) ||
+ ((player->unk_0BC & 0x40) == 0x40) ||
+ ((player->unk_0BC & 0x400) == 0x400) ||
+ ((player->unk_0BC & 0x4000) == 0x4000) ||
+ ((player->unk_0BC & 0x80000) == 0x80000) ||
+ ((player->unk_0BC & 0x800000) == 0x800000) ||
+ ((player->unk_0BC & 0x01000000) == 0x01000000) ||
+ ((player->unk_0BC & 0x02000000) == 0x02000000) ||
+ ((player->unk_0BC & 0x20000) == 0x20000) ||
+ (player->unk_044 & 0x800)) {
+ func_8002E594(player, camera, arg3, arg2);
} else {
- temp_v0_6 = func_8001FB0C(player, camera3, (f32) D_8016557C, 0.0f);
- sp1E = temp_v0_6;
- if (temp_v0_6 == 1) {
-
- } else {
- sp1E = func_8001FB0C(player, camera4, (f32) D_8016557C, 0.0f);
- }
+ func_8002D268(player, camera, arg3, arg2);
}
- }
- break;
- }
- if ((sp1E == 1) || ((player->unk_000 & 0x100) == 0x100) || (gModeSelection == BATTLE) || (temp_v0_7 = player->unk_0CA, ((temp_v0_7 & 2) != 0)) || (temp_v0_7 & 8) || (*(&D_801633F8 + (arg2 * 2)) == (s16) 1U)) {
- temp_t4 = player->unk_0BC & ~0x1000;
- player->unk_0BC = temp_t4;
- if (((temp_t4 & 0x80) == 0x80) || ((temp_t4 & 0x40) == 0x40) || ((temp_t4 & 0x400) == 0x400) || ((temp_t4 & 0x4000) == 0x4000) || ((temp_t4 & 0x80000) == 0x80000) || ((temp_t4 & 0x800000) == 0x800000) || ((temp_t4 & 0x01000000) == 0x01000000) || ((temp_t4 & 0x02000000) == 0x02000000) || ((temp_t4 & 0x20000) == 0x20000) || (player->unk_044 & 0x800)) {
- func_8002E594(player, camera, arg3, arg2);
- return;
- }
- func_8002D268(player, camera, arg3, arg2);
- return;
+ } else {
+ control_cpu_movement(player, camera, arg3, arg2);
}
- control_cpu_movement(player, camera, arg3, arg2);
- return;
- }
- if ((temp_v0 & 0x200) == 0x200) {
- func_8002D028(arg2);
+ } else if ((player->unk_000 & 0x200) == 0x200) {
+ func_8002D028(player, arg2);
func_8002F730(player, camera, arg3, arg2);
- return;
- }
- if (temp_v0 & 0x80) {
+ } else if (player->unk_000 & 0x80) {
func_8002D268(player, camera, arg3, arg2);
- return;
- }
- if ((temp_v0 & 0x4000) != 0x4000) {
- player->unk_09C = 50.0f;
+ } else {
+ if ((player->unk_000 & 0x4000) != 0x4000) {
+ player->unk_09C = 50.0f;
+ }
+ player->unk_0BC &= ~8;
}
- player->unk_0BC &= ~8;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80028864.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-void func_8002E594(s8, s8); // extern
-
-void func_80028C44(Player *arg0, s32 arg1, s8 arg2, s8 arg3) {
- s32 temp_t9;
+void func_80028C44(Player *arg0, s32 arg1, s8 arg2, s8 arg3) {
if ((arg0->unk_000 & 0x2000) == 0) {
- temp_t9 = arg0->unk_0BC & ~0x1000;
- arg0->unk_0BC = temp_t9;
- if (((temp_t9 & 0x80) == 0x80) || ((temp_t9 & 0x40) == 0x40) || ((temp_t9 & 0x400) == 0x400) || ((temp_t9 & 0x4000) == 0x4000) || ((temp_t9 & 0x80000) == 0x80000) || ((temp_t9 & 0x800000) == 0x800000) || ((temp_t9 & 0x1000000) == 0x1000000) || ((temp_t9 & 0x2000000) == 0x2000000) || ((temp_t9 & 0x20000) == 0x20000) || ((arg0->unk_044 & 0x800) != 0)) {
- func_8002E594(arg3, arg2);
- return;
- }
- func_8002D268(arg0, arg1, arg3, arg2);
- return;
- }
- arg0->unk_0BC &= -9;
+ arg0->unk_0BC &= ~0x1000;
+ if (((arg0->unk_0BC & 0x80) == 0x80) ||
+ ((arg0->unk_0BC & 0x40) == 0x40) ||
+ ((arg0->unk_0BC & 0x400) == 0x400) ||
+ ((arg0->unk_0BC & 0x4000) == 0x4000) ||
+ ((arg0->unk_0BC & 0x80000) == 0x80000) ||
+ ((arg0->unk_0BC & 0x800000) == 0x800000) ||
+ ((arg0->unk_0BC & 0x1000000) == 0x1000000) ||
+ ((arg0->unk_0BC & 0x2000000) == 0x2000000) ||
+ ((arg0->unk_0BC & 0x20000) == 0x20000) ||
+ ((arg0->unk_044 & 0x800) != 0)) {
+ func_8002E594(arg0, arg1, arg3, arg2);
+ } else {
+ func_8002D268(arg0, arg1, arg3, arg2);
+ }
+ } else {
+ arg0->unk_0BC &= -9;
+ }
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80028C44.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-void func_8002E594(s8, s8); // extern
-extern s32 D_800DC510;
void func_80028D3C(Player *arg0, s32 arg1, s8 arg2, s8 arg3) {
- s16 temp_v0;
- s32 temp_t3;
- s32 temp_v0_2;
-
- if ((((arg0->unk_000 & 0x2000) == 0) && (D_800DC510 != 5)) || (temp_v0 = arg0->unk_0CA, ((temp_v0 & 2) != 0)) || ((temp_v0 & 8) != 0) || (temp_v0_2 = arg0->unk_0BC, ((temp_v0_2 & 0x4F010CC0) != 0))) {
- temp_t3 = arg0->unk_0BC & ~0x1000;
- arg0->unk_0BC = temp_t3;
- if (((temp_t3 & 0x80) == 0x80) || ((temp_t3 & 0x40) == 0x40) || ((temp_t3 & 0x400) == 0x400) || ((temp_t3 & 0x4000) == 0x4000) || ((temp_t3 & 0x80000) == 0x80000) || ((temp_t3 & 0x800000) == 0x800000) || ((temp_t3 & 0x1000000) == 0x1000000) || ((temp_t3 & 0x2000000) == 0x2000000) || ((temp_t3 & 0x20000) == 0x20000) || ((arg0->unk_044 & 0x800) != 0)) {
- func_8002E594(arg3, arg2);
- return;
- }
- func_8002D268(arg0, arg1, arg3, arg2);
- return;
+ if (((arg0->unk_000 & 0x2000) == 0) &&
+ (D_800DC510 != 5) ||
+ (arg0->unk_0CA & 2) != 0 ||
+ (arg0->unk_0CA & 8) != 0 ||
+ (arg0->unk_0BC & 0x4F010CC0) != 0) {
+ arg0->unk_0BC &= ~0x1000;
+
+ if (((arg0->unk_0BC & 0x80) == 0x80) ||
+ ((arg0->unk_0BC & 0x40) == 0x40) ||
+ ((arg0->unk_0BC & 0x400) == 0x400) ||
+ ((arg0->unk_0BC & 0x4000) == 0x4000) ||
+ ((arg0->unk_0BC & 0x80000) == 0x80000) ||
+ ((arg0->unk_0BC & 0x800000) == 0x800000) ||
+ ((arg0->unk_0BC & 0x1000000) == 0x1000000) ||
+ ((arg0->unk_0BC & 0x2000000) == 0x2000000) ||
+ ((arg0->unk_0BC & 0x20000) == 0x20000) ||
+ ((arg0->unk_044 & 0x800) != 0)) {
+ func_8002E594(arg0, arg1, arg3, arg2);
+ } else {
+ func_8002D268(arg0, arg1, arg3, arg2);
+ }
+ } else {
+ arg0->unk_0BC = arg0->unk_0BC & ~8;
}
- arg0->unk_0BC = temp_v0_2 & ~8;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80028D3C.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-void func_80027DA8(s8); // extern
-void func_80028864(void *, s32, s8, s8); // extern
-void func_80028C44(void *, s32, s8, s8); // extern
-void func_80028D3C(void *, s32, s8, s8); // extern
-void func_80038C6C(s8, s8); // extern
-
-void func_80028E70(void *arg0, s32 arg1, s8 arg2, s8 arg3) {
- s32 temp_v0_2;
- u16 temp_v0;
-
- temp_v0 = arg0->unk0;
- if ((temp_v0 & 0x8000) == 0x8000) {
- if (gGamestate == ENDING_SEQUENCE) {
- if ((temp_v0 & 0x2000) == 0) {
- func_80038C6C(arg3, arg2);
- return;
- }
- arg0->unkBC = arg0->unkBC & ~8;
- return;
- }
- func_80027DA8(arg2);
- temp_v0_2 = gModeSelection;
- if ((temp_v0_2 != TIME_TRIALS) && (temp_v0_2 != VERSUS)) {
- if (temp_v0_2 != BATTLE) {
- func_80028864(arg0, arg1, arg2, arg3);
- // Duplicate return node #12. Try simplifying control flow for better match
- return;
- }
- func_80028D3C(arg0, arg1, arg2, arg3);
- return;
+void func_80028E70(Player *arg0, Camera *arg1, s8 arg2, s8 arg3) {
+ if ((arg0->unk_000 & 0x8000) == 0x8000) {
+ switch (gGamestate) {
+ case ENDING_SEQUENCE:
+ if (!(arg0->unk_000 & 0x2000)) {
+ func_80038C6C(arg0, arg1, arg3, arg2);
+ } else {
+ arg0->unk_0BC &= ~8;
+ }
+ break;
+ default:
+ func_80027DA8(arg0, arg2);
+ switch (gModeSelection) {
+ case TIME_TRIALS:
+ case VERSUS:
+ func_80028C44(arg0, arg1, arg2, arg3);
+ break;
+ case BATTLE:
+ func_80028D3C(arg0, arg1, arg2, arg3);
+ break;
+ default:
+ func_80028864(arg0, arg1, arg2, arg3);
+ break;
+ }
+ break;
}
- func_80028C44(arg0, arg1, arg2, arg3);
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80028E70.s")
-#endif
UNUSED void func_80028F5C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s32 arg3) {
@@ -1905,64 +1840,55 @@ void func_8002BD58(Player *player) {
}
}
-#ifdef MIPS_TO_C
-//generated by m2c commit b7eac665cffd02361f73cec283ef16d0a35a0e5b
-void func_8002BF4C(Player *player, u8 arg1) {
- s32 sp30;
- Player *var_s0;
- s32 temp_t2;
- s32 var_s1;
- s32 var_v0;
- u16 temp_v0;
- u16 temp_v0_2;
- u16 var_a2;
-
+void func_8002BF4C(Player *player, u8 arg1) {
+ UNUSED s32 stackPadding[2];
+ UNUSED s32 temp_t2;
+ s32 uselessAssignment;
+ s32 i;
+ s32 var_a2;
+ Player *playerBorrow;
+ Player *players = gPlayerOne;
+
var_a2 = 0;
+
if (((player->unk_094 / 18.0f) * 216.0f) < 50.0f) {
player->unk_0E2 = 0;
player->unk_0BC &= 0xFFDFFFFF;
return;
}
- var_s1 = 0;
- var_s0 = gPlayerOne;
if ((player->unk_0BC & 0x200000) == 0x200000) {
player->unk_0E2 -= 1;
if (player->unk_0E2 <= 0) {
player->unk_0BC &= 0xFFDFFFFF;
}
} else {
-loop_6:
- if ((player != var_s0) && (temp_v0 = var_s0->unk_000, ((temp_v0 & 0x100) == 0)) && (temp_v0 & 0x8000) && (temp_v0_2 = func_8001FD78(player, var_s0->pos[0], var_s0->pos[1], var_s0->pos[2]), var_a2 = temp_v0_2, (temp_v0_2 == 1))) {
- player->unk_0E2 += 1;
- if (player->unk_0E2 >= 0x3D) {
- temp_t2 = player->unk_000 & 0x100;
- player->unk_0BC |= 0x200000;
- var_v0 = temp_t2;
- if (temp_t2 != 0x100) {
- sp30 = (s32) var_a2;
- func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008001);
- var_v0 = player->unk_000 & 0x100;
- }
- if (var_v0 != 0x100) {
- sp30 = (s32) var_a2;
- func_800C9060(arg1, 0x19008011U);
- }
- }
- } else {
- var_s1 += 0xDD8;
- var_s0 += 0xDD8;
- if (var_s1 != 0x6EC0) {
- goto loop_6;
+ for (i = 0; i < 8; i++) {
+ playerBorrow = &players[i];
+ if (((player != playerBorrow) &&
+ ((playerBorrow->unk_000 & 0x100) == 0) &&
+ (playerBorrow->unk_000 & 0x8000)) &&
+ ((var_a2 = func_8001FD78(player, playerBorrow->pos[0], playerBorrow->pos[1], playerBorrow->pos[2]), var_a2 == 1))) {
+ player->unk_0E2 += 1;
+ if (player->unk_0E2 >= 0x3D) {
+ player->unk_0BC |= 0x200000;
+ if ((player->unk_000 & 0x100) != 0x100) {
+ uselessAssignment = player->unk_000 & 0x100;
+ func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008001);
+ }
+ if ((player->unk_000 & 0x100) != 0x100) {
+ uselessAssignment = var_a2;
+ func_800C9060(arg1, 0x19008011);
+ }
+ }
+ break;
}
}
+
if (var_a2 == 0) {
player->unk_0E2 = 0;
}
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002BF4C.s")
-#endif
void func_8002C11C(Player *player) {
if ((player->unk_0BC & 0x10) == 0x10) {
@@ -2091,40 +2017,22 @@ void func_8002C4F8(Player *player, s8 arg1) {
func_8002C17C(player, arg1);
}
-#ifdef MIPS_TO_C
-//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
-void func_8002B9CC(s8, s8); /* extern */
-
-void func_8002C7E4(Player *player, s8 arg1, s8 arg2) {
- s16 temp_v1_2;
- s32 temp_v0;
- s32 temp_v0_2;
- u16 temp_t3;
- u16 temp_t6;
- u16 temp_v1;
- u16 var_v1;
-
- var_v1 = player->unk_046;
- if ((var_v1 & 1) != 1) {
- temp_v0 = player->unk_0BC;
- if ((temp_v0 & 0x8000) == 0x8000) {
- if ((temp_v0 & 0x2000) != 0x2000) {
- func_8002B9CC(arg1, arg2);
- var_v1 = player->unk_046;
+void func_8002C7E4(Player *player, s8 arg1, s8 arg2) {
+ if ((player->unk_046 & 1) != 1) {
+ if ((player->unk_0BC & 0x8000) == 0x8000) {
+ if ((player->unk_0BC & 0x2000) != 0x2000) {
+ func_8002B9CC(player, arg1, arg2);
}
- temp_t6 = var_v1 | 1;
- player->unk_046 = temp_t6;
- player->unk_044 &= 0xFFFE;
- player->unk_046 = temp_t6 | 8;
+ player->unk_044 &= ~0x0001;
+ player->unk_046 |= 1;
+ player->unk_046 |= 8;
if ((player->unk_000 & 0x4000) == 0x4000) {
func_8001CA24(player, 2.8f);
}
- temp_v1 = player->unk_046;
- if ((temp_v1 & 2) == 2) {
- temp_t3 = temp_v1 | 4;
- if ((temp_v1 & 4) != 4) {
- player->unk_046 = temp_t3;
- player->unk_046 = temp_t3 | 0x40;
+ if ((player->unk_046 & 2) == 2) {
+ if ((player->unk_046 & 4) != 4) {
+ player->unk_046 |= 4;
+ player->unk_046 |= 0x40;
if (player->unk_0BC & 0x2000) {
func_8008D554(player);
}
@@ -2132,26 +2040,21 @@ void func_8002C7E4(Player *player, s8 arg1, s8 arg2) {
}
}
}
- temp_v0_2 = player->unk_0BC;
- if ((temp_v0_2 & 0x8000) == 0x8000) {
- player->unk_0BC = temp_v0_2 & 0xFFFF7FFF;
+ if ((player->unk_0BC & 0x8000) == 0x8000) {
+ player->unk_0BC &= ~0x8000;
player->unk_10C = 1;
- player->unk_044 &= 0xFFFE;
+ player->unk_044 &= ~0x0001;
return;
}
- temp_v1_2 = player->unk_10C;
- player->unk_046 &= 0xFFFE;
- player->unk_0BC = temp_v0_2 & 0xFFFF7FFF;
- if (temp_v1_2 > 0) {
- player->unk_10C = temp_v1_2 + 1;
+ player->unk_046 &= ~0x0001;
+ player->unk_0BC &= ~0x8000;
+ if (player->unk_10C > 0) {
+ player->unk_10C += 1;
}
if (player->unk_10C >= 0xA) {
player->unk_10C = 0;
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002C7E4.s")
-#endif
#ifdef MIPS_TO_C
//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
@@ -2224,18 +2127,8 @@ void func_8002C954(Player *player, s8 arg1, f32 *arg2) {
GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002C954.s")
#endif
-#ifdef MIPS_TO_C
-//generated by m2c commit b7eac665cffd02361f73cec283ef16d0a35a0e5b
-? func_8008CEB0(Player *, s8); /* extern */
-? func_8008D170(Player *, s8); /* extern */
-? func_80090970(Player *, s8, s8); /* extern */
-extern s32 D_800DC510;
-
void func_8002CD48(Player *player, s8 arg1, s8 arg2) {
- s16 temp_v0;
-
- temp_v0 = player->unk_0CA;
- if (((temp_v0 & 2) == 2) || ((temp_v0 & 8) == 8)) {
+ if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) {
func_80090970(player, arg1, arg2);
}
if ((player->unk_0BC & 0x800) == 0x800) {
@@ -2305,9 +2198,6 @@ void func_8002CD48(Player *player, s8 arg1, s8 arg2) {
func_80091298(player, arg1);
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002CD48.s")
-#endif
#ifdef NON_MATCHING
void func_8002D028(Player *player, s8 arg1) {
@@ -4268,148 +4158,81 @@ void func_80033850(Player *arg0, f32 arg1) {
}
}
-#ifdef MIPS_TO_C
-//generated by m2c commit b7eac665cffd02361f73cec283ef16d0a35a0e5b
void func_80033884(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) {
- s32 temp_v0;
- s32 temp_v0_2;
s32 temp_v1;
- u32 temp_t8;
- u32 var_v1;
- temp_v0 = *arg1;
- if ((temp_v0 >= arg4) || (-arg4 >= temp_v0)) {
+ if ((*arg1 >= arg4) || (-arg4 >= *arg1)) {
temp_v1 = player->unk_200;
- temp_t8 = temp_v1 - 0x800;
- player->unk_200 = (s32) temp_t8;
- var_v1 = temp_t8;
- if (temp_t8 >= 0xF0000000U) {
+ player->unk_200 -= 0x800;
+ if (player->unk_200 >= 0xF0000000) {
player->unk_200 = temp_v1;
- var_v1 = (u32) temp_v1;
}
- if (arg5 >= (s32) var_v1) {
+ if (arg5 >= player->unk_200) {
player->unk_200 = arg5;
- var_v1 = (u32) arg5;
}
- temp_v0_2 = *arg2;
- if (arg3 < temp_v0_2) {
- *arg2 = temp_v0_2 - var_v1;
- } else {
- *arg2 = temp_v0_2 + var_v1;
- }
- if (player->unk_090 < (f32) arg6) {
+
+ *arg2 = (arg3 < *arg2) ? * arg2 - player->unk_200 : *arg2 + player->unk_200;
+
+ if (player->unk_090 < ((f32) arg6)) {
player->unk_090 = (f32) -arg6;
}
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80033884.s")
-#endif
-#if MIPS_TO_C
-UNUSED void func_80033940(void *arg0, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) {
- s32 temp_at;
- s32 temp_v0_2;
- u32 temp_t6;
- u32 temp_v0;
+UNUSED void func_80033940(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) {
u32 temp_v1;
- u32 var_v1;
-
- temp_v1 = arg0->unk200;
- temp_t6 = temp_v1 - 0x800;
- temp_at = temp_t6 < 0xF0000000U;
- temp_v0 = temp_v1;
- arg0->unk200 = temp_t6;
- var_v1 = temp_t6;
- if (temp_at == 0) {
- arg0->unk200 = temp_v0;
- var_v1 = temp_v0;
- }
- if (arg3 >= (s32) var_v1) {
- arg0->unk200 = (u32) arg3;
- var_v1 = (u32) arg3;
- }
- temp_v0_2 = *arg1;
- if (arg2 < temp_v0_2) {
- *arg1 = temp_v0_2 - var_v1;
- } else {
- *arg1 = temp_v0_2 + var_v1;
+
+ temp_v1 = player->unk_200;
+ player->unk_200 -= 0x800;
+ if (!(player->unk_200 < 0xF0000000)) {
+ player->unk_200 = temp_v1;
+ }
+ if (arg3 >= player->unk_200) {
+ player->unk_200 = arg3;
}
- if (arg0->unk90 < arg4) {
- arg0->unk90 = (f32) -arg4;
+
+ *arg1 = (arg2 < *arg1) ? *arg1 - player->unk_200 : *arg1 + player->unk_200;
+
+ if (player->unk_090 < arg4) {
+ player->unk_090 = (f32) -arg4;
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80033940.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by m2c commit b7eac665cffd02361f73cec283ef16d0a35a0e5b
void func_800339C4(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) {
s32 temp_v0;
- s32 temp_v1;
- u32 temp_t6;
- u32 var_v0;
-
+
temp_v0 = player->unk_200;
- temp_t6 = temp_v0 - 0x800;
- player->unk_200 = (s32) temp_t6;
- var_v0 = temp_t6;
- if (temp_t6 >= 0xF0000000U) {
+ player->unk_200 -= 0x800;
+ if (player->unk_200 >= 0xF0000000) {
player->unk_200 = temp_v0;
- var_v0 = (u32) temp_v0;
}
- if (arg3 >= (s32) var_v0) {
+ if (arg3 >= player->unk_200) {
player->unk_200 = arg3;
- var_v0 = (u32) arg3;
- }
- temp_v1 = *arg1;
- if (arg2 < temp_v1) {
- *arg1 = temp_v1 - var_v0;
- } else {
- *arg1 = temp_v1 + var_v0;
}
+
+ *arg1 = (arg2 < *arg1) ? *arg1 - player->unk_200 : *arg1 + player->unk_200;
+
func_80033850(player, arg4);
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_800339C4.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by m2c commit b7eac665cffd02361f73cec283ef16d0a35a0e5b
void func_80033A40(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6) {
- s32 temp_v0;
- s32 temp_v0_2;
s32 temp_v1;
- u32 temp_t8;
- u32 var_v0;
-
- temp_v0 = *arg1;
- if ((temp_v0 >= arg4) || (-arg4 >= temp_v0)) {
- temp_v0_2 = player->unk_200;
- temp_t8 = temp_v0_2 - 0x800;
- player->unk_200 = (s32) temp_t8;
- var_v0 = temp_t8;
- if (temp_t8 >= 0xF0000000U) {
- player->unk_200 = temp_v0_2;
- var_v0 = (u32) temp_v0_2;
- }
- if (arg5 >= (s32) var_v0) {
- player->unk_200 = arg5;
- var_v0 = (u32) arg5;
+
+ if ((*arg1 >= arg4) || (-arg4 >= *arg1)) {
+ temp_v1 = player->unk_200;
+ player->unk_200 -= 0x800;
+ if (player->unk_200 >= 0xF0000000) {
+ player->unk_200 = temp_v1;
}
- temp_v1 = *arg2;
- if (arg3 < temp_v1) {
- *arg2 = temp_v1 - var_v0;
- } else {
- *arg2 = temp_v1 + var_v0;
+ if (arg5 >= player->unk_200) {
+ player->unk_200 = arg5;
}
+
+ *arg2 = (arg3 < *arg2) ? * arg2 - player->unk_200 : *arg2 + player->unk_200;
+
func_80033850(player, arg6);
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80033A40.s")
-#endif
#ifdef MIPS_TO_C
//generated by m2c commit 0927f17aac197848d4ebdf0c6bbad74b01f0851c
@@ -5530,53 +5353,35 @@ void func_80037CFC(Player *player, struct Controller *controller, u8 arg2) {
GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80037CFC.s")
#endif
-#ifdef MIPS_TO_C
-//generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc
-extern s8 D_80164A89;
-extern s16 D_801656F0;
-extern s32 D_8018D168;
-extern s32 gRaceFrameCounter;
-
-void func_800381AC(Player *player, struct Controller *controller, u8 arg2) {
- s16 temp_v0_2;
- s32 *temp_v0_3;
- u16 temp_v0;
-
- temp_v0 = player->unk_000;
- if (((temp_v0 & 0x8000) == 0x8000) && ((temp_v0 & 0x4000) == 0x4000) && ((temp_v0 & 0x1000) != 0x1000)) {
- if ((temp_v0 & 0x2000) != 0x2000) {
- temp_v0_2 = player->unk_0CA;
- if (((temp_v0_2 & 2) == 2) || ((temp_v0_2 & 8) == 8)) {
- if (controller->button & 0x8000) {
- func_80032D94(player);
+void func_800381AC(Player *player, struct Controller *controller, s8 arg2) {
+ if (((player->unk_000 & 0x8000) == 0x8000) &&
+ ((player->unk_000 & 0x4000) == 0x4000) &&
+ ((player->unk_000 & 0x1000) != 0x1000)) {
+ if ((player->unk_000 & 0x2000) != 0x2000) {
+ if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) {
+ if (controller->button & 0x8000) {
+ func_80032D94(player);
+ } else {
+ func_80033280(player, 5.0f);
+ }
} else {
- func_80033280(player, 5.0f);
+ func_80037CFC(player, controller, arg2);
}
- } else {
- func_80037CFC((s8) arg2);
- }
- D_80164A89 = 1;
- return;
- }
- if (D_8018D168 == 1) {
- if (D_801656F0 == (s16) 1) {
- temp_v0_3 = &D_801652E0[(s8) arg2];
- if (*temp_v0_3 == 0) {
- *temp_v0_3 = gRaceFrameCounter;
+ D_80164A89 = 1;
+ } else if (D_8018D168 == 1) {
+ if (D_801656F0 == 1) {
+ if (D_801652E0[arg2] == 0) {
+ D_801652E0[arg2] = gRaceFrameCounter;
+ }
+ }
+ if (controller->button & 0x8000) {
+ func_80032700(player);
+ } else {
+ func_80032CB0(player, 5.0f);
}
- }
- if (controller->button & 0x8000) {
- func_80032700((s8) arg2);
- return;
- }
- func_80032CB0(player, 5.0f);
}
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80027D00/func_800381AC.s")
-#endif
-
void func_800382DC(void) {
u16 temp_v0_3;
diff --git a/src/code_80057C60.c b/src/code_80057C60.c
index aa48c5ba3..c35cad19f 100644
--- a/src/code_80057C60.c
+++ b/src/code_80057C60.c
@@ -910,7 +910,7 @@ void func_80059AC8(void) {
s32 var_s0;
s32 var_s1;
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
func_8008C1D8(&D_80165678);
gRaceFrameCounter += 1;
var_s2 = D_8018CF68;
@@ -1082,7 +1082,7 @@ void func_8005A070(void) {
D_8018D120 = 0;
D_801655C0 = 0;
func_80041D34();
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
func_8005C728();
if (gGamestate == ENDING_SEQUENCE) {
func_80086604();
diff --git a/src/code_80057C60.h b/src/code_80057C60.h
index 53b9ed771..d3d0691a7 100644
--- a/src/code_80057C60.h
+++ b/src/code_80057C60.h
@@ -234,7 +234,7 @@ extern struct UnkStruct_800DC5EC *D_800DC5F0;
extern struct UnkStruct_800DC5EC *D_800DC5F4;
extern struct UnkStruct_800DC5EC *D_800DC5F8;
-extern u16 D_800DC5FC;
+extern u16 gIsGamePaused;
extern s32 D_80164394;
extern s32 D_80164398;
diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c
index a2caa719f..f53d2ab47 100644
--- a/src/code_8006E9C0.c
+++ b/src/code_8006E9C0.c
@@ -599,7 +599,7 @@ GLOBAL_ASM("asm/non_matchings/code_8006E9C0/func_8006F008.s")
//#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
//void play_sound2(?); // extern
-extern u16 D_800DC5FC;
+extern u16 gIsGamePaused;
extern s8 D_801657E4;
extern s8 D_801657E6;
extern s8 D_801657E8;
@@ -627,7 +627,7 @@ void func_8006F824(s32 arg0) {
D_80165828 = D_801657F8;
D_80165832.unk0 = D_80165800.unk0;
D_80165832.unk1 = D_80165800.unk1;
- if ((arg0 != 0) && (D_800DC5FC == 0)) {
+ if ((arg0 != 0) && (gIsGamePaused == 0)) {
play_sound2(SOUND_ACTION_PING);
}
}
diff --git a/src/code_80091750.c b/src/code_80091750.c
index dcef00c0f..d7851340d 100644
--- a/src/code_80091750.c
+++ b/src/code_80091750.c
@@ -5188,7 +5188,7 @@ void func_8009CA6C(s32 arg0) {
temp_v1->words.w0 = 0x06000000;
temp_v1->words.w1 = (u32) &D_0D0076F8;
phi_a1 = 0;
- if ((arg0 != 4) && (D_800DC5FC != 0)) {
+ if ((arg0 != 4) && (gIsGamePaused != 0)) {
phi_a1 = 1;
}
temp_t0 = *(&D_8018E7AC + arg0);
@@ -5444,7 +5444,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) {
break;
}
if (var_a1_2 != 0) {
- D_800DC5FC = 0;
+ gIsGamePaused = 0;
}
}
temp_v0_5 = find_8018D9E0_entry(0x000000BD);
@@ -9877,7 +9877,7 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A4A24.s")
#endif
void func_800A4B38(struct_8018D9E0_entry *arg0) {
- if (D_800DC5FC != 0) {
+ if (gIsGamePaused != 0) {
switch (gModeSelection) {
case TIME_TRIALS:
func_800A4BC8(arg0);
@@ -10002,13 +10002,13 @@ void func_800A4EF8(struct_8018D9E0_entry *arg0) {
s32 phi_s1;
s32 phi_s0;
- temp_v0 = (D_800DC5FC << 6) - 0x40 + &D_8015F480;
+ temp_v0 = (gIsGamePaused << 6) - 0x40 + &D_8015F480;
temp_v1 = temp_v0->unk30;
temp_t0 = temp_v0->unk32;
temp_t3 = (s32) temp_v0->unk2C / 2;
temp_t4 = (s32) temp_v0->unk2E / 2;
gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, temp_t0 + temp_t4, 0, 0, 0, 0x8C);
- temp_s3 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E8540;
+ temp_s3 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E8540;
phi_a1 = 0;
phi_s2 = 0;
do {
@@ -10082,13 +10082,13 @@ void func_800A5084(struct_8018D9E0_entry *arg0) {
s32 phi_s1;
s8 **phi_s2;
- temp_v0 = (D_800DC5FC << 6) - 0x40 + &D_8015F480;
+ temp_v0 = (gIsGamePaused << 6) - 0x40 + &D_8015F480;
temp_v1 = temp_v0->unk30;
temp_t0 = temp_v0->unk32;
temp_t3 = (s32) temp_v0->unk2C / 2;
temp_t4 = (s32) temp_v0->unk2E / 2;
gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, temp_t0 + temp_t4, 0, 0, 0, 0x8C);
- temp_s3 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E85C0;
+ temp_s3 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E85C0;
temp_s0 = (s32) ((((f32) get_string_width(D_800E7500[gCupSelection]) * 1.0f) + 10.0f) / 2.0f);
temp_s1 = (s32) ((((f32) get_string_width(D_800E76CC[gCCSelection]) * 1.0f) + 10.0f) / 2.0f);
set_text_color(3);
@@ -10141,13 +10141,13 @@ void func_800A5360(struct_8018D9E0_entry *arg0) {
s32 phi_s1;
s32 phi_s0;
- temp_v0 = (D_800DC5FC << 6) - 0x40 + &D_8015F480;
+ temp_v0 = (gIsGamePaused << 6) - 0x40 + &D_8015F480;
temp_v1 = temp_v0->unk30;
temp_t0 = temp_v0->unk32;
temp_t3 = (s32) temp_v0->unk2C / 2;
temp_t4 = (s32) temp_v0->unk2E / 2;
gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, temp_t0 + temp_t4, 0, 0, 0, 0x8C);
- temp_s3 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E8600;
+ temp_s3 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E8600;
phi_a1 = 0;
phi_s2 = 0;
do {
@@ -10190,7 +10190,7 @@ void func_800A54EC(void) {
s32 temp_t2;
? *phi_v1;
- if (D_800DC5FC != 0) {
+ if (gIsGamePaused != 0) {
temp_t2 = gModeSelection;
sp40 = temp_t2;
temp_v1 = gDisplayListHead;
@@ -10213,13 +10213,13 @@ void func_800A54EC(void) {
phi_v1 = &D_800E8538;
break;
case VERSUS:
- phi_v1 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E8540;
+ phi_v1 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E8540;
break;
case GRAND_PRIX:
- phi_v1 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E85C0;
+ phi_v1 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E85C0;
break;
case BATTLE:
- phi_v1 = ((gScreenModeSelection << 5) + (D_800DC5FC * 8)) - 8 + &D_800E8600;
+ phi_v1 = ((gScreenModeSelection << 5) + (gIsGamePaused * 8)) - 8 + &D_800E8600;
break;
}
sp50 = phi_v1->unk0 - 8;
@@ -14873,7 +14873,7 @@ void func_800ADF48(struct_8018D9E0_entry *arg0) {
s32 stackPadding;
struct Controller *controller;
- if (D_800DC5FC != 0) {
+ if (gIsGamePaused != 0) {
switch (arg0->unk4) {
case 0:
arg0->unk4 = D_800F0B50[gModeSelection];
@@ -14894,7 +14894,7 @@ void func_800ADF48(struct_8018D9E0_entry *arg0) {
case 43:
case 44:
if (func_800B4520() == 0) {
- controller = &gControllers[D_800DC5FC - 1];
+ controller = &gControllers[gIsGamePaused - 1];
if ((controller->buttonPressed | controller->stickPressed) & 0x800) {
if (D_800F0B50[gModeSelection] < arg0->unk4) {
arg0->unk4--;
@@ -14925,7 +14925,7 @@ void func_800ADF48(struct_8018D9E0_entry *arg0) {
if (controller->buttonPressed & 0x9000) {
if (arg0->unk4 == D_800F0B50[gModeSelection]) {
arg0->unk4 = 0;
- D_800DC5FC = 0;
+ gIsGamePaused = 0;
func_8028DF38();
func_800C9F90(0U);
} else {
diff --git a/src/code_800B45E0.c b/src/code_800B45E0.c
index 1922a3020..a62a9cd22 100644
--- a/src/code_800B45E0.c
+++ b/src/code_800B45E0.c
@@ -878,31 +878,25 @@ s32 func_800B6088(s32 arg0) {
return osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_WRITE, arg0 * 0x80 /* 0x80 == sizeof(struct_8018EE10_entry) */, sizeof(struct_8018EE10_entry), (u8*) temp_v1);
}
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern s32 D_800DC714;
+#ifdef NON_MATCHING
-s32 func_800B60E8(s32 arg0) {
- s32 temp_a2;
- s32 temp_v0;
- s32 temp_v1;
- s32 phi_v0;
- s32 phi_v1;
- void *phi_a1;
+struct struct_D_800DC714
+{
+ u8 filler[0x100];
+};
- temp_a2 = arg0 + 1;
- phi_v0 = 0;
- phi_v1 = 0;
- phi_a1 = D_800DC714 + (arg0 << 8);
- do {
- temp_v0 = phi_v0 + 4;
- temp_v1 = phi_v1 + ((phi_a1->unk0 * temp_a2) + phi_v0) + ((phi_a1->unk1 * temp_a2) + phi_v0) + 1 + ((phi_a1->unk2 * temp_a2) + phi_v0) + 2 + ((phi_a1->unk3 * temp_a2) + phi_v0) + 3;
- phi_v0 = temp_v0;
- phi_v1 = temp_v1;
- phi_a1 += 4;
- } while (temp_v0 != 0x100);
- return temp_v1 & 0xFF;
+u8 func_800B60E8(s32 arg0)
+{
+ u8 *addr = *(s32 *)&D_800DC714 + (arg0 << 8);
+ s32 checksum = 0, i;
+
+ for (i = 0; i < sizeof(struct struct_D_800DC714); i++)
+ {
+ checksum = i + ((arg0 + 1) * *addr++) + checksum;
+ }
+ return checksum;
}
+
#else
GLOBAL_ASM("asm/non_matchings/menus/func_800B60E8.s")
#endif
diff --git a/src/code_80280000.c b/src/code_80280000.c
index 570b94cb8..30664b9d3 100644
--- a/src/code_80280000.c
+++ b/src/code_80280000.c
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include <macros.h>
#include <defines.h>
+#include <debug.h>
#include <PR/gu.h>
#include "main.h"
@@ -75,7 +76,7 @@ void func_80280268(s32 arg0) {
void credits_loop(void) {
Camera *camera = &cameras[0];
-
+
f32 temp_f12;
f32 temp;
f32 temp_f14;
@@ -103,6 +104,9 @@ void credits_loop(void) {
} else {
func_80280000();
func_80280038();
+#if DVDL
+ display_dvdl();
+#endif
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
}
diff --git a/src/code_80280650.c b/src/code_80280650.c
index e6e3f4f96..134a0c58d 100644
--- a/src/code_80280650.c
+++ b/src/code_80280650.c
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include <macros.h>
#include <types.h>
+#include <debug.h>
#include <common_structs.h>
#include "main.h"
#include "memory.h"
@@ -483,6 +484,9 @@ void ending_sequence_loop(void) {
}
func_80281D00();
func_80281540();
+#if VARIABLE_WATCH_DEBUG_LIST
+ display_dvdl();
+#endif
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
}
diff --git a/src/debug/all_variables.h b/src/debug/all_variables.h
new file mode 100644
index 000000000..fd05a271b
--- /dev/null
+++ b/src/debug/all_variables.h
@@ -0,0 +1,78 @@
+/**
+ * please do not include this file.
+ * ONLY FOR DEBUG PURPOSE
+ */
+#ifndef _VARIABLES_H_
+#define _VARIABLES_H_
+
+// #include <actors_extended.h> does not work
+#include <actors.h>
+#include <camera.h>
+#include <camera_junk.h>
+#include <ceremony_and_credits.h>
+#include <code_800029B0.h>
+#include <code_80004740.h>
+#include <code_80005FD0.h>
+#include <code_8001F980.h>
+#include <code_80027D00.h>
+#include <code_8003DC40.h>
+#include <code_80057C60.h>
+#include <code_8006E9C0.h>
+#include <code_80071F00.h>
+#include <code_80086E70.h>
+#include <code_8008C1D0.h>
+#include <code_80091440.h>
+#include <code_80091750.h>
+#include <code_800AF9B0.h>
+#include <code_800B45E0.h>
+#include <code_80280000.h>
+#include <code_80280650.h>
+#include <code_80281780.h>
+#include <code_80281C40.h>
+#include <code_802AAA70.h>
+#include <common_textures.h>
+#include <credits.h>
+#include <data_segment2.h>
+#include <framebuffers.h>
+#include <hud_renderer.h>
+#include <kart_dma.h>
+#include <main.h>
+#include <math_util_2.h>
+#include <math_util.h>
+#include <memory.h>
+#include <menus.h>
+#include <profiler.h>
+#include <race_logic.h>
+#include <render_courses.h>
+#include <skybox_and_splitscreen.h>
+#include <spawn_players.h>
+#include <staff_ghosts.h>
+#include <textures.h>
+
+#include <actor_types.h>
+#include <common_structs.h>
+#include <config.h>
+#include <course.h>
+#include <course_offsets.h>
+#include <debug.h>
+#include <defines.h>
+#include <functions.h>
+#include <global.h>
+#include <kart_attributes.h>
+#include <macros.h>
+#include <mk64.h>
+#include <objects.h>
+// #include <packed_displaylist_symbols_gen.h> does not work
+#include <packed_displaylist_symbols.h>
+#include <segments.h>
+#include <segment_symbols.h>
+#include <sounds.h>
+#include <trig_tables.h>
+#include <types.h>
+#include <ultra64.h>
+#include <variables.h>
+#include <vehicles.h>
+#include <vertice_count_gen.h>
+#include <waypoints.h>
+
+#endif
diff --git a/src/debug/debug.c b/src/debug/debug.c
new file mode 100644
index 000000000..cdc333dc5
--- /dev/null
+++ b/src/debug/debug.c
@@ -0,0 +1,251 @@
+#include <ultra64.h>
+#include <debug.h>
+#include "debug.inc.c"
+#include <libc/stdio.h>
+
+#if DVDL
+
+u8 sDisplayListState = OK;
+
+static u32 variable_to_u64(variableWatchAttributes *);
+static void round_up_float(u32 *, u8);
+static void u64_to_string(variableWatchAttributes *, u32, u8);
+static u32 _strlen(const char *);
+static void _memcpy(char *, const char *, u32);
+
+void display_dvdl(void) {
+ u32 variable;
+ u32 i, vNameLen;
+ u32 arraySize = sizeof(gMainVariableWatchList) / sizeof(variableWatchAttributes);
+ s32 text_y_possition = TEXT_Y_POSSITION;
+ u8 base;
+ char *vName, *cBuffer;
+
+ load_debug_font();
+ for (i = 0; i < arraySize; i++) {
+ variableWatchAttributes *currentAttribute = &gMainVariableWatchList[i];
+ currentAttribute->characterBuffer = currentAttribute->buffer;
+ cBuffer = currentAttribute->characterBuffer;
+ vName = currentAttribute->variableName;
+
+ variable = variable_to_u64(currentAttribute);
+ base = 0;
+
+ if (currentAttribute->variableFlag & (DISPLAY_FLOAT_AS_TYPE | DISPLAY_FLOAT_WITH_ROUNDING)) {
+ if (currentAttribute->variableFlag & DISPLAY_FLOAT_NUMBER) {
+ sDisplayListState = BAD;
+ } else if (currentAttribute->variableFlag & DISPLAY_FLOAT_WITH_ROUNDING) {
+ round_up_float(&variable, currentAttribute->variableSize);
+ }
+ }
+
+ switch (currentAttribute->variableFlag & 0x8F) {
+ case DISPLAY_FLOAT_NUMBER:
+ sprintf(cBuffer, "%.3f", *(f32*)&variable);
+ break;
+ case DISPLAY_HEXIDECIMAL_NUMBER:
+ base = HEXIDECIMAL;
+ break;
+ case DISPLAY_DECIMAL_NUMBER:
+ base = DECIMAL;
+ break;
+ case DISPLAY_OCTAL_NUMBER:
+ base = OCTAL;
+ break;
+ case DISPLAY_BINARY_NUMBER:
+ base = BINARY;
+ break;
+ default:
+ sDisplayListState = BAD;
+ }
+ if (base) {
+ u64_to_string(currentAttribute, variable, base);
+ }
+
+ if (sDisplayListState == BAD) {
+ cBuffer = "NaN";
+ }
+ sDisplayListState = OK;
+
+ vNameLen = _strlen(vName);
+
+ debug_print_str2(TEXT_X_POSSITION, text_y_possition, vName);
+ debug_print_str2(TEXT_X_POSSITION + (vNameLen * 0x8), text_y_possition, cBuffer);
+ text_y_possition += 0x8;
+ }
+ gSPDisplayList(gDisplayListHead++, D_0D007EB8);
+ gSPDisplayList(gDisplayListHead++, D_020076E0);
+ func_80093C98(1);
+}
+
+static u32 variable_to_u64(variableWatchAttributes *attribute) {
+ u32 variable;
+
+ switch (attribute->variableSize) {
+ case sizeof(u8):
+ variable = *((u8*) attribute->variablePointer);
+ break;
+ case sizeof(u16):
+ variable = *((u16*) attribute->variablePointer);
+ break;
+ case sizeof(u32):
+ case sizeof(u64):
+ variable = *((u32*) attribute->variablePointer); // no floating point rounding
+ break;
+ default:
+ sDisplayListState = BAD;
+ }
+
+ return variable;
+}
+
+static void round_up_float(u32 *variable, u8 variableSize) {
+ switch (variableSize) {
+ case sizeof(u64):
+ case sizeof(u32):
+ *variable = (u32) (*(f32*) &*variable);
+ break;
+ default:
+ sDisplayListState = BAD;
+ }
+}
+
+static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 base) {
+ s32 signedVariable;
+ u32 stringDifference, indexesToFillAVariable, stringLengthWithZero;
+ u32 indexesToFillAByte, upperIndex, remainder;
+ u32 stringLength, lowerIndex, i;
+ u8 variableSize;
+ char *bufferedString;
+ char swapRegister;
+
+ if (sDisplayListState == BAD) {
+ return;
+ }
+
+ bufferedString = attribute->characterBuffer;
+ variableSize = attribute->variableSize;
+
+ // converts a minus number into it's unsigned equivalent for proper string conversion
+ if (attribute->variableFlag & DISPLAY_SIGNED_NUMBER) {
+ switch (variableSize) {
+ case sizeof(u8):
+ signedVariable = (s8) variable;
+ if (signedVariable < 0) {
+ signedVariable = -signedVariable;
+ variable = (u8) signedVariable;
+ *bufferedString = '-';
+ bufferedString++;
+ }
+ break;
+ case sizeof(u16):
+ signedVariable = (s16) variable;
+ if (signedVariable < 0) {
+ signedVariable = -signedVariable;
+ variable = (u16) signedVariable;
+ *bufferedString = '-';
+ bufferedString++;
+ }
+ break;
+ case sizeof(u32):
+ case sizeof(u64):
+ signedVariable = (s32) variable;
+ if (signedVariable < 0) {
+ signedVariable = -signedVariable;
+ variable = (u32) signedVariable;
+ *bufferedString = '-';
+ bufferedString++;
+ }
+ break;
+ }
+ }
+
+ stringLength = 0;
+
+ // convert u64 into a string but it gets put in reverse
+ if (base != HEXIDECIMAL) {
+ do {
+ stringLength++;
+ *bufferedString = variable % base + '0';
+ bufferedString++;
+ variable /= base;
+ } while (variable != 0);
+ } else {
+ do {
+ stringLength++;
+ remainder = variable % 16;
+
+ if ((remainder >= 0) && (remainder <= 9)) {
+ *bufferedString = '0' + remainder;
+ } else {
+ *bufferedString = 'A' + (remainder - 10);
+ }
+
+ bufferedString++;
+ variable /= 16;
+ } while (variable != 0);
+ }
+
+ bufferedString -= stringLength;
+ upperIndex = stringLength - 1;
+
+ // flip string 4321 --> 1234
+ for (lowerIndex = 0; lowerIndex < stringLength >> 1; lowerIndex++) {
+ swapRegister = bufferedString[lowerIndex];
+ bufferedString[lowerIndex] = bufferedString[upperIndex];
+ bufferedString[upperIndex] = swapRegister;
+ upperIndex--;
+ }
+
+ switch (base) {
+ case BINARY:
+ indexesToFillAByte = 8;
+ break;
+ case OCTAL:
+ indexesToFillAByte = 3;
+ break;
+ case DECIMAL:
+ bufferedString[stringLength] = '\0';
+ return;
+ case HEXIDECIMAL:
+ indexesToFillAByte = 2;
+ break;
+ }
+
+ stringLengthWithZero = stringLength - 1;
+ indexesToFillAVariable = indexesToFillAByte * variableSize;
+ stringDifference = indexesToFillAVariable - stringLengthWithZero;
+
+ // makes space and fills in extra space. u32 FE -> 000000FE
+ for (i = stringLength; i > 0; i--) {
+ bufferedString[stringDifference + i - 2] = bufferedString[i - 1];
+ }
+ for (i = 0; i < stringDifference - 1; i++) {
+ bufferedString[i] = '0';
+ }
+ bufferedString[indexesToFillAVariable] = '\0';
+}
+
+static u32 _strlen(const char *str) {
+ u32 len;
+
+ len = 0;
+ for (; *str != '\0'; str++) {
+ len++;
+ }
+
+ return len;
+}
+
+// unused but may be useful
+static void _memcpy(char *destStr, const char *copyStr, u32 copySize) {
+ u32 i;
+
+ for (i = 0; i < copySize; i++) {
+ *destStr = *copyStr;
+ destStr++;
+ copyStr++;
+ }
+}
+
+#endif
diff --git a/src/debug/debug.inc.c b/src/debug/debug.inc.c
new file mode 100644
index 000000000..5b5950469
--- /dev/null
+++ b/src/debug/debug.inc.c
@@ -0,0 +1,58 @@
+#include <ultra64.h>
+#include <debug.h>
+#include "all_variables.h"
+
+#if DVDL
+
+extern s32 gGlobalTimer;
+
+/**
+ * Edit this to edit what displays on the screen while the DVDL is active.
+ * The Size of the structure array is calculated at compile time.
+ */
+variableWatchAttributes gMainVariableWatchList[] = {
+ {
+ "Global Timer: ",
+ &gGlobalTimer,
+ sizeof(gGlobalTimer),
+ DISPLAY_DECIMAL_NUMBER | DISPLAY_SIGNED_NUMBER,
+ 0, 0
+ },
+ {
+ "Actors: ",
+ &gNumActors,
+ sizeof(gNumActors),
+ DISPLAY_DECIMAL_NUMBER,
+ 0, 0
+ },
+ {
+ "Player Type: ",
+ &gPlayers[0].unk_000,
+ sizeof(gPlayerOne->unk_000),
+ DISPLAY_HEXIDECIMAL_NUMBER,
+ 0, 0
+ },
+ {
+ "X ",
+ &gPlayers[0].pos[0],
+ sizeof(gPlayerOne->pos[0]),
+ DISPLAY_FLOAT_NUMBER,
+ 0, 0
+ },
+ {
+ "Y ",
+ &gPlayers[0].pos[1],
+ sizeof(gPlayerOne->pos[1]),
+ DISPLAY_FLOAT_NUMBER,
+ 0, 0
+ },
+ {
+ "Z ",
+ &gPlayers[0].pos[2],
+ sizeof(gPlayerOne->pos[2]),
+ DISPLAY_FLOAT_NUMBER,
+ 0, 0
+ },
+};
+
+#endif
diff --git a/src/hud_renderer.c b/src/hud_renderer.c
index 0c2b5040e..cd5961a10 100644
--- a/src/hud_renderer.c
+++ b/src/hud_renderer.c
@@ -5202,7 +5202,7 @@ void func_80055164(s32 objectIndex) {
temp_a3->words.w1 = (u32) D_0D0077A0;
sp18 = temp_v1;
func_80042E00(temp_v1->unk_004, (s16 *) temp_v1->unk_0BE, temp_v1->unk_000);
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
sp18 = temp_v1;
temp_v1->unk_0A2 = func_80004DFC(temp_v1->unk_070, temp_v1->unk_074, 0, temp_v1->unk_0A2);
return;
@@ -5254,7 +5254,7 @@ void func_800552BC(s32 objectIndex) {
gDisplayListHead = temp_a0 + 8;
temp_a0->words.w0 = 0x06000000;
temp_a0->words.w1 = (u32) D_0D0077D0;
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
sp18 = temp_v1;
temp_v1->unk_0A2 = func_80004DFC(temp_v1->unk_070, temp_v1->unk_074, 0, temp_v1->unk_0A2);
return;
@@ -6198,8 +6198,8 @@ void func_80057778(void) {
gSPDisplayList(gDisplayListHead++, D_0D007EB8);
}
-void debug_print_str2(s32 arg0, s32 arg1, char *arg2) {
- debug_print_string(&arg0, &arg1, arg2);
+void debug_print_str2(s32 xPos, s32 yPos, char *str) {
+ debug_print_string(&xPos, &yPos, str);
}
void print_str_num(s32 arg0, s32 arg1, char *arg2, u32 arg3) {
diff --git a/src/main.c b/src/main.c
index 83d1ed21e..292480c85 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,7 +32,7 @@
#include "render_courses.h"
#include "actors.h"
#include "staff_ghosts.h"
-#include <defines.h>
+#include <debug.h>
// Declarations (not in this file)
void func_80091B78(void);
@@ -538,7 +538,7 @@ void race_logic_loop(void) {
D_80150112 = 0;
D_80164AF0 = 0;
- if (D_800DC5FC != 0) {
+ if (gIsGamePaused != 0) {
func_80290B14();
}
if (gIsInQuitToMenuTransition != 0) {
@@ -557,8 +557,7 @@ void race_logic_loop(void) {
case SCREEN_MODE_1P:
gTickSpeed = 2;
staff_ghosts_loop();
- if (D_800DC5FC == 0) {
-
+ if (gIsGamePaused == 0) {
for (i = 0; i < gTickSpeed; i++) {
if (D_8015011E) {
gCourseTimer += 0.01666666; // 1 / 60
@@ -623,7 +622,7 @@ void race_logic_loop(void) {
} else {
gTickSpeed = 2;
}
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
for (i = 0; i < gTickSpeed; i++) {
if (D_8015011E != 0) {
gCourseTimer += 0.01666666;
@@ -669,7 +668,7 @@ void race_logic_loop(void) {
gTickSpeed = 2;
}
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
for (i = 0; i < gTickSpeed; i++) {
if (D_8015011E != 0) {
gCourseTimer += 0.01666666;
@@ -737,7 +736,7 @@ void race_logic_loop(void) {
break;
}
}
- if (D_800DC5FC == 0) {
+ if (gIsGamePaused == 0) {
for (i = 0; i < gTickSpeed; i++) {
if (D_8015011E != 0) {
gCourseTimer += 0.01666666;
@@ -815,6 +814,9 @@ void race_logic_loop(void) {
func_802A4300();
func_800591B4();
func_80093E20();
+#if DVDL
+ display_dvdl();
+#endif
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
}
@@ -833,6 +835,20 @@ void race_logic_loop(void) {
*/
void game_state_handler(void) {
+#if DVDL
+ if ((gControllerOne->button & L_TRIG) &&
+ (gControllerOne->button & R_TRIG) &&
+ (gControllerOne->button & Z_TRIG) &&
+ (gControllerOne->button & A_BUTTON)) {
+ gGamestateNext = CREDITS_SEQUENCE;
+ } else if ((gControllerOne->button & L_TRIG) &&
+ (gControllerOne->button & R_TRIG) &&
+ (gControllerOne->button & Z_TRIG) &&
+ (gControllerOne->button & B_BUTTON)) {
+ gGamestateNext = ENDING_SEQUENCE;
+ }
+#endif
+
switch (gGamestate) {
case 7:
game_init_clear_framebuffer();
@@ -847,6 +863,9 @@ void game_state_handler(void) {
init_rcp();
// gGfxPool->mtxPool->m or gGfxPool?
func_80094A64((Mtx *) gGfxPool->mtxPool->m);
+#if DVDL
+ display_dvdl();
+#endif
break;
case RACING:
race_logic_loop();
diff --git a/src/main.h b/src/main.h
index 1bd5f0add..df1c0fb42 100644
--- a/src/main.h
+++ b/src/main.h
@@ -116,7 +116,7 @@ extern s16 gCurrentlyLoadedCourseId;
extern s16 gCurrentCourseId;
extern s16 D_80164AF0;
-extern u16 D_800DC5FC;
+extern u16 gIsGamePaused; // 1 if the game is paused and 0 if the game is not paused
extern u16 gIsInQuitToMenuTransition;
diff --git a/src/os/_Printf.c b/src/os/_Printf.c
index e42bf0428..0442e5fcc 100644
--- a/src/os/_Printf.c
+++ b/src/os/_Printf.c
@@ -3,6 +3,12 @@
#include <string.h>
#include "printf.h"
+#if DEBUG
+#define STATIC
+#else
+#define STATIC static
+#endif
+
#define ATOI(i, a) \
for (i = 0; *a >= '0' && *a <= '9'; a++) \
if (i < 999) \
@@ -31,7 +37,7 @@ const u32 flags_arr[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAG
char _spaces[] = " ";
char _zeroes[] = "00000000000000000000000000000000";
-static void _Putfld(printf_struct *, va_list *, u8, u8 *);
+STATIC void _Putfld(printf_struct *, va_list *, u8, u8 *);
s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char *fmt, va_list args) {
printf_struct sp78;
@@ -111,7 +117,7 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char
}
}
-static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
+STATIC void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
a0->part1_len = a0->num_leading_zeros = a0->part2_len = a0->num_mid_zeros = a0->part3_len =
a0->num_trailing_zeros = 0;
diff --git a/src/os/sprintf.c b/src/os/sprintf.c
index 57a7e99d4..8450fbc53 100644
--- a/src/os/sprintf.c
+++ b/src/os/sprintf.c
@@ -9,7 +9,7 @@ int sprintf(char *dst, const char *fmt, ...) {
s32 written;
va_list args;
va_start(args, fmt);
- written = _Putfld(proutSprintf, dst, fmt, args);
+ written = _Printf(proutSprintf, dst, fmt, args);
if (written >= 0) {
dst[written] = 0;
}
diff --git a/src/race_logic.c b/src/race_logic.c
index 0a7b5e3ef..c76d2f602 100644
--- a/src/race_logic.c
+++ b/src/race_logic.c
@@ -886,7 +886,7 @@ loop_2:
}
if ((temp_s0->buttonPressed & START_BUTTON) && (temp_v0_3 = temp_s0->button, ((temp_v0_3 & R_TRIG) == 0)) && !(temp_v0_3 & L_TRIG)) {
func_8028DF00();
- D_800DC5FC = ((s32) (temp_s0 - gControllerOne) >> 4) + 1;
+ gIsGamePaused = ((s32) (temp_s0 - gControllerOne) >> 4) + 1;
temp_s0->buttonPressed = 0;
func_800C9F90(1);
D_80162DF0 = 1;