diff options
Diffstat (limited to 'apps/plugins/flipit.c')
-rw-r--r-- | apps/plugins/flipit.c | 97 |
1 files changed, 24 insertions, 73 deletions
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c index 8a493044cf..bcd705c16c 100644 --- a/apps/plugins/flipit.c +++ b/apps/plugins/flipit.c | |||
@@ -37,11 +37,11 @@ | |||
37 | 37 | ||
38 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | 38 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD |
39 | #define FLIPIT_QUIT BUTTON_OFF | 39 | #define FLIPIT_QUIT BUTTON_OFF |
40 | #define FLIPIT_SHUFFLE BUTTON_MODE | 40 | #define FLIPIT_SHUFFLE BUTTON_SELECT |
41 | #define FLIPIT_SOLVE BUTTON_ON | 41 | #define FLIPIT_SOLVE BUTTON_ON |
42 | #define FLIPIT_STEP_BY_STEP BUTTON_REC | 42 | #define FLIPIT_STEP_BY_STEP BUTTON_REC |
43 | #define FLIPIT_TOGGLE_PRE BUTTON_SELECT | 43 | #define FLIPIT_TOGGLE_PRE BUTTON_MODE |
44 | #define FLIPIT_TOGGLE (BUTTON_SELECT | BUTTON_REL) | 44 | #define FLIPIT_TOGGLE (BUTTON_MODE | BUTTON_REL) |
45 | 45 | ||
46 | #endif | 46 | #endif |
47 | 47 | ||
@@ -51,43 +51,6 @@ static int toggle[20]; | |||
51 | static int cursor_pos, moves; | 51 | static int cursor_pos, moves; |
52 | static char s[5]; | 52 | static char s[5]; |
53 | static char *ptr; | 53 | static char *ptr; |
54 | |||
55 | #if LCD_WIDTH == 160 | ||
56 | #define SPOT_SIZE 20 | ||
57 | #define SPOT_SPACE 4 | ||
58 | #define MARGIN_TOP 16 | ||
59 | #define MARGIN_LEFT 5 | ||
60 | static unsigned char spot_pic[2][60] = { | ||
61 | { 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
62 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, | ||
63 | 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
64 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, | ||
65 | 0x00, 0x01, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, | ||
66 | 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x01, 0x00, }, | ||
67 | { 0xe0, 0x18, 0x0c, 0x06, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, | ||
68 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x06, 0x0c, 0x18, 0xe0, | ||
69 | 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, | ||
71 | 0x00, 0x01, 0x03, 0x06, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, | ||
72 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x06, 0x03, 0x01, 0x00, } | ||
73 | }; | ||
74 | |||
75 | #define CURSOR_SIZE 22 | ||
76 | static unsigned char cursor_pic[66] = { | ||
77 | 0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, | ||
78 | 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, | ||
79 | 0x01, 0xaa, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
81 | 0x00, 0x00, 0x00, 0xaa, 0x15, 0x20, 0x00, 0x20, 0x00, 0x20, | ||
82 | 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, | ||
83 | 0x00, 0x20, 0x00, 0x20, 0x00, 0x2a, | ||
84 | }; | ||
85 | |||
86 | #else | ||
87 | #define SPOT_SIZE 14 | ||
88 | #define SPOT_SPACE 2 | ||
89 | #define MARGIN_TOP 0 | ||
90 | #define MARGIN_LEFT 0 | ||
91 | static unsigned char spot_pic[2][28] = { | 54 | static unsigned char spot_pic[2][28] = { |
92 | { 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, | 55 | { 0xe0, 0xf8, 0xfc, 0xfe, 0xfe, 0xff, 0xff, |
93 | 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, | 56 | 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xe0, |
@@ -98,47 +61,41 @@ static unsigned char spot_pic[2][28] = { | |||
98 | 0x01, 0x06, 0x08, 0x10, 0x10, 0x20, 0x20, | 61 | 0x01, 0x06, 0x08, 0x10, 0x10, 0x20, 0x20, |
99 | 0x20, 0x20, 0x10, 0x10, 0x08, 0x06, 0x01 } | 62 | 0x20, 0x20, 0x10, 0x10, 0x08, 0x06, 0x01 } |
100 | }; | 63 | }; |
101 | |||
102 | #define CURSOR_SIZE 16 | ||
103 | static unsigned char cursor_pic[32] = { | 64 | static unsigned char cursor_pic[32] = { |
104 | 0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, | 65 | 0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, |
105 | 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xaa, | 66 | 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xaa, |
106 | 0x55, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, | 67 | 0x55, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, |
107 | 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xaa }; | 68 | 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xaa }; |
108 | #endif | 69 | |
109 | 70 | ||
110 | /* draw a spot at the coordinates (x,y), range of p is 0-19 */ | 71 | /* draw a spot at the coordinates (x,y), range of p is 0-19 */ |
111 | static void draw_spot(int p) { | 72 | static void draw_spot(int p) { |
112 | ptr = spot_pic[spots[p]]; | 73 | ptr = spot_pic[spots[p]]; |
113 | int x,y; | ||
114 | x = (p%5)*(SPOT_SIZE + SPOT_SPACE)+1 + MARGIN_LEFT; | ||
115 | y = (p/5)*(SPOT_SIZE + SPOT_SPACE)+1 + MARGIN_TOP; | ||
116 | rb->lcd_bitmap (ptr, x, y, SPOT_SIZE, SPOT_SIZE, true); | ||
117 | /* | ||
118 | rb->lcd_bitmap (ptr, (p%5)*16+1, (p/5)*16+1, 14, 8, true); | 74 | rb->lcd_bitmap (ptr, (p%5)*16+1, (p/5)*16+1, 14, 8, true); |
119 | ptr += 14; | 75 | ptr += 14; |
120 | rb->lcd_bitmap (ptr, (p%5)*16+1, (p/5)*16+9, 14, 6, true); | 76 | rb->lcd_bitmap (ptr, (p%5)*16+1, (p/5)*16+9, 14, 6, true); |
121 | */ | ||
122 | } | 77 | } |
123 | 78 | ||
124 | /* draw the cursor at the current cursor position */ | 79 | /* draw the cursor at the current cursor position */ |
125 | static void draw_cursor(void) { | 80 | static void draw_cursor(void) { |
126 | int i,j; | 81 | int i,j; |
127 | i = (cursor_pos%5)*CURSOR_SIZE + (SPOT_SPACE/2)*(cursor_pos%5) + MARGIN_LEFT; | 82 | i = (cursor_pos%5)*16; |
128 | j = (cursor_pos/5)*CURSOR_SIZE + (SPOT_SPACE/2)*(cursor_pos/5) + MARGIN_TOP; | 83 | j = (cursor_pos/5)*16; |
129 | ptr = cursor_pic; | 84 | ptr = cursor_pic; |
130 | rb->lcd_bitmap (ptr, i, j, CURSOR_SIZE, CURSOR_SIZE, false); | 85 | rb->lcd_bitmap (ptr, i, j, 16, 8, false); |
86 | ptr += 16; | ||
87 | rb->lcd_bitmap (ptr, i, j+8, 16, 8, false); | ||
131 | } | 88 | } |
132 | 89 | ||
133 | /* clear the cursor where it is */ | 90 | /* clear the cursor where it is */ |
134 | static void clear_cursor(void) { | 91 | static void clear_cursor(void) { |
135 | int i,j; | 92 | int i,j; |
136 | i = (cursor_pos%5)*CURSOR_SIZE + (SPOT_SPACE/2)*(cursor_pos%5) + MARGIN_LEFT; | 93 | i = (cursor_pos%5)*16; |
137 | j = (cursor_pos/5)*CURSOR_SIZE + (SPOT_SPACE/2)*(cursor_pos/5) + MARGIN_TOP; | 94 | j = (cursor_pos/5)*16; |
138 | rb->lcd_clearline(i, j, i+CURSOR_SIZE-1, j); | 95 | rb->lcd_clearline(i, j, i+15, j); |
139 | rb->lcd_clearline(i, j+CURSOR_SIZE-1, i+CURSOR_SIZE-1, j+CURSOR_SIZE-1); | 96 | rb->lcd_clearline(i, j+15, i+15, j+15); |
140 | rb->lcd_clearline(i, j, i, j+CURSOR_SIZE-1); | 97 | rb->lcd_clearline(i, j, i, j+15); |
141 | rb->lcd_clearline(i+CURSOR_SIZE-1, j, i+CURSOR_SIZE-1, j+CURSOR_SIZE-1); | 98 | rb->lcd_clearline(i+15, j, i+15, j+15); |
142 | } | 99 | } |
143 | 100 | ||
144 | /* check if the puzzle is finished */ | 101 | /* check if the puzzle is finished */ |
@@ -174,7 +131,7 @@ static void flipit_toggle(void) { | |||
174 | } | 131 | } |
175 | moves++; | 132 | moves++; |
176 | rb->snprintf(s, sizeof(s), "%d", moves); | 133 | rb->snprintf(s, sizeof(s), "%d", moves); |
177 | rb->lcd_putsxy(LCD_WIDTH - 27, 20, s); | 134 | rb->lcd_putsxy(85, 20, s); |
178 | if (flipit_finished()) | 135 | if (flipit_finished()) |
179 | clear_cursor(); | 136 | clear_cursor(); |
180 | } | 137 | } |
@@ -194,8 +151,8 @@ static void flipit_init(void) { | |||
194 | int i; | 151 | int i; |
195 | rb->lcd_clear_display(); | 152 | rb->lcd_clear_display(); |
196 | moves = 0; | 153 | moves = 0; |
197 | rb->lcd_drawrect(LCD_WIDTH - 32, 0, 32, LCD_HEIGHT); | 154 | rb->lcd_drawrect(80, 0, 32, 64); |
198 | rb->lcd_putsxy(LCD_WIDTH - 31, 10, "Flips"); | 155 | rb->lcd_putsxy(81, 10, "Flips"); |
199 | for (i=0; i<20; i++) { | 156 | for (i=0; i<20; i++) { |
200 | spots[i]=1; | 157 | spots[i]=1; |
201 | toggle[i]=1; | 158 | toggle[i]=1; |
@@ -210,11 +167,11 @@ static void flipit_init(void) { | |||
210 | cursor_pos = 0; | 167 | cursor_pos = 0; |
211 | draw_cursor(); | 168 | draw_cursor(); |
212 | moves = 0; | 169 | moves = 0; |
213 | rb->lcd_clearrect(LCD_WIDTH - 32, 0, 32, LCD_HEIGHT); | 170 | rb->lcd_clearrect(80, 0, 32, 64); |
214 | rb->lcd_drawrect(LCD_WIDTH - 32, 0, 32, LCD_HEIGHT); | 171 | rb->lcd_drawrect(80, 0, 32, 64); |
215 | rb->lcd_putsxy(LCD_WIDTH - 31, 10, "Flips"); | 172 | rb->lcd_putsxy(81, 10, "Flips"); |
216 | rb->snprintf(s, sizeof(s), "%d", moves); | 173 | rb->snprintf(s, sizeof(s), "%d", moves); |
217 | rb->lcd_putsxy(LCD_WIDTH - 27, 20, s); | 174 | rb->lcd_putsxy(85, 20, s); |
218 | rb->lcd_update(); | 175 | rb->lcd_update(); |
219 | } | 176 | } |
220 | 177 | ||
@@ -341,19 +298,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
341 | rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle"); | 298 | rb->lcd_putsxy(2, 28, "[M-LEFT] shuffle"); |
342 | rb->lcd_putsxy(2, 38, "[M-UP] solution"); | 299 | rb->lcd_putsxy(2, 38, "[M-UP] solution"); |
343 | rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step"); | 300 | rb->lcd_putsxy(2, 48, "[M-RIGHT] step by step"); |
344 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | ||
345 | rb->lcd_putsxy(2, 8, "[STOP] to stop"); | ||
346 | rb->lcd_putsxy(2, 18, "[SELECT] toggle"); | ||
347 | rb->lcd_putsxy(2, 28, "[MODE] shuffle"); | ||
348 | rb->lcd_putsxy(2, 38, "[PLAY] solution"); | ||
349 | rb->lcd_putsxy(2, 48, "[REC] step by step"); | ||
350 | #endif | 301 | #endif |
351 | rb->lcd_update(); | 302 | rb->lcd_update(); |
352 | rb->sleep(HZ*3); | 303 | rb->sleep(HZ*3); |
353 | 304 | ||
354 | rb->lcd_clear_display(); | 305 | rb->lcd_clear_display(); |
355 | rb->lcd_drawrect(LCD_WIDTH - 32, 0, 32, LCD_HEIGHT); | 306 | rb->lcd_drawrect(80, 0, 32, 64); |
356 | rb->lcd_putsxy(LCD_WIDTH - 31, 10, "Flips"); | 307 | rb->lcd_putsxy(81, 10, "Flips"); |
357 | for (i=0; i<20; i++) { | 308 | for (i=0; i<20; i++) { |
358 | spots[i]=1; | 309 | spots[i]=1; |
359 | draw_spot(i); | 310 | draw_spot(i); |