program Text16;
@use "graphics"
@use "text/text"
var  
	
	/*
	
	This example uses the "text" library to set up and display a 16x16 font (by Hammerfirst)
 	
 	The font itself is located at : resources/fonts/font16x16.flf
	
	*/

	@export "resources/fonts/font16x16.flf" "resources/fonts/font16x16.bin" 256

	// Remember that the font data must also reside in chipmem!	
	fontData : incbin("resources/fonts/font16x16.bin") chipmem;
	// Random text!
	text : string =("THIS FONT IS SIXTEEN",10,10,
					"BY SIXTEEN",10,10,
					"KTHKXBYE");
					
	const noBitPlanes : integer = 1;				
	const printSpeed : integer = 16;
	
	const fontHeight : byte = 21;
	const fontWidth : byte = 16;
	
	const asciiStart : byte = 65; // PETSCII font, so ASCII starts at char 64
	
	const screenWidth : integer = 320; // We're using 320x256
	

	screen : array[40*256*noBitPlanes] of byte chipmem;
 
	const speed : integer = 16;



begin	
	// Initialises 320x256 1-bitplane using "screen" as the screen buffer
	Graphics::SetupDefaultScreen(#screen,noBitPlanes);	
	// Initialise a 8x8 font based on the included data. Currently only 1-bpl fonts are supported
	Text::Init( #fontData, screenWidth, asciiStart, fontWidth, fontHeight, noBitPlanes, #Text::lookup16x16, true);
	// Draws a string at position (x,y) = (8*32)
	Text::Draw("HELLO WORLD", 0, 32, #screen);
	// Initialise a text printer at position (x,y) = (4*8,64)
	Text::InitPrinter(#text, 0,64, #screen, printSpeed);
	
	while (true) do
	begin
		waitverticalblank();
		Text::AdvancePrinter();
	end;	
end.

