summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-06-09 06:14:40 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-06-09 06:14:40 +0000
commit005fc38d8726b50e070da32177e093447351d238 (patch)
tree8957c2614f22f1190db7f56d15b311934128a931 /apps
parent7668bf78f27a55eb2efbe4ef48fae61fae92cceb (diff)
downloadrockbox-005fc38d8726b50e070da32177e093447351d238.tar.gz
rockbox-005fc38d8726b50e070da32177e093447351d238.zip
Snake2 port to iRiver by Alexander Spyridakis
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6629 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/snake2.c500
1 files changed, 447 insertions, 53 deletions
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index 1e3859165c..3569c851b1 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -33,6 +33,28 @@ Head and Tail are stored
33#define WIDTH 28 33#define WIDTH 28
34#define HEIGHT 16 34#define HEIGHT 16
35 35
36#ifdef IRIVER_H100
37 #define MULTIPLIER 5 /*Modifier for porting on other screens*/
38 #define MODIFIER_1 5
39 #define MODIFIER_2 3
40 #define CENTER_X 10
41 #define CENTER_Y 38
42 #define BMPHEIGHT_snakebmp 128
43 #define BMPWIDTH_snakebmp 160
44 #define BMPHEIGHT_snakeupbmp 36
45 #define BMPWIDTH_snakeupbmp 160
46#else
47 #define MULTIPLIER 4
48 #define MODIFIER_1 4
49 #define MODIFIER_2 2
50 #define CENTER_X 0
51 #define CENTER_Y 0
52
53#endif
54
55
56
57
36/* variable button definitions */ 58/* variable button definitions */
37#if CONFIG_KEYPAD == RECORDER_PAD 59#if CONFIG_KEYPAD == RECORDER_PAD
38#define SNAKE2_QUIT BUTTON_OFF 60#define SNAKE2_QUIT BUTTON_OFF
@@ -78,6 +100,7 @@ static int ardirectionbuffer[2];
78static unsigned int score, hiscore = 0; 100static unsigned int score, hiscore = 0;
79static int applex; 101static int applex;
80static int appley; 102static int appley;
103static int strwdt,strhgt; /*used for string width, height for orientation purposes*/
81static int dir; 104static int dir;
82static int frames; 105static int frames;
83static int apple; 106static int apple;
@@ -90,6 +113,290 @@ static int game_type = 0;
90static int num_apples_to_get=1; 113static int num_apples_to_get=1;
91static int num_apples_to_got=0; 114static int num_apples_to_got=0;
92static int game_b_level=1; 115static int game_b_level=1;
116static int applecount=0;
117static char phscore[30];
118
119
120const unsigned char snakebmp[] = {
1210x00, 0x00, 0x00, 0xe0, 0x20, 0xa0, 0xa0, 0x00, 0xe0, 0xa0, 0xa0, 0xe0, 0x00,
1220xe0, 0x40, 0x80, 0x40, 0xe0, 0x00, 0xe0, 0xa0, 0xa0, 0xa0, 0x00, 0x00, 0xf0,
1230x08, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1240x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x08, 0xf0, 0x00, 0x00, 0x00,
1250x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80,
1260x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
1270x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80,
1280x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1290x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x08, 0x04, 0x02, 0x02, 0x02, 0x02,
1300x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
1310x02, 0x04, 0x08, 0xf0, 0x00, 0x00, 0xe0, 0x40, 0x80, 0x40, 0xe0, 0x00, 0xe0,
1320xa0, 0xa0, 0xe0, 0x00, 0x20, 0xa0, 0xa0, 0x60, 0x00, 0xe0, 0xa0, 0xa0, 0xa0,
1330x00, 0x00, 0x00, 0x00,
1340x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00,
1350x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0xc3, 0x22, 0x22, 0x22, 0xc0, 0x00, 0x07,
1360x08, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
1370x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x08, 0x07, 0x00, 0x00, 0x00,
1380x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x27, 0x4c, 0x4c, 0x79, 0x3b,
1390x00, 0x40, 0x7f, 0x47, 0x0e, 0x1c, 0x38, 0x7f, 0x00, 0x40, 0x70, 0x5c, 0x13,
1400x13, 0x5f, 0x7c, 0x70, 0x40, 0x40, 0x7f, 0x7f, 0x48, 0x0c, 0x3e, 0x79, 0x60,
1410x40, 0x40, 0x7f, 0x7f, 0x44, 0x4e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1420x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08, 0x10, 0x20, 0x20, 0x20, 0x20,
1430x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
1440x20, 0x10, 0x08, 0x07, 0x00, 0xe0, 0x13, 0x10, 0x10, 0xe0, 0x03, 0x00, 0x03,
1450x00, 0x00, 0x03, 0x00, 0x03, 0x02, 0x02, 0x02, 0x00, 0x03, 0x02, 0x02, 0x02,
1460x00, 0x00, 0x00, 0x00,
1470x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1480x80, 0x98, 0xa4, 0xa4, 0x98, 0x80, 0x81, 0x02, 0x82, 0x82, 0x01, 0x00, 0x00,
1490x00, 0x17, 0x15, 0x15, 0x1d, 0x80, 0x5f, 0x45, 0x45, 0x42, 0x40, 0x5f, 0x55,
1500x55, 0x55, 0x40, 0x5f, 0x55, 0x55, 0x55, 0x40, 0x5f, 0x51, 0x51, 0x4e, 0x40,
1510x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1520x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xf0, 0xf0, 0x10,
1530x00, 0x10, 0xf0, 0xf0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1540x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x04, 0x04, 0x1f, 0x80, 0x51,
1550x5f, 0x51, 0x44, 0x44, 0x44, 0x40, 0x57, 0x55, 0x55, 0x5d, 0x40, 0x5f, 0x51,
1560x51, 0x51, 0x40, 0x5f, 0x51, 0x51, 0x5f, 0x40, 0x5f, 0x45, 0x4d, 0x92, 0x00,
1570x1f, 0x15, 0x15, 0x15, 0x00, 0x00, 0x01, 0x81, 0x81, 0x00, 0x98, 0xa4, 0xa4,
1580x98, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1590x00, 0x00, 0x00, 0x00,
1600x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x30, 0xf8, 0x8c, 0x1a, 0x7f, 0xc0,
1610x90, 0x60, 0xc7, 0xce, 0x4c, 0x8f, 0x00, 0x47, 0x0e, 0x1e, 0x57, 0x90, 0xe0,
1620x00, 0x10, 0x28, 0xc6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1630x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1640x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1650x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0f, 0x0f, 0x08,
1660x00, 0x08, 0x0f, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1670x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00,
1680x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1690x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1700xc6, 0x28, 0x10, 0x00, 0xe0, 0x90, 0x57, 0x1e, 0x0e, 0x47, 0x00, 0x8f, 0x4c,
1710xce, 0xc7, 0x60, 0x90, 0xc0, 0x7f, 0x1a, 0x8c, 0xf8, 0x30, 0x20, 0xc0, 0x00,
1720x00, 0x00, 0x00, 0x00,
1730x80, 0xf0, 0x9c, 0x16, 0x57, 0x4d, 0xe9, 0xa1, 0xf5, 0xfc, 0x36, 0x3b, 0x39,
1740x37, 0x33, 0x31, 0x30, 0x31, 0x32, 0x35, 0x35, 0x35, 0x35, 0x33, 0x30, 0x30,
1750x30, 0x30, 0x30, 0x30, 0x31, 0x32, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
1760x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
1770x34, 0x34, 0x32, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
1780x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
1790x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
1800x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x32, 0x34,
1810x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
1820x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x32, 0x31,
1830x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x35, 0x35, 0x35, 0x35, 0x32, 0x31,
1840x30, 0x31, 0x33, 0x37, 0x39, 0x3b, 0x36, 0xfc, 0xf5, 0xa1, 0xe9, 0x4d, 0x57,
1850x16, 0x9c, 0xf0, 0x80,
1860xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
1870x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1880x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1890x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1900x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1910x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1920x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1930x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1940x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1950x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1960x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1970x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
1980x25, 0xad, 0x88, 0xff,
1990xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2000x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2010x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2020x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2030x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2040x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2050x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2060x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2070x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2080x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2090x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2100x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2110x25, 0xad, 0x88, 0xff,
2120xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2130x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2140x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2150x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2160x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2170x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2180x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2190x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2200x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2210x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2220x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2230x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2240x25, 0xad, 0x88, 0xff,
2250xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2260x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2270x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2280x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2290x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2300x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2310x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2320x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2330x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2340x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2350x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2360x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2370x25, 0xad, 0x88, 0xff,
2380xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2390x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2400x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2410x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2420x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2430x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2440x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2450x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2460x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2470x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2480x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2490x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2500x25, 0xad, 0x88, 0xff,
2510xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2520x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2530x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2540x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2550x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2560x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2570x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2580x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2590x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2600x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2610x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2620x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2630x25, 0xad, 0x88, 0xff,
2640xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2650x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2660x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2670x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2680x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2690x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2700x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2710x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2720x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2730x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2740x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2750x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2760x25, 0xad, 0x88, 0xff,
2770xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2780x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2790x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2800x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2810x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2820x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2830x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2840x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2850x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2860x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2870x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2880x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
2890x25, 0xad, 0x88, 0xff,
2900xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0x00, 0x00, 0x00,
2910x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2920x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2930x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2940x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2950x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2960x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2970x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2980x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2990x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3000x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3010x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
3020x25, 0xad, 0x88, 0xff,
3030xff, 0x88, 0xad, 0x25, 0x77, 0x52, 0xda, 0x88, 0xff, 0xff, 0xc0, 0xc0, 0xc0,
3040xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3050xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3060xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3070xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3080xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3090xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3100xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3110xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3120xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3130xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
3140xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xff, 0xff, 0x88, 0xda, 0x52, 0x77,
3150x25, 0xad, 0x88, 0xff,
3160x0f, 0x1c, 0x39, 0x6d, 0x77, 0xda, 0x8c, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3,
3170xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e,
3180xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e,
3190xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e,
3200xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3,
3210x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8,
3220x8e, 0xb8, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8,
3230xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3,
3240xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e,
3250xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e,
3260xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e,
3270xe3, 0xb8, 0x8e, 0xb8, 0xe3, 0x8e, 0xb8, 0x8e, 0xe3, 0xb8, 0x8c, 0x5a, 0x77,
3280x6d, 0x39, 0x1c, 0x0f,
329
330};
331
332const unsigned char snakeupbmp[] = {
3330x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3340x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3350x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3360x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3370x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00,
3380x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
3390x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80,
3400x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
3410x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3420x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3430x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3440x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3450x00, 0x00, 0x00, 0x00,
3460x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3470x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3480xc0, 0x40, 0x40, 0xc0, 0x00, 0xc0, 0x40, 0x40, 0x80, 0x00, 0xc0, 0x40, 0x40,
3490x80, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x40, 0x40, 0x00, 0xc0,
3500x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x27, 0x4c, 0x4c, 0x79,
3510x3b, 0x00, 0x40, 0x7f, 0x47, 0x0e, 0x1c, 0x38, 0x7f, 0x00, 0x40, 0x70, 0x5c,
3520x13, 0x13, 0x5f, 0x7c, 0x70, 0x40, 0x40, 0x7f, 0x7f, 0x48, 0x0c, 0x3e, 0x79,
3530x60, 0x40, 0x40, 0x7f, 0x7f, 0x44, 0x4e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00,
3540x00, 0x00, 0xc0, 0x40, 0x40, 0x40, 0x00, 0xc0, 0x40, 0x40, 0x40, 0x00, 0xc0,
3550x40, 0x40, 0xc0, 0x00, 0xc0, 0x40, 0x40, 0x80, 0x00, 0xc0, 0x40, 0x40, 0x40,
3560x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3570x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3580x00, 0x00, 0x00, 0x00,
3590x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
3600x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00,
3610x07, 0x01, 0x01, 0x07, 0x00, 0x87, 0x41, 0x41, 0x40, 0x40, 0x47, 0x41, 0x41,
3620x40, 0x40, 0x47, 0x44, 0x44, 0x44, 0x40, 0x47, 0x45, 0x45, 0x45, 0x40, 0x45,
3630x45, 0x45, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3640x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xf0, 0xf0,
3650x10, 0x00, 0x10, 0xf0, 0xf0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3660x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40,
3670x40, 0x40, 0x45, 0x45, 0x45, 0x47, 0x40, 0x47, 0x44, 0x44, 0x44, 0x40, 0x47,
3680x44, 0x44, 0x47, 0x40, 0x47, 0x41, 0x43, 0x44, 0x40, 0x47, 0x45, 0x85, 0x05,
3690x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80,
3700x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3710x00, 0x00, 0x00, 0x00,
3720x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x30, 0xf8, 0x8c, 0x1a, 0x7f, 0xc0,
3730x90, 0x60, 0xc7, 0xce, 0x4c, 0x8f, 0x00, 0x47, 0x0e, 0x1e, 0x57, 0x90, 0xe0,
3740x00, 0x10, 0x28, 0xc6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3750x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3760x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3770x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0f, 0x0f,
3780x08, 0x00, 0x08, 0x0f, 0x0f, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3790x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00,
3800x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3810x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3820xc6, 0x28, 0x10, 0x00, 0xe0, 0x90, 0x57, 0x1e, 0x0e, 0x47, 0x00, 0x8f, 0x4c,
3830xce, 0xc7, 0x60, 0x90, 0xc0, 0x7f, 0x1a, 0x8c, 0xf8, 0x30, 0x20, 0xc0, 0x00,
3840x00, 0x00, 0x00, 0x00,
3850x00, 0x00, 0x0c, 0x06, 0x07, 0x0d, 0x09, 0x01, 0x05, 0x0c, 0x06, 0x0b, 0x09,
3860x07, 0x03, 0x01, 0x00, 0x01, 0x02, 0x05, 0x05, 0x05, 0x05, 0x03, 0x00, 0x00,
3870x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
3880x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
3890x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3900x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3910x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3920x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04,
3930x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
3940x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x02, 0x01,
3950x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0x05, 0x05, 0x05, 0x02, 0x01,
3960x00, 0x01, 0x03, 0x07, 0x09, 0x0b, 0x06, 0x0c, 0x05, 0x01, 0x09, 0x0d, 0x07,
3970x06, 0x0c, 0x00, 0x00,
398
399};
93 400
94#define NORTH 1 401#define NORTH 1
95#define EAST 2 402#define EAST 2
@@ -107,7 +414,8 @@ static int game_b_level=1;
107#define SOUTH_EAST 2048 414#define SOUTH_EAST 2048
108#define SOUTH_WEST 4096 415#define SOUTH_WEST 4096
109 416
110#define LEVELS_FILE "/.rockbox/snake2.levels" 417#define LEVELS_FILE PLUGIN_DIR "/snake2.levels"
418#define HISCORE_FILE PLUGIN_DIR "/snake2.hs"
111 419
112int load_all_levels(void) 420int load_all_levels(void)
113{ 421{
@@ -155,9 +463,34 @@ int load_all_levels(void)
155 return 0; 463 return 0;
156} 464}
157 465
466/*Hi-Score reading and writing to file "/.rockbox/snake2.levels" function */
467void iohiscore(void)
468{
469 int fd;
470 unsigned int compare,init=0;
471
472 rb->snprintf(phscore,sizeof(phscore),"%d",init);
473
474 fd = rb->open(HISCORE_FILE,O_RDWR | O_CREAT);
475 rb->read(fd,phscore,4);
476
477 compare = rb->atoi(phscore);
478
479 if(hiscore > compare){
480 rb->snprintf(phscore,sizeof(phscore),"%d",hiscore);
481 rb->lseek(fd,0,SEEK_SET);
482 rb->write(fd,phscore,rb->strlen(phscore));
483 }
484 else
485 hiscore = compare;
486
487 rb->close(fd);
488
489}
490
158/* 491/*
159** Completely clear the board of walls and/or snake 492** Completely clear the board of walls and/or snake */
160*/ 493
161void clear_board( void) 494void clear_board( void)
162{ 495{
163 int x,y; 496 int x,y;
@@ -282,6 +615,23 @@ void init_snake(void)
282void draw_apple( void ) 615void draw_apple( void )
283{ 616{
284 int x,y; 617 int x,y;
618
619#ifdef IRIVER_H100
620 char pscore[5], counter[4];
621
622 rb->lcd_bitmap(snakebmp,0,0,BMPWIDTH_snakebmp,BMPHEIGHT_snakebmp,false);
623 rb->lcd_clearrect(0,0,BMPWIDTH_snakeupbmp,BMPHEIGHT_snakeupbmp);
624 rb->lcd_bitmap(snakeupbmp,0,0,BMPWIDTH_snakeupbmp,BMPHEIGHT_snakeupbmp,false);
625
626 rb->snprintf(counter,sizeof(counter),"%d",applecount);
627 rb->lcd_getstringsize(counter,&strwdt,&strhgt);
628 rb->lcd_putsxy(42-strwdt/2,25,counter);
629
630 rb->snprintf(pscore,sizeof(pscore),"%d",score);
631 rb->lcd_getstringsize(pscore,&strwdt,&strhgt);
632 rb->lcd_putsxy(116-strwdt/2,25,pscore);
633#endif
634
285 if (!apple) 635 if (!apple)
286 { 636 {
287 do 637 do
@@ -293,8 +643,8 @@ void draw_apple( void )
293 board[x][y]=-1; 643 board[x][y]=-1;
294 applex = x;appley = y; 644 applex = x;appley = y;
295 } 645 }
296 rb->lcd_fillrect((applex*4)+1,appley*4,2,4); 646 rb->lcd_fillrect((CENTER_X+applex*MULTIPLIER)+1,CENTER_Y+appley*MULTIPLIER,MODIFIER_2,MODIFIER_1);
297 rb->lcd_fillrect(applex*4,(appley*4)+1,4,2); 647 rb->lcd_fillrect(CENTER_X+applex*MULTIPLIER,(CENTER_Y+appley*MULTIPLIER)+1,MODIFIER_1,MODIFIER_2);
298} 648}
299 649
300/* 650/*
@@ -305,7 +655,7 @@ void draw_apple( void )
305*/ 655*/
306void draw_vertical_bit(int x, int y) 656void draw_vertical_bit(int x, int y)
307{ 657{
308 rb->lcd_fillrect(x*4+1,y*4,2,4); 658 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+1,CENTER_Y+y*MULTIPLIER,MODIFIER_2,MODIFIER_1);
309} 659}
310 660
311/* 661/*
@@ -316,7 +666,7 @@ void draw_vertical_bit(int x, int y)
316*/ 666*/
317void draw_horizontal_bit(int x, int y) 667void draw_horizontal_bit(int x, int y)
318{ 668{
319 rb->lcd_fillrect(x*4,y*4+1,4,2); 669 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER,CENTER_Y+y*MULTIPLIER+1,MODIFIER_1,MODIFIER_2);
320} 670}
321 671
322/* 672/*
@@ -327,8 +677,8 @@ void draw_horizontal_bit(int x, int y)
327*/ 677*/
328void draw_n_to_e_bit(int x, int y) 678void draw_n_to_e_bit(int x, int y)
329{ 679{
330 rb->lcd_fillrect(x*4+1,y*4+2,2,2); 680 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+1,CENTER_Y+y*MULTIPLIER+2,MODIFIER_2,MODIFIER_2);
331 rb->lcd_fillrect(x*4+2,y*4+1,2,2); 681 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+2,CENTER_Y+y*MULTIPLIER+1,MODIFIER_2,MODIFIER_2);
332} 682}
333 683
334/* 684/*
@@ -350,8 +700,8 @@ void draw_w_to_s_bit(int x, int y)
350*/ 700*/
351void draw_n_to_w_bit(int x, int y) 701void draw_n_to_w_bit(int x, int y)
352{ 702{
353 rb->lcd_fillrect(x*4,y*4+1,2,2); 703 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER,CENTER_Y+y*MULTIPLIER+1,MODIFIER_2,MODIFIER_2);
354 rb->lcd_fillrect(x*4+1,y*4+2,2,2); 704 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+1,CENTER_Y+y*MULTIPLIER+2,MODIFIER_2,MODIFIER_2);
355} 705}
356 706
357/* 707/*
@@ -373,8 +723,8 @@ void draw_e_to_s_bit(int x, int y)
373*/ 723*/
374void draw_s_to_e_bit(int x, int y) 724void draw_s_to_e_bit(int x, int y)
375{ 725{
376 rb->lcd_fillrect(x*4+1,y*4,2,2); 726 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+1,CENTER_Y+y*MULTIPLIER,MODIFIER_2,MODIFIER_2);
377 rb->lcd_fillrect(x*4+2,y*4+1,2,2); 727 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+2,CENTER_Y+y*MULTIPLIER+1,MODIFIER_2,MODIFIER_2);
378} 728}
379 729
380/* 730/*
@@ -396,8 +746,8 @@ void draw_w_to_n_bit(int x, int y)
396*/ 746*/
397void draw_e_to_n_bit(int x, int y) 747void draw_e_to_n_bit(int x, int y)
398{ 748{
399 rb->lcd_fillrect(x*4+1,y*4,2,2); 749 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER+1,CENTER_Y+y*MULTIPLIER,MODIFIER_2,MODIFIER_2);
400 rb->lcd_fillrect(x*4,y*4+1,2,2); 750 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER,CENTER_Y+y*MULTIPLIER+1,MODIFIER_2,MODIFIER_2);
401} 751}
402 752
403/* 753/*
@@ -456,8 +806,8 @@ void redraw (void)
456 switch (board[x][y]) 806 switch (board[x][y])
457 { 807 {
458 case -1: 808 case -1:
459 rb->lcd_fillrect((x*4)+1,y*4,2,4); 809 rb->lcd_fillrect((CENTER_X+x*MULTIPLIER)+1,CENTER_Y+y*MULTIPLIER,MODIFIER_2,MODIFIER_1);
460 rb->lcd_fillrect(x*4,(y*4)+1,4,2); 810 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER,(CENTER_Y+y*MULTIPLIER)+1,MODIFIER_1,MODIFIER_2);
461 break; 811 break;
462 case 0: 812 case 0:
463 break; 813 break;
@@ -473,12 +823,13 @@ void redraw (void)
473 break; 823 break;
474 824
475 default: 825 default:
476 rb->lcd_fillrect(x*4,y*4,4,4); 826 rb->lcd_fillrect(CENTER_X+x*MULTIPLIER,CENTER_Y+y*MULTIPLIER,MODIFIER_1,MODIFIER_1);
477 break; 827 break;
478 } 828 }
479 } 829 }
480 } 830 }
481 rb->lcd_update(); 831 rb->lcd_update();
832
482} 833}
483 834
484/* 835/*
@@ -487,7 +838,8 @@ void redraw (void)
487*/ 838*/
488void draw_snake_bit(int currentbit, int previousbit, int x, int y) 839void draw_snake_bit(int currentbit, int previousbit, int x, int y)
489{ 840{
490 rb->lcd_clearrect(x*4,y*4,4,4); 841 rb->lcd_clearrect(CENTER_X+x*MULTIPLIER,CENTER_Y+y*MULTIPLIER,MODIFIER_1,MODIFIER_1);
842
491 switch(currentbit) 843 switch(currentbit)
492 { 844 {
493 case(NORTH): 845 case(NORTH):
@@ -571,8 +923,7 @@ void die (void)
571{ 923{
572 int n=100; 924 int n=100;
573 int count; 925 int count;
574 char pscore[15],hscore[17]; 926 char pscore[18];
575
576 /*Flashy death sequence (flashy as in 'flashes')*/ 927 /*Flashy death sequence (flashy as in 'flashes')*/
577 for(count=0;count<24;count++) 928 for(count=0;count<24;count++)
578 { 929 {
@@ -589,20 +940,28 @@ void die (void)
589 rb->lcd_clear_display(); 940 rb->lcd_clear_display();
590 draw_apple(); 941 draw_apple();
591 rb->lcd_update(); 942 rb->lcd_update();
943 rb->lcd_clear_display();
944
945 applecount=0;
946
947 rb->lcd_getstringsize("Dead",&strwdt,&strhgt);
948 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt,"Dead");
949
950 rb->snprintf(pscore,sizeof(pscore),"Your Score %d",score);
951 rb->lcd_getstringsize(pscore,&strwdt,&strhgt);
952 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 2 + 2,pscore);
592 953
593 rb->snprintf(pscore,sizeof(pscore),"%d",score);
594 rb->lcd_putsxy(LCD_WIDTH/2 - 15,12,"Dead");
595 rb->lcd_putsxy(LCD_WIDTH/2 - 35,22,"Your score :");
596 rb->lcd_putsxy(LCD_WIDTH/2 - 35,32, pscore);
597 if (score>hiscore) 954 if (score>hiscore)
598 { 955 {
599 hiscore=score; 956 hiscore=score;
600 rb->lcd_putsxy(3,42,"New High Score!"); 957 rb->lcd_getstringsize("New High Score!",&strwdt,&strhgt);
958 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 4 + 2,"New High Score!");
601 } 959 }
602 else 960 else
603 { 961 {
604 rb->snprintf(hscore,sizeof(hscore),"High Score: %d",hiscore); 962 rb->snprintf(phscore,sizeof(phscore),"High Score: %d",hiscore);
605 rb->lcd_putsxy(5,42,hscore); 963 rb->lcd_getstringsize(phscore,&strwdt,&strhgt);
964 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt * 6,phscore);
606 } 965 }
607 rb->lcd_update(); 966 rb->lcd_update();
608 rb->sleep(3*HZ); 967 rb->sleep(3*HZ);
@@ -618,15 +977,17 @@ void collision ( int x, int y )
618{ 977{
619 int bdeath=0; 978 int bdeath=0;
620 979
980
621 switch (board[x][y]) 981 switch (board[x][y])
622 { 982 {
623 case 0: 983 case 0:
624 984
625 break; 985 break;
626 case -1: 986 case -1:
627 score+=2; 987 score = score + (1 * level);
628 apple=0; 988 apple=0;
629 applecountdown=2; 989 applecountdown=2;
990 applecount++;
630 991
631 if(game_type==1) 992 if(game_type==1)
632 { 993 {
@@ -699,12 +1060,12 @@ void move( void )
699 else if(heady < 0) 1060 else if(heady < 0)
700 heady = HEIGHT-1; 1061 heady = HEIGHT-1;
701 1062
702 rb->lcd_fillrect(headx*4,heady*4,4,4); 1063 rb->lcd_fillrect(CENTER_X+headx*MULTIPLIER,CENTER_Y+heady*MULTIPLIER,MODIFIER_1,MODIFIER_1);
703 1064
704 /*clear tail*/ 1065 /*clear tail*/
705 if(applecountdown <= 0) 1066 if(applecountdown <= 0)
706 { 1067 {
707 rb->lcd_clearrect(tailx*4,taily*4,4,4); 1068 rb->lcd_clearrect(CENTER_X+tailx*MULTIPLIER,CENTER_Y+taily*MULTIPLIER,MODIFIER_1,MODIFIER_1);
708 1069
709 taildir = board[tailx][taily]; 1070 taildir = board[tailx][taily];
710 board[tailx][taily] = 0; 1071 board[tailx][taily] = 0;
@@ -805,7 +1166,8 @@ void game_pause (void)
805 int button; 1166 int button;
806 1167
807 rb->lcd_clear_display(); 1168 rb->lcd_clear_display();
808 rb->lcd_putsxy(33,12,"Paused"); 1169 rb->lcd_getstringsize("Paused",&strwdt,&strhgt);
1170 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,LCD_HEIGHT/2,"Paused");
809 1171
810 rb->lcd_update(); 1172 rb->lcd_update();
811 while (1) 1173 while (1)
@@ -905,13 +1267,13 @@ void game (void)
905 break; 1267 break;
906 } 1268 }
907 } 1269 }
1270
908} 1271}
909 1272
910void game_init(void) 1273void game_init(void)
911{ 1274{
912 int button; 1275 int button;
913 char plevel[30]; 1276 char plevel[30];
914 char phscore[30];
915 1277
916 dead=0; 1278 dead=0;
917 apple=0; 1279 apple=0;
@@ -924,27 +1286,55 @@ void game_init(void)
924 { 1286 {
925 rb->lcd_clear_display(); 1287 rb->lcd_clear_display();
926 redraw(); 1288 redraw();
927 /*TODO: CENTER ALL TEXT!!!!*/ 1289
928 rb->snprintf(plevel,sizeof(plevel),"Speed - %d",level); 1290#ifdef IRIVER_H100
929 rb->lcd_putsxy(LCD_WIDTH/2 - 30,5, plevel); 1291
930#if CONFIG_KEYPAD == RECORDER_PAD 1292 rb->lcd_bitmap(snakebmp,0,0,BMPWIDTH_snakebmp,BMPWIDTH_snakebmp,false);
931 rb->snprintf(plevel,sizeof(plevel),"F1 - Maze %d",level_from_file); 1293
932 rb->lcd_putsxy(18, 20, plevel); 1294 rb->snprintf(plevel,sizeof(plevel),"%d",level);
933 if(game_type==0) 1295 rb->lcd_getstringsize(plevel,&strwdt,&strhgt);
934 rb->lcd_putsxy(18, 30, "F3 - Game A"); 1296 rb->lcd_putsxy(42-strwdt/2,25, plevel);
935 else 1297
936 rb->lcd_putsxy(18, 30, "F3 - Game B"); 1298 rb->snprintf(plevel,sizeof(plevel),"%d",level_from_file);
937#elif CONFIG_KEYPAD == ONDIO_PAD 1299 rb->lcd_getstringsize(plevel,&strwdt,&strhgt);
938 rb->snprintf(plevel,sizeof(plevel),"Left - Maze %d",level_from_file); 1300 rb->lcd_putsxy(121-strwdt/2,4, plevel);
939 rb->lcd_putsxy(18, 20, plevel); 1301
940 if(game_type==0) 1302 if(game_type==0){
941 rb->lcd_putsxy(12, 30, "Right - Game A"); 1303 rb->lcd_getstringsize("A",&strwdt,&strhgt);
942 else 1304 rb->lcd_putsxy(34,4,"A");
943 rb->lcd_putsxy(12, 30, "Right - Game B"); 1305 }
944#endif 1306 else{
1307 rb->lcd_getstringsize("B",&strwdt,&strhgt);
1308 rb->lcd_putsxy(34,4,"B");
1309 }
1310
1311 rb->snprintf(phscore,sizeof(phscore),"%d",hiscore);
1312 rb->lcd_getstringsize(phscore,&strwdt,&strhgt);
1313 rb->lcd_putsxy(114-strwdt/2,25, phscore);
1314
1315#else
1316 rb->snprintf(plevel,sizeof(plevel),"Speed: %d",level);
1317 rb->lcd_getstringsize("Speed: 00",&strwdt,&strhgt);
1318 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt+4, plevel);
1319
1320 rb->snprintf(plevel,sizeof(plevel),"Maze: %d",level_from_file);
1321 rb->lcd_getstringsize(plevel,&strwdt,&strhgt);
1322 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*2+4, plevel);
1323
1324 if(game_type==0){
1325 rb->lcd_getstringsize("Game Type: A ",&strwdt,&strhgt);
1326 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*3+4,"Game Type: A");
1327 }
1328 else{
1329 rb->lcd_getstringsize("Game Type: B ",&strwdt,&strhgt);
1330 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*3+4,"Game Type: B");
1331 }
945 1332
946 rb->snprintf(phscore,sizeof(phscore),"Hi Score: %d",hiscore); 1333 rb->snprintf(phscore,sizeof(phscore),"Hi Score: %d",hiscore);
947 rb->lcd_putsxy(LCD_WIDTH/2 - 37,50, phscore); 1334 rb->lcd_getstringsize(phscore,&strwdt,&strhgt);
1335 rb->lcd_putsxy((LCD_WIDTH - strwdt)/2,strhgt*4+4, phscore);
1336#endif
1337
948 rb->lcd_update(); 1338 rb->lcd_update();
949 1339
950 button=rb->button_get(true); 1340 button=rb->button_get(true);
@@ -994,6 +1384,7 @@ void game_init(void)
994 break; 1384 break;
995 } 1385 }
996 } 1386 }
1387
997} 1388}
998 1389
999enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 1390enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -1011,6 +1402,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1011 return PLUGIN_OK; 1402 return PLUGIN_OK;
1012 } 1403 }
1013 1404
1405 iohiscore();
1406
1014 while(quit==0) 1407 while(quit==0)
1015 { 1408 {
1016 game_init(); 1409 game_init();
@@ -1026,6 +1419,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1026 } 1419 }
1027 } 1420 }
1028 1421
1422 iohiscore();
1029 return (quit==1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED; 1423 return (quit==1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;
1030} 1424}
1031 1425