The listing and running of the following program on an emulated '64 (this should be copy/pasteable straight into an emulator like VICE, although watch out for the < and > entities which need altering by hand to the less than and greater than signs):
10 deffnr(m)=rnd(.)*m
20 goto100
30 poke53265,(111andfnr(128))or16:return
40 poke53270,fnr(32):return
50 poke53272,fnr(256):return
60 poke53280+fnr(5),fnr(16):return
100 on1+fnr(4)gosub30,40,50,60
110 geta$:ifa$<>""thenpoke2,.:sys2
120 goto100
Line comments:
10: Defines a shorthand for the random number generator returning a value between 0 and m-1. The dot is faster than but equivalent to zero (an old BASIC programmer trick).
20: Skip over the following subroutines to line 100
30: Memory location 53265 is the first VIC control register. The values 111, 128 and 16 are bit masks which ensure that bit 4 is never set to zero which would blank the screen and make this much less impressive. Bit seven is unimportant, hence 128
40: 53270 is the second control register. Only values 0 to 31 are used here as bits 6 and 7 serve no purpose and bit 5 is documented as ALWAYS SET THIS BIT TO 0! (Which is slightly worrying.)
50: 53272 is the third and memory control register and can receive the full input of random values to make it look all over ROM and RAM for bit patterns to display.
60: Fills a random colour register (which include the border and background colour registers) with a random colour, adding a bit of variety to the multicolour modes when the other pokes activate them.
100 to 120: The main program loop. Press any key to stop the program.
110: Uses the same dot-as-zero trick to create a machine code BRK in a free memory location (2) and then SYStem calls it, effectively forcing RUN/STOP+RESTORE behaviour.
N.B. If the program is stopped with RUN/STOP, the screen will be left in garbled state. Either run it again and stop it with any other key, or use RUN/STOP+RESTORE to get back to normal.