Rev 3767 | Rev 4164 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3767 | Rev 3768 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | #include <err.h> |
48 | #include <err.h> |
49 | #include <stdio.h> |
49 | #include <stdio.h> |
50 | #include <stdlib.h> |
50 | #include <stdlib.h> |
51 | #include <string.h> |
51 | #include <string.h> |
52 | #include <unistd.h> |
52 | #include <unistd.h> |
53 | #include <io/stream.h> |
- | |
54 | #include <console.h> |
53 | #include <console.h> |
55 | 54 | ||
56 | #include <async.h> |
55 | #include <async.h> |
57 | #include "screen.h" |
56 | #include "screen.h" |
58 | #include "tetris.h" |
57 | #include "tetris.h" |
Line 71... | Line 70... | ||
71 | { |
70 | { |
72 | while (*s) |
71 | while (*s) |
73 | putchar(*(s++)); |
72 | putchar(*(s++)); |
74 | } |
73 | } |
75 | 74 | ||
76 | static int con_phone; |
- | |
77 | - | ||
78 | - | ||
79 | static void start_standout(void) |
75 | static void start_standout(void) |
80 | { |
76 | { |
81 | console_set_rgb_color(0xf0f0f0, 0); |
77 | console_set_rgb_color(0xf0f0f0, 0); |
82 | } |
78 | } |
83 | 79 | ||
Line 86... | Line 82... | ||
86 | console_set_rgb_color(0, 0xf0f0f0); |
82 | console_set_rgb_color(0, 0xf0f0f0); |
87 | } |
83 | } |
88 | 84 | ||
89 | void clear_screen(void) |
85 | void clear_screen(void) |
90 | { |
86 | { |
91 | async_msg_0(con_phone, CONSOLE_CLEAR); |
87 | console_clear(); |
92 | moveto(0, 0); |
88 | moveto(0, 0); |
93 | } |
89 | } |
94 | 90 | ||
95 | /* |
91 | /* |
96 | * Clear the screen, forgetting the current contents in the process. |
92 | * Clear the screen, forgetting the current contents in the process. |
Line 98... | Line 94... | ||
98 | void |
94 | void |
99 | scr_clear(void) |
95 | scr_clear(void) |
100 | { |
96 | { |
101 | 97 | ||
102 | resume_normal(); |
98 | resume_normal(); |
103 | async_msg_0(con_phone, CONSOLE_CLEAR); |
99 | console_clear(); |
104 | curscore = -1; |
100 | curscore = -1; |
105 | memset((char *)curscreen, 0, sizeof(curscreen)); |
101 | memset((char *)curscreen, 0, sizeof(curscreen)); |
106 | } |
102 | } |
107 | 103 | ||
108 | /* |
104 | /* |
109 | * Set up screen |
105 | * Set up screen |
110 | */ |
106 | */ |
111 | void |
107 | void |
112 | scr_init(void) |
108 | scr_init(void) |
113 | { |
109 | { |
114 | con_phone = get_cons_phone(); |
110 | console_cursor_visibility(0); |
115 | async_msg_1(con_phone, CONSOLE_CURSOR_VISIBILITY, 0); |
- | |
116 | resume_normal(); |
111 | resume_normal(); |
117 | scr_clear(); |
112 | scr_clear(); |
118 | } |
113 | } |
119 | 114 | ||
120 | void moveto(int r, int c) |
115 | void moveto(int r, int c) |
121 | { |
116 | { |
122 | async_msg_2(con_phone, CONSOLE_GOTO, r, c); |
117 | console_goto(r, c); |
123 | } |
118 | } |
124 | 119 | ||
125 | static void fflush(void) |
120 | static void fflush(void) |
126 | { |
121 | { |
127 | async_msg_0(con_phone, CONSOLE_FLUSH); |
122 | console_flush(); |
128 | } |
123 | } |
129 | 124 | ||
130 | winsize_t winsize; |
125 | winsize_t winsize; |
131 | 126 | ||
132 | static int get_display_size(winsize_t *ws) |
127 | static int get_display_size(winsize_t *ws) |
133 | { |
128 | { |
134 | return async_req_0_2(con_phone, CONSOLE_GETSIZE, &ws->ws_row, |
129 | return console_get_size(&ws->ws_row, &ws->ws_col); |
135 | &ws->ws_col); |
- | |
136 | } |
130 | } |
137 | 131 | ||
138 | /* |
132 | /* |
139 | * Set up screen mode. |
133 | * Set up screen mode. |
140 | */ |
134 | */ |