1 | /*␊ |
2 | *␊ |
3 | * Copyright (c) 2012-2013 Cadet-Petit Armel␊ |
4 | * All rights reserved.␊ |
5 | *␊ |
6 | * Redistribution and use in source and binary forms, with or without␊ |
7 | * modification, are permitted provided that the following conditions are␊ |
8 | * met:␊ |
9 | *␊ |
10 | * * Redistributions of source code must retain the above copyright␊ |
11 | * notice, this list of conditions and the following disclaimer.␊ |
12 | *␊ |
13 | * * Redistributions in binary form must reproduce the above copyright␊ |
14 | * notice, this list of conditions and the following disclaimer in the␊ |
15 | * documentation and/or other materials provided with the␊ |
16 | * distribution.␊ |
17 | *␊ |
18 | * * Neither the name of Cadet-Petit Armel nor the names of the␊ |
19 | * contributors may be used to endorse or promote products derived␊ |
20 | * from this software without specific prior written permission.␊ |
21 | *␊ |
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS␊ |
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT␊ |
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR␊ |
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT␊ |
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,␊ |
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT␊ |
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,␊ |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY␊ |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT␊ |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE␊ |
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.␊ |
33 | */␊ |
34 | ␊ |
35 | /* PLEASE SEE THE REAME */␊ |
36 | ␊ |
37 | #include "libegint.h"␊ |
38 | #include <xml.h>␊ |
39 | #include <IOGraphics.h>␊ |
40 | #include <pexpert/i386/modules.h>␊ |
41 | #include <sys/time.h>␊ |
42 | #include <ctype.h>␊ |
43 | #include <string.h>␊ |
44 | #include "pngfile.h"␊ |
45 | ␊ |
46 | //#include "art.h"␊ |
47 | ␊ |
48 | ␊ |
49 | #ifndef DEBUG_TRYME␊ |
50 | #define DEBUG_TRYME 0␊ |
51 | #endif␊ |
52 | ␊ |
53 | #if DEBUG_TRYME␊ |
54 | #define DBG(x...)␉␉printf(x)␊ |
55 | #else␊ |
56 | #define DBG(x...)␊ |
57 | #endif␊ |
58 | ␊ |
59 | #ifndef MIN␊ |
60 | #define MIN(x, y) ((x) < (y) ? (x) : (y))␊ |
61 | #endif␊ |
62 | ␊ |
63 | #ifndef MAX␊ |
64 | #define MAX(x, y) ((x) > (y) ? (x) : (y))␊ |
65 | #endif␊ |
66 | ␊ |
67 | #define VIDEO(x) (((boot_args*)getBootArgs())->Video.v_ ## x)␊ |
68 | ␊ |
69 | #define vram VIDEO(baseAddr)␊ |
70 | ␊ |
71 | #define arc4random_unirange(lo,hi) arc4random_uniform(hi - lo + 1) + lo␊ |
72 | #define arc4random_range(lo,hi) (arc4random() % (hi - lo + 1)) + lo␊ |
73 | ␊ |
74 | EG_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0 };␊ |
75 | EG_PIXEL MenuBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0 };␊ |
76 | EG_PIXEL BlackColor = { 0xff, 0xff, 0xff, 0 };␊ |
77 | ␊ |
78 | extern long GetDirEntry(const char *dirSpec, long long *dirIndex, const char **name,␊ |
79 | long *flags, long *time);␊ |
80 | extern long GetFileInfo(const char *dirSpec, const char *name,␊ |
81 | long *flags, long *time);␊ |
82 | ␊ |
83 | extern int getc(void);␊ |
84 | ␊ |
85 | #define DEFAULT_SCREEN_WIDTH 1024␊ |
86 | #define DEFAULT_SCREEN_HEIGHT 768␊ |
87 | ␊ |
88 | #define VGA_TEXT_MODE␉␉ 0␊ |
89 | #define GRAPHICS_MODE 1␊ |
90 | #define FB_TEXT_MODE 2␊ |
91 | ␊ |
92 | unsigned long screen_params[4] = {DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0};␉// here we store the used screen resolution␊ |
93 | config_file_t themeConfig;␉␉␉␉ // theme.plist␊ |
94 | ␊ |
95 | bool LoadEmbedGui(void);␊ |
96 | ␊ |
97 | #define CHARACTERS_COUNT␉223␊ |
98 | ␊ |
99 | /*␊ |
100 | * Font structure.␊ |
101 | */␊ |
102 | typedef struct {␊ |
103 | ␉UINTN␉Height;␉␉␉// Font Height␊ |
104 | ␉UINTN␉Width;␉␉␉// Font Width for monospace font only␊ |
105 | ␉EG_IMAGE␉*chars[CHARACTERS_COUNT];␊ |
106 | ␉UINTN count; // Number of chars in font␊ |
107 | } EG_FONT;␊ |
108 | ␊ |
109 | typedef union {␊ |
110 | struct {␊ |
111 | UINT8 b;␊ |
112 | UINT8 g;␊ |
113 | UINT8 r;␊ |
114 | UINT8 a;␊ |
115 | } ch;␊ |
116 | UINT8 channel[4];␊ |
117 | UINT32 value;␊ |
118 | } EG_LEGACY_PIXEL;␊ |
119 | ␊ |
120 | typedef struct {␊ |
121 | UINT16␉height;␊ |
122 | UINT16␉width;␊ |
123 | EG_LEGACY_PIXEL*␉pixels;␊ |
124 | } EG_LEGACY_IMAGE;␊ |
125 | ␊ |
126 | typedef struct {␊ |
127 | UINT32 x;␊ |
128 | UINT32 y;␊ |
129 | } EG_POSITION;␊ |
130 | ␊ |
131 | #define PIXEL(p,x,y) ((p)->PixelData[(x) + (y) * (p)->Width])␊ |
132 | #define LEGACY_PIXEL(p,x,y,w) (((EG_LEGACY_PIXEL*)(p))[(x) + (y) * (w)])␊ |
133 | ␊ |
134 | // File Permissions and Types␊ |
135 | enum {␊ |
136 | kPermOtherExecute = 1 << 0,␊ |
137 | kPermOtherWrite = 1 << 1,␊ |
138 | kPermOtherRead = 1 << 2,␊ |
139 | kPermGroupExecute = 1 << 3,␊ |
140 | kPermGroupWrite = 1 << 4,␊ |
141 | kPermGroupRead = 1 << 5,␊ |
142 | kPermOwnerExecute = 1 << 6,␊ |
143 | kPermOwnerWrite = 1 << 7,␊ |
144 | kPermOwnerRead = 1 << 8,␊ |
145 | kPermMask = 0x1FF,␊ |
146 | kOwnerNotRoot = 1 << 9,␊ |
147 | kFileTypeUnknown = 0x0 << 16,␊ |
148 | kFileTypeFlat = 0x1 << 16,␊ |
149 | kFileTypeDirectory = 0x2 << 16,␊ |
150 | kFileTypeLink = 0x3 << 16,␊ |
151 | kFileTypeMask = 0x3 << 16␊ |
152 | };␊ |
153 | ␊ |
154 | static long long␊ |
155 | timeval_diff(struct timeval *difference,␊ |
156 | struct timeval *end_time,␊ |
157 | struct timeval *start_time␊ |
158 | )␊ |
159 | {␊ |
160 | struct timeval temp_diff;␊ |
161 | ␊ |
162 | if(difference==NULL)␊ |
163 | {␊ |
164 | difference=&temp_diff;␊ |
165 | }␊ |
166 | ␊ |
167 | difference->tv_sec =end_time->tv_sec -start_time->tv_sec ;␊ |
168 | difference->tv_usec=end_time->tv_usec-start_time->tv_usec;␊ |
169 | ␊ |
170 | /* Using while instead of if below makes the code slightly more robust. */␊ |
171 | ␊ |
172 | while(difference->tv_usec<0)␊ |
173 | {␊ |
174 | difference->tv_usec+=1000000;␊ |
175 | difference->tv_sec -=1;␊ |
176 | }␊ |
177 | ␊ |
178 | return 1000000LL*difference->tv_sec+␊ |
179 | difference->tv_usec;␊ |
180 | ␊ |
181 | } ␊ |
182 | ␊ |
183 | extern const char *getToken(const char *line, const char **begin, int *len);␊ |
184 | ␊ |
185 | bool getValueForConfigTableKey(config_file_t *config, const char *key, const char **val, int *size)␊ |
186 | {␊ |
187 | ␊ |
188 | ␉if (config->dictionary != 0 ) {␊ |
189 | ␉␉// Look up key in XML dictionary␊ |
190 | ␉␉TagPtr value;␊ |
191 | ␉␉value = XMLGetProperty(config->dictionary, key);␊ |
192 | ␉␉if (value != 0) {␊ |
193 | ␉␉␉if (value->type != kTagTypeString) {␊ |
194 | ␉␉␉␉printf("Non-string tag '%s' found in config file\n",␊ |
195 | ␉␉␉␉␉ key);␊ |
196 | ␉␉␉␉abort();␊ |
197 | ␉␉␉␉return false;␊ |
198 | ␉␉␉}␊ |
199 | ␉␉␉*val = value->string;␊ |
200 | ␉␉␉*size = strlen(value->string);␊ |
201 | ␉␉␉return true;␊ |
202 | ␉␉}␊ |
203 | ␉} else {␊ |
204 | ␉␉␊ |
205 | ␉␉// Legacy plist-style table␊ |
206 | ␉␉␊ |
207 | ␉}␊ |
208 | ␉␊ |
209 | ␉return false;␊ |
210 | }␊ |
211 | ␊ |
212 | extern bool getValueForBootKey(const char *line, const char *match, const char **matchval, int *len);␊ |
213 | extern bool getValueForKey( const char *key, const char **val, int *size, config_file_t *config );␊ |
214 | extern bool getIntForKey(const char *key, int *val, config_file_t *configBuff);␊ |
215 | extern int loadConfigFile(const char *configFile, config_file_t *configBuff);␊ |
216 | ␊ |
217 | static bool getDimensionForKey( const char *key, unsigned int *value, config_file_t *config, unsigned int dimension_max, unsigned int object_size )␊ |
218 | {␊ |
219 | ␉const char *val;␊ |
220 | ␉␊ |
221 | int size = 0;␊ |
222 | ␉int sum = 0;␊ |
223 | ␊ |
224 | ␉bool negative = false;␊ |
225 | ␉bool percentage = false; ␊ |
226 | ␉␊ |
227 | if (getValueForKey(key, &val, &size, config))␊ |
228 | ␉{␊ |
229 | ␉␉if ( size )␊ |
230 | ␉␉{␊ |
231 | ␉␉␉if (*val == '-')␊ |
232 | ␉␉␉{␊ |
233 | ␉␉␉␉negative = true;␊ |
234 | ␉␉␉␉val++;␊ |
235 | ␉␉␉␉size--;␊ |
236 | ␉␉␉}␊ |
237 | ␉␉␉␊ |
238 | ␉␉␉if (val[size-1] == '%')␊ |
239 | ␉␉␉{␊ |
240 | ␉␉␉␉percentage = true;␊ |
241 | ␉␉␉␉size--;␊ |
242 | ␉␉␉}␊ |
243 | ␉␉␉␊ |
244 | ␉␉␉// convert string to integer␊ |
245 | ␉␉␉for (sum = 0; size > 0; size--)␊ |
246 | ␉␉␉{␊ |
247 | ␉␉␉␉if (*val < '0' || *val > '9')␊ |
248 | ␉␉␉␉␉return false;␊ |
249 | ␉␉␉␉␊ |
250 | ␉␉␉␉sum = (sum * 10) + (*val++ - '0');␊ |
251 | ␉␉␉}␊ |
252 | ␉␉␉␊ |
253 | ␉␉␉if (percentage)␊ |
254 | ␉␉␉␉sum = ( dimension_max * sum ) / 100;␊ |
255 | ␉␉␉␊ |
256 | ␉␉␉// calculate offset from opposite origin␊ |
257 | ␉␉␉if (negative)␊ |
258 | ␉␉␉␉sum = ( ( dimension_max - object_size ) - sum );␊ |
259 | ␉␉␉␊ |
260 | ␉␉} else {␊ |
261 | ␉␉␉␊ |
262 | ␉␉␉// null value calculate center␊ |
263 | ␉␉␉sum = ( dimension_max - object_size ) / 2;␊ |
264 | ␉␉␉␊ |
265 | ␉␉}␊ |
266 | ␉␉␊ |
267 | ␉␉*value = (uint16_t) sum;␊ |
268 | ␉␉return true;␊ |
269 | ␉}␊ |
270 | ␉␊ |
271 | ␉// key not found␊ |
272 | return false;␊ |
273 | }␊ |
274 | ␊ |
275 | static bool getColorForKey( const char *key, unsigned int *value, config_file_t *config )␊ |
276 | {␊ |
277 | const char *val;␊ |
278 | int size;␊ |
279 | ␊ |
280 | if (getValueForKey(key, &val, &size, config))␊ |
281 | ␉{␊ |
282 | ␉␉if (*val == '#')␊ |
283 | ␉␉{␊ |
284 | val++;␊ |
285 | ␉␉␉*value = strtol(val, NULL, 16);␊ |
286 | ␉␉␉return true;␊ |
287 | }␊ |
288 | }␊ |
289 | return false;␊ |
290 | }␊ |
291 | ␊ |
292 | BOOLEAN LoadGui(VOID)␊ |
293 | {␊ |
294 | ␉␊ |
295 | ␉int␉␉␉␉␉val;␊ |
296 | ␉long long␉ index = 0;␉␊ |
297 | ␉uint32_t color = 0 ;␉␉␉// color value formatted RRGGBB␊ |
298 | ␉unsigned int pixel;␊ |
299 | EG_IMAGE_VIEW * deviceView = NULL;␊ |
300 | //EG_IMAGE_VIEW *PoofImageView[5] ;␊ |
301 | EG_IMAGE_VIEW * iconeRef = NULL;␊ |
302 | ␉EG_VIEW * screen = NULL;␊ |
303 | ␊ |
304 | ␉UINT8␉ImagesType = 0;␊ |
305 | ␉␊ |
306 | ␉long ret, length, flags, time;␊ |
307 | ␉CONST␉CHAR8 * name;␊ |
308 | ␊ |
309 | ␉CHAR8 dirspec[512];␊ |
310 | ␉BOOLEAN THEMEDIR_FOUND = FALSE;␊ |
311 | ␉␊ |
312 | ␉ret = GetFileInfo("rd(0,0)/Extra/Themes/", "Default", &flags, &time);␊ |
313 | ␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)) ␊ |
314 | ␉{␊ |
315 | ␉␉snprintf(dirspec, sizeof(dirspec),"rd(0,0)/Extra/Themes/Default/");␊ |
316 | ␉␉THEMEDIR_FOUND = TRUE;␊ |
317 | ␉␉␊ |
318 | ␉}␊ |
319 | ␉else␊ |
320 | ␉{␊ |
321 | ␉␉␊ |
322 | ␉␉ret = GetFileInfo("/Extra/Themes/", "Default", &flags, &time);␊ |
323 | ␉␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))␊ |
324 | ␉␉{␊ |
325 | ␉␉␉snprintf(dirspec, sizeof(dirspec), "/Extra/Themes/Default/");␊ |
326 | ␉␉␉THEMEDIR_FOUND = TRUE;␊ |
327 | ␉␉␉␊ |
328 | ␉␉}␊ |
329 | ␉␉else␊ |
330 | ␉␉{␊ |
331 | ␉␉␉ret = GetFileInfo("bt(0,0)/Extra/Themes/", "Default", &flags, &time);␊ |
332 | ␉␉␉if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory))␊ |
333 | ␉␉␉{␊ |
334 | ␉␉␉␉snprintf(dirspec, sizeof(dirspec),"bt(0,0)/Extra/Themes/Default/");␊ |
335 | ␉␉␉␉THEMEDIR_FOUND = TRUE;␊ |
336 | ␉␉␉␉␊ |
337 | ␉␉␉} ␊ |
338 | ␉␉}␊ |
339 | ␉}␊ |
340 | ␉␊ |
341 | ␉if (THEMEDIR_FOUND == FALSE)␊ |
342 | ␉{␊ |
343 | ␉␉return FALSE;␊ |
344 | ␉}␊ |
345 | ␉␊ |
346 | ␉{␊ |
347 | ␉␉// parse themeconfig file␊ |
348 | ␉␉CHAR8 configdirspec[1024];␊ |
349 | ␉␉snprintf(configdirspec, sizeof(configdirspec), "%stheme.plist",dirspec);␊ |
350 | ␉␉␊ |
351 | ␉␉if (loadConfigFile (configdirspec, &themeConfig) != 0)␊ |
352 | ␉␉{␊ |
353 | ␉␉␉DBG("Unable to load embed theme plist datas.\n");␊ |
354 | ␉␉␉␊ |
355 | ␉␉␉return FALSE;␊ |
356 | ␉␉}␉␉␉␉␊ |
357 | ␉␉␊ |
358 | ␉␉DBG("themeconfig file parsed\n");␊ |
359 | ␉␉␊ |
360 | ␉␉// parse display size parameters (if any)␊ |
361 | ␉␉if (getIntForKey("screen_width", &val, &themeConfig) && val > 0) {␊ |
362 | ␉␉␉screen_params[0] = val;␊ |
363 | ␉␉}␊ |
364 | ␉␉if (getIntForKey("screen_height", &val, &themeConfig) && val > 0) {␊ |
365 | ␉␉␉screen_params[1] = val;␊ |
366 | ␉␉}␉␊ |
367 | ␉␉␊ |
368 | ␉␉screen = egCreateView(screen_params[0], screen_params[1], TRUE);␊ |
369 | ␉␉if (!screen) {␉␉␊ |
370 | ␉␉␉␊ |
371 | ␉␉␉return FALSE;␊ |
372 | ␉␉} ␊ |
373 | ␉␉DBG("screen buffer created\n");␊ |
374 | ␉␉␊ |
375 | ␉␉if(getColorForKey("screen_bgcolor", &color, &themeConfig) && color)␊ |
376 | ␉␉{␊ |
377 | ␉␉␉color = (color & 0x00FFFFFF);␉␉␊ |
378 | ␉␉␉EG_PIXEL Color;␊ |
379 | ␉␉␉␊ |
380 | ␉␉␉Color.r = ((color >> 16) & 0xFF) ; ␊ |
381 | ␉␉␉Color.g = ((color >> 8) & 0xFF) ; ␊ |
382 | ␉␉␉Color.b = ((color) & 0xFF) ;␊ |
383 | ␉␉␉Color.a = 255;␊ |
384 | ␉␉␉egViewSetBackgroundColor(screen,&Color); ␊ |
385 | ␉␉␉␊ |
386 | ␉␉}␊ |
387 | ␉␉else␊ |
388 | ␉␉{␊ |
389 | ␉␉␉// flush CompImage␊ |
390 | ␉␉␉EG_PIXEL Color;␊ |
391 | ␉␉␉Color.r = 0 ;␊ |
392 | ␉␉␉Color.g = 0 ;␊ |
393 | ␉␉␉Color.b = 0 ;␊ |
394 | ␉␉␉Color.a = 0;␊ |
395 | ␉␉␉egViewSetBackgroundColor(screen,&Color); ␊ |
396 | ␉␉␉␊ |
397 | ␉␉}␊ |
398 | ␉}␊ |
399 | ␉␊ |
400 | ␉while (1) {␊ |
401 | ␉␉ret = GetDirEntry(dirspec, &index, &name, &flags, &time);␊ |
402 | ␉␉if (ret == -1) break;␊ |
403 | ␊ |
404 | ␉␉if (!name) continue;␊ |
405 | ␉␉␊ |
406 | ␉␉DBG("testing %s\n", name);␊ |
407 | ␉␉␊ |
408 | ␉␉// Make sure this is a not directory.␊ |
409 | ␉␉if ((flags & kFileTypeMask) != kFileTypeFlat) continue;␉␉␊ |
410 | ␉␉␊ |
411 | ␉␉length = AsciiStrLen(name);␊ |
412 | ␉␉␊ |
413 | ␉␉if (!length) continue;␊ |
414 | ␊ |
415 | ␉␉// Make sure the image file is supported.␊ |
416 | ␉␉{␊ |
417 | ␉␉␉if (AsciiStriCmp(name + length - 4, ".png") == 0)␊ |
418 | ␉␉␉{␊ |
419 | ␉␉␉␉ImagesType = 1 ;//"PNG"␊ |
420 | ␉␉␉}␊ |
421 | ␉␉␉else if (AsciiStriCmp(name + length - 4, ".bmp") == 0) ␊ |
422 | ␉␉␉{␊ |
423 | ␉␉␉␉ImagesType = 2 ;//"BMP"␊ |
424 | ␉␉␉␉␊ |
425 | ␉␉␉}␊ |
426 | ␉␉␉else if (AsciiStriCmp(name + length - 4, ".icns") == 0)␊ |
427 | ␉␉␉{␊ |
428 | ␉␉␉␉ImagesType = 3 ;//"ICNS"␊ |
429 | ␉␉␉}␉␉␉␊ |
430 | ␉␉␉else␊ |
431 | ␉␉␉{␊ |
432 | ␉␉␉␉DBG("Image %s format is not supported and will be ignored\n", name);␊ |
433 | ␉␉␉␉continue;␊ |
434 | ␉␉␉}␊ |
435 | ␉␉}␊ |
436 | ␉␉␉␉␊ |
437 | ␉␉if (!(ImagesType > 0)) {␊ |
438 | ␉␉␉continue;␊ |
439 | ␉␉}␊ |
440 | ␉␉␊ |
441 | ␉␉CHAR8 FilePath8[1024];␉␉␊ |
442 | ␉␉snprintf(FilePath8, sizeof(FilePath8), "%s%s",dirspec,name);␊ |
443 | ␉␉␊ |
444 | ␉␉//CHAR16 FilePath[1024];␊ |
445 | ␉␉//AsciiStrToUnicodeStr(FilePath8, FilePath);␉␉␊ |
446 | ␉␉␊ |
447 | ␉␉DBG("loading %s\n", name);␊ |
448 | ␉␉EG_IMAGE * image = NULL/*egLoadImage(FilePath, TRUE)*/;␊ |
449 | ␉␉␊ |
450 | ␉␉//if (!image) continue;␊ |
451 | ␉␉␊ |
452 | ␉␉{␊ |
453 | ␉␉␉void *BkgColor = NULL;␊ |
454 | ␉␉␉const char*pstrFileName = FilePath8;␊ |
455 | ␉␉␉int piWidth = 0;␊ |
456 | ␉␉␉int piHeight = 0;␊ |
457 | ␉␉␉unsigned char *ppbImageData = NULL ;␊ |
458 | ␉␉␉int piChannels = 0;␊ |
459 | ␉␉␉bool ret ;␊ |
460 | ␉␉␉ret = PngLoadImage (pstrFileName, &ppbImageData,␊ |
461 | ␉␉␉␉␉␉␉␉&piWidth, &piHeight, &piChannels, BkgColor);␊ |
462 | ␉␉␉␊ |
463 | ␉␉␉if (ret != FALSE) {␊ |
464 | ␉␉␉␉␊ |
465 | ␉␉␉␉image = egCreateImageFromData((EG_PIXEL *)ppbImageData, piWidth, piHeight, (piChannels == 4) ? TRUE : FALSE, TRUE);␊ |
466 | ␉␉␉␉␊ |
467 | ␉␉␉␉if (!image) continue;␊ |
468 | ␉␉␉}␊ |
469 | ␉␉}␊ |
470 | ␉␉␊ |
471 | ␉␉DBG("Creating view for %s\n", name);␊ |
472 | ␉␉␊ |
473 | ␉␉CHAR16 name16[128];␊ |
474 | ␉␉AsciiStrToUnicodeStr(name, name16);␊ |
475 | ␊ |
476 | ␉␉if (ImagesType == 1 ) //"PNG"␊ |
477 | ␉␉{␊ |
478 | ␉␉␉DBG("png file detected\n");␊ |
479 | ␊ |
480 | ␉␉␉if (strcmp(name,"logo.png") == 0)␊ |
481 | ␉␉␉{␊ |
482 | ␉␉␉␉DBG("computing logo.png\n");␊ |
483 | ␊ |
484 | ␉␉␉␉EG_POSITION pos ;␊ |
485 | ␉␉␉␉/*␊ |
486 | ␉␉␉␉pos.x = (screen_params[0] - MIN(image->Width, screen_params[0])) /2;␊ |
487 | ␉␉␉␉pos.y = (screen_params[1] - MIN(image->Height, screen_params[1])) /2;␊ |
488 | ␉␉␉␉␊ |
489 | ␉␉␉␉if(getDimensionForKey("logo_pos_x", &pixel, &themeConfig, screen_params[0] , image->Width ) )␊ |
490 | ␉␉␉␉␉pos.x = pixel;␊ |
491 | ␉␉␉␉␊ |
492 | ␉␉␉␉if(getDimensionForKey("logo_pos_y", &pixel, &themeConfig, screen_params[1] , image->Height ) )␊ |
493 | ␉␉␉␉␉pos.y = pixel;␉␉␉␉␊ |
494 | ␉␉␉␉*/␊ |
495 | ␉␉␉␉pos.y = 20;␉␉␉␉␊ |
496 | ␉␉␉␉pos.x = 20;␊ |
497 | ␊ |
498 | ␉␉␉␉␊ |
499 | ␉␉␉␉EG_IMAGE_VIEW * TopImageView = egCreateImageViewFromData((EG_PIXEL *)image->PixelData, image->Width, image->Height, TRUE , pos.x, pos.y, name16, TRUE);␊ |
500 | ␉␉␉␉␊ |
501 | ␉␉␉␉if (TopImageView) {␉␉␉␉␊ |
502 | ␉␉␉␉␉egViewAddImageView(screen, TopImageView);␊ |
503 | ␉␉␉␉␉egFreeImageView(TopImageView);␊ |
504 | ␉␉␉␉}␉␉␉␊ |
505 | ␉␉␉␉␊ |
506 | ␉␉␉␉egFreeImage(image);␊ |
507 | ␉␉␉␉␊ |
508 | ␉␉␉␉␊ |
509 | ␉␉␉} ␊ |
510 | ␉␉␉else if (strcmp(name,"device_hfsplus.png")==0)␊ |
511 | ␉␉␉{␊ |
512 | ␉␉␉␉DBG("computing device_hfsplus.png\n");␊ |
513 | ␊ |
514 | ␉␉␉␉EG_POSITION pos ;␊ |
515 | ␉␉␉␉pos.x = 0;␊ |
516 | ␉␉␉␉pos.y = 0;␊ |
517 | ␉␉␉␉␊ |
518 | ␉␉␉␉if(getDimensionForKey("devices_pos_x", &pixel, &themeConfig, screen_params[0] , image->Width ) )␊ |
519 | ␉␉␉␉␉pos.x = pixel;␊ |
520 | ␉␉␉␉else␊ |
521 | ␉␉␉␉␉pos.x = (screen_params[0] - MIN(image->Width, screen_params[0])) /2;␊ |
522 | ␉␉␉␉␊ |
523 | ␉␉␉␉if(getDimensionForKey("devices_pos_y", &pixel, &themeConfig, screen_params[1] , image->Height ) )␊ |
524 | ␉␉␉␉␉pos.y = pixel;␊ |
525 | ␉␉␉␉else␊ |
526 | ␉␉␉␉␉pos.y = (screen_params[1] - MIN(image->Height, screen_params[1])) /2;␉␉␉␊ |
527 | ␉␉␉␉␉␉␉␉␉␉␉␉␊ |
528 | ␉␉␉␉EG_IMAGE_VIEW * TopImageView = egCreateImageViewFromData((EG_PIXEL *)image->PixelData, image->Width, image->Height, TRUE , pos.x, pos.y, name16, TRUE);␉␉␉␊ |
529 | ␉␉␉␉␊ |
530 | ␉␉␉␉if (TopImageView) {␉␉␉␉␊ |
531 | ␉␉␉␉␉deviceView = egViewAddImageView(screen, TopImageView);␉␉␉␉␊ |
532 | ␉␉␉␉␉egFreeImageView(TopImageView);␊ |
533 | ␉␉␉␉}␉␊ |
534 | ␉␉␉␉␊ |
535 | ␉␉␉␉egFreeImage(image);␊ |
536 | ␉␉␉␉␊ |
537 | ␉␉␉␉␊ |
538 | ␉␉␉} ␊ |
539 | ␉␉␉else ␊ |
540 | ␉␉␉␉DBG("file not handled\n");␊ |
541 | ␉␉␉␊ |
542 | ␉␉} ␊ |
543 | ␉␉else if (ImagesType == 3 ) //"ICNS"␊ |
544 | ␉␉{␊ |
545 | ␉␉␉DBG("icns file detected\n");␊ |
546 | ␊ |
547 | ␉␉␉EG_IMAGE * icnsImage = NULL;␊ |
548 | ␉␉␉if ((icnsImage = egDecodeICNS((UINT8 *)image->PixelData, image->Width * image->Height * 4, 128, TRUE)))␊ |
549 | ␉␉␉{␉␉␉␉␊ |
550 | ␉␉␉␉␊ |
551 | ␉␉␉␉EG_IMAGE_VIEW * iconeView = egCreateImageViewFromData((EG_PIXEL *)image->PixelData, image->Width, image->Height, TRUE , 40, 40, name16, TRUE);␊ |
552 | ␉␉␉␉␊ |
553 | ␉␉␉␉if (iconeView) {␊ |
554 | ␉␉␉␉␉iconeRef = egViewAddImageView(screen, iconeView);␊ |
555 | ␉␉␉␉␉egFreeImageView(iconeView);␊ |
556 | ␉␉␉␉}␉␉␉␉␊ |
557 | ␉␉␉␉␊ |
558 | ␉␉␉␉egFreeImage(icnsImage);␊ |
559 | ␉␉␉␉egFreeImage(image);␊ |
560 | ␊ |
561 | ␊ |
562 | ␉␉␉} ␊ |
563 | ␉␉}␉␉␉␊ |
564 | ␉␉␊ |
565 | ␉}␉␊ |
566 | ␉␊ |
567 | ␊ |
568 | ␉if (!screen) {␊ |
569 | ␉␉return FALSE;␊ |
570 | ␉}␊ |
571 | ␉␊ |
572 | __setVideoMode( GRAPHICS_MODE );␊ |
573 | egViewUpdate(screen);␊ |
574 | ␊ |
575 | getc();␊ |
576 | ␉DBG("LETS HAVE SOME FUN\n"); // you should never see this message␊ |
577 | ␊ |
578 | ␉␊ |
579 | ␉/********************************␊ |
580 | ␉ *␉␉␉␉␉␉␉␉*␉␉␉␉␉␉␉␉␊ |
581 | ␉ *␉␉LETS HAVE SOME FUN␉ *␉␉␉␊ |
582 | ␉ *␉␉␉␉␉␉␉␉*␉␊ |
583 | ␉ *␉␉␉␉␉␉␉␉*␉␊ |
584 | ␉ ********************************/␊ |
585 | ␊ |
586 | #define TEXT_YMARGIN (2)␊ |
587 | #define LAYOUT_TEXT_WIDTH (512)␊ |
588 | #define LAYOUT_TOTAL_HEIGHT (368)␊ |
589 | #define FONT_CELL_HEIGHT (12)␊ |
590 | #define TEXT_LINE_HEIGHT (FONT_CELL_HEIGHT + TEXT_YMARGIN * 2)␊ |
591 | ␊ |
592 | ␊ |
593 | UINTN px = (screen_params[0] - MIN(((LAYOUT_TEXT_WIDTH *2 )/ 10) , screen_params[0])) /2, i;␊ |
594 | UINTN py = (screen_params[1] - MIN(((TEXT_LINE_HEIGHT * 8) / 10) , screen_params[1])) /2;␊ |
595 | EG_IMAGE_VIEW * ConsoleImageView = egCreateImageView(LAYOUT_TEXT_WIDTH / 10, (TEXT_LINE_HEIGHT * 8) / 10, FALSE, px , py, L"SCREEN_Console");␊ |
596 | assert(ConsoleImageView);␊ |
597 | assert(ConsoleImageView->Image);␊ |
598 | ␊ |
599 | egFillImage(ConsoleImageView->Image, &MenuBackgroundPixel);␊ |
600 | ␊ |
601 | EG_IMAGE_VIEW * ConsoleImageViewRef = egViewAddImageView(screen, ConsoleImageView);␊ |
602 | egFreeImageView(ConsoleImageView);␊ |
603 | egViewUpdate(screen);␊ |
604 | ␊ |
605 | // ios/osx style window bounce effect␊ |
606 | for (i = 1; ConsoleImageViewRef->Image->Width <= LAYOUT_TEXT_WIDTH *2*2; i++) {␊ |
607 | ␊ |
608 | if (ConsoleImageViewRef->Image->Height > TEXT_LINE_HEIGHT * 8 *2)␊ |
609 | break;␊ |
610 | #define soustraction(x,y) ((x) - (y))␊ |
611 | ConsoleImageViewRef->Image->Width += soustraction(i, (i==1)?0:1);␊ |
612 | ConsoleImageViewRef->Image->Height += soustraction(i, (i==1)?0:1);␊ |
613 | px = (screen_params[0] - MIN(ConsoleImageViewRef->Image->Width , screen_params[0])) /2;␊ |
614 | py = (screen_params[1] - MIN(ConsoleImageViewRef->Image->Height , screen_params[1])) /2;␊ |
615 | ␊ |
616 | ConsoleImageViewRef->PosY = py ;␊ |
617 | ConsoleImageViewRef->PosX = px ;␊ |
618 | ␊ |
619 | free(ConsoleImageViewRef->Image->PixelData);␊ |
620 | ␊ |
621 | ConsoleImageViewRef->Image->PixelData = (EG_PIXEL*)malloc(ConsoleImageViewRef->Image->Width * ConsoleImageViewRef->Image->Height * sizeof(EG_PIXEL));␊ |
622 | ␊ |
623 | egFillImage(ConsoleImageViewRef->Image, &MenuBackgroundPixel);␊ |
624 | screen->isDirty = TRUE;␊ |
625 | egViewUpdate(screen);␊ |
626 | ␊ |
627 | ␊ |
628 | }␊ |
629 | ␊ |
630 | for (i = 0; i < 10; i++) {␊ |
631 | ␊ |
632 | ␊ |
633 | #define soustraction(x,y) ((x) - (y))␊ |
634 | ConsoleImageViewRef->Image->Width -= i;␊ |
635 | ConsoleImageViewRef->Image->Height -= i;␊ |
636 | px = (screen_params[0] - MIN(ConsoleImageViewRef->Image->Width , screen_params[0])) /2;␊ |
637 | py = (screen_params[1] - MIN(ConsoleImageViewRef->Image->Height , screen_params[1])) /2;␊ |
638 | ␊ |
639 | ConsoleImageViewRef->PosY = py ;␊ |
640 | ConsoleImageViewRef->PosX = px ;␊ |
641 | ␊ |
642 | free(ConsoleImageViewRef->Image->PixelData);␊ |
643 | ␊ |
644 | ConsoleImageViewRef->Image->PixelData = (EG_PIXEL*)malloc(ConsoleImageViewRef->Image->Width * ConsoleImageViewRef->Image->Height * sizeof(EG_PIXEL));␊ |
645 | ␊ |
646 | egFillImage(ConsoleImageViewRef->Image, &MenuBackgroundPixel);␊ |
647 | ␊ |
648 | screen->isDirty = TRUE;␊ |
649 | egViewUpdate(screen);␊ |
650 | ␊ |
651 | ␊ |
652 | }␊ |
653 | egViewUpdate(screen);␊ |
654 | getc();␊ |
655 | ␉egViewRemoveImageView(screen, ConsoleImageViewRef);␊ |
656 | ␊ |
657 | /*␊ |
658 | UINTN TextWidth;␊ |
659 | ␊ |
660 | EG_POSITION pos ;␊ |
661 | pos.x = (screen_params[0] - MIN(LAYOUT_TEXT_WIDTH, screen_params[0])) /2;␊ |
662 | pos.y = (screen_params[1] - MIN(TEXT_LINE_HEIGHT, screen_params[1])) /2;␊ |
663 | if (deviceView) {␊ |
664 | pos.y = deviceView->PosY - 10;␊ |
665 | ␊ |
666 | }␊ |
667 | ␊ |
668 | EG_IMAGE_VIEW * TextImageView = egCreateImageView(LAYOUT_TEXT_WIDTH, TEXT_LINE_HEIGHT, FALSE, pos.x, pos.y , L"SCREEN_HEADER");␊ |
669 | ␊ |
670 | assert(TextImageView);␊ |
671 | assert(TextImageView->Image);␊ |
672 | ␊ |
673 | egFillImage(TextImageView->Image, &MenuBackgroundPixel);␊ |
674 | ␊ |
675 | // render the text␊ |
676 | egMeasureText(L"WELCOME TO THE EG GRAPHIC TEST... PRESS ANY KEY TO CONTINUE.", &TextWidth, NULL);␊ |
677 | egRenderText(L"WELCOME TO THE EG GRAPHIC TEST... PRESS ANY KEY TO CONTINUE.", TextImageView->Image, (TextImageView->Image->Width - TextWidth) >> 1, 2);␊ |
678 | ␊ |
679 | egViewAddImageView(screen, TextImageView);␊ |
680 | egFreeImageView(TextImageView);␊ |
681 | egViewUpdate(screen);␊ |
682 | getc();␊ |
683 | egViewRemoveImageViewByName(screen, L"SCREEN_HEADER", sizeof(L"SCREEN_HEADER"));␊ |
684 | */␊ |
685 | egViewUpdate(screen);␊ |
686 | getc();␊ |
687 | deviceView = deviceView ? deviceView : iconeRef;␊ |
688 | if (deviceView) {␊ |
689 | struct timeval earlier;␊ |
690 | struct timeval later;␊ |
691 | ␊ |
692 | uint32_t c;␊ |
693 | uint32_t i;␊ |
694 | uint32_t x,y;␊ |
695 | uint32_t x2,y2;␊ |
696 | ␊ |
697 | for (c = 0; c < 5; c++) {␊ |
698 | if(gettimeofday(&earlier,NULL) != 0)␊ |
699 | { ␊ |
700 | exit(-1);␊ |
701 | }␊ |
702 | int inc = 1,count = 0;␊ |
703 | x = deviceView->PosX;␊ |
704 | y = deviceView->PosY;␊ |
705 | ␊ |
706 | int inc2 = 1,count2 = 0;␊ |
707 | x2 = iconeRef->PosX;␊ |
708 | y2 = iconeRef->PosY;␊ |
709 | ␊ |
710 | // bounce left to right test (aka say NO)␊ |
711 | for (i = 0; i<100; i++) {␊ |
712 | ␊ |
713 | if (count >= 5 && count2 >= 5) break;␊ |
714 | ␊ |
715 | if (count < 5) {␊ |
716 | if (deviceView->PosX >= x )␊ |
717 | {␊ |
718 | if (deviceView->PosX == x )␊ |
719 | {␊ |
720 | count++;␊ |
721 | if (count == 5) {␊ |
722 | screen->isDirty = TRUE;␊ |
723 | egViewUpdate(screen);␊ |
724 | inc = -1;␊ |
725 | } else inc = 1;␊ |
726 | }␊ |
727 | ␊ |
728 | if (inc >= 0)␊ |
729 | {␊ |
730 | if (deviceView->PosX >= x+10 ) {␊ |
731 | deviceView->PosX-=2;␊ |
732 | inc = 0;␊ |
733 | screen->isDirty = TRUE;␊ |
734 | ␊ |
735 | }␊ |
736 | else␊ |
737 | {␊ |
738 | if (inc == 1) {␊ |
739 | deviceView->PosX+=2;␊ |
740 | ␊ |
741 | } else deviceView->PosX-=2;␊ |
742 | screen->isDirty = TRUE;␊ |
743 | ␊ |
744 | ␊ |
745 | }␊ |
746 | }␊ |
747 | ␊ |
748 | ␊ |
749 | ␊ |
750 | ␊ |
751 | }␊ |
752 | }␊ |
753 | ␊ |
754 | egViewUpdate(screen);␊ |
755 | ␊ |
756 | if (count2 < 5 && deviceView != iconeRef) {␊ |
757 | if (iconeRef->PosX >= x2 )␊ |
758 | {␊ |
759 | if (iconeRef->PosX == x2 )␊ |
760 | {␊ |
761 | count2++;␊ |
762 | if (count2 == 5) {␊ |
763 | screen->isDirty = TRUE;␊ |
764 | egViewUpdate(screen);␊ |
765 | inc2 = -1;␊ |
766 | } else inc2 = 1;␊ |
767 | }␊ |
768 | ␊ |
769 | if (inc2 >= 0)␊ |
770 | {␊ |
771 | if (iconeRef->PosX >= x2+10 ) {␊ |
772 | iconeRef->PosX-=2;␊ |
773 | inc2 = 0;␊ |
774 | screen->isDirty = TRUE;␊ |
775 | ␊ |
776 | }␊ |
777 | else␊ |
778 | {␊ |
779 | if (inc2 == 1) {␊ |
780 | iconeRef->PosX+=2;␊ |
781 | ␊ |
782 | } else iconeRef->PosX-=2;␊ |
783 | screen->isDirty = TRUE;␊ |
784 | ␊ |
785 | }␊ |
786 | } ␊ |
787 | ␊ |
788 | ␊ |
789 | }␊ |
790 | }␊ |
791 | ␊ |
792 | }␊ |
793 | if(gettimeofday(&later,NULL) != 0)␊ |
794 | {␊ |
795 | ␊ |
796 | exit(-1);␊ |
797 | }␊ |
798 | ␊ |
799 | ␊ |
800 | EG_POSITION pos ;␊ |
801 | pos.x = (screen_params[0] - MIN(LAYOUT_TEXT_WIDTH, screen_params[0])) /2;␊ |
802 | pos.y = (screen_params[1] - MIN(TEXT_LINE_HEIGHT, screen_params[1])) /2;␊ |
803 | if (deviceView) {␊ |
804 | pos.y = deviceView->PosY + 10;␊ |
805 | ␊ |
806 | }␊ |
807 | ␊ |
808 | EG_IMAGE_VIEW * TextImageView = egCreateImageView(300, TEXT_LINE_HEIGHT, FALSE, pos.x, pos.y , L"SCREEN_NOTIFICATION");␊ |
809 | ␊ |
810 | assert(TextImageView);␊ |
811 | assert(TextImageView->Image);␊ |
812 | //MenuBackgroundPixel.a -=50;␊ |
813 | egFillImage(TextImageView->Image, &MenuBackgroundPixel);␊ |
814 | ␊ |
815 | // render the text␊ |
816 | ␊ |
817 | CHAR16 Destination[512];␊ |
818 | ␊ |
819 | SPrint (␊ |
820 | Destination,␊ |
821 | sizeof(Destination),␊ |
822 | L"animation %d took %lld microseconds to finish", c,␊ |
823 | timeval_diff(NULL,&later,&earlier));␊ |
824 | ␊ |
825 | /*␊ |
826 | CHAR8 Destination8[512];␊ |
827 | snprintf(Destination8, sizeof(Destination8), "animation %d took %lld microseconds to finish", c,␊ |
828 | timeval_diff(NULL,&later,&earlier));␊ |
829 | ␊ |
830 | AsciiStrToUnicodeStr(Destination8, Destination);␊ |
831 | */␊ |
832 | /*␊ |
833 | UINTN TextWidth;␊ |
834 | egMeasureText(Destination, &TextWidth, NULL);␊ |
835 | egRenderText(Destination, TextImageView->Image, (TextImageView->Image->Width - TextWidth) >> 1, 2);␊ |
836 | */␊ |
837 | egViewAddImageView(screen, TextImageView);␊ |
838 | egFreeImageView(TextImageView);␊ |
839 | egViewUpdate(screen);␊ |
840 | ␊ |
841 | getc();␊ |
842 | egViewRemoveImageViewByName(screen, L"SCREEN_NOTIFICATION", sizeof(L"SCREEN_NOTIFICATION"));␊ |
843 | ␊ |
844 | }␊ |
845 | ␊ |
846 | ␊ |
847 | // change background test␊ |
848 | EG_PIXEL *bColor = egViewGetBackgroundColor(screen); // save original color␊ |
849 | for (i = 0; i<15; i++) {␊ |
850 | EG_PIXEL Color;␊ |
851 | Color.r = arc4random_unirange(0,255) ;␊ |
852 | Color.g = arc4random_unirange(0,255) ;␊ |
853 | Color.b = arc4random_unirange(0,255) ;␊ |
854 | Color.a = arc4random_unirange(0,255);␊ |
855 | ␊ |
856 | egViewSetBackgroundColor(screen, &Color); ␊ |
857 | delay(100000);␊ |
858 | egViewUpdate(screen);␊ |
859 | }␊ |
860 | sleep(1); ␊ |
861 | egViewSetBackgroundColor(screen,bColor); // restore color␊ |
862 | free(bColor);␊ |
863 | ␊ |
864 | // move image test␊ |
865 | for (i = 0; i<100; i++) {␊ |
866 | ␊ |
867 | ␊ |
868 | ␊ |
869 | deviceView->PosX +=2;␊ |
870 | deviceView->PosY +=2;␊ |
871 | ␊ |
872 | screen->isDirty = TRUE;␊ |
873 | ␊ |
874 | egViewUpdate(screen);␊ |
875 | }␊ |
876 | ␊ |
877 | int incx , incy ;␊ |
878 | int bxpl , bypl ;␊ |
879 | ␊ |
880 | ␊ |
881 | incx = arc4random_unirange(0,1);␊ |
882 | incy = arc4random_unirange(0,1);␊ |
883 | ␊ |
884 | bxpl = arc4random_unirange(3,6);␊ |
885 | bypl = arc4random_unirange(3,6);␊ |
886 | ␊ |
887 | ␊ |
888 | for (i = 0; i<5000; i++) {␊ |
889 | ␊ |
890 | ␊ |
891 | ␊ |
892 | if (deviceView->PosX >= bxpl && incx <= 0) {␊ |
893 | deviceView->PosX -=bxpl;␊ |
894 | incx = 0;␊ |
895 | ␊ |
896 | }␊ |
897 | else if (deviceView->PosX + deviceView->Image->Width + bxpl < screen->CompImage->Width )␊ |
898 | {␊ |
899 | deviceView->PosX +=bxpl;␊ |
900 | if (incx != 1) {␊ |
901 | // will exit rect␊ |
902 | bxpl = arc4random_unirange(3,6);␊ |
903 | ␊ |
904 | }␊ |
905 | incx = 1;␊ |
906 | }␊ |
907 | else if (deviceView->PosX + deviceView->Image->Width + bxpl >= screen->CompImage->Width && incx != 0)␊ |
908 | {␊ |
909 | incx = -1;␊ |
910 | bxpl = arc4random_unirange(3,6);␊ |
911 | ␊ |
912 | //continue;␊ |
913 | }␊ |
914 | ␊ |
915 | ␊ |
916 | if (deviceView->PosY >= bypl && incy <= 0) {␊ |
917 | deviceView->PosY -=bypl;␊ |
918 | incy = 0;␊ |
919 | ␊ |
920 | }␊ |
921 | else if (deviceView->PosY + deviceView->Image->Height + bypl < screen->CompImage->Height )␊ |
922 | {␊ |
923 | deviceView->PosY += bypl;␊ |
924 | ␊ |
925 | if (incy != 1) {␊ |
926 | // will exit rect (top)␊ |
927 | bypl = arc4random_unirange(3,6);␊ |
928 | ␊ |
929 | }␊ |
930 | ␊ |
931 | incy = 1;␊ |
932 | }␊ |
933 | else if (deviceView->PosY + deviceView->Image->Height + bypl >= screen->CompImage->Height && incy != 0)␊ |
934 | {␊ |
935 | // will exit rect ( bottom)␊ |
936 | ␊ |
937 | incy = -1;␊ |
938 | bypl = arc4random_unirange(3,6);␊ |
939 | ␊ |
940 | //continue;␊ |
941 | } ␊ |
942 | ␊ |
943 | if (incy>= 0 && incx>=0) {␊ |
944 | screen->isDirty = TRUE;␊ |
945 | ␊ |
946 | egViewUpdate(screen);␊ |
947 | }␊ |
948 | ␊ |
949 | ␊ |
950 | ␊ |
951 | }␊ |
952 | ␊ |
953 | //getc();␊ |
954 | ␊ |
955 | //egViewRemoveImageViewByName(screen, L"plug_in_Icon", sizeof(L"plug_in_Icon"));␊ |
956 | egViewUpdate(screen);␊ |
957 | getc(); ␊ |
958 | ␊ |
959 | } ␊ |
960 | ␊ |
961 | __setVideoMode(VGA_TEXT_MODE);␊ |
962 | ␊ |
963 | egFreeView(screen);␊ |
964 | ␊ |
965 | ␉return TRUE;␊ |
966 | ␉␊ |
967 | }␊ |
968 | |