-------------------------------------------------------------------- Edward Sheehan is the author of ''Kingdoms,'' which opens tonight at the Cort. By EDWARD SHEEHAN

In the late spring of 1812, there occurred in Italy and France one of the great sacrileges of history. Pope Pius VII, who had been held a prisoner at Savona near Genoa by the Emperor Napoleon I since 1809, was cruelly dragged over the Alps, in precarious health, to Fontainebleau in France. The Pope arrived at the gates of Fontainebleau Castle nearly a corpse.

Shortly before the Pope's journey, Napoleon had written to Prince Borghese at Turin: ''Precautions will be taken to see that (Pius VII) passes through Turin at night ... that he passes through Chambery and Lyon at night. ... The Pope must not travel in his Pontifical robes ... (but) in such a way that nowhere ... can he be recognized.''

The Emperor's orders were executed with brutal precision. Clad in the black cassock of a common priest, the Supreme Pontiff was bundled into a carriage in the deep of night with only his quack doctor (provided by Napoleon) for a companion, and dispatched, already ill, northward to France. High in the Alps, his bowels became blocked, he could not urinate for days, and his agony, as the horses galloped on, was unbearable. Delirious with fever, the Pontiff cried out that he would throw himself on the road and die there if he were forced to go on.

And yet he was compelled to continue. As the Papal carriage was galloped through Lyon at midnight, the Pontiff gazed up at his physician and murmured of Napoleon, ''May God forgive him. I already have.'' It was miraculous that the Pope reached Fontainebleau alive.

He had been to Fontainebleau before - as Napoleon's guest eight years earlier when he first came to France to anoint and crown the Corsican parvenu Emperor of the French. By the time the Pope reached Paris, Napoleon had decided to crown himself, as the Pope sat by and watched, but despite the discourtesy the two men admired and liked each other - for a time. Soon enough they fell out, embroiled in a bitter quarrel over the respective powers of the kingdoms of Christ and Caesar. In 1809, the Pontiff was kidnapped from Rome by a young French general acting under the Emperor's instructions to ''shut (the Pope) up.''

Napoleon held Pius VII prisoner for nearly five years. Not content to be Emperor, Napoleon coveted the powers of the Papacy as well. To that end, he subjected the Pontiff to extraordinary trial and humiliation. Doses of morphine, for example, were administered by the Pope's quack doctor under the guise of sedatives, to induce the Pontiff to bow to the Emperor's demands. The Pope's entourage reported to Paris that at times the Pope was in a ''frenzy.''

Is this the stuff of drama? I had vaguely known of the conflict between Napoleon and Pius VII since my childhood in parochial schools near Boston, but only much later in life did I decide to write a play about it. Alec Guinness, who became my friend when I was a foreign correspondent in Europe, renewed my interest in the subject. I visited Fontainebleau, and all the other places associated with Pius VII's captivity and ordeal in the Alps. I read the works of E .E.Y. Hales, the British historian, in English, and numerous works in French and Italian. Napoleon's own letters were the richest source of all.

Here were the two most powerful men of their age, the one the would-be master of the world, the other the Vicar of Heaven, locked in ferocious combat. As Hales has written, ''They were also human beings with human qualities, good and bad, strong and weak, which shaped their story. One was a political and military genius - ambitious, perceptive, impatient, ruthless; the other was a monk - sensitive, scrupulous, with a sense of humor, physically frail, detached. The bad was not all on one side, nor all the good on the other.''

Moreover, in the course of their combat, the Pope excommunicated Napoleon - made him an outcast to all the faithful, obscene to the gaze of man and God. Imagine, the curse of Heaven! What a story! What drama!

Or so I fancied. Research was one thing; writing a good play quite another. As I struggled with my first draft in Paris during 1973 and 1974, I was nearly crushed by the burden of history. Napoleon's career was so vast, the panoply of the Roman Church so enticing, I threw selectivity out of the window in my ardor to tell it all. As a result, my first draft was a paragon of confusion, more a novel in dialogue form than a real play.

Nevertheless, I persevered. I had reached the point in mid-career when I yearned to break out of journalism. For years I had been dashing to the far corners of the world, writing of wars and other upheavals, and I longed to resume my literary career. I returned to the United States in 1974 as a Fellow at the Center for International Affairs at Harvard, where I wrote a book on Henry Kissinger's diplomacy. From time to time I resurrected the typescript of my play and tinkered with it.

