program Tutorial1;
@use "screen"
@use "memory"
@use "system/str"
@use "text"
@use "system"
var
	x,y : integer;
	time, t, l : byte;
	delta: byte = 64;	
	col : byte = 1;
	sinx : array[256] of integer = buildsinetable(127);


	
begin
	
	
	System::Init();
	Screen::SetBitmapMode(Screen::BPL_40, 1);
	Screen::SetColor(0,0); // black
	Screen::SetColor(1,25); // some color
	Screen::SetColor(2,40); 
	Screen::SetColor(3,60); 

	Screen_EnableVsync();
	// Clear scren
	Memory::Fill16(#Screen::gfx,00,160*225);
	while (true) do
	begin
		// Set the border color to time
		Screen::Border:=time;
		// Draw a circle
		for t:=0 to 255  do
		begin
			x:=sinx[t]+20;
			l:=t+delta;
			y:=sinx[byte(t+delta)];
			// Put pixel on screen
			Screen::PutPixel320(x,y,Screen::colors[col]);
		end;
		time+=1;	
		// Increase delta
		delta+=1;
		if (time&15=0) then col:=(col+1)&3;
		// cycle between color 1-3
		if (col=0) then col+=1;
		
	end;		
end.
