/* $Revision Header *** Header built automatically - do not edit! ***********
 *
 *	(C) Copyright 1992 by Metalworx
 *
 *	Name .....: sysinfo.c
 *	Created ..: Sun 26-Apr-92 19:30
 *	Revision .: 0
 *
 *	Date		Author		Comment
 *	=========	========	====================
 *	16-May-91	Mtwx		Created this file!
 *
 * $Revision Header ********************************************************/
 #define REVISION 0

/***************************************************************************
* sysinfo.c: gibt einige Systeminfos mit Hilfe von TextRequest() der       *
*	     req.library aus						   *
*									   *
* created: 16-May-91 Mtwx						   *							  *
* updated: 16-May-91 Mtwx						   *
***************************************************************************/

#include <string.h>
#include "chem_defs.h"
#include "messages.h"

static struct Controls
{
  long size_chip;
  long size_fast;
  long size_total;
  char *CPU_Id;
  char *MaC_Id;
} Controls;


static struct TRStructure TRStruct;
extern struct ReqLib *ReqBase;

void	  SysInfo(void)
{
  char	    Text[1024];
  static struct CPU CPU;

  Controls.size_chip = AvailMem(MEMF_CHIP);
  Controls.size_fast = AvailMem(MEMF_FAST);
  Controls.size_total=Controls.size_chip+Controls.size_fast;
  strcpy(Text,"System Info:\n\n");
  strcat(Text,FREE_CHIP);
  strcat(Text,FREE_FAST);
  strcat(Text,FREE_TOTAL);
  CPU = CheckCPU();
  strcat(Text,"CPU-Type         : %5s\n");
  Controls.CPU_Id=CPU.CPU_Id;
  strcat(Text,"Math Coprocessor : %5s");
  Controls.MaC_Id=CPU.MaC_Id;
  TRStruct.Text=Text;
  TRStruct.Controls=(char *) &Controls;
  TRStruct.NegativeText=RESUME_TEXT;
  TRStruct.Title="System-Information";
  TRStruct.textcolor=8;
  TextRequest(&TRStruct);
}

struct CPU CheckCPU(void)
{
  char	    banner[6];
  struct CPU CPU;
			  /* set up Intuition/AmigaDOS structure pointers */
  struct DOSBase *DOSBase;
  struct ExecBase **SysBase;
  register struct ExecBase *ExecBase;

			 /* define other variables as registers,
			  to save space */
  register int attnflag;	       /* processor type bits from ExecBase struct */

  strcpy(banner,"680");
  strcpy(CPU.CPU_Id,"");
  strcpy(CPU.MaC_Id,"");

			 /* Set up the ExecBase pointer manually,
			  since we don't link with anybody */
  SysBase = (struct ExecBase **) (4L);
  ExecBase = *SysBase;
  DOSBase = (struct DOSBase *) ReqBase->DosLib;

			 /* Only read the ExecBase structure once,
			  to save space */
  attnflag = ExecBase->AttnFlags;

  if (attnflag & AFF_68020)
    strcat(banner,"20");
  else
  {
    if (attnflag & AFF_68010)
      strcat(banner,"10");
    else
      strcat(banner,"00");
  }

  strcpy(CPU.CPU_Id, banner);

			 /* check for math co-processor */
  if (attnflag & AFF_68881)
    strcpy(CPU.MaC_Id, "68881");
  else
    strcpy(CPU.MaC_Id, "-----");

			 /* Clean up and go home */
  return (CPU);
}
