--- ../../build/rockblox.c 2004-10-16 06:00:06.000000000 +0200 +++ rockblox.c 2005-05-03 22:15:12.000000000 +0200 @@ -1,422 +1,486 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: rockblox.c,v 1.2 2004/10/16 00:07:43 amiconn Exp $ - * - * Copyright (C) 1999 Mattis Wadman (nappe@sudac.org) - * - * Heavily modified for embedded use by Bjö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. - * - ****************************************************************************/ -#include "plugin.h" - -#ifdef HAVE_LCD_BITMAP - -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 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; -static char virtual[LCD_WIDTH * LCD_HEIGHT]; -static struct plugin_api* rb; - -/* - 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 -*/ - -static const char block_data[7][4][2][4] = -{ - { - {{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}} - } -}; - -static int t_rand(int range) -{ - return *rb->current_tick % range; -} - -static void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y) -{ - rb->lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y); - rb->lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y); - - rb->lcd_drawline(fstart_x, fstart_y, fstart_x, fstop_y); - rb->lcd_drawline(fstop_x, fstart_y, fstop_x, fstop_y); - - rb->lcd_drawline(fstart_x - 1, fstart_y + 1, fstart_x - 1, fstop_y + 1); - rb->lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1); -} - -static void draw_block(int x, int y, int block, int frame, bool clear) -{ - int i, a, b; - for(i=0;i < 4;i++) { - if (clear) - { - for (a = 0; a < 3; a++) - for (b = 0; b < 4; b++) - rb->lcd_clearpixel(start_x + x + block_data[block][frame][1][i] * 4 - b, - start_y + y + block_data[block][frame][0][i] * 3 + a); - } - else - { - for (a = 0; a < 3; a++) - for (b = 0; b < 4; b++) - rb->lcd_drawpixel(start_x+x+block_data[block][frame][1][i] * 4 - b, - start_y+y+block_data[block][frame][0][i] * 3 + a); - } - } -} - -static void to_virtual(void) -{ - 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; -} - -static bool block_touch (int x, int y) -{ - int a,b; - for (a = 0; a < 4; a++) - for (b = 0; b < 3; b++) - if (*(virtual + (y + b) * max_x + (x - a)) != 0) - return true; - return false; -} - -static bool gameover(void) -{ - int i; - int frame, block, y, x; - - x = current_x; - y = current_y; - block = current_b; - frame = current_f; - - 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)) - { - /* Are we at the top of the frame? */ - if(x + block_data[block][frame][1][i] * 4 >= max_x - 16) - { - /* Game over ;) */ - return true; - } - } - } - return false; -} - -static bool valid_position(int x, int y, int block, int frame) -{ - int i; - for(i=0;i < 4;i++) - 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)) - { - return false; - } - return true; -} - -static void from_virtual(void) -{ - int x,y; - for(y = 0; y < max_y; y++) - for(x = 1; x < max_x - 1; x++) - if(*(virtual + (y * max_x) + x) != 0) - rb->lcd_drawpixel(start_x + x, start_y + y); - else - rb->lcd_clearpixel(start_x + x, start_y + y); -} - -static 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; - } - - if(valid_position(current_x + x, current_y + y, current_b, current_f)) - { - 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); - rb->lcd_update(); - } - else - current_f = last_frame; -} - -static void new_block(void) -{ - current_b = next_b; - current_f = next_f; - current_x = max_x - 16; - current_y = (int)12; - next_b = t_rand(blocks); - next_f = t_rand(block_frames[next_b]); - - rb->lcd_drawline (max_x + 7, start_y - 1, max_x + 29, start_y - 1); - rb->lcd_drawline (max_x + 29, start_y, max_x + 29, start_y + 14); - rb->lcd_drawline (max_x + 29, start_y + 14, max_x + 7, start_y + 14); - rb->lcd_drawline (max_x + 7, start_y + 14, max_x + 7, start_y - 1); - rb->lcd_drawline (max_x + 6, start_y + 15, max_x + 6, start_y); - rb->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); - if(!valid_position(current_x, current_y, current_b, current_f)) - { - draw_block(current_x, current_y, current_b, current_f, false); - rb->lcd_update(); - } - else - draw_block(current_x, current_y, current_b, current_f, false); -} - -static int check_lines(void) -{ - int x,y,i,j; - bool line; - int lines = 0; - for(x = 0; x < max_x; x++) - { - line = true; - for(y = 0; y < max_y; y++) - { - if(*(virtual + y * max_x + x) == 0) - { - line = false; - break; - } - } - - if(line) - { - lines++; - /* 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 */ - } - } - - return lines / 4; -} - -static void move_down(void) -{ - int l; - char s[25]; - - if(!valid_position(current_x - 4, current_y, current_b, current_f)) - { - to_virtual(); - l = check_lines(); - if(l) - { - lines += l; - level = (int)lines/10; - if(level > 9) - level = 9; - from_virtual(); - score += l*l; - } - - rb->snprintf(s, sizeof(s), "%d Rows - Level %d", lines, level); - rb->lcd_putsxy(2, 42, s); - - new_block(); - move_block(0,0,0); - } - else - move_block(-4,0,0); -} - -static int game_loop(void) -{ - int button; - - while(1) - { - int count = 0; - while(count * 300 < level_speeds[level]) - { - button = rb->button_get_w_tmo(HZ/10); - switch(button) - { - case BUTTON_OFF: - return PLUGIN_OK; - - 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_RIGHT: - case BUTTON_RIGHT | BUTTON_REPEAT: - move_block(0,0,1); - break; - - case BUTTON_LEFT: - case BUTTON_LEFT | BUTTON_REPEAT: - move_down(); - break; - - default: - if (rb->default_event_handler(button) == SYS_USB_CONNECTED) - return PLUGIN_USB_CONNECTED; - break; - } - - count++; - } - - if(gameover()) - { - rb->lcd_clearrect(0, 52, LCD_WIDTH, LCD_HEIGHT - 52); - rb->lcd_putsxy(2, 52, "You lose!"); - rb->lcd_update(); - rb->sleep(HZ * 3); - return false; - } - - move_down(); - } - - return false; -} - -static void init_rockblox(void) -{ - rb->memset(&virtual, 0, sizeof(virtual)); - - current_x = 0; - current_y = 0; - current_f = 0; - current_b = 0; - level = 0; - lines = 0; - score = 0; - next_b = 0; - next_f = 0; -} - -enum plugin_status plugin_start(struct plugin_api* api, void* parameter) -{ - int ret; - - TEST_PLUGIN_API(api); - - (void)parameter; - rb = api; - - /* Lets use the default font */ - rb->lcd_setfont(FONT_SYSFIXED); - - init_rockblox(); - - draw_frame(start_x, start_x + max_x - 1, start_y - 1, start_y + max_y); - rb->lcd_putsxy(2, 42, "0 Rows - Level 0"); - rb->lcd_update(); - - next_b = t_rand(blocks); - next_f = t_rand(block_frames[next_b]); - new_block(); - ret = game_loop(); - - rb->lcd_setfont(FONT_UI); - - return ret; -} - -#endif - +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: rockblox.c,v 1.2 2004/10/16 00:07:43 amiconn Exp $ + * + * Copyright (C) 1999 Mattis Wadman (nappe@sudac.org) + * + * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se) + * + * Major rewrite: rotated by 90 degree for archos and iriver by A.Hellmann + * + * 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. + * + ****************************************************************************/ + +#include "plugin.h" + +#ifdef HAVE_LCD_BITMAP + +static const char Rows[] = +{ 0x00,0x7F,0x09,0x19,0x29,0x46, + 0x00,0x38,0x44,0x44,0x44,0x38, + 0x00,0x3C,0x40,0x38,0x40,0x3C, + 0x00,0x48,0x54,0x54,0x54,0x24, + 0x00,0x00,0x00,0x66,0x00,0x00 }; + +#define FULL ((1 << numx) - 1)/* full line mask */ +static short virtmap[20]; /* holds the block map */ +static int xsz; /* # pixels per block in x */ +static int ysz; /* # pixels per block in y */ +static const int numx = 10; /* # blocks in x (max: 16 blocks in x) */ +static const int numy = 17; /* # blocks in y */ +static int xs, ys; +static int horizontal; +static int no_preview = 0; +static int start_game; +static int level; +static int lines; +static int curr_x, curr_y, curr_b, curr_f, next_b, next_f; +static const short level_speeds[10] = +{ 1000, 900, 800, 700, 600, 500, 400, 300, 250, 200 }; +static struct plugin_api* rb; + +/* + 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 +*/ + +static const int blocks = 7; +static const int block_frames[7] = {1,2,2,2,4,4,4}; + +static const char block_data[7][4][2][4] = +{ + { {{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}} } +}; + +static int t_rand(int range) +{ + return *rb->current_tick % range; +} + +static void draw_frame(int x, int y, int nx, int ny) +{ + int xb, yb, xe, ye, one; + + if(horizontal) /* rotate image */ + { + y -= ysz; + yb = xs + x - 1; + xb = ys - y; + ye = xs + x + nx; + xe = ys - y - ny - 1; + one = -1; + } + else + { + xb = xs + x - 1; + yb = ys + y - 1; + xe = xs + x + nx; + ye = ys + y + ny; + one = 1; + } + + rb->lcd_drawline(xb, yb, xe, yb); + rb->lcd_drawline(xe, yb, xe, ye); + rb->lcd_drawline(xb, yb, xb, ye); + rb->lcd_drawline(xb, ye, xe, ye); + + /* draw shadow */ + rb->lcd_drawline(xe+one, yb+1, xe+one, ye+1); + rb->lcd_drawline(xb+one, ye+1, xe+one, ye+1); +} + +static void draw_block(int x, int y, int block, int frame, bool clear) +{ + int i; + + void (*drawrect)(int x, int y, int nx, int ny) = clear ? rb->lcd_clearrect : rb->lcd_fillrect; + + for(i=0; i<4; i++) + if(horizontal) /* rotate image */ + drawrect(1 + ys - y - block_data[block][frame][1][i] * ysz, + xs + x + block_data[block][frame][0][i] * xsz, + ysz-1, xsz-1); + else + drawrect(1 + xs + x + block_data[block][frame][0][i] * xsz, + ys + y + block_data[block][frame][1][i] * ysz, + xsz-1, ysz-1); +} + +static void to_virtmap(void) +{ + int i; + + for(i=0; i<4; i++) + virtmap[curr_y + block_data[curr_b][curr_f][1][i]] |= + 1 << (curr_x + block_data[curr_b][curr_f][0][i]); +} + +static bool block_touch(int x, int y) +{ + return virtmap[y] & (1 << x) ? true : false; +} + +static bool gameover(void) +{ + int i; + + for(i=0; i<4; i++) + { + /* Do we have blocks touching? */ + if(block_touch(curr_x + block_data[curr_b][curr_f][0][i], + curr_y + block_data[curr_b][curr_f][1][i])) + { + /* Are we at the top of the frame? */ + if(curr_y + block_data[curr_b][curr_f][1][i] < 2) + return true; /* Game over */ + } + } + return false; +} + +static bool valid_position(int x, int y, int block, int frame) +{ + int i; + + for(i=0; i<4; i++) + if((x + block_data[block][frame][0][i] > numx - 1) || + (y + block_data[block][frame][1][i] > numy - 1) || + (x + block_data[block][frame][0][i] < 0) || + (y + block_data[block][frame][1][i] < 0) || + block_touch(x + block_data[block][frame][0][i], + y + block_data[block][frame][1][i])) + return false; + + return true; +} + +static void from_virtmap(void) +{ + int x, y; + void (*drawrect)(int x, int y, int nx, int ny); + + for(y=0; ylcd_fillrect : rb->lcd_clearrect; + + if(horizontal) /* rotate image */ + drawrect(1 + ys - y * ysz, xs + x * xsz, ysz-1, xsz-1); + else + drawrect(1 + xs + x * xsz, ys + y * ysz, xsz-1, ysz-1); + } +} + +static void move_block(int x, int y, int f) +{ + int last_f = curr_f; + + curr_f = (curr_f + f) % block_frames[curr_b]; /* rotate */ + + if(valid_position(curr_x + x, curr_y + y, curr_b, curr_f)) + { + draw_block(xsz*curr_x, ysz*curr_y, curr_b, last_f, true); + curr_x += x; + curr_y += y; + draw_block(xsz*curr_x, ysz*curr_y, curr_b, curr_f, false); + rb->lcd_update(); + } + else + curr_f = last_f; +} + +static void new_block(void) +{ + curr_x = 4; + curr_y = 0; + curr_b = next_b; + curr_f = next_f; + next_b = t_rand(blocks); + next_f = t_rand(block_frames[next_b]); + + if(!no_preview) + { + if(horizontal) /* rotate image */ + { + draw_block((numx-4)*xsz/2, -34, curr_b, curr_f, true); + draw_block((numx-4)*xsz/2, -34, next_b, next_f, false); + } + else + { + draw_block(xsz*numx+2*xsz, 0, curr_b, curr_f, true); + draw_block(xsz*numx+2*xsz, 0, next_b, next_f, false); + } + } + + draw_block(xsz*curr_x, ysz*curr_y, curr_b, curr_f, false); + + rb->lcd_update(); +} + +static int check_lines(void) +{ + int y, i, lines = 0; + + for(y=0; y0; i--) + virtmap[i] = virtmap[i-1]; + + y--; /* re-check current line */ + } + } + + return lines; +} + +static void move_down(void) +{ + int l; + char s[20]; + + if(!valid_position(curr_x, curr_y+1, curr_b, curr_f)) + { + to_virtmap(); + l = check_lines(); + if(l) + { + lines += l; + level = lines / 10; + if(level > 9) + level = 9; + from_virtmap(); + } + + if(horizontal) /* rotate image */ + { + rb->snprintf(s, sizeof(s), "%d Rows - Level %d", lines, level); + rb->lcd_putsxy(8, xs+numx*xsz+10, s); + } + else + { + rb->snprintf(s, sizeof(s), "Rows:%2d", lines); + rb->lcd_putsxy(xs+xsz*numx+10, ys+ysz*5+ 4, s); + rb->snprintf(s, sizeof(s), "Level:%d", level); + rb->lcd_putsxy(xs+xsz*numx+10, ys+ysz*5+14, s); + } + + new_block(); + } + else + move_block(0, 1, 0); +} + +static int game_loop(void) +{ + int button; + + while(1) + { + int count = 0; + while(count * 300 < level_speeds[level]) + { + button = rb->button_get_w_tmo(HZ/10); + if(horizontal) + { + switch(button) + { + case BUTTON_OFF: return PLUGIN_OK; + 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_DOWN: + case BUTTON_DOWN | BUTTON_REPEAT: move_block(1,0,0); break; + case BUTTON_UP: + case BUTTON_UP | BUTTON_REPEAT: move_block(-1,0,0); break; + default: + if(rb->default_event_handler(button) == SYS_USB_CONNECTED) + return PLUGIN_USB_CONNECTED; + } + } + else + { + switch(button) + { + case BUTTON_OFF: return PLUGIN_OK; + case BUTTON_UP: + case BUTTON_UP | BUTTON_REPEAT: move_block(0,0,1); break; + case BUTTON_DOWN: + case BUTTON_DOWN | BUTTON_REPEAT: move_down(); break; + case BUTTON_RIGHT: + case BUTTON_RIGHT | BUTTON_REPEAT:move_block(1,0,0); break; + case BUTTON_LEFT: + case BUTTON_LEFT | BUTTON_REPEAT: move_block(-1,0,0); break; + default: + if(rb->default_event_handler(button) == SYS_USB_CONNECTED) + return PLUGIN_USB_CONNECTED; + } + } + + count++; + } + + if(gameover()) + { + rb->lcd_putsxy(xs+xsz*numx+10, ys+ysz*5+24, "Game over!"); + rb->lcd_update(); + rb->sleep(HZ * 3); + return false; + } + + move_down(); + } + + return false; +} + +static void init_rockblox(void) +{ + rb->memset(&virtmap, 0, sizeof(virtmap)); + + curr_x = 0; + curr_y = 0; + curr_f = 0; + curr_b = 0; + level = 0; + lines = 0; + next_b = 0; + next_f = 0; + +#ifdef IRIVER_H100 + xsz = 7; /* # pixels per block in x */ + ysz = 7; /* # pixels per block in y */ + xs = horizontal ? 8 : 20; /* rotated? */ + ys = horizontal ? numy*ysz-2 : 4; /* rotated? */ +#else /* ARCHOS with 112 x 64 pixel */ + xsz = horizontal ? 3 : 4; /* rotated? */ + ysz = horizontal ? 4 : 3; /* rotated? */ + xs = horizontal ? 4 : 4; /* rotated? */ + ys = horizontal ? numy*ysz : 5; /* rotated? */ +#endif + + if(horizontal && no_preview) + { + xsz++; /* increase blocksize */ + ysz++; /* increase blocksize */ + ys += numy; + } +} + +enum plugin_status plugin_start(struct plugin_api* api, void* parameter) +{ + int pos, xm, ym, ret; + int styl[] = { STYLE_DEFAULT, STYLE_INVERT }; + const char *vstg[] = { " Vertical: Yes", " Vertical: No" }; + const char *pstg[] = { " Preview: Yes", " Preview: No" }; + + TEST_PLUGIN_API(api); + + (void)parameter; + rb = api; + + /* Lets use the default font */ + rb->lcd_setfont(FONT_SYSFIXED); + + xm = (LCD_WIDTH /2 - 56) / 6; /* center menu in x */ + ym = (LCD_HEIGHT/2 - 16) / 8; /* center menu in y */ + pos = 0; + + while(!start_game) + { + switch(rb->button_get_w_tmo(HZ/10)) + { + case BUTTON_UP: if(pos > 0) pos--; break; + case BUTTON_DOWN: if(pos < 3) pos++; break; + case BUTTON_RIGHT: if(pos == 1) horizontal ^= 1; + if(pos == 2) no_preview ^= 1; + if(pos == 3) start_game = 1; + break; + } + + rb->lcd_clear_display(); + rb->lcd_puts_style(xm, ym+0, " -- Settings --", styl[pos == 0]); + rb->lcd_puts_style(xm, ym+1, vstg[horizontal] , styl[pos == 1]); + rb->lcd_puts_style(xm, ym+2, pstg[no_preview] , styl[pos == 2]); + rb->lcd_puts_style(xm, ym+3, " Play Game ", styl[pos == 3]); + rb->lcd_update(); + } + + rb->lcd_clear_display(); + init_rockblox(); + draw_frame(0, 0, xsz*numx, ysz*numy); /* main frame */ + + if(horizontal) + { + if(!no_preview) + draw_frame((numx-4)*xsz/2, -34, 4*xsz, 4*ysz); /* preview frame */ + + rb->lcd_putsxy(8, xs+numx*xsz+10, "0 Rows - Level 0"); + } + else + { + if(!no_preview) + draw_frame(xsz*numx+2*xsz, 0, 4*xsz, 4*ysz); /* preview frame */ + + rb->lcd_putsxy(xs+xsz*numx+10, ys+ysz*5+ 4, "Rows: 0"); + rb->lcd_putsxy(xs+xsz*numx+10, ys+ysz*5+14, "Level:0"); + } + + rb->lcd_update(); + next_b = t_rand(blocks); + next_f = t_rand(block_frames[next_b]); + new_block(); + + ret = game_loop(); + rb->lcd_setfont(FONT_UI); + + return ret; +} +#endif