Umm, as I was re-reading your question, I saw that I perhaps overlooked something essential. If you are working in x/y/z coordinates, then you are working in 3d, right? If so, change your starting line:
Graphics 800,600,16,2
to use the 3d Graphics command:
Graphics3d 800,600, etc
Graphics 800,600,16,2
to use the 3d Graphics command:
Graphics3d 800,600, etc