ata.device: Add another 'const' to move attrBaseIDs from .data to .rodata
[AROS.git] / test / sortlayercr.c
blob1e23737e5faa5394d6e164ec4d200756719c4ab7
1 #include <graphics/clip.h>
2 #include <graphics/gfx.h>
3 #include <exec/exec.h>
4 #include <proto/layers.h>
5 #include <proto/exec.h>
7 #include <stdio.h>
9 struct Library *LayersBase;
10 struct Layer dummy_lay;
12 struct ClipRect dummy_cr[100];
14 void setcr(WORD which, WORD x1, WORD y1, WORD x2, WORD y2)
16 dummy_cr[which].bounds.MinX = x1;
17 dummy_cr[which].bounds.MinY = y1;
18 dummy_cr[which].bounds.MaxX = x2;
19 dummy_cr[which].bounds.MaxY = y2;
20 dummy_cr[which].Flags = which;
22 if (which > 0) dummy_cr[which - 1].Next = &dummy_cr[which];
25 void makecrs(void)
27 /* 0000000000011111111122
28 0123456789012345678901
30 00 +---+---+------------+
31 01 | 0 | | |
32 02 +---+ | 2 |
33 03 | | 1 +---+--------+
34 04 | 3 | | 4 | |
35 05 +---+ +---+ |
36 06 | 6 | | | 5 |
37 07 +---+---+ 8 +--------+
38 08 | 7 | | 9 |
39 09 +-------+---+--------+
42 setcr(0, 0, 0, 39, 19);
43 setcr(1, 40, 0, 79, 69);
44 setcr(2, 80, 0, 209, 29);
45 setcr(3, 0, 20, 39, 49);
46 setcr(4, 80, 30, 119, 49);
47 setcr(5, 120, 30, 209, 69);
48 setcr(6, 0, 50, 39, 69);
49 setcr(7, 0, 70, 79, 89);
50 setcr(8, 80, 50, 119, 89);
51 setcr(9, 120, 70, 209, 89);
53 dummy_lay.ClipRect = dummy_cr;
56 void doit(char *msg, WORD dx, WORD dy)
58 struct ClipRect *cr;
60 SortLayerCR(&dummy_lay, dx, dy);
62 printf("\n%s\n----------------------------\n", msg);
63 cr = dummy_lay.ClipRect;
64 while(cr)
66 printf("%ld ", (long)cr->Flags);
67 cr = cr->Next;
69 printf("\n");
73 void action(void)
75 doit("UP", 0, -1);
76 doit("DOWN", 0, 1);
77 doit("LEFT", -1, 0);
78 doit("RIGHT", 1, 0);
79 doit("UP LEFT", -1, -1);
80 doit("UP RIGHT", 1, -1);
81 doit("DOWN LEFT", -1, 1);
82 doit("DOWN RIGHT", 1, 1);
86 int main(void)
88 LayersBase = OpenLibrary("layers.library", 0);
89 if (LayersBase)
91 makecrs();
92 action();
94 CloseLibrary(LayersBase);
97 return 0;