clock_arm.inc.c (2415B)
1 // clock_arm.inc.c 2 3 /** 4 * Main loop of the hour and minute hands of the Tick Tock Clock painting. 5 */ 6 void bhv_rotating_clock_arm_loop(void) { 7 struct Surface *marioSurface; 8 u16 rollAngle = o->oFaceAngleRoll; 9 10 o->oFloorHeight = 11 find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &marioSurface); 12 13 // Seems to make sure Mario is on a default surface & 4 frames pass before 14 // allowing him to change the Tick Tock Clock speed setting. 15 // Probably a safety check for when you leave the level through the painting 16 // to make sure the setting isn't accidentally locked in as you fly out. 17 if (o->oAction == 0) { 18 if (marioSurface->type == SURFACE_DEFAULT && o->oTimer >= 4) { 19 o->oAction++; 20 } 21 } else if (o->oAction == 1) { 22 // If Mario is touching the Tick Tock Clock painting... 23 if (marioSurface != NULL 24 && (marioSurface->type == SURFACE_TTC_PAINTING_1 25 || marioSurface->type == SURFACE_TTC_PAINTING_2 26 || marioSurface->type == SURFACE_TTC_PAINTING_3)) { 27 // And this is the minute hand... 28 if (cur_obj_has_behavior(bhvClockMinuteHand)) { 29 // Set Tick Tick Clock's speed based on the angle of the hand. 30 // The angle actually counting down from 0xFFFF to 0 so 31 // 11 o'clock is a small value and 1 o'clock is a large value. 32 if (rollAngle < 0xAAA) { // > 345 degrees from 12 o'clock. 33 gTTCSpeedSetting = TTC_SPEED_STOPPED; 34 } else if (rollAngle < 0x6AA4) { // 210..345 degrees from 12 o'clock. 35 gTTCSpeedSetting = TTC_SPEED_FAST; 36 } else if (rollAngle < 0x954C) { // 150..210 degrees from 12 o'clock. 37 gTTCSpeedSetting = TTC_SPEED_RANDOM; 38 } else if (rollAngle < 0xF546) { // 15..150 degrees from 12 o'clock. 39 gTTCSpeedSetting = TTC_SPEED_SLOW; 40 } else { // < 15 degrees from 12 o'clock. 41 gTTCSpeedSetting = TTC_SPEED_STOPPED; 42 } 43 } 44 45 // Increment the action to stop animating the hands. 46 o->oAction++; 47 } else { 48 } 49 } 50 51 // Only rotate the hands until Mario enters the painting. 52 if (o->oAction < 2) { 53 cur_obj_rotate_face_angle_using_vel(); 54 } 55 }