diff options
| -rw-r--r-- | uisimulator/app.c | 18 | ||||
| -rw-r--r-- | uisimulator/tetris.c | 8 |
2 files changed, 19 insertions, 7 deletions
diff --git a/uisimulator/app.c b/uisimulator/app.c index d3e1b8e..9df7863 100644 --- a/uisimulator/app.c +++ b/uisimulator/app.c @@ -33,16 +33,26 @@ #define MAX_LINE 3 /* the last index with info, starting on 0 */ -void app_main(void) +/* global cursor */ +int cursor = 0; + +void menu_init(void) { - lcd_puts(0, 0, "-Rockabox", 0); + lcd_puts(6, 0, "Rockabox", 0); lcd_puts(6, 8, "Boxrock", 0); lcd_puts(6, 16, "Robkoxx", 0); lcd_puts(6, 24, "Tetris", 0); lcd_puts(8, 38, "Rockbox!", 2); - int cursor = 0; + + lcd_puts(0, cursor, "-", 0); +} + +void app_main(void) +{ int key; + menu_init(); + while(1) { key = button_get(); @@ -65,6 +75,8 @@ void app_main(void) if(cursor == (MAX_LINE * LINE_HEIGHT)) { lcd_clearrect(0, 0, LCD_WIDTH, LCD_HEIGHT); tetris(); + lcd_clearrect(0, 0, LCD_WIDTH, LCD_HEIGHT); + menu_init(); } break; } diff --git a/uisimulator/tetris.c b/uisimulator/tetris.c index d49cbec..e18474a 100644 --- a/uisimulator/tetris.c +++ b/uisimulator/tetris.c @@ -253,20 +253,19 @@ void game_loop(void) /* while(count*20 < level_speeds[level]) */ { b = button_get(); + if ( b & BUTTON_OFF ) + return; /* get out of here */ + if ( b & BUTTON_LEFT ) { - printf("Left\n"); move_block(-1,0,0); } if ( b & BUTTON_RIGHT ) { - printf("Right\n"); move_block(1,0,0); } if ( b & BUTTON_UP ) { - printf("Up\n"); move_block(0,0,1); } if ( b & BUTTON_DOWN ) { - printf("Down\n"); move_down(); } count++; @@ -279,6 +278,7 @@ void game_loop(void) void tetris(void) { draw_frame(start_x-1,start_x+max_x,start_y-1,start_y+max_y); + lcd_puts(10, 32, "Tetris!", 2); lcd_update(); next_b = rand(blocks); |