
@ifdef BUILDCRT
// only used in cart - to copy characters into VIC RAM
procedure CopyCharSet();
begin

	p1 := @CHAR_ADDR;
	p2 := @CHAR_ADDR_CART;
	for t := 0 to 2 do
	begin
		for i := 0 to 256 do
		begin
	
			p1[ i ] := p2[ i ];

		end;
	
		p1 := p1 + 256;
		p2 := p2 + 256;
	
	end;

end;
@endif

procedure ClearTheScreen();
begin
	ClearScreen(0, ^@SCREEN_ADDR);
	ClearScreen(WHITE, ^@COLOR_ADDR);
end;

// Set up initial screen configuration on unepanded Vic20
// Character map to use, bespoke screen width and height
procedure ScreenSetup();
begin

	DefineScreen();
	ClearTheScreen();
	//poke( SCREEN_CHAR_REGISTER, 0, 255 ); // set char map to $1c00, leave screen at $1e00
	//SetCharsetLocation( @CHAR_ADDR );
	VIC_DATA_LOC := $ff; // screen and char location
	
	SCREEN_TEXT_WIDTH := @SCREEN_WIDTH | 128;  // width
	SCREEN_TEXT_HEIGHT := 48; // 24 (25 rows-1) x 2
	HSCROLL_REGISTER := peek(HSCROLL_REGISTER, 0) + 2;
	VSCROLL_REGISTER := peek(VSCROLL_REGISTER, 0) - 2;
	AUX_COLOR_AND_VOLUME := 12; // volume
	SCREEN_BG_COLOR := 8;
	
	CreateAddressTable( #scrm, $1e00, @SCREEN_WIDTH, @SCREEN_HEIGHT ); // bug- constants not accepted @SCREEN_ADDR and @COLOUR_ADDR
	CreateAddressTable( #clrm, $9600, @SCREEN_WIDTH, @SCREEN_HEIGHT );
	
	@ifdef BUILDCRT
	
	CopyCharSet();
	
	@endif

end;

// set position of head and tail pointers
procedure SetupPlayer();
begin
	head := $1f9a; //AddressTable( scrm, 11, 21 );
	tail := $1f95; //AddressTable( scrm, 6, 21 );
	headc := $979a; //AddressTable( clrm, 11, 21 );
	tailc := $9795; //AddressTable( clrm, 6, 21 );
end;

// wait for numberOfRastersToWait raster loops
// uses s variable
procedure WaitForNRasters();
begin
	fori s := 1 to numberOfRastersToWait do
		waitforraster(@WAITVBL_LINE); 
end;
