in addition to viceroy he was captain general and president of the royal court