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