Before the Big Boo in the mission Ride Big Boo's Merry-Go-Round is defeated, the Merry-Go-Round rotates and plays music if Mario is near it. On the more technical side, the Merry-Go-Round's behavior consists of two functions, one of which is to handle playing music, and the other of which handles the rest of its behavior.
The purpose and outline of the first function is as follows: the game checks whether or not the Merry-Go-Round music should play, plays it if it should, and if not, does not play it and checks whether it should. If the music should not play, the game checks if Mario’s current room is near the Merry-Go-Round. If it is, the game plays the Merry-Go-Round music and BBH music at the same time and sets a variable that the Merry-Go-Round music should play. If the Merry-Go-Round music should play, the game goes through steps to check if it should continue to play. The game gets Mario’s floor and the floor’s surface type. If Mario’s floor is null, the floor type is set to 0. Otherwise, the floor type is obtained directly from Mario’s current floor. Then, the game checks if Mario is on the Merry-Go-Round platform or if Mario’s current floor has type 0x1A (used for the Merry-Go-Round). If either of these conditions are met, the game plays only the Merry-Go-Round music and sets a variable that Mario is on the Merry-Go-Round. Otherwise, the game plays both the Merry-Go-Round and BBH music and the variable for whether Mario is on the Merry-Go-Round is set to false. The game also has a check for whether or not Mario is in the Merry-Go-Round area of the basement. If Mario’s current room is not the Merry-Go-Round room, and his current room is not near the Merry-Go-Round room, the game goes back to playing the BBH music and sets that the Merry-Go-Round music should not play. If this check is not satisfied, the game plays the sound of the Merry-Go-Round creaking.
The Merry-Go-Round’s other function has two purposes: to play the howling wind sound and to move the Merry-Go-Round. The Merry-Go-Round object has an attribute for whether or not Mario is in the outside area of BBH. If this is set to false, the game checks whether Mario is in the outside area or not. If he is, the attribute is set to true. If the attribute is set to true, the sound of howling wind plays. Within the code that occurs when Mario is set to outside, if Mario’s current room is not the outside area of BBH and Mario’s room is not the Merry-Go-Round room, the Merry-Go-Round attribute for whether Mario is outside is set to false. For the movement, if the Merry-Go-Round should not be stopped, the Merry-Go-Rounds Angular Yaw Velocity is set to 128 angular units (.7 degrees), this value is added to the Merry-Go-Round’s moving angle and facing angle every frame, and the Merry-Go-Round music function is run. If the Merry-Go-Round should be stopped, the Angular Yaw Velocity is set to 0 and the music switches back to the BBH music.