For March's program of the month, I drew inspiration from one of my older demo’s, The Ball. Like many young kids from the early eighties using BASIC, I took a stab at animating a bouncing ball. It is a a relatively easy program to write depending on how complex you want to make the math. In my case, it is very simple math, no physics involved here. I wanted something a little more interesting, however, and decided to add curtains. As the ball moves behind them them it changes colors. The Ball is still a very slow demo though, so in 2012 I sped it up by compiling it with MCODER II. This month’s program is based on both versions, merged together to show you the difference between them. The Ball Redux combines a little old with a little new, but at its core is still my original program.
The Ball has always had a special place in my heart. It is one of my first attempts at creating moving graphics. If you look at the code, don’t laugh. This is all brute force BASIC. No special algorithms here. The code simply checks to see which way the ball is traveling and runs through a series of IF statements to figure out if the ball needs to change color. Nothing pretty, it just works. The original BASIC version is a bit slow, but not overly so. Overall, just what you’d expect from a program born in the 80s.
Because it is so simple, I was easily able to compile it using MCODER. The result is a much faster and smoother animation. You will notice, however, that the ball will slow down towards the top of the screen. This will occur on a real ZX81 as well, something I tested when I was a teenager, and I’m not sure if this is an MCODER issue or something else. If I get around to it, I can bypass the print routine using POKE to test my theory. Since this is only a demo, I’m not going to worry about it for now.
For this 2014 version, I tweaked the BASIC a bit to show you want it originally looked like. After a few bounces, it jumps to the MCODER version. This version is much faster. So much faster, I added a loop to slow it down. To make it interesting, I added an easy way to dial the speed up or down using the 6 or 7 keys and their matching cursors. 6 lowers the delay thus speeding up the ball. 7 increases the delay causing the ball to move slower. To help, I print the delay value at the bottom of the screen for a bit. The increments are in ten and go from 0 to 1000. You can also hit “Q” to quit back to the BASIC version. Hitting “Q” again will return you to the MCODER version.
I hope you enjoyed my Ball demo. To be honest, it wasn’t the program I originally was going to use. Unfortunately, I chose a program I never completed and didn’t realize it until after I typed it in. Maybe I’ll finish it for a future program of the month. How’s that for foreshadowing.
If you want to run this program on your Android phone or tablet you can download a compressed copy of the program to your device. You'll need to save the .p version of the program to your device to allow Zed Ex (Beta) to run it.