WALLA WALLA, Wash. (AP) _ James Fogle's vivid memories of his life on the outside help him to forget the much longer time he has spent inside prison walls.

His current address is the Washington State Penitentiary, but he has been in juvenile halls, county jails or state and federal lockups for nearly 35 of his 53 years. Most of the crimes were committed to feed a drug addiction.

Now, characters from his life as a junkie and convict have come to life in a movie based on Fogle's jailhouse novel, ''Drugstore Cowboy,'' starring Matt Dillon.

Fogle sits on his bunk in Unit 8 of this state's oldest and largest maximum security prison, his denim blues neatly pressed, and politely answers a reporter's questions about his fledgling writing career.

''I've been locked up so much that I remember everything I did outside. It's like looking at things through a magnifying glass,'' he said of his writing. ''I might even have a better perception of what was happening when I was out there than most people who are out there.''

''Drugstore Cowboy'' is one of four unpublished novels Fogle has written in prison.

Dillon's character, Bob Hughes, is a composite of himself, cellmate Leonard Hystad and others he has known both inside and outside prisons, Fogle said.

The movie, about a junkie and three friends who commit a series of drugstore holdups in the Northwest, is based on a period of his life when he lived in Portland, Ore.

''I got out of here in 1974 and I was running with a group of people and we were doing the same kind of things. It was just the type of people and things they were doing,'' he said.

But the movie is more fictional, he said. ''None of that is really true. It was all things we started to do and didn't do.'' In the movie, a female junkie dies of an overdose.

''That never happened to me,'' Fogle said. ''My girlfriend that was with me at that time did end up getting murdered, but that was later when I was back in here.''

Fogle gave Dillon a pack of cigarettes when the actor visited him in July 1988 and later sent the actor a ring he made in a prison shop. During the 2 1/ 2 -hour visit, Dillon asked questions about Fogle's life as a junkie.

''He wanted to know a little bit about mannerisms of addicts. I told him, 'man, they all got different ones anyway, so whatever you do is going to be right.' We hit it off pretty well,'' he said.

The film, which received favorable reviews in openings in Los Angeles and New York, is playing in a dozen major cities and is scheduled for wider distribution this month.

Fogle has seen the movie twice, once in color and once on the small black and white television set in his cell.

''The first time I seen it, I was with people (in a Narcotics Anonymous session) and I didn't know what to expect,'' he said. ''It was a kind of emotional release. I started perspiring. Sweat just started running off me.''

But it wasn't until he saw it a second time in black and white that he came to appreciate the film. ''Things just sort of blended better, all those things he tried to do,'' Fogle said of Dillon's performance. ''Its got some parts where it's supposed to be like a dope fiend tripping on dope. In black and white it really came out good, more realistic. I think it was better in black and white for me.''

His own gray existence as a junkie began at age 25, after serving 8 1/2 years on an auto theft conviction. At first he sold drugs to make a living. Later, he began using them. The search for drugs led to a string of pharmacy robberies, first in California, then in Oregon and Washington state.

Reeling off his pharmaceuticals of choice like a waiter repeating a restaurant menu, Fogle recounts the nearly 20 years he spent rustling drugstores.

At first, there were sympathetic doctors who would prescribe medications. Later, there were forged prescriptions, burglaries and disabling drugstore alarm systems. His favorite method was the ''crash and dash'' - driving an automobile through a drugstore's front window, snatching up handfuls of drugs and out before police could respond.

He and a partner were not fast enough in Elcho, Wis., his birthplace, while robbing a ppharmacy in 1979. His partner was shot and killed by police and Fogle was shipped back to Washington to begin serving a concurrent 22-year prison term for the robbery of a Cowlitz County drugstore.

Fogle, who has kicked a smoking habit and regularly attends Narcotics Anonymous sessions, began writing seriously in 1971 after he bought a typewriter with $50 his father sent him. After classes in physics and math in the mornings, he spends most afternoons on his bunk, writing stories in longhand, which he later types.

After writing and then throwing out an autobiography in 1980 - ''it was so pointless'' - Fogle began working on ''Drugstore Cowboy.''

The unpublished manuscript found its way to screenwriter and producer Dan Yost, a free-lance writer in Portland, Ore., who has since moved to Los Angeles. Yost serves as Fogle's agent and co-writer.

Fogle's works ''truly amazed me. I had a hard time putting them down,'' Yost said. ''They are not 600 to 700 pages of great prose . .. but they're not shallow either.

''He's never immoral or amoral. There is a strong base of ethics. His characters care about each other. They're not overly violent.''

Fogle, who is not sure when he'll be free, talks of becoming a mechanic at an Alaska cannery. Most of the $12,000 he received for the rights to his screenplay will go toward buying mechanics tools, he said.

''I'm 53. I'm not letting it go to my head,'' he said of the increasing demands for interviews after the movie's release. ''Everybody's got a story to tell.''

AP-NY-11-12-89 2359EST