You have to get 150 stars .
After collecting all 120 stars, a cannon will appear outside of the castle. Use this cannon to blast yourself to the top of the castle. At the top of the castle, you'll find Yoshi, who will give you 100 extra lives.
To get to the top of the castle on Super Mario 64, there are two ways. The first is to get a running start (running towards the right side corner of the castle), jump on the castle wall, then on the grass, then back on to nearly grab onto the edge, and get on top of the castle. The second way is to get all of the stars, then a cannon will be accessible out on the front part of the castle. Then, climb into the cannon and shoot yourself on top of the castle.
get all the stars to unlock the cannon
You will need to collect all 150 stars and the cannon in front of the castle should open and then all you have to do is go in the cannon and blast off.
You can use the cannon to shoot up to the top of the castle. Yoshi is there in the Nintendo 64 version. After you talk to him, you will have 100 lives.
I've heard you can use the cannon by getting 120 stars. I say that you should you DS action replay to moon jump on the castle.
You use the moon jump cheat.
a castle turret is a cannon poking through the wall of the castle
You must collect all 150 (160 if I'm not correct) stars. Once that is achieved, go outside and out to the sandy area. the gate that was on top of the cannon underneath is now gone, you can go into the cannon and on top of the castle. Be aware that there is a glitch where, being luigi, can go to the left side of the castle where the waterfall is and backflip onto the grassy ledge and use a glitch to get up the steep slope to the top of the castle.
well once you have 125 stars, the cannon opens, once it does use it to get to the top of the castle, there you will find Yoshi and three one ups
on the levels that are closest to it on them you have to complete the level in a sneaky shortcut kind of way to get a red flag instead of black
You go to the top of the castle and defeat Bowser. After you have defeated Bowser you will have completed the game. If you did that and you won. CONGRATULATIONS