Rev 3767 | Rev 3795 | 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 | { |
||
3707 | decky | 84 | async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp); |
1518 | palkovsky | 85 | } |
86 | |||
3793 | svoboda | 87 | static void vp_invalidate(int vp) |
88 | { |
||
89 | async_msg_1(fbphone, FB_VIEWPORT_INVALIDATE, vp); |
||
90 | } |
||
91 | |||
92 | |||
1522 | palkovsky | 93 | /** Create view port */ |
2621 | jermar | 94 | static int vp_create(unsigned int x, unsigned int y, unsigned int width, |
95 | unsigned int height) |
||
1518 | palkovsky | 96 | { |
2621 | jermar | 97 | return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, |
98 | (width << 16) | height); |
||
1518 | palkovsky | 99 | } |
100 | |||
1522 | palkovsky | 101 | static void clear(void) |
1518 | palkovsky | 102 | { |
2621 | jermar | 103 | async_msg_0(fbphone, FB_CLEAR); |
1518 | palkovsky | 104 | } |
105 | |||
3767 | svoboda | 106 | static void set_rgb_color(int fgcolor, int bgcolor) |
1518 | palkovsky | 107 | { |
3767 | svoboda | 108 | async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor); |
1518 | palkovsky | 109 | } |
110 | |||
1558 | palkovsky | 111 | /** Transparent putchar */ |
112 | static void tran_putch(char c, int row, int col) |
||
1522 | palkovsky | 113 | { |
3707 | decky | 114 | async_msg_3(fbphone, FB_PUTCHAR, c, row, col); |
1522 | palkovsky | 115 | } |
116 | |||
1558 | palkovsky | 117 | /** Redraw the button showing state of a given console */ |
1555 | palkovsky | 118 | static void redraw_state(int consnum) |
1522 | palkovsky | 119 | { |
120 | char data[5]; |
||
121 | int i; |
||
1555 | palkovsky | 122 | enum butstate state = console_state[consnum]; |
123 | |||
1522 | palkovsky | 124 | vp_switch(cstatus_vp[consnum]); |
1555 | palkovsky | 125 | if (ic_pixmaps[state] != -1) |
2025 | jermar | 126 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], |
2621 | jermar | 127 | ic_pixmaps[state]); |
1555 | palkovsky | 128 | |
2070 | jermar | 129 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && |
130 | state != CONS_DISCONNECTED_SEL) { |
||
2025 | jermar | 131 | snprintf(data, 5, "%d", consnum + 1); |
2070 | jermar | 132 | for (i = 0; data[i]; i++) |
2025 | jermar | 133 | tran_putch(data[i], 1, 2 + i); |
1555 | palkovsky | 134 | } |
1522 | palkovsky | 135 | } |
136 | |||
1555 | palkovsky | 137 | /** Notification run on changing console (except kernel console) */ |
1518 | palkovsky | 138 | void gcons_change_console(int consnum) |
139 | { |
||
1555 | palkovsky | 140 | int i; |
141 | |||
1518 | palkovsky | 142 | if (!use_gcons) |
143 | return; |
||
1552 | palkovsky | 144 | |
1555 | palkovsky | 145 | if (active_console == KERNEL_CONSOLE) { |
2025 | jermar | 146 | for (i = 0; i < CONSOLE_COUNT; i++) |
1555 | palkovsky | 147 | redraw_state(i); |
1647 | palkovsky | 148 | if (animation != -1) |
2621 | jermar | 149 | async_msg_1(fbphone, FB_ANIM_START, animation); |
1555 | palkovsky | 150 | } else { |
151 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
||
152 | console_state[active_console] = CONS_DISCONNECTED; |
||
153 | else |
||
154 | console_state[active_console] = CONS_IDLE; |
||
155 | redraw_state(active_console); |
||
156 | } |
||
1522 | palkovsky | 157 | active_console = consnum; |
1528 | palkovsky | 158 | |
1555 | palkovsky | 159 | if (console_state[consnum] == CONS_DISCONNECTED) { |
160 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
||
161 | redraw_state(consnum); |
||
162 | } else |
||
163 | console_state[consnum] = CONS_SELECTED; |
||
164 | redraw_state(consnum); |
||
165 | |||
3793 | svoboda | 166 | vp_invalidate(console_vp); |
1518 | palkovsky | 167 | vp_switch(console_vp); |
168 | } |
||
169 | |||
1552 | palkovsky | 170 | /** Notification function that gets called on new output to virtual console */ |
1518 | palkovsky | 171 | void gcons_notify_char(int consnum) |
172 | { |
||
173 | if (!use_gcons) |
||
174 | return; |
||
175 | |||
2070 | jermar | 176 | if (consnum == active_console || |
177 | console_state[consnum] == CONS_HAS_DATA) |
||
1528 | palkovsky | 178 | return; |
179 | |||
1555 | palkovsky | 180 | console_state[consnum] = CONS_HAS_DATA; |
1552 | palkovsky | 181 | |
1555 | palkovsky | 182 | if (active_console == KERNEL_CONSOLE) |
1552 | palkovsky | 183 | return; |
184 | |||
1555 | palkovsky | 185 | redraw_state(consnum); |
1528 | palkovsky | 186 | |
1518 | palkovsky | 187 | vp_switch(console_vp); |
1555 | palkovsky | 188 | } |
1552 | palkovsky | 189 | |
1592 | palkovsky | 190 | /** Notification function called on service disconnect from console */ |
191 | void gcons_notify_disconnect(int consnum) |
||
192 | { |
||
193 | if (!use_gcons) |
||
194 | return; |
||
195 | if (active_console == consnum) |
||
196 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
||
197 | else |
||
198 | console_state[consnum] = CONS_DISCONNECTED; |
||
3707 | decky | 199 | |
1592 | palkovsky | 200 | if (active_console == KERNEL_CONSOLE) |
201 | return; |
||
3707 | decky | 202 | |
1592 | palkovsky | 203 | redraw_state(consnum); |
204 | vp_switch(console_vp); |
||
205 | } |
||
206 | |||
1558 | palkovsky | 207 | /** Notification function called on console connect */ |
1555 | palkovsky | 208 | void gcons_notify_connect(int consnum) |
209 | { |
||
210 | if (!use_gcons) |
||
211 | return; |
||
212 | if (active_console == consnum) |
||
213 | console_state[consnum] = CONS_SELECTED; |
||
214 | else |
||
215 | console_state[consnum] = CONS_IDLE; |
||
216 | |||
217 | if (active_console == KERNEL_CONSOLE) |
||
218 | return; |
||
219 | |||
220 | redraw_state(consnum); |
||
221 | vp_switch(console_vp); |
||
1518 | palkovsky | 222 | } |
223 | |||
1552 | palkovsky | 224 | /** Change to kernel console */ |
225 | void gcons_in_kernel(void) |
||
226 | { |
||
1647 | palkovsky | 227 | if (animation != -1) |
2621 | jermar | 228 | async_msg_1(fbphone, FB_ANIM_STOP, animation); |
3707 | decky | 229 | |
230 | active_console = KERNEL_CONSOLE; |
||
1552 | palkovsky | 231 | vp_switch(0); |
232 | } |
||
233 | |||
1751 | palkovsky | 234 | /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */ |
1707 | palkovsky | 235 | static inline int limit(int a,int left, int right) |
236 | { |
||
237 | if (a < left) |
||
238 | a = left; |
||
239 | if (a >= right) |
||
240 | a = right - 1; |
||
241 | return a; |
||
242 | } |
||
243 | |||
1717 | palkovsky | 244 | int mouse_x, mouse_y; |
245 | int btn_pressed, btn_x, btn_y; |
||
246 | |||
247 | /** Handle mouse move |
||
248 | * |
||
249 | * @param dx Delta X of mouse move |
||
250 | * @param dy Delta Y of mouse move |
||
251 | */ |
||
1707 | palkovsky | 252 | void gcons_mouse_move(int dx, int dy) |
253 | { |
||
3670 | decky | 254 | mouse_x = limit(mouse_x + dx, 0, xres); |
255 | mouse_y = limit(mouse_y + dy, 0, yres); |
||
1707 | palkovsky | 256 | |
1717 | palkovsky | 257 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
258 | } |
||
1707 | palkovsky | 259 | |
1717 | palkovsky | 260 | static int gcons_find_conbut(int x, int y) |
261 | { |
||
3670 | decky | 262 | int status_start = STATUS_START + (xres - 800) / 2; |
1717 | palkovsky | 263 | |
2025 | jermar | 264 | if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT) |
1717 | palkovsky | 265 | return -1; |
266 | |||
267 | if (x < status_start) |
||
268 | return -1; |
||
269 | |||
2025 | jermar | 270 | if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT) |
1717 | palkovsky | 271 | return -1; |
3670 | decky | 272 | if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE) |
1717 | palkovsky | 273 | return -1; |
274 | |||
3670 | decky | 275 | return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); |
1707 | palkovsky | 276 | } |
277 | |||
1717 | palkovsky | 278 | /** Handle mouse click |
279 | * |
||
280 | * @param state New state (1-pressed, 0-depressed) |
||
281 | */ |
||
282 | int gcons_mouse_btn(int state) |
||
283 | { |
||
284 | int conbut; |
||
1707 | palkovsky | 285 | |
1717 | palkovsky | 286 | if (state) { |
287 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
||
288 | if (conbut != -1) { |
||
289 | btn_pressed = 1; |
||
290 | btn_x = mouse_x; |
||
291 | btn_y = mouse_y; |
||
292 | } |
||
293 | return -1; |
||
294 | } |
||
295 | if (!state && !btn_pressed) |
||
296 | return -1; |
||
297 | btn_pressed = 0; |
||
298 | |||
299 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
||
300 | if (conbut == gcons_find_conbut(btn_x, btn_y)) |
||
301 | return conbut; |
||
302 | return -1; |
||
303 | } |
||
304 | |||
305 | |||
1552 | palkovsky | 306 | /** Draw a PPM pixmap to framebuffer |
307 | * |
||
308 | * @param logo Pointer to PPM data |
||
309 | * @param size Size of PPM data |
||
310 | * @param x Coordinate of upper left corner |
||
311 | * @param y Coordinate of upper left corner |
||
312 | */ |
||
1547 | palkovsky | 313 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
314 | { |
||
315 | char *shm; |
||
316 | int rc; |
||
317 | |||
318 | /* Create area */ |
||
2025 | jermar | 319 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
2621 | jermar | 320 | MAP_ANONYMOUS, 0, 0); |
1547 | palkovsky | 321 | if (shm == MAP_FAILED) |
322 | return; |
||
323 | |||
324 | memcpy(shm, logo, size); |
||
325 | /* Send area */ |
||
2621 | jermar | 326 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
1547 | palkovsky | 327 | if (rc) |
328 | goto exit; |
||
2678 | jermar | 329 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
1547 | palkovsky | 330 | if (rc) |
331 | goto drop; |
||
332 | /* Draw logo */ |
||
1610 | palkovsky | 333 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
1547 | palkovsky | 334 | drop: |
335 | /* Drop area */ |
||
2621 | jermar | 336 | async_msg_0(fbphone, FB_DROP_SHM); |
1547 | palkovsky | 337 | exit: |
338 | /* Remove area */ |
||
339 | munmap(shm, size); |
||
340 | } |
||
341 | |||
342 | extern char _binary_helenos_ppm_start[0]; |
||
343 | extern int _binary_helenos_ppm_size; |
||
344 | extern char _binary_nameic_ppm_start[0]; |
||
345 | extern int _binary_nameic_ppm_size; |
||
3707 | decky | 346 | |
347 | /** Redraws console graphics */ |
||
348 | void gcons_redraw_console(void) |
||
1518 | palkovsky | 349 | { |
1522 | palkovsky | 350 | int i; |
3707 | decky | 351 | |
1518 | palkovsky | 352 | if (!use_gcons) |
353 | return; |
||
354 | |||
355 | vp_switch(0); |
||
3767 | svoboda | 356 | set_rgb_color(MAIN_COLOR, MAIN_COLOR); |
1522 | palkovsky | 357 | clear(); |
2070 | jermar | 358 | draw_pixmap(_binary_helenos_ppm_start, |
2621 | jermar | 359 | (size_t) &_binary_helenos_ppm_size, xres - 66, 2); |
2070 | jermar | 360 | draw_pixmap(_binary_nameic_ppm_start, |
2621 | jermar | 361 | (size_t) &_binary_nameic_ppm_size, 5, 17); |
3707 | decky | 362 | |
2621 | jermar | 363 | for (i = 0; i < CONSOLE_COUNT; i++) |
1555 | palkovsky | 364 | redraw_state(i); |
3793 | svoboda | 365 | vp_invalidate(console_vp); |
1518 | palkovsky | 366 | vp_switch(console_vp); |
367 | } |
||
368 | |||
1558 | palkovsky | 369 | /** Creates a pixmap on framebuffer |
370 | * |
||
371 | * @param data PPM data |
||
372 | * @param size PPM data size |
||
373 | * @return Pixmap identification |
||
374 | */ |
||
1555 | palkovsky | 375 | static int make_pixmap(char *data, int size) |
376 | { |
||
377 | char *shm; |
||
378 | int rc; |
||
379 | int pxid = -1; |
||
380 | |||
381 | /* Create area */ |
||
2025 | jermar | 382 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
2621 | jermar | 383 | MAP_ANONYMOUS, 0, 0); |
1555 | palkovsky | 384 | if (shm == MAP_FAILED) |
385 | return -1; |
||
386 | |||
387 | memcpy(shm, data, size); |
||
388 | /* Send area */ |
||
2621 | jermar | 389 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
1555 | palkovsky | 390 | if (rc) |
391 | goto exit; |
||
2678 | jermar | 392 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
1555 | palkovsky | 393 | if (rc) |
394 | goto drop; |
||
395 | |||
396 | /* Obtain pixmap */ |
||
2621 | jermar | 397 | rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); |
1555 | palkovsky | 398 | if (rc < 0) |
399 | goto drop; |
||
400 | pxid = rc; |
||
401 | drop: |
||
402 | /* Drop area */ |
||
2621 | jermar | 403 | async_msg_0(fbphone, FB_DROP_SHM); |
1555 | palkovsky | 404 | exit: |
405 | /* Remove area */ |
||
406 | munmap(shm, size); |
||
407 | |||
408 | return pxid; |
||
409 | } |
||
410 | |||
1646 | palkovsky | 411 | extern char _binary_anim_1_ppm_start[0]; |
412 | extern int _binary_anim_1_ppm_size; |
||
413 | extern char _binary_anim_2_ppm_start[0]; |
||
414 | extern int _binary_anim_2_ppm_size; |
||
415 | extern char _binary_anim_3_ppm_start[0]; |
||
416 | extern int _binary_anim_3_ppm_size; |
||
417 | extern char _binary_anim_4_ppm_start[0]; |
||
418 | extern int _binary_anim_4_ppm_size; |
||
2025 | jermar | 419 | |
1646 | palkovsky | 420 | static void make_anim(void) |
421 | { |
||
422 | int an; |
||
423 | int pm; |
||
424 | |||
2621 | jermar | 425 | an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
1646 | palkovsky | 426 | if (an < 0) |
427 | return; |
||
428 | |||
2070 | jermar | 429 | pm = make_pixmap(_binary_anim_1_ppm_start, |
2621 | jermar | 430 | (int) &_binary_anim_1_ppm_size); |
1646 | palkovsky | 431 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
432 | |||
2070 | jermar | 433 | pm = make_pixmap(_binary_anim_2_ppm_start, |
2621 | jermar | 434 | (int) &_binary_anim_2_ppm_size); |
1646 | palkovsky | 435 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
436 | |||
2070 | jermar | 437 | pm = make_pixmap(_binary_anim_3_ppm_start, |
2621 | jermar | 438 | (int) &_binary_anim_3_ppm_size); |
1646 | palkovsky | 439 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
440 | |||
2070 | jermar | 441 | pm = make_pixmap(_binary_anim_4_ppm_start, |
2621 | jermar | 442 | (int) &_binary_anim_4_ppm_size); |
1646 | palkovsky | 443 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
444 | |||
2621 | jermar | 445 | async_msg_1(fbphone, FB_ANIM_START, an); |
1646 | palkovsky | 446 | |
447 | animation = an; |
||
448 | } |
||
449 | |||
1555 | palkovsky | 450 | extern char _binary_cons_selected_ppm_start[0]; |
451 | extern int _binary_cons_selected_ppm_size; |
||
452 | extern char _binary_cons_idle_ppm_start[0]; |
||
453 | extern int _binary_cons_idle_ppm_size; |
||
454 | extern char _binary_cons_has_data_ppm_start[0]; |
||
455 | extern int _binary_cons_has_data_ppm_size; |
||
456 | extern char _binary_cons_kernel_ppm_start[0]; |
||
457 | extern int _binary_cons_kernel_ppm_size; |
||
2025 | jermar | 458 | |
1518 | palkovsky | 459 | /** Initialize nice graphical console environment */ |
460 | void gcons_init(int phone) |
||
461 | { |
||
462 | int rc; |
||
463 | int i; |
||
1646 | palkovsky | 464 | int status_start = STATUS_START; |
3707 | decky | 465 | |
1518 | palkovsky | 466 | fbphone = phone; |
3707 | decky | 467 | |
2621 | jermar | 468 | rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); |
1518 | palkovsky | 469 | if (rc) |
470 | return; |
||
471 | |||
3707 | decky | 472 | if ((xres < 800) || (yres < 600)) |
1518 | palkovsky | 473 | return; |
3707 | decky | 474 | |
1518 | palkovsky | 475 | /* create console viewport */ |
1555 | palkovsky | 476 | /* Align width & height to character size */ |
2070 | jermar | 477 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
2621 | jermar | 478 | ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8), |
479 | ALIGN_DOWN(yres - (CONSOLE_TOP + CONSOLE_MARGIN), 16)); |
||
1518 | palkovsky | 480 | if (console_vp < 0) |
481 | return; |
||
482 | |||
483 | /* Create status buttons */ |
||
2025 | jermar | 484 | status_start += (xres - 800) / 2; |
485 | for (i = 0; i < CONSOLE_COUNT; i++) { |
||
2070 | jermar | 486 | cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN + |
2621 | jermar | 487 | i * (STATUS_WIDTH + STATUS_SPACE), STATUS_TOP, |
488 | STATUS_WIDTH, STATUS_HEIGHT); |
||
1518 | palkovsky | 489 | if (cstatus_vp[i] < 0) |
490 | return; |
||
1555 | palkovsky | 491 | vp_switch(cstatus_vp[i]); |
3767 | svoboda | 492 | set_rgb_color(0x202020, 0xffffff); |
1518 | palkovsky | 493 | } |
494 | |||
1555 | palkovsky | 495 | /* Initialize icons */ |
2025 | jermar | 496 | ic_pixmaps[CONS_SELECTED] = |
2621 | jermar | 497 | make_pixmap(_binary_cons_selected_ppm_start, |
498 | (int) &_binary_cons_selected_ppm_size); |
||
2070 | jermar | 499 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
2621 | jermar | 500 | (int) &_binary_cons_idle_ppm_size); |
2025 | jermar | 501 | ic_pixmaps[CONS_HAS_DATA] = |
2621 | jermar | 502 | make_pixmap(_binary_cons_has_data_ppm_start, |
503 | (int) &_binary_cons_has_data_ppm_size); |
||
2025 | jermar | 504 | ic_pixmaps[CONS_DISCONNECTED] = |
2621 | jermar | 505 | make_pixmap(_binary_cons_idle_ppm_start, |
506 | (int) &_binary_cons_idle_ppm_size); |
||
1555 | palkovsky | 507 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
2621 | jermar | 508 | (int) &_binary_cons_kernel_ppm_size); |
1555 | palkovsky | 509 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
1646 | palkovsky | 510 | |
511 | make_anim(); |
||
3707 | decky | 512 | |
1518 | palkovsky | 513 | use_gcons = 1; |
1555 | palkovsky | 514 | console_state[0] = CONS_DISCONNECTED_SEL; |
515 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
||
1522 | palkovsky | 516 | gcons_redraw_console(); |
1518 | palkovsky | 517 | } |
3707 | decky | 518 | |
1649 | cejka | 519 | /** @} |
520 | */ |