

procedure CopyCredsOrg(k : global byte);
begin
	for j:=0 to 57 do
		begin
			Crtc::PointToY(k);
			n := Crtc::sp[0];
			zp:=Crtc::sp +1;
			memcpy(zp,Crtc::sp,79);
			Crtc::sp[79]:=n;
			k:=k+2;
		end
	

end;


procedure CopyCreds(k : global byte);
begin
	p1:=$1000+80;
	zp:=$2600+80;
//	y:=sine32[c1]>>1;
	//zp := zp + Crtc::ytab[y];
	//while (ll>80) do ll:=ll-80;
	if (yy=0) then
	begin
	p1:=p1-c2y;
	zp:=zp-c2x;
	end
	else 
	begin
	p1:=p1-c2y;
	zp:=zp+c2x;
	
	end;

	for j:=0 to 62 do
		begin
			Crtc::PointToY(k);
			Crtc::sp:=Crtc::sp+5;
			//memcpy(zp,Crtc::sp,79);
			asm("
				ld hl,[p1]
				exx
				ld hl,[zp]
				ld de,[Crtc_sp]
				ld bc,70
cccl:
				ld a,[hl]
				
				exx
				or [hl]
				inc hl
				exx
				
				ld [de],a
				inc de
				inc hl
				
				dec c
				jr nz,cccl
			");
			zp:=zp+80;
			p1:=p1+80;
			
			k:=k+2;
		end
	

end;

var
/*	treePal : array[16] of byte = (
//	0,0,0,0, 15,3,0,0,   0,0,0,0,    0,0,0,0);
	0,0,0,0, 5,1,0,0,   0,0,0,0,    0,0,0,0);
*/
procedure EffectCreds(yy, x,y,c1 : global byte; textp : global pointer);
begin
	
	fill(#coltab1,15,15);

	k:=0;

//	Crtc::SetPalette(#treePal);

	for j:=0 to 15 do 
		Crtc::SetSinglePaletteHW(j,0); // Text

	Crtc::SetSinglePaletteHW(4,x); // Text
	Crtc::SetSinglePaletteHW(5,y); // Text
		

	Crtc::SetSinglePaletteHW(15,c1); // Text

	Compression::Decompress(#forest_bg, $1000);
	Compression::Decompress(#forest_fg, $2600);



	
//	Compression::Decompress(pp2, screen);
	c2x:=0;
	c2y:=23;
	n:=0;
	while (done=false) do
	begin
			CopyCreds(23);
			c2x:=c2x+1;
			if (c2x&1=0) then c2y:=c2y+1;
			if (c2x>=80) then  c2x:=0;
			if (c2y>=80) then  c2y:=0;
		UpdatePrintText();
		UpdatePrintText();
	end;
end;
