2002-06-15 13:29:03 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Daniel Stenberg
|
|
|
|
*
|
|
|
|
* 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 "config.h"
|
2002-09-06 07:35:40 +00:00
|
|
|
#include "options.h"
|
2002-06-15 13:29:03 +00:00
|
|
|
|
2002-08-31 20:57:53 +00:00
|
|
|
#ifdef USE_SCREENSAVERS
|
2002-06-15 13:29:03 +00:00
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
2002-08-23 12:32:52 +00:00
|
|
|
#include "menu.h"
|
2002-09-06 12:05:37 +00:00
|
|
|
#include "sprintf.h"
|
2002-06-15 13:29:03 +00:00
|
|
|
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define SS_TITLE "Bouncer"
|
|
|
|
#define SS_TITLE_FONT 2
|
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
static unsigned char table[]={
|
2002-06-15 13:29:03 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
static unsigned char xtable[]={
|
2002-09-05 13:13:01 +00:00
|
|
|
54,58,63,67,71,75,79,82,85,88,91,93,95,97,98,99,99,99,99,99,97,96,94,92,90,87,84,80,77,73,69,65,60,56,52,47,43,39,34,30,26,22,19,15,12,9,7,5,3,2,0,0,0,0,0,1,2,4,6,8,11,14,17,20,24,28,32,36,41,45,49
|
2002-06-15 13:29:03 +00:00
|
|
|
};
|
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
static signed char speed[]={
|
|
|
|
1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-06-15 13:29:03 +00:00
|
|
|
#define XDIFF -4
|
|
|
|
#define YDIFF -6
|
|
|
|
|
|
|
|
extern const unsigned char char_gen_12x16[][22];
|
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
enum {
|
|
|
|
NUM_XSANKE,
|
|
|
|
NUM_YSANKE,
|
|
|
|
NUM_XADD,
|
|
|
|
NUM_YADD,
|
|
|
|
NUM_XDIST,
|
|
|
|
NUM_YDIST,
|
|
|
|
|
|
|
|
NUM_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
struct counter {
|
|
|
|
char *what;
|
|
|
|
int num;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct counter values[]={
|
|
|
|
{"xsanke", 1},
|
|
|
|
{"ysanke", 1},
|
|
|
|
{"xadd", 1},
|
|
|
|
{"yadd", 1},
|
|
|
|
{"xdist", -4},
|
|
|
|
{"ydistt", -6},
|
|
|
|
};
|
|
|
|
|
2002-06-15 13:29:03 +00:00
|
|
|
static void loopit(void)
|
|
|
|
{
|
|
|
|
int b;
|
2002-09-06 12:05:37 +00:00
|
|
|
unsigned int y=100;
|
|
|
|
unsigned int x=100;
|
|
|
|
unsigned int yy,xx;
|
2002-06-15 13:29:03 +00:00
|
|
|
unsigned int i;
|
2002-09-06 12:05:37 +00:00
|
|
|
unsigned int ysanke=0;
|
|
|
|
unsigned int xsanke=0;
|
2002-06-15 13:29:03 +00:00
|
|
|
|
2002-08-13 15:01:59 +00:00
|
|
|
char rock[]="ROCKbox";
|
2002-06-15 13:29:03 +00:00
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
int show=0;
|
|
|
|
int timeout=0;
|
|
|
|
char buffer[30];
|
|
|
|
|
2002-06-15 13:29:03 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
while(1)
|
|
|
|
{
|
2002-09-06 12:05:37 +00:00
|
|
|
b = button_get_w_tmo(HZ/10);
|
2002-06-15 13:29:03 +00:00
|
|
|
if ( b & BUTTON_OFF )
|
2002-09-06 12:05:37 +00:00
|
|
|
break;
|
|
|
|
else if(b != BUTTON_NONE)
|
|
|
|
timeout=20;
|
2002-08-13 15:01:59 +00:00
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
y+= speed[ysanke&15] + values[NUM_YADD].num;
|
|
|
|
x+= speed[xsanke&15] + values[NUM_XADD].num;
|
2002-06-15 13:29:03 +00:00
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
if(timeout) {
|
|
|
|
switch(b) {
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
values[show].num--;
|
|
|
|
break;
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
values[show].num++;
|
|
|
|
break;
|
|
|
|
case BUTTON_UP:
|
|
|
|
if(++show == NUM_LAST)
|
|
|
|
show=0;
|
|
|
|
break;
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
if(--show < 0)
|
|
|
|
show=NUM_LAST-1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
snprintf(buffer, 30, "%s: %d",
|
|
|
|
values[show].what, values[show].num);
|
|
|
|
lcd_putsxy(0, 56, buffer, 0);
|
|
|
|
timeout--;
|
|
|
|
}
|
|
|
|
for(i=0, yy=y, xx=x;
|
|
|
|
i<sizeof(rock)-1;
|
|
|
|
i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
|
2002-06-15 13:29:03 +00:00
|
|
|
lcd_bitmap((char *)char_gen_12x16[rock[i]-0x20],
|
2002-09-05 13:13:01 +00:00
|
|
|
xtable[xx%71], table[yy&63],
|
2002-06-15 13:29:03 +00:00
|
|
|
11, 16, false);
|
2002-09-06 12:05:37 +00:00
|
|
|
|
2002-06-15 13:29:03 +00:00
|
|
|
lcd_update();
|
|
|
|
|
2002-09-06 12:05:37 +00:00
|
|
|
ysanke+= values[NUM_YSANKE].num;
|
|
|
|
xsanke+= values[NUM_XSANKE].num;
|
2002-06-15 13:29:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-23 12:32:52 +00:00
|
|
|
Menu bounce(void)
|
2002-06-15 13:29:03 +00:00
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
char *off = "[Off] to stop";
|
|
|
|
int len = strlen(SS_TITLE);
|
|
|
|
|
|
|
|
lcd_getfontsize(SS_TITLE_FONT, &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_clear_display();
|
|
|
|
lcd_putsxy(LCD_WIDTH/2-len, (LCD_HEIGHT/2)-h, SS_TITLE, SS_TITLE_FONT);
|
|
|
|
|
|
|
|
len = strlen(off);
|
|
|
|
lcd_getfontsize(0, &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,0);
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ);
|
|
|
|
loopit();
|
2002-08-23 12:32:52 +00:00
|
|
|
|
|
|
|
return MENU_OK;
|
2002-06-15 13:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|