program Lbm8_09;
var
@DEFINE BGBUFFERS 32

// unexpanded Vic 20
@vicmemoryconfig "none" 

@use "output/lbm8"
@use screen

	
	// export the default characterset
	@export "chr/char.flf" "chr/char.bin" 64
	charset: incbin("chr/char.bin", $1c00); // unexpanded location for char setcharset 


	@vbmcompilechunk "chr/sprites.flf" "sprites2.inc" "MySprite" "lbm8_d" "" 0 16 1 0

	@include "sprites2.inc" // this file has been generated by the vbmcompilechunk above

	
	sinx : array[256] of byte = buildsinetable(127);
	
	
	// x and y position
	xp, yp, zp, time: byte;
	
	i,t: byte;
	dt : byte =64;
	const noSprites: byte = 8;
	
begin

	DefineScreen();

	ClearScreen( 32, #SCREEN_CHAR_LOC); 	// ^$9600 - unexpanded colour location

	ClearScreen( GREEN, #SCREEN_COL_LOC); 	// ^$9600 - unexpanded colour location

	AUX_COLOR_AND_VOLUME := %00000010;
	SCREEN_BG_COLOR := BLACK + SCREEN_BG_BLACK;

	Screen::SetScreenCharAddress( 
		Screen::SCREEN_1c00 + Screen::CHAR_1c00, 
		Screen::SCREEN_ADD_0200 );

	// put some characters on the screen
	screenmemory := $1e00+88;
	// Fill with last char
	clearscreen($3F,$1e00);
	fill(^$1c00+$3F*8,0,8);

	while (true) do
	begin
		WaitForRaster(130);
		
		lbm8::RestoreBG();
		t:=time;
		for i:=0 to noSprites do
		begin
			xp := sinx[t];
			yp := sinx[t+dt]+32;
			lbm8::DrawCAt( 4+i<<2, xp, yp, #MySprite );
			t+=32;
		end;
		
		if (time&3=0) then
			dt+=1;
			
		time+=1;
	end;

end.
