program Sable_raster_wedge;
var  
	y,time,idx,tt: byte = 0;
	
	colorsRedhues : array [] of byte = (  6,11,15,1,7,8,2,2,  2, 2,2,8,7,1,15,11,6  );


@define useKernal 0

interrupt RasterBar();

interrupt RasterTop();
begin
	StartIRQ(@useKernal);	
	screen_fg_col:=blue;
	screen_bg_col:=blue;
	inc(time);
	idx:=0;
	tt+=2;
	y:=sine[tt]/4 + 80;

	RasterIRQWedge(RasterBar(), y,@useKernal);
	CloseIRQ();
end;


interrupt RasterBar();
begin
	idx+=1;
	StartIRQWedge(5);	
	screen_bg_col:=colorsRedhues[idx];
	screen_fg_col:=screen_bg_col;
	y:=y+6;
	
	RasterIRQWedge(RasterBar(), y,@useKernal);

	if (idx=16) then // Go to top again
		RasterIRQ(RasterTop(),0,@useKernal);

    closeirqwedge();
end;


begin
	preventirq();
	disableciainterrupts();
	SetMemoryConfig(1,@useKernal,0);
	StartRasterChain(RasterTop(),0,@useKernal);
	Loop();
end.
