program TileMap;
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. 

// Show two tilemaps (key 1 and 2) of different sizes

// declare all your include files here
@export "resources/charsets/tiles.flf" "resources/charsets/tiles.bin" 10
tiles: incbin( "resources/charsets/tiles.bin", $4000 ); // individual tile characters
map: incbin( "resources/charsets/tilemap.bin", $4050 ); // full screen map of tiles
map10: incbin( "resources/charsets/tilemap10x10.bin", $4230 ); // small tilemap
font: incbin( "resources/charsets/font8x8.bin", $4294 ); // character set for first 64 PETSCII Screen Codes


	i : byte;

	message: CSTRING = "PRESS  1 OR 2";

begin

	// set the default display mode showing all 20 columns
	vbmSetDisplayMode( 0 );
	
	// Clear the bitmap with a value of 0
	vbmClear( 0 );
	
	// set the colour memory to GREEN
	vbmClearColor( GREEN );
	
	// set screen colour
	SCREEN_BG_COLOR := SCREEN_BG_BLACK + GREEN;
	vbmDrawText( #message, #font, 3, 100, 8 );

	while (true) offpage do
	begin
	
		i := getkey();
		
		case i of 
			
			// draw a complete tilemap if key 1 is pressed
			KEY_1: vbmDrawTileMap( #map, #tiles, 0,0, 20,184 );
			
			// draw a small tilemap if key 2 is pressed (56)
			KEY_2:
			begin
				vbmClear( 0 );
 				vbmDrawTileMap( #map10, #tiles, 5,100, 15,172 );
 			end;
 			
		end;
		
		waitforraster(100);

	end;

end.
