/*
** Name:      Colour
** Version:   1.0
** Author:    Paul Manias
** Copyright: DreamWorld Productions (c) 1997
** SAS/C:     sc Colour.c link startup=lib:gms.o data=far opt nostackcheck
** Doc:       Generates some nice patterns.  Hold LMB to exit.
**
**
*/

#include <proto/games.h>

extern struct GMSBase *GMSBase;
APTR   PREFSNAME = DEFAULT;

struct GameScreen *screen;

void Moire(void);

#define AMTCOLOURS 4

ULONG palette[AMTCOLOURS] = { 0x000000,0x505050,0x707070,0xF0F0F0 };

/***********************************************************************************/

void main(void)
{
  if (screen = AddScreenTags(TAGS_GAMESCREEN,NULL,
     GSA_AmtColours, sizeof(palette),
     GSA_Palette,    palette,
     TAGEND)) {

     ShowScreen(screen);
     InitJoyPorts();

     Moire();

  DeleteScreen(screen);
  }
}

/***********************************************************************************/

void Moire(void)
{
  WORD xm,ym,i;

  while(!(ReadJoyPort(JPORT1,JT_ZBXY) & MB_LMB)) {
    ClearBitmap(screen->Bitmap);
    xm = FastRandom(screen->ScrWidth);        /* Coordinates of Centre Point */
    ym = FastRandom(screen->ScrHeight);

    for (i=0; i < screen->ScrHeight; i++) {
       DrawLine(screen->Bitmap, xm, ym, 0, i, i%(2+1));
       DrawLine(screen->Bitmap, xm, ym, screen->ScrWidth,i, i%(2+1));
    }

    for (i=0; i < screen->ScrWidth; i++) {
       DrawLine(screen->Bitmap, xm, ym, i, 0, i%(2+1));
       DrawLine(screen->Bitmap, xm, ym, i, screen->ScrHeight, i%(2+1));
    }
    WaitTime(100);
  }
}

