FizzleFade

Here's one for you MGA :)

Found this discussion about a technique used in Wolfenstein:

https://news.ycombinator.com/item?id=15122540

Here's the code translated to SmallBASIC


func main()
rndval = 1
while 1
y = rndval band 0xff ' Y = low 8 bits
x = rndval rshift 8 ' X = High 9 bits
lsb = rndval band 1 ' Get the output bit.
rndval = rndval rshift 1 ' Shift register
if (lsb) then ' If the output is 0, the xor can be skipped.
rndval = rndval xor 0x00012000
endif
pset x,y color 4
if rndval == 1 then
exit loop
endif
wend
end

main
pause

Cool! Try this

func
main(rndval)
'rndval = 5
color rgb(255*rndval/1002, 0, 0)
while 1
y = rndval band 0xff ' Y = low 8 bits
x = rndval rshift 8 ' X = High 9 bits
x= rndval rshift 8
lsb = rndval band 1 ' Get the output bit.
rndval = rndval rshift 1 ' Shift register
if (lsb) then ' If the output is 0, the xor can be skipped.
rndval = rndval xor 0x00012000
endif
pset x,y
if rndval == 1 then
exit loop
endif
wend
end

for
i = 1001 to 0 step -10
main(i)
next