General comments, nothing specific.
I very commonly port C code to Pascal and I've learned the hard way that it pays to make the first attempt as parallel to the C code as possible. IOW, no renaming variables, no improving anything, just make it as one-to-one as possible. Make it work and, thoroughly test it that way.
Once it has been thoroughly tested and it really works as intended then and only then "Pascalize" the code. I've learned it saves a lot of aggravation (and time) to do it in two steps than attempting to do it in one.
Of course, for really simple programs (such as Petzold's C examples), the first step need not be strictly adhered to but, for anything that goes beyond the trivial, it pays to be "religious" about it.
HTH.