program Tutorial3_Putpixel;
var
@use "screen"

	i,time,j,k,m,x,y : byte=0;
	zp:pointer;
	
    sinx : array[256] of byte = BuildTable("Math.sin(i/256.0*Math.PI*2.0)*80+79");
    siny : array[256] of byte = BuildTable("Math.sin(i/256.0*Math.PI*2.0*2)*80+100");



begin
	Screen::ResetStack();
	Screen::Init();
	RasterIRQ(Screen::DefaultIRQ());
	Screen::SetMode2();
	Screen::StartInterrupts();
	Screen::SetPalette(#Screen::defaultPalette);	
	// Clear the screen
	Screen::FillBanks($4000,00,$40);	
	m:=64;
//	Screen::DisableInterrupt();	
	While(true) do
	begin
		inc(time);
		j:=time;
		for i:=0 to 128 do
		begin
			x := sinx[j];
			y := siny[j+m];
			j:=j+1;
			Screen::PutPixelMode2(x,y,i&15);
		end;	
//		Screen::WaitForVerticalSync();
		
		j:=time;
		// Clear the pixels 
		for i:=0 to 128 do
		begin
			x := sinx[j];
			y := siny[j+m];
			j:=j+1;
			Screen::PutPixelMode2(x,y,0);
		end;	
		if (time&3=1) then 
			m:=m+1;

	end;

end.
