Rev 4264 | Rev 4515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4264 | Rev 4488 | ||
---|---|---|---|
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 <console.h> |
53 | #include <vfs/vfs.h> |
54 | - | ||
55 | #include <async.h> |
54 | #include <async.h> |
56 | #include "screen.h" |
55 | #include "screen.h" |
57 | #include "tetris.h" |
56 | #include "tetris.h" |
58 | #include <ipc/console.h> |
57 | #include <io/console.h> |
59 | 58 | ||
60 | static cell curscreen[B_SIZE]; /* 1 => standout (or otherwise marked) */ |
59 | static cell curscreen[B_SIZE]; /* 1 => standout (or otherwise marked) */ |
61 | static int curscore; |
60 | static int curscore; |
62 | static int isset; /* true => terminal is in game mode */ |
61 | static int isset; /* true => terminal is in game mode */ |
63 | 62 | ||
64 | 63 | ||
65 | /* |
64 | /* |
66 | * putstr() is for unpadded strings (either as in termcap(5) or |
65 | * putstr() is for unpadded strings (either as in termcap(5) or |
67 | * simply literal strings); |
66 | * simply literal strings); |
68 | */ |
67 | */ |
69 | static inline void putstr(char *s) |
68 | static inline void putstr(char *s) |
70 | { |
69 | { |
71 | while (*s) |
70 | while (*s) |
72 | putchar(*(s++)); |
71 | putchar(*(s++)); |
73 | } |
72 | } |
74 | 73 | ||
75 | static void start_standout(void) |
74 | static void start_standout(void) |
76 | { |
75 | { |
77 | console_set_rgb_color(0xf0f0f0, 0); |
76 | console_set_rgb_color(fphone(stdout), 0xf0f0f0, 0); |
78 | } |
77 | } |
79 | 78 | ||
80 | static void resume_normal(void) |
79 | static void resume_normal(void) |
81 | { |
80 | { |
82 | console_set_rgb_color(0, 0xf0f0f0); |
81 | console_set_rgb_color(fphone(stdout), 0, 0xf0f0f0); |
83 | } |
82 | } |
84 | 83 | ||
85 | void clear_screen(void) |
84 | void clear_screen(void) |
86 | { |
85 | { |
87 | console_clear(); |
86 | console_clear(fphone(stdout)); |
88 | moveto(0, 0); |
87 | moveto(0, 0); |
89 | } |
88 | } |
90 | 89 | ||
91 | /* |
90 | /* |
92 | * Clear the screen, forgetting the current contents in the process. |
91 | * Clear the screen, forgetting the current contents in the process. |
Line 94... | Line 93... | ||
94 | void |
93 | void |
95 | scr_clear(void) |
94 | scr_clear(void) |
96 | { |
95 | { |
97 | 96 | ||
98 | resume_normal(); |
97 | resume_normal(); |
99 | console_clear(); |
98 | console_clear(fphone(stdout)); |
100 | curscore = -1; |
99 | curscore = -1; |
101 | memset((char *)curscreen, 0, sizeof(curscreen)); |
100 | memset((char *)curscreen, 0, sizeof(curscreen)); |
102 | } |
101 | } |
103 | 102 | ||
104 | /* |
103 | /* |
105 | * Set up screen |
104 | * Set up screen |
106 | */ |
105 | */ |
107 | void |
106 | void |
108 | scr_init(void) |
107 | scr_init(void) |
109 | { |
108 | { |
110 | console_cursor_visibility(0); |
109 | console_cursor_visibility(fphone(stdout), 0); |
111 | resume_normal(); |
110 | resume_normal(); |
112 | scr_clear(); |
111 | scr_clear(); |
113 | } |
112 | } |
114 | 113 | ||
115 | void moveto(int r, int c) |
114 | void moveto(int r, int c) |
116 | { |
115 | { |
117 | console_goto(r, c); |
116 | console_goto(fphone(stdout), c, r); |
118 | } |
117 | } |
119 | 118 | ||
120 | winsize_t winsize; |
119 | winsize_t winsize; |
121 | 120 | ||
122 | static int get_display_size(winsize_t *ws) |
121 | static int get_display_size(winsize_t *ws) |
123 | { |
122 | { |
124 | return console_get_size(&ws->ws_row, &ws->ws_col); |
123 | return console_get_size(fphone(stdout), &ws->ws_col, &ws->ws_row); |
125 | } |
124 | } |
126 | 125 | ||
127 | /* |
126 | /* |
128 | * Set up screen mode. |
127 | * Set up screen mode. |
129 | */ |
128 | */ |