The Legend of Zelda: Gears of Moonlight

Ganon plans to destroy the Hyrule Castle and take over it. It decides to make an army to stop Link from saving Hyrule. Link hears about the attack as soon as it happens and he figures a plan to escape Ganon's army. He ventures to find his brother, but he is not at his house. Instead he finds a book that shows that 8 gears hidden in a different kingdom had the power to destroy armies and break spells, and it also restores destroyed places like Hyrule Castle. He then tries to find all of them, but it dosent work. He reads through the book and tells him that he needs to wait till dusk. At dusk, he unleashed it's power and defeated Ganon, which then gets sealed inside the gears and it dissappears