Path: blob/master/src/game/behaviors/bbh_merry_go_round.inc.c
7861 views
/**1* Behavior for bhvMerryGoRound.2* This is the merry-go-round in BBH.3*/45/**6* This function handles the merry-go-round's music.7* It starts the music when Mario enters the room around the8* merry-go-round's enclosure, and ends the music when he's neither9* in the enclosure nor in the room around it.10*/11static void handle_merry_go_round_music(void) {12// If the music should play, play it and check whether it still should.13// Otherwise, don't play it and check whether it should.14if (o->oMerryGoRoundMusicShouldPlay == FALSE) {15if (gMarioCurrentRoom == BBH_NEAR_MERRY_GO_ROUND_ROOM) {16// Play the merry-go-round and BBH music at the same time17play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 45, 20, 200);18// Set to TRUE19o->oMerryGoRoundMusicShouldPlay++;20}21} else {22// Get Mario's floor and floor surface type23struct Surface *marioFloor;24u16 marioFloorType;2526find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &marioFloor);2728if (marioFloor == NULL) {29marioFloorType = 0;30} else {31marioFloorType = marioFloor->type;32}3334// All floors in the merry-go-round's enclosure have surface type 0x1A.35// The cur_obj_is_mario_on_platform check is redundant since the merry-go-round36// has surface type 0x1A, so Mario cannot be on the merry-go-round37// without being on a floor with surface type 0x1A (SURFACE_MGR_MUSIC).38if (cur_obj_is_mario_on_platform() || marioFloorType == SURFACE_MGR_MUSIC) {39// If Mario is in the merry-go-round's enclosure, play only the merry-go-round music.40play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 0, 78, 50);41gMarioOnMerryGoRound = TRUE;42} else {43// If Mario is not in the merry-go-round's enclosure,44// i.e. he's around it, play both the merry-go-round music and the BBH music.45play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 45, 20, 200);46gMarioOnMerryGoRound = FALSE;47}4849// If Mario is not in the merry-go-round's area of the basement anymore,50// stop playing the music.51// If he is, play the creaking sound.52if (53// The merry-go-round is a dynamic surface.54gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM55&& gMarioCurrentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) {56func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling57o->oMerryGoRoundMusicShouldPlay = FALSE;58} else {59cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING);60}61}62}6364/**65* Merry-go-round update function.66*/67void bhv_merry_go_round_loop(void) {68// Surprisingly, the merry-go-round is what's responsible69// for playing the howling wind sound in BBH.70if (!o->oMerryGoRoundMarioIsOutside) {71if (gMarioCurrentRoom == BBH_OUTSIDE_ROOM) {72// Set to TRUE73o->oMerryGoRoundMarioIsOutside++;74}75} else {76play_sound(SOUND_AIR_HOWLING_WIND, gGlobalSoundSource);7778if (79// There are objects outside BBH, such as corkboxes.80// The howling wind should not stop when Mario stands on a cork box.81//! @bug Interestingly, this means if Mario goes from outside82// to a dynamic surface *inside* the mansion in a single frame,83// the howling wind music will still play.84gMarioCurrentRoom != BBH_OUTSIDE_ROOM && gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM) {85o->oMerryGoRoundMarioIsOutside = FALSE;86}87}8889// Rotate the merry-go-round and play appropriate music if it's not stopped.90if (!o->oMerryGoRoundStopped) {91o->oAngleVelYaw = 0x80;92o->oMoveAngleYaw += o->oAngleVelYaw;93o->oFaceAngleYaw += o->oAngleVelYaw;94handle_merry_go_round_music();95} else {96o->oAngleVelYaw = 0;97func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling98}99}100101102