Sri Krishna Devaraya falls in love with a court dancer. he decides to marry her but she refuses, so he decides to built a temple for their love, he throws a sphere to locate the place for constructing the temple. the sphere strikes the Goddess Tripura Sundari idol. thus cursing the king. his soul has to wait for the next 500 years to re-establish the Goddess idol back in place.
this he does entering bangaru raju alias the heir of the Rayala varu dynasty. thus completing his promise.