Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behaviors/bbh_merry_go_round.inc.c
7861 views
1
/**
2
* Behavior for bhvMerryGoRound.
3
* This is the merry-go-round in BBH.
4
*/
5
6
/**
7
* This function handles the merry-go-round's music.
8
* It starts the music when Mario enters the room around the
9
* merry-go-round's enclosure, and ends the music when he's neither
10
* in the enclosure nor in the room around it.
11
*/
12
static void handle_merry_go_round_music(void) {
13
// If the music should play, play it and check whether it still should.
14
// Otherwise, don't play it and check whether it should.
15
if (o->oMerryGoRoundMusicShouldPlay == FALSE) {
16
if (gMarioCurrentRoom == BBH_NEAR_MERRY_GO_ROUND_ROOM) {
17
// Play the merry-go-round and BBH music at the same time
18
play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 45, 20, 200);
19
// Set to TRUE
20
o->oMerryGoRoundMusicShouldPlay++;
21
}
22
} else {
23
// Get Mario's floor and floor surface type
24
struct Surface *marioFloor;
25
u16 marioFloorType;
26
27
find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &marioFloor);
28
29
if (marioFloor == NULL) {
30
marioFloorType = 0;
31
} else {
32
marioFloorType = marioFloor->type;
33
}
34
35
// All floors in the merry-go-round's enclosure have surface type 0x1A.
36
// The cur_obj_is_mario_on_platform check is redundant since the merry-go-round
37
// has surface type 0x1A, so Mario cannot be on the merry-go-round
38
// without being on a floor with surface type 0x1A (SURFACE_MGR_MUSIC).
39
if (cur_obj_is_mario_on_platform() || marioFloorType == SURFACE_MGR_MUSIC) {
40
// If Mario is in the merry-go-round's enclosure, play only the merry-go-round music.
41
play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 0, 78, 50);
42
gMarioOnMerryGoRound = TRUE;
43
} else {
44
// If Mario is not in the merry-go-round's enclosure,
45
// i.e. he's around it, play both the merry-go-round music and the BBH music.
46
play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 45, 20, 200);
47
gMarioOnMerryGoRound = FALSE;
48
}
49
50
// If Mario is not in the merry-go-round's area of the basement anymore,
51
// stop playing the music.
52
// If he is, play the creaking sound.
53
if (
54
// The merry-go-round is a dynamic surface.
55
gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM
56
&& gMarioCurrentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) {
57
func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling
58
o->oMerryGoRoundMusicShouldPlay = FALSE;
59
} else {
60
cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING);
61
}
62
}
63
}
64
65
/**
66
* Merry-go-round update function.
67
*/
68
void bhv_merry_go_round_loop(void) {
69
// Surprisingly, the merry-go-round is what's responsible
70
// for playing the howling wind sound in BBH.
71
if (!o->oMerryGoRoundMarioIsOutside) {
72
if (gMarioCurrentRoom == BBH_OUTSIDE_ROOM) {
73
// Set to TRUE
74
o->oMerryGoRoundMarioIsOutside++;
75
}
76
} else {
77
play_sound(SOUND_AIR_HOWLING_WIND, gGlobalSoundSource);
78
79
if (
80
// There are objects outside BBH, such as corkboxes.
81
// The howling wind should not stop when Mario stands on a cork box.
82
//! @bug Interestingly, this means if Mario goes from outside
83
// to a dynamic surface *inside* the mansion in a single frame,
84
// the howling wind music will still play.
85
gMarioCurrentRoom != BBH_OUTSIDE_ROOM && gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM) {
86
o->oMerryGoRoundMarioIsOutside = FALSE;
87
}
88
}
89
90
// Rotate the merry-go-round and play appropriate music if it's not stopped.
91
if (!o->oMerryGoRoundStopped) {
92
o->oAngleVelYaw = 0x80;
93
o->oMoveAngleYaw += o->oAngleVelYaw;
94
o->oFaceAngleYaw += o->oAngleVelYaw;
95
handle_merry_go_round_music();
96
} else {
97
o->oAngleVelYaw = 0;
98
func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling
99
}
100
}
101
102