Eventually, I recognized I had to get away from history, not deeper into it. History could only serve, not as a blueprint, but as a loose model. Characters had to be combined into composites; all of them, whether historically they had known each other or not, had to interact intimately and dramatically. The Empress Josephine, for example, though in fact she had met the Pope only in 1804, had for dramatic purposes to sustain and deepen her friendship with him throughout the play.

I had written two novels, but now I found that novel-writing was even worse than journalism as training for effective dramaturgy. ''Literary'' dialogue was fatal; only ''dramatic'' dialogue would work; every line had to create character and advance the plot. Narration and exposition were worthless; ''moments'' mattered more than scenes.

As my agony continued, I discovered that the key to the play was my treatment of Napoleon's character. My task was not so much to cast aside the historical Napoleon - that would be a travesty - as to focus all on one fragment of his huge and stunning life. The fragment was his personal relationship with the Pope. History served as my inspiration, but as I delved deeper and deeper into the skins of Napoleon and Pius VII, I resorted more and more to fancy and invention.

I did this largely out of disappointment with the depictions of Napoleon I had seen in films since childhood. Many of them tried to encompass too much of his vast career. Even in France, where I lived for nearly nine years, I never saw a satisfying film about Napoleon. Abel Gance's ''Napoleon,'' which has recently become all the rage in the United States, I found cinematically exciting but otherwise a preposterous glorification. Perhaps most successful of all, I thought, was Charles Boyer's depiction of 1937 alongside Greta Garbo in ''Conquest,'' and that precisely because it focused on a fragment - Napoleon's romance with the Countess Maria Walewska.

How, finally, was I to portray Napoleon? Was he in fact the savior of Europe, an emancipator disguised as a despot, yearning to remove his mask? Or was he a squalid little gangster, the precursor of Hitler, posturing under a patina of culture, committing blasphemy against the Roman Pontiff? Sigmund Freud once wrote of ''that magnificent rascal Napoleon, who remained fixated on his puberty fantasies, was blessed with incredible good luck, inhibited by no ties except his family, and made his way through life like a sleepwalker until he was finally shipwrecked by his folie de grandeur ... an absolutely classic anti-Gentleman, but cut on the grand scale.''

I rejected the Freudian notion of Napoleon in favor of the imagination of the Romantic 19th-century poets who saw him as the new Prometheus, at war with the Heavenly powers and daring them to strike him down. Prometheus stole the fire of Heaven; Napoleon snatched the crown from the Pope's hands, then snatched Rome itself. The Pontiff cursed him for it. That is the story of my play ''Kingdoms'' - Promethean arrogance and the curse of Heaven.

Is my theme too ambitious? I can only reply that writing ''Kingdoms'' was a mad scheme to start with, that I persisted over several years in the face of universal discouragement and derision, and that now - after playing in Wilmington and at the Kennedy Center in Washington -''Kingdoms'' is coming to Broadway. I left Harvard in 1978, possessed by an idee fixe to make this happen.

Rejection followed rejection; revision of my text I compounded by revision and more revision. Finally, in 1980, Elliot Martin decided to produce my play. Elliot insisted on more revisions, until earlier this year Roy Dotrice, Armand Assante and Maria Tucci enthusiastically accepted the main roles of Pius VII, Napoleon, and Josephine respectively.

But even as I write, the battle is not over yet. Since late October, Paul Giovanni - our director - and I have been struggling to improve the text, to intensify the moments, to move the audience to greater involvement. Will we succeed in New York? Will a public so conditioned by musicals and comedies accept a drama about the master of Europe, the Vicar of Christ, and the curse of Heaven? I am serene and fatalistic. Can a play that began as a fantasy in Paris, with no hope of production, that has undergone more transformations than I can count, ignite the public fancy?

I do believe that our New York audience will find in ''Kingdoms'' a vivid relevance to our present time. The issues of earthly versus spiritual power, the role of conscience versus brute force, are no less real today than they were in 1812. During Pius VII's captivity, blood flowed in torrents throughout Christendom, just as it has flowed in our own epoch and may again. The present Pope was shot; Pius VII was kidnapped. Violence haunts our dreams, and can we halt it without the help of Heaven?

Illustrations: Photo of Armand Assante and Roy Dotrice