diff options
author | Robert Hak <adiamas@rockbox.org> | 2002-10-29 10:45:29 +0000 |
---|---|---|
committer | Robert Hak <adiamas@rockbox.org> | 2002-10-29 10:45:29 +0000 |
commit | 8f11dc00ac1a0a5fe009d1d07d9a1378c3300ba8 (patch) | |
tree | 759d57e1894de9f86f324fcb54d0b089e2b9eb8c /apps/recorder/tetris.c | |
parent | dae8deaf1f4ce56158e9385844885f7b9faa9a42 (diff) | |
download | rockbox-8f11dc00ac1a0a5fe009d1d07d9a1378c3300ba8.tar.gz rockbox-8f11dc00ac1a0a5fe009d1d07d9a1378c3300ba8.zip |
usb detection in bounce, and all files use default font (not loaded)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2773 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/tetris.c')
-rw-r--r-- | apps/recorder/tetris.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/apps/recorder/tetris.c b/apps/recorder/tetris.c index 9c706e9c8e..6302e40109 100644 --- a/apps/recorder/tetris.c +++ b/apps/recorder/tetris.c | |||
@@ -25,12 +25,13 @@ | |||
25 | #ifdef USE_GAMES | 25 | #ifdef USE_GAMES |
26 | 26 | ||
27 | #include <stdbool.h> | 27 | #include <stdbool.h> |
28 | #include <string.h> | ||
28 | #include "lcd.h" | 29 | #include "lcd.h" |
29 | #include "button.h" | 30 | #include "button.h" |
30 | #include "kernel.h" | 31 | #include "kernel.h" |
31 | #include <string.h> | ||
32 | #include "menu.h" | 32 | #include "menu.h" |
33 | #include "screens.h" | 33 | #include "screens.h" |
34 | #include "font.h" | ||
34 | 35 | ||
35 | #ifdef SIMULATOR | 36 | #ifdef SIMULATOR |
36 | #include <stdio.h> | 37 | #include <stdio.h> |
@@ -46,7 +47,9 @@ static const int start_x = 5; | |||
46 | static const int start_y = 5; | 47 | static const int start_y = 5; |
47 | static const int max_x = 4 * 17; | 48 | static const int max_x = 4 * 17; |
48 | static const int max_y = 3 * 10; | 49 | static const int max_y = 3 * 10; |
49 | static const short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200}; | 50 | static const short level_speeds[10] = { |
51 | 1000, 900, 800, 700, 600, 500, 400, 300, 250, 200 | ||
52 | }; | ||
50 | static const int blocks = 7; | 53 | static const int blocks = 7; |
51 | static const int block_frames[7] = {1,2,2,2,4,4,4}; | 54 | static const int block_frames[7] = {1,2,2,2,4,4,4}; |
52 | 55 | ||
@@ -147,14 +150,15 @@ static void draw_block(int x, int y, int block, int frame, bool clear) | |||
147 | 150 | ||
148 | static void to_virtual(void) | 151 | static void to_virtual(void) |
149 | { | 152 | { |
150 | int i,a,b; | 153 | int i, a, b; |
151 | 154 | ||
152 | for(i = 0; i < 4; i++) | 155 | for(i = 0; i < 4; i++) |
153 | for (a = 0; a < 3; a++) | 156 | for (a = 0; a < 3; a++) |
154 | for (b = 0; b < 4; b++) | 157 | for (b = 0; b < 4; b++) |
155 | *(virtual + | 158 | *(virtual + |
156 | (current_y + block_data[current_b][current_f][0][i] * 3 + a) * max_x + | 159 | (current_y + block_data[current_b][current_f][0][i] * 3 + a) * |
157 | current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1; | 160 | max_x + current_x + block_data[current_b][current_f][1][i] * |
161 | 4 - b) = current_b + 1; | ||
158 | } | 162 | } |
159 | 163 | ||
160 | static bool block_touch (int x, int y) | 164 | static bool block_touch (int x, int y) |
@@ -179,7 +183,8 @@ static bool gameover(void) | |||
179 | 183 | ||
180 | for(i = 0; i < 4; i++){ | 184 | for(i = 0; i < 4; i++){ |
181 | /* Do we have blocks touching? */ | 185 | /* Do we have blocks touching? */ |
182 | if(block_touch(x + block_data[block][frame][1][i] * 4, y + block_data[block][frame][0][i] * 3)) | 186 | if(block_touch(x + block_data[block][frame][1][i] * 4, |
187 | y + block_data[block][frame][0][i] * 3)) | ||
183 | { | 188 | { |
184 | /* Are we at the top of the frame? */ | 189 | /* Are we at the top of the frame? */ |
185 | if(x + block_data[block][frame][1][i] * 4 >= max_x - 16) | 190 | if(x + block_data[block][frame][1][i] * 4 >= max_x - 16) |
@@ -200,8 +205,11 @@ static bool valid_position(int x, int y, int block, int frame) | |||
200 | (x + block_data[block][frame][1][i] * 4 > max_x - 4) || | 205 | (x + block_data[block][frame][1][i] * 4 > max_x - 4) || |
201 | (y + block_data[block][frame][0][i] * 3 < 0) || | 206 | (y + block_data[block][frame][0][i] * 3 < 0) || |
202 | (x + block_data[block][frame][1][i] * 4 < 4) || | 207 | (x + block_data[block][frame][1][i] * 4 < 4) || |
203 | block_touch (x + block_data[block][frame][1][i] * 4, y + block_data[block][frame][0][i] * 3)) | 208 | block_touch (x + block_data[block][frame][1][i] * 4, |
209 | y + block_data[block][frame][0][i] * 3)) | ||
210 | { | ||
204 | return false; | 211 | return false; |
212 | } | ||
205 | return true; | 213 | return true; |
206 | } | 214 | } |
207 | 215 | ||
@@ -290,7 +298,7 @@ static int check_lines(void) | |||
290 | /* move rows down */ | 298 | /* move rows down */ |
291 | for(i = x; i < max_x - 1; i++) | 299 | for(i = x; i < max_x - 1; i++) |
292 | for (j = 0; j < max_y; j++) | 300 | for (j = 0; j < max_y; j++) |
293 | *(virtual + j * max_x + i) = *(virtual + j * max_x + (i + 1)); | 301 | *(virtual + j * max_x + i)=*(virtual + j * max_x + (i + 1)); |
294 | 302 | ||
295 | x--; /* re-check this line */ | 303 | x--; /* re-check this line */ |
296 | } | 304 | } |
@@ -402,6 +410,10 @@ static void init_tetris(void) | |||
402 | bool tetris(void) | 410 | bool tetris(void) |
403 | { | 411 | { |
404 | char buf[20]; | 412 | char buf[20]; |
413 | bool val; | ||
414 | |||
415 | /* Lets use the default font */ | ||
416 | lcd_setfont(FONT_SYSFIXED); | ||
405 | 417 | ||
406 | init_tetris(); | 418 | init_tetris(); |
407 | 419 | ||
@@ -413,7 +425,14 @@ bool tetris(void) | |||
413 | next_b = t_rand(blocks); | 425 | next_b = t_rand(blocks); |
414 | next_f = t_rand(block_frames[next_b]); | 426 | next_f = t_rand(block_frames[next_b]); |
415 | new_block(); | 427 | new_block(); |
416 | return game_loop(); | 428 | val = game_loop(); |
429 | |||
430 | lcd_setfont(FONT_UI); | ||
431 | |||
432 | return val; | ||
417 | } | 433 | } |
418 | 434 | ||
419 | #endif | 435 | #endif |
436 | |||
437 | |||
438 | |||