/* Standard-Includefile mit Display-Funktionen und   */
/* den noetigen globalen Variablen                   */
#include <screen&window.h>

/* Includefile fuer (u.a.) die Definition von SetOPen*/
#include <graphics/gfxmacros.h>

/* Includefile fuer Aztec-C                          */
#include <functions.h>

struct ViewPort* viep;
struct RastPort* rasp;
struct AreaInfo a_info;
struct TmpRas t_ras;
UWORD areabuf[500];
BYTE* area_plane;
UWORD farbliste[] = { 0x000,0xf00,0x0f0,0x00f,
                      0xfff,0xfb0,0x0db,0xc1f,
                      0xd00,0xf80,0xfd0,0xff0,
                      0xf90,0xbf0,0x8e0,0x2c0,
                      0x0b1,0x0bb,0x1fb,0x6fe,
                      0x6ce,0x61f,0x06d,0x91f,
                      0xf1f,0xfac,0xdb9,0xc80,
                      0xa87,0xccc,0x999,0xab6 };

UWORD fillpattern[] = { 0xff00,0xff00,0x00ff,0x00ff,
                        0xf0f0,0xf0f0,0x0f0f,0x0f0f };

UWORD multicolor_pattern[5][8] = {
                     { 0x0000,0x0000,0xffff,0xffff,
                       0x0000,0x0000,0xffff,0xffff },
                     { 0x0000,0x0000,0x0000,0x0000,
                       0xffff,0xffff,0xffff,0xffff },
                     { 0xff00,0xff00,0xff00,0xff00,
                       0xff00,0xff00,0xff00,0xff00 },
                     { 0x0000,0x0000,0x0000,0x0000,
                       0x0000,0x0000,0x0000,0x0000 },
                     { 0x0000,0x0000,0x0000,0x0000,
                       0x0000,0x0000,0x0000,0x0000 } };
                 
    
main()
{
 int i;

 make_display();  
 
 rasp = grafikwindow->RPort;

/* ViewPort-Zuweisung                                */
 viep = &grafikscreen->ViewPort;

 InitArea(&a_info,&areabuf[0],200L);
 area_plane = AllocRaster(320L,256L);

 rasp->AreaInfo = &a_info;
 rasp->TmpRas = &t_ras;

 InitTmpRas(&t_ras,area_plane,(long)RASSIZE(320,256)); 

/* Farbpalette in den ViewPort des Screens laden     */
 LoadRGB4(viep,&farbliste[0],32L);

/* 32 Rechtecke in verschiedenen Farben              */
 for(i=0;i<289;i+=9)
 {
  SetAPen(rasp,(long)i);
  RectFill(rasp,15L+i,20L,25L+i,40L);
 }

 Delay(50L);

/* Farben Nr.1 und Nr.4 sollen getauscht werden      */
 SetRGB4(viep,1L,15L,15L,15L);
 SetRGB4(viep,4L,15L,0L,0L);

 Delay(50L);

/* Rechteck mit Rand zeichnen                        */
 SetAPen(rasp,4L);
 SetOPen(rasp,2L);
 RectFill(rasp,50L,50L,150L,100L);

 Delay(50L);

/* Nicht eingerahmte...                              */
 SetAPen(rasp,4L);
 Move(rasp,170L,60L);
 Text(rasp,"Nicht eingerahmt",16L);

/* ...und eingerahmte Texte                          */
 SetAPen(rasp,3L);
 SetBPen(rasp,2L);
 Move(rasp,170L,85L);
 Text(rasp,"Eingerahmt",10L);

 Delay(50L);
/* Nun werden ein paar gepunktete Linien gezeichnet  */
 SetBPen(rasp,0L);

 SetAPen(rasp,4L);
/* Hierfuer muss das DrawPattern veraendert werden   */
 SetDrPt(rasp,0xcccc);
 Move(rasp,50L,110L);
 Draw(rasp,270L,110L);

 SetAPen(rasp,4L);
 SetDrPt(rasp,0x4444);
 Move(rasp,50L,120L);
 Draw(rasp,270L,120L);

/* Und dasselbe noch einmal, nur mit anderem BPen    */
 SetBPen(rasp,2L);

 SetAPen(rasp,4L);
 SetDrPt(rasp,0xcccc);
 Move(rasp,50L,130L);
 Draw(rasp,270L,130L);

 SetAPen(rasp,4L);
 SetDrPt(rasp,0x4444);
 Move(rasp,50L,140L);
 Draw(rasp,270L,140L);

 Delay(50L);

/* Das Fuellmuster wird geladen                      */
 SetAfPt(rasp,&fillpattern[0],3L);

/* Eine Flaeche wird im Fuellmuster gezeichnet       */
 RectFill(rasp,50L,150L,120L,220L);

 Delay(50L);

/* Das Vielfarbenmuster wird geladen                 */
 SetAfPt(rasp,&multicolor_pattern[0][0],-3L);

/* Eine Flaeche wird im Fuellmuster gezeichnet       */
 RectFill(rasp,130L,150L,200L,220L);

 Delay(50L);

/* Nun wird Bitmap 2 desaktiviert...                 */
 SetWrMsk(rasp,0xfb);

/* ...und die letzte Flaeche noch einmal gezeichnet  */
 RectFill(rasp,210L,150L,280L,220L);

 Delay(50L);

/* Alle Bitplanes aktivieren                         */
 SetWrMsk(rasp,0xff);

/* Nun folgen die letzten drei RectFills mit         */
/* veraendertem Zeichenmodus                         */
 SetDrMd(rasp,JAM1|COMPLEMENT);

 SetAfPt(rasp,&fillpattern[0],3L);
 RectFill(rasp,50L,150L,120L,220L);
 Delay(50L);
 SetAfPt(rasp,&multicolor_pattern[0][0],-3L);
 RectFill(rasp,130L,150L,200L,220L);
 Delay(50L);
 SetWrMsk(rasp,0xfb);
 RectFill(rasp,210L,150L,280L,220L);

 Wait(1L<<grafikwindow->UserPort->mp_SigBit);
 
 FreeRaster(area_plane,320L,256L);

 end_display();
 
 Exit(1L);
}
