fire

BASIC 10 liner demo for the Sinclair ZX Spectrum

by Marco's Retrobits English language blog Italian language blog YouTube channel BooMfire video

BooMfire animation

BooMfire is my entry to the 13th edition (2024) of the BASIC 10 Liner contest, SCHAU category.

It is an implementation of the DOOM FIRE effect for the Sinclair ZX Spectrum, inspired by Roberto Capuano's MSX entry to the 11th edition of the contest.

My first attempt was coded using Sinclair BASIC, but to achieve smoother animation I relied on the ugBASIC compiler by Marco Spedaletti. BooMfire does not (yet?) exploit isomorphism (the main feature of ugBASIC, which allows you to generate executables for dozens of 8-bit systems from a single source), as the program uses some specific features of the ZX Spectrum and so can only be built for this platform.

Although the program runs on a regular ZX Spectrum, in order to enjoy(!) the music and sound effects, a model with the AY-3-8912 chip (128K, +2, Next, etc...) is required.

When the program starts, the BooM writing, which mimics a simplified version of the DOOM videogame logo, is displayed. In the meanwhile, the AY-3-8912 chip will play an annoying music inspired by the DOOM theme. After the logo has been painted on screen, you'll hear an explosion (powered by the aforementioned AY-3-8912) and then the fire will start to burn. You can change the fire effect by pressing one of the following keys: 1: fire above the BooM logo, 2: fire across the logo (for colour clash enthusiasts), 3: fire behind the logo, 0: extinguish fire.

Note: BooMfire has been coded by the fireplace.

Program description

Drawing algorithm

The BooM logo drawing algorithm is similar to the one used on the Amiga to display the Kickstart floppy image.

Flood fill

The flood fill routine is an implementation in ugBASIC of the recursive flood fill algorithm described in the A Fast Well-Behaved Pattern Flood Fill article by Alvin Albrecht.

ugBASIC offers a nice flood fill routine by means of the PAINT statement; however, a custom subroutine has been implemented in order to play music while painting.

Fire effect

The fire animation is my own implementation of the well-known DOOM Fire effect. Instead of plotting coloured pixels, the flame is drawn by updating the attributes of the character cells.

Expanded code commented

Here is the full code, expanded for better readability and extensively commented:

Compressed program and length proof

The program has been compressed using abbreviations and by joining multiple statements per line. The resulting program is 10 (actually 9, since last line is a comment) lines long. Each line contains less than 256 characters, so BOOMfire is a suitable entry to the SCHAU category.

The following image shows the "compressed" program in Notepad++. The cyan marker on the right indicates the 256th column.

Loading instructions

BooMfire is provided in TAP tape image format, which can be easily loaded in most ZX Spectrum emulators and on the real machines, either equipped with devices such as the DivMMC or by playing it through the MIC port using tools like PlayTZX or WinTZX.

Fuse emulator

The following instructions apply to the Fuse open source emulator, which is available for Unix, Linux, Windows, macOS and many other platforms. For other emulators or devices, please refer to their specific documentation for loading TAP files.

Start the Fuse emulator and select a Spectrum 128K model in "Machine" -> "Select..."

Make sure that automatic loading of tape image files is enabled, by checking the corresponding options in "Options" -> "Media..."

Open the BooMfire.tap file, either by selecting it in "File"->"Open..." or by dragging and dropping it on the emulator window.

The ugBASIC runtime will prompt you for a command:

To start the program, type run and tap Enter:

To view the listing, type list and tap Enter:

If your emulator of choice does not support automatic tape loading, after mounting the tape image you must make sure that "Tape Loader" is highlighted (you can change the selection using the cursor up/down keys) and press Enter.

You might also have to press "PLAY" on the virtual tape emulator.

JSSpeccy

Alternatively, if your web browser supports Javascript, you can play directly in your browser (powered by JSSpeccy - A ZX Spectrum emulator in Javascript). Just surf to: https://retrobits.itch.io/boomfire. Mobile devices are not currently supported.