"At the beginning of the first century BC, the site of the palace was occupied by a gate in the Roman walls. After the fall of the Western Roman Empire, the gate was used as a fortified stronghold in the defences of the city. Later the building became a possession of the Savoia-Acaja, a secondary branch of the House of Savoy; in the early fourteenth century, they enlarged it into a castle. After the extinction of the Acajas, the edifice became a residence for guests of the house of Savoy.
In 1637 the regent for Duke Charles II Emmanuel, Christine Marie of France, chose it as her personal residence. She commissioned the covering of the court and a revamping of the inner apartments. Sixty years later another regent, Marie Jeanne of Savoy, lived in the palace, conferring upon it definitively the nickname of Madama (Italian for Madame).
Later the palace had various uses, and housed the headquarters of the provisional French government during the Napoleonic Wars. In the 19th century King Charles Albert selected it as seat of the Pinacoteca Regia, the royal art gallery, and, later, of the Subalpine Senate (the Parliament of the Kingdom of Sardinia) and of the High Court. Since 1934 it has housed to the City Museum of Ancient Art." - in: wikipedia
This view of the castle can be seen from the Princes Street Gardens, a public park in the centre of Edinburgh, in the shadow of Edinburgh Castle. The Gardens were created in the 1820s following the long draining of the Nor Loch and the creation of the New Town. The Nor Loch was a large loch in the centre of the city. It was heavily polluted from centuries of sewage draining downhill from the Old Town.