1 /****************************************************************
2 * A little hack inspired by "EyeCon" on the Suns.
4 * I use something like this on my workbench:
5 * SetRGB4(vp, 0, 6, 6, 4);
6 * SetRGB4(vp, 1, 4, 3, 0);
7 * SetRGB4(vp, 2, 15, 12, 5);
8 * SetRGB4(vp, 3, 10, 8, 3);
9 * Looks good in interlace and gives Amy a more 'pro' look.
11 * (C) 1989 Jonas Petersson & Sirius Soft
13 * Comments to zaphod@malmax.maxcimator.se or
14 * zaphod@magrathea.sirius.se
18 /* Figure out the #includes for yourself - or use the trick... */
20 #include <aros/oldprograms.h>
21 #include <exec/memory.h>
22 #include <proto/alib.h>
26 #define Lx 29 /* The eyes offset from upper left corner */
31 #if (AROS_BIG_ENDIAN == 0)
32 # define CONV_WORD(x) (((x) >> 8) | ((x) << 8))
34 # define CONV_WORD(x) x
37 struct IntuitionBase
*IntuitionBase
;
38 struct GfxBase
*GfxBase
;
40 struct MsgPort
*timerport
; /* for timer communications */
41 struct IOStdReq
*timermsg
; /* for timer */
43 USHORT
*Manmap_chip
[2]= {NULL
,NULL
}; /* Chip copy */
45 USHORT Manmap
[2][528] = { /* Background head image */
46 /* Probably in fastmem */
47 { 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF00,
48 0x8000,0x0000,0x0000,0x0000,0x0000,0x0100,
49 0x9555,0x5555,0x7555,0x5555,0x5555,0x5700,
50 0xAAAA,0xAAAF,0xFAAF,0xAAAA,0xAAAA,0xAB00,
51 0x9555,0x557F,0xFD7F,0xD555,0x5555,0x5700,
52 0xAAAA,0xBFFF,0xFDFF,0xFEAA,0xAAAA,0xAB00,
53 0x9555,0xFFFF,0xFE7F,0xFFD5,0x5555,0x5700,
54 0xAAFF,0xFFFF,0xFFBF,0xFFFA,0xAAAA,0xAB00,
55 0x97FF,0xFFFF,0xFFCF,0xFFF5,0x5555,0x5700,
56 0xBFFF,0xFFFF,0xFFF7,0xFFFA,0xAAAA,0xAB00,
57 0xBFFF,0xFFFF,0xFFF9,0xFFF5,0x5555,0x5700,
58 0xBFFF,0xFFFF,0xFFFE,0xFFFA,0xAAAA,0xAB00,
59 0x9FFF,0xFFFF,0xFFFF,0x3FFD,0x5555,0x5700,
60 0xAFFF,0xFFFF,0xFFFF,0xDFFA,0xAAAA,0xAB00,
61 0x97FF,0xFFFF,0xFFFF,0xFFFD,0x5555,0x5700,
62 0xAAFF,0xFFFF,0xFFFF,0xFFFE,0xAAAA,0xAB00,
63 0x957F,0xFFFF,0xFFFF,0xFFFD,0x5555,0x5700,
64 0xAABF,0xFFFF,0xFFFF,0xFFFE,0xAAAA,0xAB00,
65 0x955F,0xFFFF,0xFFFF,0x5FFF,0x5555,0x5700,
66 0xAAAF,0xFFFF,0xFFAA,0xAAFE,0xAAAA,0xAB00,
67 0x9555,0xFFFF,0x807F,0xFD55,0x5555,0x5700,
68 0xAAAA,0xFFF0,0x0FFF,0xFAAA,0xAAAA,0xAB00,
69 0x9555,0x500F,0xFFFF,0xFF55,0x5555,0x5700,
70 0xAAAA,0xA1FF,0xFFFF,0xFDAA,0xAAAA,0xAB00,
71 0x9555,0x5FFF,0xFFFF,0xFAD5,0x5555,0x5700,
72 0xAAAA,0xAFFF,0xFFFF,0xFD6A,0xAAAA,0xAB00,
73 0x9555,0x5FFF,0xFFFF,0xFEB5,0x5555,0x5700,
74 0xAAAA,0xAFFF,0xFFFF,0xFF5E,0xAAAA,0xAB00,
75 0x9555,0x5FFF,0xFFFF,0xFFAD,0x5555,0x5700,
76 0xAAAA,0xAFFF,0xFFFF,0xFFD6,0xAAAA,0xAB00,
77 0x9555,0x5FFF,0xFFFF,0xFFAB,0x5555,0x5700,
78 0xAAAA,0xAFFF,0xFFFF,0xFFD5,0xAAAA,0xAB00,
79 0x9555,0x5FFF,0xFFFF,0xFFEB,0x5555,0x5700,
80 0xAAAA,0xAFFF,0xFFFF,0xFFF5,0xAAAA,0xAB00,
81 0x9555,0x5FFF,0xFFFF,0xFFEA,0xD555,0x5700,
82 0xAAAA,0xAFFF,0xFFFF,0xFFF5,0x6AAA,0xAB00,
83 0x9555,0x5FFF,0xFFFF,0xFFFA,0xB555,0x5700,
84 0xAAAA,0xAFFF,0xFFFF,0xFFFD,0x6EAA,0xAB00,
85 0x9555,0x5FFF,0xFFFF,0xFFEA,0xBB55,0x5700,
86 0xAAAA,0xAFFF,0xFFFF,0xFD55,0x56AA,0xAB00,
87 0x9555,0x5FFF,0xFFEA,0xBAAA,0xAB55,0x5700,
88 0xAAAA,0xAFFF,0xFF55,0x7F55,0x56AA,0xAB00,
89 0x9555,0x5FFE,0xAABA,0xFFFA,0xAD75,0x5700,
90 0xAAAA,0xAF7F,0x555F,0xFFFD,0x5ABA,0xAB00,
91 0x9555,0x5AFF,0xAEBF,0xC3FE,0xAD7D,0x5700,
92 0xAAAA,0xADD5,0xFFFE,0x00FD,0x5ABC,0xAB00,
93 0x9555,0x56BF,0xFFFC,0x007E,0xB57B,0x5700,
94 0xAAAA,0xABF0,0x1FF4,0x007F,0x5ABC,0xAB00,
95 0x9555,0x55E0,0x0FFC,0x007E,0xB57B,0x5700,
96 0xAAAA,0xAAC0,0x07F4,0x007F,0x5AB4,0xAB00,
97 0x9555,0x55C0,0x07FA,0x00FE,0xAF6B,0x5700,
98 0xAAAA,0xAAC0,0x07F7,0xC7FF,0x55B6,0xAB00,
99 0x9555,0x5560,0x0FEB,0xFF55,0x5551,0x5700,
100 0xAAAA,0xAAF0,0x1FF7,0xEAAA,0xAAAA,0xAB00,
101 0x9555,0x5578,0x3FAA,0x0005,0x5553,0x5700,
102 0xAAAA,0xAABF,0xED50,0x0002,0xAAA8,0xAB00,
103 0x9555,0x557D,0x5A00,0x0001,0x5555,0x5700,
104 0xAAAA,0xAAAA,0xA000,0x0000,0xAAAA,0xAB00,
105 0x9555,0x5550,0x0000,0x0001,0x5555,0x5700,
106 0xAAAA,0xAA00,0x0000,0x0000,0xAAAA,0xAB00,
107 0x9555,0x5400,0x0000,0x0000,0x5555,0x5700,
108 0xAAAA,0xAA00,0x0000,0x0000,0x2AAA,0xAB00,
109 0x9555,0x5500,0x0000,0x0000,0x5555,0x5700,
110 0xAAAA,0xAA00,0x1E00,0x0000,0x2AAA,0xAB00,
111 0x9555,0x5500,0x3F00,0x0020,0x1555,0x5700,
112 0xAAAA,0xAA80,0xFF01,0x5550,0x0AAA,0xAB00,
113 0x9555,0x5502,0xFF2A,0xAAA0,0x0555,0x5700,
114 0xAAAA,0xAA87,0xFD55,0x5000,0x0FFF,0xFB00,
115 0x9555,0x5545,0x7AA8,0x0000,0x1FFF,0xF700,
116 0xAAAA,0xAA82,0xD540,0x0000,0x1FFF,0xFB00,
117 0x9555,0x5541,0x0000,0x0000,0x3FFF,0xF700,
118 0xAAAA,0xAA80,0x0000,0x0002,0xBFFF,0xFB00,
119 0x9555,0x5540,0x0000,0x0555,0x7FFF,0xF700,
120 0xAAAA,0xAA80,0x0002,0xAAAA,0xBFFF,0xEB00,
121 0x9555,0x5540,0x0555,0x5555,0x7FFF,0xF700,
122 0xAAAA,0xAA82,0xAAAA,0xAAAA,0xBFFF,0xEB00,
123 0x9555,0x5555,0x5555,0x5555,0x5FFF,0xD700,
124 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xBFFF,0xAB00,
125 0x9555,0x5555,0x5555,0x5555,0x5FFF,0xD700,
126 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xBFFF,0xAB00,
127 0x9555,0x5555,0x5555,0x5555,0x5FEA,0xD700,
128 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xD555,0x2B00,
129 0x9555,0x5555,0x5555,0x56AA,0xAA55,0x5700,
130 0xAAAA,0xAAAA,0xAAAB,0x5555,0x56AA,0xAB00,
131 0x9555,0x5555,0x5555,0x5555,0x5555,0x5700,
132 0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAAAA,0xAB00,
133 0xBFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF00,
134 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFF00,
136 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
137 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
138 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
139 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
140 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
141 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
142 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
143 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
144 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
145 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
146 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
147 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
148 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
149 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
150 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
151 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
152 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
153 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
154 0x0000,0x0000,0x0000,0xA000,0x0000,0x0000,
155 0x0000,0x0000,0x0055,0x5501,0x0000,0x0000,
156 0x0000,0x0000,0x7FFF,0xFAAA,0x8000,0x0000,
157 0x0000,0x000F,0xFFFF,0xF555,0x0000,0x0000,
158 0x0000,0x0FFF,0xFFFF,0xFAAA,0x8000,0x0000,
159 0x0000,0x1FFF,0xFFFF,0xFF55,0x4000,0x0000,
160 0x0000,0x0FFF,0xFFFF,0xFFAA,0xA000,0x0000,
161 0x0000,0x07FF,0xFFFF,0xFFD5,0x5000,0x0000,
162 0x0000,0x0FFF,0xFFFF,0xFFEA,0xA000,0x0000,
163 0x0000,0x07FF,0xFFFF,0xFFF5,0x5000,0x0000,
164 0x0000,0x0FFF,0xFFFF,0xFFFA,0xA800,0x0000,
165 0x0000,0x07FF,0xFFFF,0xFFFD,0x5400,0x0000,
166 0x0000,0x0FFF,0xFFFF,0xFFFE,0xAA00,0x0000,
167 0x0000,0x07FF,0xFFFF,0xFFFF,0x5500,0x0000,
168 0x0000,0x0FFF,0xFFFF,0xFFFE,0xAA00,0x0000,
169 0x0000,0x07FF,0xFFFF,0xFFFF,0x5500,0x0000,
170 0x0000,0x0FFF,0xFFFF,0xFFFF,0xAA80,0x0000,
171 0x0000,0x07FF,0xFFFF,0xFFFF,0xD540,0x0000,
172 0x0000,0x0FFF,0xFFFF,0xFFFF,0xEAA0,0x0000,
173 0x0000,0x07FF,0xFFFF,0xFFFF,0xD540,0x0000,
174 0x0000,0x0FFF,0xFFFF,0xFFFF,0xEEA0,0x0000,
175 0x0000,0x07FF,0xFFFF,0xFFFF,0xFD50,0x0000,
176 0x0000,0x0FFF,0xFFFF,0xE7FF,0xFEA8,0x0000,
177 0x0000,0x07FF,0xFFFF,0xC0FF,0xFD54,0x0000,
178 0x0000,0x0FE3,0xFFE7,0x0FFF,0xFAAA,0x0000,
179 0x0000,0x07C0,0xFFE0,0x3FFF,0xF554,0x0000,
180 0x0000,0x0F80,0x71F8,0x03FF,0xFAB8,0x0000,
181 0x0000,0x067E,0x0FFE,0x00FF,0xF55E,0x0000,
182 0x0000,0x03FF,0xBFFC,0x007F,0xEABE,0x0000,
183 0x0000,0x01F0,0x1FFC,0x007F,0xF55E,0x0000,
184 0x0000,0x00E0,0x0FFC,0x007F,0xEABE,0x0000,
185 0x0000,0x0040,0x07FC,0x007F,0xF55E,0x0000,
186 0x0000,0x00C0,0x07FE,0x00FF,0xFABE,0x0000,
187 0x0000,0x0040,0x07FF,0xC7FF,0xFF5C,0x0000,
188 0x0000,0x0020,0x0FFF,0xFEAA,0xAAAC,0x0000,
189 0x0000,0x0070,0x1FFF,0xD555,0x5556,0x0000,
190 0x0000,0x0038,0x3FFF,0xFFFA,0xAAAE,0x0000,
191 0x0000,0x001F,0xD7FF,0xFFFD,0x5557,0x0000,
192 0x0000,0x003A,0xAFFF,0xFFFE,0xAAAA,0x0000,
193 0x0000,0x0055,0x5FFF,0xFFFF,0x5555,0x0000,
194 0x0000,0x00AF,0xFFFF,0xFFFE,0xAAAA,0x8000,
195 0x0000,0x01FF,0xFFFF,0xFFFF,0x5555,0x4000,
196 0x0000,0x03FF,0xFFE0,0x7FFF,0xAAAA,0x8000,
197 0x0000,0x01FF,0xFF00,0x01FF,0xD555,0x4000,
198 0x0000,0x00FF,0xF800,0x000F,0xAAAA,0xA000,
199 0x0000,0x01FF,0xE000,0x000F,0xD555,0x4000,
200 0x0000,0x00FF,0xC000,0x007F,0xEAAA,0xA000,
201 0x0000,0x007F,0x0003,0xFFFF,0xF555,0x5000,
202 0x0000,0x00FC,0x003F,0xFFFF,0xFAAA,0xA800,
203 0x0000,0x0078,0x03FF,0xFFFF,0xF000,0x0000,
204 0x0000,0x0038,0x0FFF,0xFFFF,0xE000,0x0000,
205 0x0000,0x007C,0x3FFF,0xFFFF,0xE000,0x0000,
206 0x0000,0x003E,0xFFFF,0xFFFF,0xC000,0x0000,
207 0x0000,0x007F,0xFFFF,0xFFFD,0x4000,0x0000,
208 0x0000,0x003F,0xFFFF,0xFAAA,0x8000,0x0000,
209 0x0000,0x007F,0xFFFD,0x5555,0x4000,0x0000,
210 0x0000,0x003F,0xFAAA,0xAAAA,0x8000,0x0000,
211 0x0000,0x007D,0x5555,0x5555,0x4000,0x0000,
212 0x0000,0x00AA,0xAAAA,0xAAAA,0xA000,0x0000,
213 0x0000,0x0055,0x5555,0x5555,0x4000,0x0000,
214 0x0000,0x002A,0xAAAA,0xAAAA,0xA000,0x0000,
215 0x0000,0x0015,0x5555,0x5555,0x4000,0x0000,
216 0x0000,0x000A,0xAAAA,0xAAAA,0xA03F,0x8000,
217 0x0000,0x0005,0x5555,0x5555,0x7FFF,0x8000,
218 0x0000,0x0002,0xAAAA,0xABFF,0xFF00,0x0000,
219 0x0000,0x0001,0x5555,0xFFFF,0xFC00,0x0000,
220 0x0000,0x0000,0xAAAA,0x0000,0x0000,0x0000,
221 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
222 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
223 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
228 USHORT (*Eyemap_chip
); /* Eye */
229 USHORT Eyemap
[4] = {
236 static struct Gadget gadget
= /* Used to move and quit */
239 GADGHNONE
|GRELWIDTH
|GRELHEIGHT
,
240 GADGIMMEDIATE
|RELVERIFY
,
250 static struct NewWindow IconNW
= /* The window */
255 RMBTRAP
|BORDERLESS
|SMART_REFRESH
|NOCAREREFRESH
,
267 void CloseStuff(int);
271 extern USHORT
*Eyemap_chip
;
272 extern USHORT
*Manmap_chip
[];
274 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 0L)))
276 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 0L)))
278 if (!(win
= OpenWindow (&IconNW
)))
280 if ((Eyemap_chip
= AllocMem((LONG
)sizeof(Eyemap
),MEMF_CHIP
))== 0)
281 CloseStuff (1); /* allocate chip memory for images */
282 for (i
=0 ; i
< 4 ;i
++) {
283 /* Do endian conversion */
284 Eyemap_chip
[i
] = CONV_WORD(Eyemap
[i
]);
286 if ((Manmap_chip
[0] = AllocMem((LONG
)sizeof(Manmap
[0]),MEMF_CHIP
)) == NULL
)
288 if ((Manmap_chip
[1] = AllocMem((LONG
)sizeof(Manmap
[1]),MEMF_CHIP
)) == NULL
)
291 for (i
=0 ; i
< 528 ;i
++) {
293 /* Do endian conversion */
294 Manmap_chip
[0][i
] = CONV_WORD(Manmap
[0][i
]);
295 Manmap_chip
[1][i
] = CONV_WORD(Manmap
[1][i
]);
297 SetAPen(win
->RPort
, 1L);
298 SetDrMd(win
->RPort
, JAM1
);
299 BltTemplate((PLANEPTR
)Manmap_chip
[0], 0L, 12L, win
->RPort
, 0L, 0L, 88L, 88L);
301 SetAPen(win
->RPort
, 2L);
302 SetWriteMask(win
->RPort
, 2L); /* Braindead COMPLEMENT */
303 BltTemplate((PLANEPTR
)Manmap_chip
[1], 0L, 12L, win
->RPort
, 0L, 0L, 88L, 88L);
304 SetWriteMask(win
->RPort
, 255L); /* Braindead COMPLEMENT */
305 if (!(timerport
= CreatePort(NULL
, 0L))
306 || !(timermsg
= CreateStdIO(timerport
))
307 || OpenDevice(TIMERNAME
,UNIT_VBLANK
, (struct IORequest
*)timermsg
, 0L))
311 void CloseStuff (exitcode
)
315 CloseDevice((struct IORequest
*)timermsg
);
316 DeleteStdIO(timermsg
);
318 if (timerport
) DeletePort(timerport
);
319 if (win
) CloseWindow(win
);
320 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
321 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
322 if (Eyemap_chip
) FreeMem(Eyemap_chip
, (LONG
)sizeof(Eyemap
));
323 if (Manmap_chip
[0]) FreeMem(Manmap_chip
[0], (LONG
)sizeof(Manmap
[0]));
324 if (Manmap_chip
[1]) FreeMem(Manmap_chip
[1], (LONG
)sizeof(Manmap
[1]));
328 /* Hmm, this seems to work - a bit strange, but it works... */
329 #define ABS(x) (x<0 ? -x : x)
330 #define index(x,y) (((y<0)<<2) + ((x<0)<<1) + (ABS(x)>ABS(y)))
332 /****************************************************************
333 * Draw the eye at OffX, OffY but with an extra offset
334 * given by idx in a direct[]-table.
335 * col is used to erase/draw.
338 void DrawEye(idx
, OffX
, OffY
, col
)
339 int idx
, OffX
, OffY
, col
;
341 static int direct
[2][8] = {
342 { 1, 2,-1,-2, 1, 2,-1,-2},
343 { 2, 1, 2, 1,-2,-1,-2,-1}};
345 SetAPen(win
->RPort
, (LONG
)col
);
346 BltTemplate((PLANEPTR
)Eyemap_chip
, 0L, 2L, win
->RPort
,
347 (LONG
)(OffX
+ direct
[0][idx
&7]),
348 (LONG
)(OffY
+ direct
[1][idx
&7]), 4L, 4L);
351 /****************************************************************
352 * Get mouse position relative to windows upper left corner.
353 * (A lot easier than I thought...) A very nice programmer
354 * probably would get the mouse coords in another way, but
355 * I'm not very paranoid...
361 *x
= win
->WScreen
->MouseX
- win
->LeftEdge
;
362 *y
= win
->WScreen
->MouseY
- win
->TopEdge
;
365 /****************************************************************
366 * The main loop. Ok, I COULD do the timer and intuimsgs
367 * in a nicer way, but it wouldn't make much of a difference
371 int main (int argc
, char **argv
)
373 ULONG msgclass
; /* Message class from Intuition message */
374 struct IntuiMessage
*msg
; /* The msg we got */
375 int Mx
, My
, /* Mouse's current relative offset */
376 LastL
= 0, LastR
= 0, /* Last index for left&right Eye */
377 NewL
, NewR
; /* New index -- "" -- */
378 ULONG PrevSecs
= 0, PrevMics
= 0; /* Time of last click */
382 DrawEye(LastL
, Lx
, Ly
, 1);
383 DrawEye(LastR
, Rx
, Ry
, 1);
386 timermsg
->io_Command
= TR_ADDREQUEST
; /* add a new timer request */
387 timermsg
->io_Actual
= 0; /* seconds */
388 timermsg
->io_Length
= 100000; /* microseconds */
389 DoIO((struct IORequest
*)timermsg
); /* Wait for a while... */
390 while((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
))) {
392 msgclass
= msg
->Class
;
393 ReplyMsg ((struct Message
*)msg
);
396 if (DoubleClick(PrevSecs
, PrevMics
, msg
->Seconds
, msg
->Micros
))
399 PrevSecs
= msg
->Seconds
;
400 PrevMics
= msg
->Micros
;
405 GetRelMp(&Mx
, &My
); /* Action ! */
406 if (LastL
!= (NewL
= index(Mx
- Lx
, My
- Ly
))) {
407 DrawEye(LastL
, Lx
, Ly
, 0);
408 DrawEye(LastL
=NewL
, Lx
, Ly
, 1);
410 if (LastR
!= (NewR
= index(Mx
- Rx
, My
- Ry
))) {
411 DrawEye(LastR
, Rx
, Ry
, 0);
412 DrawEye(LastR
=NewR
, Rx
, Ry
, 1);