summaryrefslogtreecommitdiffstats
path: root/apps/recorder
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/bounce.c43
-rw-r--r--apps/recorder/cube.c158
-rw-r--r--apps/recorder/sokoban.c9
-rw-r--r--apps/recorder/tetris.c37
-rw-r--r--apps/recorder/wormlet.c23
5 files changed, 169 insertions, 101 deletions
diff --git a/apps/recorder/bounce.c b/apps/recorder/bounce.c
index f89f699862..4f00d50470 100644
--- a/apps/recorder/bounce.c
+++ b/apps/recorder/bounce.c
@@ -28,6 +28,8 @@
#include "menu.h"
#include "sprintf.h"
#include "rtc.h"
+#include "font.h"
+#include "screens.h"
#ifdef SIMULATOR
#include <stdio.h>
@@ -37,6 +39,13 @@
#define SS_TITLE "Bouncer"
#define SS_TITLE_FONT 2
+#define LETTERS_ON_SCREEN 12
+
+#define YSPEED 2
+#define XSPEED 3
+#define YADD -4
+
+
static unsigned char table[]={
26,28,30,33,35,37,39,40,42,43,45,46,46,47,47,47,47,47,46,46,45,43,42,40,39,37,35,33,30,28,26,24,21,19,17,14,12,10,8,7,5,4,2,1,1,0,0,0,0,0,1,1,2,4,5,7,8,10,12,14,17,19,21,23,
};
@@ -225,12 +234,6 @@ static void addclock(void)
}
}
-#define LETTERS_ON_SCREEN 12
-
-#define YSPEED 2
-#define XSPEED 3
-#define YADD -4
-
static int scrollit(void)
{
int b;
@@ -301,6 +304,12 @@ static int loopit(void)
b = button_get_w_tmo(HZ/10);
if ( b == (BUTTON_OFF|BUTTON_REL) )
return 0;
+
+ if ( b == SYS_USB_CONNECTED) {
+ usb_screen();
+ return 0;
+ }
+
if ( b == (BUTTON_ON|BUTTON_REL) )
return 1;
else if(b != BUTTON_NONE)
@@ -355,6 +364,8 @@ bool bounce(void)
char *off = "[Off] to stop";
int len = strlen(SS_TITLE);
+ lcd_setfont(FONT_SYSFIXED);
+
lcd_getstringsize(SS_TITLE,&w, &h);
/* Get horizontel centering for text */
@@ -363,41 +374,43 @@ bool bounce(void)
len = ((len+1)/2)+(w/2);
else
len /= 2;
-
+
if (h%2 != 0)
h = (h/2)+1;
else
h /= 2;
-
+
lcd_clear_display();
lcd_putsxy(LCD_WIDTH/2-len, (LCD_HEIGHT/2)-h, SS_TITLE);
-
+
len = 1;
lcd_getstringsize(off, &w, &h);
-
+
/* Get horizontel centering for text */
len *= w;
if (len%2 != 0)
len = ((len+1)/2)+(w/2);
else
len /= 2;
-
+
if (h%2 != 0)
h = (h/2)+1;
else
h /= 2;
-
+
lcd_putsxy(LCD_WIDTH/2-len, LCD_HEIGHT-(2*h), off);
-
+
lcd_update();
sleep(HZ);
-
+
do {
h= loopit();
if(h)
- h= scrollit();
+ h = scrollit();
} while(h);
+ lcd_setfont(FONT_UI);
+
return false;
}
diff --git a/apps/recorder/cube.c b/apps/recorder/cube.c
index fddd294773..4ad7ebb80b 100644
--- a/apps/recorder/cube.c
+++ b/apps/recorder/cube.c
@@ -31,25 +31,33 @@
#include "button.h"
#include "sprintf.h"
#include "screens.h"
+#include "font.h"
-typedef struct
-{long x,y,z;} point3D;
+/* Loops that the values are displayed */
+#define DISP_TIME 30
+
+struct point_3D {
+ long x, y, z;
+};
+
+struct point_2D {
+ long x, y;
+};
-typedef struct
-{long x,y;} point2D;
+static struct point_3D sommet[8];
+static struct point_3D point3D[8];
+static struct point_2D point2D[8];
-static point3D Sommet[8];
-static point3D Point3D[8];
-static point2D Point2D[8];
+static long matrice[3][3];
-static int Nb_points = 8;
+static int nb_points = 8;
-static int Xoff = 56;
-static int Yoff = 95;
-static int Zoff = 600;
+static int x_off = 56;
+static int y_off = 95;
+static int z_off = 600;
/* Precalculated sine and cosine * 10000 (four digit fixed point math) */
-static int SinTable[91] =
+static int sin_table[91] =
{
0, 174, 348, 523, 697,
871,1045,1218,1391,1564,
@@ -72,76 +80,83 @@ static int SinTable[91] =
10000
};
-static long Sin(int val)
+static long sin(int val)
{
/* Speed improvement through sukzessive lookup */
if (val<181)
{
- if (val<91)/* phase 0-90 degree */
+ if (val<91)
{
- return (long)SinTable[val];
+ /* phase 0-90 degree */
+ return (long)sin_table[val];
}
- else/* phase 91-180 degree */
+ else
{
- return (long)SinTable[180-val];
+ /* phase 91-180 degree */
+ return (long)sin_table[180-val];
}
}
else
{
- if (val<271)/* phase 181-270 degree */
+ if (val<271)
{
- return (-1L)*(long)SinTable[val-180];
+ /* phase 181-270 degree */
+ return (-1L)*(long)sin_table[val-180];
}
- else/* phase 270-359 degree */
+ else
{
- return (-1L)*(long)SinTable[360-val];
+ /* phase 270-359 degree */
+ return (-1L)*(long)sin_table[360-val];
}
}
return 0;
}
-static long Cos(int val)
+static long cos(int val)
{
/* Speed improvement through sukzessive lookup */
if (val<181)
{
- if (val<91)/* phase 0-90 degree */
+ if (val<91)
{
- return (long)SinTable[90-val];
+ /* phase 0-90 degree */
+ return (long)sin_table[90-val];
}
- else/* phase 91-180 degree */
+ else
{
- return (-1L)*(long)SinTable[val-90];
+ /* phase 91-180 degree */
+ return (-1L)*(long)sin_table[val-90];
}
}
else
{
- if (val<271)/* phase 181-270 degree */
+ if (val<271)
{
- return (-1L)*(long)SinTable[270-val];
+ /* phase 181-270 degree */
+ return (-1L)*(long)sin_table[270-val];
}
- else/* phase 270-359 degree */
+ else
{
- return (long)SinTable[val-270];
+ /* phase 270-359 degree */
+ return (long)sin_table[val-270];
}
}
return 0;
}
-static long matrice[3][3];
-static void cube_rotate(int Xa, int Ya, int Za)
+static void cube_rotate(int xa, int ya, int za)
{
int i;
/* Just to prevent unnecessary lookups */
long sxa,cxa,sya,cya,sza,cza;
- sxa=Sin(Xa);
- cxa=Cos(Xa);
- sya=Sin(Ya);
- cya=Cos(Ya);
- sza=Sin(Za);
- cza=Cos(Za);
+ sxa=sin(xa);
+ cxa=cos(xa);
+ sya=sin(ya);
+ cya=cos(ya);
+ sza=sin(za);
+ cza=cos(za);
/* calculate overall translation matrix */
matrice[0][0] = cza*cya/10000L;
@@ -157,19 +172,16 @@ static void cube_rotate(int Xa, int Ya, int Za)
matrice[2][2] = cxa*cya/10000L;
/* apply translation matrix to all points */
- for(i=0;i<Nb_points;i++)
+ for(i=0;i<nb_points;i++)
{
- Point3D[i].x = matrice[0][0]*Sommet[i].x
- + matrice[1][0]*Sommet[i].y
- + matrice[2][0]*Sommet[i].z;
-
- Point3D[i].y = matrice[0][1]*Sommet[i].x
- + matrice[1][1]*Sommet[i].y
- + matrice[2][1]*Sommet[i].z;
-
- Point3D[i].z = matrice[0][2]*Sommet[i].x
- + matrice[1][2]*Sommet[i].y
- + matrice[2][2]*Sommet[i].z;
+ point3D[i].x = matrice[0][0]*sommet[i].x + matrice[1][0]*sommet[i].y
+ + matrice[2][0]*sommet[i].z;
+
+ point3D[i].y = matrice[0][1]*sommet[i].x + matrice[1][1]*sommet[i].y
+ + matrice[2][1]*sommet[i].z;
+
+ point3D[i].z = matrice[0][2]*sommet[i].x + matrice[1][2]*sommet[i].y
+ + matrice[2][2]*sommet[i].z;
}
}
@@ -178,31 +190,31 @@ static void cube_viewport(void)
int i;
/* Do viewport transformation for all points */
- for(i=0;i<Nb_points;i++)
+ for(i=0;i<nb_points;i++)
{
- Point2D[i].x=(((Point3D[i].x)<<8)/10000L)/
- (Point3D[i].z/10000L+Zoff)+Xoff;
- Point2D[i].y=(((Point3D[i].y)<<8)/10000L)/
- (Point3D[i].z/10000L+Zoff)+Yoff;
+ point2D[i].x=(((point3D[i].x)<<8)/10000L)/
+ (point3D[i].z/10000L+z_off)+x_off;
+ point2D[i].y=(((point3D[i].y)<<8)/10000L)/
+ (point3D[i].z/10000L+z_off)+y_off;
}
}
static void cube_init(void)
{
/* Original 3D-position of cube's corners */
- Sommet[0].x = -40; Sommet[0].y = -40; Sommet[0].z = -40;
- Sommet[1].x = 40; Sommet[1].y = -40; Sommet[1].z = -40;
- Sommet[2].x = 40; Sommet[2].y = 40; Sommet[2].z = -40;
- Sommet[3].x = -40; Sommet[3].y = 40; Sommet[3].z = -40;
- Sommet[4].x = 40; Sommet[4].y = -40; Sommet[4].z = 40;
- Sommet[5].x = -40; Sommet[5].y = -40; Sommet[5].z = 40;
- Sommet[6].x = -40; Sommet[6].y = 40; Sommet[6].z = 40;
- Sommet[7].x = 40; Sommet[7].y = 40; Sommet[7].z = 40;
+ sommet[0].x = -40; sommet[0].y = -40; sommet[0].z = -40;
+ sommet[1].x = 40; sommet[1].y = -40; sommet[1].z = -40;
+ sommet[2].x = 40; sommet[2].y = 40; sommet[2].z = -40;
+ sommet[3].x = -40; sommet[3].y = 40; sommet[3].z = -40;
+ sommet[4].x = 40; sommet[4].y = -40; sommet[4].z = 40;
+ sommet[5].x = -40; sommet[5].y = -40; sommet[5].z = 40;
+ sommet[6].x = -40; sommet[6].y = 40; sommet[6].z = 40;
+ sommet[7].x = 40; sommet[7].y = 40; sommet[7].z = 40;
}
static void line(int a, int b)
{
- lcd_drawline(Point2D[a].x,Point2D[a].y,Point2D[b].x,Point2D[b].y);
+ lcd_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y);
}
static void cube_draw(void)
@@ -222,10 +234,6 @@ static void cube_draw(void)
line(3,6);
}
-
-/* Loops that the values are displayed */
-#define DISP_TIME 30
-
bool cube(void)
{
int t_disp=0;
@@ -240,11 +248,14 @@ bool cube(void)
bool highspeed=0;
bool exit=0;
+ lcd_setfont(FONT_SYSFIXED);
+
cube_init();
while(!exit)
{
- if (!highspeed) sleep(4);
+ if (!highspeed)
+ sleep(4);
lcd_clear_display();
cube_rotate(xa,ya,za);
@@ -255,7 +266,7 @@ bool cube(void)
t_disp--;
snprintf(buffer, 30, "x:%d y:%d z:%d h:%d",xs,ys,zs,highspeed);
lcd_putsxy(0, 56, buffer);
- }
+ }
lcd_update();
xa+=xs;
@@ -322,10 +333,13 @@ bool cube(void)
case SYS_USB_CONNECTED:
usb_screen();
+ lcd_setfont(FONT_UI);
return true;
-
}
}
+
+ lcd_setfont(FONT_UI);
+
return false;
}
@@ -338,3 +352,5 @@ bool cube(void)
* vim: et sw=4 ts=8 sts=4 tw=78
*/
+
+
diff --git a/apps/recorder/sokoban.c b/apps/recorder/sokoban.c
index 5081ddc8ce..bac1101838 100644
--- a/apps/recorder/sokoban.c
+++ b/apps/recorder/sokoban.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "options.h"
+
#ifdef USE_GAMES
#include <sprintf.h>
@@ -28,6 +29,7 @@
#include "kernel.h"
#include "menu.h"
#include "screens.h"
+#include "font.h"
#include "sokoban_levels.h"
@@ -503,6 +505,8 @@ bool sokoban(void)
int w, h;
int len;
+ lcd_setfont(FONT_SYSFIXED);
+
lcd_getstringsize(SOKOBAN_TITLE, &w, &h);
/* Get horizontel centering for text */
@@ -535,10 +539,9 @@ bool sokoban(void)
lcd_clear_display();
result = sokoban_loop();
+ lcd_setfont(FONT_UI);
+
return result;
}
#endif
-
-
-
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 @@
#ifdef USE_GAMES
#include <stdbool.h>
+#include <string.h>
#include "lcd.h"
#include "button.h"
#include "kernel.h"
-#include <string.h>
#include "menu.h"
#include "screens.h"
+#include "font.h"
#ifdef SIMULATOR
#include <stdio.h>
@@ -46,7 +47,9 @@ static const int start_x = 5;
static const int start_y = 5;
static const int max_x = 4 * 17;
static const int max_y = 3 * 10;
-static const short level_speeds[10] = {1000,900,800,700,600,500,400,300,250,200};
+static const short level_speeds[10] = {
+ 1000, 900, 800, 700, 600, 500, 400, 300, 250, 200
+};
static const int blocks = 7;
static const int block_frames[7] = {1,2,2,2,4,4,4};
@@ -147,14 +150,15 @@ static void draw_block(int x, int y, int block, int frame, bool clear)
static void to_virtual(void)
{
- int i,a,b;
+ int i, a, b;
for(i = 0; i < 4; i++)
for (a = 0; a < 3; a++)
for (b = 0; b < 4; b++)
*(virtual +
- (current_y + block_data[current_b][current_f][0][i] * 3 + a) * max_x +
- current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1;
+ (current_y + block_data[current_b][current_f][0][i] * 3 + a) *
+ max_x + current_x + block_data[current_b][current_f][1][i] *
+ 4 - b) = current_b + 1;
}
static bool block_touch (int x, int y)
@@ -179,7 +183,8 @@ static bool gameover(void)
for(i = 0; i < 4; i++){
/* Do we have blocks touching? */
- if(block_touch(x + block_data[block][frame][1][i] * 4, y + block_data[block][frame][0][i] * 3))
+ if(block_touch(x + block_data[block][frame][1][i] * 4,
+ y + block_data[block][frame][0][i] * 3))
{
/* Are we at the top of the frame? */
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)
(x + block_data[block][frame][1][i] * 4 > max_x - 4) ||
(y + block_data[block][frame][0][i] * 3 < 0) ||
(x + block_data[block][frame][1][i] * 4 < 4) ||
- block_touch (x + block_data[block][frame][1][i] * 4, y + block_data[block][frame][0][i] * 3))
+ block_touch (x + block_data[block][frame][1][i] * 4,
+ y + block_data[block][frame][0][i] * 3))
+ {
return false;
+ }
return true;
}
@@ -290,7 +298,7 @@ static int check_lines(void)
/* move rows down */
for(i = x; i < max_x - 1; i++)
for (j = 0; j < max_y; j++)
- *(virtual + j * max_x + i) = *(virtual + j * max_x + (i + 1));
+ *(virtual + j * max_x + i)=*(virtual + j * max_x + (i + 1));
x--; /* re-check this line */
}
@@ -402,6 +410,10 @@ static void init_tetris(void)
bool tetris(void)
{
char buf[20];
+ bool val;
+
+ /* Lets use the default font */
+ lcd_setfont(FONT_SYSFIXED);
init_tetris();
@@ -413,7 +425,14 @@ bool tetris(void)
next_b = t_rand(blocks);
next_f = t_rand(block_frames[next_b]);
new_block();
- return game_loop();
+ val = game_loop();
+
+ lcd_setfont(FONT_UI);
+
+ return val;
}
#endif
+
+
+
diff --git a/apps/recorder/wormlet.c b/apps/recorder/wormlet.c
index 76f70169b5..f1654227ff 100644
--- a/apps/recorder/wormlet.c
+++ b/apps/recorder/wormlet.c
@@ -35,6 +35,7 @@
#include "rtc.h"
#include "lang.h"
#include "screens.h"
+#include "font.h"
/* size of the field the worm lives in */
#define FIELD_RECT_X 1
@@ -1891,8 +1892,11 @@ extern bool use_old_rect;
*/
bool wormlet(void)
{
- bool wormDead = false;
+ bool worm_dead = false;
int button;
+
+ lcd_setfont(FONT_SYSFIXED);
+
#ifdef DEBUG_WORMLET
testline_in_rect();
test_worm_argh_collision_in_moves();
@@ -1978,6 +1982,7 @@ bool wormlet(void)
case SYS_USB_CONNECTED:
usb_screen();
+ lcd_setfont(FONT_UI);
return true;
}
} while (button != BUTTON_PLAY &&
@@ -1997,11 +2002,11 @@ bool wormlet(void)
button = BUTTON_OFF;
/* start the game */
- wormDead = run();
+ worm_dead = run();
/* if worm isn't dead the game was quit
via BUTTON_OFF -> no need to wait for buttons. */
- if (wormDead) {
+ if (worm_dead) {
do {
button = button_get(true);
}
@@ -2012,8 +2017,20 @@ bool wormlet(void)
}
while (button != BUTTON_OFF);
+ lcd_setfont(FONT_UI);
+
return false;
}
#endif /* USE_GAMES */
+
+
+
+
+
+
+
+
+
+