diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-09-06 12:05:37 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-09-06 12:05:37 +0000 |
commit | 9381765209c1d4ff27f38a83661bf3f045ef9604 (patch) | |
tree | 113b486db686a9c8932b69bad2f96337ea6e2301 /apps/recorder | |
parent | 5bed6e648ae8f289b7770963418083ea098c4582 (diff) |
To give you all a feeling from the good-old C64 demo scene, press UP or DOWN
and then change the values with LEFT and RIGHT. Enjoy!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2211 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/bounce.c | 91 |
1 files changed, 77 insertions, 14 deletions
diff --git a/apps/recorder/bounce.c b/apps/recorder/bounce.c index 121f039e82..8f6ffe6226 100644 --- a/apps/recorder/bounce.c +++ b/apps/recorder/bounce.c @@ -26,6 +26,7 @@ #include "button.h" #include "kernel.h" #include "menu.h" +#include "sprintf.h" #ifdef SIMULATOR #include <stdio.h> @@ -35,49 +36,111 @@ #define SS_TITLE "Bouncer" #define SS_TITLE_FONT 2 -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, }; -unsigned char xtable[]={ +static unsigned char xtable[]={ 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 }; +static signed char speed[]={ + 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1, +}; + + #define XDIFF -4 #define YDIFF -6 extern const unsigned char char_gen_12x16[][22]; +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}, +}; + static void loopit(void) { int b; - int y=0; - int x=16; - int yy,xx; + unsigned int y=100; + unsigned int x=100; + unsigned int yy,xx; unsigned int i; + unsigned int ysanke=0; + unsigned int xsanke=0; char rock[]="ROCKbox"; + int show=0; + int timeout=0; + char buffer[30]; + lcd_clear_display(); while(1) { - b = button_get(false); + b = button_get_w_tmo(HZ/10); if ( b & BUTTON_OFF ) - return; + break; + else if(b != BUTTON_NONE) + timeout=20; - lcd_clear_display(); - y++; - x++; + y+= speed[ysanke&15] + values[NUM_YADD].num; + x+= speed[xsanke&15] + values[NUM_XADD].num; - yy=y; - xx=x; - for(i=0; i<sizeof(rock)-1; i++, yy+=YDIFF, xx+=XDIFF) + 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) lcd_bitmap((char *)char_gen_12x16[rock[i]-0x20], xtable[xx%71], table[yy&63], 11, 16, false); + lcd_update(); - sleep(HZ/10); + ysanke+= values[NUM_YSANKE].num; + xsanke+= values[NUM_XSANKE].num; } } |