[net.micro.amiga] Program to test larger-than-normal screen sizes.

dillon@CORY.BERKELEY.EDU (Matt Dillon) (06/20/86)

	This is NOT a shell archive.  Note that this is only a fool-around-with
me program, and it is possible to crash the machine if you specify values
that are out of range.  To run the program, execute from your CLI or favorite
shell: YOU MUST COMPILE WITH 32-bit INT's or fix the code yourself.

wscreen width height [delay]

If no delay is specified, the screen will stay active for 60 seconds.  You
specify the delay in ticks (e.g. 50 = 1 second):  This program uses lo-res
screens, though you can change it if you want.  The maximum screen size for
lo-res screens is 352x262.  If you specify values < 16, you'll probably
crash your Amiga.

wscreen 320 200 500				-normal screen, delay 10 seconds
wscreen 340 220 500				-somewhat larger.





/*
 * WSCREEN.C
 *
 * Attempt to create a wide screen.  You can use the minimal startup
 * (and thus not have to link in lc.lib), if you want.  Please link with
 * 32 bit integers.
 *
 * wscreen width height [delay in seconds]
 *
 *	-I forgot to close the libraries or fully check error returns.. 
 *		remember, this is a scratch program.
 */

#include <exec/types.h>
#include <exec/exec.h>
#include <devices/serial.h>
#include <devices/console.h>
#include <devices/timer.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <stdio.h>

static struct TextAttr Ta = { "topaz.font", 8 };

static struct NewScreen Ns = {
   0, 0, 0, 0, 1,
   0, 1,
   0,
   CUSTOMSCREEN,
   &Ta,
   "test"
};

int IntuitionBase;
int GfxBase;

main(ac, av)
char *av[];
{
   int delay = 50 * 60;
   struct Screen *scr;

   IntuitionBase = OpenLibrary("intuition.library", 0);
   GfxBase       = OpenLibrary("graphics.library",  0);

   if (ac < 3 || IntuitionBase == 0 || GfxBase == 0) {
      printf ("width height [delay]");
      exit (1);
   }
   Ns.Width = atoi(av[1]);
   Ns.Height= atoi(av[2]);
   if (av[3])
      delay = atoi(av[3]);

   scr = (struct Screen *)OpenScreen(&Ns);
   if (scr) {
      junk(&scr->RastPort, Ns.Width, Ns.Height);

      Delay(delay);
      CloseScreen(scr);
   }
}


atoi(str)
char *str;
{
   short i = 0;

   while (*str)
      i = (short)(i * (short)10) + *str++ - '0';
   return ((int)i);
}

junk(rp, width, height)
struct RastPort *rp;
{
   int xs, ys, xe, ye;

   xs = ys = 0;
   xe = width - 1;
   ye = height - 1;

   SetAPen (rp, 1);
   while (xe > 10 && ye > 10) {
      Move (rp, xs   , ys   );
      Draw (rp, xs+xe, ys   );
      Draw (rp, xs+xe, ys+ye);
      Draw (rp, xs   , ys+ye);
      Draw (rp, xs   , ys   );
      xs += 2;
      ys += 2;
      xe -= 4;
      ye -= 4;
   }
}