EXCLUSIVE

Roman Polanski will come back to a California courtroom to face the judge over his fugitive status in his child rape case, but only if the judge says in advance that the director served his full time behind bars.

Polanski's lawyer, Harland Braun, has filed legal docs trying to cut through what has become a decades long legal mess. Braun says it's boiled down to a simple fact ... the sentencing judge required Polanski to serve less than 50 days, and between jail in the U.S. and house arrest in Switzerland, he's served nearly 400 days.

The sentencing judge, Braun says, reneged on a deal that was struck and threatened up to 50 years in prison, and that's why Polanski bailed in the case involving a 13-year-old.

Polanski, who was married to Manson Family murder victim Sharon Tate, has been on the run since 1978.