clear exclusive access in local monitor (needed if interrupt occurred
[AROS.git] / test / ilbmtoc.c
blobdc55634b84dbce4d6032b9001d7c74d2a6e4dd01
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <intuition/intuition.h>
7 #include <graphics/gfx.h>
8 #include <cybergraphx/cybergraphics.h>
9 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/intuition.h>
12 #include <proto/cybergraphics.h>
13 #include <stdio.h>
14 #include <string.h>
16 struct IntuitionBase *IntuitionBase;
17 struct GfxBase *GfxBase;
18 struct Library *CyberGfxBase;
19 struct Window *win;
20 struct RastPort *rp;
22 #include "ilbmtoc_image.c"
24 UBYTE unpacked_image[EARTHMAP_SMALL_WIDTH * EARTHMAP_SMALL_HEIGHT];
26 #define CONTINENT_RED 18
27 #define CONTINENT_GREEN 114
28 #define CONTINENT_BLUE 58
30 #define OCEAN_RED 21
31 #define OCEAN_GREEN 18
32 #define OCEAN_BLUE 114
34 static unsigned char *unpack_byterun1(unsigned char *source, unsigned char *dest, LONG unpackedsize)
36 unsigned char r;
37 signed char c;
39 for(;;)
41 c = (signed char)(*source++);
42 if (c >= 0)
44 while(c-- >= 0)
46 *dest++ = *source++;
47 if (--unpackedsize <= 0) return source;
50 else if (c != -128)
52 c = -c;
53 r = *source++;
55 while(c-- >= 0)
57 *dest++ = r;
58 if (--unpackedsize <= 0) return source;
65 int main(void)
67 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39);
68 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39);
69 CyberGfxBase = OpenLibrary("cybergraphics.library", 39);
71 if (IntuitionBase && GfxBase && CyberGfxBase)
73 printf("All libraries opened\n");
75 win = OpenWindowTags(0, WA_InnerWidth, EARTHMAP_SMALL_WIDTH,
76 WA_InnerHeight, EARTHMAP_SMALL_HEIGHT,
77 WA_CloseGadget, TRUE,
78 WA_DepthGadget, TRUE,
79 WA_DragBar, TRUE,
80 WA_IDCMP, IDCMP_CLOSEWINDOW,
81 WA_Activate, TRUE,
82 TAG_DONE);
84 rp = win->RPort;
86 unpack_byterun1(earthmap_small_data, unpacked_image, EARTHMAP_SMALL_WIDTH * EARTHMAP_SMALL_HEIGHT);
89 WORD i;
91 for(i = 0; i < EARTHMAP_SMALL_COLORS; i++)
93 ULONG rgb = earthmap_small_pal[i];
94 ULONG red = (rgb & 0xFF0000) >> 16;
95 ULONG green = (rgb & 0x00FF00) >> 8;
96 ULONG blue = (rgb & 0x0000FF);
97 ULONG alpha = (red + green + blue) / 3;
99 red = (alpha * OCEAN_RED + (255 - alpha) * CONTINENT_RED) / 255;
100 green = (alpha * OCEAN_GREEN + (255 - alpha) * CONTINENT_GREEN) / 255;
101 blue = (alpha * OCEAN_BLUE + (255 - alpha) * CONTINENT_BLUE) / 255;
103 rgb = (red << 16) + (green << 8) + blue;
105 earthmap_small_pal[i] = rgb;
110 WriteLUTPixelArray(unpacked_image,
113 EARTHMAP_SMALL_WIDTH,
115 earthmap_small_pal,
116 win->BorderLeft,
117 win->BorderTop,
118 EARTHMAP_SMALL_WIDTH,
119 EARTHMAP_SMALL_HEIGHT,
120 CTABFMT_XRGB8);
122 WaitPort(win->UserPort);
124 CloseWindow(win);
127 return 0;