program TextScroller;
var

// Take a look at the VBM commands in the help (press F1)
// and also in the platform section of the help file
//
// Note that TRSE for VIC 20 is using zero pages from $8F downwards
// and VBM uses zero pages from $00 upwards.
// The Zero page memory in between can be used by your programs.
// See VBM Memory in the Platforms help section for details. 

// Displays a scrolling text message and a tile bitmap

// declare all your include files here

@export "resources/charsets/charset_8x8.flf" "resources/charsets/font8x8.bin" 256

font: incbin( "resources/charsets/font8x8.bin", $4000 ); // character set for first 64 PETSCII Screen Codes
chars: incbin( "resources/tilemap/monschar.bin", $4800 ); // individual tile characters
map: incbin( "resources/tilemap/monsmap.bin", $4db0 ); // full screen map of tiles


// declare all your variables and procedures here
	message: CSTRING = ("HELLO WORLD!  . . . THIS IS AN AWESOME TEXT SCROLLER ",
						"... CONTAIN YOUR EXCITEMENT MADAME!  ",
						"LONG CSTRING MESSAGES CAN BE CONSTRUCTED IN THE CODE ",
						"BY ASSIGNING WITH (PARENTHESES) AND COMMAS.   COOL    ",
						"EVERY SCROLLER NEEDS SOME GREETS: BIG HELLO TO NICOLAAS ",
						"WHOM WITHOUT WE WOULD NEVER HAVE THE WONDERFUL TURBO ",
						"RASCAL   -   R, A AND l - LOVE YOU!   -  AND OF COURSE ",
						"YOU WONDERFUL LOT WHO HAVE COME HERE TO HAVE A GO AT ",
						"MAKING SOMETHING COOL WITH TURBO RASCAL!         ");

	char: byte = 1;

	i, j : byte = 0;
	p1 : pointer;

@donotremove "setUpScreenShiftLeft"
// scrolling must be initialised to match the DisplayMode
procedure setUpScreenShiftLeft();
begin

	vbmInitScreenShiftLeft(1);

end;

begin

	// set the smaller display mode showing 19 columns, the 20th is hidden
	vbmSetDisplayMode( 1 );

	
	// Clear the bitmap with a value of 0
	vbmClear( 0 );
	
	// set the colour memory to WHITE
	vbmClearColor( WHITE );
	
	// set screen colour
	SCREEN_BG_COLOR := SCREEN_BG_BLACK + BLACK;
	
	screenmemory := $94d1;
	screenmemory[ 0 ] := BLUE;
	screenmemory[ 18 ] := BLUE;
	screenmemory[ 1 ] := PURPLE;
	screenmemory[ 17 ] := PURPLE;
	screenmemory[ 2 ] := CYAN;
	screenmemory[ 16 ] := CYAN;

	vbmDrawTileMap( #map, #chars, 0,10, 20,146 );

	p1 := #message;

	while (true) offpage do
	begin
	
// uncomment this line and the similar one below to see how much time it is taking
//	SCREEN_BG_COLOR := SCREEN_BG_BLACK + red;

		vbmScreenShiftLeft( 184, 191 );
		i := i + 1;
		if ( i = 8 ) then
		begin
			
			char := p1[ 0 ];
			p1 := p1 + 1;
			if (char = 0) then
			begin
			
				p1 := #message;
				char := 32;

			end;
			
			i := 0;
			vbmDrawText( #char, #font, 19, 184, 8 );
			
		end;
// uncomment this line and the similar one above to see how much time it is taking
//	SCREEN_BG_COLOR := SCREEN_BG_BLACK + BLACK;
		
		waitforraster( 20 );
		
		
	end;
	
	loop();

end.
