Updated PCI IDs to latest snapshot.
[tangerine.git] / test / obtainpentest.c
blob6c33f7f365f3e2750e8ecc3dcbe50cf913cbba1b
1 #include <proto/graphics.h>
2 #include <proto/exec.h>
3 #include <intuition/intuitionbase.h>
4 #include <intuition/screens.h>
5 #include <graphics/view.h>
7 #include <stdio.h>
9 int main(void)
11 struct IntuitionBase * IntuitionBase;
12 struct Library * GfxBase;
13 struct ViewPort * vp;
14 struct ColorMap * cm;
15 struct PaletteExtra * pe;
16 #define NUMCOLORS 32
17 ULONG n[2*NUMCOLORS];
18 ULONG i;
20 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
21 GfxBase = OpenLibrary("graphics.library",0);
23 cm = GetColorMap(NUMCOLORS);
25 vp = &IntuitionBase->ActiveScreen->ViewPort;
27 AttachPalExtra(cm,vp);
28 pe = cm->PalExtra;
30 n[0] = ObtainPen(cm,
31 -1,
32 0xa0000000,
33 0xb0000000,
34 0xc0000000,
35 0);
37 printf("Got pen number %ld.\n",n[0]);
39 printf("Trying to obtain the same pen as shared.\n");
40 n[1] = ObtainPen(cm,
41 -1,
42 0xa0000000,
43 0xb0000000,
44 0xc0000000,
45 0);
47 printf("Got pen number %ld (=%ld!).\n",n[1],n[0]);
49 printf("Trying to obtain a pen as exclusive.\n");
50 n[2] = ObtainPen(cm,
51 -1,
52 0xa0000000,
53 0xb0000000,
54 0xc0000000,
55 PENF_EXCLUSIVE);
57 printf("Got pen number %ld.\n",n[2]);
59 printf("Trying to allocate pen %ld as exclusive again.\n",n[2]);
60 n[3] = ObtainPen(cm,
61 n[2],
62 0xa0000000,
63 0xb0000000,
64 0xc0000000,
65 PENF_EXCLUSIVE);
67 printf("Got pen number %ld.\n",n[3]);
69 printf("Trying to allocate pen %ld as shared.\n",n[2]);
70 n[4] = ObtainPen(cm,
71 n[2],
72 0xa0000000,
73 0xb0000000,
74 0xc0000000,
75 0);
77 printf("Got pen number %ld.\n",n[4]);
79 printf("Releasing all pens.\n");
80 ReleasePen(cm, n[4]);
81 ReleasePen(cm, n[3]);
82 ReleasePen(cm, n[2]);
83 ReleasePen(cm, n[1]);
84 ReleasePen(cm, n[0]);
86 printf("Obtaining a shared pen.\n");
87 n[0] = ObtainPen(cm,
88 -1,
89 0xa0000000,
90 0xb0000000,
91 0xc0000000,
92 0);
94 printf("Got pen number %ld.\n",n[0]);
96 ReleasePen(cm, n[0]);
98 printf("---------------------------\n");
100 printf("Trying to allocate %d shared pens\n",NUMCOLORS);
101 i = 0;
102 while (i < NUMCOLORS)
104 n[i] = ObtainPen(cm, -1, i << 28, i << 24, i << 20,0);
106 printf("Got pen %ld\n",n[i]);
107 i++;
110 printf("Trying to get %d exclusive pens (no pen was released)\n",NUMCOLORS);
111 i = 0;
112 while (i < NUMCOLORS)
114 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
116 printf("Got pen %ld (=-1)\n",n[i+NUMCOLORS]);
117 i++;
120 printf("Releasing all pens!\n");
121 i = 0;
122 while (i < 2 * NUMCOLORS)
124 ReleasePen(cm, n[i]);
125 i++;
128 printf("---------------------------\n");
131 printf("Trying to get %d exclusive pens\n",NUMCOLORS);
132 i = 0;
133 while (i < NUMCOLORS)
135 n[i] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
137 printf("Got pen %ld\n",n[i]);
138 i++;
141 printf("Trying to allocate %d shared pens (no pen was released)\n",NUMCOLORS);
142 i = 0;
143 while (i < NUMCOLORS)
145 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,0);
147 printf("Got pen %ld (=-1)\n",n[i+NUMCOLORS]);
148 i++;
151 printf("Releasing all pens!\n");
152 i = 0;
153 while (i < 2*NUMCOLORS)
155 ReleasePen(cm, n[i]);
156 i++;
159 printf("---------------------------\n");
161 printf("Trying to allocate %d shared pens at certain indices\n",NUMCOLORS);
162 i = 0;
163 while (i < NUMCOLORS)
165 n[i] = ObtainPen(cm, i, 0, 0, 0,0);
167 printf("Got pen %ld\n",n[i]);
168 i++;
171 printf("Trying to get %d exclusive pens (no pen was released)\n",NUMCOLORS);
172 i = 0;
173 while (i < NUMCOLORS)
175 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,PENF_EXCLUSIVE);
177 printf("Got pen %ld (=-1)\n",n[i+NUMCOLORS]);
178 i++;
181 printf("Releasing all pens!\n");
182 i = 0;
183 while (i < 2 * NUMCOLORS)
185 ReleasePen(cm, n[i]);
186 i++;
189 printf("---------------------------\n");
191 printf("Trying to get %d exclusive pens at certain indices\n",NUMCOLORS);
192 i = 0;
193 while (i < NUMCOLORS)
195 n[i] = ObtainPen(cm, i, 0,0,0,PENF_EXCLUSIVE);
197 printf("Got pen %ld\n",n[i]);
198 i++;
201 printf("Trying to allocate %d shared pens (bo pen was released)\n",NUMCOLORS);
202 i = 0;
203 while (i < NUMCOLORS)
205 n[i+NUMCOLORS] = ObtainPen(cm, -1, 0,0,0,0);
207 printf("Got pen %ld (=-1)\n",n[i+NUMCOLORS]);
208 i++;
211 printf("Releasing all pens!\n");
212 i = 0;
213 while (i < 2*NUMCOLORS)
215 ReleasePen(cm, n[i]);
216 i++;
219 printf("---------------------------\n");
221 FreeColorMap(cm);
223 return 0;