program Randomness;

@projectsettings "petmodel" "8032"

var  
	random_color,x,y,index: byte; 
	// Array of random bytes
	random_values : array[256] of byte; 
	// Pointer to screen and color ram
	screenP, zp : pointer;



// Initialize a random table of 256 bytes
// generator
procedure InitializeRandom();
begin
	// same as : for x:=0 to 0 do begin..
	for x:=0 to 256 do begin 
		random_values[x]:=Random();
    end;
end;

begin
	InitializeRandom();
	
	// point to start of random table
	index:=0; 
	// infinite loop
	while (true) do  begin
		// Set pointer to point to beginning of screen/color ram ($0400 and $D800)
		screenP:=#screen_char_loc;
		// loop y		
		for y:=0 to screen_height do begin
			// moves current screen position
			// Select some random color
			zp:=#random_values+index;
			memcpy(zp,0,screenP,80);
			index:=index+11;
			screenP:=screenP+screen_width;
		end
	end;

end.


