System/Workbook: gi_RastPort should not be directly accessed
[AROS.git] / test / blttemplatealpha.c
blob6ff51438741fcb2c20fbf473a2a338d35b895bf1
2 #include <dos/dos.h>
3 #include <intuition/intuition.h>
4 #include <graphics/gfx.h>
5 #include <cybergraphx/cybergraphics.h>
6 #include <proto/exec.h>
7 #include <proto/dos.h>
8 #include <proto/graphics.h>
9 #include <proto/cybergraphics.h>
10 #include <proto/intuition.h>
12 #include <math.h>
13 #include <stdio.h>
14 #include <stdlib.h>
16 #define SCREENWIDTH 300
17 #define SCREENHEIGHT 200
18 #define SCREENCY (SCREENHEIGHT / 2)
20 /***********************************************************************************/
22 struct IntuitionBase *IntuitionBase;
23 struct GfxBase *GfxBase;
24 struct Library *CyberGfxBase;
25 struct Screen *scr;
26 struct Window *win;
27 struct RastPort *rp;
29 UBYTE buf[SCREENWIDTH * SCREENHEIGHT];
31 /***********************************************************************************/
33 static void cleanup(char *msg)
35 if (msg)
37 printf("BltTemplateAlpha: %s\n",msg);
40 if (win) CloseWindow(win);
42 if (scr) UnlockPubScreen(0, scr);
44 if (CyberGfxBase) CloseLibrary(CyberGfxBase);
45 if (GfxBase) CloseLibrary((struct Library *)GfxBase);
46 if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
48 exit(0);
51 /***********************************************************************************/
53 static void openlibs(void)
55 if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39)))
57 cleanup("Can't open intuition.library V39!");
60 if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39)))
62 cleanup("Can't open graphics.library V39!");
65 if (!(CyberGfxBase = OpenLibrary("cybergraphics.library",0)))
67 cleanup("Can't open cybergraphics.library!");
71 /***********************************************************************************/
73 static void getvisual(void)
75 if (!(scr = LockPubScreen(NULL)))
77 cleanup("Can't lock pub screen!");
80 if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8)
82 cleanup("Need hi or true color screen!");
86 /***********************************************************************************/
88 static void makewin(void)
90 win = OpenWindowTags(NULL, WA_CustomScreen , (IPTR)scr,
91 WA_InnerWidth , SCREENWIDTH,
92 WA_InnerHeight , SCREENHEIGHT,
93 WA_Title , (IPTR)"BltTemplateAlpha: Moving mouse is useless!",
94 WA_DragBar , TRUE,
95 WA_DepthGadget , TRUE,
96 WA_CloseGadget , TRUE,
97 WA_Activate , TRUE,
98 WA_IDCMP , IDCMP_CLOSEWINDOW,
99 WA_BackFill , (IPTR) LAYERS_NOBACKFILL,
100 TAG_DONE);
102 if (!win) cleanup("Can't open window");
104 rp = win->RPort;
108 /***********************************************************************************/
110 #define KC_LEFT 0x4F
111 #define KC_RIGHT 0x4E
112 #define KC_UP 0x4C
113 #define KC_DOWN 0x4D
114 #define KC_ESC 0x45
116 /***********************************************************************************/
118 /***********************************************************************************/
120 static void action(void)
122 int x, y;
123 for(y = 0; y < SCREENHEIGHT; y++)
125 for(x = 0; x < SCREENWIDTH; x++)
127 buf[y * SCREENWIDTH + x] = (y + x) & 255;
131 SetABPenDrMd(rp, 1, 2, JAM1);
133 BltTemplateAlpha(buf, 0, SCREENWIDTH, rp, win->BorderLeft, win->BorderTop, SCREENWIDTH, SCREENHEIGHT);
136 WaitPort(win->UserPort);
139 /***********************************************************************************/
141 int main(void)
143 openlibs();
144 getvisual();
145 makewin();
146 action();
147 cleanup(0);
149 return 0;
152 /***********************************************************************************/