echo ;  /*  Hmmm
lc -cwusf -v -sc=__MERGED -y cli_60or80.c
blink cli_60or80.o LIB lib:amiga.lib DEFINE _stdout=_echo SD SC ND VERBOSE
quit
*/

/*   cli_60or80.c                                                     */
/*   by Mark E. Schretlen    87-09-26   modified 87-12-15             */

/*   type "execute cli_60or80.c" to compile & link with Lattice 4.0   */

#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include "proto/intuition.h"
#include "exec/execbase.h"
#include "proto/exec.h"
#include "proto/dos.h"

#define INTUITION_REV 0L
#pragma libcall IntuitionBase GetPrefs 84 802
#pragma libcall IntuitionBase SetPrefs 144 10803
#pragma syscall CloseLibrary 19e 901
#pragma syscall OpenLibrary 228 902

int   printf(char *,);

struct ExecBase *SysBase = 0;
struct IntuitionBase *IntuitionBase = 0;
struct Preferences Buffer;
struct Window *w;
struct DosLibrary  *DOSBase;
struct List *lh = NULL;
struct Node *ln, *FindName();

char NewSIZE = TOPAZ_EIGHTY;

void cli6080()
{
   struct Preferences *PrefBuffer;

   if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",0)))  return;

   echo = (int)Output();

   PrefBuffer = &Buffer;
   SysBase = (struct ExecBase *)OpenLibrary("exec.library", 0);

   lh = &(SysBase->PortList);
   ln = FindName(lh,"Workbench");
   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", INTUITION_REV);
   if( (ln == 0) || (IntuitionBase == NULL)  ||  ((w = IntuitionBase->ActiveWindow) == NULL) )
      {
      printf (" Where's Workbench ? \n");
      CloseLibrary((struct Library *)IntuitionBase); /* modify to a closeAllLibs() routine  */
      CloseLibrary((struct Library *)SysBase);
      CloseLibrary((struct Library *)DosBase);
      return;
      }

   Forbid ();
   GetPrefs(PrefBuffer, (long) sizeof(struct Preferences));

   if( NewSIZE == PrefBuffer->FontHeight ) NewSIZE = TOPAZ_SIXTY;
   else NewSIZE = TOPAZ_EIGHTY;

   PrefBuffer->FontHeight = NewSIZE;
   SetPrefs(PrefBuffer, (long) sizeof(struct Preferences), TRUE);
   w->WScreen->FirstWindow->NextWindow->Title = "60or80 by Mark Schretlen ";
   Permit ();

   printf (" 60or80 by Mark Schretlen ---- distribute freely \n");
   CloseLibrary((struct Library *)IntuitionBase);
   CloseLibrary((struct Library *)SysBase);
   CloseLibrary((struct Library *)DosBase);
}
