Nibbles Error on Fast Computers

If you get a "Division by zero" error when running Nibbles, right after you've entered in all of the setup info, but before you actually get to play the game, you're likely experiencing the problem described below. A way to fix it is described after that.

Nibbles was written with a nice little routine that would determine the speed of your computer, and then while running the program, run a loop calibrated to that speed, so that the program would operate the same way on all computers, no matter what their speed. It did this by recording the time, running a loop where it counted to 1000, the recording the stop time. However long it took to count to 1000 determine the speed of your computer. However, it was written way back in 1990, and computers are significantly faster, now. To the point that computers can now do that count to 1000 so quickly that there's no detectable difference between the start time and the stop time, so you end up with an elapsed time of zero, which just really screws things up.

I've come up with a hack that will get the program at least running, even if it doesn't maintain all of the functionality of the original program. I'm sure if you spent a little more time looking at the code than I did, you'd be able to come up with a better fix. Note that in my changes below, I'm keeping all of the original code as an archive, just commenting it out with the apostrophe.

When the error first occurs, you should be on the line that reads:

speed = speed * .5 / (stopTime# - startTime#)

If you're trying to make this change before you actually get the error, go to the subroutine GetInputs (View > Subs > GetInputs), and find that line at the end of the subroutine. Change it to:

speed = 10000 'speed * .5 / (stopTime# - startTime#)

Next, go to the subroutine PlayNibbles (View > Subs > PlayNibbles). Under the comment, 'Delay game, change the line

For a# = 1 to curSpeed: NEXT a#

to

For a# = 1 to some number 'curSpeed: NEXT a#

where some number is sufficiently large to slow down the program to make it playable. I used 1,000,000 to make it work on my computer. You might want to tweak that on your own.

So, that's the fix. You may notice that all of the numbers are now statically defined, so the game speed will always be the same on your computer, no matter what you specify when the program first runs and asks you for the setup information. I'm sure there's a better fix, I just don't have the time/desire to do it.