I think it is "If you want me to return the princess, surrender the castle" as you said.
VVV=VVV= "If [you (the listener)] wanted (someone/some people who can control the action of VVV) to VVV" where VVV is an action. sounds old, overly elegant, or demanding while is more contemporary, less elegant, and less demanding.
i.e
() = If [you] wanted (person/people in control) to eat
() = If [you] wanted (person/people in control) to stop
() = If [you] wanted (person/people in control) to resign
() = If [you] wanted (person/people in control) to release (some people)
()() = If [you] wanted (person/people in control) to take (some people) (somewhere)
I am just answering from my language experience (Japanese is my first language) and I am not a scholar. I hope I helped a little bit.