Apple III: Console Driver--Screen Mode Switching Program

Apple III: Console Driver--Screen Mode Switching Program

The following program is a demostration of how to change the Apple III screen mode.
PROGRAM SCREENTEST;
 
PROCEDURE SCREENMODE (NUMBER: INTEGER);
VAR CH: CHAR;
BEGIN
   IF NUMBER IN [0..2] THEN BEGIN {If the given number is valid}
      WRITE (CHR (14));                {turn off the screen and}
      CH := CHR (16);
      UNITWRITE (1, CH, 1, , 12);    {send the prefix character}
      CH := CHR (NUMBER);
      UNITWRITE (1, CH, 1, , 12);      {and the mode character.}
      IF NUMBER = 2 THEN WRITE (CHR (1));   {If 80 column, restore}
                                            {viewport.}
      WRITE (CHR (28), CHR (15)); {Clear screen and turn it on.}
   END ELSE WRITELN (CHR (7), 'SCREENMODE ERROR '); {else OOPS!}
END;
 
PROCEDURE TESTERROR;
BEGIN
   WRITE (CHR (28));                         {Clear the screen.}
   GOTOXY (0,11);
   WRITE ('This will generate an error.  ');  {Write some text.}
   SCREENMODE (5);                        {Set an invalid mode.}
   WRITELN;
   WRITE ('Press RETURN to continue: ');
   READLN;
END;
 
PROCEDURE TEST40;
BEGIN
   SCREENMODE (0);                     {Set 40 column B/W mode.}
   GOTOXY (0,11);
   WRITELN ('This is 40 column text mode.');
   WRITELN;
   WRITE   ('Press RETURN to continue: ');
   READLN;
END;
 
PROCEDURE TESTCOLOR;
BEGIN
   SCREENMODE (1);                   {Set 40 column color mode.}
   WRITE (CHR (20), CHR (4));    {Set background to Dark Green.}
   WRITE (CHR (28));                         {Clear the screen.}
   WRITE (CHR (19), CHR (13));        {Set forground to Yellow.}
   GOTOXY (0,11);
   WRITELN ('This is 40 column COLOR mode.');
   WRITELN;
   WRITE   ('Press RETURN to quit: ');
   READLN;
END;
 
BEGIN
   TESTERROR;
   TEST40;
   TESTCOLOR;
   SCREENMODE (2);
END.