summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcoco875 <59367621+coco875@users.noreply.github.com>2024-09-17 17:32:50 +0200
committerGitHub <noreply@github.com>2024-09-17 09:32:50 -0600
commit203090e5913f79df01ee273e40dea03b294f061e (patch)
tree2ee78c50742b20238c07610b8ba9f7f93c3a80e1 /src
parentd36d7dcd604d0f85b6b547a85e9b7a4fe3e59b5c (diff)
update with the decomp (#97)
* Update menus.c (#634) * Update common_data.yml (#635) * Renames for screenId and other changes (#636) * screenId renames * Rename surface map to collision mesh (#637) * Rename some stack vars (#638) * Fix syntax error (#639) * Rename some stack vars * Update collision.c * Collision Documentation (#640) * Collision related renames * update doxygen (#649) * change bool (#644) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Update (#642) * Delete trig_tables_bss.c (#650) * fix typo audio (#656) * fix typo src actor (#657) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo include (#658) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix course (#659) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo debug (#660) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo data (#661) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * replace number with const (#665) * fix typo buffers (#655) * fix typo buffers * tweak ld file * rename to sMemoryPool * add a warning --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo src (#654) * fix typo src * fix non matcing * Update code_80091750.c --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo racing (#653) * fix typo racing * get it match * replace G_LINE3D to G_QUAD --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo src (#652) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix ending typo (#651) * Action more info when it doesn't match and fix first diff (#662) * Update linux-compile.yml * fix first-diff * Update first-diff.py --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * document texture of kart (#663) * document texture of kart * change screenPlayerId to screenId * some documentation around object * Revert "some documentation around object" This reverts commit cbb39078e036bf2a417bed67359e910213acab28. * more rename --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Make evaluate_collision_players_palm_tree better (#667) This matches just the same as before, but using those two casts instead of shifts seems more likely to be accurate to the original source code Signed-off-by: Gabriel Ravier <gabravier@gmail.com> * add fedora instruciton (#666) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * start documenting animation (#668) * start documenting animation * Update course_data.c * change comment * update libultra asm (#648) * update libultra asm * fix gcc __osThreadTail --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Document Vehicles (#641) * start doc collision * fix merge * finish rename fonction related to vehicle * document around waypoint of vehicle * make some modification * make some change and rename one * copy_ to oldPos * doc smoke ferry and train * some rename * fix some renaming * precise index * rename a funciton * simplify waypoint_vehicles * change some name * change some name * rename move_to_point_direction * fix some conflict * Update code_80005FD0.c * Update code_80005FD0.h --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Label a save info loop (#645) * save info * more gcc progress * fix a value and do a rename (#669) * update clang and add action (#664) * update clang and add action * try clang on course folder only * forget two file * Update course_displaylists.inc.c * forget few other file * Update course_vertices.inc.c * format all code while get it match * second pass * format other dir * disable clang format on bad ido code * fix some tabulation * revert format on tool dir * Update clang-format.yml * ignore gbi.h * add some read me instruction * fix error * format and fixing error * Update README.md --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Update linkonly_generator.py (#670) * some rename for torch (#588) * rename gBombKartSpawns, and fix cup ID * Update doxygen_syms.md * rename for gCourseIndexInCup and his constant * rename to gCupSelectedCourseIndex * forget a change in constant * fix compilation issue * Update Dockerfile to latest Ubuntu LTS + fixed missing cmake (#674) * Fix color font matrix function (#676) * Fix label variables used in menus (#675) * Fix label variables used in menus * split D_800F2BDC and clang format menu.c --------- Co-authored-by: coco875 <pereira.jannin@gmail.com> * Fix some libultra struct types (#677) * Uintptr (#671) * Update render_courses.c * Update math_util.c * Update math_util.c * Update math_util.h * Update render_courses.c * Clang suggest (#678) * add clang suggestion * Update clang-format-suggest.yml * Update clang-format-suggest.yml * simplify * switch to ubuntu * Update clang-format-suggest.yml * update ubuntu --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Clang pr (#679) * Create clang-pr.yml * Update clang-pr.yml * Update osCreateMesgQueue.c * Update osCreateMesgQueue.c * Update clang-pr.yml * Update clang-pr.yml * Update clang-format.yml * clang format (#680) Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> * some rename in ceremony (#647) * rename ceremony * apply some suggestion * some rename --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * clang format (#681) Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> * Rename Object Timing Related Code (#673) * start making models extraction with blender * finishing extract model * Update fast64 * extract course * Update fast64 * Update fast64 * simplify import of course_displaylists and course_textures and remplace adress with texture * Update fast64 * change data format and simplify the thread queue * move in a blender folder * remove fast64 * re add fast64 * add model_extract and fast64_blender in makefile * multithread with make file split the models into multiple json and add course segment * Update fast64 * remove old model_extract * remove the error when he don't find blender * start rename around course section * rename around object * update submodule fast64 * fix compilation issue and add some model to extract * Update fast64 * remove fast64 * re add fast64 * update submodule * fix compilation issue * add other collision gfx and prepare reorganise file * re arrange json * Create README.MD * Update README.MD * Update README.MD * update fast64 * rename to initiate_next_state * Revert "Merge branch '3d-objects' into general-object" This reverts commit f5347b38cc75af4d10ee3726dc1524c1c71d6849, reversing changes made to a353c4d954fb5b50c8b48fe3f9d67c95ccaab299. * revert the revert... * revert 3d-models PR * finish some revert * Update code_80005FD0.c * fix code_80091750.c * Update code_80091750.c * rename isTimerRunning to isTimerActive and set_object_timer_running to set_object_timer_state * rename to initialize_next_state * rename to object_next_state --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * extract models with blender (#577) * start making models extraction with blender * finishing extract model * Update fast64 * extract course * Update fast64 * Update fast64 * simplify import of course_displaylists and course_textures and remplace adress with texture * Update fast64 * change data format and simplify the thread queue * move in a blender folder * remove fast64 * re add fast64 * add model_extract and fast64_blender in makefile * multithread with make file split the models into multiple json and add course segment * Update fast64 * remove old model_extract * remove the error when he don't find blender * start rename around course section * update submodule fast64 * fix compilation issue and add some model to extract * Update fast64 * remove fast64 * re add fast64 * update submodule * fix compilation issue * add other collision gfx and prepare reorganise file * re arrange json * Create README.MD * Update README.MD * Update README.MD * update fast64 --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * other * fix some error of compilation * finish fix all error --------- Signed-off-by: Gabriel Ravier <gabravier@gmail.com> Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> Co-authored-by: Gabriel Ravier <gabravier@gmail.com> Co-authored-by: MisterSheeple <27652712+MisterSheeple@users.noreply.github.com> Co-authored-by: AloXado320 <38191089+AloXado320@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/actors/falling_rock/update.inc.c16
-rw-r--r--src/audio/effects.h8
-rw-r--r--src/camera.h3
-rw-r--r--src/camera_junk.h4
-rw-r--r--src/code_800029B0.c2
-rw-r--r--src/code_80005FD0.c64
-rw-r--r--src/code_80005FD0.h2
-rw-r--r--src/code_80057C60.c4
-rw-r--r--src/code_8006E9C0.c2
-rw-r--r--src/code_80086E70.c20
-rw-r--r--src/code_80091440.c1
-rw-r--r--src/code_80091750.c141
-rw-r--r--src/code_80091750.h1
-rw-r--r--src/ending/camera_junk.c4
-rw-r--r--src/ending/ceremony_and_credits.c589
-rw-r--r--src/ending/ceremony_and_credits.h163
-rw-r--r--src/ending/code_80280000.c2
-rw-r--r--src/ending/code_80281780.c2
-rw-r--r--src/ending/code_80281C40.c2
-rw-r--r--src/ending/podium_ceremony_actors.c2
-rw-r--r--src/menus.c126
-rw-r--r--src/menus.h12
-rw-r--r--src/networking/start_game.c4
-rw-r--r--src/os/__osDequeueThread.c33
-rw-r--r--src/os/__osDevMgrMain.c4
-rw-r--r--src/os/__osLeoInterrupt.c2
-rw-r--r--src/os/__osViSwapContext.c6
-rw-r--r--src/os/controller.h4
-rw-r--r--src/os/leointerrupt.c185
-rw-r--r--src/os/libultra_internal.h16
-rw-r--r--src/os/osContInit.c66
-rw-r--r--src/os/osContInternal.h43
-rw-r--r--src/os/osContStartReadData.c87
-rw-r--r--src/os/osCreateMesgQueue.c5
-rw-r--r--src/os/osCreatePiManager.c4
-rw-r--r--src/os/osEepromRead.c6
-rw-r--r--src/os/osEepromWrite.c9
-rw-r--r--src/os/osViSwapBuffer.c2
-rw-r--r--src/racing/math_util.c2
-rw-r--r--src/racing/math_util.h3
-rw-r--r--src/racing/race_logic.c6
-rw-r--r--src/racing/render_courses.c87
-rw-r--r--src/render_objects.c6
-rw-r--r--src/save.c22
-rw-r--r--src/spawn_players.c6
-rw-r--r--src/textures.h4
-rw-r--r--src/update_objects.c652
-rw-r--r--src/update_objects.h6
48 files changed, 1178 insertions, 1262 deletions
diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c
index 9610c425d..c0e58f27d 100644
--- a/src/actors/falling_rock/update.inc.c
+++ b/src/actors/falling_rock/update.inc.c
@@ -4,8 +4,17 @@
#include <assets/choco_mountain_data.h>
void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
+#ifndef TARGET_N64
struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) LOAD_ASSET(spawnData);
+#else
+ s32 segment = SEGMENT_NUMBER2(spawnData);
+ s32 offset = SEGMENT_OFFSET(spawnData);
+ struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset);
+#endif
Vec3s sp24 = { 60, 120, 180 };
+#ifndef TARGET_N64
+ temp_v0 += rock->unk_06;
+#endif
rock->respawnTimer = sp24[rock->unk_06]; // * 2
rock->pos[0] = (f32) temp_v0[rock->unk_06].pos[0] * gCourseDirection;
rock->pos[1] = (f32) temp_v0[rock->unk_06].pos[1] + 10.0f;
@@ -21,7 +30,14 @@ void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
* @param spawnData
*/
void spawn_falling_rocks(struct ActorSpawnData* spawnData) {
+#ifndef TARGET_N64
struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) LOAD_ASSET(spawnData);
+#else
+ s32 addr = SEGMENT_NUMBER2(spawnData);
+ s32 offset = SEGMENT_OFFSET(spawnData);
+ // Casting this to prevent warning does not work.
+ struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset);
+#endif
struct FallingRock* temp_v1;
Vec3f startingPos;
Vec3f startingVelocity;
diff --git a/src/audio/effects.h b/src/audio/effects.h
index 738ff8bea..8c7712825 100644
--- a/src/audio/effects.h
+++ b/src/audio/effects.h
@@ -26,6 +26,14 @@
#define ADSR_GOTO -2
#define ADSR_RESTART -3
+// Envelopes are always stored as big endian, to match sequence files which are
+// byte blobs and can embed envelopes. Hence this byteswapping macro.
+#if IS_BIG_ENDIAN
+#define BSWAP16(x) (x)
+#else
+#define BSWAP16(x) (((x) & 0xff) << 8 | (((x) >> 8) & 0xff))
+#endif
+
void sequence_channel_process_sound(struct SequenceChannel* seqChannel, s32 recalculateVolume);
void sequence_player_process_sound(struct SequencePlayer* seqPlayer);
f32 get_portamento_freq_scale(struct Portamento* p);
diff --git a/src/camera.h b/src/camera.h
index 043804b15..299954594 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -57,9 +57,6 @@ typedef struct {
/* 0xB4 */ f32 unk_B4;
} Camera; /* size = 0xB8 */
-typedef BAD_RETURN(s32) (*CameraEvent)(Camera* c);
-typedef CameraEvent CutsceneShot;
-
void camera_init(f32, f32, f32, s16, u32, s32);
void func_8001CA10(Camera*);
void func_8001CA24(Player*, f32);
diff --git a/src/camera_junk.h b/src/camera_junk.h
index d1c9dd355..f8e26f5a1 100644
--- a/src/camera_junk.h
+++ b/src/camera_junk.h
@@ -3,8 +3,8 @@
/* Function Prototypes */
-void setup_camera_podium_ceremony(void);
-void func_802816B8(void);
+void update_camera_podium_ceremony(void);
+void init_camera_podium_ceremony(void);
// guPerspective params
diff --git a/src/code_800029B0.c b/src/code_800029B0.c
index 0cf1888b5..c319d3bef 100644
--- a/src/code_800029B0.c
+++ b/src/code_800029B0.c
@@ -188,7 +188,7 @@ void setup_race(void) {
gCourseDirection = 1.0f;
}
if (gModeSelection == GRAND_PRIX) {
- gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection];
+ gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup];
}
gActiveScreenMode = gScreenModeSelection;
if (gCurrentCourseId != gCurrentlyLoadedCourseId) {
diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c
index ffacdf4e4..669802699 100644
--- a/src/code_80005FD0.c
+++ b/src/code_80005FD0.c
@@ -2388,7 +2388,7 @@ s16 find_closest_waypoint_track_section(f32 posX, f32 posY, f32 posZ, u16 trackS
/**
* Tries to find the waypoint nearest to (posX, posY, posZ)
* Only consider waypoints in the same segment as trackSectionId
- * Only considers waypoints within 500 units of (posX, posY, posZ)
+ * Only considers waypoints within 500 units of(posX, posY, posZ)
* Looks 3 waypoints behind and 6 waypoints ahead of waypointIndex
**/
s16 func_8000C884(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex, u16 trackSectionId) {
@@ -2931,24 +2931,24 @@ void set_bomb_kart_spawn_positions(void) {
s32 var_s3;
TrackWaypoint* temp_v0;
UNUSED BombKart* var_s0;
- BombKartSpawn* temp_s1;
+ BombKartSpawn* bombKartSpawn;
for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) {
- temp_s1 = &gBombKartSpawns[gCurrentCourseId][var_s3];
+ bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3];
switch (gCurrentCourseId) {
case COURSE_YOSHI_VALLEY:
- startingXPos = temp_s1->startingXPos;
- startingZPos = temp_s1->startingZPos;
+ startingXPos = bombKartSpawn->startingXPos;
+ startingZPos = bombKartSpawn->startingZPos;
startingYPos = spawn_actor_on_surface(startingXPos, 2000.0f, startingZPos);
break;
case COURSE_AWARD_CEREMONY:
- temp_v0 = &D_80164550[3][temp_s1->waypointIndex];
+ temp_v0 = &D_80164550[3][bombKartSpawn->waypointIndex];
startingXPos = temp_v0->posX;
startingYPos = temp_v0->posY;
startingZPos = temp_v0->posZ;
break;
default:
- temp_v0 = &D_80164550[0][temp_s1->waypointIndex];
+ temp_v0 = &D_80164550[0][bombKartSpawn->waypointIndex];
startingXPos = temp_v0->posX;
startingYPos = temp_v0->posY;
startingZPos = temp_v0->posZ;
@@ -2969,11 +2969,11 @@ void set_bomb_kart_spawn_positions(void) {
gBombKarts[var_s3].wheel4Pos[0] = startingXPos;
gBombKarts[var_s3].wheel4Pos[1] = startingYPos;
gBombKarts[var_s3].wheel4Pos[2] = startingZPos;
- gBombKarts[var_s3].waypointIndex = temp_s1->waypointIndex;
- gBombKarts[var_s3].unk_3C = temp_s1->unk_04;
+ gBombKarts[var_s3].waypointIndex = bombKartSpawn->waypointIndex;
+ gBombKarts[var_s3].unk_3C = bombKartSpawn->unk_04;
gBombKarts[var_s3].bounceTimer = 0;
gBombKarts[var_s3].circleTimer = 0;
- gBombKarts[var_s3].state = temp_s1->startingState;
+ gBombKarts[var_s3].state = bombKartSpawn->startingState;
gBombKarts[var_s3].unk_4A = 0;
gBombKarts[var_s3].unk_4C = 1;
gBombKarts[var_s3].yPos = startingYPos;
@@ -5423,26 +5423,26 @@ void func_80014D30(s32 cameraId, s32 pathIndex) {
(f32) temp_v0->posZ);
}
-void func_80014DE4(s32 arg0) {
+void func_80014DE4(s32 cameraIndex) {
s32 cameraId;
D_801646CC = 0;
- D_80164678[arg0] = D_80164670[arg0];
- if ((gModeSelection != 1) && ((gCupCourseSelection == 0) || (gDemoMode == (u16) 1))) {
- D_80164678[arg0] = 0;
- } else if ((D_80164678[arg0] != 0) && (D_80164678[arg0] != (s16) 1) && (D_80164678[arg0] != 2) &&
- (D_80164678[arg0] != 3)) {
- D_80164678[arg0] = 0;
- }
- D_80164680[arg0] = -1;
+ D_80164678[cameraIndex] = D_80164670[cameraIndex];
+ if ((gModeSelection != 1) && ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == (u16) 1))) {
+ D_80164678[cameraIndex] = 0;
+ } else if ((D_80164678[cameraIndex] != 0) && (D_80164678[cameraIndex] != (s16) 1) &&
+ (D_80164678[cameraIndex] != 2) && (D_80164678[cameraIndex] != 3)) {
+ D_80164678[cameraIndex] = 0;
+ }
+ D_80164680[cameraIndex] = -1;
D_80163238 = 0;
- D_801646C0[arg0] = 0;
+ D_801646C0[cameraIndex] = 0;
D_801646C8 = 0;
- D_801646D0[arg0].unk0 = 0;
- D_801646D0[arg0].unk2 = 0;
- D_801646D0[arg0].unk4 = 0;
+ D_801646D0[cameraIndex].unk0 = 0;
+ D_801646D0[cameraIndex].unk2 = 0;
+ D_801646D0[cameraIndex].unk4 = 0;
if ((gModeSelection == 1) && (D_8018EDFC == 0)) {
- D_80164678[arg0] = 0;
+ D_80164678[cameraIndex] = 0;
}
for (cameraId = 0; cameraId < 4; cameraId++) {
@@ -5529,7 +5529,7 @@ f32 func_80014EE4(f32 arg0, s32 arg1) {
return arg0;
}
-void func_800151A4(Camera* camera, s32 arg1) {
+void calculate_camera_up_vector(Camera* camera, s32 cameraIndex) {
f32 xnorm;
f32 ynorm;
f32 znorm;
@@ -5540,7 +5540,7 @@ void func_800151A4(Camera* camera, s32 arg1) {
f32 sp28;
u16 thing;
- thing = D_801646C0[arg1];
+ thing = D_801646C0[cameraIndex];
if (thing == 0) {
camera->up[0] = 0.0f;
camera->up[2] = 0.0f;
@@ -6662,10 +6662,10 @@ void func_80019890(s32 playerId, s32 cameraId) {
}
}
-void func_80019B50(s32 arg0, u16 arg1) {
+void func_80019B50(s32 cameraIndex, u16 arg1) {
u16 var_v0;
- var_v0 = D_801646C0[arg0];
+ var_v0 = D_801646C0[cameraIndex];
if (var_v0 < arg1) {
if ((arg1 - var_v0) < 0x8000) {
var_v0 += 0x5A;
@@ -6689,10 +6689,10 @@ void func_80019B50(s32 arg0, u16 arg1) {
}
} else if ((var_v0 - arg1) >= 0x8000) {
var_v0 += 0x5A;
- if (!arg0) {} // wtf?
+ if (!cameraIndex) {} // wtf?
}
}
- D_801646C0[arg0] = (s16) var_v0;
+ D_801646C0[cameraIndex] = (s16) var_v0;
}
void func_80019C50(s32 arg0) {
@@ -6720,7 +6720,7 @@ void func_80019D2C(Camera* camera, Player* player, s32 arg2) {
playerId = camera->playerId;
if ((D_80163378 != 0) && (gCurrentCourseId == 8)) {
- func_800151A4(camera, arg2);
+ calculate_camera_up_vector(camera, arg2);
nearestWaypoint = gNearestWaypointByPlayerId[playerId];
if (((nearestWaypoint >= 0x65) && (nearestWaypoint < 0xFA)) ||
((nearestWaypoint >= 0x1AF) && (nearestWaypoint < 0x226))) {
@@ -6956,7 +6956,7 @@ void func_8001A588(UNUSED u16* localD_80152300, Camera* camera, Player* player,
func_80019D2C(camera, player, cameraIndex);
} else {
D_801646C0[cameraIndex] = 0;
- func_800151A4(camera, cameraIndex);
+ calculate_camera_up_vector(camera, cameraIndex);
}
switch ((u16) D_801646CC) {
case 1:
diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h
index eaa00e6f8..61dff3435 100644
--- a/src/code_80005FD0.h
+++ b/src/code_80005FD0.h
@@ -194,7 +194,7 @@ void func_80014D30(s32, s32);
void func_80014DE4(s32);
f32 func_80014EE4(f32, s32);
-void func_800151A4(Camera*, s32);
+void calculate_camera_up_vector(Camera*, s32);
void func_8001530C(void);
void func_80015314(s32, f32, s32);
void func_80015390(Camera*, Player*, s32);
diff --git a/src/code_80057C60.c b/src/code_80057C60.c
index c106c61cf..ceb0df519 100644
--- a/src/code_80057C60.c
+++ b/src/code_80057C60.c
@@ -6188,8 +6188,8 @@ void render_balloon(Vec3f arg0, f32 arg1, s16 arg2, s16 arg3) {
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gSPVertex(gDisplayListHead++, gBalloonVertexPlane1, 4, 0);
gSPDisplayList(gDisplayListHead++, common_square_plain_render);
- // D_8018D4C0 is correct. But interestingly, IDO seems to set "-0x40" to a different register so the texture
- // still looks fine.
+ // D_8018D4C0 is correct. But interestingly, IDO seems to set "-0x40" to a different register so the texture still
+ // looks fine.
gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C0 - 0x40, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0,
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOLOD);
diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c
index 68175fea1..baf4e1aa1 100644
--- a/src/code_8006E9C0.c
+++ b/src/code_8006E9C0.c
@@ -146,7 +146,7 @@ void init_item_window(s32 objectIndex) {
temp_v0 = (ItemWindowObjects*) &gObjectList[objectIndex];
temp_v0->currentItem = ITEM_NONE;
- temp_v0->itemDisplay = temp_v0->currentItem;
+ temp_v0->textureListIndex = temp_v0->currentItem;
temp_v0->tlutList = (u8*) common_tlut_item_window_none;
temp_v0->activeTLUT = (u8*) common_tlut_item_window_none;
temp_v0->textureList = common_texture_item_window_none;
diff --git a/src/code_80086E70.c b/src/code_80086E70.c
index e138aed68..6c94edee9 100644
--- a/src/code_80086E70.c
+++ b/src/code_80086E70.c
@@ -1507,7 +1507,7 @@ void func_8008A9B8(s32 objectIndex) {
object = &gObjectList[objectIndex];
object->controlPoints++;
object->unk_09A = (s16) (10000 / (s16) (object->controlPoints[0].velocity));
- object->timer = 0;
+ object->animationTimer = 0;
func_8008A920(objectIndex);
}
@@ -1516,7 +1516,7 @@ void func_8008AA3C(s32 objectIndex) {
object = &gObjectList[objectIndex];
object->controlPoints = object->spline->controlPoints;
object->unk_084[9] = 0;
- object->timer = 0;
+ object->animationTimer = 0;
/*
This is INCREDIBLY stupid. This should really be
temp_v0->unk_084[8] = temp_v0->spline->numControlPoints;
@@ -1539,8 +1539,8 @@ void func_8008AB10(s32 objectIndex) {
object->offset[0] += object->velocity[0];
object->offset[1] += object->velocity[1];
object->offset[2] += object->velocity[2];
- object->timer += (u16) object->unk_09A;
- if (object->timer >= 0x2710) {
+ object->animationTimer += (u16) object->unk_09A;
+ if (object->animationTimer >= 0x2710) {
object->unk_084[9] = (u16) object->unk_084[9] + 1;
if (((u16) object->unk_084[9] + 1) == (u16) object->unk_084[8]) {
object->unk_0AE += 1;
@@ -1734,7 +1734,7 @@ void func_8008B3E4(s32 objectIndex) {
if (is_obj_index_flag_status_inactive(objectIndex, 8) != 0) {
object = &gObjectList[objectIndex];
object->unk_084[9] = 0;
- object->timer = 0;
+ object->animationTimer = 0;
object->controlPoints = object->spline->controlPoints;
/*
This is INCREDIBLY stupid. This should really be
@@ -1748,7 +1748,7 @@ void func_8008B3E4(s32 objectIndex) {
}
void func_8008B44C(s32 objectIndex) {
- gObjectList[objectIndex].timer = 0;
+ gObjectList[objectIndex].animationTimer = 0;
gObjectList[objectIndex].controlPoints++;
}
@@ -1768,7 +1768,7 @@ void func_8008B478(s32 objectIndex, s32 arg1) {
// I think the game treats each spline as being having a lenght of 10000
// This is getting the percent along the spline we want to reach,
// which is then treated as the `t` value given to the curve calculations
- sp34 = ((f32) gObjectList[objectIndex].timer / 10000.0);
+ sp34 = ((f32) gObjectList[objectIndex].animationTimer / 10000.0);
// Calculate the curve at `t`
func_8008B17C(objectIndex, sp34);
if (is_obj_flag_status_active(objectIndex, 0x800) != 0) {
@@ -1781,7 +1781,7 @@ void func_8008B478(s32 objectIndex, s32 arg1) {
temp = gObjectList[objectIndex].controlPoints[1].velocity;
gObjectList[objectIndex].unk_09A = 10000.0 / (((temp - var_f6) * sp34) + var_f6);
- gObjectList[objectIndex].timer += gObjectList[objectIndex].unk_09A;
+ gObjectList[objectIndex].animationTimer += gObjectList[objectIndex].unk_09A;
}
void func_8008B620(s32 objectIndex) {
@@ -1790,7 +1790,7 @@ void func_8008B620(s32 objectIndex) {
func_8008B478(objectIndex, 0);
object = &gObjectList[objectIndex];
- if (object->timer >= 0x2710) {
+ if (object->animationTimer >= 0x2710) {
// Have to do it this way due to the u16 cast
object->unk_084[9] = (u16) object->unk_084[9] + 1;
if (((u16) object->unk_084[9] + 3) == (u16) object->unk_084[8]) {
@@ -1806,7 +1806,7 @@ void func_8008B6A4(s32 objectIndex) {
func_8008B478(objectIndex, 1);
object = &gObjectList[objectIndex];
- if (object->timer >= 0x2710) {
+ if (object->animationTimer >= 0x2710) {
// Have to do it this way due to the u16 cast
object->unk_084[9] = (u16) object->unk_084[9] + 1;
if ((u16) object->unk_084[9] == (u16) object->unk_084[8]) {
diff --git a/src/code_80091440.c b/src/code_80091440.c
index a69a53c0b..2b8b49aff 100644
--- a/src/code_80091440.c
+++ b/src/code_80091440.c
@@ -47,6 +47,7 @@ UNUSED void func_800914E0(void) {
camera->pos[1] = (f32) (tempData->pos[1] + 7);
camera->pos[2] = (f32) (tempData->pos[2] - 20);
camera->lookAt[0] = gPlayerOneCopy->pos[0];
+
camera->lookAt[1] = gPlayerOneCopy->pos[1];
camera->lookAt[2] = gPlayerOneCopy->pos[2];
check_bounding_collision(&camera->collision, 20.0f, camera->pos[0], camera->pos[1], camera->pos[2]);
diff --git a/src/code_80091750.c b/src/code_80091750.c
index f3ac52b55..734ad88c4 100644
--- a/src/code_80091750.c
+++ b/src/code_80091750.c
@@ -1256,7 +1256,7 @@ void func_80091EE4(void) {
tmp = func_800B5F30();
if ((D_8018EDFB != 0) && (tmp == 0)) {
- temp_s2 = (gCupSelection * 4) + gCupCourseSelection;
+ temp_s2 = (gCupSelection * 4) + gCourseIndexInCup;
func_800B6708();
for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) {
@@ -2547,17 +2547,30 @@ Gfx* func_800959F8(Gfx* displayListHead, Vtx* arg1) {
} else {
index = ((gTextColor * 2) + ((s32) gGlobalTimer % 2)) - 4;
}
- if (arg1 == &a_D_02007BB8[0]) {
+#ifdef AVOID_UB
+ if (arg1 == D_02007BB8) {
+ gSPDisplayList(displayListHead++, D_800E84CC[index]);
+ } else if (arg1 == &D_02007BB8[18]) {
+ gSPDisplayList(displayListHead++, D_800E84EC[index]);
+ } else if (arg1 == &D_02007BB8[36]) {
+ gSPDisplayList(displayListHead++, D_800E850C[index]);
+ }
+#else
+ if (arg1 == D_02007BB8) {
gSPDisplayList(displayListHead++, D_800E84CC[index]);
- } else if (arg1 == &a_D_02007BB8[18]) {
+ } else if (arg1 == D_02007CD8) {
gSPDisplayList(displayListHead++, D_800E84EC[index]);
- } else if (arg1 == &a_D_02007BB8[36]) {
+ } else if (arg1 == D_02007DF8) {
gSPDisplayList(displayListHead++, D_800E850C[index]);
}
+#endif
return displayListHead;
}
+#ifdef AVOID_UB
+#define MTX_TYPE Mtx
+#else
typedef struct {
u16 i[4][4];
u16 f[4][4];
@@ -2574,28 +2587,42 @@ typedef union {
s32 w;
} TheWhyUnion;
+#define MTX_TYPE Mtx2
+#endif
+
// Why... Why... Why... This function is so bad it's not going in the header.
-void func_80095AE0(Mtx2* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
+void func_80095AE0(MTX_TYPE* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
+#ifdef AVOID_UB
+ // Use Mat4 array to set matrix values using guMtxF2L. This helps little-endian systems.
+ Mat4 src;
+ src[0][0] = arg3;
+ src[0][1] = 0.0f;
+ src[0][2] = 0.0f;
+ src[0][3] = 0.0f;
+ src[1][0] = 0.0f;
+ src[1][1] = arg4;
+ src[1][2] = 0.0f;
+ src[1][3] = 0.0f;
+ src[2][0] = 0.0f;
+ src[2][1] = 0.0f;
+ src[2][2] = 1.0f;
+ src[2][3] = 0.0f;
+ src[3][0] = arg1;
+ src[3][1] = arg2;
+ src[3][2] = 0.0f;
+ src[3][3] = 1.0f;
+ guMtxF2L(src, arg0);
+#else
TheWhyUnion sp14;
TheWhyUnion sp10;
TheWhyUnion spC;
TheWhyUnion sp8;
s32 i;
-#ifdef AVOID_UB
- size_t row;
- size_t col;
- for (row = 0; row < 4; row++) {
- for (col = 0; col < 4; col++) {
- arg0->m[row][col] = 0;
- }
- }
-#else
// clang-format off
// should be inline
for(i = 0; i < 16; i++) { arg0->m[0][i] = 0; }
// clang-format on
-#endif
sp14.w = arg3 * 65536.0f;
sp10.w = arg4 * 65536.0f;
@@ -2611,8 +2638,11 @@ void func_80095AE0(Mtx2* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
arg0->u.f[1][1] = sp10.s[1];
arg0->u.f[3][0] = spC.s[1];
arg0->u.f[3][1] = sp8.s[1];
+#endif
}
+#undef MTX_TYPE
+
Gfx* func_80095BD0(Gfx* displayListHead, u8* arg1, f32 arg2, f32 arg3, u32 arg4, u32 arg5, f32 arg6, f32 arg7) {
Vtx* var_a1;
Mtx* sp28;
@@ -3342,11 +3372,6 @@ Gfx* draw_box(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 red,
return displayListHead;
}
-//! @todo Need to call this somewhere on func_800A2D1C
-Gfx* draw_box_fill_wide_wrap(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry) {
- return draw_box_fill_wide(displayListHead, ulx, uly, lrx, lry, 0, 0, 0, 0xFF);
-}
-
Gfx* func_80098FC8(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry) {
return draw_box_fill(displayListHead, ulx, uly, lrx, lry, 0, 0, 0, 0xFF);
}
@@ -3439,16 +3464,22 @@ void func_80099184(MkTexture* arg0) {
if (var_a1_2 % 8) {
var_a1_2 = ((var_a1_2 / 8) * 8) + 8;
}
- // dma_copy_base_729a30(var_s1->textureData, var_a1_2, D_8018D9B4);
- // mio0decode(D_8018D9B4, &D_8018D9B0[gD_8018E118TotalSize]);
- // size_t texSize = ResourceGetTexSizeByName(var_s1->textureData);
- // memcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData, texSize);
+// mio0decode(D_8018D9B4, &D_8018D9B0[gD_8018E118TotalSize]);
+// size_t texSize = ResourceGetTexSizeByName(var_s1->textureData);
+// memcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData, texSize);
+#ifdef TARGET_N64
+ dma_copy_base_729a30(var_s1->textureData, var_a1_2, D_8018D9B4);
+ mio0decode(D_8018D9B4, (u8*) &D_8018D9B0[gD_8018E118TotalSize]);
+#else
strcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData);
+#endif
} else {
- // dma_copy_base_729a30(var_s1->textureData, (var_s1->height * var_s1->width) * 2,
- // &D_8018D9B0[gD_8018E118TotalSize]); memcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData,
- // var_s1->width * var_s1->height*2);
+#ifdef TARGET_N64
+ dma_copy_base_729a30(var_s1->textureData, var_s1->height * var_s1->width * 2,
+ &D_8018D9B0[gD_8018E118TotalSize]);
+#else
strcpy(&D_8018D9B0[gD_8018E118TotalSize], var_s1->textureData);
+#endif
}
thing[gNumD_8018E118Entries].textureData = var_s1->textureData;
thing[gNumD_8018E118Entries].offset = gD_8018E118TotalSize;
@@ -4986,7 +5017,7 @@ void func_8009CE64(s32 arg0) {
}
gCupSelection = gCupSelectionByCourseId[gCurrentCourseId];
D_800DC540 = (s32) gCupSelection;
- gCupCourseSelection = (s8) gPerCupIndexByCourseId[gCurrentCourseId];
+ gCourseIndexInCup = (s8) gPerCupIndexByCourseId[gCurrentCourseId];
break;
case 3: /* switch 3 */
switch (gMenuSelection) {
@@ -5068,7 +5099,7 @@ void func_8009CE64(s32 arg0) {
}
gCupSelection = gCupSelectionByCourseId[gCurrentCourseId];
D_800DC540 = gCupSelection;
- gCupCourseSelection = gPerCupIndexByCourseId[gCurrentCourseId];
+ gCourseIndexInCup = gPerCupIndexByCourseId[gCurrentCourseId];
switch (gDebugGotoScene) { /* switch 6; irregular */
case 1: /* switch 6 */
break;
@@ -5779,7 +5810,7 @@ void add_8018D9E0_entry(s32 type, s32 column, s32 row, s8 priority) {
}
}
if ((var_ra->unk1C == 0) || (var_ra->unk20 != 0)) {
- func_800B559C((gCupSelection * 4) + gCupCourseSelection);
+ func_800B559C((gCupSelection * 4) + gCourseIndexInCup);
}
break;
case 0xE6:
@@ -6060,7 +6091,7 @@ void func_8009F5E0(struct_8018D9E0_entry* arg0) {
case 0x18: /* switch 6 */
case 0x19: /* switch 6 */
var_v1 = D_800E86B0[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
- var_a1 = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ var_a1 = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
switch (arg0->type) { /* switch 5 */
case 0x12: /* switch 5 */
case 0x13: /* switch 5 */
@@ -7200,7 +7231,7 @@ void func_800A2EB8(struct_8018D9E0_entry* arg0) {
func_80093324(arg0->column + 0x1E, arg0->row + 0x19, "results", 0, 1.0f, 1.0f);
set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2);
func_80093324(arg0->column + 0x2C, arg0->row + 0x28, "round", 0, 0.7f, 0.7f);
- convert_number_to_ascii(gCupCourseSelection + 1, sp68);
+ convert_number_to_ascii(gCourseIndexInCup + 1, sp68);
func_80093324(arg0->column + 0x57, arg0->row + 0x28, &sp68[1], 0, 0.7f, 0.7f);
for (var_s2 = 0; var_s2 < 4; var_s2++) {
if (gGPCurrentRacePlayerIdByRank[var_s2] < gPlayerCount) {
@@ -7279,7 +7310,7 @@ void func_800A34A8(struct_8018D9E0_entry* arg0) {
func_80093324(arg0->column + 0x19, 0x19 - arg0->row, "driver's points", 0, 0.8f, 0.8f);
set_text_color(5);
func_80093324(arg0->column + 0x36, 0x28 - arg0->row, "round", 0, 0.7f, 0.7f);
- convert_number_to_ascii(gCupCourseSelection + 1, sp78);
+ convert_number_to_ascii(gCourseIndexInCup + 1, sp78);
func_80093324(arg0->column + 0x61, (0x28 & 0xFFFFFFFF) - arg0->row, &sp78[1], 0, 0.7f, 0.7f);
for (rank = 0; rank < 4; rank++) {
test = arg0->cursor;
@@ -7412,8 +7443,8 @@ void func_800A3C84(struct_8018D9E0_entry* arg0) {
s32 rowOffset;
set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_1);
- draw_text(arg0->column + 0x43, arg0->row + 0x19,
- gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 0.6f, 0.6f);
+ draw_text(arg0->column + 0x43, arg0->row + 0x19, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]],
+ 0, 0.6f, 0.6f);
set_text_color(TEXT_YELLOW);
draw_text(arg0->column + 0x46, arg0->row + 0x28, D_800E7730, 0, 0.75f, 0.75f);
for (recordType = 0, rowOffset = 0; recordType < TIME_TRIAL_3LAP_RECORD_5; recordType += 1, rowOffset += 0xF) {
@@ -7452,8 +7483,8 @@ void func_800A3E60(struct_8018D9E0_entry* arg0) {
}
set_text_color(4);
- draw_text(arg0->column + 0x55, 0x19 - arg0->row,
- gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 0.6f, 0.6f);
+ draw_text(arg0->column + 0x55, 0x19 - arg0->row, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]],
+ 0, 0.6f, 0.6f);
set_text_color(3);
draw_text(arg0->column + 0x55, 0x28 - arg0->row, D_800E7730, 0, 0.75f, 0.75f);
for (var_s1 = 0; var_s1 < 4; var_s1++) {
@@ -7750,7 +7781,7 @@ void render_pause_menu_time_trials(struct_8018D9E0_entry* arg0) {
gDisplayListHead = draw_box(gDisplayListHead, 0, 0, 0x0000013F, 0x000000EF, 0, 0, 0, 0x0000008C);
set_text_color(TEXT_YELLOW);
- draw_text(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 1.0f,
+ draw_text(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0, 1.0f,
1.0f);
set_text_color(TEXT_RED);
draw_text(0x0000009D, 0x00000060, D_800E7728[0], 0, 0.8f, 0.8f);
@@ -7838,7 +7869,7 @@ void render_pause_grand_prix(struct_8018D9E0_entry* arg0) {
set_text_color(TEXT_YELLOW);
draw_text(160 + temp_s0, temp_s3->row - 50, D_800E76CC[gCCSelection], 0, 1.0f, 1.0f);
set_text_color(TEXT_YELLOW);
- draw_text(160, temp_s3->row - 30, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 1.0f,
+ draw_text(160, temp_s3->row - 30, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0, 1.0f,
1.0f);
for (var_s0 = 0; var_s0 < 2; var_s0++) {
text_rainbow_effect(arg0->cursor - 31, var_s0, TEXT_YELLOW);
@@ -7953,7 +7984,7 @@ void func_800A5738(struct_8018D9E0_entry* arg0) {
gDisplayListHead = draw_box(gDisplayListHead, 0, 0, 0x0000013F, 0x000000EF, 0, 0, 0, var_s1);
gDPSetPrimColor(gDisplayListHead++, 0, 0, 0x00, 0x00, 0x00, var_s2);
set_text_color(3);
- func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0,
+ func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0,
1.0f, 1.0f);
switch (arg0->cursor) { /* switch 1 */
case 1: /* switch 1 */
@@ -8996,7 +9027,7 @@ void func_800A8270(s32 arg0, struct_8018D9E0_entry* arg1) {
} else {
gDisplayListHead = func_80098FC8(gDisplayListHead, var_s3, var_s0, var_s4, var_s0 + 0x35);
}
- for (var_s0 += 0x41, var_s2 = 0; var_s2 <= D_800F2B60[0][arg0]; var_s2++, var_s0 += 0x12) {
+ for (var_s0 += 0x41, var_s2 = 0; var_s2 <= gPlayerModeSelection[arg0]; var_s2++, var_s0 += 0x12) {
if ((var_s2 == D_800E86AC[arg0]) && ((arg0 + 1) == gPlayerCount) && (gMainMenuSelectionDepth >= 4)) {
if (gMainMenuSelectionDepth == GAME_MODE_SELECTION) {
gDisplayListHead =
@@ -9126,8 +9157,8 @@ void func_800A8A98(struct_8018D9E0_entry* arg0) {
gDPPipeSync(gDisplayListHead++);
gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_DECALRGBA);
- for (someIndex = 0; someIndex < 4; someIndex++) {
- if ((someIndex == gCupCourseSelection) && (D_8018EDEC >= 2) && (gModeSelection != GRAND_PRIX)) {
+ for (someIndex = 0; someIndex < NUM_COURSES_PER_CUP; someIndex++) {
+ if ((someIndex == gCourseIndexInCup) && (D_8018EDEC >= 2) && (gModeSelection != GRAND_PRIX)) {
if ((D_8018EDEC == 2) || (D_8018EDEC == 4)) {
gDisplayListHead = draw_flash_select_case_slow(
gDisplayListHead, D_800E7208[someIndex][0].column + temp_s2, D_800E7208[someIndex][0].row + temp_s3,
@@ -9213,7 +9244,7 @@ void func_800A8F48(UNUSED struct_8018D9E0_entry* arg0) {
break;
case 2:
default:
- if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) >= 0) {
+ if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) >= 0) {
gDisplayListHead = func_80098FC8(gDisplayListHead, 0x00000057, 0x00000070, 0x00000096, 0x00000081);
gDisplayListHead = func_8009BA74(gDisplayListHead, D_02004A0C, 0x00000057, 0x00000070);
}
@@ -9673,7 +9704,7 @@ void func_800A9E58(struct_8018D9E0_entry* arg0) {
break;
}
- temp_a1 = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ temp_a1 = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
switch (arg0->cursor) { /* switch 5; irregular */
case 0: /* switch 5 */
if ((temp_a1 != sp20) && (temp_a1 != sp1C)) {
@@ -10403,7 +10434,7 @@ void func_800AB314(struct_8018D9E0_entry* arg0) {
arg0->cursor = 0;
arg0->unk20 = 0;
for (var_a1 = 0; var_a1 < 4; var_a1++) {
- if (gCupCourseSelection == var_a1) {
+ if (gCourseIndexInCup == var_a1) {
sp24[var_a1]->visible = one;
if (arg0->unk1C != var_a1) {
arg0->unk1C = var_a1;
@@ -10906,7 +10937,7 @@ void func_800AC458(struct_8018D9E0_entry* arg0) {
if (arg0->unk1C <= 0) {
arg0->cursor = 0x0000000A;
arg0->unk1C = 0;
- if (gCupCourseSelection == 3) {
+ if (gCourseIndexInCup == 3) {
for (var_a1 = 0; var_a1 < 8; var_a1++) {
if (D_80164478[gCharacterIdByGPOverallRank[var_a1]] < gPlayerCount) {
func_800B536C(var_a1);
@@ -11305,7 +11336,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) {
break;
case 0: /* switch 4 */
func_800B6708();
- arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x11;
+ arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x11;
var_v1 = 1;
play_sound2(SOUND_MENU_SELECT);
break;
@@ -11352,7 +11383,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) {
if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8*) gGameName,
(u8*) gExtCode, &gControllerPak1FileNote) == 0) {
func_800B6708();
- arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x11;
+ arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x11;
play_sound2(SOUND_MENU_SELECT);
return;
}
@@ -11402,7 +11433,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) {
case 17: /* switch 1 */
case 18: /* switch 1 */
arg0->unk20 = arg0->cursor - 0x11;
- if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) != arg0->unk20) {
+ if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->unk20) {
if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) {
if (arg0->cursor >= 0x12) {
arg0->cursor--;
@@ -11709,7 +11740,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) {
break;
case PFS_NO_ERROR: /* switch 3 */
func_800B6708();
- arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x1E;
+ arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x1E;
var_v1 = 1;
break;
case PFS_ERR_NEW_PACK: /* switch 3 */
@@ -11758,7 +11789,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) {
if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8*) gGameName,
(u8*) gExtCode, &gControllerPak1FileNote) == 0) {
func_800B6708();
- arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x1E;
+ arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x1E;
play_sound2(SOUND_MENU_SELECT);
return;
}
@@ -11804,7 +11835,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) {
case 30: /* switch 1 */
case 31: /* switch 1 */
arg0->unk20 = (u32) arg0->cursor - 0x1E;
- if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) != arg0->unk20) {
+ if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->unk20) {
if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) {
if (arg0->cursor >= 0x1F) {
arg0->cursor--;
@@ -12127,14 +12158,14 @@ void func_800AF270(struct_8018D9E0_entry* arg0) {
if (D_802874D8.unk1D >= 3) {
arg0->cursor = 4;
func_800CA0B8();
- func_800C90F4(0U, (sp30 * 0x10) + 0x29008003);
+ func_800C90F4(0U, (sp30 * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x03));
func_800CA0A0();
} else {
arg0->cursor = 3;
func_8009A640(arg0->D_8018DEE0_index, 0, sp30,
segmented_to_virtual_dupe_2(gCharacterCelebrateAnimation[temp_v0]));
func_800CA0B8();
- func_800C90F4(0U, (sp30 * 0x10) + 0x29008007);
+ func_800C90F4(0U, (sp30 * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x07));
func_800CA0A0();
}
}
diff --git a/src/code_80091750.h b/src/code_80091750.h
index 277fa36d5..01c4ca8ee 100644
--- a/src/code_80091750.h
+++ b/src/code_80091750.h
@@ -400,6 +400,7 @@ void func_800AF740(struct_8018D9E0_entry*);
// This really, really shouldn't be in this header file, but I don't know where else to put it
void rmonPrintf(const char*, ...);
+void tkmk00decode(u8*, u8*, u8*, s32);
/* File specific defines */
diff --git a/src/ending/camera_junk.c b/src/ending/camera_junk.c
index 4cbe14c31..7edb587a7 100644
--- a/src/ending/camera_junk.c
+++ b/src/ending/camera_junk.c
@@ -8,7 +8,7 @@
#include "ceremony_and_credits.h"
#include "main.h"
-void setup_camera_podium_ceremony(void) {
+void update_camera_podium_ceremony(void) {
Camera* camera;
f32 x_dist;
f32 y_dist;
@@ -26,7 +26,7 @@ void setup_camera_podium_ceremony(void) {
}
// GP podium ceremony camera settings?
-void func_802816B8(void) {
+void init_camera_podium_ceremony(void) {
cameras[0].pos[0] = -3133.0f;
cameras[0].pos[1] = 19.0f;
cameras[0].pos[2] = -467.0f;
diff --git a/src/ending/ceremony_and_credits.c b/src/ending/ceremony_and_credits.c
index 2eacf12a5..8af800cae 100644
--- a/src/ending/ceremony_and_credits.c
+++ b/src/ending/ceremony_and_credits.c
@@ -24,9 +24,9 @@
f32 D_802856B0 = 98.0f;
f32 D_802856B4 = 12.0f;
-f32 D_802856B8 = 52.0f;
+f32 gOrderedSizeSlidingBorders = 52.0f;
f32 D_802856BC = 52.0f;
-f32 D_802856C0 = 0.0f;
+f32 gSizeSlidingBorders = 0.0f;
s32 D_802856C4 = 0;
s32 D_802856C8[3] = { 0 }; // padding?
@@ -37,7 +37,7 @@ s32 D_802876D4;
s32 D_802876D8;
s32 D_802876DC; // fake/padding? Or D8 is array?
-struct CinematicCamera D_802876E0;
+CinematicCamera D_802876E0;
struct struct_80283431 D_80287750[10];
struct struct_80283430 D_80287818[32];
struct struct_80283430 D_80287998[32];
@@ -84,7 +84,7 @@ void func_80282040(void) {
void func_80282048(void) {
}
-UNUSED void func_80282050(Vec3f dest, Vec3f src, s16 angle) {
+UNUSED void rotate_y_vec3f(Vec3f dest, Vec3f src, s16 angle) {
Vec3f sp2C;
vec3f_copy_return_dupe(sp2C, src);
@@ -93,7 +93,7 @@ UNUSED void func_80282050(Vec3f dest, Vec3f src, s16 angle) {
dest[2] = (sp2C[2] * coss(angle)) - (sp2C[0] * sins(angle));
}
-UNUSED void func_802820F8(Vec3f dest, Vec3f src, s16 angle) {
+UNUSED void rotate_x_vec3f(Vec3f dest, Vec3f src, s16 angle) {
Vec3f sp2C;
vec3f_copy_return_dupe(sp2C, src);
@@ -120,80 +120,80 @@ s32 f32_lerp(f32* dest, f32 src, f32 lerp) {
return 1;
}
-UNUSED s32 func_80282200(Vec3s arg0, s16 arg1, s16 arg2) {
- s16 temp_v0 = *arg0;
+UNUSED bool ease_out_transition(s16* var, s16 dest, s16 speed_factor) {
+ s16 temp_v0 = *var;
- if (arg2 == 0) {
- arg0[0] = arg1;
+ if (speed_factor == 0) {
+ *var = dest;
} else {
- temp_v0 -= arg1;
- temp_v0 -= (temp_v0 / arg2);
- temp_v0 += arg1;
- arg0[0] = temp_v0;
+ temp_v0 -= dest;
+ temp_v0 -= (temp_v0 / speed_factor);
+ temp_v0 += dest;
+ *var = temp_v0;
}
- if (arg1 == arg0[0]) {
- return 0;
+ if (dest == *var) {
+ return false;
}
- return 1;
+ return true;
}
// Calculates fade in/out
-s32 set_transition_colour_fade_alpha_ending(f32* arg0, f32 arg1, f32 arg2) {
- f32 temp_f0 = arg1 - *arg0;
+bool adjust_f32_value_transition(f32* var, f32 dest, f32 speed_factor) {
+ f32 temp_f0 = dest - *var;
- if (arg2 < 0.0f) {
- arg2 = -1.0f * arg2;
+ if (speed_factor < 0.0f) {
+ speed_factor = -1.0f * speed_factor;
}
if (temp_f0 > 0.0f) {
- temp_f0 -= arg2;
+ temp_f0 -= speed_factor;
if (temp_f0 > 0.0f) {
- *arg0 = arg1 - temp_f0;
+ *var = dest - temp_f0;
} else {
- *arg0 = arg1;
+ *var = dest;
}
} else {
- temp_f0 += arg2;
+ temp_f0 += speed_factor;
if (temp_f0 < 0.0f) {
- *arg0 = arg1 - temp_f0;
+ *var = dest - temp_f0;
} else {
- *arg0 = arg1;
+ *var = dest;
}
}
- if (arg1 == *arg0) {
- return 0;
+ if (dest == *var) {
+ return false;
}
- return 1;
+ return true;
}
-s32 func_80282364(s16* arg0, s16 arg1, s16 arg2) {
- s16 temp_v0 = arg1 - *arg0;
+bool adjust_s16_value_transition(s16* var, s16 goal, s16 speed_factor) {
+ s16 temp_v0 = goal - *var;
- if (arg2 < 0) {
- arg2 = arg2 * -1;
+ if (speed_factor < 0) {
+ speed_factor = speed_factor * -1;
}
if (temp_v0 > 0) {
- temp_v0 -= arg2;
+ temp_v0 -= speed_factor;
if (temp_v0 >= 0) {
- *arg0 = arg1 - temp_v0;
+ *var = goal - temp_v0;
} else {
- *arg0 = arg1;
+ *var = goal;
}
} else {
- temp_v0 += arg2;
+ temp_v0 += speed_factor;
if (temp_v0 <= 0) {
- *arg0 = arg1 - temp_v0;
+ *var = goal - temp_v0;
} else {
- *arg0 = arg1;
+ *var = goal;
}
}
- if (arg1 == *arg0) {
- return 0;
+ if (goal == *var) {
+ return false;
}
- return 1;
+ return true;
}
void reset_spline(void) {
@@ -203,30 +203,30 @@ void reset_spline(void) {
D_80287B20 = 0;
}
-void func_80282434(UNUSED struct CinematicCamera* arg0) {
+void reset_spline_wrap(UNUSED CinematicCamera* arg0) {
reset_spline();
}
-void func_80282454(Vec3f arg0, Vec3f arg1, f32* distance, s16* arg3, s16* arg4) {
+void calculate_distance_angle_y_and_angle_y_to_xz(Vec3f vec1, Vec3f vec2, f32* distance, s16* angleYToXZ, s16* angleY) {
f32 xdist;
f32 ydist;
f32 zdist;
- xdist = arg1[0] - arg0[0];
- ydist = arg1[1] - arg0[1];
- zdist = arg1[2] - arg0[2];
+ xdist = vec2[0] - vec1[0];
+ ydist = vec2[1] - vec1[1];
+ zdist = vec2[2] - vec1[2];
*distance = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist));
- *arg3 = atan2s(ydist, sqrtf((xdist * xdist) + (zdist * zdist)));
- *arg4 = atan2s(xdist, zdist);
+ *angleYToXZ = atan2s(ydist, sqrtf((xdist * xdist) + (zdist * zdist)));
+ *angleY = atan2s(xdist, zdist);
}
-void func_80282504(Vec3f arg0, Vec3f arg1, f32 arg2, s16 arg3, s16 arg4) {
- arg1[0] = arg0[0] + (arg2 * coss(arg3) * sins(arg4));
- arg1[1] = arg0[1] + (arg2 * sins(arg3));
- arg1[2] = arg0[2] + (arg2 * coss(arg3) * coss(arg4));
+void apply_distance_angle_y_and_angle_y_to_xz(Vec3f vec1, Vec3f vec2, f32 coef, s16 angleYToXZ, s16 angleY) {
+ vec2[0] = vec1[0] + (coef * coss(angleYToXZ) * sins(angleY));
+ vec2[1] = vec1[1] + (coef * sins(angleYToXZ));
+ vec2[2] = vec1[2] + (coef * coss(angleYToXZ) * coss(angleY));
}
-UNUSED void func_802825C8(Vec3f arg0, Vec3f arg1, Vec3f arg2, Vec3s arg3) {
+UNUSED void aborting_cinematic_function(Vec3f arg0, Vec3f arg1, Vec3f arg2, Vec3s arg3) {
Vec3f sp3C;
Vec3f sp30;
@@ -240,8 +240,8 @@ UNUSED void func_802825C8(Vec3f arg0, Vec3f arg1, Vec3f arg2, Vec3s arg3) {
arg0[2] = arg1[2] + (sp30[2] * coss(arg3[1])) - (sp30[0] * sins(arg3[1]));
}
-// evaluate_cubic_spline
-void func_80282700(f32 arg0, Vec3f arg1, f32* arg2, f32 arg3[], f32 arg4[], f32 arg5[], f32 arg6[]) {
+void evaluate_cubic_spline(f32 arg0, Vec3f point, f32* arg2, f32 controlPoints1[], f32 controlPoints2[],
+ f32 controlPoints3[], f32 controlPoints4[]) {
f32 B[4];
if (arg0 > 1.0f) {
@@ -252,10 +252,13 @@ void func_80282700(f32 arg0, Vec3f arg1, f32* arg2, f32 arg3[], f32 arg4[], f32
B[2] = ((((((-arg0) * arg0) * arg0) / 2.0f) + ((arg0 * arg0) / 2.0f)) + (arg0 / 2.0f)) + 0.16666667f;
B[3] = ((arg0 * arg0) * arg0) / 6.0f;
- arg1[0] = B[0] * arg3[0] + B[1] * arg4[0] + B[2] * arg5[0] + B[3] * arg6[0];
- arg1[1] = B[0] * arg3[1] + B[1] * arg4[1] + B[2] * arg5[1] + B[3] * arg6[1];
- arg1[2] = B[0] * arg3[2] + B[1] * arg4[2] + B[2] * arg5[2] + B[3] * arg6[2];
- *arg2 = B[0] * arg3[3] + B[1] * arg4[3] + B[2] * arg5[3] + B[3] * arg6[3];
+ point[0] =
+ B[0] * controlPoints1[0] + B[1] * controlPoints2[0] + B[2] * controlPoints3[0] + B[3] * controlPoints4[0];
+ point[1] =
+ B[0] * controlPoints1[1] + B[1] * controlPoints2[1] + B[2] * controlPoints3[1] + B[3] * controlPoints4[1];
+ point[2] =
+ B[0] * controlPoints1[2] + B[1] * controlPoints2[2] + B[2] * controlPoints3[2] + B[3] * controlPoints4[2];
+ *arg2 = B[0] * controlPoints1[3] + B[1] * controlPoints2[3] + B[2] * controlPoints3[3] + B[3] * controlPoints4[3];
}
/**
@@ -279,7 +282,8 @@ void func_80282700(f32 arg0, Vec3f arg1, f32* arg2, f32 arg3[], f32 arg4[], f32
* @return 1 if the point has reached the end of the spline, when `progress` reaches 1.0 or greater, and
* the 4th CutsceneSplinePoint in the current segment away from spline[splineSegment] has an index of -1.
*/
-s32 move_point_along_spline(Vec3f p, f32* arg1, struct struct_80283430 spline[], s16* splineSegment, f32* progress) {
+s32 move_point_along_spline(Vec3f point, f32* arg1, struct struct_80283430 spline[], s16* splineSegment,
+ f32* progress) {
s32 finished = 0;
Mat4 controlPoints;
s32 i = 0;
@@ -304,7 +308,7 @@ s32 move_point_along_spline(Vec3f p, f32* arg1, struct struct_80283430 spline[],
controlPoints[i][3] = spline[segment + i].unk4 * 256.0f;
}
- func_80282700(u, p, arg1, controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3]);
+ evaluate_cubic_spline(u, point, arg1, controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3]);
if (spline[*splineSegment + 1].unk2 != 0) {
firstSpeed = 1.0f / spline[*splineSegment + 1].unk2;
@@ -372,12 +376,11 @@ void func_80282C40(struct struct_80283430* arg0, struct struct_80282C40* arg1, s
}
}
-//! @todo Cast to normal Camera? Or from CinematicCamera?
-s32 func_80282D90(struct CinematicCamera* camera, struct struct_80286A04* arg1, struct struct_80286A04* arg2,
- s32 arg3) {
+s32 move_cinematic_camera_along_spline(CinematicCamera* camera, struct struct_80286A04* arg1,
+ struct struct_80286A04* arg2, s32 arg3) {
s32 res;
- cutscene_event((CameraEvent) func_80282434, camera, 0, 0);
+ cutscene_event(reset_spline_wrap, camera, 0, 0);
func_80282C40(D_80287818, (struct struct_80282C40*) arg1, arg3);
func_80282C40(D_80287998, (struct struct_80282C40*) arg2, arg3);
@@ -390,13 +393,13 @@ s32 func_80282D90(struct CinematicCamera* camera, struct struct_80286A04* arg1,
return res;
}
-void func_80282E58(struct CinematicCamera* camera, struct struct_80282C40* arg1, s32 arg2) {
+void func_80282E58(CinematicCamera* camera, struct struct_80282C40* arg1, s32 arg2) {
func_80282C40(D_80287818, arg1, arg2);
move_point_along_spline(camera->lookAt, &camera->unk18, D_80287818, &sCutsceneSplineSegment,
&sCutsceneSplineSegmentProgress);
}
-void func_80282EAC(s32 arg0, struct CinematicCamera* arg1, s16 arg2, s16 arg3, s16 arg4) {
+void func_80282EAC(s32 arg0, CinematicCamera* arg1, s16 arg2, s16 arg3, s16 arg4) {
if ((arg0 >= 0) && (arg0 < 3)) {
if (arg1->unk48[arg0] < arg2) {
arg1->unk48[arg0] = arg2;
@@ -414,10 +417,10 @@ void func_80282F00(s16* arg0, s16 arg1) {
*arg0 += arg1;
}
-void func_80282F44(s32 arg0, struct CinematicCamera* arg1, Camera* camera) {
- f32 sp5C;
+void func_80282F44(s32 arg0, CinematicCamera* arg1, Camera* camera) {
+ f32 distance;
UNUSED s32 pad[2];
- s16 sp50[2];
+ s16 angleCam[2];
Vec3f pos;
Vec3f lookat;
@@ -425,13 +428,13 @@ void func_80282F44(s32 arg0, struct CinematicCamera* arg1, Camera* camera) {
vec3f_set_dupe(lookat, camera->lookAt[0], camera->lookAt[1], camera->lookAt[2]);
if ((arg0 == 0) || (arg0 == 1)) {
if ((arg1->unk48[0] != 0) || (arg1->unk48[1] != 0)) {
- func_80282454(pos, lookat, &sp5C, &sp50[0], &sp50[1]);
- sp50[arg0] += (((f32) arg1->unk48[arg0]) * sins(arg1->unk4E[arg0]));
- if ((sp50[0] < 0x3800) && (sp50[0] >= -0x37FF)) {
- func_80282504(pos, lookat, sp5C, sp50[0], sp50[1]);
+ calculate_distance_angle_y_and_angle_y_to_xz(pos, lookat, &distance, &angleCam[0], &angleCam[1]);
+ angleCam[arg0] += (((f32) arg1->unk48[arg0]) * sins(arg1->unk4E[arg0]));
+ if ((angleCam[0] < 0x3800) && (angleCam[0] >= -0x37FF)) {
+ apply_distance_angle_y_and_angle_y_to_xz(pos, lookat, distance, angleCam[0], angleCam[1]);
}
func_80282F00(&arg1->unk4E[arg0], arg1->unk54[arg0]);
- if (func_80282364(&arg1->unk48[arg0], 0, arg1->unk5A[arg0]) == 0) {
+ if (adjust_s16_value_transition(&arg1->unk48[arg0], 0, arg1->unk5A[arg0]) == false) {
arg1->unk4E[arg0] = 0;
}
}
@@ -441,7 +444,7 @@ void func_80282F44(s32 arg0, struct CinematicCamera* arg1, Camera* camera) {
}
}
-void func_802830B4(struct CinematicCamera* arg0, s16 arg1, s16 arg2, s16 arg3) {
+void func_802830B4(CinematicCamera* arg0, s16 arg1, s16 arg2, s16 arg3) {
if (arg0->unk60 < arg1) {
arg0->unk60 = arg1;
arg0->unk6C = arg2;
@@ -449,11 +452,11 @@ void func_802830B4(struct CinematicCamera* arg0, s16 arg1, s16 arg2, s16 arg3) {
}
}
-void func_80283100(struct CinematicCamera* arg0, f32* arg1) {
+void func_80283100(CinematicCamera* arg0, f32* arg1) {
if (arg0->unk60 != 0) {
arg0->unk6E = (coss((u16) arg0->unk64) * arg0->unk60) / 256;
arg0->unk64 += arg0->unk68;
- func_80282364(&arg0->unk60, 0, arg0->unk6C);
+ adjust_s16_value_transition(&arg0->unk60, 0, arg0->unk6C);
} else {
arg0->unk64 = 0.0f;
}
@@ -472,10 +475,10 @@ void func_80283240(s16 arg0) {
* Call the event while `start` <= gCutsceneShotTimer <= `end`
* If `end` is -1, call for the rest of the shot.
*/
-s32 cutscene_event(CameraEvent event, struct CinematicCamera* camera, s16 start, s16 end) {
+s32 cutscene_event(CameraEvent event, CinematicCamera* camera, s16 start, s16 end) {
if (gCutsceneShotTimer >= start) {
if ((end == -1) || (end >= gCutsceneShotTimer)) {
- event((Camera*) camera);
+ event(camera);
}
}
return 0;
@@ -494,7 +497,7 @@ s32 func_80283330(s32 arg0) {
extern s32 D_802876D8;
//! @todo Does this match as a return of s8?
-s32 func_8028336C(UNUSED struct CinematicCamera* arg0, UNUSED Camera* camera) {
+s32 func_8028336C(UNUSED CinematicCamera* arg0, UNUSED Camera* camera) {
u8 sp20[] = { 2, 3, 4, 5, 5, 5, 5, 5 };
if (D_802876D8 != 0) {
return D_802876D8;
@@ -515,13 +518,13 @@ s32 func_8028336C(UNUSED struct CinematicCamera* arg0, UNUSED Camera* camera) {
return D_802876D8;
}
-s32 func_80283428(void) {
+s32 cinematic_stub(void) {
return 0;
}
void init_cinematic_camera(void) {
s32 i;
- struct CinematicCamera* camera = &D_802876E0;
+ CinematicCamera* camera = &D_802876E0;
D_802876D8 = 0;
camera->cutscene = 0;
@@ -557,140 +560,143 @@ void init_cinematic_camera(void) {
vec3s_clear(D_80287750[i].unkC);
}
- D_802856C0 = 0.0f;
+ gSizeSlidingBorders = 0.0f;
if (gGamestate == ENDING) {
D_802856B0 = 120.0f;
D_802856B4 = 12.0f;
- D_802856B8 = 120.0f;
+ gOrderedSizeSlidingBorders = 120.0f;
} else {
D_802856B0 = 98.0f;
D_802856B4 = 12.0f;
- D_802856B8 = 52.0f;
+ gOrderedSizeSlidingBorders = 52.0f;
}
}
+// weird link between camera and cinematic camera where pos and lookAt are swapped
s32 func_80283648(Camera* camera) {
- s16 sp6E;
- s16 sp6C;
+ s16 angleYToXZ;
+ s16 angleY;
f32 var_f2;
- f32 sp64;
- Vec3f sp58;
- Vec3f sp4C;
- Vec3f sp40;
- struct CinematicCamera* new_var = &D_802876E0;
-
- func_80283428();
- vec3f_copy_return_dupe(sp58, camera->pos);
- vec3f_copy_return_dupe(sp4C, camera->lookAt);
- vec3f_copy_return_dupe(sp40, camera->up);
- new_var->cutscene = func_8028336C(new_var, camera);
- if (new_var->cutscene != 0) {
- vec3f_copy_return_dupe(new_var->lookAt, camera->pos);
- vec3f_copy_return_dupe(new_var->pos, camera->lookAt);
- play_cutscene(new_var);
- func_80282454(new_var->lookAt, new_var->pos, &sp64, &sp6E, &sp6C);
- if (sp6E >= 0x3800) {
- sp6E = 0x3800;
+ f32 distance;
+ Vec3f pos;
+ Vec3f lookAt;
+ Vec3f up;
+ CinematicCamera* cinematicCamera = &D_802876E0;
+
+ cinematic_stub();
+ vec3f_copy_return_dupe(pos, camera->pos);
+ vec3f_copy_return_dupe(lookAt, camera->lookAt);
+ vec3f_copy_return_dupe(up, camera->up);
+ cinematicCamera->cutscene = func_8028336C(cinematicCamera, camera);
+ if (cinematicCamera->cutscene != 0) {
+ vec3f_copy_return_dupe(cinematicCamera->lookAt, camera->pos);
+ vec3f_copy_return_dupe(cinematicCamera->pos, camera->lookAt);
+ play_cutscene(cinematicCamera);
+ calculate_distance_angle_y_and_angle_y_to_xz(cinematicCamera->lookAt, cinematicCamera->pos, &distance,
+ &angleYToXZ, &angleY);
+ if (angleYToXZ >= 0x3800) {
+ angleYToXZ = 0x3800;
}
- if (sp6E < -0x37FF) {
- sp6E = -0x3800;
+ if (angleYToXZ < -0x37FF) {
+ angleYToXZ = -0x3800;
}
- if ((sp6E == 0x3800) || (sp6E == -0x3800)) {
- func_80282504(new_var->lookAt, new_var->pos, sp64, sp6E, sp6C);
+ if ((angleYToXZ == 0x3800) || (angleYToXZ == -0x3800)) {
+ apply_distance_angle_y_and_angle_y_to_xz(cinematicCamera->lookAt, cinematicCamera->pos, distance,
+ angleYToXZ, angleY);
}
- if (new_var->unk18 > 65536.0f) {
- new_var->unk18 -= 65536.0f;
+ if (cinematicCamera->unk18 > 65536.0f) {
+ cinematicCamera->unk18 -= 65536.0f;
}
- if (new_var->unk18 < -65536.0f) {
- new_var->unk18 += 65536.0f;
+ if (cinematicCamera->unk18 < -65536.0f) {
+ cinematicCamera->unk18 += 65536.0f;
}
// Huh?
if (1) {
- var_f2 = new_var->unk18;
+ var_f2 = cinematicCamera->unk18;
}
if (var_f2 < 0.0f) {
var_f2 = 65536.0f + var_f2;
}
- camera->up[0] = sins(var_f2) * coss(sp6C);
+ camera->up[0] = sins(var_f2) * coss(angleY);
camera->up[1] = coss(var_f2);
- camera->up[2] = -sins(var_f2) * sins(sp6C);
- vec3f_copy_return_dupe(camera->pos, new_var->lookAt);
- vec3f_copy_return_dupe(camera->lookAt, new_var->pos);
+ camera->up[2] = -sins(var_f2) * sins(angleY);
+ vec3f_copy_return_dupe(camera->pos, cinematicCamera->lookAt);
+ vec3f_copy_return_dupe(camera->lookAt, cinematicCamera->pos);
if ((gGamestate == CREDITS_SEQUENCE) && (gIsMirrorMode != 0)) {
camera->pos[0] = -camera->pos[0];
camera->lookAt[0] = -camera->lookAt[0];
}
}
- func_80282F44(0, new_var, camera);
- func_80282F44(1, new_var, camera);
- func_80283100(new_var, gCameraZoom);
- vec3f_copy_return_dupe(new_var->unk30, camera->pos);
- vec3f_copy_return_dupe(new_var->unk24, camera->lookAt);
- vec3f_copy_return_dupe(new_var->unk3C, camera->up);
+ func_80282F44(0, cinematicCamera, camera);
+ func_80282F44(1, cinematicCamera, camera);
+ func_80283100(cinematicCamera, gCameraZoom);
+ vec3f_copy_return_dupe(cinematicCamera->unk30, camera->pos);
+ vec3f_copy_return_dupe(cinematicCamera->unk24, camera->lookAt);
+ vec3f_copy_return_dupe(cinematicCamera->unk3C, camera->up);
return D_802876D8;
}
-void func_80283968(UNUSED struct CinematicCamera* camera) {
+void wrap_func_8028100C(UNUSED CinematicCamera* camera) {
func_8028100C(-0xC6C, 0xD2, -0x1EF);
}
-void func_80283994(UNUSED struct CinematicCamera* camera) {
+void wrap_func_80280FFC(UNUSED CinematicCamera* camera) {
func_80280FFC();
}
-void func_802839B4(UNUSED struct CinematicCamera* camera) {
- D_802856B8 = 52.0f;
+void animation_apears_sliding_borders(UNUSED CinematicCamera* camera) {
+ gOrderedSizeSlidingBorders = 52.0f;
}
-void func_802839CC(UNUSED struct CinematicCamera* camera) {
- D_802856B8 = 0.0f;
+void animation_disapears_sliding_borders(UNUSED CinematicCamera* camera) {
+ gOrderedSizeSlidingBorders = 0.0f;
}
-void func_802839E0(UNUSED struct CinematicCamera* camera) {
+void wrap_func_80092C80(UNUSED CinematicCamera* camera) {
func_80092C80();
}
/**
* Played at beginning of credits.
*/
-void play_sound_welcome(UNUSED struct CinematicCamera* camera) {
+void play_sound_welcome(UNUSED CinematicCamera* camera) {
if (D_800DC5E4 == 0) {
play_sound2(SOUND_INTRO_WELCOME);
}
}
-void func_80283A34(UNUSED struct CinematicCamera* camera) {
+void wrap_func_800CA0CC(UNUSED CinematicCamera* camera) {
func_800CA0CC();
}
/**
* Played after receiving trophy.
*/
-void play_sound_congratulation(UNUSED struct CinematicCamera* camera) {
+void play_sound_congratulation(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_CONGRATULATION);
}
/**
* Played in ceremony opening with balloons.
*/
-void play_sound_balloon_pop(UNUSED struct CinematicCamera* camera) {
+void play_sound_balloon_pop(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_BALLOON_POP);
}
-void play_sound_fish(UNUSED struct CinematicCamera* camera) {
+void play_sound_fish(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_FISH);
}
-void play_sound_fish_2(UNUSED struct CinematicCamera* camera) {
+void play_sound_fish_2(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_FISH_2);
}
-void play_sound_shoot_trophy(UNUSED struct CinematicCamera* camera) {
+void play_sound_shoot_trophy(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_SHOOT_TROPHY);
}
-void play_sound_podium(UNUSED struct CinematicCamera* camera) {
+void play_sound_podium(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_PODIUM);
}
@@ -698,50 +704,50 @@ void play_sound_podium(UNUSED struct CinematicCamera* camera) {
* Played in background nearly the entire ceremony
* Begins again or plays louder once the trophy appears.
*/
-void play_sound_trophy(UNUSED struct CinematicCamera* camera) {
+void play_sound_trophy(UNUSED CinematicCamera* camera) {
play_sound2(SOUND_CEREMONY_TROPHY);
}
-void func_80283B6C(UNUSED struct CinematicCamera* camera) {
+void func_80283B6C(UNUSED CinematicCamera* camera) {
func_800CA0B8();
func_800C9060(0, SOUND_ACTION_EXPLOSION);
func_800CA0A0();
}
-void func_80283BA4(UNUSED struct CinematicCamera* camera) {
+void func_80283BA4(UNUSED CinematicCamera* camera) {
func_800CA0B8();
- func_800C90F4(0, (gPlayerFour->characterId * 0x10) + 0x29008004);
+ func_800C90F4(0, (gPlayerFour->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x04));
func_800CA0A0();
}
-void func_80283BF0(UNUSED struct CinematicCamera* camera) {
+void func_80283BF0(UNUSED CinematicCamera* camera) {
func_800C8EF8(0x1A);
}
//
-void func_80283C14(UNUSED struct CinematicCamera* camera) {
+void func_80283C14(UNUSED CinematicCamera* camera) {
func_800C8EF8(0x1B);
}
-void func_80283C38(UNUSED struct CinematicCamera* camera) {
+void wrap_func_800CB134(UNUSED CinematicCamera* camera) {
func_800CB134();
}
-void func_80283C58(UNUSED struct CinematicCamera* camera) {
+void wrap_func_800CB14C(UNUSED CinematicCamera* camera) {
func_800CB14C();
}
-void func_80283C78(UNUSED struct CinematicCamera* arg0) {
+void func_80283C78(UNUSED CinematicCamera* arg0) {
if (D_800DC5E4 == 0) {
func_800C8EF8(0x1C);
}
}
-void func_80283CA8(UNUSED struct CinematicCamera* camera) {
+void func_80283CA8(UNUSED CinematicCamera* camera) {
func_800CA008(0, 3);
}
-void func_80283CD0(UNUSED struct CinematicCamera* camera) {
+void func_80283CD0(UNUSED CinematicCamera* camera) {
if (D_800DC5E4 == 0) {
func_800CA008(0, 2);
}
@@ -751,11 +757,11 @@ void func_80283CD0(UNUSED struct CinematicCamera* camera) {
* End of credits farewell.
* "Hey, you're very good. See you next time!"
*/
-void play_sound_farewell(UNUSED struct CinematicCamera* arg0) {
+void play_sound_farewell(UNUSED CinematicCamera* arg0) {
play_sound2(SOUND_CREDITS_FAREWELL);
}
-// Camera rail spline animation
+//! Camera rail spline animation
struct struct_80282C40 D_802856DC[] = {
// go to
{ 0, 0, 0, 0, 0, 0, { 0xF576, 0x014E, 0xFE70 } }, { 0, 0, 0, 0, 0, 0, { 0xF576, 0x014E, 0xFE70 } },
@@ -763,12 +769,20 @@ struct struct_80282C40 D_802856DC[] = {
{ -1, 0, 0, 0, 0, 0, { 0xF3E8, 0x0016, 0xFE34 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285718[] = {
{ 0, 0, 0, 61, 0, 0, { 0xF493, 0x0309, 0xFE4E } }, { 0, 0, 0, 149, 0, 0, { 0xF494, 0x030A, 0xFE4E } },
{ 0, 0, 0, 94, 0, 0, { 0xF243, 0x0179, 0xFDF0 } }, { 0, 0, 0, 60, 0, 0, { 0xF213, 0x00B1, 0xFDE9 } },
{ -1, 0, 0, 60, 0, 0, { 0xF213, 0x008D, 0xFDE9 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285754[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF4F4, 0xFFE2, 0xFF67 } },
{ 0, 0, 0, 0, 0, 0, { 0xF51A, 0x0002, 0xFF5D } },
@@ -776,6 +790,10 @@ struct struct_80282C40 D_80285754[] = {
{ -1, 0, 0, 0, 0, 0, { 0xF608, 0x0065, 0xFFE4 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285784[] = {
{ 0, 0, 0, 186, 0, 0, { 0xF33E, 0x0009, 0x0053 } },
{ 0, 0, 0, 89, 0, 0, { 0xF329, 0xFFA4, 0xFF8F } },
@@ -783,17 +801,29 @@ struct struct_80282C40 D_80285784[] = {
{ -1, 0, 0, 45, 0, 0, { 0xF44A, 0x00BE, 0xFF16 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802857B4[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF22C, 0xFFF4, 0x0067 } },
{ -1, 0, 0, 0, 0, 0, { 0xF22C, 0xFFF4, 0x0067 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802857CC[] = {
{ 0, 0, 0, 90, 0, 0, { 0xF3F8, 0xFFDB, 0xFC39 } },
{ 0, 0, 0, 90, 0, 0, { 0xF419, 0xFFF8, 0xFC3B } },
{ -1, 0, 0, 101, 0, 0, { 0xF454, 0x000E, 0xFBFF } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802857F0[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF208, 0x004F, 0xFDC9 } }, { 0, 0, 0, 0, 0, 0, { 0xF20F, 0x004E, 0xFDCB } },
{ 0, 0, 0, 0, 0, 0, { 0xF23D, 0x0049, 0xFDDC } }, { 0, 0, 0, 0, 0, 0, { 0xF284, 0x0044, 0xFDEF } },
@@ -801,6 +831,10 @@ struct struct_80282C40 D_802857F0[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF303, 0x0039, 0xFE0A } }, { -1, 0, 0, 0, 0, 0, { 0xF325, 0x0033, 0xFE11 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285850[] = {
{ 0, 0, 0, 30, 0, 0, { 0xF3D7, 0x0004, 0xFE77 } }, { 0, 0, 0, 30, 0, 0, { 0xF3E3, 0x000C, 0xFE6F } },
{ 0, 0, 0, 50, 0, 0, { 0xF421, 0x001E, 0xFE53 } }, { 0, 0, 0, 50, 0, 0, { 0xF468, 0x001C, 0xFE69 } },
@@ -808,31 +842,55 @@ struct struct_80282C40 D_80285850[] = {
{ 0, 0, 0, 30, 0, 0, { 0xF4E3, 0xFFE1, 0xFE76 } }, { -1, 0, 0, 30, 0, 0, { 0xF505, 0xFFD1, 0xFE72 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802858B0[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF42B, 0x002D, 0xFE46 } },
{ -1, 0, 0, 0, 0, 0, { 0xF42B, 0x002D, 0xFE46 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802858C8[] = {
{ 0, 0, 0, 30, 0, 0, { 0xF246, 0x0073, 0xFDE7 } },
{ -1, 0, 0, 30, 0, 0, { 0xF246, 0x0073, 0xFDE7 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802858E0[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF39F, 0x003C, 0xFE2F } },
{ -1, 0, 0, 0, 0, 0, { 0xF39F, 0x003C, 0xFE2F } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_802858F8[] = {
{ 0, 0, 0, 1, 0, 0, { 0xF245, 0x0187, 0xFDA1 } },
{ -1, 0, 0, 1, 0, 0, { 0xF245, 0x0187, 0xFDA1 } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285910[] = {
{ 0, 0, 0, 0, 0, 0, { 0xF4A0, 0x00B7, 0xFF6C } },
{ -1, 0, 0, 0, 0, 0, { 0xF4A0, 0x00B7, 0xFF6C } },
};
+/**
+ * @brief spline animation
+ *
+ */
struct struct_80282C40 D_80285928[] = {
{ 0, 0, 0, 6, 0, 0, { 0xF340, 0x0025, 0xFE28 } },
{ -1, 0, 0, 6, 0, 0, { 0xF340, 0x0025, 0xFE28 } },
@@ -858,61 +916,63 @@ struct struct_80282C40 D_80285940[] = {
{ 0xFF, 0x00, 0x00, 0x1E, 0x00, 0x00, { 0xF1E0, 0x000C, 0xFE71 } },
};
-void func_80283D2C(struct CinematicCamera* camera) {
- D_802856B8 = 120.0f;
- cutscene_event((CameraEvent) &func_80283CA8, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80283A34, camera, 1, 1);
- cutscene_event((CameraEvent) &func_80283BF0, camera, 0, 0);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 45, 45);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 65, 65);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 70, 70);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 94, 94);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 110, 110);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 130, 130);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 152, 152);
- cutscene_event((CameraEvent) &play_sound_balloon_pop, camera, 160, 160);
- cutscene_event((CameraEvent) &func_80283994, camera, D_80285D10[0].duration - 60, D_80285D10[0].duration - 60);
- func_80282D90(camera, (struct struct_80286A04*) D_802856DC, (struct struct_80286A04*) D_80285718, 0);
-}
-
-void func_80283EA0(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_80285754, (struct struct_80286A04*) D_80285784, 0);
-}
-
-void func_80283ED0(struct CinematicCamera* camera) {
+void func_80283D2C(CinematicCamera* camera) {
+ gOrderedSizeSlidingBorders = 120.0f;
+ cutscene_event(func_80283CA8, camera, 0, 0);
+ cutscene_event(wrap_func_800CA0CC, camera, 1, 1);
+ cutscene_event(func_80283BF0, camera, 0, 0);
+ cutscene_event(play_sound_balloon_pop, camera, 45, 45);
+ cutscene_event(play_sound_balloon_pop, camera, 65, 65);
+ cutscene_event(play_sound_balloon_pop, camera, 70, 70);
+ cutscene_event(play_sound_balloon_pop, camera, 94, 94);
+ cutscene_event(play_sound_balloon_pop, camera, 110, 110);
+ cutscene_event(play_sound_balloon_pop, camera, 130, 130);
+ cutscene_event(play_sound_balloon_pop, camera, 152, 152);
+ cutscene_event(play_sound_balloon_pop, camera, 160, 160);
+ cutscene_event(wrap_func_80280FFC, camera, gCutScene[0].duration - 60, gCutScene[0].duration - 60);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_802856DC,
+ (struct struct_80286A04*) D_80285718, 0);
+}
+
+void func_80283EA0(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285754,
+ (struct struct_80286A04*) D_80285784, 0);
+}
+
+void copy_player_two_in_camera(CinematicCamera* camera) {
vec3f_copy_return_dupe(camera->pos, gPlayerTwo->pos);
}
-void func_80283EF8(struct CinematicCamera* camera) {
+void lerp_player_two_in_camera(CinematicCamera* camera) {
f32_lerp(&camera->pos[0], gPlayerTwo->pos[0], 0.12f);
f32_lerp(&camera->pos[1], gPlayerTwo->pos[1], 0.12f);
f32_lerp(&camera->pos[2], gPlayerTwo->pos[2], 0.12f);
}
-void func_80283F6C(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &func_80283ED0, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80283EF8, camera, 0, -1);
+void func_80283F6C(CinematicCamera* camera) {
+ cutscene_event(copy_player_two_in_camera, camera, 0, 0);
+ cutscene_event(lerp_player_two_in_camera, camera, 0, -1);
func_80282E58(camera, (struct struct_80282C40*) D_802857B4, 0);
}
-void func_80283FCC(struct CinematicCamera* camera) {
+void copy_player_three_in_camera(CinematicCamera* camera) {
vec3f_copy_return_dupe(camera->pos, gPlayerThree->pos);
}
-void func_80283FF4(struct CinematicCamera* camera) {
+void lerp_player_three_in_camera(CinematicCamera* camera) {
f32_lerp(&camera->pos[0], gPlayerThree->pos[0], 0.12f);
f32_lerp(&camera->pos[1], gPlayerThree->pos[1], 0.12f);
f32_lerp(&camera->pos[2], gPlayerThree->pos[2], 0.12f);
}
-void func_80284068(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &func_80283FCC, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80283FF4, camera, 0, -1);
+void func_80284068(CinematicCamera* camera) {
+ cutscene_event(copy_player_three_in_camera, camera, 0, 0);
+ cutscene_event(lerp_player_three_in_camera, camera, 0, -1);
func_80282E58(camera, (struct struct_80282C40*) D_802857CC, 0);
}
-void func_802840C8(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &func_80283C14, camera, 5, 5);
+void func_802840C8(CinematicCamera* camera) {
+ cutscene_event(func_80283C14, camera, 5, 5);
switch (D_802876D8) {
case 2:
@@ -927,45 +987,49 @@ void func_802840C8(struct CinematicCamera* camera) {
}
}
-void func_80284154(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_80285910, (struct struct_80286A04*) D_80285928, 0);
+void func_80284154(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285910,
+ (struct struct_80286A04*) D_80285928, 0);
}
-void func_80284184(struct CinematicCamera* camera) {
+void func_80284184(CinematicCamera* camera) {
f32 trophy;
trophy = ((gObjectList[indexObjectList1[3]].pos[1] - camera->lookAt[1]) * 0.9f) + camera->lookAt[1];
f32_lerp(&camera->pos[1], trophy, 0.5);
}
-void func_802841E8(struct CinematicCamera* camera) {
+void func_802841E8(CinematicCamera* camera) {
func_80282E58(camera, (struct struct_80282C40*) D_80285940, 0);
vec3f_set_dupe(camera->pos, -3202.0f, 90.0f, -478.0f);
}
-void func_8028422C(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &play_sound_shoot_trophy, camera, 6, 6);
- cutscene_event((CameraEvent) &play_sound_trophy, camera, 30, 30);
- cutscene_event((CameraEvent) &func_802841E8, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80284184, camera, 6, -1);
+void func_8028422C(CinematicCamera* camera) {
+ cutscene_event(play_sound_shoot_trophy, camera, 6, 6);
+ cutscene_event(play_sound_trophy, camera, 30, 30);
+ cutscene_event(func_802841E8, camera, 0, 0);
+ cutscene_event(func_80284184, camera, 6, -1);
}
-void func_802842A8(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_802858B0, (struct struct_80286A04*) D_802858C8, 0);
+void func_802842A8(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_802858B0,
+ (struct struct_80286A04*) D_802858C8, 0);
}
-void func_802842D8(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_802857F0, (struct struct_80286A04*) D_80285850, 0);
+void func_802842D8(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_802857F0,
+ (struct struct_80286A04*) D_80285850, 0);
}
-void func_80284308(struct CinematicCamera* camera) {
+void func_80284308(CinematicCamera* camera) {
Player** sp30[4] = { &gPlayerOne, &gPlayerTwo, &gPlayerThree, &gPlayerFour };
Player* ply;
f32 x;
f32 y;
f32 z;
- cutscene_event((CameraEvent) play_sound_congratulation, camera, 140, 140);
- func_80282D90(camera, (struct struct_80286A04*) D_802858E0, (struct struct_80286A04*) D_802858F8, 0);
+ cutscene_event(play_sound_congratulation, camera, 140, 140);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_802858E0,
+ (struct struct_80286A04*) D_802858F8, 0);
ply = *(sp30[0] + D_802874D8.unk1D);
@@ -1090,64 +1154,71 @@ struct struct_80282C40 D_80285CE0[] = {
{ 0xFF, 0x00, 0x00, 0x19, 0x00, 0x00, { 0xF3E1, 0xFF47, 0x00A2 } },
};
-struct Cutscene D_80285D10[] = {
+struct Cutscene gCutScene[] = {
{ func_80283D2C, 330 }, { func_802840C8, 270 }, { func_802842D8, 247 },
{ func_80284418, 200 }, { func_80284494, 170 }, { func_802844FC, 108 },
{ func_8028422C, 140 }, { func_802842A8, 270 }, { func_80284308, 0x7FFF },
};
-void func_80284418(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &play_sound_podium, camera, 0x52, 0x52);
- cutscene_event((CameraEvent) &play_sound_podium, camera, 0x48, 0x48);
- cutscene_event((CameraEvent) &play_sound_podium, camera, 0x3D, 0x3D);
- func_80282D90(camera, (struct struct_80286A04*) D_80285A10, (struct struct_80286A04*) D_80285A4C, 0);
+void func_80284418(CinematicCamera* camera) {
+ cutscene_event(play_sound_podium, camera, 0x52, 0x52);
+ cutscene_event(play_sound_podium, camera, 0x48, 0x48);
+ cutscene_event(play_sound_podium, camera, 0x3D, 0x3D);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285A10,
+ (struct struct_80286A04*) D_80285A4C, 0);
}
-void func_80284494(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &play_sound_fish_2, camera, 0x1E, 0x1E);
- cutscene_event((CameraEvent) &func_80283968, camera, 0, 0);
- func_80282D90(camera, (struct struct_80286A04*) D_80285A88, (struct struct_80286A04*) D_80285AB8, 0);
+void func_80284494(CinematicCamera* camera) {
+ cutscene_event(play_sound_fish_2, camera, 0x1E, 0x1E);
+ cutscene_event(wrap_func_8028100C, camera, 0, 0);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285A88,
+ (struct struct_80286A04*) D_80285AB8, 0);
}
-void func_802844FC(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &play_sound_fish, camera, 0x3B, 0x3B);
- func_80282D90(camera, (struct struct_80286A04*) D_80285AE8, (struct struct_80286A04*) D_80285B00, 0);
+void func_802844FC(CinematicCamera* camera) {
+ cutscene_event(play_sound_fish, camera, 0x3B, 0x3B);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285AE8,
+ (struct struct_80286A04*) D_80285B00, 0);
}
-void func_8028454C(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &func_80283CA8, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80283A34, camera, 1, 1);
- cutscene_event((CameraEvent) &func_80283C38, camera, 0, 0);
- cutscene_event((CameraEvent) &func_80283994, camera, 0x3C, 0x3C);
- func_80282D90(camera, (struct struct_80286A04*) D_80285B18, (struct struct_80286A04*) D_80285B54, 0);
+void func_8028454C(CinematicCamera* camera) {
+ cutscene_event(func_80283CA8, camera, 0, 0);
+ cutscene_event(wrap_func_800CA0CC, camera, 1, 1);
+ cutscene_event(wrap_func_800CB134, camera, 0, 0);
+ cutscene_event(wrap_func_80280FFC, camera, 0x3C, 0x3C);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285B18,
+ (struct struct_80286A04*) D_80285B54, 0);
}
-void func_802845EC(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_80285B90, (struct struct_80286A04*) D_80285BA8, 0);
+void func_802845EC(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285B90,
+ (struct struct_80286A04*) D_80285BA8, 0);
}
-void func_8028461C(struct CinematicCamera* camera) {
+void func_8028461C(CinematicCamera* camera) {
func_80283240(1);
func_80283B6C(camera);
}
-void func_80284648(struct CinematicCamera* camera) {
- cutscene_event((CameraEvent) &func_802845EC, camera, 0, 0);
- cutscene_event((CameraEvent) &func_8028461C, camera, 0x110, 0x110);
- cutscene_event((CameraEvent) &func_80283BA4, camera, 0x115, 0x115);
+void func_80284648(CinematicCamera* camera) {
+ cutscene_event(func_802845EC, camera, 0, 0);
+ cutscene_event(func_8028461C, camera, 0x110, 0x110);
+ cutscene_event(func_80283BA4, camera, 0x115, 0x115);
}
UNUSED void func_802846AC(void) {
}
-void func_802846B4(struct CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_80285C38, (struct struct_80286A04*) D_80285C74, 0);
+void func_802846B4(CinematicCamera* camera) {
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285C38,
+ (struct struct_80286A04*) D_80285C74, 0);
}
//! @todo What does this even do?
-void func_802846E4(struct CinematicCamera* camera) {
+void func_802846E4(CinematicCamera* camera) {
- func_80282D90(camera, (struct struct_80286A04*) D_80285CB0, (struct struct_80286A04*) D_80285CE0, 0);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80285CB0,
+ (struct struct_80286A04*) D_80285CE0, 0);
camera->lookAt[0] += (gPlayerFour->pos[0] - -2796.0f); // <-- rodata
camera->lookAt[1] += (gPlayerFour->pos[1] - -29.0f);
camera->lookAt[2] += (gPlayerFour->pos[2] - -97.0f);
@@ -1367,39 +1438,39 @@ u16 D_80286B34[] = {
};
#endif
-void func_802847CC(struct CinematicCamera* camera) {
+void func_802847CC(CinematicCamera* camera) {
u16 sp2E;
u16 sp2C;
// D_802856B4 cast to u32 triggers cfc1.
sp2E = D_80286A04[D_800DC5E4].unkC - (10 - (-(((u16) (u32) D_802856B4))));
sp2C = D_80286A04[D_800DC5E4].unkC;
- cutscene_event((CameraEvent) func_80283CD0, camera, 0, 0);
- cutscene_event((CameraEvent) play_sound_welcome, camera, 8, 8);
+ cutscene_event(func_80283CD0, camera, 0, 0);
+ cutscene_event(play_sound_welcome, camera, 8, 8);
#ifdef VERSION_EU
- cutscene_event((CameraEvent) func_80283C78, camera, 134, 134);
+ cutscene_event(func_80283C78, camera, 134, 134);
#else
- cutscene_event((CameraEvent) func_80283C78, camera, 149, 149);
+ cutscene_event(func_80283C78, camera, 149, 149);
#endif
- cutscene_event((CameraEvent) func_80282434, camera, 0, 0);
+ cutscene_event(reset_spline_wrap, camera, 0, 0);
switch (D_80286A04[D_800DC5E4].unk0) {
case 1:
- cutscene_event((CameraEvent) func_802839CC, camera, 0, -1);
- cutscene_event((CameraEvent) func_802839E0, camera, sp2E - 0x14, sp2E - 0x14);
+ cutscene_event(animation_disapears_sliding_borders, camera, 0, -1);
+ cutscene_event(wrap_func_80092C80, camera, sp2E - 0x14, sp2E - 0x14);
break;
case 2:
- cutscene_event((CameraEvent) func_802839B4, camera, 0, 0);
- cutscene_event((CameraEvent) play_sound_farewell, camera, 247, 247);
- func_80282D90(camera, (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk4,
- (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk8, 0);
+ cutscene_event(animation_apears_sliding_borders, camera, 0, 0);
+ cutscene_event(play_sound_farewell, camera, 247, 247);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk4,
+ (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk8, 0);
break;
default:
- cutscene_event((CameraEvent) func_802839B4, camera, 0, 0);
- cutscene_event((CameraEvent) func_802839CC, camera, sp2E, sp2E);
- cutscene_event((CameraEvent) func_802839E0, camera, sp2E - 0x14, sp2E - 0x14);
- func_80282D90(camera, (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk4,
- (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk8, 0);
+ cutscene_event(animation_apears_sliding_borders, camera, 0, 0);
+ cutscene_event(animation_disapears_sliding_borders, camera, sp2E, sp2E);
+ cutscene_event(wrap_func_80092C80, camera, sp2E - 0x14, sp2E - 0x14);
+ move_cinematic_camera_along_spline(camera, (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk4,
+ (struct struct_80286A04*) D_80286A04[D_800DC5E4].unk8, 0);
break;
}
@@ -1429,7 +1500,7 @@ struct struct_80284AE8 {
/**
* Play the current cutscene until either gCutsceneShotTimer reaches the max time, or c->cutscene is set to 0
*/
-void play_cutscene(struct CinematicCamera* camera) {
+void play_cutscene(CinematicCamera* camera) {
UNUSED s32 pad[3];
s16 cutsceneDuration;
@@ -1442,14 +1513,14 @@ void play_cutscene(struct CinematicCamera* camera) {
return;
}
switch (camera->cutscene) {
- CUTSCENE(2, D_80285D10)
+ CUTSCENE(2, gCutScene)
break;
- CUTSCENE(3, D_80285D10)
+ CUTSCENE(3, gCutScene)
break;
- CUTSCENE(4, D_80285D10)
+ CUTSCENE(4, gCutScene)
break;
CUTSCENE(5, D_80285D58)
- func_80283C58(camera);
+ wrap_func_800CB14C(camera);
break;
CUTSCENE(6, D_80286B5C)
break;
@@ -1486,15 +1557,15 @@ void play_cutscene(struct CinematicCamera* camera) {
* Sliding black borders that open horizontally to display scene.
* Used at the beginning of award ceremony and throughout credits.
*/
-void transition_sliding_borders(void) {
+void ceremony_transition_sliding_borders(void) {
f32 temp_f0;
f32 temp_f14;
- temp_f14 = D_802856B0 - D_802856C0;
+ temp_f14 = D_802856B0 - gSizeSlidingBorders;
if (temp_f14 < 0.0f) {
temp_f14 = 0.0f;
}
- temp_f0 = D_802856B0 + D_802856C0;
+ temp_f0 = D_802856B0 + gSizeSlidingBorders;
// clang-format off
// Note that this MUST be on one line. All hail significant whitespace in C!
do {if (temp_f0 > 240.0f) { temp_f0 = 239.0f; } } while (0);
@@ -1507,5 +1578,5 @@ void transition_sliding_borders(void) {
gDPFillRectangle(gDisplayListHead++, 0, 0, 319, (s32) temp_f14);
gDPFillRectangle(gDisplayListHead++, 0, (s32) temp_f0, 319, 239);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
- set_transition_colour_fade_alpha_ending(&D_802856C0, D_802856B8, D_802856BC / D_802856B4);
+ adjust_f32_value_transition(&gSizeSlidingBorders, gOrderedSizeSlidingBorders, D_802856BC / D_802856B4);
}
diff --git a/src/ending/ceremony_and_credits.h b/src/ending/ceremony_and_credits.h
index 9cf2861d2..2913c3ec3 100644
--- a/src/ending/ceremony_and_credits.h
+++ b/src/ending/ceremony_and_credits.h
@@ -48,7 +48,7 @@ struct credits_data_1FA0 {
*
* See the sCutsceneVars[] array in camera.c for more details.
*/
-struct CinematicCamera {
+typedef struct {
/* 0x00 */ Vec3f pos;
/* 0x0C */ Vec3f lookAt;
/* 0x18 */ f32 unk18;
@@ -67,7 +67,7 @@ struct CinematicCamera {
/* 0x68 */ f32 unk68;
/* 0x6C */ s16 unk6C;
/* 0x6E */ s16 unk6E;
-}; // size = 0x70
+} CinematicCamera; // size = 0x70
struct struct_80282C40 {
s8 unk0;
@@ -99,11 +99,14 @@ struct CutsceneSplinePoint {
};
struct Cutscene {
- /* 0x0 */ void (*shot)(struct CinematicCamera*);
+ /* 0x0 */ void (*shot)(CinematicCamera*);
/* 0x4 */ s16 duration;
/* 0x6 */ // s16 pad;
}; /* size = 0x8 */
+typedef void (*CameraEvent)(CinematicCamera* c);
+typedef CameraEvent CutsceneShot;
+
/* Function Prototypes */
void init_cinematic_camera(void);
@@ -116,88 +119,88 @@ void vec3f_copy_return_dupe(Vec3f, Vec3f);
void vec3s_copy_dupe(Vec3s, Vec3s);
void func_80282040(void);
void func_80282048(void);
-void func_80282050(Vec3f, Vec3f, s16);
-void func_802820F8(Vec3f, Vec3f, s16);
+void rotate_y_vec3f(Vec3f, Vec3f, s16);
+void rotate_x_vec3f(Vec3f, Vec3f, s16);
s32 f32_lerp(f32*, f32, f32);
-s32 func_80282200(Vec3s, s16, s16);
-s32 set_transition_colour_fade_alpha_ending(f32*, f32, f32);
-s32 func_80282364(s16*, s16, s16);
+bool ease_out_transition(s16*, s16, s16);
+bool adjust_f32_value_transition(f32*, f32, f32);
+bool adjust_s16_value_transition(s16*, s16, s16);
void reset_spline(void);
-void func_80282434(struct CinematicCamera*);
-void func_80282454(Vec3f, Vec3f, f32*, s16*, s16*);
-void func_80282504(Vec3f, Vec3f, f32, s16, s16);
-void func_802825C8(Vec3f, Vec3f, Vec3f, Vec3s);
-void func_80282700(f32, Vec3f, f32*, f32[], f32[], f32[], f32[]);
+void reset_spline_wrap(CinematicCamera*);
+void calculate_distance_angle_y_and_angle_y_to_xz(Vec3f, Vec3f, f32*, s16*, s16*);
+void apply_distance_angle_y_and_angle_y_to_xz(Vec3f, Vec3f, f32, s16, s16);
+void aborting_cinematic_function(Vec3f, Vec3f, Vec3f, Vec3s);
+void evaluate_cubic_spline(f32, Vec3f, f32*, f32[], f32[], f32[], f32[]);
s32 move_point_along_spline(Vec3f, f32*, struct struct_80283430[], s16*, f32*);
void func_80282BE4(struct struct_80283430*, s8, u8, s8, Vec3s, s32);
void func_80282C40(struct struct_80283430*, struct struct_80282C40*, s32);
-s32 func_80282D90(struct CinematicCamera*, struct struct_80286A04*, struct struct_80286A04*, s32);
-void func_80282E58(struct CinematicCamera*, struct struct_80282C40*, s32);
-void func_80282EAC(s32, struct CinematicCamera*, s16, s16, s16);
+s32 move_cinematic_camera_along_spline(CinematicCamera*, struct struct_80286A04*, struct struct_80286A04*, s32);
+void func_80282E58(CinematicCamera*, struct struct_80282C40*, s32);
+void func_80282EAC(s32, CinematicCamera*, s16, s16, s16);
void func_80282F00(s16*, s16);
-void func_80282F44(s32, struct CinematicCamera*, Camera*);
-void func_802830B4(struct CinematicCamera*, s16, s16, s16);
-void func_80283100(struct CinematicCamera*, f32*);
+void func_80282F44(s32, CinematicCamera*, Camera*);
+void func_802830B4(CinematicCamera*, s16, s16, s16);
+void func_80283100(CinematicCamera*, f32*);
void func_80283240(s16);
-s32 cutscene_event(CameraEvent event, struct CinematicCamera*, s16, s16);
+s32 cutscene_event(CameraEvent event, CinematicCamera*, s16, s16);
s32 func_80283330(s32);
-s32 func_8028336C(struct CinematicCamera*, Camera*);
-s32 func_80283428(void);
-void func_80283968(struct CinematicCamera*);
-void func_80283994(struct CinematicCamera*);
-void func_802839B4(struct CinematicCamera*);
-void func_802839CC(struct CinematicCamera*);
-void func_802839E0(struct CinematicCamera*);
-void play_sound_welcome(struct CinematicCamera*);
-void func_80283A34(struct CinematicCamera*);
-void play_sound_congratulation(struct CinematicCamera*);
-void play_sound_balloon_pop(struct CinematicCamera*);
-void play_sound_fish(struct CinematicCamera*);
-void play_sound_fish_2(struct CinematicCamera*);
-void play_sound_shoot_trophy(struct CinematicCamera*);
-void play_sound_podium(struct CinematicCamera*);
-void play_sound_trophy(struct CinematicCamera*);
-void func_80283A54(struct CinematicCamera*);
-void func_80283A7C(struct CinematicCamera*);
-void func_80283B6C(struct CinematicCamera*);
-void func_80283BA4(struct CinematicCamera*);
-void func_80283BF0(struct CinematicCamera*);
-void func_80283C14(struct CinematicCamera*);
-void func_80283C38(struct CinematicCamera*);
-void func_80283C58(struct CinematicCamera*);
-void func_80283C78(struct CinematicCamera*);
-void func_80283CA8(struct CinematicCamera*);
-void func_80283CD0(struct CinematicCamera*);
-void play_sound_farewell(struct CinematicCamera*);
-void func_80283D2C(struct CinematicCamera*);
-void func_80283EA0(struct CinematicCamera*);
-void func_80283ED0(struct CinematicCamera*);
-void func_80283EF8(struct CinematicCamera*);
-void func_80283F6C(struct CinematicCamera*);
-void func_80283FCC(struct CinematicCamera*);
-void func_80283FF4(struct CinematicCamera*);
-void func_80284068(struct CinematicCamera*);
-void func_802840C8(struct CinematicCamera*);
-void func_80284154(struct CinematicCamera*);
-void func_80284184(struct CinematicCamera*);
-void func_802841E8(struct CinematicCamera*);
-void func_8028422C(struct CinematicCamera*);
-void func_802842A8(struct CinematicCamera*);
-void func_802842D8(struct CinematicCamera*);
-void func_80284308(struct CinematicCamera*);
-void func_80284418(struct CinematicCamera*);
-void func_80284494(struct CinematicCamera*);
-void func_802844FC(struct CinematicCamera*);
-void func_8028454C(struct CinematicCamera*);
-void func_802845EC(struct CinematicCamera*);
-void func_8028461C(struct CinematicCamera*);
-void func_80284648(struct CinematicCamera*);
+s32 func_8028336C(CinematicCamera*, Camera*);
+s32 cinematic_stub(void);
+void wrap_func_8028100C(CinematicCamera*);
+void wrap_func_80280FFC(CinematicCamera*);
+void animation_apears_sliding_borders(CinematicCamera*);
+void animation_disapears_sliding_borders(CinematicCamera*);
+void wrap_func_80092C80(CinematicCamera*);
+void play_sound_welcome(CinematicCamera*);
+void wrap_func_800CA0CC(CinematicCamera*);
+void play_sound_congratulation(CinematicCamera*);
+void play_sound_balloon_pop(CinematicCamera*);
+void play_sound_fish(CinematicCamera*);
+void play_sound_fish_2(CinematicCamera*);
+void play_sound_shoot_trophy(CinematicCamera*);
+void play_sound_podium(CinematicCamera*);
+void play_sound_trophy(CinematicCamera*);
+void func_80283A54(CinematicCamera*);
+void func_80283A7C(CinematicCamera*);
+void func_80283B6C(CinematicCamera*);
+void func_80283BA4(CinematicCamera*);
+void func_80283BF0(CinematicCamera*);
+void func_80283C14(CinematicCamera*);
+void wrap_func_800CB134(CinematicCamera*);
+void wrap_func_800CB14C(CinematicCamera*);
+void func_80283C78(CinematicCamera*);
+void func_80283CA8(CinematicCamera*);
+void func_80283CD0(CinematicCamera*);
+void play_sound_farewell(CinematicCamera*);
+void func_80283D2C(CinematicCamera*);
+void func_80283EA0(CinematicCamera*);
+void copy_player_two_in_camera(CinematicCamera*);
+void lerp_player_two_in_camera(CinematicCamera*);
+void func_80283F6C(CinematicCamera*);
+void copy_player_three_in_camera(CinematicCamera*);
+void lerp_player_three_in_camera(CinematicCamera*);
+void func_80284068(CinematicCamera*);
+void func_802840C8(CinematicCamera*);
+void func_80284154(CinematicCamera*);
+void func_80284184(CinematicCamera*);
+void func_802841E8(CinematicCamera*);
+void func_8028422C(CinematicCamera*);
+void func_802842A8(CinematicCamera*);
+void func_802842D8(CinematicCamera*);
+void func_80284308(CinematicCamera*);
+void func_80284418(CinematicCamera*);
+void func_80284494(CinematicCamera*);
+void func_802844FC(CinematicCamera*);
+void func_8028454C(CinematicCamera*);
+void func_802845EC(CinematicCamera*);
+void func_8028461C(CinematicCamera*);
+void func_80284648(CinematicCamera*);
void func_802846AC(void);
-void func_802846B4(struct CinematicCamera*);
-void func_802846E4(struct CinematicCamera*);
-void func_802847CC(struct CinematicCamera*);
-void play_cutscene(struct CinematicCamera*);
-void transition_sliding_borders(void);
+void func_802846B4(CinematicCamera*);
+void func_802846E4(CinematicCamera*);
+void func_802847CC(CinematicCamera*);
+void play_cutscene(CinematicCamera*);
+void ceremony_transition_sliding_borders(void);
/* This is where I'd put my static data, if I had any */
@@ -205,9 +208,9 @@ extern s32 D_80283FCC;
extern s32 D_80283FF4;
extern f32 D_802856B0;
extern f32 D_802856B4;
-extern f32 D_802856B8;
+extern f32 gOrderedSizeSlidingBorders;
extern f32 D_802856BC;
-extern f32 D_802856C0;
+extern f32 gSizeSlidingBorders;
extern s32 D_802856C4;
extern s32 D_802856C8[]; // padding?
extern s16 sCutsceneShot;
@@ -215,7 +218,7 @@ extern s16 gCutsceneShotTimer;
extern s32 D_802876D4;
extern s32 D_802876D8;
extern s32 D_802876DC; // fake/padding? Or D8 is array?
-extern struct CinematicCamera D_802876E0;
+extern CinematicCamera D_802876E0;
extern struct struct_80283431 D_80287750[];
extern struct struct_80283430 D_80287818[];
extern struct struct_80283430 D_80287998[];
@@ -248,7 +251,7 @@ extern struct struct_80282C40 D_80285B90[];
extern struct struct_80282C40 D_80285BA8[];
extern struct struct_80282C40 D_80285C38[];
extern struct struct_80282C40 D_80285C74[];
-extern struct Cutscene D_80285D10[];
+extern struct Cutscene gCutScene[];
extern s16 D_80285D14;
extern s32 D_802876D4;
extern s32 D_802876D8;
diff --git a/src/ending/code_80280000.c b/src/ending/code_80280000.c
index 19fc43e6f..a52372d7f 100644
--- a/src/ending/code_80280000.c
+++ b/src/ending/code_80280000.c
@@ -65,7 +65,7 @@ void func_80280038(void) {
render_course_actors(D_800DC5EC);
render_object(PLAYER_ONE + SCREEN_MODE_1P);
render_player_snow_effect(PLAYER_ONE + SCREEN_MODE_1P);
- transition_sliding_borders();
+ ceremony_transition_sliding_borders();
func_80281C40();
init_rdp();
func_80093F10();
diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c
index b978d2457..3b7769ce9 100644
--- a/src/ending/code_80281780.c
+++ b/src/ending/code_80281780.c
@@ -160,7 +160,7 @@ void load_ceremony_cutscene(void) {
init_hud();
func_8001C05C();
balloons_and_fireworks_init();
- func_802816B8();
+ init_camera_podium_ceremony();
func_80093E60();
D_801625F8 = (uintptr_t) gHeapEndPtr - gNextFreeMemoryAddress;
D_801625FC = ((f32) D_801625F8 / 1000.0f);
diff --git a/src/ending/code_80281C40.c b/src/ending/code_80281C40.c
index 54720e8b4..5616040a5 100644
--- a/src/ending/code_80281C40.c
+++ b/src/ending/code_80281C40.c
@@ -132,7 +132,7 @@ void func_80281D00(void) {
func_80021B0C();
gSPDisplayList(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_80284EE0));
func_80093F10();
- transition_sliding_borders();
+ ceremony_transition_sliding_borders();
func_80281C40();
init_rdp();
}
diff --git a/src/ending/podium_ceremony_actors.c b/src/ending/podium_ceremony_actors.c
index 577b5c444..b3edd81d7 100644
--- a/src/ending/podium_ceremony_actors.c
+++ b/src/ending/podium_ceremony_actors.c
@@ -450,7 +450,7 @@ void func_80281540(void) {
void podium_ceremony_loop(void) {
gMatrixObjectCount = 0;
D_802874FC = 0;
- setup_camera_podium_ceremony();
+ update_camera_podium_ceremony();
func_80028F70();
func_80022744();
func_80059AC8();
diff --git a/src/menus.c b/src/menus.c
index 8bc28ea85..dffd6c47b 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -54,7 +54,7 @@ s32 gMenuDelayTimer;
s8 D_8018EE08;
s8 gCupSelection;
s8 D_8018EE0A;
-s8 gCupCourseSelection;
+s8 gCourseIndexInCup;
s8 D_8018EE0C;
struct_8018EE10_entry D_8018EE10[2];
@@ -81,29 +81,38 @@ s8 unref_800E86E0[4] = { 0, 0, 0, 1 };
u32 sVIGammaOffDitherOn = OS_VI_GAMMA_OFF | OS_VI_DITHER_FILTER_ON;
-/*** Const/rodata Data ***/
-// used to set gScreenModeSelection; might be smaller; could be function static data
+// Used to set gScreenModeSelection; might be smaller; could be function static data
const s8 D_800F2B50[] = { 0, 1, 2, 3, 3 };
-// set to gPlayerCount, then that sets gPlayerCountSelection1
+// Set to gPlayerCount, then that sets gPlayerCountSelection1
const s8 D_800F2B58[] = { 1, 2, 2, 3, 4 };
-// Limit for each column in one-two-three-four players selection
-const s8 D_800F2B60[5][3] = {
- { 1, 2, 1 }, { 1, 2, 1 }, { 0, 2, 2 }, { 0, 2, 0 }, { 0, 2, 0 },
- // {0, 3, 1},
- // {0, 3, 3},
- // {0, 3, 0},
- // {0, 3, 0},
+// Set indexed slots numbers for one-two-three-four mode selection
+const s8 gPlayerModeSelection[] = { 1, 2, 1, 1 };
+
+// Limit for each index column in one-two-three-four mode selection
+const s8 gGameModePlayerColumnDefault[][3] = {
+ { 2, 1, 0 }, // 1p (GP options, TT options, ...)
+ { 2, 2, 0 }, // 2p (GP options, VS options, Battle)
+ { 2, 0, 0 }, // 3p (VS options, Battle, ...)
+ { 2, 0, 0 }, // 4p (VS options, Battle, ...)
+};
+
+// Limit for each index column in one-two-three-four mode selection
+// for extra mode (mirror mode), hence the extra value (3 instead of 2)
+const s8 gGameModePlayerColumnExtra[][3] = {
+ { 3, 1, 0 }, // 1p (GP options, TT options, ...)
+ { 3, 3, 0 }, // 2p (GP options, VS options, Battle)
+ { 3, 0, 0 }, // 3p (VS options, Battle, ...)
+ { 3, 0, 0 }, // 4p (VS options, Battle, ...)
};
-// is this another union GameModePack? Figure out when decomping.
-const s32 gGameModeFromNumPlayersAndRowSelection[5][3] = {
- { 0x03010003, 0x03000300, 0x00030000 }, // Despite this matching, there is no way this line belongs in this array
- { GRAND_PRIX, TIME_TRIALS, 0x00000000 }, // first column
- { GRAND_PRIX, VERSUS, BATTLE }, // second
- { VERSUS, BATTLE, 0x00000000 }, // third
- { VERSUS, BATTLE, 0x00000000 }, // four
+// Modes to select in one-two-three-four mode selection
+const s32 gGameModePlayerSelection[][3] = {
+ { GRAND_PRIX, TIME_TRIALS, 0x00000000 }, // 1p game modes
+ { GRAND_PRIX, VERSUS, BATTLE }, // 2p game modes
+ { VERSUS, BATTLE, 0x00000000 }, // 3p game modes
+ { VERSUS, BATTLE, 0x00000000 }, // 4p game modes
};
// map from character grid position id to character id
@@ -124,9 +133,10 @@ const s16 gCupCourseOrder[5][4] = {
{ COURSE_BIG_DONUT, COURSE_BLOCK_FORT, COURSE_DOUBLE_DECK, COURSE_SKYSCRAPER },
};
-const s8 D_800F2BDC[8] = { 1, 0, 0, 0, 0, 1, 3, 4 };
+const s8 D_800F2BDC[4] = { 1, 0, 0, 0 };
+const s8 D_800F2BE0[4] = { 0, 1, 3, 4 };
-const union GameModePack D_800F2BE4 = { { 0, 1, 2, 3 } };
+const union GameModePack gSoundMenuPack = { { SOUND_STEREO, SOUND_HEADPHONES, SOUND_UNUSED, SOUND_MONO } };
/**************************/
@@ -821,7 +831,7 @@ void logo_intro_menu_act(struct Controller* arg0, UNUSED u16 arg1) {
gGamestateNext = 4; // Enter race state
gCCSelection = CC_100;
gCupSelection = 1;
- gCupCourseSelection = 0;
+ gCourseIndexInCup = 0;
gCurrentCourseId = 0;
gScreenModeSelection = SCREEN_MODE_1P;
gCharacterSelections[0] = 0;
@@ -1196,7 +1206,7 @@ void func_800B28C8(void) {
// be whether 'Begin' or 'Data' is selected. Not used for Battle.
s8 temp_v0 = D_800E86B0[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
// Determine which game mode was selected based on the number of players and the row selected on the main menu
- switch (gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]]) {
+ switch (gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]]) {
case GRAND_PRIX:
gCCSelection = temp_v0;
gPlaceItemBoxes = 1;
@@ -1238,7 +1248,7 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
if (!func_800B4520()) {
switch (gMainMenuSelectionDepth) {
case BLANK_MAIN_MENU: {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
break;
}
case PLAYER_NUM_SELECTION: {
@@ -1272,32 +1282,32 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
func_800CA330(0x19);
D_8018EDE0 = 1;
play_sound2(SOUND_MENU_GO_BACK);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & A_BUTTON) {
// L800B2C00
gMainMenuSelectionDepth = GAME_MODE_SELECTION;
func_800B44AC();
play_sound2(SOUND_MENU_SELECT);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & CONT_L) {
// L800B2C58
gMainMenuSelectionDepth = OPTIONS_SELECTION;
func_8009E280();
play_sound2(SOUND_MENU_OPTION);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & CONT_R) {
gMainMenuSelectionDepth = DATA_SELECTION;
func_8009E258();
play_sound2(SOUND_MENU_DATA);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
}
break;
}
case GAME_MODE_SELECTION: {
if (btnAndStick & D_JPAD) {
- if (D_800E86AC[gPlayerCount - 1] < D_800F2B58[gPlayerCount + 7]) {
+ if (D_800E86AC[gPlayerCount - 1] < gPlayerModeSelection[gPlayerCount - 1]) {
D_800E86AC[gPlayerCount - 1] += 1;
func_800B44AC();
play_sound2(SOUND_MENU_CURSOR_MOVE);
@@ -1316,10 +1326,10 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
gMainMenuSelectionDepth = PLAYER_NUM_SELECTION;
func_800B44AC();
play_sound2(SOUND_MENU_GO_BACK);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & A_BUTTON) {
// L800B2E3C
- switch (gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]]) {
+ switch (gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]]) {
case 0:
gMainMenuSelectionDepth = GAME_MODE_CC_OR_TIME_TRIALS_OPTIONS_SELECTION;
play_sound2(SOUND_MENU_GP);
@@ -1343,9 +1353,9 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
// L800B2F04
func_800B44AC();
gMenuTimingCounter = 0;
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
}
break;
}
@@ -1355,8 +1365,8 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
gMenuTimingCounter++;
if ((gMenuTimingCounter == 100 || gMenuTimingCounter % 300 == 0)) {
// L800B2FAC
- if (gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]] == 0 ||
- gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]] == 2) {
+ if (gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]] == 0 ||
+ gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]] == 2) {
play_sound2(SOUND_MENU_SELECT_LEVEL);
}
}
@@ -1372,12 +1382,12 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
if (btnAndStick & D_JPAD) {
sp24 = false;
if (func_800B555C()) {
- if (sp28 < D_800F2B60[gPlayerCount + 4][D_800E86AC[gPlayerCount - 1] + 1]) {
+ if (sp28 < gGameModePlayerColumnExtra[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1] + 1]) {
sp24 = true;
}
} else {
// L800B30D4
- if (sp28 < D_800F2B60[gPlayerCount][D_800E86AC[gPlayerCount - 1] + 1]) {
+ if (sp28 < gGameModePlayerColumnDefault[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1] + 1]) {
sp24 = true;
}
}
@@ -1394,7 +1404,7 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
gMainMenuSelectionDepth = GAME_MODE_SELECTION;
func_800B44AC();
play_sound2(SOUND_MENU_GO_BACK);
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & A_BUTTON) {
// L800B31DC
func_800B44AC();
@@ -1406,10 +1416,10 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
play_sound2(SOUND_MENU_SELECT);
gMenuTimingCounter = 0;
}
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else {
// L800B3294
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
}
break;
}
@@ -1420,7 +1430,7 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
}
// L800B330C
if (btnAndStick & B_BUTTON) {
- switch (gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]]) {
+ switch (gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]]) {
case 0:
case 1:
case 2:
@@ -1435,25 +1445,25 @@ void main_menu_act(struct Controller* controller, u16 arg1) {
func_800B44AC();
play_sound2(SOUND_MENU_GO_BACK);
gMenuTimingCounter = 0;
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else if (btnAndStick & A_BUTTON) {
// L800B33D8
func_8009E1C0();
play_sound2(SOUND_MENU_OK_CLICKED);
func_800B28C8();
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
} else {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
}
break;
}
case OPTIONS_SELECTION:
case DATA_SELECTION: {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
break;
}
default: {
- newMode = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
+ newMode = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
break;
}
}
@@ -1693,7 +1703,7 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) {
}
D_800DC540 = gCupSelection;
- gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection];
+ gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup];
if ((buttonAndStickPress & B_BUTTON) != 0) {
func_8009E208();
play_sound2(SOUND_MENU_GO_BACK);
@@ -1704,7 +1714,7 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) {
} else {
D_8018EDEC = 3;
play_sound2(SOUND_MENU_SELECT);
- gCurrentCourseId = gCupCourseOrder[gCupSelection][CUP_COURSE_ONE];
+ gCurrentCourseId = gCupCourseOrder[gCupSelection][COURSE_ONE];
gMenuTimingCounter = 0;
}
func_800B44AC();
@@ -1712,18 +1722,18 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) {
break;
case 2:
case 4:
- if (((buttonAndStickPress & D_JPAD) != 0) && (gCupCourseSelection < CUP_COURSE_FOUR)) {
- ++gCupCourseSelection;
+ if (((buttonAndStickPress & D_JPAD) != 0) && (gCourseIndexInCup < COURSE_FOUR)) {
+ ++gCourseIndexInCup;
func_800B44AC();
play_sound2(SOUND_MENU_CURSOR_MOVE);
}
- if (((buttonAndStickPress & U_JPAD) != 0) && (gCupCourseSelection > CUP_COURSE_ONE)) {
- --gCupCourseSelection;
+ if (((buttonAndStickPress & U_JPAD) != 0) && (gCourseIndexInCup > COURSE_ONE)) {
+ --gCourseIndexInCup;
func_800B44AC();
play_sound2(SOUND_MENU_CURSOR_MOVE);
}
- gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection];
+ gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup];
if ((buttonAndStickPress & B_BUTTON) != 0) {
if (D_8018EDEC == 2) {
D_8018EDEC = 1;
@@ -1814,7 +1824,7 @@ void func_800B3F74(s32 menuSelection) {
gIsMirrorMode = 0;
gEnableDebugMode = DEBUG_MODE;
gCupSelection = MUSHROOM_CUP;
- gCupCourseSelection = 0;
+ gCourseIndexInCup = 0;
gTimeTrialDataCourseIndex = 0;
if (gPlayerCount <= 0) {
gPlayerCount = 1;
@@ -1822,7 +1832,7 @@ void func_800B3F74(s32 menuSelection) {
if (gPlayerCount >= 5) {
gPlayerCount = 4;
}
- D_8018EDF1 = D_800F2BDC[gPlayerCount + 3];
+ D_8018EDF1 = D_800F2BE0[gPlayerCount - 1];
func_800CA008(0, 0);
func_800C8EAC(1);
D_8018EDFC = 0;
@@ -1884,7 +1894,7 @@ void func_800B3F74(s32 menuSelection) {
case 0: {
D_8018EDEE = 1;
if (gGamestate == 0) {
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) {
if (i < gPlayerCount) {
gCharacterGridSelections[i] = i + 1;
} else {
@@ -1942,7 +1952,7 @@ void func_800B3F74(s32 menuSelection) {
play_sound2(SOUND_MENU_SELECT_MAP);
D_8018EE0A = 0;
if (gModeSelection == GRAND_PRIX) {
- gCupCourseSelection = 0;
+ gCourseIndexInCup = 0;
}
for (i = 0; i < ARRAY_COUNT(gGPPointsByCharacterId); i++) {
@@ -1962,7 +1972,7 @@ void func_800B44BC(void) {
UNUSED u32 pad;
union GameModePack pack;
- pack = D_800F2BE4;
+ pack = gSoundMenuPack;
if ((gSoundMode == SOUND_STEREO) || (gSoundMode == SOUND_HEADPHONES) || (gSoundMode == SOUND_MONO)) {
func_800C3448(pack.modes[gSoundMode] | 0xE0000000);
}
diff --git a/src/menus.h b/src/menus.h
index ce9dc24d4..bcab9e809 100644
--- a/src/menus.h
+++ b/src/menus.h
@@ -70,7 +70,7 @@ extern s32 gMenuDelayTimer;
extern s8 D_8018EE08;
extern s8 gCupSelection;
extern s8 D_8018EE0A;
-extern s8 gCupCourseSelection;
+extern s8 gCourseIndexInCup;
extern s8 D_8018EE0C;
extern struct_8018EE10_entry D_8018EE10[];
@@ -89,14 +89,14 @@ extern u32 sVIGammaOffDitherOn;
extern const s8 D_800F2B50[5];
extern const s8 D_800F2B58[5];
-extern const s8 D_800F2B60[5][3];
-extern const s32 gGameModeFromNumPlayersAndRowSelection[5][3];
+extern const s8 gPlayerModeSelection[];
+extern const s8 gGameModePlayerColumnDefault[][3];
+extern const s8 gGameModePlayerColumnExtra[][3];
+extern const s32 gGameModePlayerSelection[][3];
extern const s8 D_800F2BAC[8];
extern const s16 gCupCourseOrder[NUM_CUPS][NUM_COURSES_PER_CUP];
-extern const s8 D_800F2BDC[8];
-
-extern const union GameModePack D_800F2BE4;
+extern const union GameModePack gSoundMenuPack;
// end of menus.c variables
diff --git a/src/networking/start_game.c b/src/networking/start_game.c
index d1f86ff6a..668367f74 100644
--- a/src/networking/start_game.c
+++ b/src/networking/start_game.c
@@ -53,7 +53,7 @@ void network_cup_vote(uint32_t course) {
void set_course(const char* data) {
if (data != NULL) {
gCupSelection = data[0];
- gCurrentCourseId = gCupCourseOrder[gCupSelection][CUP_COURSE_ONE];
+ gCurrentCourseId = gCupCourseOrder[gCupSelection][COURSE_ONE];
}
}
@@ -121,7 +121,7 @@ void networking_start_session(const char* data) {
gGamestateNext = RACING;
gCCSelection = CC_150;
// gCupSelection = FLOWER_CUP;
- gCupCourseSelection = CUP_COURSE_ONE;
+ gCourseIndexInCup = COURSE_ONE;
gScreenModeSelection = SCREEN_MODE_1P;
gModeSelection = GRAND_PRIX;
gPlayerCount = 1;
diff --git a/src/os/__osDequeueThread.c b/src/os/__osDequeueThread.c
index 8a9a8f483..009114aab 100644
--- a/src/os/__osDequeueThread.c
+++ b/src/os/__osDequeueThread.c
@@ -1,23 +1,24 @@
#include "libultra_internal.h"
-NO_REORDER OSThread* __osThreadTail = NULL;
-NO_REORDER u32 __osTest = -1;
-NO_REORDER OSThread* __osRunQueue = (OSThread*) &__osThreadTail;
-NO_REORDER OSThread* __osActiveQueue = (OSThread*) &__osThreadTail;
-OSThread* __osRunningThread = NULL;
-OSThread* __osFaultedThread = NULL;
+struct __osThreadTail __osThreadTail = { NULL, -1 };
+OSThread* __osRunQueue = (OSThread*) &__osThreadTail;
+OSThread* __osActiveQueue = (OSThread*) &__osThreadTail;
+OSThread* __osRunningThread = { 0 };
+OSThread* __osFaultedThread = { 0 };
-void __osDequeueThread(OSThread** queue, OSThread* thread) {
- register OSThread** a2;
- register OSThread* a3;
- a2 = queue;
- a3 = *a2;
- while (a3 != NULL) {
- if (a3 == thread) {
- *a2 = thread->next;
+void __osDequeueThread(register OSThread** queue, register OSThread* t) {
+ register OSThread* pred;
+ register OSThread* succ;
+
+ pred = (OSThread*) queue;
+ succ = pred->next;
+
+ while (succ != NULL) {
+ if (succ == t) {
+ pred->next = t->next;
return;
}
- a2 = &a3->next;
- a3 = *a2;
+ pred = succ;
+ succ = pred->next;
}
}
diff --git a/src/os/__osDevMgrMain.c b/src/os/__osDevMgrMain.c
index 5a7ecfb45..4fa057fd5 100644
--- a/src/os/__osDevMgrMain.c
+++ b/src/os/__osDevMgrMain.c
@@ -64,11 +64,11 @@ void __osDevMgrMain(void* args) {
break;
case 15:
osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK);
- ret = sp34->epiDmaCallback(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, mb->size);
+ ret = sp34->edma_func(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, mb->size);
break;
case 16:
osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK);
- ret = sp34->epiDmaCallback(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, mb->size);
+ ret = sp34->edma_func(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, mb->size);
break;
case 10:
osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK);
diff --git a/src/os/__osLeoInterrupt.c b/src/os/__osLeoInterrupt.c
index d0629ce55..69bbeb889 100644
--- a/src/os/__osLeoInterrupt.c
+++ b/src/os/__osLeoInterrupt.c
@@ -9,6 +9,8 @@ extern u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_ST
extern u32 D_800EA5F0;
+u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
+
s32 __osLeoInterrupt() {
u32 stat;
volatile u32 pistat;
diff --git a/src/os/__osViSwapContext.c b/src/os/__osViSwapContext.c
index 0fef03ce6..66d89edfa 100644
--- a/src/os/__osViSwapContext.c
+++ b/src/os/__osViSwapContext.c
@@ -23,10 +23,10 @@ void __osViSwapContext() {
} else {
s1->x.scale = s0->comRegs.xScale;
}
- if (s1->state & 4) {
+ if (s1->unk00 & 4) {
sp34 = (u32) (s0->fldRegs[field].yScale & 0xfff);
- s1->y.scale = s1->y.factor * sp34;
- s1->y.scale |= s0->fldRegs[field].yScale & ~0xfff;
+ s1->unk2c = s1->unk24 * sp34;
+ s1->unk2c |= s0->fldRegs[field].yScale & ~0xfff;
} else {
s1->y.scale = s0->fldRegs[field].yScale;
}
diff --git a/src/os/controller.h b/src/os/controller.h
index f1ff34661..257e3db8e 100644
--- a/src/os/controller.h
+++ b/src/os/controller.h
@@ -149,8 +149,8 @@ s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 start_page, u16* sum, u
s32 __osBlockSum(OSPfs* pfs, u8 page_no, u16* sum, u8 bank);
s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer);
s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int force);
-void __osContGetInitData(u8* pattern, OSContStatus* data);
-void __osPackRequestData(u8 cmd);
+void __osContGetInitData(u8* bitpattern, OSContStatus* status);
+void __osPackRequestData(u8 command);
void __osPfsRequestData(u8 cmd);
void __osPfsGetInitData(u8* pattern, OSContStatus* data);
u8 __osContAddressCrc(u16 addr);
diff --git a/src/os/leointerrupt.c b/src/os/leointerrupt.c
deleted file mode 100644
index 1690fe474..000000000
--- a/src/os/leointerrupt.c
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "libultra_internal.h"
-#include <PR/rcp.h>
-#include "bstring.h"
-#include "piint.h"
-#include "osint.h"
-
-u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
-
-#ifdef VERSION_SH
-
-//! @todo so many magic constants :'(
-static void __osLeoResume(void);
-static void __osLeoAbnormalResume(void);
-
-s32 __osLeoInterrupt() {
- u32 stat;
- volatile u32 pi_stat;
- u32 bm_stat;
- __OSTranxInfo* info;
- __OSBlockInfo* blockInfo;
- stat = 0;
- info = &__osDiskHandle->transferInfo;
- blockInfo = &info->block[info->blockNum];
- pi_stat = IO_READ(PI_STATUS_REG);
- if (pi_stat & PI_STATUS_DMA_BUSY) {
- __OSGlobalIntMask = __OSGlobalIntMask & ~SR_IBIT4; // cartridge interrupt
- blockInfo->errStatus = LEO_ERROR_29;
- __osLeoResume();
- return 1;
- }
- WAIT_ON_IOBUSY(pi_stat);
- stat = IO_READ(LEO_STATUS);
- if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
- WAIT_ON_IOBUSY(pi_stat);
- IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
- blockInfo->errStatus = LEO_ERROR_GOOD;
- return 0;
- }
- if (info->cmdType == LEO_CMD_TYPE_2) {
- return 1;
- }
- if (stat & LEO_STATUS_BUFFER_MANAGER_ERROR) {
- WAIT_ON_IOBUSY(pi_stat);
- stat = IO_READ(LEO_STATUS);
- blockInfo->errStatus = LEO_ERROR_22;
- __osLeoResume();
- IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
- __OSGlobalIntMask |= OS_IM_PI;
- return 1;
- }
- if (info->cmdType == LEO_CMD_TYPE_1) {
- if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
- if (info->sectorNum + 1 != info->transferMode * 85) {
- blockInfo->errStatus = LEO_ERROR_24;
- __osLeoAbnormalResume();
- return 1;
- }
- IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
- __OSGlobalIntMask |= OS_IM_PI;
- blockInfo->errStatus = LEO_ERROR_GOOD;
- __osLeoResume();
- return 1;
- }
- blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
- info->sectorNum++;
- osEPiRawStartDma(__osDiskHandle, OS_WRITE, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
- return 1;
- }
- if (info->cmdType == LEO_CMD_TYPE_0) {
- if (info->transferMode == LEO_SECTOR_MODE) {
- if ((s32) blockInfo->C1ErrNum + 17 < info->sectorNum) {
- blockInfo->errStatus = LEO_ERROR_GOOD;
- __osLeoAbnormalResume();
- return 1;
- }
- if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
- blockInfo->errStatus = LEO_ERROR_23;
- __osLeoAbnormalResume();
- return 1;
- }
- } else {
- blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
- }
- bm_stat = IO_READ(LEO_BM_STATUS);
- if ((bm_stat & LEO_BM_STATUS_C1SINGLE && bm_stat & LEO_BM_STATUS_C1DOUBLE) || bm_stat & LEO_BM_STATUS_MICRO) {
- if (blockInfo->C1ErrNum > 3) {
- if (info->transferMode != LEO_SECTOR_MODE || info->sectorNum > 0x52) {
- blockInfo->errStatus = LEO_ERROR_23;
- __osLeoAbnormalResume();
- return 1;
- }
- } else {
- int errNum = blockInfo->C1ErrNum;
- blockInfo->C1ErrSector[errNum] = info->sectorNum + 1;
- }
- blockInfo->C1ErrNum++;
- }
- if (stat & LEO_STATUS_C2_TRANSFER) {
- if (info->sectorNum != 87) {
- blockInfo->errStatus = LEO_ERROR_24;
- __osLeoAbnormalResume();
- }
- if (info->transferMode == LEO_TRACK_MODE && info->blockNum == 0) {
- info->blockNum = 1;
- info->sectorNum = -1;
- info->block[1].dramAddr = (void*) ((u32) info->block[1].dramAddr - info->block[1].sectorSize);
-
- blockInfo->errStatus = LEO_ERROR_22;
- } else {
- IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
- __OSGlobalIntMask |= OS_IM_PI;
- info->cmdType = LEO_CMD_TYPE_2;
- blockInfo->errStatus = LEO_ERROR_GOOD;
- }
- osEPiRawStartDma(__osDiskHandle, OS_READ, LEO_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4);
- return 1;
- }
-
- if (info->sectorNum == -1 && info->transferMode == LEO_TRACK_MODE && info->blockNum == 1) {
- __OSBlockInfo* bptr = &info->block[0];
- if (bptr->C1ErrNum == 0) {
- if (((u32*) bptr->C2Addr)[0] | ((u32*) bptr->C2Addr)[1] | ((u32*) bptr->C2Addr)[2] |
- ((u32*) bptr->C2Addr)[3]) {
- bptr->errStatus = LEO_ERROR_24;
- __osLeoAbnormalResume();
- return 1;
- }
- }
- bptr->errStatus = 0;
- __osLeoResume();
- }
- info->sectorNum++;
- if (stat & LEO_STATUS_DATA_REQUEST) {
- if (info->sectorNum > 0x54) {
- blockInfo->errStatus = LEO_ERROR_24;
- __osLeoAbnormalResume();
- return 1;
- }
- osEPiRawStartDma(__osDiskHandle, 0, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
- blockInfo->errStatus = LEO_ERROR_GOOD;
- return 1;
- }
- if (info->sectorNum <= 0x54) {
- blockInfo->errStatus = LEO_ERROR_24;
- __osLeoAbnormalResume();
- return 1;
- }
- return 1;
- }
- blockInfo->errStatus = LEO_ERROR_4;
- __osLeoAbnormalResume();
- return 1;
-}
-
-static void __osLeoAbnormalResume(void) {
- __OSTranxInfo* info;
- u32 pi_stat;
- info = &__osDiskHandle->transferInfo;
- WAIT_ON_IOBUSY(pi_stat);
- IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET);
- WAIT_ON_IOBUSY(pi_stat);
- IO_WRITE(LEO_BM_CTL, info->bmCtlShadow);
- __osLeoResume();
- IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
- __OSGlobalIntMask |= OS_IM_PI;
-}
-
-static void __osLeoResume(void) {
- __OSEventState* es;
- OSMesgQueue* mq;
- s32 last;
- es = &__osEventStateTab[OS_EVENT_PI];
- mq = es->messageQueue;
- if (mq == NULL || MQ_IS_FULL(mq)) {
- return;
- }
- last = (mq->first + mq->validCount) % mq->msgCount;
- mq->msg[last] = es->message;
- mq->validCount++;
- if (mq->mtqueue->next != NULL) {
- __osEnqueueThread(&D_80334898, __osPopThread(&mq->mtqueue));
- }
-}
-
-#endif
diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h
index b6ae5dd06..8b775d3e1 100644
--- a/src/os/libultra_internal.h
+++ b/src/os/libultra_internal.h
@@ -10,14 +10,10 @@ typedef struct __OSEventState {
} __OSEventState;
#endif
-typedef struct // __osThreadTail
-{
- /* 0x00 */ OSThread* next;
- /* 0x04 */ OSPri priority;
- /* 0x08 */ OSThread* queue;
- /* 0x0c */ OSThread* tlnext;
-
-} OSThreadTail;
+extern struct __osThreadTail {
+ OSThread* next;
+ OSPri priority;
+} __osThreadTail;
/*
* This define is needed because the original definitions in __osDequeueThread.c are declared
@@ -35,10 +31,10 @@ typedef struct {
} OSThread_ListHead;
// Original OSThread_ListHead definitions
-extern OSThread* __osThreadTail;
+extern OSThread* __osRunningThread;
extern OSThread* __osActiveQueue;
+extern OSThread* __osFaultedThread;
extern OSThread* __osRunQueue;
-extern OSThread* __osRunningThread;
// Original EEPROM definitions
extern u32 D_80365E00[15];
diff --git a/src/os/osContInit.c b/src/os/osContInit.c
index ccd7583d5..04cb65ddf 100644
--- a/src/os/osContInit.c
+++ b/src/os/osContInit.c
@@ -1,5 +1,5 @@
#include "libultra_internal.h"
-#include "osContInternal.h"
+#include "controller.h"
void __osPackRequestData(u8);
void __osContGetInitData(u8*, OSContStatus*);
@@ -9,6 +9,7 @@ u32 _osContInitialized = 0;
extern u64 osClockRate;
// these probably belong in EEPROMlongread or something
+ALIGNED16 OSPifRam __osContPifRam;
u8 __osContLastCmd;
u8 _osContNumControllers;
OSTimer D_80196548;
@@ -34,9 +35,9 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* status) {
//! @todo figure out what it means
_osContNumControllers = 4;
__osPackRequestData(0);
- ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
+ ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
- ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
+ ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
__osContGetInitData(bitpattern, status);
__osContLastCmd = 0;
@@ -45,48 +46,49 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* status) {
return ret;
}
void __osContGetInitData(u8* bitpattern, OSContStatus* status) {
- OSContPackedRequest* cmdBufPtr;
- OSContPackedRequest response;
+ u8* ptr;
+ __OSContRequesFormat response;
s32 i;
- u8 sp7;
+ u8 bits;
- sp7 = 0;
- cmdBufPtr = &(_osContCmdBuf[0].request);
- for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) {
- response = *(OSContPackedRequest*) cmdBufPtr;
- status->errnum = (response.rxLen & 0xc0) >> 4;
+ bits = 0;
+ ptr = (u8*) __osContPifRam.ramarray;
+ for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(response), status++) {
+ response = *((__OSContRequesFormat*) (ptr));
+ status->errnum = CHNL_ERR(response);
if (status->errnum == 0) {
- status->type = response.data2 << 8 | response.data1;
- status->status = response.data3;
+ status->type = response.typel << 8 | response.typeh;
+ status->status = response.status;
- sp7 |= 1 << i;
+ bits |= 1 << i;
}
}
- *bitpattern = sp7;
+
+ *bitpattern = bits;
}
void __osPackRequestData(u8 command) {
- OSContPackedRequest* cmdBufPtr;
- OSContPackedRequest request;
+ u8* ptr;
+ __OSContRequesFormat requestHeader;
s32 i;
- // some kind of weird zeroing code
- for (i = 0; i < 0x10; i++) {
- *((u32*) &_osContCmdBuf + i) = 0;
+ for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
+ __osContPifRam.ramarray[i] = 0;
}
- _osContPifCtrl = 1;
- cmdBufPtr = &_osContCmdBuf[0].request;
- request.padOrEnd = 255;
- request.txLen = 1;
- request.rxLen = 3;
- request.command = command;
- request.data1 = 255;
- request.data2 = 255;
- request.data3 = 255;
- request.data4 = 255;
+ __osContPifRam.pifstatus = CONT_CMD_EXE;
+ ptr = (u8*) __osContPifRam.ramarray;
+ requestHeader.dummy = CONT_CMD_NOP;
+ requestHeader.txsize = CONT_CMD_RESET_TX;
+ requestHeader.rxsize = CONT_CMD_RESET_RX;
+ requestHeader.cmd = command;
+ requestHeader.typeh = CONT_CMD_NOP;
+ requestHeader.typel = CONT_CMD_NOP;
+ requestHeader.status = CONT_CMD_NOP;
+ requestHeader.dummy1 = CONT_CMD_NOP;
for (i = 0; i < _osContNumControllers; i++) {
- *cmdBufPtr++ = request;
+ *(__OSContRequesFormat*) ptr = requestHeader;
+ ptr += sizeof(requestHeader);
}
- cmdBufPtr->padOrEnd = 254;
+ *ptr = CONT_CMD_END;
}
diff --git a/src/os/osContInternal.h b/src/os/osContInternal.h
deleted file mode 100644
index 3b6fc3d47..000000000
--- a/src/os/osContInternal.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef _ULTRA64_CONTROLLER_INTERNAL_H_
-#define _ULTRA64_CONTROLLER_INTERNAL_H_
-
-typedef struct {
- u8 padOrEnd;
- u8 txLen;
- u8 rxLen; // includes errno
- u8 command;
- u16 button;
- s8 rawStickX;
- s8 rawStickY;
-} OSContPackedRead;
-
-typedef struct {
- u8 padOrEnd;
- u8 txLen;
- u8 rxLen;
- u8 command;
- u8 data1;
- u8 data2;
- u8 data3;
- u8 data4;
-} OSContPackedRequest;
-
-typedef union {
- OSContPackedRead read;
- OSContPackedRequest request;
- u32 as_raw[2];
-} OSContPackedStruct;
-
-#ifdef AVOID_UB
-// Fix the OSContPackedStruct array
-extern OSContPackedStruct _osContCmdBuf[8];
-
-// And fix the last element
-#define _osContPifCtrl _osContCmdBuf[7].as_raw[1]
-#else
-// Original OSContPackedStruct definitions
-extern OSContPackedStruct _osContCmdBuf[7];
-extern u32 _osContPifCtrl;
-#endif
-
-#endif
diff --git a/src/os/osContStartReadData.c b/src/os/osContStartReadData.c
index dd80ee70c..f559a6347 100644
--- a/src/os/osContStartReadData.c
+++ b/src/os/osContStartReadData.c
@@ -1,16 +1,7 @@
#include "libultra_internal.h"
-#include "osContInternal.h"
+#include "controller.h"
#include <macros.h>
-#ifndef AVOID_UB
-ALIGNED8 OSContPackedStruct _osContCmdBuf[7];
-UNUSED static u32 unused; // padding between these two variables
-u32 _osContPifCtrl;
-#else
-// Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB.
-ALIGNED8 OSContPackedStruct _osContCmdBuf[8];
-#endif
-
extern u8 __osContLastCmd;
extern u8 _osContNumControllers;
@@ -18,56 +9,66 @@ void __osPackReadData(void);
s32 osContStartReadData(OSMesgQueue* mesg) {
s32 ret = 0;
s32 i;
+
__osSiGetAccess();
- if (__osContLastCmd != 1) {
+
+ if (__osContLastCmd != CONT_CMD_READ_BUTTON) {
__osPackReadData();
- ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
+ ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
osRecvMesg(mesg, NULL, OS_MESG_BLOCK);
}
- for (i = 0; i < 0x10; i++) {
- *((u32*) &_osContCmdBuf + i) = 255;
+
+ for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
+ __osContPifRam.ramarray[i] = CONT_CMD_NOP;
}
- _osContPifCtrl = 0;
- ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
- __osContLastCmd = 1;
+ __osContPifRam.pifstatus = 0;
+ ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
+ __osContLastCmd = CONT_CMD_READ_BUTTON;
+
__osSiRelAccess();
+
return ret;
}
void osContGetReadData(OSContPad* pad) {
- OSContPackedRead* cmdBufPtr;
- OSContPackedRead response;
+ u8* ptr = (u8*) __osContPifRam.ramarray;
+ __OSContReadFormat readformat;
s32 i;
- cmdBufPtr = &_osContCmdBuf[0].read;
- for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) {
- response = *cmdBufPtr;
- pad->errno = (response.rxLen & 0xc0) >> 4;
- if (pad->errno == 0) {
- pad->button = response.button;
- pad->stick_x = response.rawStickX;
- pad->stick_y = response.rawStickY;
+
+ for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(readformat), pad++) {
+ readformat = *(__OSContReadFormat*) ptr;
+ pad->errno = CHNL_ERR(readformat);
+
+ if (pad->errno != 0) {
+ continue;
}
- };
+
+ pad->button = readformat.button;
+ pad->stick_x = readformat.stick_x;
+ pad->stick_y = readformat.stick_y;
+ }
}
void __osPackReadData() {
- OSContPackedRead* cmdBufPtr;
- OSContPackedRead request;
+ u8* ptr = (u8*) __osContPifRam.ramarray;
+ __OSContReadFormat readformat;
s32 i;
- cmdBufPtr = &_osContCmdBuf[0].read;
- for (i = 0; i < 0x10; i++) {
- *((u32*) &_osContCmdBuf + i) = 0;
+
+ for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
+ __osContPifRam.ramarray[i] = 0;
}
- _osContPifCtrl = 1;
- request.padOrEnd = 255;
- request.txLen = 1;
- request.rxLen = 4;
- request.command = 1;
- request.button = 65535;
- request.rawStickX = -1;
- request.rawStickY = -1;
+ __osContPifRam.pifstatus = CONT_CMD_EXE;
+ readformat.dummy = CONT_CMD_NOP;
+ readformat.txsize = CONT_CMD_READ_BUTTON_TX;
+ readformat.rxsize = CONT_CMD_READ_BUTTON_RX;
+ readformat.cmd = CONT_CMD_READ_BUTTON;
+ readformat.button = 0xFFFF;
+ readformat.stick_x = -1;
+ readformat.stick_y = -1;
+
for (i = 0; i < _osContNumControllers; i++) {
- *cmdBufPtr++ = request;
+ *(__OSContReadFormat*) ptr = readformat;
+ ptr += sizeof(readformat);
}
- cmdBufPtr->padOrEnd = 254;
+ *ptr = CONT_CMD_END;
}
diff --git a/src/os/osCreateMesgQueue.c b/src/os/osCreateMesgQueue.c
index 1b5c011da..865a49b2b 100644
--- a/src/os/osCreateMesgQueue.c
+++ b/src/os/osCreateMesgQueue.c
@@ -1,11 +1,10 @@
#include "libultra_internal.h"
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msgBuf, s32 count) {
- mq->mtqueue = (OSThread*) &__osThreadTail; //?
- mq->fullqueue = (OSThread*) &__osThreadTail;
+ mq->mtqueue = (OSThread*) &__osThreadTail.next;
+ mq->fullqueue = (OSThread*) &__osThreadTail.next;
mq->validCount = 0;
mq->first = 0;
mq->msgCount = count;
mq->msg = msgBuf;
- return;
}
diff --git a/src/os/osCreatePiManager.c b/src/os/osCreatePiManager.c
index b76cc0f7b..cfbd61196 100644
--- a/src/os/osCreatePiManager.c
+++ b/src/os/osCreatePiManager.c
@@ -44,8 +44,8 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
__osPiDevMgr.cmdQueue = cmdQ;
__osPiDevMgr.eventQueue = &__osPiMesgQueue;
__osPiDevMgr.accessQueue = &gOsPiMessageQueue;
- __osPiDevMgr.piDmaCallback = osPiRawStartDma;
- __osPiDevMgr.epiDmaCallback = osEPiRawStartDma;
+ __osPiDevMgr.dma_func = osPiRawStartDma;
+ __osPiDevMgr.edma_func = osEPiRawStartDma;
osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void*) &__osPiDevMgr, &piMgrStack[0x400], pri);
osStartThread(&piMgrThread);
__osRestoreInt(int_disabled);
diff --git a/src/os/osEepromRead.c b/src/os/osEepromRead.c
index a6545ce4f..e9f45d072 100644
--- a/src/os/osEepromRead.c
+++ b/src/os/osEepromRead.c
@@ -35,7 +35,7 @@ s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) {
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
+ for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
__osEepPifRam.pifstatus = 0;
@@ -66,7 +66,7 @@ void __osPackEepReadData(u8 address) {
__OSContEepromFormat eepromformat;
s32 i;
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
+ for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
__osEepPifRam.pifstatus = CONT_CMD_EXE;
@@ -75,7 +75,7 @@ void __osPackEepReadData(u8 address) {
eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX;
eepromformat.cmd = CONT_CMD_READ_EEPROM;
eepromformat.address = address;
- for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
+ for (i = 0; i < ARRLEN(eepromformat.data); i++) {
eepromformat.data[i] = 0;
}
diff --git a/src/os/osEepromWrite.c b/src/os/osEepromWrite.c
index faa99d91d..03eaf63e9 100644
--- a/src/os/osEepromWrite.c
+++ b/src/os/osEepromWrite.c
@@ -1,5 +1,4 @@
#include "libultra_internal.h"
-#include "osContInternal.h"
#include "controller.h"
#include "macros.h"
@@ -37,7 +36,7 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
+ for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
@@ -61,7 +60,7 @@ void __osPackEepWriteData(u8 address, u8* buffer) {
__OSContEepromFormat eepromformat;
s32 i;
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
+ for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
}
__osEepPifRam.pifstatus = CONT_CMD_EXE;
@@ -71,7 +70,7 @@ void __osPackEepWriteData(u8 address, u8* buffer) {
eepromformat.cmd = CONT_CMD_WRITE_EEPROM;
eepromformat.address = address;
- for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
+ for (i = 0; i < ARRLEN(eepromformat.data); i++) {
eepromformat.data[i] = *buffer++;
}
@@ -89,7 +88,7 @@ s32 __osEepStatus(OSMesgQueue* mq, OSContStatus* data) {
u8* ptr = (u8*) __osEepPifRam.ramarray;
__OSContRequesFormat requestformat;
- for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
+ for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
__osEepPifRam.ramarray[i] = 0;
}
__osEepPifRam.pifstatus = CONT_CMD_EXE;
diff --git a/src/os/osViSwapBuffer.c b/src/os/osViSwapBuffer.c
index f8db8084e..d830f35a9 100644
--- a/src/os/osViSwapBuffer.c
+++ b/src/os/osViSwapBuffer.c
@@ -6,6 +6,6 @@ void osViSwapBuffer(void* vaddr) {
u32 int_disabled = __osDisableInt();
__osViNext->buffer = vaddr;
//! @todo figure out what this flag means
- __osViNext->state |= 0x10;
+ __osViNext->unk00 |= 0x10;
__osRestoreInt(int_disabled);
}
diff --git a/src/racing/math_util.c b/src/racing/math_util.c
index 44e07e6aa..a243a066e 100644
--- a/src/racing/math_util.c
+++ b/src/racing/math_util.c
@@ -419,7 +419,7 @@ void func_802B5CAC(s16 arg0, s16 arg1, Vec3f arg2) {
}
void func_802B5D30(s16 arg0, s16 arg1, s32 arg2) {
- func_802B5D64(0x9000000, arg0, arg1, arg2);
+ func_802B5D64((Lights1*) 0x9000000, arg0, arg1, arg2);
}
void func_802B5D64(Lights1* addr, s16 arg1, s16 arg2, s32 arg3) {
diff --git a/src/racing/math_util.h b/src/racing/math_util.h
index e322724ad..a9c396ad6 100644
--- a/src/racing/math_util.h
+++ b/src/racing/math_util.h
@@ -4,6 +4,9 @@
#include <libultraship.h>
#include <common_structs.h>
+// #define sins(x) gSineTable[(u16) (x) >> 4]
+// #define coss(x) gCosineTable[(u16) (x) >> 4]
+
// #define min(a, b) ((a) <= (b) ? (a) : (b))
// #define max(a, b) ((a) > (b) ? (a) : (b))
diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c
index b73833fc5..4f7ea8c50 100644
--- a/src/racing/race_logic.c
+++ b/src/racing/race_logic.c
@@ -144,16 +144,16 @@ void func_8028E3A0(void) {
if (D_80150120) {
- if (gCupCourseSelection == CUP_COURSE_FOUR) {
+ if (gCourseIndexInCup == COURSE_FOUR) {
gGotoMode = ENDING;
} else {
D_800DC544++;
- gCupCourseSelection++;
+ gCourseIndexInCup++;
gGotoMode = RACING;
}
} else {
D_800DC544++;
- gCupCourseSelection++;
+ gCourseIndexInCup++;
gGotoMode = RACING;
}
}
diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c
index 9ce24b7d3..00283ca8c 100644
--- a/src/racing/render_courses.c
+++ b/src/racing/render_courses.c
@@ -78,7 +78,7 @@ extern u32 isFlycam;
void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1) {
Player* player = arg1->player;
Camera* camera = arg1->camera;
- s16 var_a3;
+ s16 direction;
s16 index;
s16 sp1E;
s16 temp_v0_3;
@@ -86,31 +86,31 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1)
if (gIsMirrorMode) {
rot = (u16) camera->rot[1];
if (rot < 0x2000) {
- var_a3 = 2;
+ direction = SOUTH;
} else if (rot < 0x6000) {
- var_a3 = 3;
+ direction = WEST;
} else if (rot < 0xA000) {
- var_a3 = 0;
+ direction = NORTH;
} else if (rot < 0xE000) {
- var_a3 = 1;
+ direction = EAST;
} else {
- var_a3 = 2;
+ direction = SOUTH;
}
} else {
rot = (u16) camera->rot[1];
if (rot < 0x2000) {
- var_a3 = 2;
+ direction = SOUTH;
} else if (rot < 0x6000) {
- var_a3 = 1;
+ direction = EAST;
} else if (rot < 0xA000) {
- var_a3 = 0;
+ direction = NORTH;
} else if (rot < 0xE000) {
- var_a3 = 3;
+ direction = WEST;
} else {
- var_a3 = 2;
+ direction = SOUTH;
}
}
- arg1->playerDirection = var_a3;
+ arg1->playerDirection = direction;
if (D_80152300[camera - camera1] == 1) {
sp1E = get_track_section_id(camera->collision.meshIndexZX);
@@ -176,7 +176,7 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC* arg1)
}
arg1->pathCounter = index;
- index = ((index - 1) * 4) + var_a3;
+ index = ((index - 1) * 4) + direction;
gSPDisplayList(gDisplayListHead++, addr[index]);
if (CVarGetInteger("gDisableLod", 0) == 1 && gCurrentCourseId == COURSE_BOWSER_CASTLE &&
@@ -530,7 +530,7 @@ void func_8029122C(struct UnkStruct_800DC5EC* arg0, s32 playerId) {
void render_mario_raceway(struct UnkStruct_800DC5EC* arg0) {
UNUSED s32 pad;
u16 sp22 = arg0->pathCounter;
- u16 temp_t0 = arg0->playerDirection;
+ u16 playerDirection = arg0->playerDirection;
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
@@ -551,20 +551,20 @@ void render_mario_raceway(struct UnkStruct_800DC5EC* arg0) {
case 1:
case 2:
case 17:
- if ((temp_t0 == 2) || (temp_t0 == 1)) {
+ if ((playerDirection == 2) || (playerDirection == 1)) {
func_802911C4();
}
break;
case 3:
- if (temp_t0 != 0) {
+ if (playerDirection != 0) {
func_802911C4();
}
break;
case 4:
- if (temp_t0 == 0) {
+ if (playerDirection == 0) {
func_80291198();
} else {
- if (temp_t0 == 1) {
+ if (playerDirection == 1) {
func_80291198();
}
func_802911C4();
@@ -572,7 +572,7 @@ void render_mario_raceway(struct UnkStruct_800DC5EC* arg0) {
break;
case 5:
case 6:
- if ((temp_t0 == 2) || (temp_t0 == 3)) {
+ if ((playerDirection == 2) || (playerDirection == 3)) {
func_802911C4();
} else {
func_80291198();
@@ -580,37 +580,37 @@ void render_mario_raceway(struct UnkStruct_800DC5EC* arg0) {
break;
case 7:
func_80291198();
- if ((temp_t0 == 2) || (temp_t0 == 3)) {
+ if ((playerDirection == 2) || (playerDirection == 3)) {
func_802911C4();
}
break;
case 8:
case 9:
- if (temp_t0 != 1) {
+ if (playerDirection != 1) {
func_802911C4();
}
/* fallthrough */
case 10:
- if (temp_t0 != 2) {
+ if (playerDirection != 2) {
func_80291198();
}
break;
case 11:
- if (temp_t0 == 0) {
+ if (playerDirection == 0) {
func_802911C4();
func_80291198();
- } else if (temp_t0 == 3) {
+ } else if (playerDirection == 3) {
func_802911C4();
}
break;
case 12:
- if ((temp_t0 == 0) || (temp_t0 == 3)) {
+ if ((playerDirection == 0) || (playerDirection == 3)) {
func_802911C4();
}
break;
case 13:
case 14:
- if (temp_t0 != 1) {
+ if (playerDirection != 1) {
case 15:
case 16:
func_802911C4();
@@ -712,7 +712,7 @@ void render_bowsers_castle(struct UnkStruct_800DC5EC* arg0) {
if (D_802B87BC > 255) {
D_802B87BC = 0;
}
- render_course_segments(bowsers_castle_dls, arg0);
+ render_course_segments((uintptr_t) bowsers_castle_dls, arg0);
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
@@ -785,7 +785,7 @@ void render_yoshi_valley(struct UnkStruct_800DC5EC* arg0) {
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
- render_course_segments(yoshi_valley_dls, arg0);
+ render_course_segments((uintptr_t) d_course_yoshi_valley_dl_list, arg0);
gDPPipeSync(gDisplayListHead++);
}
@@ -804,7 +804,7 @@ void render_frappe_snowland(struct UnkStruct_800DC5EC* arg0) {
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
- render_course_segments(frappe_snowland_dls, arg0);
+ render_course_segments((uintptr_t) d_course_frappe_snowland_dl_list, arg0);
}
void render_koopa_troopa_beach(struct UnkStruct_800DC5EC* arg0) {
@@ -824,7 +824,7 @@ void render_koopa_troopa_beach(struct UnkStruct_800DC5EC* arg0) {
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
// d_course_koopa_troopa_beach_packed_dl_9688
gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(0x07009688));
- render_course_segments(koopa_troopa_beach_dls1, arg0);
+ render_course_segments(d_course_koopa_troopa_beach_dl_list1, arg0);
gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
@@ -971,7 +971,7 @@ void render_luigi_raceway(struct UnkStruct_800DC5EC* arg0) {
void render_moo_moo_farm(struct UnkStruct_800DC5EC* arg0) {
UNUSED s32 pad[13];
s16 temp_s0 = arg0->pathCounter;
- s16 temp_s1 = arg0->playerDirection;
+ s16 playerDirection = arg0->playerDirection;
func_802B5D64(D_800DC610, D_802B87D4, 0, 1);
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
@@ -988,53 +988,50 @@ void render_moo_moo_farm(struct UnkStruct_800DC5EC* arg0) {
render_course_segments(moo_moo_farm_dls, arg0);
if ((temp_s0 < 14) && (temp_s0 > 10)) {
- if ((temp_s1 == 2) || (temp_s1 == 3) || (temp_s1 == 1)) {
+ if ((playerDirection == 2) || (playerDirection == 3) || (playerDirection == 1)) {
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8);
}
} else if (temp_s0 < 16) {
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8);
} else if (temp_s0 < 19) {
- if (temp_s1 != 2) {
+ if (playerDirection != 2)
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8);
- }
} else if (temp_s0 < 20) {
- if (temp_s1 == 0) {
+ if (playerDirection == 0)
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8);
- }
}
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
if ((temp_s0 >= 16) && (temp_s0 < 24)) {
- if ((temp_s1 == 2) || (temp_s1 == 3)) {
+ if ((playerDirection == 2) || (playerDirection == 3)) {
// d_course_moo_moo_farm_packed_dl_5410
gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(0x07005410));
}
} else if (temp_s0 < 9) {
- if (temp_s1 == 2) {
+ if (playerDirection == 2) {
// d_course_moo_moo_farm_packed_dl_5410
gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(0x07005410));
}
}
if (temp_s0 < 4) {
- if (temp_s1 != 0) {
+ if (playerDirection != 0) {
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060);
}
} else if (temp_s0 < 8) {
- if (temp_s1 == 2) {
+ if (playerDirection == 2) {
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060);
}
} else if (temp_s0 >= 22) {
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060);
} else if (temp_s0 >= 18) {
- if ((temp_s1 == 0) || (temp_s1 == 3)) {
+ if ((playerDirection == 0) || (playerDirection == 3))
gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060);
- }
}
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
@@ -1056,7 +1053,7 @@ void render_toads_turnpike(struct UnkStruct_800DC5EC* arg0) {
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_PASS2);
gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2);
- render_course_segments(toads_turnpike_dls, arg0);
+ render_course_segments((uintptr_t) d_course_toads_turnpike_dl_list, arg0);
gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2);
gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_PASS2);
@@ -1111,7 +1108,7 @@ void render_sherbet_land(struct UnkStruct_800DC5EC* arg0) {
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
- render_course_segments(sherbet_land_dls, arg0);
+ render_course_segments((uintptr_t) sherbet_land_dls, arg0);
}
void render_rainbow_road(UNUSED struct UnkStruct_800DC5EC* arg0) {
@@ -1275,7 +1272,7 @@ void render_dks_jungle_parkway(struct UnkStruct_800DC5EC* arg0) {
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
- render_course_segments(dks_jungle_parkway_dls, arg0);
+ render_course_segments((uintptr_t) d_course_dks_jungle_parkway_unknown_dl_list, arg0);
gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK);
}
diff --git a/src/render_objects.c b/src/render_objects.c
index 8ea3f0080..f85072faa 100644
--- a/src/render_objects.c
+++ b/src/render_objects.c
@@ -4274,7 +4274,7 @@ void func_800557B4(s32 objectIndex, u32 arg1, u32 arg2) {
object->sizeScaling);
gSPDisplayList(gDisplayListHead++, D_0D0077D0);
render_animated_model((Armature*) object->model, (Animation**) object->vertex,
- (s16) object->unk_0D8, (s16) object->itemDisplay);
+ (s16) object->unk_0D8, (s16) object->textureListIndex);
}
} else if (arg1 < 0x15F91U) {
func_8004A7AC(objectIndex, 1.5f);
@@ -4283,7 +4283,7 @@ void func_800557B4(s32 objectIndex, u32 arg1, u32 arg2) {
rsp_set_matrix_transformation(object->pos, object->orientation, object->sizeScaling);
gSPDisplayList(gDisplayListHead++, D_0D0077D0);
render_animated_model((Armature*) object->model, (Animation**) object->vertex, (s16) object->unk_0D8,
- (s16) object->itemDisplay);
+ (s16) object->textureListIndex);
}
}
@@ -4352,7 +4352,7 @@ void func_80055AB8(s32 objectIndex, s32 cameraId) {
gSPDisplayList(gDisplayListHead++, D_0D0077D0);
render_animated_model((Armature*) gObjectList[objectIndex].model,
(Animation**) gObjectList[objectIndex].vertex, 0,
- (s16) gObjectList[objectIndex].itemDisplay);
+ (s16) gObjectList[objectIndex].textureListIndex);
}
}
}
diff --git a/src/save.c b/src/save.c
index e4c2fd851..fb52a9e9f 100644
--- a/src/save.c
+++ b/src/save.c
@@ -246,10 +246,9 @@ u32 func_800B4DF4(u8* arr) {
// Get a time trial record, infer course index
s32 func_800B4E24(s32 recordIndex) {
- return func_800B4DF4(
- gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCupCourseSelection) / 4)]
- .courseRecords[(((gCupSelection * 4) + gCupCourseSelection) % 4)]
- .records[recordIndex]);
+ return func_800B4DF4(gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCourseIndexInCup) / 4)]
+ .courseRecords[(((gCupSelection * 4) + gCourseIndexInCup) % 4)]
+ .records[recordIndex]);
}
// Get a time trial record, but take the course index as an argument
@@ -261,10 +260,9 @@ u32 func_800B4EB4(s32 recordIndex, s32 courseIndex) {
// Get Best Lap record of the inferred course index
s32 func_800B4F2C(void) {
- return func_800B4DF4(
- gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCupCourseSelection) / 4)]
- .courseRecords[(((gCupSelection * 4) + gCupCourseSelection) % 4)]
- .records[TIME_TRIAL_1LAP_RECORD]);
+ return func_800B4DF4(gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCourseIndexInCup) / 4)]
+ .courseRecords[(((gCupSelection * 4) + gCourseIndexInCup) % 4)]
+ .records[TIME_TRIAL_1LAP_RECORD]);
}
// Get the best single lap time record of the given course index
@@ -281,7 +279,7 @@ s32 func_800B5020(u32 time, s32 charId) {
s32 j;
CourseTimeTrialRecords* tt;
- course = gCupSelection * 4 + gCupCourseSelection;
+ course = gCupSelection * 4 + gCourseIndexInCup;
tt = &gSaveData.allCourseTimeTrialRecords.cupRecords[course / 4].courseRecords[course % 4];
i = 0;
@@ -328,7 +326,7 @@ s32 func_800B5218(void) {
s32 checkLapIndex;
s32 character;
s32 lapBitmask;
- recordIndex = (gCupSelection * 4) + gCupCourseSelection;
+ recordIndex = (gCupSelection * 4) + gCourseIndexInCup;
recordPointer =
&gSaveData.allCourseTimeTrialRecords.cupRecords[recordIndex / 4].courseRecords[recordIndex % 4].records[0][0];
lapBitmask = 1;
@@ -787,7 +785,7 @@ s32 func_800B6178(s32 arg0) {
if (var_v0 == 0) {
temp_s3->ghostDataSaved = 1;
if (gGamestate == 4) {
- temp_s3->courseIndex = (gCupSelection * 4) + gCupCourseSelection;
+ temp_s3->courseIndex = (gCupSelection * 4) + gCourseIndexInCup;
}
temp_s3->unk_00 = D_80162DFC;
temp_s3->characterId = (u8) D_80162DE0;
@@ -836,7 +834,7 @@ s32 func_800B63F0(s32 arg0) {
func_80005AE8(gPlayerThree);
phi_s3 = 0;
- if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) {
+ if (((gCupSelection * 4) + gCourseIndexInCup) != D_8018EE10[arg0].courseIndex) {
phi_s3 = 2;
} else if (D_80162DFC != D_8018EE10[arg0].unk_00) {
phi_s3 = 3;
diff --git a/src/spawn_players.c b/src/spawn_players.c
index af103b653..480707f47 100644
--- a/src/spawn_players.c
+++ b/src/spawn_players.c
@@ -486,7 +486,7 @@ void func_80039DA4(void) {
0, 1, 2, 3, 4, 5, 6, 7,
};
- if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) ||
+ if (((gCourseIndexInCup == COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) ||
(gDebugMenuSelection == DEBUG_MENU_EXITED)) {
for (i = 0; i < NUM_PLAYERS; i++) {
D_80165270[i] = sp2C[i];
@@ -504,7 +504,7 @@ UNUSED s16 D_800E43A8 = 0;
void spawn_players_gp_one_player(f32* arg0, f32* arg1, f32 arg2) {
func_80039DA4();
- if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) ||
+ if (((gCourseIndexInCup == COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) ||
(gDebugMenuSelection == DEBUG_MENU_EXITED)) {
s16 rand;
s16 i;
@@ -638,7 +638,7 @@ void spawn_players_versus_one_player(f32* arg0, f32* arg1, f32 arg2) {
void spawn_players_gp_two_player(f32* arg0, f32* arg1, f32 arg2) {
func_80039DA4();
- if ((gCupCourseSelection == CUP_COURSE_ONE) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) {
+ if ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) {
s16 rand;
s16 i;
diff --git a/src/textures.h b/src/textures.h
index fa2cb9c69..7536c07c9 100644
--- a/src/textures.h
+++ b/src/textures.h
@@ -1,8 +1,12 @@
#ifndef TEXTURES_H
#define TEXTURES_H
+#ifndef TARGET_N64
#include <libultraship.h>
#include <assets/texture_tkmk00.h>
+#else
+#include <PR/ultratypes.h>
+#endif
/**
* @brief struct for a texture use in menu mainly
diff --git a/src/update_objects.c b/src/update_objects.c
index 2c3c2481f..a0ea003c8 100644
--- a/src/update_objects.c
+++ b/src/update_objects.c
@@ -270,8 +270,8 @@ bool func_80072354(s32 objectIndex, s32 arg1) {
return b;
}
-void set_object_unk_0CB(s32 objectIndex, s32 arg1) {
- gObjectList[objectIndex].unk_0CB = arg1;
+void set_object_timer_state(s32 objectIndex, s32 arg1) {
+ gObjectList[objectIndex].isTimerActive = arg1;
}
void init_object(s32 objectIndex, s32 arg1) {
@@ -280,27 +280,27 @@ void init_object(s32 objectIndex, s32 arg1) {
gObjectList[objectIndex].unk_05C = 0;
gObjectList[objectIndex].unk_0CD = 0;
gObjectList[objectIndex].unk_0CF = 0;
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
gObjectList[objectIndex].unk_0D8 = arg1;
gObjectList[objectIndex].state = 1;
}
UNUSED void func_80072408(s32 objectIndex) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
}
void func_80072428(s32 objectIndex) {
gObjectList[objectIndex].state = 0;
gObjectList[objectIndex].unk_0D8 = 0;
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
gObjectList[objectIndex].status = 0;
gObjectList[objectIndex].unk_058 = 0;
gObjectList[objectIndex].unk_05C = 0;
func_80086F60(objectIndex);
}
-void func_80072488(s32 objectIndex) {
- set_object_unk_0CB(objectIndex, 0);
+void object_next_state(s32 objectIndex) {
+ set_object_timer_state(objectIndex, 0);
set_object_flag_status_false(objectIndex, 0x2000);
gObjectList[objectIndex].state++;
}
@@ -320,16 +320,16 @@ s16 func_80072530(s32 objectIndex) {
}
void func_80072568(s32 objectIndex, s32 arg1) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
set_object_flag_status_false(objectIndex, 0x2000);
set_object_flag_status_false(objectIndex, 8);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_800724F8(objectIndex, gObjectList[objectIndex].state);
gObjectList[objectIndex].state = arg1;
}
void func_800725E8(s32 objectIndex, s32 arg1, s32 arg2) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
set_object_flag_status_false(objectIndex, 0x2000);
set_object_flag_status_false(objectIndex, 8);
gObjectList[objectIndex].state = arg2;
@@ -340,44 +340,47 @@ void func_800725E8(s32 objectIndex, s32 arg1, s32 arg2) {
s16 func_80072530(s32); // extern
void func_8007266C(s32 objectIndex) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
set_object_flag_status_false(objectIndex, 0x2000);
set_object_flag_status_false(objectIndex, 8);
gObjectList[objectIndex].state = func_80072530(objectIndex);
}
void func_800726CC(s32 objectIndex, s32 arg1) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
set_object_flag_status_false(objectIndex, 0x2000);
gObjectList[objectIndex].state = arg1;
}
UNUSED void func_8007271C(s32 objectIndex, s32 arg1) {
- if (gObjectList[objectIndex].unk_0CB == 0) {
+ if (gObjectList[objectIndex].isTimerActive == 0) {
gObjectList[objectIndex].state = arg1;
}
}
UNUSED void func_8007274C(s32 objectIndex) {
- if (gObjectList[objectIndex].unk_0CB == 0) {
- func_80072488(objectIndex);
+ if (gObjectList[objectIndex].isTimerActive == 0) {
+ object_next_state(objectIndex);
}
}
-s32 func_8007278C(s32 objectIndex, s32 arg1) {
- s32 phi_v1;
+/**
+ * @brief will return true if the timer is done
+ */
+bool set_and_run_timer_object(s32 objectIndex, s32 timer) {
+ bool phi_v1;
- phi_v1 = 0;
- if (gObjectList[objectIndex].unk_0CB == 0) {
- set_object_unk_0CB(objectIndex, 1);
- gObjectList[objectIndex].unk_050 = arg1;
+ phi_v1 = false;
+ if (gObjectList[objectIndex].isTimerActive == false) {
+ set_object_timer_state(objectIndex, true);
+ gObjectList[objectIndex].timer = timer;
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
- phi_v1 = 1;
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ set_object_timer_state(objectIndex, false);
+ object_next_state(objectIndex);
+ phi_v1 = true;
}
return phi_v1;
@@ -387,15 +390,15 @@ UNUSED s32 func_8007281C(s32 objectIndex, s32 arg1) {
s32 phi_a2;
phi_a2 = 0;
- if (gObjectList[objectIndex].unk_0CB == 0) {
- set_object_unk_0CB(objectIndex, 1);
- gObjectList[objectIndex].unk_050 = random_int((u16) arg1);
+ if (gObjectList[objectIndex].isTimerActive == 0) {
+ set_object_timer_state(objectIndex, 1);
+ gObjectList[objectIndex].timer = random_int((u16) arg1);
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
phi_a2 = 1;
}
@@ -407,15 +410,15 @@ UNUSED s32 func_800728B0(s32 objectIndex, s32 arg1, s32 arg2) {
s32 phi_a3;
phi_a3 = 0;
- if (gObjectList[objectIndex].unk_0CB == 0) {
- set_object_unk_0CB(objectIndex, 1);
- gObjectList[objectIndex].unk_050 = random_int((u16) arg2) + arg1;
+ if (gObjectList[objectIndex].isTimerActive == 0) {
+ set_object_timer_state(objectIndex, 1);
+ gObjectList[objectIndex].timer = random_int((u16) arg2) + arg1;
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
phi_a3 = 1;
}
@@ -451,7 +454,7 @@ void func_800729EC(s32 objectIndex) {
s32 i;
start_race();
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
D_8018D2BC = 1;
D_8018D2A4 = 1;
@@ -464,25 +467,25 @@ void func_800729EC(s32 objectIndex) {
}
UNUSED void func_80072A78(s32 objectIndex, s32 arg1) {
- gObjectList[objectIndex].itemDisplay = arg1;
- func_80072488(objectIndex);
+ gObjectList[objectIndex].textureListIndex = arg1;
+ object_next_state(objectIndex);
}
s32 func_80072AAC(s32 objectIndex, s32 arg1, s32 arg2) {
s32 phi_v1;
phi_v1 = 0;
- if (gObjectList[objectIndex].unk_0CB == 0) {
+ if (gObjectList[objectIndex].isTimerActive == 0) {
- set_object_unk_0CB(objectIndex, 1);
- gObjectList[objectIndex].itemDisplay = arg1;
- gObjectList[objectIndex].unk_050 = arg2;
+ set_object_timer_state(objectIndex, 1);
+ gObjectList[objectIndex].textureListIndex = arg1;
+ gObjectList[objectIndex].timer = arg2;
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
phi_v1 = 1;
}
@@ -493,18 +496,18 @@ s32 func_80072B48(s32 objectIndex, s32 arg1) {
s32 phi_v1;
phi_v1 = 0;
- if (gObjectList[objectIndex].unk_0CB == 0) {
- set_object_unk_0CB(objectIndex, 1);
+ if (gObjectList[objectIndex].isTimerActive == 0) {
+ set_object_timer_state(objectIndex, 1);
set_object_flag_status_true(objectIndex, 0x80000);
- gObjectList[objectIndex].itemDisplay = D_8018D140;
- gObjectList[objectIndex].unk_050 = arg1;
+ gObjectList[objectIndex].textureListIndex = D_8018D140;
+ gObjectList[objectIndex].timer = arg1;
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
set_object_flag_status_false(objectIndex, 0x80000);
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
phi_v1 = 1;
}
@@ -513,15 +516,15 @@ s32 func_80072B48(s32 objectIndex, s32 arg1) {
void func_80072C00(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3) {
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].unk_050 = arg2;
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].timer = arg2;
+ gObjectList[objectIndex].textureListIndex = arg1;
gObjectList[objectIndex].unk_0D4 = 1;
gObjectList[objectIndex].unk_0CC = arg3;
set_object_flag_status_true(objectIndex, 0x2000);
} else {
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- gObjectList[objectIndex].unk_050 = arg2;
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ gObjectList[objectIndex].timer = arg2;
gObjectList[objectIndex].unk_0D4--;
if ((gObjectList[objectIndex].unk_0D4 & 1) != 0) {
set_object_flag_status_false(objectIndex, 0x80000);
@@ -538,7 +541,7 @@ void func_80072C00(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3) {
if (gObjectList[objectIndex].unk_0CC == 0) {
set_object_flag_status_false(objectIndex, 0x2000);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
}
}
@@ -547,22 +550,22 @@ void func_80072C00(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3) {
void func_80072D3C(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].unk_050 = arg3;
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].timer = arg3;
+ gObjectList[objectIndex].textureListIndex = arg1;
gObjectList[objectIndex].unk_0D4 = 1;
gObjectList[objectIndex].unk_0CC = arg4;
set_object_flag_status_true(objectIndex, 0x2000);
return;
}
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 < 0) {
- gObjectList[objectIndex].unk_050 = arg3;
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer < 0) {
+ gObjectList[objectIndex].timer = arg3;
gObjectList[objectIndex].unk_0D4--;
if ((gObjectList[objectIndex].unk_0D4 & 1) != 0) {
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].textureListIndex = arg1;
} else {
- gObjectList[objectIndex].itemDisplay = arg2;
+ gObjectList[objectIndex].textureListIndex = arg2;
}
if (gObjectList[objectIndex].unk_0D4 < 0) {
@@ -573,7 +576,7 @@ void func_80072D3C(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
if (gObjectList[objectIndex].unk_0CC == 0) {
set_object_flag_status_false(objectIndex, 0x2000);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
}
}
@@ -584,29 +587,29 @@ s32 func_80072E54(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 a
sp24 = 0;
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].itemDisplay = arg1;
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].textureListIndex = arg1;
+ gObjectList[objectIndex].timer = arg4;
gObjectList[objectIndex].unk_0CC = arg5;
- set_object_unk_0CB(objectIndex, 1);
+ set_object_timer_state(objectIndex, 1);
set_object_flag_status_true(objectIndex, 0x2000);
} else {
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 <= 0) {
- gObjectList[objectIndex].unk_050 = arg4;
- gObjectList[objectIndex].itemDisplay += arg3;
- if (arg2 < gObjectList[objectIndex].itemDisplay) {
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer <= 0) {
+ gObjectList[objectIndex].timer = arg4;
+ gObjectList[objectIndex].textureListIndex += arg3;
+ if (arg2 < gObjectList[objectIndex].textureListIndex) {
if (gObjectList[objectIndex].unk_0CC > 0) {
gObjectList[objectIndex].unk_0CC--;
}
if (gObjectList[objectIndex].unk_0CC == 0) {
- gObjectList[objectIndex].itemDisplay = arg2;
+ gObjectList[objectIndex].textureListIndex = arg2;
set_object_flag_status_false(objectIndex, 0x2000);
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
sp24 = 1;
} else {
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].textureListIndex = arg1;
}
}
}
@@ -619,28 +622,28 @@ bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32
sp24 = false;
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].itemDisplay = arg1;
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].textureListIndex = arg1;
+ gObjectList[objectIndex].timer = arg4;
gObjectList[objectIndex].unk_0CC = arg5;
- set_object_unk_0CB(objectIndex, 1);
+ set_object_timer_state(objectIndex, 1);
set_object_flag_status_true(objectIndex, 0x2000);
} else {
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 <= 0) {
- gObjectList[objectIndex].unk_050 = arg4;
- gObjectList[objectIndex].itemDisplay -= arg3;
- if (gObjectList[objectIndex].itemDisplay < arg2) {
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer <= 0) {
+ gObjectList[objectIndex].timer = arg4;
+ gObjectList[objectIndex].textureListIndex -= arg3;
+ if (gObjectList[objectIndex].textureListIndex < arg2) {
if (gObjectList[objectIndex].unk_0CC > 0) {
gObjectList[objectIndex].unk_0CC--;
}
if (gObjectList[objectIndex].unk_0CC == 0) {
- gObjectList[objectIndex].itemDisplay = arg2;
+ gObjectList[objectIndex].textureListIndex = arg2;
set_object_flag_status_false(objectIndex, 0x2000);
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
sp24 = true;
} else {
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].textureListIndex = arg1;
}
}
}
@@ -653,26 +656,26 @@ bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32
sp24 = false;
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].itemDisplay = arg1;
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].textureListIndex = arg1;
+ gObjectList[objectIndex].timer = arg4;
gObjectList[objectIndex].unk_0CC = arg5;
- set_object_unk_0CB(objectIndex, 1);
+ set_object_timer_state(objectIndex, 1);
set_object_flag_status_true(objectIndex, 0x2000);
set_object_flag_status_false(objectIndex, 0x4000);
} else {
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 <= 0) {
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer <= 0) {
+ gObjectList[objectIndex].timer = arg4;
if (is_obj_index_flag_status_inactive(objectIndex, 0x4000) != 0) {
- gObjectList[objectIndex].itemDisplay += arg3;
- if (gObjectList[objectIndex].itemDisplay >= arg2) {
- gObjectList[objectIndex].itemDisplay = arg2;
+ gObjectList[objectIndex].textureListIndex += arg3;
+ if (gObjectList[objectIndex].textureListIndex >= arg2) {
+ gObjectList[objectIndex].textureListIndex = arg2;
set_object_flag_status_true(objectIndex, 0x4000);
}
} else {
- gObjectList[objectIndex].itemDisplay -= arg3;
- if (arg1 >= gObjectList[objectIndex].itemDisplay) {
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].textureListIndex -= arg3;
+ if (arg1 >= gObjectList[objectIndex].textureListIndex) {
+ gObjectList[objectIndex].textureListIndex = arg1;
if (gObjectList[objectIndex].unk_0CC > 0) {
gObjectList[objectIndex].unk_0CC--;
}
@@ -680,8 +683,8 @@ bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32
if (gObjectList[objectIndex].unk_0CC == 0) {
set_object_flag_status_false(objectIndex, 0x80);
set_object_flag_status_false(objectIndex, 0x2000);
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
sp24 = true;
} else {
set_object_flag_status_false(objectIndex, 0x4000);
@@ -699,33 +702,33 @@ s32 func_8007326C(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 a
sp24 = 0;
if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) {
- gObjectList[objectIndex].itemDisplay = arg1;
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].textureListIndex = arg1;
+ gObjectList[objectIndex].timer = arg4;
gObjectList[objectIndex].unk_0CC = arg5;
- set_object_unk_0CB(objectIndex, 1);
+ set_object_timer_state(objectIndex, 1);
set_object_flag_status_true(objectIndex, 0x2000);
set_object_flag_status_false(objectIndex, 0x4000);
} else {
- gObjectList[objectIndex].unk_050--;
- if (gObjectList[objectIndex].unk_050 <= 0) {
- gObjectList[objectIndex].unk_050 = arg4;
+ gObjectList[objectIndex].timer--;
+ if (gObjectList[objectIndex].timer <= 0) {
+ gObjectList[objectIndex].timer = arg4;
if (is_obj_index_flag_status_inactive(objectIndex, 0x4000) != 0) {
- gObjectList[objectIndex].itemDisplay -= arg3;
- if (arg2 >= gObjectList[objectIndex].itemDisplay) {
- gObjectList[objectIndex].itemDisplay = arg2;
+ gObjectList[objectIndex].textureListIndex -= arg3;
+ if (arg2 >= gObjectList[objectIndex].textureListIndex) {
+ gObjectList[objectIndex].textureListIndex = arg2;
set_object_flag_status_true(objectIndex, 0x4000);
}
} else {
- gObjectList[objectIndex].itemDisplay += arg3;
- if (gObjectList[objectIndex].itemDisplay >= arg1) {
- gObjectList[objectIndex].itemDisplay = arg1;
+ gObjectList[objectIndex].textureListIndex += arg3;
+ if (gObjectList[objectIndex].textureListIndex >= arg1) {
+ gObjectList[objectIndex].textureListIndex = arg1;
if (gObjectList[objectIndex].unk_0CC > 0) {
gObjectList[objectIndex].unk_0CC--;
}
if (gObjectList[objectIndex].unk_0CC == 0) {
set_object_flag_status_false(objectIndex, 0x2000);
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
sp24 = 1;
} else {
set_object_flag_status_false(objectIndex, 0x4000);
@@ -741,7 +744,7 @@ void func_80073404(s32 objectIndex, u8 arg1, u8 arg2, Vtx* arg3) {
gObjectList[objectIndex].vertex = arg3;
gObjectList[objectIndex].textureWidth = arg1;
gObjectList[objectIndex].textureHeight = arg2;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].unk_0D3 = -1;
gObjectList[objectIndex].status = 0;
}
@@ -751,7 +754,7 @@ void init_texture_object(s32 objectIndex, u8* texture, const char** arg2, u8 arg
gObjectList[objectIndex].textureList = arg2;
gObjectList[objectIndex].textureWidth = arg3;
gObjectList[objectIndex].textureHeight = arg4;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].unk_0D3 = -1;
gObjectList[objectIndex].status = 0;
}
@@ -762,7 +765,7 @@ UNUSED void func_8007348C(s32 objectIndex, u8* arg1, u8 arg2, u8 arg3, Vtx* arg4
gObjectList[objectIndex].textureWidth = arg2;
gObjectList[objectIndex].textureHeight = arg3;
gObjectList[objectIndex].vertex = arg4;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].unk_0D3 = -1;
gObjectList[objectIndex].status = 0;
}
@@ -773,13 +776,14 @@ UNUSED void func_800734D4() {
void update_neon_texture(s32 objectIndex) {
// I have no idea why this typecast works
gObjectList[objectIndex].activeTLUT =
- (u8*) ((u32*) gObjectList[objectIndex].tlutList + (gObjectList[objectIndex].itemDisplay * 128));
+ (u8*) ((u32*) gObjectList[objectIndex].tlutList + (gObjectList[objectIndex].textureListIndex * 128));
gObjectList[objectIndex].activeTexture = gObjectList[objectIndex].textureList;
}
void func_80073514(s32 objectIndex) {
gObjectList[objectIndex].activeTLUT = gObjectList[objectIndex].tlutList;
- gObjectList[objectIndex].activeTexture = gObjectList[objectIndex].textureList[gObjectList[objectIndex].itemDisplay];
+ gObjectList[objectIndex].activeTexture =
+ gObjectList[objectIndex].textureList[gObjectList[objectIndex].textureListIndex];
}
UNUSED void func_80073568() {
@@ -799,11 +803,11 @@ void func_800735BC(s32 objectIndex, Gfx* arg1, f32 arg2) {
gObjectList[objectIndex].status = 0;
gObjectList[objectIndex].model = arg1;
gObjectList[objectIndex].sizeScaling = arg2;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80073600(s32 objectIndex) {
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
gObjectList[objectIndex].unk_0D6 = 0;
gObjectList[objectIndex].unk_04C = -1;
set_object_flag_status_false(objectIndex, 0x8000);
@@ -1294,13 +1298,13 @@ size_t func_80074790(s32 objectIndex, const char** lakituTexturePtr) {
void func_800747F0(s32 objectIndex, const char** lakituTexturePtr) {
const char* nextTexture = NULL;
- if (gObjectList[objectIndex].itemDisplay != gObjectList[objectIndex].unk_0D3) {
- nextTexture = gObjectList[objectIndex].textureList[gObjectList[objectIndex].itemDisplay];
+ if (gObjectList[objectIndex].textureListIndex != gObjectList[objectIndex].unk_0D3) {
+ nextTexture = gObjectList[objectIndex].textureList[gObjectList[objectIndex].textureListIndex];
if (nextTexture != NULL) {
func_80074574(lakituTexturePtr, nextTexture, func_80074790(objectIndex, lakituTexturePtr),
gObjectList[objectIndex].textureWidth, gObjectList[objectIndex].textureHeight);
- gObjectList[objectIndex].unk_0D3 = gObjectList[objectIndex].itemDisplay;
+ gObjectList[objectIndex].unk_0D3 = gObjectList[objectIndex].textureListIndex;
func_80074478(objectIndex);
}
}
@@ -1382,7 +1386,7 @@ void func_80074924(s32 objectIndex) {
object->unk_084[7] = -0x100 - (sp20 / 32);
}
object->primAlpha = 0x00E6;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80074D94(s32 objectIndex) {
@@ -1402,7 +1406,7 @@ void func_80074E28(s32 objectIndex) {
func_80074924(objectIndex);
break;
case 2:
- if (func_8007278C(objectIndex, 1) != 0) {
+ if (set_and_run_timer_object(objectIndex, 1) != false) {
func_80086E70(objectIndex);
break;
}
@@ -1451,7 +1455,7 @@ void func_80074FD8(s32 objectIndex) {
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.12f,
gObjectList[objectIndex].unk_034, gObjectList[objectIndex].direction_angle[1],
0x00000064) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
object_calculate_new_pos_offset(objectIndex);
gObjectList[objectIndex].orientation[0] += D_8016582C[0];
@@ -1587,7 +1591,7 @@ void func_80075698(s32 objectIndex) {
gObjectList[objectIndex].offset[1] = 0.0f;
gObjectList[objectIndex].offset[2] = 0.0f;
gObjectList[objectIndex].sizeScaling = 0.5f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80075714(s32 objectIndex) {
@@ -1600,7 +1604,7 @@ void func_80075714(s32 objectIndex) {
f32_step_up_towards(&gObjectList[objectIndex].offset[1], 100.0f, gObjectList[objectIndex].velocity[1]);
func_8007415C(objectIndex, &gObjectList[objectIndex].sizeScaling, 0.55f, 1.0f, 0.1f, 1, 0);
if (func_80073B00(objectIndex, &gObjectList[objectIndex].primAlpha, 0xFF, 0x1E, 7, 0, 0) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
@@ -1708,7 +1712,7 @@ void func_80075B08(s32 objectIndex) {
gObjectList[objectIndex].offset[1] = 0.0f;
gObjectList[objectIndex].offset[2] = 0.0f;
gObjectList[objectIndex].sizeScaling = 0.5f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80075B84(s32 objectIndex) {
@@ -1721,7 +1725,7 @@ void func_80075B84(s32 objectIndex) {
f32_step_up_towards(&gObjectList[objectIndex].offset[1], 100.0f, gObjectList[objectIndex].velocity[1]);
func_8007415C(objectIndex, &gObjectList[objectIndex].sizeScaling, 0.55f, 1.0f, 0.1f, 1, 0);
if (func_80073B00(objectIndex, &gObjectList[objectIndex].primAlpha, 0xFF, 0x1E, 7, 0, 0) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
@@ -1924,7 +1928,7 @@ void func_8007634C(s32 objectIndex) {
object->primAlpha = 0x00FF;
set_obj_orientation(objectIndex, 0U, 0U, 0U);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800763CC(s32 objectIndex) {
@@ -1937,7 +1941,7 @@ void func_800763CC(s32 objectIndex) {
func_8007634C(objectIndex);
break;
case 2:
- if (func_8007278C(objectIndex, object->unk_048) != 0) {
+ if (set_and_run_timer_object(objectIndex, object->unk_048) != 0) {
func_80086E70(objectIndex);
}
break;
@@ -1953,7 +1957,7 @@ void func_800763CC(s32 objectIndex) {
}
if ((object->unk_0AE >= 2) &&
(func_80073B00(objectIndex, &object->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 4:
@@ -2092,7 +2096,7 @@ void func_80076958(s32 objectIndex) {
object->primAlpha = 0x00FF;
set_obj_orientation(objectIndex, 0U, 0U, 0U);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800769D8(s32 objectIndex) {
@@ -2106,7 +2110,7 @@ void func_800769D8(s32 objectIndex) {
func_80076958(objectIndex);
break;
case 2:
- if (func_8007278C(objectIndex, object->unk_048) != 0) {
+ if (set_and_run_timer_object(objectIndex, object->unk_048) != 0) {
func_80086E70(objectIndex);
}
break;
@@ -2115,7 +2119,7 @@ void func_800769D8(s32 objectIndex) {
s16_step_towards(&object->type, 0, 0x0018);
if ((object->unk_0AE >= 2) &&
(func_80073B00(objectIndex, &object->primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0, 0) != 0)) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 4:
@@ -2200,7 +2204,7 @@ void init_smoke_particle(Vec3f arg0, UNUSED f32 arg1, s16 arg2) {
}
void func_80076DC4(s32 objectIndex) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
if (gObjectList[objectIndex].unk_0D5 != 0x0B) {
func_80086E70(objectIndex);
}
@@ -2215,7 +2219,7 @@ void func_80076E14(s32 objectIndex) {
if ((gObjectList[objectIndex].unk_0AE >= 2) &&
(func_80073B00(objectIndex, &gObjectList[objectIndex].primAlpha, 0x000000FF, 0x00000050, 0x00000020, 0,
0) != 0)) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0:
@@ -2340,7 +2344,7 @@ void func_800773D8(f32* arg0, s32 arg1) {
}
void func_80077428(s32 arg0) {
- func_80072488(arg0);
+ object_next_state(arg0);
func_80086E70(arg0);
}
@@ -2475,7 +2479,7 @@ void spawn_leaf(Vec3f arg0, UNUSED s32 arg1) {
}
void func_80077B14(s32 arg0) {
- func_80072488(arg0);
+ object_next_state(arg0);
func_80086E70(arg0);
}
@@ -2491,7 +2495,7 @@ void func_80077B3C(s32 objectIndex) {
break;
case 2:
if (object->unk_0AE == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
@@ -2576,7 +2580,7 @@ void func_80077E20(s32 objectIndex) {
object->primAlpha = 0x00FF;
object->unk_0D5 = 0;
object->type = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80077EB8(s32 objectIndex, u16 arg1, Camera* camera) {
@@ -2631,7 +2635,7 @@ void func_800780CC(s32 objectIndex, Camera* camera) {
case 2:
func_80077F64(objectIndex, camera);
if (gObjectList[objectIndex].unk_0AE == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
return;
}
case 0:
@@ -2666,7 +2670,7 @@ void func_80078220(s32 objectIndex) {
object->vertex = vtx;
object->sizeScaling = 0.15f;
func_80086EF0(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80078288(s32 objectIndex) {
@@ -2735,7 +2739,7 @@ void func_800786EC(s32 objectIndex) {
case 2:
func_80078288(objectIndex);
if (gObjectList[objectIndex].unk_0AE == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
@@ -3035,44 +3039,44 @@ void init_obj_lakitu_red_flag_countdown(s32 objectIndex, s32 playerId) {
gObjectList[objectIndex].vertex = vtx;
gObjectList[objectIndex].sizeScaling = 0.15f;
set_object_flag_status_false(objectIndex, 0x00000010);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
gObjectList[objectIndex].unk_048 = D_8018D180;
}
-void update_object_lakitu_countdown(s32 objectIndex, s32 playerId) {
+void update_object_lakitu_countdown(s32 objectIndex, s32 arg1) {
UNUSED s32 pad;
switch (gObjectList[objectIndex].state) {
case 0:
break;
case 1:
- init_obj_lakitu_red_flag_countdown(objectIndex, playerId);
+ init_obj_lakitu_red_flag_countdown(objectIndex, arg1);
break;
case 2:
- func_8007278C(objectIndex, gObjectList[objectIndex].unk_048);
- if ((gObjectList[objectIndex].unk_050 == 0x00000055) && (gPlayerCount == 3) && (playerId == 0)) {
+ set_and_run_timer_object(objectIndex, gObjectList[objectIndex].unk_048);
+ if ((gObjectList[objectIndex].timer == 0x00000055) && (gPlayerCount == 3) && (arg1 == 0)) {
D_8018D168 = 1;
}
break;
case 3:
set_object_flag_status_true(objectIndex, 0x00000010);
- func_80086F10(objectIndex, 1, &D_800E67B8);
- func_80072488(objectIndex);
+ func_80086F10(objectIndex, 1, &D_800E67B8); // set a spline
+ object_next_state(objectIndex);
break;
case 4:
- if ((func_8007278C(objectIndex, 0x0000001E) != 0) && (gPlayerCount != 3) && (playerId == 0)) {
+ if ((set_and_run_timer_object(objectIndex, 0x0000001E) != false) && (gPlayerCount != 3) && (arg1 == 0)) {
D_8018D168 = 1;
}
break;
case 5:
- func_8007278C(objectIndex, 0x0000001E);
+ set_and_run_timer_object(objectIndex, 0x0000001E);
break;
case 6:
func_80072E54(objectIndex, 1, 7, 1, 2, 0);
break;
case 7:
- if (func_8007278C(objectIndex, 0x00000014) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x00000014) != 0) {
gObjectList[objectIndex].tlutList += 0x200;
- if (playerId == 0) {
+ if (arg1 == 0) {
play_sound2(SOUND_ACTION_COUNTDOWN_LIGHT);
}
}
@@ -3081,19 +3085,19 @@ void update_object_lakitu_countdown(s32 objectIndex, s32 playerId) {
func_80072E54(objectIndex, 8, 0x0000000F, 1, 6, 0);
break;
case 9:
- if ((func_8007278C(objectIndex, 8) != 0) && (playerId == 0)) {
+ if ((set_and_run_timer_object(objectIndex, 8) != 0) && (arg1 == 0)) {
play_sound2(SOUND_ACTION_COUNTDOWN_LIGHT);
}
break;
case 10:
- if ((func_80072E54(objectIndex, 0x00000010, 0x00000017, 1, 6, 0) != 0) && (playerId == 0)) {
+ if ((func_80072E54(objectIndex, 0x00000010, 0x00000017, 1, 6, 0) != 0) && (arg1 == 0)) {
D_801656F0 = 1;
}
break;
case 11:
- if (func_8007278C(objectIndex, 8) != 0) {
+ if (set_and_run_timer_object(objectIndex, 8) != 0) {
gObjectList[objectIndex].tlutList += 0x200;
- if (playerId == 0) {
+ if (arg1 == 0) {
play_sound2(SOUND_ACTION_GREEN_LIGHT);
}
}
@@ -3102,15 +3106,15 @@ void update_object_lakitu_countdown(s32 objectIndex, s32 playerId) {
func_80072E54(objectIndex, 0x00000018, 0x0000001B, 1, 6, 0);
break;
case 13:
- if (playerId == 0) {
+ if (arg1 == 0) {
func_800729EC(objectIndex);
D_8018D160 = 1;
break;
}
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 14:
- func_8007278C(objectIndex, 0x00000078);
+ set_and_run_timer_object(objectIndex, 0x00000078);
break;
case 15:
func_80072428(objectIndex);
@@ -3150,7 +3154,7 @@ void init_obj_lakitu_red_flag(s32 objectIndex, s32 playerIndex) {
object->sizeScaling = 0.15f;
func_80086F10(objectIndex, 2, &D_800E6834);
set_object_flag_status_false(objectIndex, 0x00000010);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void update_object_lakitu_red_flag(s32 objectIndex, s32 playerIndex) {
@@ -3162,7 +3166,7 @@ void update_object_lakitu_red_flag(s32 objectIndex, s32 playerIndex) {
break;
case 2:
set_object_flag_status_true(objectIndex, 0x00000010);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3:
func_80072E54(objectIndex, 0, 0x0000001F, 1, 2, -1);
@@ -3226,7 +3230,7 @@ void init_obj_lakitu_red_flag_fishing(s32 objectIndex, s32 arg1) {
func_80086E70(objectIndex);
set_object_flag_status_false(objectIndex, 0x00000010);
func_80073720(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_800C8F80((u8) arg1, 0x0100FA28);
}
@@ -3268,7 +3272,7 @@ void update_object_lakitu_fishing(s32 objectIndex, s32 playerId) {
case 2: /* switch 1 */
set_object_flag_status_true(objectIndex, 0x00000010);
func_800736E0(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3: /* switch 1 */
func_800730BC(objectIndex, 0, 3, 1, 2, -1);
@@ -3323,7 +3327,7 @@ void update_object_lakitu_fishing2(s32 objectIndex, s32 playerId) {
set_object_flag_status_true(objectIndex, 0x00000010);
func_800736E0(objectIndex);
player->unk_0CA |= 0x80;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3: /* switch 1 */
func_800730BC(objectIndex, 0, 3, 1, 2, -1);
@@ -3413,7 +3417,7 @@ void func_8007A060(s32 objectIndex, s32 playerIndex) {
object->sizeScaling = 0.15f;
set_object_flag_status_false(objectIndex, 0x00000010);
func_80086F10(objectIndex, 5, &D_800E694C);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void update_object_lakitu_second_lap(s32 objectIndex, s32 playerIndex) {
@@ -3425,16 +3429,16 @@ void update_object_lakitu_second_lap(s32 objectIndex, s32 playerIndex) {
break;
case 2:
set_object_flag_status_true(objectIndex, 0x00000010);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3:
- func_8007278C(objectIndex, 0x00000014);
+ set_and_run_timer_object(objectIndex, 0x00000014);
break;
case 4:
func_80072E54(objectIndex, 0, 0x0000000F, 1, 2, 1);
break;
case 5:
- func_8007278C(objectIndex, 0x0000003C);
+ set_and_run_timer_object(objectIndex, 0x0000003C);
break;
case 6:
func_80072F88(objectIndex, 0x0000000F, 0, 1, 2, 1);
@@ -3472,7 +3476,7 @@ void func_8007A228(s32 objectIndex, s32 playerIndex) {
object->sizeScaling = 0.15f;
set_object_flag_status_false(objectIndex, 0x00000010);
func_80086F10(objectIndex, 5, &D_800E694C);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void update_object_lakitu_final_lap(s32 objectIndex, s32 playerIndex) {
@@ -3484,16 +3488,16 @@ void update_object_lakitu_final_lap(s32 objectIndex, s32 playerIndex) {
break;
case 2:
set_object_flag_status_true(objectIndex, 0x00000010);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3:
- func_8007278C(objectIndex, 0x00000014);
+ set_and_run_timer_object(objectIndex, 0x00000014);
break;
case 4:
func_80072E54(objectIndex, 0, 0x0000000F, 1, 2, 1);
break;
case 5:
- func_8007278C(objectIndex, 0x0000003C);
+ set_and_run_timer_object(objectIndex, 0x0000003C);
break;
case 6:
func_80072F88(objectIndex, 0x0000000F, 0, 1, 2, 1);
@@ -3530,7 +3534,7 @@ void func_8007A3F0(s32 objectIndex, s32 arg1) {
set_object_flag_status_false(objectIndex, 0x00000010);
func_80086F10(objectIndex, 6, &D_800E69B0);
gObjectList[objectIndex].unk_0D6 = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_800C8F80((u8) arg1, 0x0100FA28);
}
@@ -3546,7 +3550,7 @@ void update_object_lakitu_reverse(s32 objectIndex, s32 playerId) {
case 2:
set_object_flag_status_true(objectIndex, 0x00000010);
gObjectList[objectIndex].unk_0D6 = 1;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 3:
func_800730BC(objectIndex, 0, 0x0000000F, 1, 2, -1);
@@ -3568,7 +3572,7 @@ void update_object_lakitu_reverse(s32 objectIndex, s32 playerId) {
case 2: /* switch 1 */
gObjectList[objectIndex].unk_04C--;
if (gObjectList[objectIndex].unk_04C == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
gObjectList[objectIndex].unk_0D6 = 0;
}
break;
@@ -3740,13 +3744,13 @@ void consume_item(s32 playerId) {
func_800722CC(objectIndex, 2);
player->currentItemCopy = ITEM_NONE;
itemWindow->currentItem = ITEM_NONE;
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
func_800726CC(objectIndex, 9);
}
} else {
player->currentItemCopy = ITEM_NONE;
itemWindow->currentItem = ITEM_NONE;
- set_object_unk_0CB(objectIndex, 0);
+ set_object_timer_state(objectIndex, 0);
}
}
@@ -4292,7 +4296,7 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) {
func_800C9060(playerId, 0x1900A058U);
}
var_t3 = 1;
- gObjectList[objectIndex].itemDisplay = gObjectList[objectIndex].unk_0A2 = var_v1;
+ gObjectList[objectIndex].textureListIndex = gObjectList[objectIndex].unk_0A2 = var_v1;
} else {
for (var_v1_2 = 0; var_v1_2 < gPlayerCountSelection1; var_v1_2++) {
temp_a0 = gItemWindowObjectByPlayerId[var_v1_2];
@@ -4308,7 +4312,7 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) {
var_v1 = random_int(var_a3);
temp_a1 = sp40[var_v1];
gObjectList[objectIndex].unk_0A2 = temp_a1;
- gObjectList[objectIndex].itemDisplay = temp_a1;
+ gObjectList[objectIndex].textureListIndex = temp_a1;
temp_v1 = sp50[var_v1];
gObjectList[objectIndex].unk_0D1 = temp_v1;
temp_a0 = gItemWindowObjectByPlayerId[temp_v1];
@@ -4318,7 +4322,7 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) {
sp38->currentItemCopy = 0;
if (func_80072320(temp_a0, 2) != 0) {
func_800722CC(temp_a0, 2);
- gObjectList[temp_a0].timer = 0;
+ gObjectList[temp_a0].animationTimer = 0;
}
var_t3 = 1;
}
@@ -4338,14 +4342,14 @@ void func_8007B254(s32 objectIndex, s32 arg1) {
gObjectList[objectIndex].textureHeight = 0x20;
gObjectList[objectIndex].unk_04C = 0x00000032;
gObjectList[objectIndex].unk_0D6 = 1;
- gObjectList[objectIndex].timer = 0;
+ gObjectList[objectIndex].animationTimer = 0;
func_800722A4(objectIndex, 4);
if (D_80165888 != 0) {
func_800726CC(objectIndex, 8);
gObjectList[objectIndex].unk_0D6 = 2;
gObjectList[objectIndex].type = 0x000E;
test = gObjectList[objectIndex].type;
- gObjectList[objectIndex].itemDisplay = test;
+ gObjectList[objectIndex].textureListIndex = test;
gObjectList[objectIndex].unk_0A2 = test;
playerHUD[PLAYER_ONE].slideItemBoxY = 0;
D_80165888 = 0;
@@ -4380,24 +4384,24 @@ void func_8007B34C(s32 playerId) {
if (gActiveScreenMode == 0) {
s16_step_up_towards(&playerHUD[playerId].slideItemBoxY, 0x0040, 4);
if (playerHUD[playerId].slideItemBoxY == 0x0040) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
} else if (gActiveScreenMode == 3) {
if ((playerId == 0) || (playerId == 2)) {
s16_step_up_towards(&playerHUD[playerId].slideItemBoxX, 0x0080, 8);
if (playerHUD[playerId].slideItemBoxX == 0x0080) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
} else {
s16_step_down_towards(&playerHUD[playerId].slideItemBoxX, -0x0080, 8);
if (playerHUD[playerId].slideItemBoxX == -0x0080) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
}
} else {
s16_step_up_towards(&playerHUD[playerId].slideItemBoxX, 0x0080, 8);
if (playerHUD[playerId].slideItemBoxX == 0x0080) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
}
break;
@@ -4411,10 +4415,10 @@ void func_8007B34C(s32 playerId) {
func_80072E54(temp_s0, 1, 4, 1, 0x00000010, 1);
break;
case 6:
- object->itemDisplay = func_8007AFB0(temp_s0, playerId);
+ object->textureListIndex = func_8007AFB0(temp_s0, playerId);
object->unk_04C = 8;
object->unk_0D6 = 2;
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
func_800C9018((u8) playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFE, 0x1C));
func_800C8F80((u8) playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFE, 0x47));
break;
@@ -4424,31 +4428,31 @@ void func_8007B34C(s32 playerId) {
case 9:
func_800722CC(temp_s0, 4);
func_80073600(temp_s0);
- object->itemDisplay = 0;
- func_80072488(temp_s0);
+ object->textureListIndex = 0;
+ object_next_state(temp_s0);
break;
case 10:
- func_8007278C(temp_s0, 0x00000014);
+ set_and_run_timer_object(temp_s0, 0x00000014);
break;
case 11:
if (gActiveScreenMode == 0) {
if (s16_step_down_towards(&playerHUD[playerId].slideItemBoxY, 0, 4) != 0) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
} else if (gActiveScreenMode == 3) {
if ((playerId == 0) || (playerId == 2)) {
s16_step_down_towards(&playerHUD[playerId].slideItemBoxX, 0, 8);
if (playerHUD[playerId].slideItemBoxX == 0) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
} else {
s16_step_up_towards(&playerHUD[playerId].slideItemBoxX, 0, 8);
if (playerHUD[playerId].slideItemBoxX == 0) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
}
} else if (s16_step_down_towards(&playerHUD[playerId].slideItemBoxX, 0, 8) != 0) {
- func_80072488(temp_s0);
+ object_next_state(temp_s0);
}
break;
case 12:
@@ -4493,10 +4497,10 @@ void func_8007B34C(s32 playerId) {
break;
}
if (func_80072320(temp_s0, 2) != 0) {
- if (object->timer == 0) {
+ if (object->animationTimer == 0) {
consume_item(playerId);
} else {
- object->timer--;
+ object->animationTimer--;
}
}
if (object->unk_04C >= 0) {
@@ -4542,8 +4546,8 @@ void func_8007B34C(s32 playerId) {
}
}
}
- object->activeTLUT = (u8*) gItemWindowTLUTs[object->itemDisplay];
- object->activeTexture = gItemWindowTextures[object->itemDisplay];
+ object->activeTLUT = (u8*) gItemWindowTLUTs[object->textureListIndex];
+ object->activeTexture = gItemWindowTextures[object->textureListIndex];
sp38->currentItemCopy = object->type;
}
@@ -4574,7 +4578,7 @@ void func_8007BBBC(s32 objectIndex) {
var_f14 = object->velocity[2];
}
object->direction_angle[0] = func_80041658(object->velocity[1], var_f14);
- func_8007278C(objectIndex, 0x00000046);
+ set_and_run_timer_object(objectIndex, 0x00000046);
break;
case 3:
func_80072428(objectIndex);
@@ -4615,7 +4619,7 @@ void init_var_cheep_cheep(s32 objectIndex) {
object->status = 0;
object->model = d_course_banshee_boardwalk_dl_cheep_cheep;
object->sizeScaling = 0.2f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
set_obj_origin_pos(objectIndex, D_800E634C[0][0], D_800E634C[0][1] + 55.0, D_800E634C[0][2]);
set_obj_origin_offset(objectIndex, 0.0f, 30.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, 0x3800U, 0U);
@@ -4630,18 +4634,18 @@ void func_8007BEC8(s32 objectIndex) {
init_var_cheep_cheep(objectIndex);
break;
case 2:
- if (func_8007278C(objectIndex, 0x0000003C) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000003C) != 0) {
set_object_flag_status_true(objectIndex, 0x00000010);
func_80086E70(objectIndex);
}
break;
case 3:
if (object->unk_0AE == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 4:
- if (func_8007278C(objectIndex, 0x0000000A) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000000A) != 0) {
func_8008701C(objectIndex, 2);
}
break;
@@ -4763,10 +4767,10 @@ void func_8007C360(s32 objectIndex, Camera* camera) {
if (temp < 0x13) {
set_object_flag_status_false(objectIndex, 0x80);
- gObjectList[objectIndex].itemDisplay = temp;
+ gObjectList[objectIndex].textureListIndex = temp;
} else {
set_object_flag_status_true(objectIndex, 0x80);
- gObjectList[objectIndex].itemDisplay = 0x24 - temp;
+ gObjectList[objectIndex].textureListIndex = 0x24 - temp;
}
}
@@ -4791,10 +4795,10 @@ void func_8007C4A4(s32 objectIndex) {
if (var_t9 < 0x13) {
set_object_flag_status_false(objectIndex, 0x80);
- gObjectList[objectIndex].itemDisplay = var_t9;
+ gObjectList[objectIndex].textureListIndex = var_t9;
} else {
set_object_flag_status_true(objectIndex, 0x80);
- gObjectList[objectIndex].itemDisplay = 0x24 - var_t9;
+ gObjectList[objectIndex].textureListIndex = 0x24 - var_t9;
}
}
@@ -4814,7 +4818,7 @@ void func_8007C5B4(s32 objectIndex) {
object->pos[1] = 0.0f;
object->pos[2] = 0.0f;
set_object_flag_status_true(objectIndex, 0x00000020);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
object->primAlpha = 0;
func_80073844(objectIndex);
object->sizeScaling = 0.15f;
@@ -5010,12 +5014,12 @@ void func_8007CE0C(s32 objectIndex) {
init_texture_object(objectIndex, d_course_banshee_boardwalk_boo_tlut, gTextureGhosts, 0x30U, (u16) 0x00000028);
object = &gObjectList[objectIndex];
- object->itemDisplay = 0x1C;
+ object->textureListIndex = 0x1C;
object->pos[0] = 0.0f;
object->pos[1] = 0.0f;
object->pos[2] = 0.0f;
object->sizeScaling = 0.15f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
object->primAlpha = 0;
func_80073844(objectIndex);
func_80086EF0(objectIndex);
@@ -5035,10 +5039,10 @@ void func_8007CEDC(s32 objectIndex) {
func_8007CE0C(objectIndex);
break;
case 2: /* switch 1 */
- func_8007278C(objectIndex, 0x0000001E);
+ set_and_run_timer_object(objectIndex, 0x0000001E);
break;
case 3: /* switch 1 */
- func_8007278C(objectIndex, 0x000003E8);
+ set_and_run_timer_object(objectIndex, 0x000003E8);
break;
case 4: /* switch 1 */
func_80072428(objectIndex);
@@ -5211,7 +5215,7 @@ s32 func_8007D804(s32 objectIndex) {
}
void func_8007D8AC(s32 arg0) {
- func_80072488(arg0);
+ object_next_state(arg0);
func_80086E70(arg0);
}
@@ -5403,7 +5407,7 @@ void init_bb_trash_bin(s32 objectIndex) {
gObjectList[objectIndex].pos[1] = 45.0f;
set_obj_velocity(objectIndex, 0.0f, 0.0f, 0.0f);
gObjectList[objectIndex].type = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8007E00C(s32 objectIndex) {
@@ -5413,10 +5417,10 @@ void func_8007E00C(s32 objectIndex) {
break;
case 3:
D_8018CFB0 = 1;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 4:
- func_8007278C(objectIndex, 0x000000D2);
+ set_and_run_timer_object(objectIndex, 0x000000D2);
if (D_80165594 == 0) {
if (gCCSelection < CC_150) {
func_8007D714(1);
@@ -5441,13 +5445,13 @@ void func_8007E00C(s32 objectIndex) {
case 5:
gObjectList[objectIndex].orientation[2] = func_800417B4(gObjectList[objectIndex].orientation[2], 0U);
if (gObjectList[objectIndex].orientation[2] == 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 6:
gObjectList[objectIndex].orientation[2] = 0;
gObjectList[objectIndex].unk_084[7] = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
D_8018CFB0 = 0;
break;
case 0:
@@ -5514,7 +5518,7 @@ void func_8007E358(s32 objectIndex) {
gObjectList[objectIndex].type = 0;
gObjectList[objectIndex].unk_04C = 0;
gObjectList[objectIndex].unk_084[7] = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8007E3EC(s32 objectIndex) {
@@ -5525,10 +5529,10 @@ void func_8007E3EC(s32 objectIndex) {
break;
case 3:
D_8018CFE8 = 1;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 4:
- func_8007278C(objectIndex, 0x000000D2);
+ set_and_run_timer_object(objectIndex, 0x000000D2);
if (D_80165598 == 0) {
if (gCCSelection < CC_150) {
func_8007D714(2);
@@ -5540,7 +5544,7 @@ void func_8007E3EC(s32 objectIndex) {
break;
case 5:
D_8018CFE8 = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
case 0:
case 2:
@@ -5597,17 +5601,17 @@ void func_8007E63C(s32 objectIndex) {
set_object_flag_status_true(objectIndex, 0x00000200);
func_800722A4(objectIndex, 1);
func_800722CC(objectIndex, 2);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0x33:
if (f32_step_down_towards(&gObjectList[objectIndex].offset[1], 0.0f, 2.0f) != 0) {
if (gObjectList[objectIndex].offset[1] >= 16.0f) {
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
} else if (gObjectList[objectIndex].offset[1] >= 8.0f) {
- gObjectList[objectIndex].itemDisplay = 1;
+ gObjectList[objectIndex].textureListIndex = 1;
} else {
- gObjectList[objectIndex].itemDisplay = 2;
+ gObjectList[objectIndex].textureListIndex = 2;
}
func_800722CC(objectIndex, 1);
if (is_obj_flag_status_active(objectIndex, 0x00010000) != 0) {
@@ -5619,7 +5623,7 @@ void func_8007E63C(s32 objectIndex) {
if (func_80072320(objectIndex, 2) != 0) {
func_800726CC(objectIndex, 0x00000064);
} else {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
}
break;
@@ -5631,9 +5635,9 @@ void func_8007E63C(s32 objectIndex) {
break;
case 0x36:
if (gObjectList[objectIndex].offset[1] >= 20.0f) {
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
} else if (gObjectList[objectIndex].offset[1] >= 18.0f) {
- gObjectList[objectIndex].itemDisplay = 1;
+ gObjectList[objectIndex].textureListIndex = 1;
}
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], gObjectList[objectIndex].unk_01C[1], 0.5f) !=
0) {
@@ -5645,11 +5649,11 @@ void func_8007E63C(s32 objectIndex) {
func_80072E54(objectIndex, 3, 5, 1, 8, 0);
break;
case 0x65:
- func_8007278C(objectIndex, 0x0000001E);
+ set_and_run_timer_object(objectIndex, 0x0000001E);
break;
case 0x66:
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], 20.0f, 1.5f) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0x67:
@@ -5660,12 +5664,12 @@ void func_8007E63C(s32 objectIndex) {
func_800722A4(objectIndex, 0x00000020);
}
}
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0x68:
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], 12.0f, 1.5f) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0x69:
@@ -5678,7 +5682,7 @@ void func_8007E63C(s32 objectIndex) {
}
func_800C98B8(gObjectList[objectIndex].pos, gObjectList[objectIndex].velocity,
SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x45));
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0x6A:
@@ -5688,33 +5692,33 @@ void func_8007E63C(s32 objectIndex) {
break;
case 0x6B:
if (gObjectList[objectIndex].offset[1] >= 22.0f) {
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
} else if (gObjectList[objectIndex].offset[1] >= 20.0f) {
- gObjectList[objectIndex].itemDisplay = 1;
+ gObjectList[objectIndex].textureListIndex = 1;
} else if (gObjectList[objectIndex].offset[1] >= 18.0f) {
- gObjectList[objectIndex].itemDisplay = 2;
+ gObjectList[objectIndex].textureListIndex = 2;
} else if (gObjectList[objectIndex].offset[1] >= 16.0f) {
- gObjectList[objectIndex].itemDisplay = 3;
+ gObjectList[objectIndex].textureListIndex = 3;
} else if (gObjectList[objectIndex].offset[1] >= 14.0f) {
- gObjectList[objectIndex].itemDisplay = 4;
+ gObjectList[objectIndex].textureListIndex = 4;
} else {
func_800730BC(objectIndex, 3, 5, 1, 6, -1);
}
if (f32_step_up_towards(&gObjectList[objectIndex].offset[1], gObjectList[objectIndex].unk_01C[1], 0.5f) !=
0) {
- set_object_unk_0CB(objectIndex, 0);
- func_80072488(objectIndex);
+ set_object_timer_state(objectIndex, 0);
+ object_next_state(objectIndex);
}
break;
case 0x6C:
- if (func_8007278C(objectIndex, 0x00000064) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x00000064) != 0) {
func_800722CC(objectIndex, 2);
set_object_flag_status_false(objectIndex, 0x00000200);
func_8007266C(objectIndex);
}
break;
case 0xC8:
- if (func_8007278C(objectIndex, 0x0000012C) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000012C) != 0) {
func_80072320(objectIndex, 0x00000080);
func_80072428(objectIndex);
func_800726CC(objectIndex, 1);
@@ -5753,7 +5757,7 @@ void func_8007EC30(s32 objectIndex) {
object->type = 0;
object->unk_0DF = 6;
func_800724DC(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8007ED6C(s32 objectIndex) {
@@ -5765,7 +5769,7 @@ void func_8007ED6C(s32 objectIndex) {
func_8007EC30(objectIndex);
break;
case 2:
- func_8007278C(objectIndex, 0x0000003C);
+ set_and_run_timer_object(objectIndex, 0x0000003C);
break;
case 3:
func_80072568(objectIndex, 0x00000032);
@@ -5814,7 +5818,7 @@ void func_8007EE5C(s32 objectIndex) {
} else {
object->unk_0DD = 2;
}
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8007EFBC(s32 objectIndex) {
@@ -5993,7 +5997,7 @@ void func_8007F5A8(s32 objectIndex) {
break;
case 4:
func_80086FD4(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
}
func_8007E63C(objectIndex);
@@ -6112,7 +6116,7 @@ void func_8007FA08(s32 objectIndex) {
object->unk_0DF = 8;
object->offset[1] = 15.0f;
object->unk_01C[1] = 15.0f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8007FB48(s32 objectIndex) {
@@ -6152,7 +6156,7 @@ void func_8007FB48(s32 objectIndex) {
gObjectList[objectIndex].orientation[1] = func_800417B4(
gObjectList[objectIndex].orientation[1], (gObjectList[objectIndex].direction_angle[1] + 0x8000));
if (gObjectList[objectIndex].unk_0B0 == 0x0064) {
- gObjectList[objectIndex].itemDisplay = 1;
+ gObjectList[objectIndex].textureListIndex = 1;
}
}
var_v0 = 0;
@@ -6183,7 +6187,7 @@ void func_8007FB48(s32 objectIndex) {
if (gObjectList[objectIndex].orientation[1] == gObjectList[objectIndex].direction_angle[1]) {
func_800722CC(objectIndex, 8);
func_80086FD4(objectIndex);
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
}
break;
case 0:
@@ -6238,7 +6242,7 @@ void func_8007FFC0(s32 objectIndex) {
func_80072568(objectIndex, 0x00000032);
break;
case 4:
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_80086FD4(objectIndex);
break;
}
@@ -6272,20 +6276,20 @@ void func_80080078(s32 objectIndex) {
}
switch (object->primAlpha) { /* irregular */
case 0:
- object->unk_050 = 2;
+ object->timer = 2;
break;
case 1:
- object->unk_050 = 0x0000003C;
+ object->timer = 0x0000003C;
break;
case 2:
- object->unk_050 = 0x00000078;
+ object->timer = 0x00000078;
break;
case 3:
- object->unk_050 = 0x000000B4;
+ object->timer = 0x000000B4;
break;
}
func_800724DC(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800801FC(s32 objectIndex) {
@@ -6299,13 +6303,13 @@ void func_800801FC(s32 objectIndex) {
func_80080078(objectIndex);
break;
case 2:
- func_8007278C(objectIndex, object->unk_050);
+ set_and_run_timer_object(objectIndex, object->timer);
break;
case 3:
func_80072568(objectIndex, 0x00000032);
break;
case 4:
- object->unk_050 = 0x0000003C;
+ object->timer = 0x0000003C;
func_800726CC(objectIndex, 2);
break;
}
@@ -6322,7 +6326,7 @@ void func_800802C0(s32 objectIndex) {
init_texture_object(objectIndex, d_course_bowsers_castle_thwomp_tlut, (u8*) d_course_bowsers_castle_thwomp_faces,
0x10U, (u16) 0x00000040);
object->model = d_course_bowsers_castle_dl_thwomp;
- object->itemDisplay = 0;
+ object->textureListIndex = 0;
object->boundingBoxSize = 0x000C;
object->sizeScaling = 1.5f;
set_object_flag_status_true(objectIndex, 0x05000220);
@@ -6342,7 +6346,7 @@ void func_800802C0(s32 objectIndex) {
object->offset[0] = 0.0f;
object->offset[2] = 0.0f;
func_800724DC(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80080408(s32 objectIndex) {
@@ -6357,16 +6361,16 @@ void func_80080408(s32 objectIndex) {
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
func_800C98B8(gObjectList[objectIndex].pos, gObjectList[objectIndex].velocity,
SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x45));
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
if (func_800730BC(objectIndex, 3, 5, 1, 6, 6) != 0) {
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
}
break;
case 4:
- if (func_8007278C(objectIndex, 0x0000012C) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000012C) != 0) {
func_800726CC(objectIndex, 2);
}
break;
@@ -6383,7 +6387,7 @@ void func_80080524(s32 objectIndex) {
object = &gObjectList[objectIndex];
object->model = d_course_bowsers_castle_dl_thwomp;
object->boundingBoxSize = 0x000C;
- object->itemDisplay = 0;
+ object->textureListIndex = 0;
object->sizeScaling = 1.0f;
set_object_flag_status_true(objectIndex, 0x04000220);
object->type = 0;
@@ -6410,7 +6414,7 @@ void func_80080524(s32 objectIndex) {
break;
}
func_800722A4(objectIndex, 0x00000080);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800806BC(s32 objectIndex) {
@@ -6627,7 +6631,7 @@ void func_80081080(s32 objectIndex) {
object->offset[1] = 0.0f;
object->offset[2] = 0.0f;
object->sizeScaling = 0.25f;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800810F4(s32 objectIndex) {
@@ -6642,7 +6646,7 @@ void func_800810F4(s32 objectIndex) {
f32_step_up_towards(&gObjectList[objectIndex].offset[1], 14.0f, 0.5f);
func_8007415C(objectIndex, &gObjectList[objectIndex].sizeScaling, 0.25f, 0.75f, 0.025f, 1, 0);
if (func_80073B00(objectIndex, &gObjectList[objectIndex].primAlpha, 0x000000FF, 0, 4, 0, 0) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 3:
@@ -6785,7 +6789,7 @@ void func_80081790(s32 objectIndex) {
case 1:
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.3f, gObjectList[objectIndex].unk_034,
gObjectList[objectIndex].orientation[1], 0x00000032) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
object_calculate_new_pos_offset(objectIndex);
break;
@@ -6801,14 +6805,14 @@ void func_80081848(s32 objectIndex) {
u8* tlut = (u8*) LOAD_ASSET(d_course_moo_moo_farm_mole_tlut);
init_texture_object(objectIndex, d_course_moo_moo_farm_mole_tlut, (u8*) mole, 0x20U, (u16) 0x00000040);
gObjectList[objectIndex].sizeScaling = 0.15f;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
gObjectList[objectIndex].boundingBoxSize = 6;
gObjectList[objectIndex].velocity[1] = 4.0f;
set_object_flag_status_true(objectIndex, 0x04000000);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80081924(s32 objectIndex) {
@@ -6873,7 +6877,7 @@ void func_80081AFC(s32 objectIndex, s32 arg1) {
case 0x2:
if (object->unk_04C == 0) {
func_80086EAC(objectIndex, 2, 1);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
set_object_flag_status_true(objectIndex, 0x00000200);
} else {
object->unk_04C--;
@@ -6883,7 +6887,7 @@ void func_80081AFC(s32 objectIndex, s32 arg1) {
if (object->unk_0AE == 0) {
func_80086EAC(objectIndex, 2, 4);
func_8008153C(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x07));
}
break;
@@ -7107,7 +7111,7 @@ void func_8008241C(s32 objectIndex, s32 arg1) {
func_80086EF0(objectIndex);
gObjectList[objectIndex].spline = D_800E633C[arg1 % 4];
set_object_flag_status_true(objectIndex, 0x00000800);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80082714(s32 objectIndex, s32 arg1) {
@@ -7201,8 +7205,8 @@ void init_ktb_crab(s32 objectIndex) {
(u8*) d_course_koopa_troopa_beach_crab_frames, 0x40U, (u16) 0x00000040);
object = &gObjectList[objectIndex];
object->sizeScaling = 0.15f;
- object->itemDisplay = 0;
- func_80072488(objectIndex);
+ object->textureListIndex = 0;
+ object_next_state(objectIndex);
object->boundingBoxSize = 1;
set_object_flag_status_true(objectIndex, 0x04000420);
func_80086EAC(objectIndex, 0, 1);
@@ -7305,7 +7309,7 @@ void func_80082F1C(s32 objectIndex, s32 arg1) {
gObjectList[objectIndex].sizeScaling = 0.027f;
// if (test->rot && test->rot) {}
test = &D_800E5DF4[arg1];
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
set_obj_origin_pos(objectIndex, test->pos[0] * xOrientation, test->pos[1], test->pos[2]);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, test->rot, 0U);
@@ -7354,8 +7358,8 @@ void func_8008311C(s32 objectIndex, s32 arg1) {
object->activeTexture = d_course_yoshi_valley_hedgehog;
object->vertex = vtx;
object->sizeScaling = 0.2f;
- object->itemDisplay = 0;
- func_80072488(objectIndex);
+ object->textureListIndex = 0;
+ object_next_state(objectIndex);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
object->unk_034 = ((arg1 % 6) * 0.1) + 0.5;
@@ -7409,7 +7413,7 @@ void func_800833D0(s32 objectIndex, s32 arg1) {
func_80072D3C(objectIndex, 0, 1, 4, -1);
break;
}
- if (gObjectList[objectIndex].itemDisplay == 0) {
+ if (gObjectList[objectIndex].textureListIndex == 0) {
Vtx* vtx = (Vtx*) LOAD_ASSET(common_vtx_hedgehog);
gObjectList[objectIndex].vertex = vtx;
} else {
@@ -7480,7 +7484,7 @@ void func_8008379C(s32 objectIndex) {
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.74f,
gObjectList[objectIndex].unk_034, gObjectList[objectIndex].direction_angle[1],
0x00000064) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 2:
@@ -7501,8 +7505,8 @@ void func_80083868(s32 objectIndex) {
object = &gObjectList[objectIndex];
object->vertex = vtx;
object->sizeScaling = 0.1f;
- object->itemDisplay = 0;
- func_80072488(objectIndex);
+ object->textureListIndex = 0;
+ object_next_state(objectIndex);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
object->orientation[0] = 0;
object->orientation[1] = 0;
@@ -7566,8 +7570,8 @@ void func_80083B0C(s32 objectIndex) {
init_texture_object(objectIndex, d_course_frappe_snowland_snowman_tlut, sSnowmanBodyList, 0x40U, (u16) 0x00000040);
gObjectList[objectIndex].vertex = vtx;
gObjectList[objectIndex].sizeScaling = 0.1f;
- gObjectList[objectIndex].itemDisplay = 0;
- func_80072488(objectIndex);
+ gObjectList[objectIndex].textureListIndex = 0;
+ object_next_state(objectIndex);
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
gObjectList[objectIndex].orientation[0] = 0;
gObjectList[objectIndex].orientation[1] = 0;
@@ -7592,22 +7596,22 @@ void func_80083C04(s32 objectIndex) {
func_80083B0C(objectIndex);
break;
case 2:
- func_8007278C(objectIndex, 0x00000096);
+ set_and_run_timer_object(objectIndex, 0x00000096);
break;
case 10:
- if (func_8007278C(objectIndex, 0x0000012C) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000012C) != 0) {
func_800722A4(objectIndex, 2);
}
break;
case 11:
- if (func_8007278C(objectIndex, 0x0000000A) != 0) {
+ if (set_and_run_timer_object(objectIndex, 0x0000000A) != 0) {
set_object_flag_status_true(objectIndex, 0x00000010);
object->sizeScaling = 0.001f;
}
break;
case 12:
if (func_80074118(objectIndex, &object->sizeScaling, 0.001f, 0.1f, 0.0025f, 0, 0) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 13:
@@ -7675,7 +7679,7 @@ void func_80083F18(s32 objectIndex) {
if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.12f,
gObjectList[objectIndex].unk_034, gObjectList[objectIndex].direction_angle[1],
0x00000064) != 0) {
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
object_calculate_new_pos_offset(objectIndex);
break;
@@ -7765,7 +7769,7 @@ void func_80084430(s32 objectIndex, UNUSED s32 arg1) {
object->spline = D_800E672C[0];
set_object_flag_status_true(objectIndex, 0x04000800);
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_8008453C(s32 objectIndex, s32 arg1) {
@@ -7883,7 +7887,7 @@ void func_800845C8(s32 objectIndex, s32 arg1) {
func_80086EF0(objectIndex);
object->unk_034 = 0.0f;
object->type = get_animation_length(d_course_sherbet_land_unk_data11, 0);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80084B7C(s32 objectIndex, s32 arg1) {
@@ -7912,7 +7916,7 @@ void func_80084B7C(s32 objectIndex, s32 arg1) {
break;
case 4:
func_800722CC(objectIndex, 2);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
break;
}
if (func_80072320(objectIndex, 0x00000020) != 0) {
@@ -7955,7 +7959,7 @@ void func_80084D2C(s32 objectIndex, s32 arg1) {
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_09C = 1;
gObjectList[objectIndex].unk_0D8 = 1;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
@@ -7996,7 +8000,7 @@ void func_80084D2C(s32 objectIndex, s32 arg1) {
if (func_80087060(objectIndex, 0x0000000A) != 0) {
func_800722A4(objectIndex, 2);
gObjectList[objectIndex].unk_0D8 = 2;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
func_800726CC(objectIndex, 3);
@@ -8006,7 +8010,7 @@ void func_80084D2C(s32 objectIndex, s32 arg1) {
case 6:
if (func_80072354(objectIndex, 2) != 0) {
gObjectList[objectIndex].unk_0D8 = 0;
- gObjectList[objectIndex].itemDisplay = 0;
+ gObjectList[objectIndex].textureListIndex = 0;
gObjectList[objectIndex].type =
get_animation_length(d_course_sherbet_land_unk_data11, gObjectList[objectIndex].unk_0D8);
gObjectList[objectIndex].unk_0C6 += 0x8000;
@@ -8124,7 +8128,7 @@ void init_hot_air_balloon(s32 objectIndex) {
func_80086EF0(objectIndex);
gObjectList[objectIndex].velocity[1] = -2.0f;
init_actor_hot_air_balloon_item_box(0.0f, 0.0f, 0.0f);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80085534(s32 objectIndex) {
@@ -8223,7 +8227,7 @@ void func_80085878(s32 objectIndex, s32 arg1) {
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
object->unk_034 = 4.0f;
object->type = get_animation_length(d_rainbow_road_unk3, 0);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_800859C8(s32 objectIndex, s32 arg1) {
@@ -8269,7 +8273,7 @@ void func_80085BB4(s32 objectIndex) {
gObjectList[objectIndex].sizeScaling = 8.0f;
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
const char* sNeonMushroomList[] = { d_course_rainbow_road_neon_mushroom };
@@ -8295,13 +8299,13 @@ void func_80085CA0(s32 objectIndex) {
func_80072D3C(objectIndex, 3, 4, 4, 0x0000000A);
break;
case 4:
- func_8007278C(objectIndex, 0x00000014);
+ set_and_run_timer_object(objectIndex, 0x00000014);
break;
case 5:
func_80072E54(objectIndex, 0, 4, 1, 0x0000000C, 5);
break;
case 6:
- func_8007278C(objectIndex, 0x00000014);
+ set_and_run_timer_object(objectIndex, 0x00000014);
break;
case 7:
func_80072D3C(objectIndex, 3, 4, 0, 0x00000014);
@@ -8369,13 +8373,13 @@ void func_80085F74(s32 objectIndex) {
func_80072E54(objectIndex, 0, 4, 1, 5, 1);
break;
case 3:
- func_8007278C(objectIndex, 0x0000001E);
+ set_and_run_timer_object(objectIndex, 0x0000001E);
break;
case 4:
func_80072C00(objectIndex, 4, 0, 7);
break;
case 5:
- func_8007278C(objectIndex, 0x0000001E);
+ set_and_run_timer_object(objectIndex, 0x0000001E);
break;
case 6:
func_80072F88(objectIndex, 3, 0, 1, 5, 1);
@@ -8474,7 +8478,7 @@ void func_8008629C(s32 objectIndex, s32 arg1) {
set_obj_origin_offset(objectIndex, 0.0f, -10.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, 0xF8E4U, 0U);
gObjectList[objectIndex].unk_048 = 0;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
void func_80086424(s32 objectIndex) {
@@ -8506,10 +8510,10 @@ void func_80086528(s32 objectIndex, s32 arg1) {
func_8008629C(objectIndex, arg1);
break;
case 2:
- if (func_8007278C(objectIndex, gObjectList[objectIndex].unk_04C) != 0) {
+ if (set_and_run_timer_object(objectIndex, gObjectList[objectIndex].unk_04C) != 0) {
func_80091440(arg1);
func_80086E70(objectIndex);
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
case 0:
@@ -8517,7 +8521,7 @@ void func_80086528(s32 objectIndex, s32 arg1) {
case 3:
if (gObjectList[objectIndex].unk_0AE == 0) {
gObjectList[objectIndex].unk_048 = 1;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
}
break;
}
@@ -8581,7 +8585,7 @@ void func_80086700(s32 objectIndex) {
set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
set_obj_direction_angle(objectIndex, 0U, 0U, 0U);
gObjectList[objectIndex].unk_084[1] = 0x0200;
- func_80072488(objectIndex);
+ object_next_state(objectIndex);
func_80086E70(objectIndex);
}
diff --git a/src/update_objects.h b/src/update_objects.h
index 96c3c62ce..a50f05e04 100644
--- a/src/update_objects.h
+++ b/src/update_objects.h
@@ -26,11 +26,11 @@ void func_800722CC(s32, s32);
void func_800722F8(s32, s32);
bool func_80072320(s32, s32);
bool func_80072354(s32, s32);
-void set_object_unk_0CB(s32, s32);
+void set_object_timer_state(s32, s32);
void init_object(s32, s32);
void func_80072408(s32);
void func_80072428(s32);
-void func_80072488(s32);
+void object_next_state(s32);
void func_800724DC(s32);
void func_800724F8(s32, s32);
s16 func_80072530(s32);
@@ -41,7 +41,7 @@ void func_8007266C(s32);
void func_800726CC(s32, s32);
void func_8007271C(s32, s32);
void func_8007274C(s32);
-s32 func_8007278C(s32, s32);
+bool set_and_run_timer_object(s32, s32);
s32 func_8007281C(s32, s32);
s32 func_800728B0(s32, s32, s32);
void func_80072950(s32, s32, s32, s32);