broke the file into functions to be easier to understand. There's (deliberate?) dead code in the original BASIC code, which I preserved - I don't see any way to get to the "happy" ending.