summaryrefslogtreecommitdiffstats
path: root/apps/recorder
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-09-24 17:22:12 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-09-24 17:22:12 +0000
commitb1b8bd4dd159e90f9e197c8870953da079162639 (patch)
tree27238f1b5a1535de0604e423ca91236bb3e2f833 /apps/recorder
parentc909b4b42e88a8e797e58a5e3e5ecf3716ae4783 (diff)
downloadrockbox-b1b8bd4dd159e90f9e197c8870953da079162639.tar.gz
rockbox-b1b8bd4dd159e90f9e197c8870953da079162639.tar.bz2
rockbox-b1b8bd4dd159e90f9e197c8870953da079162639.zip
Moved on_screen, f2_screen, f3_screen and handle_usb (renamed usb_screen) to a new file: screens.c.
typedef Menu replaced with a bool. All code now calls usb_screen() for usb handling. Nearly all code now deals with USB connect/disconnect properly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2401 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/snake.c4
-rw-r--r--apps/recorder/sokoban.c31
-rw-r--r--apps/recorder/sokoban.h5
-rw-r--r--apps/recorder/tetris.c79
-rw-r--r--apps/recorder/wormlet.c9
-rw-r--r--apps/recorder/wormlet.h2
6 files changed, 75 insertions, 55 deletions
diff --git a/apps/recorder/snake.c b/apps/recorder/snake.c
index 8c14527bd5..736d08dbd7 100644
--- a/apps/recorder/snake.c
+++ b/apps/recorder/snake.c
@@ -257,10 +257,10 @@ void game_init(void) {
}
-Menu snake(void) {
+bool snake(void) {
game_init();
lcd_clear_display();
game();
- return MENU_OK;
+ return false;
}
diff --git a/apps/recorder/sokoban.c b/apps/recorder/sokoban.c
index bec556054a..3e5d447ae9 100644
--- a/apps/recorder/sokoban.c
+++ b/apps/recorder/sokoban.c
@@ -27,6 +27,7 @@
#include "button.h"
#include "kernel.h"
#include "menu.h"
+#include "screens.h"
#ifdef SIMULATOR
#include <stdio.h>
@@ -37,6 +38,10 @@
#define SOKOBAN_TITLE_FONT 2
#define NUM_LEVELS sizeof(levels)/320
+static void load_level(int);
+static void update_screen(void);
+static bool sokoban_loop(void);
+
static char board[16][20];
static int current_level=0;
static int moves=0;
@@ -1766,7 +1771,7 @@ static const char levels[][320] = {
};
-void load_level (int level_to_load) {
+static void load_level (int level_to_load) {
int a = 0;
int b = 0;
int c = 0;
@@ -1790,7 +1795,7 @@ void load_level (int level_to_load) {
return;
}
-void update_screen(void) {
+static void update_screen(void) {
int b = 0;
int c = 0;
char s[25];
@@ -1855,7 +1860,8 @@ void update_screen(void) {
-void sokoban_loop(void) {
+static bool sokoban_loop(void)
+{
int ii = 0;
moves = 0;
current_level = 0;
@@ -1868,7 +1874,7 @@ void sokoban_loop(void) {
case BUTTON_OFF:
/* get out of here */
- return;
+ return false;
case BUTTON_F3:
/* increase level */
@@ -2170,6 +2176,10 @@ void sokoban_loop(void) {
row++;
break;
+ case SYS_USB_CONNECTED:
+ usb_screen();
+ return true;
+
default:
idle = true;
break;
@@ -2192,20 +2202,23 @@ void sokoban_loop(void) {
lcd_invertrect(0,0,111,63);
lcd_update();
if ( button_get(false) )
- return;
+ return false;
}
- return;
+ return false;
}
load_level(current_level);
lcd_clear_display();
update_screen();
}
}
+
+ return false;
}
-Menu sokoban(void)
+bool sokoban(void)
{
+ bool result;
int w, h;
int len = strlen(SOKOBAN_TITLE);
@@ -2240,9 +2253,9 @@ Menu sokoban(void)
lcd_update();
sleep(HZ*2);
lcd_clear_display();
- sokoban_loop();
+ result = sokoban_loop();
- return MENU_OK;
+ return result;
}
#endif
diff --git a/apps/recorder/sokoban.h b/apps/recorder/sokoban.h
index ee1398c011..f4f8fdd24f 100644
--- a/apps/recorder/sokoban.h
+++ b/apps/recorder/sokoban.h
@@ -22,10 +22,7 @@
#include "menu.h"
-void load_level(int);
-void update_screen(void);
-void sokoban_loop(void);
-Menu sokoban(void);
+bool sokoban(void);
#endif /*__SOKOBAN__ */
diff --git a/apps/recorder/tetris.c b/apps/recorder/tetris.c
index 2455f269b3..5264b8e789 100644
--- a/apps/recorder/tetris.c
+++ b/apps/recorder/tetris.c
@@ -30,6 +30,7 @@
#include "kernel.h"
#include <string.h>
#include "menu.h"
+#include "screens.h"
#ifdef SIMULATOR
#include <stdio.h>
@@ -106,12 +107,12 @@ static const char block_data[7][4][2][4] =
}
};
-int t_rand(int range)
+static int t_rand(int range)
{
return current_tick % range;
}
-void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
+static void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
{
lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y);
lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y);
@@ -123,7 +124,7 @@ void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1);
}
-void draw_block(int x, int y, int block, int frame, bool clear)
+static void draw_block(int x, int y, int block, int frame, bool clear)
{
int i, a, b;
for(i=0;i < 4;i++) {
@@ -144,7 +145,7 @@ void draw_block(int x, int y, int block, int frame, bool clear)
}
}
-void to_virtual(void)
+static void to_virtual(void)
{
int i,a,b;
@@ -156,7 +157,7 @@ void to_virtual(void)
current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1;
}
-bool block_touch (int x, int y)
+static bool block_touch (int x, int y)
{
int a,b;
for (a = 0; a < 4; a++)
@@ -166,7 +167,7 @@ bool block_touch (int x, int y)
return false;
}
-bool gameover(void)
+static bool gameover(void)
{
int i;
int frame, block, y, x;
@@ -191,7 +192,7 @@ bool gameover(void)
return false;
}
-bool valid_position(int x, int y, int block, int frame)
+static bool valid_position(int x, int y, int block, int frame)
{
int i;
for(i=0;i < 4;i++)
@@ -204,7 +205,7 @@ bool valid_position(int x, int y, int block, int frame)
return true;
}
-void from_virtual(void)
+static void from_virtual(void)
{
int x,y;
for(y = 0; y < max_y; y++)
@@ -215,7 +216,7 @@ void from_virtual(void)
lcd_clearpixel(start_x + x, start_y + y);
}
-void move_block(int x,int y,int f)
+static void move_block(int x,int y,int f)
{
int last_frame = current_f;
if(f != 0)
@@ -239,7 +240,7 @@ void move_block(int x,int y,int f)
current_f = last_frame;
}
-void new_block(void)
+static void new_block(void)
{
current_b = next_b;
current_f = next_f;
@@ -266,7 +267,7 @@ void new_block(void)
draw_block(current_x, current_y, current_b, current_f, false);
}
-int check_lines(void)
+static int check_lines(void)
{
int x,y,i,j;
bool line;
@@ -298,7 +299,7 @@ int check_lines(void)
return lines / 4;
}
-void move_down(void)
+static void move_down(void)
{
int l;
char s[25];
@@ -327,7 +328,7 @@ void move_down(void)
move_block(-4,0,0);
}
-void game_loop(void)
+static bool game_loop(void)
{
while(1)
{
@@ -336,28 +337,32 @@ void game_loop(void)
{
switch(button_get_w_tmo(HZ/10))
{
- case BUTTON_OFF:
- return;
+ case BUTTON_OFF:
+ return false;
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
- move_block(0,-3,0);
- break;
+ case BUTTON_UP:
+ case BUTTON_UP | BUTTON_REPEAT:
+ move_block(0,-3,0);
+ break;
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
- move_block(0,3,0);
- break;
+ case BUTTON_DOWN:
+ case BUTTON_DOWN | BUTTON_REPEAT:
+ move_block(0,3,0);
+ break;
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
- move_block(0,0,1);
- break;
+ case BUTTON_RIGHT:
+ case BUTTON_RIGHT | BUTTON_REPEAT:
+ move_block(0,0,1);
+ break;
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
- move_down();
- break;
+ case BUTTON_LEFT:
+ case BUTTON_LEFT | BUTTON_REPEAT:
+ move_down();
+ break;
+
+ case SYS_USB_CONNECTED:
+ usb_screen();
+ return true;
}
count++;
@@ -369,14 +374,16 @@ void game_loop(void)
lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0);
lcd_update();
sleep(HZ * 3);
- return;
+ return false;
}
move_down();
}
+
+ return false;
}
-void init_tetris(void)
+static void init_tetris(void)
{
memset(&virtual, 0, sizeof(virtual));
@@ -391,7 +398,7 @@ void init_tetris(void)
next_f = 0;
}
-Menu tetris(void)
+bool tetris(void)
{
init_tetris();
@@ -402,9 +409,7 @@ Menu tetris(void)
next_b = t_rand(blocks);
next_f = t_rand(block_frames[next_b]);
new_block();
- game_loop();
-
- return MENU_OK;
+ return game_loop();
}
#endif
diff --git a/apps/recorder/wormlet.c b/apps/recorder/wormlet.c
index acebbad8bf..0edd550966 100644
--- a/apps/recorder/wormlet.c
+++ b/apps/recorder/wormlet.c
@@ -34,6 +34,7 @@
#include "menu.h"
#include "rtc.h"
#include "lang.h"
+#include "screens.h"
/* size of the field the worm lives in */
#define FIELD_RECT_X 1
@@ -1888,7 +1889,7 @@ extern bool use_old_rect;
/**
* Main entry point from the menu to start the game control.
*/
-Menu wormlet(void)
+bool wormlet(void)
{
bool wormDead = false;
int button;
@@ -1974,6 +1975,10 @@ Menu wormlet(void)
use_remote = true;
}
break;
+
+ case SYS_USB_CONNECTED:
+ usb_screen();
+ return true;
}
} while (button != BUTTON_PLAY &&
button != BUTTON_OFF && button != BUTTON_ON);
@@ -2007,7 +2012,7 @@ Menu wormlet(void)
}
while (button != BUTTON_OFF);
- return MENU_OK;
+ return false;
}
diff --git a/apps/recorder/wormlet.h b/apps/recorder/wormlet.h
index 347c6be737..0aeea3cc77 100644
--- a/apps/recorder/wormlet.h
+++ b/apps/recorder/wormlet.h
@@ -22,7 +22,7 @@
#include "menu.h"
-Menu wormlet(void);
+bool wormlet(void);
#endif /*__WORMLET__ */