Rev 3022 | Rev 4201 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3022 | Rev 4055 | ||
---|---|---|---|
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> |
53 | #include <console.h> |
54 | - | ||
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" |
59 | #include "../../srv/console/console.h" |
58 | #include <ipc/console.h> |
60 | 59 | ||
61 | static cell curscreen[B_SIZE]; /* 1 => standout (or otherwise marked) */ |
60 | static cell curscreen[B_SIZE]; /* 1 => standout (or otherwise marked) */ |
62 | static int curscore; |
61 | static int curscore; |
63 | static int isset; /* true => terminal is in game mode */ |
62 | static int isset; /* true => terminal is in game mode */ |
64 | 63 | ||
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 | - | ||
80 | static void set_style(int fgcolor, int bgcolor) |
- | |
81 | { |
- | |
82 | async_msg_2(con_phone, CONSOLE_SET_STYLE, fgcolor, bgcolor); |
- | |
83 | } |
- | |
84 | - | ||
85 | static void start_standout(void) |
75 | static void start_standout(void) |
86 | { |
76 | { |
87 | set_style(0xf0f0f0, 0); |
77 | console_set_rgb_color(0xf0f0f0, 0); |
88 | } |
78 | } |
89 | 79 | ||
90 | static void resume_normal(void) |
80 | static void resume_normal(void) |
91 | { |
81 | { |
92 | set_style(0, 0xf0f0f0); |
82 | console_set_rgb_color(0, 0xf0f0f0); |
93 | } |
83 | } |
94 | 84 | ||
95 | - | ||
96 | void clear_screen(void) |
85 | void clear_screen(void) |
97 | { |
86 | { |
98 | async_msg_0(con_phone, CONSOLE_CLEAR); |
87 | console_clear(); |
99 | moveto(0, 0); |
88 | moveto(0, 0); |
100 | } |
89 | } |
101 | 90 | ||
102 | /* |
91 | /* |
103 | * Clear the screen, forgetting the current contents in the process. |
92 | * Clear the screen, forgetting the current contents in the process. |
Line 105... | Line 94... | ||
105 | void |
94 | void |
106 | scr_clear(void) |
95 | scr_clear(void) |
107 | { |
96 | { |
108 | 97 | ||
109 | resume_normal(); |
98 | resume_normal(); |
110 | async_msg_0(con_phone, CONSOLE_CLEAR); |
99 | console_clear(); |
111 | curscore = -1; |
100 | curscore = -1; |
112 | memset((char *)curscreen, 0, sizeof(curscreen)); |
101 | memset((char *)curscreen, 0, sizeof(curscreen)); |
113 | } |
102 | } |
114 | 103 | ||
115 | /* |
104 | /* |
116 | * Set up screen |
105 | * Set up screen |
117 | */ |
106 | */ |
118 | void |
107 | void |
119 | scr_init(void) |
108 | scr_init(void) |
120 | { |
109 | { |
121 | con_phone = get_cons_phone(); |
110 | console_cursor_visibility(0); |
122 | async_msg_1(con_phone, CONSOLE_CURSOR_VISIBILITY, 0); |
- | |
123 | resume_normal(); |
111 | resume_normal(); |
124 | scr_clear(); |
112 | scr_clear(); |
125 | } |
113 | } |
126 | 114 | ||
127 | void moveto(int r, int c) |
115 | void moveto(int r, int c) |
128 | { |
116 | { |
129 | async_msg_2(con_phone, CONSOLE_GOTO, r, c); |
117 | console_goto(r, c); |
130 | } |
118 | } |
131 | 119 | ||
132 | static void fflush(void) |
120 | static void fflush(void) |
133 | { |
121 | { |
134 | async_msg_0(con_phone, CONSOLE_FLUSH); |
122 | console_flush(); |
135 | } |
123 | } |
136 | 124 | ||
137 | winsize_t winsize; |
125 | winsize_t winsize; |
138 | 126 | ||
139 | static int get_display_size(winsize_t *ws) |
127 | static int get_display_size(winsize_t *ws) |
140 | { |
128 | { |
141 | return async_req_0_2(con_phone, CONSOLE_GETSIZE, &ws->ws_row, |
129 | return console_get_size(&ws->ws_row, &ws->ws_col); |
142 | &ws->ws_col); |
- | |
143 | } |
130 | } |
144 | 131 | ||
145 | /* |
132 | /* |
146 | * Set up screen mode. |
133 | * Set up screen mode. |
147 | */ |
134 | */ |