program tutorial_23_sqrt_effect;
var  
@define charsetPos "$6000"
@define charVal "64"
	charset: IncBin("charsets/tutorial19_charset.bin", @charsetPos);

	x,y,i,j,dx,dy : byte;
	wrk : integer;
	dp:pointer;
	tmp: array[4] of byte = (1,2,3,4,5,0);

//@startblock $8200 "Code far far away!"

procedure Render();
begin
	moveto(0,0,$44);
	for y:=0 to 25 do begin
		for x:=0 to 40 do begin
			dx:=abs(20-x);
			dy:=abs(13-y);
			i:=(atan2(20,x,12,y));
			i:=(i/2)&15;
//			i:=6;
			screenmemory[x]:=i+@charVal;
		end;
		inczp(screenmemory,40);
	end;
end;


procedure ShiftCharsetData();
begin
	memcpy(^$6000+^@charVal*^8, 0, ^$6000+^@charVal*^8+^128,8);
	memcpy(^$6000+^@charVal*^8+^8, 0, ^$6000+^@charVal*^8,^128);

end;

//@endblock

begin
	setcharsetlocation(@charsetPos);
	clearscreen($20,^$4400);
//	setmemoryconfig(1,0,0);
	
	clearscreen(YELLOW,^$D800);
	setbank(VIC_BANK1);
	SCREEN_BG_COL:=BLACK;
	SCREEN_FG_COL:=BLACK;
	Render();

	while (1<2) do begin
		ShiftCharsetData();
		waitnoraster(255);
		wait(255);
	end;
end.
