Skip to content

Commit f5caebc

Browse files
Document *.m64 sequence IDs (and also add support for custom track music) (#740)
* Document sequence IDs * Document sequence IDs * Document sequence IDs * Document sequence IDs * Document sequence IDs * Fix function comments * Properly identify the podium ceremony sequence; fix comments --------- Co-authored-by: MegaMech <[email protected]>
1 parent bb8ac99 commit f5caebc

File tree

8 files changed

+185
-107
lines changed

8 files changed

+185
-107
lines changed

include/seq_ids.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef SEQ_IDS_H
2+
#define SEQ_IDS_H
3+
4+
enum SeqId {
5+
SEQ_SOUND_PLAYER, // 0x00 (00)
6+
SEQ_MENU_TITLE_SCREEN, // 0x01 (01)
7+
SEQ_MENU_MAIN_MENU, // 0x02 (02)
8+
SEQ_TRACK_RACEWAY, // 0x03 (03)
9+
SEQ_TRACK_FARM, // 0x04 (04)
10+
SEQ_TRACK_MOUNTAIN, // 0x05 (05)
11+
SEQ_TRACK_BEACH, // 0x06 (06)
12+
SEQ_TRACK_SCARY, // 0x07 (07)
13+
SEQ_TRACK_SNOW, // 0x08 (08)
14+
SEQ_TRACK_CASTLE, // 0x09 (09)
15+
SEQ_TRACK_DESERT, // 0x0A (10)
16+
SEQ_EVENT_RACE_STARTING, // 0x0B (11)
17+
SEQ_EVENT_RACE_FINAL_LAP, // 0x0C (12)
18+
SEQ_EVENT_RACE_FINISH_FIRST, // 0x0D (13)
19+
SEQ_EVENT_RACE_FINISH_OTHER, // 0x0E (14)
20+
SEQ_EVENT_RACE_FINISH_LOSE, // 0x0F (15)
21+
SEQ_MENU_RESULTS_SCREEN_WIN, // 0x10 (16)
22+
SEQ_EVENT_RACE_POWERUP_STAR, // 0x11 (17)
23+
SEQ_TRACK_RAINBOW, // 0x12 (18)
24+
SEQ_TRACK_JUNGLE, // 0x13 (19)
25+
SEQ_EVENT_CEREMONY_TROPHY_LOSE, // 0x14 (20)
26+
SEQ_TRACK_TURNPIKE, // 0x15 (21)
27+
SEQ_EVENT_RACE_STARTING_VS, // 0x16 (22)
28+
SEQ_MENU_RESULTS_SCREEN_WIN_VS, // 0x17 (23)
29+
SEQ_MENU_RESULTS_SCREEN_LOSE, // 0x18 (24)
30+
SEQ_TRACK_BATTLE, // 0x19 (25)
31+
SEQ_EVENT_CEREMONY_PRESENTATION_PART1, // 0x1A (26)
32+
SEQ_EVENT_CEREMONY_PRESENTATION_PART2_WIN, // 0x1B (27)
33+
SEQ_EVENT_CEREMONY_TROPHY_CREDITS, // 0x1C (28)
34+
SEQ_EVENT_CEREMONY_PRESENTATION_PART2_LOSE, // 0x1D (29)
35+
SEQ_COUNT
36+
};
37+
38+
#endif // SEQ_IDS_H

src/audio/external.c

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "code_800029B0.h"
1515
#include "cpu_vehicles_camera_path.h"
1616
#include "menu_items.h"
17+
#include "seq_ids.h"
1718

1819
s8 D_8018EF10;
1920
UnkStruct8018EF18 D_8018EF18[16];
@@ -2397,6 +2398,13 @@ void func_800C70A8(u8 playerId) {
23972398
}
23982399
}
23992400

