dos.library: Fix race condition caught by mungwall in CreateNewProc()
[AROS.git] / test / ilbmtoc.c
blobfc950012c72a89f0cc0aa3fe8553b4f7e09f1e73
1 #include <intuition/intuition.h>
2 #include <graphics/gfx.h>
3 #include <cybergraphx/cybergraphics.h>
4 #include <proto/exec.h>
5 #include <proto/graphics.h>
6 #include <proto/intuition.h>
7 #include <proto/cybergraphics.h>
8 #include <stdio.h>
9 #include <string.h>
11 struct IntuitionBase *IntuitionBase;
12 struct GfxBase *GfxBase;
13 struct Library *CyberGfxBase;
14 struct Window *win;
15 struct RastPort *rp;
17 #include "ilbmtoc_image.c"
19 UBYTE unpacked_image[EARTHMAP_SMALL_WIDTH * EARTHMAP_SMALL_HEIGHT];
21 #define CONTINENT_RED 18
22 #define CONTINENT_GREEN 114
23 #define CONTINENT_BLUE 58
25 #define OCEAN_RED 21
26 #define OCEAN_GREEN 18
27 #define OCEAN_BLUE 114
29 static unsigned char *unpack_byterun1(unsigned char *source, unsigned char *dest, LONG unpackedsize)
31 unsigned char r;
32 signed char c;
34 for(;;)
36 c = (signed char)(*source++);
37 if (c >= 0)
39 while(c-- >= 0)
41 *dest++ = *source++;
42 if (--unpackedsize <= 0) return source;
45 else if (c != -128)
47 c = -c;
48 r = *source++;
50 while(c-- >= 0)
52 *dest++ = r;
53 if (--unpackedsize <= 0) return source;
60 int main(void)
62 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39);
63 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39);
64 CyberGfxBase = OpenLibrary("cybergraphics.library", 39);
66 if (IntuitionBase && GfxBase && CyberGfxBase)
68 printf("All libraries opened\n");
70 win = OpenWindowTags(0, WA_InnerWidth, EARTHMAP_SMALL_WIDTH,
71 WA_InnerHeight, EARTHMAP_SMALL_HEIGHT,
72 WA_CloseGadget, TRUE,
73 WA_DepthGadget, TRUE,
74 WA_DragBar, TRUE,
75 WA_IDCMP, IDCMP_CLOSEWINDOW,
76 WA_Activate, TRUE,
77 TAG_DONE);
79 rp = win->RPort;
81 unpack_byterun1(earthmap_small_data, unpacked_image, EARTHMAP_SMALL_WIDTH * EARTHMAP_SMALL_HEIGHT);
84 WORD i;
86 for(i = 0; i < EARTHMAP_SMALL_COLORS; i++)
88 ULONG rgb = earthmap_small_pal[i];
89 ULONG red = (rgb & 0xFF0000) >> 16;
90 ULONG green = (rgb & 0x00FF00) >> 8;
91 ULONG blue = (rgb & 0x0000FF);
92 ULONG alpha = (red + green + blue) / 3;
94 red = (alpha * OCEAN_RED + (255 - alpha) * CONTINENT_RED) / 255;
95 green = (alpha * OCEAN_GREEN + (255 - alpha) * CONTINENT_GREEN) / 255;
96 blue = (alpha * OCEAN_BLUE + (255 - alpha) * CONTINENT_BLUE) / 255;
98 rgb = (red << 16) + (green << 8) + blue;
100 earthmap_small_pal[i] = rgb;
105 WriteLUTPixelArray(unpacked_image,
108 EARTHMAP_SMALL_WIDTH,
110 earthmap_small_pal,
111 win->BorderLeft,
112 win->BorderTop,
113 EARTHMAP_SMALL_WIDTH,
114 EARTHMAP_SMALL_HEIGHT,
115 CTABFMT_XRGB8);
117 WaitPort(win->UserPort);
119 CloseWindow(win);
122 return 0;