-------------------------------------------
Matrix Digital Rain for the ZX Spectrum 48k
-------------------------------------------

By Marco Varesio (Marco's Retrobits) 2020 
https://retrobits.itch.io/
https://retrobits.altervista.org/
https://somebitsofme.altervista.org/

Coded for the Matrix Challenge, organized by Retro Programmers Inside
https://www.facebook.com/groups/RetroProgrammersInside/

This is my implementation of the well known Digital Rain (also referred to as
Raining Code) effect, featured in The Matrix science fiction movies.
Watch the video: https://youtu.be/pmC55K0co_Y

Load the "coderain.tap" file in your ZX Spectrum or your favorite emulator.
A good emulator available for many platforms is FUSE:
http://fuse-emulator.sourceforge.net/#Download
You can even try Matrix Digital Rain in your web browser
(powered by JSSpeccy emulator):
https://somebitsofme.altervista.org/rm-rf/site/?p=emu/jsspeccy&soft=MatrixDigitalRain

While the code rain animation is running, you can change the effects
by pressing the following numeric keys:
7: set mode to "inverted drops"
8: set mode to "standard" (default)
9: set mode to "woman in red"

You can change the colour by pressing the following numeric keys:
1: blue
2: red
3: magenta 
4: green
5: cyan
6: yellow

Implementation details
----------------------

The adopted technique is to initially fill the screen with random characters
(or with a bitmap image for the "woman in red"), making them not visible 
(black ink on black paper).
Then, within an endless loop, the rain effect has been implemented by altering
the screen attributes memory area, to make the "drop" and its trail visible.
The “drops” start falling at random position and each “drop” falls at a 
random speed and leaves a trail with random length.
In the "standard" and "inverted drops" mode, the trail is brighter immediately
after the “drop” and becomes darker as the “drop” slides down; moreover,
random characters at random positions are periodically printed to the screen.

The Matrix Digital Rain for the ZX Spectrum has been coded in C language and
built with z88dk using the ZSDCC compiler.

Source files:
coderain.c: the actual program
udg.c:      the custom characters
woman.c:    the "woman in red" bitmap

Compile with:
zcc +zx -vn -startup=1 -clib=sdcc_iy -lm woman.c udg.c coderain.c -o coderain -create-app