2401+
/*
2402+
Routine to tell the game which "finish" music to play depending on which mode the player is in (Grand Prix, Time Trials, etc),
2403+
whether the game is in multiplayer or not, and which position they ended up finishing in (1st, 2nd, 3rd, etc)
2404+
2405+
Contains a LOT of inlined funcs.
2406+
Modify if you dare.
2407+
*/
24002408
void func_800C76C0(u8 playerId) {
24012409
if (D_800E9EA4[playerId] != 0) {
24022410
if (D_800E9EA4[playerId] < 0x2BC) {
@@ -2420,15 +2428,15 @@ void func_800C76C0(u8 playerId) {
24202428
func_800C97C4(playerId);
24212429
D_800EA0F0 = 2;
24222430
func_800C9A88(playerId);
2423-
func_800CA414(0x000DU, 0x0010U);
2431+
play_sequences(SEQ_EVENT_RACE_FINISH_FIRST, SEQ_MENU_RESULTS_SCREEN_WIN);
24242432
} else if (gPlayers[playerId].currentRank < 4) {
24252433
func_800C97C4(playerId);
24262434
D_800EA0F0 = 2;
24272435
func_800C9A88(playerId);
2428-
func_800CA414(0x000EU, 0x0010U);
2436+
play_sequences(SEQ_EVENT_RACE_FINISH_OTHER, SEQ_MENU_RESULTS_SCREEN_WIN);
24292437
} else {
24302438
func_800C3448(-0x3E9F9C00);
2431-
func_800CA414(0x000FU, 0x0018U);
2439+
play_sequences(SEQ_EVENT_RACE_FINISH_LOSE, SEQ_MENU_RESULTS_SCREEN_LOSE);
24322440
}
24332441
} else {
24342442
D_800EA0EC[playerId] = 2;
@@ -2439,7 +2447,7 @@ void func_800C76C0(u8 playerId) {
24392447
func_800C97C4(playerId);
24402448
D_800EA0F0 = 2;
24412449
func_800C9A88(playerId);
2442-
func_800CA414(0x000DU, 0x0010U);
2450+
play_sequences(SEQ_EVENT_RACE_FINISH_FIRST, SEQ_MENU_RESULTS_SCREEN_WIN);
24432451
} else if (gPlayers[playerId].currentRank < 4) {
24442452
if (D_800EA104 == 0) {
24452453
func_800C3448(0x100100FF);
@@ -2448,12 +2456,12 @@ void func_800C76C0(u8 playerId) {
24482456
func_800C97C4(playerId);
24492457
D_800EA0F0 = 2;
24502458
func_800C9A88(playerId);
2451-
func_800CA414(0x000EU, 0x0010U);
2459+
play_sequences(SEQ_EVENT_RACE_FINISH_OTHER, SEQ_MENU_RESULTS_SCREEN_WIN);
24522460
} else if (D_800EA104 == 0) {
24532461
func_800C3448(0x100100FF);
24542462
func_800C3448(0x110100FF);
24552463
func_800C3448(-0x3E9F9C00);
2456-
func_800CA414(0x000FU, 0x0018U);
2464+
play_sequences(SEQ_EVENT_RACE_FINISH_LOSE, SEQ_MENU_RESULTS_SCREEN_LOSE);
24572465
}
24582466
if ((D_800EA104 != 0) || (D_800EA0EC[playerId] != 1)) {
24592467
func_800C5278(5U);
@@ -2469,9 +2477,9 @@ void func_800C76C0(u8 playerId) {
24692477
D_800EA0EC[playerId] = 2;
24702478
func_800C9060(playerId, 0x1900F103U);
24712479
if (D_801657E5 == 1) {
2472-
func_800CA414(0x000DU, 0x0010U);
2480+
play_sequences(SEQ_EVENT_RACE_FINISH_FIRST, SEQ_MENU_RESULTS_SCREEN_WIN);
24732481
} else if (D_8018ED90 == 1) {
2474-
func_800CA414(0x000EU, 0x0010U);
2482+
play_sequences(SEQ_EVENT_RACE_FINISH_OTHER, SEQ_MENU_RESULTS_SCREEN_WIN);
24752483
} else {
24762484
func_800C3448(0x01640010);
24772485
}
@@ -2486,16 +2494,16 @@ void func_800C76C0(u8 playerId) {
24862494
func_800C97C4(playerId);
24872495
D_800EA0F0 = 2;
24882496
func_800C9A88(playerId);
2489-
func_800CA414(0x000DU, 0x0017U);
2497+
play_sequences(SEQ_EVENT_RACE_FINISH_FIRST, SEQ_MENU_RESULTS_SCREEN_WIN_VS);
24902498
break;
24912499
case 2: /* switch 1 */
24922500
if ((D_800EA104 == 0) && (D_800EA0EC[playerId] == 1)) {
24932501
func_800C3448(0x100100FF);
24942502
func_800C3448(0x110100FF);
24952503
#ifdef VERSION_EU
2496-
func_800C8EF8(0x000DU);
2504+
play_sequence2(SEQ_EVENT_RACE_FINISH_FIRST);
24972505
#else
2498-
func_800CA414(0x000DU, 0x0017U);
2506+
play_sequences(SEQ_EVENT_RACE_FINISH_FIRST, SEQ_MENU_RESULTS_SCREEN_WIN_VS);
24992507
#endif
25002508
D_800EA104 = 1;
25012509
} else if ((D_800EA104 == 1) && (D_800EA0EC[playerId] == 1)) {
@@ -2505,7 +2513,7 @@ void func_800C76C0(u8 playerId) {
25052513
#endif
25062514
{
25072515
D_800EA104 = 0;
2508-
func_800CA414(0x000EU, 0x0017U);
2516+
play_sequences(SEQ_EVENT_RACE_FINISH_OTHER, SEQ_MENU_RESULTS_SCREEN_WIN_VS);
25092517
}
25102518
D_800EA104 = 2;
25112519
}
@@ -2514,12 +2522,12 @@ void func_800C76C0(u8 playerId) {
25142522
if ((D_800EA104 == 0) && (D_800EA0EC[playerId] == 1)) {
25152523
func_800C3448(0x100100FF);
25162524
func_800C3448(0x110100FF);
2517-
func_800C8EF8(0x000DU);
2525+
play_sequence2(SEQ_EVENT_RACE_FINISH_FIRST);
25182526
D_800EA104 = 1;
25192527
} else if ((D_800EA104 == 1) && (D_800EA0EC[playerId] == 1)) {
25202528
if (func_800C3508(1) != 0x000D) {
25212529
D_800EA104 = 0;
2522-
func_800C8EF8(0x000EU);
2530+
play_sequence2(SEQ_EVENT_RACE_FINISH_OTHER);
25232531
}
25242532
D_800EA104 = 2;
25252533
} else if ((D_800EA104 == 2) && (D_800EA0EC[playerId] == 1)) {
@@ -2529,7 +2537,7 @@ void func_800C76C0(u8 playerId) {
25292537
#endif
25302538
{
25312539
D_800EA104 = 0;
2532-
func_800CA414(0x000EU, 0x0017U);
2540+
play_sequences(SEQ_EVENT_RACE_FINISH_OTHER, SEQ_MENU_RESULTS_SCREEN_WIN_VS);
25332541
}
25342542
D_800EA104 = 3;
25352543
}
@@ -2543,7 +2551,7 @@ void func_800C76C0(u8 playerId) {
25432551
func_800C3448(0x110100FF);
25442552
func_800C5278(5U);
25452553
func_800C9018(playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xF9, 0x26));
2546-
func_800C8EF8(0x0017U);
2554+
play_sequence2(SEQ_MENU_RESULTS_SCREEN_WIN_VS);
25472555
D_800EA0EC[playerId] = 2;
25482556
func_800C90F4(playerId, (gPlayers[gPlayerWinningIndex].characterId * 0x10) +
25492557
SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D));
@@ -2552,7 +2560,7 @@ void func_800C76C0(u8 playerId) {
25522560
if ((D_800EA0EC[0] == 1) && (D_800EA0EC[1] == 1) && (D_800EA0EC[2] == 1)) {
25532561
func_800C5278(5U);
25542562
func_800C9018(playerId, SOUND_ARG_LOAD(0x01, 0x00, 0x80, 0x26));
2555-
func_800C8EF8(0x0017U);
2563+
play_sequence2(SEQ_MENU_RESULTS_SCREEN_WIN_VS);
25562564
D_800EA0EC[playerId] = 2;
25572565
func_800C90F4(playerId, (gPlayers[gPlayerWinningIndex].characterId * 0x10) +
25582566
SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D));
@@ -2563,7 +2571,7 @@ void func_800C76C0(u8 playerId) {
25632571
(D_800EA0EC[3] == 1)) {
25642572
func_800C5278(5U);
25652573
func_800C9018(playerId, SOUND_ARG_LOAD(0x01, 0x00, 0x80, 0x26));
2566-
func_800C8EF8(0x0017U);
2574+
play_sequence2(SEQ_MENU_RESULTS_SCREEN_WIN_VS);
25672575
D_800EA0EC[playerId] = 2;
25682576
func_800C90F4(playerId, (gPlayers[gPlayerWinningIndex].characterId * 0x10) +
25692577
SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D));
@@ -2880,14 +2888,14 @@ void play_sound2(s32 soundBits) {
28802888
play_sound(soundBits, &D_800EA1C8, 4, &D_800EA1D4, &D_800EA1D4, &D_800EA1DC);
28812889
}
28822890

2883-
void func_800C8EAC(u16 arg0) {
2884-
func_800C3448(arg0 | 0x10000);
2885-
D_800EA15C = arg0;
2891+
void play_sequence(u16 index) {
2892+
func_800C3448(index | 0x0010000);
2893+
D_800EA15C = index;
28862894
}
28872895

2888-
void func_800C8EF8(u16 arg0) {
2889-
func_800C3448(arg0 | 0x1010000);
2890-
D_800EA160 = arg0;
2896+
void play_sequence2(u16 index) {
2897+
func_800C3448(index | 0x1010000);
2898+
D_800EA160 = index;
28912899
}
28922900

28932901
void func_800C8F44(u8 arg0) {
@@ -3309,12 +3317,12 @@ void func_800CA388(u8 arg0) {
33093317
fade_channel_volume_scale(5, 0, arg0);
33103318
}
33113319

3312-
void func_800CA414(u16 arg0, u16 arg1) {
3320+
void play_sequences(u16 first, u16 second) {
33133321
if (D_800EA104 == 0) {
33143322
func_800C3448(func_800C3508(0) | 0x30000000);
33153323
func_800C35E8(0);
3316-
func_800C3448(arg1 | 0xC1510000);
3317-
func_800C3448(arg0 | 0x1000000);
3324+
func_800C3448(second | 0xC1510000);
3325+
func_800C3448(first | 0x01000000);
33183326
}
33193327
D_800EA104 = 1;
33203328
}
@@ -3326,12 +3334,12 @@ void func_800CA49C(u8 playerIndex) {
33263334
} else if (D_800EA164 != 0) {
33273335
func_800C3448(0x100100FF); // 0x19000000
33283336
func_800C3448(0x110100FF);
3329-
func_800C8EF8(0xC);
3337+
play_sequence2(SEQ_EVENT_RACE_FINAL_LAP);
33303338
func_800C3448(0xC1510011);
33313339
} else {
33323340
func_800C3448(0x100100FF); // 0x19000000
33333341
func_800C3448(0x110100FF);
3334-
func_800C8EF8(0xC);
3342+
play_sequence2(SEQ_EVENT_RACE_FINAL_LAP);
33353343
func_800C3448(D_800EA15C | 0xC1500000);
33363344
func_800C3448(0xC130017D);
33373345
}
@@ -3355,11 +3363,11 @@ void func_800CA59C(u8 playerId) {
33553363
func_800C3448(0xC1F00000);
33563364
func_800C3448(0xC1510011);
33573365
} else {
3358-
func_800C8EF8(0x0011U);
3366+
play_sequence2(SEQ_EVENT_RACE_POWERUP_STAR);
33593367
}
33603368
} else {
33613369
if (1) {} // ?
3362-
func_800C8EF8(0x0011U);
3370+
play_sequence2(SEQ_EVENT_RACE_POWERUP_STAR);
33633371
}
33643372
}
33653373
D_800EA10C[playerId] = 1;
@@ -3382,20 +3390,20 @@ void func_800CA730(u8 playerIndex) {
33823390
if (D_8018FC08 != 0) {
33833391
if (((u32) (gSequencePlayers[1].enabled)) == 0) {
33843392
func_800C3608(1, 5);
3385-
func_800C8EAC(D_800EA15C);
3393+
play_sequence(D_800EA15C);
33863394
func_800C3448(0xB001307DU);
33873395
} else if ((func_800C3508(1) == 0xC) || (func_800C357C(0x0101000C) == 0)) {
33883396
func_800C3448(0xC1F00000U);
33893397
func_800C3448(D_800EA15C | 0xC1500000);
33903398
func_800C3448(0xC130017DU);
33913399
} else {
33923400
func_800C3448(0x110100FFU);
3393-
func_800C8EAC(D_800EA15C);
3401+
play_sequence(D_800EA15C);
33943402
func_800C3448(0xB001307DU);
33953403
}
33963404
} else {
33973405
func_800C3448(0x110100FFU);
3398-
func_800C8EAC(D_800EA15C);
3406+
play_sequence(D_800EA15C);
33993407
}
34003408
}
34013409
D_800EA164 = 0;
@@ -3556,41 +3564,54 @@ void func_800CB134() {
35563564
D_800EA174 = 1;
35573565
}
35583566

3559-
void func_800CB14C() {
3567+
/*
3568+
Play the entire "losing" sequence for the podium ceremony.
3569+
3570+
Increments a timer value by one per frame in order to tell which part of the sequence to play at which point.
3571+
*/
3572+
void begin_losing_ceremony_sequence() {
35603573
if (D_800EA174 != 0) {
35613574
D_800EA174++;
3575+
35623576
if (D_800EA174 == 3) {
3563-
func_800C8EAC(0x001AU);
3577+
play_sequence(SEQ_EVENT_CEREMONY_PRESENTATION_PART1); // Begin with Part 1 of the ceremony presentation music --- "Everything seems normal..."
35643578
func_800C3448(0x4000007F);
35653579
}
3566-
if (D_800EA174 == 0x012C) {
3567-
func_800C8EAC(0x001BU);
3580+
3581+
if (D_800EA174 == 300) {
3582+
play_sequence(SEQ_EVENT_CEREMONY_PRESENTATION_PART2_WIN); // Follow up with Part 2 of the winning ceremony presentation music --- "Looks like I won...?"
35683583
func_800C3448(0x4000007F);
3569-
func_800C8EF8(0x001DU);
3584+
play_sequence2(SEQ_EVENT_CEREMONY_PRESENTATION_PART2_LOSE); // Once it ends, begin the LOSING ceremony presentation music, which has a few notes changed to be off-tune --- "Uh oh..."
35703585
func_800C3448(0x41000000);
35713586
}
3572-
if (D_800EA174 == 0x0230) {
3587+
3588+
if (D_800EA174 == 560) { // (Somewhere in this code it slows down the music, changes the pitch of it and completely breaks the music)
35733589
func_800C3448(0x40640000);
35743590
func_800C3448(0xB0640073);
35753591
func_800C3448(0x4150007F);
35763592
func_800C3448(0xB1640073);
35773593
}
3578-
if (D_800EA174 == 0x02A8) {
3594+
3595+
if (D_800EA174 == 680) {
35793596
func_800C3448(0x100100FF);
35803597
}
3581-
if (D_800EA174 == 0x041A) {
3598+
3599+
if (D_800EA174 == 1050) {
35823600
func_800C3448(0xB1500001);
35833601
func_800C3448(0x51500001);
35843602
}
3585-
if (D_800EA174 == 0x046A) {
3603+
3604+
if (D_800EA174 == 1130) {
35863605
func_800C3448(0x41320000);
35873606
}
3588-
if (D_800EA174 == 0x04B0) {
3607+
3608+
if (D_800EA174 == 1200) { // (Player gets hit by the bomb-omb car; play the "explosion" sound effect and the "hurt" voice for the current character)
35893609
func_800C3448(0x110100FF);
35903610
}
3591-
if (D_800EA174 == 0x04CE) {
3592-
func_800C8EAC(0x0014U);
3593-
func_800C3448(0x4000007F);
3611+
3612+
if (D_800EA174 == 1230) { // Once the music is completely broken by this point, play the "No Trophy For You!" sequence --- "Aw man, I lost... :("
3613+
play_sequence(SEQ_EVENT_CEREMONY_TROPHY_LOSE);
3614+
func_800C3448(0x4000007F); // (Play the "losing" voice for the current character, twice)
35943615
}
35953616
}
35963617
}

src/audio/external.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ void func_800C8AE4(void);
270270
void func_800C8C7C(u8);
271271
void func_800C8CCC(void);
272272
void play_sound2(s32);
273-
void func_800C8EAC(u16);
274-
void func_800C8EF8(u16);
273+
void play_sequence(u16);
274+
void play_sequence2(u16);
275275
void func_800C8F44(u8);
276276
void func_800C8F80(u8, u32);
277277

@@ -304,7 +304,7 @@ void func_800CA2E4(u8, s8);
304304
void func_800CA30C(u8);
305305
void func_800CA330(u8);
306306
void func_800CA388(u8);
307-
void func_800CA414(u16, u16);
307+
void play_sequences(u16, u16);
308308
void func_800CA49C(u8);
309309
void func_800CA59C(u8);
310310
void func_800CA984(u8);
@@ -317,7 +317,7 @@ void func_800CAEC4(u8, f32);
317317
void func_800CAFC0(u8);
318318

319319
void func_800CB134(void);
320-
void func_800CB14C(void);
320+
void begin_losing_ceremony_sequence(void);
321321
void func_800CB2C4(void);
322322
void func_800CBC24(void);
323323

0 commit comments

Comments
 (0)