program Demo4;

uses
  	MCGA256, Crt, Memory;

var
  	StandardPal: PaletteArray;
    Ch: char;




procedure ErrorReadingFile;
begin
	CloseGraphics;
    WriteLn('Program terminated: Error reading file.');
    Halt(2);
end; {ErrorReadingFile}



procedure DisplayCharacterSet(x, y: word);
var i, xpos, ypos: word;
begin
	xpos := x;	ypos := y;
	for i := 32 to 127 do
    begin
    	DisplayChar(Chr(i), x, y, 15);
        x := x + 8;
        if (x > 300) then
        begin
        	x := 0;
            y := y + 10;
        end;
    end;
end; {DisplayCharacterSet}



begin
	if (not OpenGraphics) then
    begin
    	WriteLn('Error opening graphics library.');
        Halt(1);
    end;

    SetActivePage(UserScreen);
    FillRectangle(0, 0, 319, 199, 0);
    if (not LoadPalette('STANDARD.PAL', StandardPal)) then ErrorReadingFile;
    SetPalette(StandardPal);

    SetTextFont(1);
    DisplayString('This is the system character set:', 0, 10, 214);
    DisplayCharacterSet(0, 20);
    SetTextFont(2);
    SetTextSpacing(-2);
    DisplayString('THIS IS THE TINY CHARACTER SET:', 0, 60, 34);
    DisplayCharacterSet(0, 70);
    SetTextFont(3);
    SetTextSpacing(-1);
    DisplayString('This is the line character set:', 0, 110, 86);
    DisplayCharacterSet(0, 120);
    SetTextFont(1);
    SetTextSpacing(0);
    DisplayString('press a key...', 200, 190, 123);
  	Ch := ReadKey;

    FillRectangle(0, 0, 319, 199, 0);
    DisplayString('They can be in different sizes:', 0, 10, 125);
    SetTextWidth(2);
    DisplayString('Double Width', 20, 30, 45);
    SetTextFont(2);
    SetTextSpacing(-2);
    SetTextHeight(2);
    SetTextWidth(1);
    DisplayString('DOUBLE HEIGHT', 20, 50, 178);
    SetTextFont(3);
    SetTextSpacing(-1);
    SetTextWidth(2);
    DisplayString('and BOTH', 20, 70, 78);
    SetTextHeight(1);
    SetTextWidth(1);
    SetTextFont(1);
    SetTextSpacing(0);
    DisplayString('With different spacing:', 0, 100, 125);
    SetTextSpacing(8);
    DisplayString('Such as this.', 20, 120, 235);
    SetTextFont(2);
    SetTextSpacing(-4);
    DisplayString('AND EVEN THIS.', 20, 140, 68);
    SetTextFont(1);
    SetTextSpacing(0);
    DisplayString('Press a key to quit...', 90, 180, 7);
    DisplayString('Press a key to quit...', 89, 179, 15);

    Ch := ReadKey;
  	CloseGraphics;
end.