2002-05-17 12:22:24 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 1999 Mattis Wadman (nappe@sudac.org)
|
|
|
|
|
*
|
|
|
|
|
* Heavily modified for embedded use by Bj<EFBFBD>rn Stenberg (bjorn@haxx.se)
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2002-05-24 08:59:34 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2002-05-17 12:22:24 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include "lcd.h"
|
|
|
|
|
#include "button.h"
|
|
|
|
|
#include "kernel.h"
|
2002-05-29 14:32:05 +00:00
|
|
|
|
#include <string.h>
|
2002-08-23 12:32:52 +00:00
|
|
|
|
#include "menu.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
|
|
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#endif
|
2002-06-12 17:57:49 +00:00
|
|
|
|
#include "sprintf.h"
|
2002-05-17 12:22:24 +00:00
|
|
|
|
|
|
|
|
|
#define TETRIS_TITLE "Tetris!"
|
2002-05-31 22:16:10 +00:00
|
|
|
|
#define TETRIS_TITLE_FONT 1
|
|
|
|
|
#define TETRIS_TITLE_XLOC 43
|
|
|
|
|
#define TETRIS_TITLE_YLOC 15
|
2002-05-17 12:22:24 +00:00
|
|
|
|
|
2002-07-04 13:46:18 +00:00
|
|
|
|
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;
|
2002-06-20 09:32:33 +00:00
|
|
|
|
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};
|
|
|
|
|
|
|
|
|
|
static int current_x, current_y, current_f, current_b;
|
|
|
|
|
static int level, score;
|
|
|
|
|
static int next_b, next_f;
|
|
|
|
|
static short lines;
|
2002-07-03 13:31:12 +00:00
|
|
|
|
static char virtual[LCD_WIDTH * LCD_HEIGHT];
|
2002-05-17 12:22:24 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
block_data is built up the following way
|
|
|
|
|
|
|
|
|
|
first array index specifies the block number
|
|
|
|
|
second array index specifies the rotation of the block
|
|
|
|
|
third array index specifies:
|
|
|
|
|
0: x-coordinates of pixels
|
|
|
|
|
1: y-coordinates of pixels
|
|
|
|
|
fourth array index specifies the coordinate of a pixel
|
|
|
|
|
|
|
|
|
|
each block consists of four pixels whose relative coordinates are given
|
|
|
|
|
with block_data
|
|
|
|
|
*/
|
|
|
|
|
|
2002-06-20 09:32:33 +00:00
|
|
|
|
static const char block_data[7][4][2][4] =
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
{{0,1,0,1},{0,0,1,1}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{0,1,1,2},{1,1,0,0}},
|
|
|
|
|
{{0,0,1,1},{0,1,1,2}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{0,1,1,2},{0,0,1,1}},
|
|
|
|
|
{{1,1,0,0},{0,1,1,2}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{1,1,1,1},{0,1,2,3}},
|
|
|
|
|
{{0,1,2,3},{2,2,2,2}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{1,1,1,2},{2,1,0,0}},
|
|
|
|
|
{{0,1,2,2},{1,1,1,2}},
|
|
|
|
|
{{0,1,1,1},{2,2,1,0}},
|
|
|
|
|
{{0,0,1,2},{0,1,1,1}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{0,1,1,1},{0,0,1,2}},
|
|
|
|
|
{{0,1,2,2},{1,1,1,0}},
|
|
|
|
|
{{1,1,1,2},{0,1,2,2}},
|
|
|
|
|
{{0,0,1,2},{2,1,1,1}}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{{1,0,1,2},{0,1,1,1}},
|
|
|
|
|
{{2,1,1,1},{1,0,1,2}},
|
|
|
|
|
{{1,0,1,2},{2,1,1,1}},
|
|
|
|
|
{{0,1,1,1},{1,0,1,2}}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int t_rand(int range)
|
|
|
|
|
{
|
2002-06-20 09:40:51 +00:00
|
|
|
|
return current_tick % range;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
lcd_drawline(fstart_x, fstart_y, fstart_x, fstop_y);
|
|
|
|
|
lcd_drawline(fstop_x, fstart_y, fstop_x, fstop_y);
|
2002-07-04 13:46:18 +00:00
|
|
|
|
|
|
|
|
|
lcd_drawline(fstart_x - 1, fstart_y + 1, fstart_x - 1, fstop_y + 1);
|
|
|
|
|
lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
void draw_block(int x, int y, int block, int frame, bool clear)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
2002-07-03 13:31:12 +00:00
|
|
|
|
int i, a, b;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
for(i=0;i < 4;i++) {
|
2002-05-31 22:16:10 +00:00
|
|
|
|
if (clear)
|
|
|
|
|
{
|
2002-07-04 13:46:18 +00:00
|
|
|
|
for (a = 0; a < 3; a++)
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for (b = 0; b < 4; b++)
|
2002-07-04 13:46:18 +00:00
|
|
|
|
lcd_clearpixel(start_x + x + block_data[block][frame][1][i] * 4 - b,
|
|
|
|
|
start_y + y + block_data[block][frame][0][i] * 3 + a);
|
2002-05-31 22:16:10 +00:00
|
|
|
|
}
|
2002-05-17 12:22:24 +00:00
|
|
|
|
else
|
2002-05-31 22:16:10 +00:00
|
|
|
|
{
|
2002-07-04 13:46:18 +00:00
|
|
|
|
for (a = 0; a < 3; a++)
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for (b = 0; b < 4; b++)
|
2002-07-04 13:46:18 +00:00
|
|
|
|
lcd_drawpixel(start_x+x+block_data[block][frame][1][i] * 4 - b,
|
|
|
|
|
start_y+y+block_data[block][frame][0][i] * 3 + a);
|
2002-05-31 22:16:10 +00:00
|
|
|
|
}
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
void to_virtual(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
2002-07-03 13:31:12 +00:00
|
|
|
|
int i,a,b;
|
2002-07-04 13:46:18 +00:00
|
|
|
|
|
2002-05-31 22:16:10 +00:00
|
|
|
|
for(i = 0; i < 4; i++)
|
2002-07-04 13:46:18 +00:00
|
|
|
|
for (a = 0; a < 3; a++)
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for (b = 0; b < 4; b++)
|
|
|
|
|
*(virtual +
|
2002-07-04 13:46:18 +00:00
|
|
|
|
(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;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool block_touch (int x, int y)
|
|
|
|
|
{
|
2002-07-03 13:31:12 +00:00
|
|
|
|
int a,b;
|
|
|
|
|
for (a = 0; a < 4; a++)
|
2002-07-04 13:46:18 +00:00
|
|
|
|
for (b = 0; b < 3; b++)
|
|
|
|
|
if (*(virtual + (y + b) * max_x + (x - a)) != 0)
|
2002-07-03 13:31:12 +00:00
|
|
|
|
return true;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
return false;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
bool gameover(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int frame, block, y, x;
|
|
|
|
|
|
|
|
|
|
x = current_x;
|
|
|
|
|
y = current_y;
|
|
|
|
|
block = current_b;
|
|
|
|
|
frame = current_f;
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for(i = 0; i < 4; i++){
|
2002-05-17 12:22:24 +00:00
|
|
|
|
/* Do we have blocks touching? */
|
2002-07-04 13:46:18 +00:00
|
|
|
|
if(block_touch(x + block_data[block][frame][1][i] * 4, y + block_data[block][frame][0][i] * 3))
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
/* Are we at the top of the frame? */
|
2002-07-04 21:24:09 +00:00
|
|
|
|
if(x + block_data[block][frame][1][i] * 4 >= max_x - 16)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
/* Game over ;) */
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
bool valid_position(int x, int y, int block, int frame)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i < 4;i++)
|
2002-07-04 13:46:18 +00:00
|
|
|
|
if ((y + block_data[block][frame][0][i] * 3 > max_y - 3) ||
|
|
|
|
|
(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))
|
2002-05-17 12:22:24 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
void from_virtual(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int x,y;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
for(y = 0; y < max_y; y++)
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for(x = 1; x < max_x - 1; x++)
|
2002-05-31 22:16:10 +00:00
|
|
|
|
if(*(virtual + (y * max_x) + x) != 0)
|
|
|
|
|
lcd_drawpixel(start_x + x, start_y + y);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
else
|
2002-05-31 22:16:10 +00:00
|
|
|
|
lcd_clearpixel(start_x + x, start_y + y);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void move_block(int x,int y,int f)
|
|
|
|
|
{
|
|
|
|
|
int last_frame = current_f;
|
|
|
|
|
if(f != 0)
|
|
|
|
|
{
|
|
|
|
|
current_f += f;
|
|
|
|
|
if(current_f > block_frames[current_b]-1)
|
|
|
|
|
current_f = 0;
|
|
|
|
|
if(current_f < 0)
|
|
|
|
|
current_f = block_frames[current_b]-1;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
if(valid_position(current_x + x, current_y + y, current_b, current_f))
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
draw_block(current_x,current_y,current_b,last_frame,true);
|
|
|
|
|
current_x += x;
|
|
|
|
|
current_y += y;
|
|
|
|
|
draw_block(current_x,current_y,current_b,current_f,false);
|
|
|
|
|
lcd_update();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
current_f = last_frame;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
void new_block(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
current_b = next_b;
|
|
|
|
|
current_f = next_f;
|
2002-07-04 13:46:18 +00:00
|
|
|
|
current_x = max_x - 16;
|
|
|
|
|
current_y = (int)12;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
next_b = t_rand(blocks);
|
|
|
|
|
next_f = t_rand(block_frames[next_b]);
|
2002-07-04 13:46:18 +00:00
|
|
|
|
|
|
|
|
|
lcd_drawline (max_x + 7, start_y - 1, max_x + 29, start_y - 1);
|
|
|
|
|
lcd_drawline (max_x + 29, start_y, max_x + 29, start_y + 14);
|
|
|
|
|
lcd_drawline (max_x + 29, start_y + 14, max_x + 7, start_y + 14);
|
|
|
|
|
lcd_drawline (max_x + 7, start_y + 14, max_x + 7, start_y - 1);
|
|
|
|
|
lcd_drawline (max_x + 6, start_y + 15, max_x + 6, start_y);
|
|
|
|
|
lcd_drawline (max_x + 6, start_y + 15, max_x + 28, start_y + 15);
|
|
|
|
|
|
|
|
|
|
draw_block(max_x + 9, start_y - 4, current_b, current_f, true);
|
|
|
|
|
draw_block(max_x + 9, start_y - 4, next_b, next_f, false);
|
2002-07-03 13:31:12 +00:00
|
|
|
|
if(!valid_position(current_x, current_y, current_b, current_f))
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
2002-07-03 13:31:12 +00:00
|
|
|
|
draw_block(current_x, current_y, current_b, current_f, false);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-07-03 13:31:12 +00:00
|
|
|
|
draw_block(current_x, current_y, current_b, current_f, false);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
int check_lines(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
2002-07-03 15:45:39 +00:00
|
|
|
|
int x,y,i,j;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
bool line;
|
|
|
|
|
int lines = 0;
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for(x = 0; x < max_x; x++)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
line = true;
|
2002-07-03 13:31:12 +00:00
|
|
|
|
for(y = 0; y < max_y; y++)
|
|
|
|
|
{
|
2002-05-31 22:16:10 +00:00
|
|
|
|
if(*(virtual + y * max_x + x) == 0)
|
|
|
|
|
{
|
2002-05-17 12:22:24 +00:00
|
|
|
|
line = false;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2002-07-03 13:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-17 12:22:24 +00:00
|
|
|
|
if(line)
|
|
|
|
|
{
|
|
|
|
|
lines++;
|
2002-07-03 13:31:12 +00:00
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
|
|
x--; // re-check this line
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
|
|
|
|
return lines / 4;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
void move_down(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
int l;
|
2002-05-31 22:16:10 +00:00
|
|
|
|
char s[25];
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
|
|
|
|
if(!valid_position(current_x - 4, current_y, current_b, current_f))
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
to_virtual();
|
2002-05-31 22:16:10 +00:00
|
|
|
|
l = check_lines();
|
2002-05-17 12:22:24 +00:00
|
|
|
|
if(l)
|
|
|
|
|
{
|
|
|
|
|
lines += l;
|
|
|
|
|
level = (int)lines/10;
|
|
|
|
|
if(level > 9)
|
|
|
|
|
level = 9;
|
|
|
|
|
from_virtual();
|
|
|
|
|
score += l*l;
|
|
|
|
|
}
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
2002-06-03 06:57:27 +00:00
|
|
|
|
snprintf (s, sizeof(s), "%d Rows - Level %d", lines, level);
|
2002-08-26 03:29:13 +00:00
|
|
|
|
lcd_putsxy (2, 42, s, 0);
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
2002-05-17 12:22:24 +00:00
|
|
|
|
new_block();
|
|
|
|
|
move_block(0,0,0);
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-07-03 13:31:12 +00:00
|
|
|
|
move_block(-4,0,0);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void game_loop(void)
|
|
|
|
|
{
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
2002-07-24 19:42:46 +00:00
|
|
|
|
int count = 0;
|
|
|
|
|
while(count * 300 < level_speeds[level])
|
|
|
|
|
{
|
2002-08-07 07:46:24 +00:00
|
|
|
|
switch(button_get_w_tmo(HZ/10))
|
2002-07-24 19:42:46 +00:00
|
|
|
|
{
|
|
|
|
|
case BUTTON_OFF:
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case BUTTON_UP:
|
2002-07-27 21:29:07 +00:00
|
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2002-07-24 19:42:46 +00:00
|
|
|
|
move_block(0,-3,0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_DOWN:
|
2002-07-27 21:29:07 +00:00
|
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2002-07-24 19:42:46 +00:00
|
|
|
|
move_block(0,3,0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
2002-07-27 21:29:07 +00:00
|
|
|
|
case BUTTON_RIGHT | BUTTON_REPEAT:
|
2002-07-24 19:42:46 +00:00
|
|
|
|
move_block(0,0,1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BUTTON_LEFT:
|
2002-07-27 21:29:07 +00:00
|
|
|
|
case BUTTON_LEFT | BUTTON_REPEAT:
|
2002-07-24 19:42:46 +00:00
|
|
|
|
move_down();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
count++;
|
2002-07-24 19:42:46 +00:00
|
|
|
|
}
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
|
|
|
|
if(gameover())
|
|
|
|
|
{
|
2002-07-04 21:24:09 +00:00
|
|
|
|
lcd_clearrect(0, 52, LCD_WIDTH, LCD_HEIGHT - 52);
|
|
|
|
|
lcd_putsxy (2, 52, "You lose!", 0);
|
2002-06-20 09:32:33 +00:00
|
|
|
|
lcd_update();
|
2002-07-04 21:24:09 +00:00
|
|
|
|
sleep(HZ * 3);
|
2002-06-20 09:32:33 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
2002-07-24 19:42:46 +00:00
|
|
|
|
move_down();
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 12:34:29 +00:00
|
|
|
|
void init_tetris(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
memset(&virtual, 0, sizeof(virtual));
|
2002-07-03 13:31:12 +00:00
|
|
|
|
|
2002-05-17 12:22:24 +00:00
|
|
|
|
current_x = 0;
|
|
|
|
|
current_y = 0;
|
|
|
|
|
current_f = 0;
|
|
|
|
|
current_b = 0;
|
|
|
|
|
level = 0;
|
|
|
|
|
lines = 0;
|
|
|
|
|
score = 0;
|
|
|
|
|
next_b = 0;
|
|
|
|
|
next_f = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-23 12:32:52 +00:00
|
|
|
|
Menu tetris(void)
|
2002-05-17 12:22:24 +00:00
|
|
|
|
{
|
|
|
|
|
init_tetris();
|
|
|
|
|
|
2002-07-03 13:31:12 +00:00
|
|
|
|
draw_frame(start_x, start_x + max_x - 1, start_y - 1, start_y + max_y);
|
2002-08-26 03:29:13 +00:00
|
|
|
|
lcd_putsxy (2, 42, "0 Rows - Level 0", 0);
|
2002-05-17 12:22:24 +00:00
|
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
|
|
next_b = t_rand(blocks);
|
|
|
|
|
next_f = t_rand(block_frames[next_b]);
|
|
|
|
|
new_block();
|
|
|
|
|
game_loop();
|
2002-08-23 12:32:52 +00:00
|
|
|
|
|
|
|
|
|
return MENU_OK;
|
2002-05-17 12:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|