Rev 2677 | Rev 3707 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1518 | palkovsky | 1 | /* |
2071 | jermar | 2 | * Copyright (c) 2006 Ondrej Palkovsky |
1518 | palkovsky | 3 | * All rights reserved. |
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
13 | * documentation and/or other materials provided with the distribution. |
||
14 | * - The name of the author may not be used to endorse or promote products |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
1649 | cejka | 29 | /** @addtogroup console |
30 | * @{ |
||
31 | */ |
||
32 | /** @file |
||
33 | */ |
||
34 | |||
1518 | palkovsky | 35 | #include <ipc/fb.h> |
36 | #include <ipc/ipc.h> |
||
1522 | palkovsky | 37 | #include <async.h> |
38 | #include <stdio.h> |
||
1867 | jermar | 39 | #include <sys/mman.h> |
1547 | palkovsky | 40 | #include <string.h> |
1555 | palkovsky | 41 | #include <align.h> |
1518 | palkovsky | 42 | |
43 | #include "console.h" |
||
1522 | palkovsky | 44 | #include "gcons.h" |
1518 | palkovsky | 45 | |
1668 | palkovsky | 46 | #define CONSOLE_TOP 66 |
1555 | palkovsky | 47 | #define CONSOLE_MARGIN 6 |
1518 | palkovsky | 48 | |
1555 | palkovsky | 49 | #define STATUS_START 110 |
50 | #define STATUS_TOP 8 |
||
1668 | palkovsky | 51 | #define STATUS_SPACE 4 |
1555 | palkovsky | 52 | #define STATUS_WIDTH 48 |
53 | #define STATUS_HEIGHT 48 |
||
1518 | palkovsky | 54 | |
1547 | palkovsky | 55 | #define MAIN_COLOR 0xffffff |
1522 | palkovsky | 56 | |
1518 | palkovsky | 57 | static int use_gcons = 0; |
58 | static ipcarg_t xres,yres; |
||
59 | |||
1555 | palkovsky | 60 | enum butstate { |
61 | CONS_DISCONNECTED = 0, |
||
62 | CONS_SELECTED, |
||
63 | CONS_IDLE, |
||
64 | CONS_HAS_DATA, |
||
65 | CONS_KERNEL, |
||
66 | CONS_DISCONNECTED_SEL, |
||
67 | CONS_LAST |
||
68 | }; |
||
69 | |||
1518 | palkovsky | 70 | static int console_vp; |
71 | static int cstatus_vp[CONSOLE_COUNT]; |
||
1555 | palkovsky | 72 | static enum butstate console_state[CONSOLE_COUNT]; |
1518 | palkovsky | 73 | |
74 | static int fbphone; |
||
75 | |||
1555 | palkovsky | 76 | /** List of pixmaps identifying these icons */ |
2025 | jermar | 77 | static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; |
1646 | palkovsky | 78 | static int animation = -1; |
1522 | palkovsky | 79 | |
80 | static int active_console = 0; |
||
81 | |||
1518 | palkovsky | 82 | static void vp_switch(int vp) |
83 | { |
||
2621 | jermar | 84 | async_msg_1(fbphone,FB_VIEWPORT_SWITCH, vp); |
1518 | palkovsky | 85 | } |
86 | |||
1522 | palkovsky | 87 | /** Create view port */ |
2621 | jermar | 88 | static int vp_create(unsigned int x, unsigned int y, unsigned int width, |
89 | unsigned int height) |
||
1518 | palkovsky | 90 | { |
2621 | jermar | 91 | return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, |
92 | (width << 16) | height); |
||
1518 | palkovsky | 93 | } |
94 | |||
1522 | palkovsky | 95 | static void clear(void) |
1518 | palkovsky | 96 | { |
2621 | jermar | 97 | async_msg_0(fbphone, FB_CLEAR); |
1518 | palkovsky | 98 | } |
99 | |||
1522 | palkovsky | 100 | static void set_style(int fgcolor, int bgcolor) |
1518 | palkovsky | 101 | { |
1610 | palkovsky | 102 | async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
1518 | palkovsky | 103 | } |
104 | |||
1558 | palkovsky | 105 | /** Transparent putchar */ |
106 | static void tran_putch(char c, int row, int col) |
||
1522 | palkovsky | 107 | { |
1610 | palkovsky | 108 | async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
1522 | palkovsky | 109 | } |
110 | |||
1558 | palkovsky | 111 | /** Redraw the button showing state of a given console */ |
1555 | palkovsky | 112 | static void redraw_state(int consnum) |
1522 | palkovsky | 113 | { |
114 | char data[5]; |
||
115 | int i; |
||
1555 | palkovsky | 116 | enum butstate state = console_state[consnum]; |
117 | |||
1522 | palkovsky | 118 | vp_switch(cstatus_vp[consnum]); |
1555 | palkovsky | 119 | if (ic_pixmaps[state] != -1) |
2025 | jermar | 120 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], |
2621 | jermar | 121 | ic_pixmaps[state]); |
1555 | palkovsky | 122 | |
2070 | jermar | 123 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && |
124 | state != CONS_DISCONNECTED_SEL) { |
||
2025 | jermar | 125 | snprintf(data, 5, "%d", consnum + 1); |
2070 | jermar | 126 | for (i = 0; data[i]; i++) |
2025 | jermar | 127 | tran_putch(data[i], 1, 2 + i); |
1555 | palkovsky | 128 | } |
1522 | palkovsky | 129 | } |
130 | |||
1555 | palkovsky | 131 | /** Notification run on changing console (except kernel console) */ |
1518 | palkovsky | 132 | void gcons_change_console(int consnum) |
133 | { |
||
1555 | palkovsky | 134 | int i; |
135 | |||
1518 | palkovsky | 136 | if (!use_gcons) |
137 | return; |
||
1552 | palkovsky | 138 | |
1555 | palkovsky | 139 | if (active_console == KERNEL_CONSOLE) { |
2025 | jermar | 140 | for (i = 0; i < CONSOLE_COUNT; i++) |
1555 | palkovsky | 141 | redraw_state(i); |
1647 | palkovsky | 142 | if (animation != -1) |
2621 | jermar | 143 | async_msg_1(fbphone, FB_ANIM_START, animation); |
1555 | palkovsky | 144 | } else { |
145 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
||
146 | console_state[active_console] = CONS_DISCONNECTED; |
||
147 | else |
||
148 | console_state[active_console] = CONS_IDLE; |
||
149 | redraw_state(active_console); |
||
150 | } |
||
1522 | palkovsky | 151 | active_console = consnum; |
1528 | palkovsky | 152 | |
1555 | palkovsky | 153 | if (console_state[consnum] == CONS_DISCONNECTED) { |
154 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
||
155 | redraw_state(consnum); |
||
156 | } else |
||
157 | console_state[consnum] = CONS_SELECTED; |
||
158 | redraw_state(consnum); |
||
159 | |||
1518 | palkovsky | 160 | vp_switch(console_vp); |
161 | } |
||
162 | |||
1552 | palkovsky | 163 | /** Notification function that gets called on new output to virtual console */ |
1518 | palkovsky | 164 | void gcons_notify_char(int consnum) |
165 | { |
||
166 | if (!use_gcons) |
||
167 | return; |
||
168 | |||
2070 | jermar | 169 | if (consnum == active_console || |
170 | console_state[consnum] == CONS_HAS_DATA) |
||
1528 | palkovsky | 171 | return; |
172 | |||
1555 | palkovsky | 173 | console_state[consnum] = CONS_HAS_DATA; |
1552 | palkovsky | 174 | |
1555 | palkovsky | 175 | if (active_console == KERNEL_CONSOLE) |
1552 | palkovsky | 176 | return; |
177 | |||
1555 | palkovsky | 178 | redraw_state(consnum); |
1528 | palkovsky | 179 | |
1518 | palkovsky | 180 | vp_switch(console_vp); |
1555 | palkovsky | 181 | } |
1552 | palkovsky | 182 | |
1592 | palkovsky | 183 | /** Notification function called on service disconnect from console */ |
184 | void gcons_notify_disconnect(int consnum) |
||
185 | { |
||
186 | if (!use_gcons) |
||
187 | return; |
||
188 | if (active_console == consnum) |
||
189 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
||
190 | else |
||
191 | console_state[consnum] = CONS_DISCONNECTED; |
||
192 | |||
193 | if (active_console == KERNEL_CONSOLE) |
||
194 | return; |
||
195 | |||
196 | redraw_state(consnum); |
||
197 | vp_switch(console_vp); |
||
198 | } |
||
199 | |||
1558 | palkovsky | 200 | /** Notification function called on console connect */ |
1555 | palkovsky | 201 | void gcons_notify_connect(int consnum) |
202 | { |
||
203 | if (!use_gcons) |
||
204 | return; |
||
205 | if (active_console == consnum) |
||
206 | console_state[consnum] = CONS_SELECTED; |
||
207 | else |
||
208 | console_state[consnum] = CONS_IDLE; |
||
209 | |||
210 | if (active_console == KERNEL_CONSOLE) |
||
211 | return; |
||
212 | |||
213 | redraw_state(consnum); |
||
214 | vp_switch(console_vp); |
||
1518 | palkovsky | 215 | } |
216 | |||
1552 | palkovsky | 217 | /** Change to kernel console */ |
218 | void gcons_in_kernel(void) |
||
219 | { |
||
1557 | palkovsky | 220 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
1555 | palkovsky | 221 | console_state[active_console] = CONS_DISCONNECTED; |
222 | else |
||
223 | console_state[active_console] = CONS_IDLE; |
||
224 | redraw_state(active_console); |
||
225 | |||
1647 | palkovsky | 226 | if (animation != -1) |
2621 | jermar | 227 | async_msg_1(fbphone, FB_ANIM_STOP, animation); |
1647 | palkovsky | 228 | |
1555 | palkovsky | 229 | active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
1552 | palkovsky | 230 | vp_switch(0); |
231 | } |
||
232 | |||
1751 | palkovsky | 233 | /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */ |
1707 | palkovsky | 234 | static inline int limit(int a,int left, int right) |
235 | { |
||
236 | if (a < left) |
||
237 | a = left; |
||
238 | if (a >= right) |
||
239 | a = right - 1; |
||
240 | return a; |
||
241 | } |
||
242 | |||
1717 | palkovsky | 243 | int mouse_x, mouse_y; |
244 | int btn_pressed, btn_x, btn_y; |
||
245 | |||
246 | /** Handle mouse move |
||
247 | * |
||
248 | * @param dx Delta X of mouse move |
||
249 | * @param dy Delta Y of mouse move |
||
250 | */ |
||
1707 | palkovsky | 251 | void gcons_mouse_move(int dx, int dy) |
252 | { |
||
1717 | palkovsky | 253 | mouse_x = limit(mouse_x+dx, 0, xres); |
254 | mouse_y = limit(mouse_y+dy, 0, yres); |
||
1707 | palkovsky | 255 | |
1717 | palkovsky | 256 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
257 | } |
||
1707 | palkovsky | 258 | |
1717 | palkovsky | 259 | static int gcons_find_conbut(int x, int y) |
260 | { |
||
2025 | jermar | 261 | int status_start = STATUS_START + (xres - 800) / 2;; |
1717 | palkovsky | 262 | |
2025 | jermar | 263 | if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT) |
1717 | palkovsky | 264 | return -1; |
265 | |||
266 | if (x < status_start) |
||
267 | return -1; |
||
268 | |||
2025 | jermar | 269 | if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT) |
1717 | palkovsky | 270 | return -1; |
1718 | palkovsky | 271 | if (((x - status_start) % (STATUS_WIDTH+STATUS_SPACE)) < STATUS_SPACE) |
1717 | palkovsky | 272 | return -1; |
273 | |||
2025 | jermar | 274 | return (x - status_start) / (STATUS_WIDTH+STATUS_SPACE); |
1707 | palkovsky | 275 | } |
276 | |||
1717 | palkovsky | 277 | /** Handle mouse click |
278 | * |
||
279 | * @param state New state (1-pressed, 0-depressed) |
||
280 | */ |
||
281 | int gcons_mouse_btn(int state) |
||
282 | { |
||
283 | int conbut; |
||
1707 | palkovsky | 284 | |
1717 | palkovsky | 285 | if (state) { |
286 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
||
287 | if (conbut != -1) { |
||
288 | btn_pressed = 1; |
||
289 | btn_x = mouse_x; |
||
290 | btn_y = mouse_y; |
||
291 | } |
||
292 | return -1; |
||
293 | } |
||
294 | if (!state && !btn_pressed) |
||
295 | return -1; |
||
296 | btn_pressed = 0; |
||
297 | |||
298 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
||
299 | if (conbut == gcons_find_conbut(btn_x, btn_y)) |
||
300 | return conbut; |
||
301 | return -1; |
||
302 | } |
||
303 | |||
304 | |||
1552 | palkovsky | 305 | /** Draw a PPM pixmap to framebuffer |
306 | * |
||
307 | * @param logo Pointer to PPM data |
||
308 | * @param size Size of PPM data |
||
309 | * @param x Coordinate of upper left corner |
||
310 | * @param y Coordinate of upper left corner |
||
311 | */ |
||
1547 | palkovsky | 312 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
313 | { |
||
314 | char *shm; |
||
315 | int rc; |
||
316 | |||
317 | /* Create area */ |
||
2025 | jermar | 318 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
2621 | jermar | 319 | MAP_ANONYMOUS, 0, 0); |
1547 | palkovsky | 320 | if (shm == MAP_FAILED) |
321 | return; |
||
322 | |||
323 | memcpy(shm, logo, size); |
||
324 | /* Send area */ |
||
2621 | jermar | 325 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
1547 | palkovsky | 326 | if (rc) |
327 | goto exit; |
||
2678 | jermar | 328 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
1547 | palkovsky | 329 | if (rc) |
330 | goto drop; |
||
331 | /* Draw logo */ |
||
1610 | palkovsky | 332 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
1547 | palkovsky | 333 | drop: |
334 | /* Drop area */ |
||
2621 | jermar | 335 | async_msg_0(fbphone, FB_DROP_SHM); |
1547 | palkovsky | 336 | exit: |
337 | /* Remove area */ |
||
338 | munmap(shm, size); |
||
339 | } |
||
340 | |||
341 | extern char _binary_helenos_ppm_start[0]; |
||
342 | extern int _binary_helenos_ppm_size; |
||
343 | extern char _binary_nameic_ppm_start[0]; |
||
344 | extern int _binary_nameic_ppm_size; |
||
1558 | palkovsky | 345 | /** Redraws console graphics */ |
1555 | palkovsky | 346 | static void gcons_redraw_console(void) |
1518 | palkovsky | 347 | { |
1522 | palkovsky | 348 | int i; |
349 | |||
1518 | palkovsky | 350 | if (!use_gcons) |
351 | return; |
||
352 | |||
353 | vp_switch(0); |
||
1522 | palkovsky | 354 | set_style(MAIN_COLOR, MAIN_COLOR); |
355 | clear(); |
||
2070 | jermar | 356 | draw_pixmap(_binary_helenos_ppm_start, |
2621 | jermar | 357 | (size_t) &_binary_helenos_ppm_size, xres - 66, 2); |
2070 | jermar | 358 | draw_pixmap(_binary_nameic_ppm_start, |
2621 | jermar | 359 | (size_t) &_binary_nameic_ppm_size, 5, 17); |
1522 | palkovsky | 360 | |
2621 | jermar | 361 | for (i = 0; i < CONSOLE_COUNT; i++) |
1555 | palkovsky | 362 | redraw_state(i); |
1518 | palkovsky | 363 | vp_switch(console_vp); |
364 | } |
||
365 | |||
1558 | palkovsky | 366 | /** Creates a pixmap on framebuffer |
367 | * |
||
368 | * @param data PPM data |
||
369 | * @param size PPM data size |
||
370 | * @return Pixmap identification |
||
371 | */ |
||
1555 | palkovsky | 372 | static int make_pixmap(char *data, int size) |
373 | { |
||
374 | char *shm; |
||
375 | int rc; |
||
376 | int pxid = -1; |
||
377 | |||
378 | /* Create area */ |
||
2025 | jermar | 379 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
2621 | jermar | 380 | MAP_ANONYMOUS, 0, 0); |
1555 | palkovsky | 381 | if (shm == MAP_FAILED) |
382 | return -1; |
||
383 | |||
384 | memcpy(shm, data, size); |
||
385 | /* Send area */ |
||
2621 | jermar | 386 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
1555 | palkovsky | 387 | if (rc) |
388 | goto exit; |
||
2678 | jermar | 389 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
1555 | palkovsky | 390 | if (rc) |
391 | goto drop; |
||
392 | |||
393 | /* Obtain pixmap */ |
||
2621 | jermar | 394 | rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); |
1555 | palkovsky | 395 | if (rc < 0) |
396 | goto drop; |
||
397 | pxid = rc; |
||
398 | drop: |
||
399 | /* Drop area */ |
||
2621 | jermar | 400 | async_msg_0(fbphone, FB_DROP_SHM); |
1555 | palkovsky | 401 | exit: |
402 | /* Remove area */ |
||
403 | munmap(shm, size); |
||
404 | |||
405 | return pxid; |
||
406 | } |
||
407 | |||
1646 | palkovsky | 408 | extern char _binary_anim_1_ppm_start[0]; |
409 | extern int _binary_anim_1_ppm_size; |
||
410 | extern char _binary_anim_2_ppm_start[0]; |
||
411 | extern int _binary_anim_2_ppm_size; |
||
412 | extern char _binary_anim_3_ppm_start[0]; |
||
413 | extern int _binary_anim_3_ppm_size; |
||
414 | extern char _binary_anim_4_ppm_start[0]; |
||
415 | extern int _binary_anim_4_ppm_size; |
||
2025 | jermar | 416 | |
1646 | palkovsky | 417 | static void make_anim(void) |
418 | { |
||
419 | int an; |
||
420 | int pm; |
||
421 | |||
2621 | jermar | 422 | an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
1646 | palkovsky | 423 | if (an < 0) |
424 | return; |
||
425 | |||
2070 | jermar | 426 | pm = make_pixmap(_binary_anim_1_ppm_start, |
2621 | jermar | 427 | (int) &_binary_anim_1_ppm_size); |
1646 | palkovsky | 428 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
429 | |||
2070 | jermar | 430 | pm = make_pixmap(_binary_anim_2_ppm_start, |
2621 | jermar | 431 | (int) &_binary_anim_2_ppm_size); |
1646 | palkovsky | 432 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
433 | |||
2070 | jermar | 434 | pm = make_pixmap(_binary_anim_3_ppm_start, |
2621 | jermar | 435 | (int) &_binary_anim_3_ppm_size); |
1646 | palkovsky | 436 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
437 | |||
2070 | jermar | 438 | pm = make_pixmap(_binary_anim_4_ppm_start, |
2621 | jermar | 439 | (int) &_binary_anim_4_ppm_size); |
1646 | palkovsky | 440 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
441 | |||
2621 | jermar | 442 | async_msg_1(fbphone, FB_ANIM_START, an); |
1646 | palkovsky | 443 | |
444 | animation = an; |
||
445 | } |
||
446 | |||
1555 | palkovsky | 447 | extern char _binary_cons_selected_ppm_start[0]; |
448 | extern int _binary_cons_selected_ppm_size; |
||
449 | extern char _binary_cons_idle_ppm_start[0]; |
||
450 | extern int _binary_cons_idle_ppm_size; |
||
451 | extern char _binary_cons_has_data_ppm_start[0]; |
||
452 | extern int _binary_cons_has_data_ppm_size; |
||
453 | extern char _binary_cons_kernel_ppm_start[0]; |
||
454 | extern int _binary_cons_kernel_ppm_size; |
||
2025 | jermar | 455 | |
1518 | palkovsky | 456 | /** Initialize nice graphical console environment */ |
457 | void gcons_init(int phone) |
||
458 | { |
||
459 | int rc; |
||
460 | int i; |
||
1646 | palkovsky | 461 | int status_start = STATUS_START; |
1518 | palkovsky | 462 | |
463 | fbphone = phone; |
||
464 | |||
2621 | jermar | 465 | rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); |
1518 | palkovsky | 466 | if (rc) |
467 | return; |
||
468 | |||
469 | if (xres < 800 || yres < 600) |
||
470 | return; |
||
471 | |||
472 | /* create console viewport */ |
||
1555 | palkovsky | 473 | /* Align width & height to character size */ |
2070 | jermar | 474 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
2621 | jermar | 475 | ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8), |
476 | ALIGN_DOWN(yres - (CONSOLE_TOP + CONSOLE_MARGIN), 16)); |
||
1518 | palkovsky | 477 | if (console_vp < 0) |
478 | return; |
||
479 | |||
480 | /* Create status buttons */ |
||
2025 | jermar | 481 | status_start += (xres - 800) / 2; |
482 | for (i = 0; i < CONSOLE_COUNT; i++) { |
||
2070 | jermar | 483 | cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN + |
2621 | jermar | 484 | i * (STATUS_WIDTH + STATUS_SPACE), STATUS_TOP, |
485 | STATUS_WIDTH, STATUS_HEIGHT); |
||
1518 | palkovsky | 486 | if (cstatus_vp[i] < 0) |
487 | return; |
||
1555 | palkovsky | 488 | vp_switch(cstatus_vp[i]); |
489 | set_style(0x202020, 0xffffff); |
||
1518 | palkovsky | 490 | } |
491 | |||
1555 | palkovsky | 492 | /* Initialize icons */ |
2025 | jermar | 493 | ic_pixmaps[CONS_SELECTED] = |
2621 | jermar | 494 | make_pixmap(_binary_cons_selected_ppm_start, |
495 | (int) &_binary_cons_selected_ppm_size); |
||
2070 | jermar | 496 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
2621 | jermar | 497 | (int) &_binary_cons_idle_ppm_size); |
2025 | jermar | 498 | ic_pixmaps[CONS_HAS_DATA] = |
2621 | jermar | 499 | make_pixmap(_binary_cons_has_data_ppm_start, |
500 | (int) &_binary_cons_has_data_ppm_size); |
||
2025 | jermar | 501 | ic_pixmaps[CONS_DISCONNECTED] = |
2621 | jermar | 502 | make_pixmap(_binary_cons_idle_ppm_start, |
503 | (int) &_binary_cons_idle_ppm_size); |
||
1555 | palkovsky | 504 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
2621 | jermar | 505 | (int) &_binary_cons_kernel_ppm_size); |
1555 | palkovsky | 506 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
1646 | palkovsky | 507 | |
508 | make_anim(); |
||
1555 | palkovsky | 509 | |
1518 | palkovsky | 510 | use_gcons = 1; |
1555 | palkovsky | 511 | console_state[0] = CONS_DISCONNECTED_SEL; |
512 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
||
1522 | palkovsky | 513 | gcons_redraw_console(); |
1518 | palkovsky | 514 | } |
1649 | cejka | 515 | |
516 | /** @} |
||
517 | */ |
||
518 |