To reach Yoshi on the roof in Super Mario 64, you first need to collect all 120 stars. Doing so unlocks a cannon outside the castle — use it to launch onto the roof. Once up there, you'll find Yoshi along with the cap, and he'll reward you with the special triple jump ability that lets you reach even greater heights.