program Pixels;
@use "screen"
var
	
   i,x,y,shift,x1,y1,cnt: byte = 0; 
   ix : integer;
   time,t1,t2 : byte = 0;
   // A suitable sine function (sin(t)/3)
   sine3 : array[256] of byte = BuildSineTable(127);
   p : ^byte;   

// Simple pixel example, no double buffering


procedure LoopPixels();
begin

	x:=sine3[t1];
	y:=sine3[t2];
	x1:=sine3[time]+x;
	y1:=sine3[time+64+shift]>>1+y;
	// Put that pixel!	
	Screen::PutPixel(x1,y1);

	// Some funky phase shifts
	time+=1;
	t1+=1;
	t2:=t2+2;
	if (time&211=0) then t1+=1;
	if (time&63=0) then t2+=1;
	if (time&31=0) then shift+=1;
	// Clear at certain intervals
	if (time=0) then 
	begin
		Screen::ClearScreen(0,cnt&15);
		cnt+=1;
		
	end;
end;



begin
	Screen_BorderColor(0);
	Screen::ClearScreen(0,0);
	while (true) do
		LoopPixels();

end.
