Post by Carl on Mar 13, 2013 18:50:12 GMT
Here is a little routine that is a nod to the Da Vinci virus of yesteryear, the great thing about this FIGnition forth programme is that you can call it anytime you want to, without needing to set an environment to do it, and its less than 1000 bytes.
and here is the listing....
to run, type 'virus' at any time when not editing.
and here is the listing....
insert ( virus- by Carl ,PS don't bother typing in the annotations!! )
0 var seed
: rnd seed @ 1 + 75 * dup seed ! u* swap drop ; ( make random numbers)
: pause clock i@ + begin dup clock i@ - 0<L until drop ; ( define a pause, n pause is the delay )
575 rnd var location
0 var xx
: chk vram location @ + ic@ xx ! ; ( finds out what char is at the location and calls it xx)
: gap? xx @ 32 = if xx @ 100 rnd + xx ! then ;
( as spaces are boring we ask if its 32 if it is we add a number between 0 and 100 to it and call it xx )
: fall 32 vram location @ + ic! xx @ vram location @ 25 + + ic! ;
( fall puts a space '32' in is present location then prints the char value 25 spaces ahead of it in effect right below it)
: end? 32 = if quit then ;
( end? is our escape)
: store location @ 25 + location ! location 574 > if 573 rnd location ! chk then ;
( store adds 25 to location and stops the chars falling off of the screen by making a new location value if they exceed vram 573)
: virus begin inkey end? chk gap? fall store 0 pause location 0 < until ;
( brings all together, note that location can not be less than zero there fore if and endless loop, so we look for space to quit) code here
to run, type 'virus' at any time when not editing.