BBC Micro based landscape rendering
The original version of this program was published in Acorn User edition 86 from September 1989. I fondly remember typing it in laboriously and generating various sample landscapes with it at the time. The program was written by David Lawrence and is copyright Acorn User magazine.
The original program is saved here as BeebVersion.bbc. With a bit of compression, we can even enter it into an online emulator via the url. Try it out here: Landscape. It's a long URL, so might only work in some browsers.
In the accompanying article, it is explained that due to the limits of the BBC's memory, the maximum grid size is just 10x10. Another listing was given for the Acorn Archimedes that could have much higher resolution and colour. I wanted to see if it was possible to bring the higher resolution to the BBC version.
Without a deadline for a magazine release and the benefit of modern tools, it is possible to explore many different enhancements. I made various minor improvements to the algorithms but the biggest was to switch away from generating the whole landscape data in memory before rendering the landscape. Instead, the random fault data is saved into memory and a the landscape height calculated one row at a time, avoiding the quadratic scaling memory usage of the original approach.
Having made a BBC Basic program that could now scale much higher, it was time to deal with the speed. The original program took about 50 seconds to draw a 10x10 landscape. Moving up to 40x40 with the new approach left it taking around 5 minutes. Not very satisfying! So I decided to learn 6502 assembly code, initially thinking to just convert the slowest parts of the code but in the end converting the marjority of it, after generating the random fault data in Basic. Now we can generate large 40x40 landscapes in around 30-35 seconds, faster than the original but with 16 times more patches!
Try out the new enhanced version via https://bbc.godbolt.org/.