1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Adam Boot
12 * Color graphics from Frozen Bubble (http://www.frozen-bubble.org/)
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
26 #ifdef HAVE_LCD_BITMAP
29 #include "lib/pluginlib_actions.h"
30 #include "lib/fixedpoint.h"
31 #include "lib/playback_control.h"
32 #include "lib/highscore.h"
37 #define SCORE_FILE PLUGIN_GAMES_DIR "/bubbles.score"
38 #define SAVE_FILE PLUGIN_GAMES_DIR "/bubbles.save"
39 #define DATA_FILE PLUGIN_GAMES_DIR "/bubbles.data"
41 /* final game return status */
44 BB_QUIT_WITHOUT_SAVING
,
52 /* play board dimension */
55 #define BB_LEVEL_HEIGHT 10
59 #define NUM_LEVELS 100
64 #define NUM_COMPRESS 9
65 #define MAX_SHOTTIME 1000
67 /* keyboard layouts */
69 #ifdef HAVE_SCROLLWHEEL
70 /* sansas use the wheel instead of left/right if available */
71 #define BUBBLES_LEFT PLA_SCROLL_BACK
72 #define BUBBLES_LEFT_REP PLA_SCROLL_BACK_REPEAT
73 #define BUBBLES_RIGHT PLA_SCROLL_FWD
74 #define BUBBLES_RIGHT_REP PLA_SCROLL_FWD_REPEAT
76 #define BUBBLES_LEFT PLA_LEFT
77 #define BUBBLES_LEFT_REP PLA_LEFT_REPEAT
78 #define BUBBLES_RIGHT PLA_RIGHT
79 #define BUBBLES_RIGHT_REP PLA_RIGHT_REPEAT
83 #define ANGLE_STEP_REP 4
85 #define BUBBLES_QUIT1 PLA_EXIT
86 #define BUBBLES_QUIT2 PLA_CANCEL
88 /* these are better off shooting with up */
89 #if (CONFIG_KEYPAD == SAMSUNG_YH_PAD) \
90 || (CONFIG_KEYPAD == ONDIO_PAD) \
91 || (CONFIG_KEYPAD == IRIVER_H10_PAD)
96 #define BUBBLES_FIRE PLA_UP
97 #define BUBBLES_FIRE_REPEAT PLA_UP_REPEAT
98 #define BUBBLES_PAUSE PLA_SELECT
100 #define BUBBLES_FIRE PLA_SELECT
101 #define BUBBLES_FIRE_REPEAT PLA_SELECT_REPEAT
102 #define BUBBLES_PAUSE PLA_UP
105 /* external bitmaps */
106 #ifdef HAVE_LCD_COLOR
107 #include "pluginbitmaps/bubbles_background.h"
109 #include "pluginbitmaps/bubbles_bubble.h"
110 #include "pluginbitmaps/bubbles_emblem.h"
112 #define BUBBLE_WIDTH BMPWIDTH_bubbles_bubble
113 #define BUBBLE_HEIGHT BMPHEIGHT_bubbles_bubble
114 #define EMBLEM_WIDTH BMPWIDTH_bubbles_emblem
115 #define EMBLEM_HEIGHT (BMPHEIGHT_bubbles_emblem/8)
117 /* bubbles will consume height of ROW_HEIGHT*(BB_HEIGHT-1)+BUBBLE_HEIGHT*3/2 */
118 /* 44x44 bubbles (m:robe 500) */
119 #if (LCD_WIDTH == 640) && (LCD_HEIGHT == 480)
123 #elif (LCD_WIDTH == 480) && (LCD_HEIGHT == 640)
127 /* 22x22 bubbles (iPod Video) */
128 #elif (LCD_HEIGHT == 240) && (LCD_WIDTH == 320)
132 /* 22x22 bubbles (Gigabeat, Onda VX747) */
133 #elif ((LCD_HEIGHT == 320) || (LCD_HEIGHT == 400)) && (LCD_WIDTH == 240)
137 /* 16x16 bubbles (H300, iPod Color, HDD6330) */
138 #elif (LCD_HEIGHT == 176) && (LCD_WIDTH == 220)
142 /* 16x16 bubbles (Sansa E200) */
143 #elif (LCD_HEIGHT == 220) && (LCD_WIDTH == 176)
148 /* custom text positioning */
149 #define LEVEL_TXT_X 24
150 #define LEVEL_TXT_WIDTH 31
151 #define LEVEL_TXT_Y 5
152 #define SCORE_TXT_X 58
153 #define SCORE_TXT_WIDTH 31
154 #define SCORE_TXT_Y 5
155 #define NEXT_BB_X 112
156 #define NEXT_BB_WIDTH 31
159 /* 12x12 bubbles (iPod Nano) */
160 #elif (LCD_HEIGHT == 132) && (LCD_WIDTH == 176)
164 /* 12x12 bubbles (H100, H10, iAudio X5, HDD1630, iPod 3G, iPod 4G grayscale) */
165 #elif (LCD_HEIGHT == 128) && ((LCD_WIDTH == 160) || (LCD_WIDTH == 128))
169 /* 12x12 bubbles (GoGear SA9200) */
170 #elif (LCD_HEIGHT == 160) && (LCD_WIDTH == 128)
172 #define ROW_HEIGHT 10
176 /* 10x10 bubbles (iPod Mini) */
177 #elif (LCD_HEIGHT == 110) && (LCD_WIDTH == 138)
181 /* 9x9 bubbles (iAudio M3) */
182 #elif (LCD_HEIGHT == 96) && (LCD_WIDTH == 128)
186 /* 8x8 bubbles (Sansa C200) */
187 #elif ((LCD_HEIGHT == 80) && (LCD_WIDTH == 132))
192 /* 7x7 bubbles (Sansa Clip/m200) */
193 #elif (LCD_HEIGHT == 64 && LCD_WIDTH == 128)
198 /* 8x7 bubbles (Archos recorder, Ondio) */
199 #elif (LCD_HEIGHT == 64) && (LCD_WIDTH == 112)
205 #error BUBBLES: Unsupported LCD type
208 #if !defined(ROW_HEIGHT)
209 #define ROW_HEIGHT (BUBBLE_WIDTH-(BUBBLE_WIDTH-EMBLEM_WIDTH)/2)
212 #define ROW_INDENT (BUBBLE_WIDTH/2)
214 #define TEXT_LINES (LCD_HEIGHT/8)
221 #define SHOTX XOFS+ROW_INDENT+BUBBLE_WIDTH*3
222 #define SHOTY (YOFS+ROW_HEIGHT*(BB_HEIGHT-1)+BUBBLE_HEIGHT/2)
224 /* collision distance squared */
225 #define MIN_DISTANCE ((BUBBLE_WIDTH*8)/10)*((BUBBLE_HEIGHT*8)/10)
228 char level
[NUM_LEVELS
][BB_LEVEL_HEIGHT
][BB_WIDTH
] = {
229 {{ 6, 6, 4, 4, 2, 2, 3, 3},
230 { 6, 6, 4, 4, 2, 2, 3, -1},
231 { 2, 2, 3, 3, 6, 6, 4, 4},
232 { 2, 3, 3, 6, 6, 4, 4, -1},
233 {-1, -1, -1, -1, -1, -1, -1, -1},
234 {-1, -1, -1, -1, -1, -1, -1, -1},
235 {-1, -1, -1, -1, -1, -1, -1, -1},
236 {-1, -1, -1, -1, -1, -1, -1, -1},
237 {-1, -1, -1, -1, -1, -1, -1, -1},
238 {-1, -1, -1, -1, -1, -1, -1, -1}},
239 {{-1, 7, 7, 7, 7, 7, 7, -1},
240 {-1, 1, 1, 1, 1, 1, -1, -1},
241 {-1, -1, 2, 2, 2, 2, -1, -1},
242 {-1, -1, -1, 2, -1, -1, -1, -1},
243 {-1, -1, -1, 2, 2, -1, -1, -1},
244 {-1, -1, -1, 5, -1, -1, -1, -1},
245 {-1, -1, -1, 5, 5, -1, -1, -1},
246 {-1, -1, -1, -1, -1, -1, -1, -1},
247 {-1, -1, -1, -1, -1, -1, -1, -1},
248 {-1, -1, -1, -1, -1, -1, -1, -1}},
249 {{-1, -1, 7, -1, -1, 7, -1, -1},
250 {-1, -1, 7, 1, 7, -1, -1, -1},
251 {-1, -1, -1, 1, 2, -1, -1, -1},
252 {-1, -1, 1, 2, 1, -1, -1, -1},
253 {-1, -1, -1, 2, 5, -1, -1, -1},
254 {-1, -1, 3, 5, 3, -1, -1, -1},
255 {-1, -1, -1, 5, 3, -1, -1, -1},
256 {-1, -1, -1, 3, -1, -1, -1, -1},
257 {-1, -1, -1, -1, -1, -1, -1, -1},
258 {-1, -1, -1, -1, -1, -1, -1, -1}},
259 {{-1, -1, -1, 0, 0, -1, -1, -1},
260 {-1, -1, 5, 0, 1, -1, -1, -1},
261 {-1, -1, 3, 5, 1, 6, -1, -1},
262 {-1, 4, 3, -1, 6, 7, -1, -1},
263 {-1, 7, 4, -1, -1, 7, 4, -1},
264 { 6, 7, -1, -1, -1, 4, 3, -1},
265 { 1, 6, -1, -1, -1, -1, 3, 5},
266 { 1, -1, -1, -1, -1, -1, 5, -1},
267 {-1, -1, -1, -1, -1, -1, -1, -1},
268 {-1, -1, -1, -1, -1, -1, -1, -1}},
269 {{-1, -1, 0, 0, 0, 0, -1, -1},
270 {-1, 0, 1, 1, 1, 0, -1, -1},
271 {-1, 0, 1, 0, 0, 1, 0, -1},
272 {-1, 0, 1, 1, 1, 0, -1, -1},
273 {-1, -1, 0, 0, 0, 0, -1, -1},
274 {-1, -1, 7, -1, 7, -1, -1, -1},
275 {-1, -1, 7, 7, 7, 7, -1, -1},
276 {-1, -1, -1, -1, -1, -1, -1, -1},
277 {-1, -1, -1, -1, -1, -1, -1, -1},
278 {-1, -1, -1, -1, -1, -1, -1, -1}},
279 {{-1, 4, 4, 4, 6, 6, 6, -1},
280 { 4, -1, -1, -1, -1, -1, 6, -1},
281 {-1, 4, -1, -1, -1, -1, 6, -1},
282 { 4, 2, 3, 1, 2, 3, 6, -1},
283 {-1, 3, 1, 2, 3, 1, 2, -1},
284 {-1, -1, -1, -1, -1, -1, -1, -1},
285 {-1, -1, -1, -1, -1, -1, -1, -1},
286 {-1, -1, -1, -1, -1, -1, -1, -1},
287 {-1, -1, -1, -1, -1, -1, -1, -1},
288 {-1, -1, -1, -1, -1, -1, -1, -1}},
289 {{-1, 4, 4, 4, 6, 6, 6, -1},
290 { 4, -1, -1, -1, -1, -1, 6, -1},
291 {-1, 4, -1, -1, -1, -1, 6, -1},
292 { 4, 2, 3, 1, 2, 3, 6, -1},
293 {-1, 3, 1, 2, 3, 1, 2, -1},
294 {-1, 2, 3, 1, 2, 3, -1, -1},
295 {-1, -1, -1, -1, -1, -1, -1, -1},
296 {-1, -1, -1, -1, -1, -1, -1, -1},
297 {-1, -1, -1, -1, -1, -1, -1, -1},
298 {-1, -1, -1, -1, -1, -1, -1, -1}},
299 {{-1, 0, 0, -1, -1, 2, 2, -1},
300 {-1, 5, -1, -1, -1, 3, -1, -1},
301 {-1, 0, -1, -1, -1, 6, -1, -1},
302 {-1, 3, -1, -1, -1, 0, -1, -1},
303 {-1, 4, -1, -1, -1, 5, -1, -1},
304 {-1, 2, -1, -1, -1, 3, -1, -1},
305 {-1, 2, -1, -1, -1, 1, -1, -1},
306 {-1, 3, -1, -1, -1, 4, -1, -1},
307 {-1, -1, -1, -1, -1, -1, -1, -1},
308 {-1, -1, -1, -1, -1, -1, -1, -1}},
309 {{ 3, -1, -1, -1, -1, -1, -1, 3},
310 { 6, 3, 2, 4, 6, 3, 2, -1},
311 { 4, -1, -1, -1, -1, -1, -1, 4},
312 { 2, 4, 6, 3, 2, 4, 6, -1},
313 {-1, -1, -1, 6, -1, -1, -1, -1},
314 {-1, -1, -1, 3, -1, -1, -1, -1},
315 {-1, -1, -1, -1, -1, -1, -1, -1},
316 {-1, -1, -1, -1, -1, -1, -1, -1},
317 {-1, -1, -1, -1, -1, -1, -1, -1},
318 {-1, -1, -1, -1, -1, -1, -1, -1}},
319 {{-1, 2, -1, 1, -1, 1, -1, 2},
320 { 1, 2, -1, 2, 1, -1, 1, -1},
321 { 1, -1, 1, -1, 2, -1, 2, -1},
322 { 2, 1, -1, 1, 2, -1, 2, -1},
323 {-1, 2, -1, 2, -1, 2, -1, 2},
324 { 1, 2, -1, 2, 1, -1, 1, -1},
325 { 1, -1, 1, -1, 2, -1, 1, -1},
326 { 2, 2, -1, 1, 1, -1, 2, -1},
327 {-1, 2, -1, 1, -1, 1, -1, 1},
328 {-1, -1, -1, -1, -1, -1, -1, -1}},
329 {{-1, 7, 7, -1, -1, 5, 5, -1},
330 { 1, -1, -1, -1, -1, -1, 4, -1},
331 { 2, 1, -1, -1, -1, -1, 4, 3},
332 { 2, -1, -1, -1, -1, -1, 3, -1},
333 { 1, 2, -1, -1, -1, -1, 3, 4},
334 { 1, -1, -1, -1, -1, -1, 4, -1},
335 { 7, 1, -1, -1, -1, -1, 4, 5},
336 { 7, 7, -1, -1, -1, 5, 5, -1},
337 {-1, -1, -1, -1, -1, -1, -1, -1},
338 {-1, -1, -1, -1, -1, -1, -1, -1}},
339 {{ 7, 7, -1, -1, -1, -1, 5, 5},
340 { 1, 5, -1, -1, -1, 7, 4, -1},
341 { 2, 1, -1, -1, -1, -1, 4, 3},
342 { 2, -1, -1, -1, -1, -1, 3, -1},
343 { 1, 5, -1, -1, -1, -1, 7, 4},
344 { 1, -1, -1, -1, -1, -1, 4, -1},
345 { 7, 1, -1, -1, -1, -1, 4, 5},
346 { 7, 5, -1, -1, -1, 7, 5, -1},
347 {-1, -1, -1, -1, -1, -1, -1, -1},
348 {-1, -1, -1, -1, -1, -1, -1, -1}},
349 {{-1, -1, -1, 0, 0, -1, -1, -1},
350 {-1, -1, 5, 0, 1, -1, -1, -1},
351 {-1, -1, 3, 5, 1, 6, -1, -1},
352 {-1, 4, 3, 2, 6, 2, -1, -1},
353 {-1, 7, 4, 7, 2, 2, 4, -1},
354 { 6, 7, 7, 3, 3, 4, 3, -1},
355 { 1, 6, 1, 1, 1, 3, 3, 5},
356 { 1, 1, -1, -1, -1, -1, 5, -1},
357 {-1, -1, -1, -1, -1, -1, -1, -1},
358 {-1, -1, -1, -1, -1, -1, -1, -1}},
359 {{-1, -1, 0, -1, -1, 0, -1, -1},
360 {-1, 3, 3, -1, 3, 3, -1, -1},
361 {-1, 0, 2, 0, 0, 2, 0, -1},
362 {-1, 3, 3, -1, 3, 3, -1, -1},
363 {-1, -1, 0, -1, -1, 0, -1, -1},
364 {-1, -1, -1, -1, -1, -1, -1, -1},
365 {-1, -1, -1, -1, -1, -1, -1, -1},
366 {-1, -1, -1, -1, -1, -1, -1, -1},
367 {-1, -1, -1, -1, -1, -1, -1, -1},
368 {-1, -1, -1, -1, -1, -1, -1, -1}},
369 {{-1, -1, -1, 1, 1, -1, -1, -1},
370 {-1, -1, 2, 2, 2, -1, -1, -1},
371 {-1, -1, 3, 3, 3, 3, -1, -1},
372 {-1, 4, 4, 4, 4, 4, -1, -1},
373 {-1, 5, 5, 5, 5, 5, 5, -1},
374 {-1, -1, -1, 6, -1, -1, -1, -1},
375 {-1, -1, -1, 7, 7, -1, -1, -1},
376 {-1, -1, -1, 0, -1, -1, -1, -1},
377 {-1, -1, -1, -1, -1, -1, -1, -1},
378 {-1, -1, -1, -1, -1, -1, -1, -1}},
379 {{-1, -1, -1, 2, 5, -1, -1, -1},
380 {-1, 4, 3, -1, -1, -1, -1, -1},
381 { 6, 7, -1, 5, 2, -1, -1, -1},
382 {-1, -1, -1, -1, 3, 4, -1, -1},
383 {-1, -1, -1, 2, 5, -1, 7, 6},
384 {-1, 4, 3, -1, -1, -1, -1, -1},
385 { 6, 7, -1, 5, 2, -1, -1, -1},
386 {-1, -1, -1, -1, 3, 4, -1, -1},
387 {-1, -1, -1, -1, -1, -1, 7, 6},
388 {-1, -1, -1, -1, -1, -1, -1, -1}},
389 {{-1, -1, -1, 5, 5, -1, -1, -1},
390 {-1, -1, -1, 3, -1, -1, -1, -1},
391 {-1, -1, -1, 1, -1, -1, -1, -1},
392 {-1, -1, -1, 7, -1, -1, -1, -1},
393 {-1, -1, -1, 2, -1, -1, -1, -1},
394 {-1, -1, -1, 4, -1, -1, -1, -1},
395 {-1, -1, -1, 5, -1, -1, -1, -1},
396 {-1, -1, -1, 3, -1, -1, -1, -1},
397 {-1, -1, -1, -1, -1, -1, -1, -1},
398 {-1, -1, -1, -1, -1, -1, -1, -1}},
399 {{-1, -1, -1, 0, 1, -1, -1, -1},
400 {-1, -1, 0, 2, 7, 7, -1, -1},
401 {-1, -1, -1, 0, 1, 7, -1, -1},
402 {-1, 0, 0, 0, 0, -1, -1, -1},
403 {-1, 0, 0, 0, 1, 1, -1, -1},
404 { 0, 0, 0, 1, 1, 1, -1, -1},
405 {-1, 0, 0, 1, 1, 1, -1, -1},
406 {-1, 0, 0, 0, 7, 7, -1, -1},
407 {-1, -1, 7, 7, -1, -1, -1, -1},
408 {-1, -1, -1, -1, -1, -1, -1, -1}},
409 {{-1, 1, -1, -1, -1, -1, -1, -1},
410 { 1, -1, -1, -1, -1, -1, -1, -1},
411 {-1, 2, 3, 4, 7, 6, 5, -1},
412 {-1, -1, -1, -1, -1, -1, 1, -1},
413 {-1, -1, -1, -1, -1, -1, 1, -1},
414 {-1, 2, 3, 4, 7, 6, -1, -1},
415 {-1, 1, -1, -1, -1, -1, -1, -1},
416 { 1, -1, -1, -1, -1, -1, -1, -1},
417 {-1, 2, 3, 4, 7, 6, 5, -1},
418 {-1, -1, -1, -1, -1, -1, -1, -1}},
419 {{-1, 6, -1, -1, -1, -1, -1, -1},
420 { 5, -1, -1, -1, -1, -1, -1, -1},
421 { 2, 3, 4, 7, 6, 5, 2, 3},
422 {-1, -1, -1, -1, -1, -1, 4, -1},
423 {-1, -1, -1, -1, -1, -1, 7, -1},
424 {-1, 4, 3, 2, 5, 6, -1, -1},
425 {-1, 7, -1, -1, -1, -1, -1, -1},
426 { 6, -1, -1, -1, -1, -1, -1, -1},
427 { 5, 2, 3, 4, 7, 6, 5, -1},
428 {-1, -1, -1, -1, -1, -1, -1, -1}},
429 {{ 3, 2, 1, 0, 0, 1, 2, 3},
430 { 3, 2, 1, 0, 1, 2, 3, -1},
431 { 4, 3, 2, 1, 1, 2, 3, 4},
432 { 4, 3, 2, 1, 2, 3, 4, -1},
433 { 5, 4, 3, 2, 2, 3, 4, 5},
434 { 5, 4, 3, 2, 3, 4, 5, -1},
435 { 6, 5, 4, 3, 3, 4, 5, 6},
436 { 6, 5, 4, 3, 4, 5, 6, -1},
437 { 7, 6, 5, 4, 4, 5, 6, 7},
438 {-1, -1, -1, -1, -1, -1, -1, -1}},
439 {{-1, -1, -1, 5, 5, -1, -1, -1},
440 {-1, -1, -1, 3, -1, -1, -1, -1},
441 {-1, -1, -1, 2, 4, -1, -1, -1},
442 {-1, -1, -1, 6, -1, -1, -1, -1},
443 {-1, -1, -1, 2, 4, -1, -1, -1},
444 {-1, 2, -1, 5, -1, 4, -1, -1},
445 { 1, 0, 1, 0, 1, 0, 1, 0},
446 { 3, -1, 3, -1, 2, -1, 6, -1},
447 {-1, -1, -1, -1, -1, -1, -1, -1},
448 {-1, -1, -1, -1, -1, -1, -1, -1}},
449 {{-1, -1, -1, -1, 1, -1, -1, -1},
450 { 7, 4, 3, 5, -1, -1, -1, -1},
451 { 6, -1, -1, 1, -1, -1, -1, -1},
452 {-1, -1, -1, 5, 3, 4, 7, -1},
453 { 6, -1, -1, -1, 1, -1, -1, 6},
454 { 7, 4, 3, 5, -1, -1, -1, -1},
455 {-1, -1, -1, 1, -1, -1, -1, 6},
456 {-1, -1, -1, 5, 3, 4, 7, -1},
457 {-1, -1, -1, -1, -1, -1, -1, -1},
458 {-1, -1, -1, -1, -1, -1, -1, -1}},
459 {{-1, -1, -1, -1, 7, 3, 6, -1},
460 {-1, -1, 3, 7, 3, 6, 3, -1},
461 {-1, -1, 5, 7, 3, 6, 3, -1},
462 {-1, 6, 7, 3, 6, 7, -1, -1},
463 {-1, 7, 7, 3, 6, 1, -1, -1},
464 { 3, 7, 3, 6, 3, -1, -1, -1},
465 { 5, 6, 2, 7, 1, -1, -1, -1},
466 {-1, -1, -1, -1, -1, -1, -1, -1},
467 {-1, -1, -1, -1, -1, -1, -1, -1},
468 {-1, -1, -1, -1, -1, -1, -1, -1}},
469 {{ 5, -1, -1, -1, -1, -1, -1, 5},
470 { 5, -1, 6, 6, 6, -1, 5, -1},
471 {-1, 5, 4, -1, -1, 4, 5, -1},
472 {-1, 3, -1, -1, -1, 3, -1, -1},
473 {-1, 6, 0, -1, -1, 0, 6, -1},
474 {-1, 3, -1, -1, -1, 3, -1, -1},
475 {-1, -1, 4, -1, -1, 4, -1, -1},
476 {-1, -1, 6, 6, 6, -1, -1, -1},
477 {-1, -1, -1, -1, -1, -1, -1, -1},
478 {-1, -1, -1, -1, -1, -1, -1, -1}},
479 {{-1, 7, 0, -1, -1, 0, 7, -1},
480 { 7, -1, 0, -1, 0, -1, 7, -1},
481 { 7, 1, -1, 0, 0, -1, 1, 7},
482 { 7, 1, 2, 0, 2, 1, 7, -1},
483 { 7, 6, 3, 2, 2, 3, 6, 7},
484 { 7, -1, 3, 2, 3, -1, 7, -1},
485 {-1, 7, 7, 3, 3, 7, 7, -1},
486 {-1, -1, -1, 3, -1, -1, -1, -1},
487 {-1, -1, -1, -1, -1, -1, -1, -1},
488 {-1, -1, -1, -1, -1, -1, -1, -1}},
489 {{-1, 3, -1, 1, -1, 7, -1, 6},
490 { 5, -1, 7, -1, 7, -1, 6, -1},
491 { 6, -1, 0, -1, 5, -1, 3, -1},
492 {-1, 2, -1, 1, -1, 5, -1, -1},
493 {-1, 4, -1, 3, -1, 4, -1, -1},
494 { 2, -1, 3, -1, 2, -1, -1, -1},
495 {-1, -1, 4, -1, 6, -1, -1, -1},
496 {-1, -1, -1, 5, -1, -1, -1, -1},
497 {-1, -1, -1, -1, -1, -1, -1, -1},
498 {-1, -1, -1, -1, -1, -1, -1, -1}},
499 {{-1, -1, -1, -1, 1, -1, -1, -1},
500 {-1, -1, -1, -1, 3, -1, -1, -1},
501 { 6, 1, 3, 1, 2, 1, 4, 1},
502 {-1, -1, -1, -1, 6, -1, -1, -1},
503 {-1, -1, -1, 4, 1, -1, -1, -1},
504 {-1, -1, 1, -1, 3, -1, -1, -1},
505 {-1, -1, -1, 2, 1, -1, -1, -1},
506 {-1, -1, -1, -1, 4, -1, -1, -1},
507 {-1, -1, -1, 6, 1, -1, -1, -1},
508 {-1, -1, -1, 6, -1, -1, -1, -1}},
509 {{-1, -1, -1, 5, 4, -1, -1, -1},
510 {-1, -1, 4, 1, 0, -1, -1, -1},
511 {-1, -1, -1, 2, 3, -1, -1, -1},
512 {-1, 1, 4, -1, 2, 2, -1, -1},
513 {-1, 3, 1, 2, 5, 1, 4, -1},
514 {-1, 4, 2, -1, 0, 4, -1, -1},
515 {-1, -1, -1, -1, -1, -1, -1, -1},
516 {-1, -1, -1, -1, -1, -1, -1, -1},
517 {-1, -1, -1, -1, -1, -1, -1, -1},
518 {-1, -1, -1, -1, -1, -1, -1, -1}},
519 {{-1, -1, -1, -1, 1, -1, -1, -1},
520 {-1, -1, -1, 1, -1, -1, -1, -1},
521 {-1, 2, -1, -1, 1, -1, 5, -1},
522 { 5, -1, -1, 1, -1, -1, 0, -1},
523 {-1, 6, -1, -1, 1, -1, 4, -1},
524 {-1, 0, -1, 1, -1, 5, -1, -1},
525 {-1, -1, 5, 5, 0, 1, -1, -1},
526 {-1, -1, -1, -1, -1, -1, -1, -1},
527 {-1, -1, -1, -1, -1, -1, -1, -1},
528 {-1, -1, -1, -1, -1, -1, -1, -1}},
529 {{-1, -1, -1, 6, 3, -1, -1, -1},
530 {-1, -1, 3, 2, 6, -1, -1, -1},
531 {-1, -1, 2, 6, 3, 2, -1, -1},
532 {-1, 6, 3, 2, 6, 3, -1, -1},
533 {-1, 3, 2, 6, 3, 2, 6, -1},
534 { 2, 6, 3, 2, 6, 3, 2, -1},
535 { 6, 3, 2, 6, 3, 2, 6, 3},
536 {-1, -1, -1, -1, -1, -1, -1, -1},
537 {-1, -1, -1, -1, -1, -1, -1, -1},
538 {-1, -1, -1, -1, -1, -1, -1, -1}},
539 {{ 6, 6, 6, 6, 6, 6, 6, 6},
540 { 4, -1, -1, -1, -1, -1, -1, -1},
541 {-1, 3, 2, 5, 7, 6, 4, 3},
542 {-1, 5, -1, -1, -1, -1, -1, -1},
543 {-1, -1, 7, 6, 4, 3, 2, 5},
544 {-1, -1, 4, -1, -1, -1, -1, -1},
545 {-1, -1, -1, 3, 2, 5, 7, 6},
546 {-1, -1, -1, -1, -1, -1, -1, -1},
547 {-1, -1, -1, -1, -1, -1, -1, -1},
548 {-1, -1, -1, -1, -1, -1, -1, -1}},
549 {{ 1, -1, 7, -1, -1, 6, -1, 2},
550 { 6, -1, 1, -1, 6, 1, 3, -1},
551 {-1, 4, -1, 7, 2, -1, 7, -1},
552 { 2, 7, -1, -1, -1, 4, -1, -1},
553 { 6, -1, 3, 5, 0, 2, -1, 7},
554 { 1, -1, -1, -1, -1, -1, 1, -1},
555 {-1, 1, 4, 5, 7, 5, 1, -1},
556 {-1, -1, -1, -1, -1, -1, -1, -1},
557 {-1, -1, -1, -1, -1, -1, -1, -1},
558 {-1, -1, -1, -1, -1, -1, -1, -1}},
559 {{ 6, 6, 6, -1, -1, 6, 6, 6},
560 {-1, -1, 6, -1, 6, -1, -1, -1},
561 {-1, -1, 2, 3, 3, 2, -1, -1},
562 {-1, 3, -1, 5, -1, 3, -1, -1},
563 {-1, -1, 5, 3, 3, 5, -1, -1},
564 {-1, -1, 6, 1, 6, -1, -1, -1},
565 {-1, 4, 2, -1, -1, 2, 4, -1},
566 {-1, -1, -1, -1, -1, -1, -1, -1},
567 {-1, -1, -1, -1, -1, -1, -1, -1},
568 {-1, -1, -1, -1, -1, -1, -1, -1}},
569 {{-1, -1, -1, 5, 5, -1, -1, -1},
570 {-1, -1, 5, -1, -1, -1, -1, -1},
571 {-1, 3, 4, 6, 6, -1, -1, 5},
572 { 3, 3, 4, 6, 5, -1, 5, -1},
573 { 3, 2, 3, 6, 6, 5, 5, -1},
574 { 3, 3, 4, 6, 5, -1, 5, -1},
575 {-1, 3, 4, 6, 6, -1, -1, 5},
576 {-1, -1, 5, -1, -1, -1, -1, -1},
577 {-1, -1, -1, 5, 5, -1, -1, -1},
578 {-1, -1, -1, -1, -1, -1, -1, -1}},
579 {{ 1, -1, -1, -1, -1, -1, -1, 1},
580 { 1, -1, 2, 2, 2, -1, 1, -1},
581 {-1, 1, 2, 3, 3, 2, 1, -1},
582 { 6, 2, 3, -1, 3, 2, 6, -1},
583 { 6, 2, 3, -1, -1, 3, 2, 6},
584 { 6, 2, 3, -1, 3, 2, 6, -1},
585 { 3, 3, 3, 7, 7, 3, 3, 3},
586 { 0, 5, 0, 2, 0, 5, 0, -1},
587 {-1, -1, -1, -1, -1, -1, -1, -1},
588 {-1, -1, -1, -1, -1, -1, -1, -1}},
589 {{-1, -1, 7, 7, 7, -1, -1, -1},
590 {-1, 7, 2, 2, 7, -1, -1, -1},
591 {-1, 7, 5, 5, 5, 7, -1, -1},
592 { 7, 7, 7, 7, 7, 7, -1, -1},
593 {-1, -1, 6, -1, 6, -1, -1, -1},
594 {-1, 6, -1, -1, 6, -1, -1, -1},
595 {-1, 6, 4, 4, -1, 6, 4, 4},
596 {-1, -1, -1, -1, -1, -1, -1, -1},
597 {-1, -1, -1, -1, -1, -1, -1, -1},
598 {-1, -1, -1, -1, -1, -1, -1, -1}},
599 {{-1, 3, 3, -1, 3, 3, 3, -1},
600 { 3, 7, 5, 4, 6, 5, 3, -1},
601 { 1, 3, 3, 3, -1, 3, 3, 1},
602 { 2, 1, 2, 1, 2, 1, 2, -1},
603 { 1, 3, 3, -1, 3, 3, 3, 1},
604 { 3, 5, 6, 4, 5, 7, 3, -1},
605 { 2, 3, 3, 3, -1, 3, 3, 2},
606 { 1, 1, 2, 2, 2, 1, 1, -1},
607 {-1, -1, -1, -1, -1, -1, -1, -1},
608 {-1, -1, -1, -1, -1, -1, -1, -1}},
609 {{-1, 6, 5, -1, -1, -1, -1, -1},
610 { 3, 1, 3, -1, -1, -1, -1, -1},
611 {-1, 5, 6, -1, -1, -1, -1, -1},
612 {-1, -1, 5, 3, -1, -1, -1, -1},
613 {-1, -1, 6, 1, 6, -1, -1, -1},
614 {-1, -1, 3, 5, -1, -1, -1, -1},
615 {-1, -1, -1, -1, 3, 6, -1, -1},
616 {-1, -1, -1, 5, 6, 5, -1, -1},
617 {-1, -1, -1, -1, 6, 3, -1, -1},
618 {-1, -1, -1, -1, -1, -1, -1, -1}},
619 {{ 6, 3, 7, 4, 5, 1, 6, 3},
620 { 5, 1, 6, 3, 7, 4, 5, -1},
621 { 6, 3, 7, 4, 5, 1, 6, 3},
622 {-1, -1, -1, -1, -1, -1, -1, -1},
623 {-1, -1, -1, -1, -1, -1, -1, -1},
624 {-1, -1, -1, -1, -1, -1, -1, -1},
625 {-1, -1, -1, -1, -1, -1, -1, -1},
626 {-1, -1, -1, -1, -1, -1, -1, -1},
627 {-1, -1, -1, -1, -1, -1, -1, -1},
628 {-1, -1, -1, -1, -1, -1, -1, -1}},
629 {{-1, -1, -1, -1, -1, -1, 4, 4},
630 {-1, -1, 7, 7, 7, 4, 4, -1},
631 {-1, -1, -1, -1, -1, -1, 4, 4},
632 {-1, 1, -1, -1, -1, 7, -1, -1},
633 {-1, 1, 1, -1, -1, 7, -1, -1},
634 { 3, 3, 3, -1, 7, -1, -1, -1},
635 { 3, -1, 2, 3, 3, 3, -1, 3},
636 {-1, 2, -1, 3, -1, 3, 3, -1},
637 {-1, 2, -1, -1, -1, -1, -1, -1},
638 {-1, -1, -1, -1, -1, -1, -1, -1}},
639 {{-1, -1, 4, -1, -1, -1, -1, -1},
640 {-1, 7, 4, -1, -1, -1, -1, -1},
641 {-1, -1, 7, 4, -1, -1, -1, -1},
642 {-1, 4, 7, 4, -1, -1, -1, -1},
643 { 1, 1, 1, 1, 1, 1, 1, -1},
644 { 1, 2, 1, 2, 1, 1, -1, -1},
645 { 2, 2, 2, 2, 2, 2, 2, 2},
646 {-1, -1, -1, -1, -1, -1, -1, -1},
647 {-1, -1, -1, -1, -1, -1, -1, -1},
648 {-1, -1, -1, -1, -1, -1, -1, -1}},
649 {{ 0, -1, -1, -1, -1, -1, -1, 6},
650 { 6, 1, 4, 3, 7, 5, 0, -1},
651 { 0, -1, -1, -1, -1, -1, -1, 6},
652 { 6, 1, 4, 3, 7, 5, 0, -1},
653 { 0, -1, -1, -1, -1, -1, -1, 6},
654 { 6, 1, 4, 3, 7, 5, 0, -1},
655 {-1, -1, -1, -1, -1, -1, -1, -1},
656 {-1, -1, -1, -1, -1, -1, -1, -1},
657 {-1, -1, -1, -1, -1, -1, -1, -1},
658 {-1, -1, -1, -1, -1, -1, -1, -1}},
659 {{ 3, 3, 4, 6, 6, 4, 3, 3},
660 { 0, 3, 4, 6, 4, 3, 1, -1},
661 { 5, 1, 3, 4, 4, 3, 0, 1},
662 { 0, 1, 3, 4, 3, 1, 0, -1},
663 { 2, 1, 6, 3, 3, 0, 0, 1},
664 { 0, 3, 4, 3, 6, 1, 5, -1},
665 { 6, 1, 2, 6, 4, 0, 0, 2},
666 {-1, -1, -1, -1, -1, -1, -1, -1},
667 {-1, -1, -1, -1, -1, -1, -1, -1},
668 {-1, -1, -1, -1, -1, -1, -1, -1}},
669 {{ 6, 6, -1, -1, -1, -1, 4, 4},
670 { 4, 0, -1, -1, -1, 3, 6, -1},
671 { 0, 6, -1, -1, -1, -1, 4, 2},
672 { 7, -1, -1, -1, -1, -1, 7, -1},
673 { 4, 4, -1, -1, -1, -1, 5, 6},
674 { 6, 4, 7, 7, 5, 6, 4, -1},
675 {-1, 7, 6, 4, 6, 4, 7, -1},
676 {-1, 0, -1, 7, -1, 7, -1, -1},
677 {-1, -1, -1, -1, -1, -1, -1, -1},
678 {-1, -1, -1, -1, -1, -1, -1, -1}},
679 {{-1, 5, -1, -1, -1, -1, 4, -1},
680 {-1, 5, -1, -1, -1, 4, -1, -1},
681 {-1, -1, 5, 6, 6, 4, -1, -1},
682 {-1, -1, 2, -1, 2, -1, -1, -1},
683 { 0, 0, 6, -1, -1, 6, 1, 1},
684 {-1, -1, 2, -1, 2, -1, -1, -1},
685 {-1, -1, 7, 6, 6, 3, -1, -1},
686 {-1, 7, -1, -1, -1, 3, -1, -1},
687 {-1, 7, -1, -1, -1, -1, 3, -1},
688 {-1, -1, -1, -1, -1, -1, -1, -1}},
689 {{-1, 6, -1, -1, -1, -1, 2, -1},
690 { 1, 7, 1, 1, 1, 3, 1, -1},
691 {-1, -1, 4, 1, 1, 4, -1, -1},
692 {-1, 1, 3, 1, 7, 1, -1, -1},
693 {-1, -1, -1, 2, 6, -1, -1, -1},
694 {-1, -1, 1, 5, 1, -1, -1, -1},
695 {-1, -1, -1, -1, -1, -1, -1, -1},
696 {-1, -1, -1, -1, -1, -1, -1, -1},
697 {-1, -1, -1, -1, -1, -1, -1, -1},
698 {-1, -1, -1, -1, -1, -1, -1, -1}},
699 {{ 7, 7, 7, 7, 7, 7, 7, 7},
700 { 7, -1, -1, -1, -1, -1, 7, -1},
701 { 7, -1, -1, 2, 0, 5, 2, 2},
702 { 7, -1, -1, -1, 0, 3, 6, -1},
703 { 7, -1, -1, -1, -1, -1, 4, 0},
704 { 5, 5, -1, -1, -1, -1, -1, -1},
705 { 4, 3, 6, 2, -1, -1, -1, -1},
706 { 0, 2, 0, 4, -1, -1, -1, -1},
707 {-1, -1, -1, -1, -1, -1, -1, -1},
708 {-1, -1, -1, -1, -1, -1, -1, -1}},
709 {{-1, -1, 1, -1, -1, 1, -1, -1},
710 {-1, 4, -1, -1, 5, -1, -1, -1},
711 {-1, 7, -1, -1, 1, 1, 1, -1},
712 { 6, -1, -1, -1, -1, 7, -1, -1},
713 { 1, 1, 1, 1, -1, 4, -1, -1},
714 {-1, -1, 5, -1, -1, -1, -1, -1},
715 {-1, -1, 0, -1, -1, -1, -1, -1},
716 {-1, 3, -1, -1, -1, -1, -1, -1},
717 {-1, 1, -1, -1, -1, -1, -1, -1},
718 {-1, -1, -1, -1, -1, -1, -1, -1}},
719 {{-1, 7, 7, -1, -1, 7, 7, -1},
720 { 6, -1, 4, -1, 4, -1, 6, -1},
721 { 5, -1, -1, 3, 3, -1, -1, 5},
722 { 6, -1, -1, -1, -1, -1, 6, -1},
723 {-1, 7, -1, -1, -1, -1, 7, -1},
724 {-1, 4, -1, -1, -1, 4, -1, -1},
725 {-1, -1, 3, -1, -1, 3, -1, -1},
726 {-1, -1, 2, -1, 2, -1, -1, -1},
727 {-1, -1, -1, 5, 5, -1, -1, -1},
728 {-1, -1, -1, -1, -1, -1, -1, -1}},
729 {{-1, 0, 0, -1, -1, 0, 0, -1},
730 { 7, 4, 6, 6, 6, 4, 3, -1},
731 { 5, 6, 6, 6, 2, 6, 6, 3},
732 { 7, 4, 6, 6, 6, 4, 3, -1},
733 {-1, 0, 0, -1, -1, 0, 0, -1},
734 {-1, -1, -1, -1, -1, -1, -1, -1},
735 {-1, -1, -1, -1, -1, -1, -1, -1},
736 {-1, -1, -1, -1, -1, -1, -1, -1},
737 {-1, -1, -1, -1, -1, -1, -1, -1},
738 {-1, -1, -1, -1, -1, -1, -1, -1}},
739 {{-1, -1, -1, -1, -1, 7, 7, 7},
740 {-1, -1, -1, -1, 2, 7, 7, -1},
741 {-1, 0, 7, 7, 7, -1, 7, 7},
742 { 6, 7, 7, 7, -1, -1, -1, -1},
743 { 6, -1, -1, -1, 7, 7, 7, 7},
744 { 6, -1, -1, -1, -1, -1, -1, -1},
745 { 4, 2, 2, 2, 4, -1, 3, -1},
746 { 4, 4, 4, 4, 3, 3, 3, -1},
747 {-1, -1, -1, -1, -1, -1, -1, -1},
748 {-1, -1, -1, -1, -1, -1, -1, -1}},
749 {{ 4, -1, -1, 7, -1, 6, -1, 7},
750 { 7, 6, 7, -1, -1, 7, 4, -1},
751 {-1, -1, 7, -1, -1, 7, -1, -1},
752 {-1, 0, 0, 0, 0, 0, 3, -1},
753 {-1, -1, 0, 2, 2, 0, 6, 4},
754 {-1, -1, 0, 0, 0, 1, 3, -1},
755 {-1, -1, -1, 0, 0, -1, 3, 4},
756 {-1, -1, -1, 6, -1, 5, 6, -1},
757 {-1, -1, -1, -1, -1, -1, 1, 0},
758 {-1, -1, -1, -1, -1, -1, -1, -1}},
759 {{-1, 5, -1, -1, -1, -1, 5, -1},
760 { 0, -1, -1, 0, -1, -1, 0, -1},
761 { 0, 0, 0, 2, 2, 0, 0, 0},
762 { 0, -1, -1, 0, -1, -1, 0, -1},
763 {-1, 7, -1, 3, -1, -1, 7, -1},
764 {-1, -1, 3, 6, -1, -1, -1, -1},
765 {-1, -1, -1, 6, -1, -1, -1, -1},
766 {-1, 3, 6, -1, -1, -1, -1, -1},
767 {-1, 3, -1, -1, -1, -1, -1, -1},
768 {-1, -1, -1, -1, -1, -1, -1, -1}},
769 {{-1, -1, -1, 6, 5, -1, -1, -1},
770 {-1, -1, 2, 6, 3, -1, -1, -1},
771 {-1, -1, 5, 4, 7, 1, -1, -1},
772 {-1, 6, 2, 2, 3, 4, -1, -1},
773 {-1, -1, 3, 7, 3, 6, -1, -1},
774 {-1, -1, 1, 3, 2, -1, -1, -1},
775 {-1, -1, -1, 4, 5, -1, -1, -1},
776 {-1, -1, -1, 4, -1, -1, -1, -1},
777 {-1, -1, -1, -1, -1, -1, -1, -1},
778 {-1, -1, -1, -1, -1, -1, -1, -1}},
779 {{ 7, 7, -1, 2, 2, -1, 6, 6},
780 { 6, -1, -1, 6, -1, -1, 3, -1},
781 { 2, -1, -1, 1, -1, -1, 2, -1},
782 { 5, -1, -1, 3, -1, -1, 2, -1},
783 { 1, -1, -1, 2, -1, -1, 1, -1},
784 { 5, -1, -1, 2, -1, -1, 2, -1},
785 { 6, -1, -1, 1, -1, -1, 7, -1},
786 { 5, -1, -1, 5, -1, -1, 4, -1},
787 {-1, -1, -1, -1, -1, -1, -1, -1},
788 {-1, -1, -1, -1, -1, -1, -1, -1}},
789 {{-1, -1, -1, 6, 6, -1, -1, -1},
790 {-1, 0, 4, 4, 4, 0, -1, -1},
791 {-1, -1, -1, 6, 6, -1, -1, -1},
792 {-1, -1, 2, 7, 2, -1, -1, -1},
793 {-1, -1, -1, 6, 6, -1, -1, -1},
794 {-1, 0, 5, 5, 5, 0, -1, -1},
795 {-1, -1, -1, 3, 3, -1, -1, -1},
796 {-1, -1, -1, -1, -1, -1, -1, -1},
797 {-1, -1, -1, -1, -1, -1, -1, -1},
798 {-1, -1, -1, -1, -1, -1, -1, -1}},
799 {{-1, -1, 4, 1, 3, -1, -1, -1},
800 {-1, 1, -1, -1, 1, -1, -1, -1},
801 {-1, -1, 4, 1, 3, 4, 1, -1},
802 {-1, 1, 3, 4, -1, -1, 4, -1},
803 {-1, 3, -1, -1, 3, 4, 1, -1},
804 {-1, 1, 3, 4, 1, 3, -1, -1},
805 {-1, -1, 4, 1, -1, -1, -1, -1},
806 {-1, -1, -1, -1, -1, -1, -1, -1},
807 {-1, -1, -1, -1, -1, -1, -1, -1},
808 {-1, -1, -1, -1, -1, -1, -1, -1}},
809 {{-1, 6, 4, -1, 3, 2, 5, -1},
810 { 0, -1, -1, -1, -1, -1, 1, -1},
811 {-1, 2, 3, 5, -1, 4, 6, -1},
812 { 0, -1, -1, -1, -1, -1, 1, -1},
813 {-1, 4, 6, -1, 2, 5, 3, -1},
814 { 0, -1, -1, -1, -1, -1, 1, -1},
815 {-1, 5, 2, 3, -1, 4, 6, -1},
816 {-1, -1, -1, -1, -1, -1, -1, -1},
817 {-1, -1, -1, -1, -1, -1, -1, -1},
818 {-1, -1, -1, -1, -1, -1, -1, -1}},
819 {{-1, -1, -1, 6, 6, -1, -1, -1},
820 {-1, -1, 7, 6, 4, -1, -1, -1},
821 {-1, 2, 1, 7, 4, 1, 3, -1},
822 { 2, 1, 1, 1, 1, 1, 3, -1},
823 {-1, 2, 2, 2, 3, 3, 3, -1},
824 {-1, -1, -1, 5, -1, -1, -1, -1},
825 {-1, -1, -1, 2, 3, -1, -1, -1},
826 {-1, -1, -1, 5, -1, -1, -1, -1},
827 {-1, -1, 2, 2, 3, 3, -1, -1},
828 {-1, -1, -1, -1, -1, -1, -1, -1}},
829 {{ 4, -1, 5, -1, -1, 3, -1, 6},
830 { 2, -1, 3, -1, 2, -1, 4, -1},
831 { 4, -1, -1, 1, 0, -1, -1, 6},
832 { 6, -1, 2, 3, 5, -1, 4, -1},
833 { 4, -1, -1, 0, 1, -1, -1, 6},
834 { 2, -1, 5, -1, 3, -1, 4, -1},
835 { 4, -1, 3, -1, -1, 2, -1, 6},
836 { 6, -1, -1, -1, -1, -1, 4, -1},
837 {-1, -1, -1, -1, -1, -1, -1, -1},
838 {-1, -1, -1, -1, -1, -1, -1, -1}},
839 {{ 2, 6, 0, 5, 5, 1, 3, 4},
840 { 1, -1, -1, 2, -1, -1, 0, -1},
841 { 4, -1, -1, 3, 6, -1, -1, 2},
842 {-1, -1, -1, 0, -1, -1, -1, -1},
843 {-1, -1, -1, 1, 4, -1, -1, -1},
844 {-1, -1, -1, 2, -1, -1, -1, -1},
845 {-1, -1, -1, 6, 3, -1, -1, -1},
846 {-1, -1, -1, 5, -1, -1, -1, -1},
847 {-1, -1, -1, 4, 1, -1, -1, -1},
848 {-1, -1, -1, -1, -1, -1, -1, -1}},
849 {{-1, -1, -1, -1, 5, 1, 1, 3},
850 { 0, 5, 1, 0, 5, 3, 3, -1},
851 { 5, 1, 0, 5, 1, 0, 5, 1},
852 { 0, 5, 1, 0, 5, 1, 6, -1},
853 {-1, -1, -1, -1, 1, 6, 5, 1},
854 {-1, -1, -1, -1, 5, 1, 6, -1},
855 {-1, -1, -1, -1, 1, 0, 5, 1},
856 {-1, -1, -1, -1, 5, 1, 0, -1},
857 {-1, -1, -1, -1, -1, -1, -1, -1},
858 {-1, -1, -1, -1, -1, -1, -1, -1}},
859 {{-1, 0, 7, 3, -1, -1, 2, 2},
860 {-1, 0, 7, 3, -1, -1, 2, -1},
861 {-1, 0, 7, 3, -1, -1, 2, 2},
862 {-1, 0, 7, 3, -1, 3, 1, -1},
863 {-1, 0, 7, 3, -1, 6, 4, 5},
864 {-1, 0, 7, 3, -1, 7, 0, -1},
865 {-1, 0, 7, 3, -1, 2, 3, 4},
866 {-1, 0, 7, 3, -1, 5, 6, -1},
867 {-1, -1, -1, -1, -1, 7, 0, 1},
868 {-1, -1, -1, -1, -1, -1, -1, -1}},
869 {{-1, -1, -1, 7, 7, 7, 7, -1},
870 { 3, 4, 5, -1, -1, -1, 7, -1},
871 { 2, -1, -1, -1, -1, -1, -1, 3},
872 { 7, -1, -1, -1, -1, -1, 4, -1},
873 { 7, -1, -1, -1, 3, 4, 5, 6},
874 { 7, -1, -1, 2, 0, 1, 2, -1},
875 { 6, -1, -1, -1, 3, 4, 5, 6},
876 { 0, 1, -1, -1, -1, -1, -1, -1},
877 { 2, 3, 4, -1, -1, -1, -1, -1},
878 { 5, 6, 0, -1, -1, -1, -1, -1}},
879 {{-1, 7, -1, -1, -1, -1, 2, -1},
880 { 1, 1, -1, -1, -1, 3, 3, -1},
881 {-1, 2, -1, -1, -1, -1, 4, -1},
882 { 3, 3, -1, -1, -1, 5, 5, -1},
883 {-1, 4, -1, -1, -1, -1, 6, -1},
884 { 5, 5, -1, -1, -1, 1, 1, -1},
885 {-1, 6, -1, -1, -1, -1, 7, -1},
886 {-1, -1, -1, -1, -1, -1, -1, -1},
887 {-1, -1, -1, -1, -1, -1, -1, -1},
888 {-1, -1, -1, -1, -1, -1, -1, -1}},
889 {{-1, 4, -1, -1, -1, -1, 4, -1},
890 { 2, -1, -1, 1, -1, -1, 2, -1},
891 { 5, -1, -1, 0, 0, -1, -1, 5},
892 { 5, -1, -1, 1, -1, -1, 6, -1},
893 {-1, 4, 2, 7, 7, 5, 4, -1},
894 {-1, -1, -1, 6, -1, -1, -1, -1},
895 {-1, -1, -1, 3, 3, -1, -1, -1},
896 {-1, -1, -1, 7, -1, -1, -1, -1},
897 {-1, -1, -1, -1, -1, -1, -1, -1},
898 {-1, -1, -1, -1, -1, -1, -1, -1}},
899 {{-1, 1, -1, -1, 2, 3, 4, -1},
900 { 2, -1, -1, 3, 0, 4, -1, -1},
901 { 4, -1, -1, 2, 3, 1, -1, -1},
902 { 3, -1, 4, 3, 0, -1, -1, -1},
903 { 4, -1, -1, 2, 5, 1, -1, -1},
904 { 3, -1, 4, 5, 0, 4, -1, -1},
905 {-1, -1, -1, -1, -1, -1, -1, -1},
906 {-1, -1, -1, -1, -1, -1, -1, -1},
907 {-1, -1, -1, -1, -1, -1, -1, -1},
908 {-1, -1, -1, -1, -1, -1, -1, -1}},
909 {{ 2, -1, -1, 1, 1, -1, -1, 2},
910 { 2, -1, 3, 3, 3, -1, 2, -1},
911 {-1, 2, -1, 4, 4, -1, 2, -1},
912 {-1, 7, 7, 0, 7, 7, -1, -1},
913 {-1, -1, -1, 4, 4, -1, -1, -1},
914 {-1, -1, 5, 7, 5, -1, -1, -1},
915 { 6, 3, 2, 6, 4, 2, 3, 6},
916 { 5, -1, -1, -1, -1, -1, 1, -1},
917 {-1, -1, -1, -1, -1, -1, -1, -1},
918 {-1, -1, -1, -1, -1, -1, -1, -1}},
919 {{ 4, 2, 3, 5, 7, 1, 3, 6},
920 { 1, -1, -1, 1, -1, -1, 1, -1},
921 { 3, 0, 1, 3, 2, 4, 3, 5},
922 { 4, -1, -1, 4, -1, -1, 4, -1},
923 {-1, 5, -1, -1, 5, -1, -1, 5},
924 { 0, 3, 2, 0, 4, 5, 0, -1},
925 {-1, 6, -1, -1, 6, -1, -1, 6},
926 { 7, -1, -1, 7, -1, -1, 7, -1},
927 {-1, -1, -1, -1, -1, -1, -1, -1},
928 {-1, -1, -1, -1, -1, -1, -1, -1}},
929 {{-1, 5, 4, -1, 1, 1, -1, -1},
930 { 5, -1, 4, 1, -1, 1, -1, -1},
931 { 0, -1, -1, -1, -1, -1, 0, -1},
932 { 0, 6, 4, -1, -1, 4, 2, -1},
933 {-1, 4, 3, 5, 2, 6, 3, 6},
934 {-1, 2, 6, -1, -1, 5, 4, -1},
935 {-1, -1, -1, -1, -1, -1, -1, -1},
936 {-1, -1, -1, -1, -1, -1, -1, -1},
937 {-1, -1, -1, -1, -1, -1, -1, -1},
938 {-1, -1, -1, -1, -1, -1, -1, -1}},
939 {{-1, -1, -1, 6, 6, -1, -1, -1},
940 {-1, -1, 5, 5, 4, -1, -1, -1},
941 {-1, -1, 1, 6, 6, 4, -1, -1},
942 {-1, 1, 7, 2, 5, 3, -1, -1},
943 {-1, 2, 7, 2, 1, 5, 3, -1},
944 { 2, 1, 3, 1, 4, 2, 7, -1},
945 {-1, 3, 1, 3, 4, 2, 7, -1},
946 {-1, 3, 5, 5, 6, 6, -1, -1},
947 {-1, -1, -1, -1, -1, -1, -1, -1},
948 {-1, -1, -1, -1, -1, -1, -1, -1}},
949 {{-1, -1, 7, 3, -1, -1, -1, -1},
950 {-1, 1, 7, 6, -1, -1, -1, -1},
951 {-1, 3, 7, 5, 1, 5, -1, -1},
952 { 7, 7, 0, 2, 4, 0, 4, -1},
953 { 7, 1, 4, 6, 5, 6, 5, 7},
954 { 1, 7, 7, 1, 7, 7, 1, -1},
955 {-1, -1, -1, -1, -1, -1, -1, -1},
956 {-1, -1, -1, -1, -1, -1, -1, -1},
957 {-1, -1, -1, -1, -1, -1, -1, -1},
958 {-1, -1, -1, -1, -1, -1, -1, -1}},
959 {{-1, -1, 1, -1, -1, 1, -1, -1},
960 {-1, 5, 6, 1, 5, 6, -1, -1},
961 {-1, 1, 1, 2, 2, 1, 1, -1},
962 { 4, 7, 1, 0, 1, 7, 4, -1},
963 {-1, 3, 7, 5, 7, 5, 3, -1},
964 {-1, 1, 1, 1, 1, 1, -1, -1},
965 {-1, -1, -1, -1, -1, -1, -1, -1},
966 {-1, -1, -1, -1, -1, -1, -1, -1},
967 {-1, -1, -1, -1, -1, -1, -1, -1},
968 {-1, -1, -1, -1, -1, -1, -1, -1}},
969 {{ 4, -1, -1, -1, 5, -1, -1, 4},
970 { 6, 6, 7, 6, -1, 4, 5, -1},
971 { 4, 2, 7, 5, 2, 2, 6, 4},
972 {-1, -1, 4, 1, -1, 5, 2, -1},
973 {-1, 5, 2, 7, 7, -1, 7, 4},
974 { 4, 6, 5, 4, -1, 4, 2, -1},
975 {-1, -1, -1, 4, -1, 4, 1, -1},
976 { 0, 0, 0, 5, -1, -1, -1, -1},
977 {-1, -1, -1, -1, 0, 0, 0, 0},
978 {-1, -1, -1, -1, -1, -1, -1, -1}},
979 {{ 1, -1, -1, -1, 0, 0, -1, -1},
980 { 2, -1, -1, 0, 1, 0, -1, -1},
981 { 3, -1, -1, 0, 2, 2, 0, -1},
982 { 4, -1, 0, 1, 1, 1, 0, -1},
983 { 5, -1, -1, 0, 4, 4, 0, -1},
984 { 6, -1, -1, 4, 4, 4, -1, -1},
985 { 7, -1, -1, -1, 4, 4, -1, -1},
986 {-1, -1, -1, 0, 1, 0, -1, -1},
987 {-1, -1, -1, 0, 1, 1, 0, -1},
988 {-1, -1, -1, -1, -1, -1, -1, -1}},
989 {{-1, -1, 3, -1, -1, 1, 7, -1},
990 {-1, 7, 4, -1, -1, 4, 3, -1},
991 { 1, -1, -1, 0, 2, 0, -1, -1},
992 { 5, 4, -1, 3, -1, -1, -1, -1},
993 { 4, -1, 3, 6, 1, 1, 6, -1},
994 {-1, 1, -1, -1, 4, -1, 1, -1},
995 {-1, 7, 5, -1, -1, -1, 3, -1},
996 {-1, -1, 3, -1, -1, -1, -1, -1},
997 {-1, -1, -1, -1, -1, -1, -1, -1},
998 {-1, -1, -1, -1, -1, -1, -1, -1}},
999 {{ 1, -1, -1, -1, 1, -1, -1, -1},
1000 { 2, -1, -1, -1, 2, -1, -1, -1},
1001 {-1, 3, -1, -1, 3, 3, -1, -1},
1002 {-1, 4, -1, 4, -1, 4, -1, -1},
1003 {-1, 5, -1, -1, 5, 5, -1, -1},
1004 { 6, -1, -1, 7, 1, 7, -1, -1},
1005 { 7, -1, -1, -1, 6, 6, -1, -1},
1006 {-1, -1, -1, -1, -1, -1, -1, -1},
1007 {-1, -1, -1, -1, -1, -1, -1, -1},
1008 {-1, -1, -1, -1, -1, -1, -1, -1}},
1009 {{ 2, -1, -1, 6, -1, 2, 5, 1},
1010 { 5, -1, 4, -1, 4, -1, 4, -1},
1011 { 6, -1, -1, 3, -1, -1, -1, 3},
1012 { 4, 2, 0, -1, -1, -1, 5, -1},
1013 {-1, -1, -1, 6, -1, 3, 6, -1},
1014 {-1, -1, 5, -1, 5, -1, -1, -1},
1015 {-1, -1, -1, 3, -1, 4, 2, 5},
1016 {-1, -1, -1, -1, -1, -1, -1, -1},
1017 {-1, -1, -1, -1, -1, -1, -1, -1},
1018 {-1, -1, -1, -1, -1, -1, -1, -1}},
1019 {{ 6, -1, -1, -1, 4, -1, -1, 3},
1020 { 0, 3, -1, -1, 6, -1, 0, -1},
1021 {-1, -1, 7, -1, 1, -1, 3, -1},
1022 { 7, -1, 4, 7, -1, 2, -1, -1},
1023 { 5, 2, 3, 2, 1, 6, -1, 3},
1024 {-1, -1, 0, 4, 3, 5, 4, -1},
1025 {-1, 7, 6, -1, -1, 0, -1, -1},
1026 { 4, 3, -1, -1, -1, 4, 2, -1},
1027 { 0, -1, -1, -1, -1, -1, 6, -1},
1028 {-1, -1, -1, -1, -1, -1, -1, -1}},
1029 {{ 6, 1, 2, 5, 1, 6, 3, 0},
1030 {-1, -1, -1, -1, -1, -1, 4, -1},
1031 { 0, 5, 2, 7, 1, 6, 2, -1},
1032 { 3, -1, -1, -1, -1, -1, -1, -1},
1033 { 6, 7, 6, 4, 0, 5, 2, 6},
1034 {-1, -1, -1, -1, -1, -1, 1, -1},
1035 { 6, 1, 4, 0, 6, 2, 3, -1},
1036 { 0, -1, -1, -1, -1, -1, -1, -1},
1037 {-1, 0, 4, 5, 3, 7, 6, 0},
1038 {-1, -1, -1, -1, -1, -1, -1, -1}},
1039 {{-1, -1, -1, 0, 1, -1, -1, -1},
1040 {-1, -1, 0, 7, 0, -1, -1, -1},
1041 {-1, -1, 1, 2, 2, 0, -1, -1},
1042 {-1, 0, 7, 0, 7, 0, -1, -1},
1043 {-1, 6, -1, 7, 7, -1, 6, -1},
1044 { 4, 1, 6, 6, 6, 4, 1, -1},
1045 {-1, 5, -1, 7, 7, -1, 5, -1},
1046 {-1, -1, -1, -1, -1, -1, -1, -1},
1047 {-1, -1, -1, -1, -1, -1, -1, -1},
1048 {-1, -1, -1, -1, -1, -1, -1, -1}},
1049 {{-1, -1, -1, 5, 6, -1, -1, -1},
1050 {-1, -1, 3, 3, 3, -1, -1, -1},
1051 {-1, -1, 7, 5, 3, 7, -1, -1},
1052 {-1, 3, -1, 6, -1, 3, -1, -1},
1053 { 2, -1, -1, 3, 7, -1, -1, 1},
1054 { 2, 2, -1, 3, -1, 1, 1, -1},
1055 {-1, 0, 2, 5, 6, 1, 0, -1},
1056 {-1, -1, -1, 3, -1, -1, -1, -1},
1057 {-1, -1, -1, 3, 7, -1, -1, -1},
1058 {-1, -1, -1, -1, -1, -1, -1, -1}},
1059 {{-1, 6, -1, -1, -1, -1, 2, -1},
1060 {-1, 2, 6, 0, 6, 0, -1, -1},
1061 {-1, 0, -1, -1, -1, -1, -1, -1},
1062 { 6, -1, -1, -1, -1, -1, -1, -1},
1063 {-1, 3, 3, 2, 0, 6, 0, 0},
1064 {-1, 6, -1, -1, -1, -1, 0, -1},
1065 {-1, -1, -1, 6, 0, 2, 6, -1},
1066 {-1, 2, 0, -1, -1, -1, -1, -1},
1067 {-1, -1, -1, -1, -1, -1, -1, -1},
1068 {-1, -1, -1, -1, -1, -1, -1, -1}},
1069 {{ 0, 7, -1, -1, -1, -1, -1, -1},
1070 { 1, 5, -1, -1, -1, -1, -1, -1},
1071 { 7, 2, 5, -1, -1, -1, -1, -1},
1072 { 6, 3, 4, -1, -1, -1, -1, -1},
1073 { 5, 5, 4, 4, -1, -1, -1, -1},
1074 { 3, 3, 5, 3, -1, -1, -1, -1},
1075 { 1, 2, 2, 5, 3, -1, -1, -1},
1076 { 1, 0, 0, 7, 6, -1, -1, -1},
1077 { 3, 3, 5, 5, 7, 6, -1, -1},
1078 {-1, -1, -1, -1, -1, -1, -1, -1}},
1079 {{-1, -1, 2, 6, 6, 2, -1, -1},
1080 {-1, 2, 1, 1, 0, 2, -1, -1},
1081 {-1, 2, 3, 2, 2, 0, 2, -1},
1082 { 2, 3, 2, 5, 2, 7, 2, -1},
1083 { 2, 4, 2, 5, 2, 7, 2, 0},
1084 { 2, 4, 2, 6, 6, 2, 0, -1},
1085 {-1, 2, 5, 2, 2, 2, 7, 2},
1086 {-1, 2, 5, 6, 6, 7, 2, -1},
1087 {-1, -1, 2, 2, 2, 2, 2, -1},
1088 {-1, -1, -1, -1, -1, -1, -1, -1}},
1089 {{-1, -1, 0, -1, -1, 0, -1, -1},
1090 { 1, 0, 0, 1, 0, 0, 1, -1},
1091 { 1, 7, 7, 5, 5, 7, 7, 1},
1092 { 3, 2, -1, 2, -1, 2, 3, -1},
1093 { 3, 7, -1, 6, 6, -1, 7, 3},
1094 { 7, -1, -1, 6, -1, -1, 7, -1},
1095 { 4, 4, 5, -1, -1, 5, 4, 4},
1096 {-1, -1, -1, -1, -1, -1, -1, -1},
1097 {-1, -1, -1, -1, -1, -1, -1, -1},
1098 {-1, -1, -1, -1, -1, -1, -1, -1}},
1099 {{-1, 6, 3, -1, -1, 3, 6, -1},
1100 { 6, -1, 2, -1, 2, -1, 6, -1},
1101 { 2, -1, 0, 1, 1, 0, -1, 2},
1102 { 5, 0, -1, 7, -1, 0, 5, -1},
1103 {-1, 5, -1, 6, 6, -1, 5, -1},
1104 { 7, 1, 4, -1, 4, 1, 7, -1},
1105 { 7, -1, 4, -1, -1, 4, -1, 7},
1106 { 2, 0, -1, -1, -1, 0, 2, -1},
1107 {-1, 2, -1, -1, -1, -1, 2, -1},
1108 {-1, -1, -1, -1, -1, -1, -1, -1}},
1109 {{ 6, 1, -1, -1, -1, -1, 4, 0},
1110 { 2, 7, 5, 5, 5, 7, 3, -1},
1111 { 6, 1, -1, -1, -1, -1, 4, 0},
1112 { 2, 5, 7, 7, 7, 5, 3, -1},
1113 { 6, 1, -1, -1, -1, -1, 4, 0},
1114 { 2, 0, 6, 6, 6, 0, 3, -1},
1115 { 6, 1, -1, -1, -1, -1, 4, 0},
1116 {-1, -1, -1, -1, -1, -1, -1, -1},
1117 {-1, -1, -1, -1, -1, -1, -1, -1},
1118 {-1, -1, -1, -1, -1, -1, -1, -1}},
1119 {{ 5, -1, -1, 1, 1, -1, -1, 5},
1120 { 5, -1, 4, -1, 4, -1, 5, -1},
1121 {-1, 2, 4, -1, -1, 4, 2, -1},
1122 { 7, 2, -1, -1, -1, 2, 7, -1},
1123 { 0, -1, 0, 4, 4, 0, -1, 0},
1124 { 7, 2, -1, -1, -1, 2, 7, -1},
1125 {-1, 2, 3, -1, -1, 3, 2, -1},
1126 { 5, -1, 3, -1, 3, -1, 5, -1},
1127 { 5, -1, -1, 6, 6, -1, -1, 5},
1128 {-1, -1, -1, -1, -1, -1, -1, -1}},
1129 {{ 2, 2, -1, -1, -1, -1, 5, 5},
1130 { 5, -1, -1, -1, -1, -1, 2, -1},
1131 { 5, -1, -1, -1, -1, -1, -1, 2},
1132 { 1, -1, 1, 5, 1, -1, 3, -1},
1133 { 5, 2, 5, 3, 1, 2, 5, 2},
1134 { 2, 0, 5, -1, 2, 0, 5, -1},
1135 {-1, 3, 7, -1, -1, 3, 7, -1},
1136 {-1, -1, 2, 0, 5, -1, -1, -1},
1137 {-1, -1, -1, -1, -1, -1, -1, -1},
1138 {-1, -1, -1, -1, -1, -1, -1, -1}},
1139 {{ 0, 6, 5, 2, 3, 4, 1, 7},
1140 {-1, -1, -1, -1, 1, -1, -1, -1},
1141 {-1, -1, -1, 1, 1, -1, -1, -1},
1142 {-1, -1, 1, -1, -1, -1, -1, -1},
1143 { 7, 1, 4, 3, 2, 5, 6, 0},
1144 {-1, -1, -1, -1, 1, -1, -1, -1},
1145 {-1, -1, -1, 1, 1, -1, -1, -1},
1146 {-1, -1, 1, -1, -1, -1, -1, -1},
1147 { 0, 6, 5, 2, 3, 4, 1, 7},
1148 {-1, -1, -1, -1, -1, -1, -1, -1}},
1149 {{-1, -1, 1, -1, -1, 1, -1, -1},
1150 {-1, 2, 4, -1, 2, 4, -1, -1},
1151 {-1, 2, 3, 6, 5, 3, 2, -1},
1152 {-1, 6, 5, -1, 6, 5, -1, -1},
1153 {-1, -1, -1, 7, 7, -1, -1, -1},
1154 {-1, -1, -1, 7, -1, -1, -1, -1},
1155 { 1, -1, -1, 7, 7, -1, -1, 3},
1156 { 2, -1, -1, 7, -1, -1, 2, -1},
1157 {-1, 3, 4, 5, 6, 4, 1, -1},
1158 {-1, -1, -1, -1, -1, -1, -1, -1}},
1159 {{ 1, -1, -1, 2, 2, -1, -1, 2},
1160 { 1, 3, 7, 3, 7, 4, 2, -1},
1161 {-1, 1, 6, -1, -1, 6, 2, -1},
1162 { 6, -1, 7, 3, 7, -1, 6, -1},
1163 {-1, 4, 2, -1, -1, 1, 3, -1},
1164 {-1, -1, 2, 6, 1, -1, -1, -1},
1165 {-1, 4, 3, 3, 4, 4, 3, -1},
1166 {-1, -1, -1, -1, -1, -1, -1, -1},
1167 {-1, -1, -1, -1, -1, -1, -1, -1},
1168 {-1, -1, -1, -1, -1, -1, -1, -1}},
1169 {{-1, -1, -1, 5, 6, -1, -1, -1},
1170 {-1, -1, -1, 3, -1, -1, -1, -1},
1171 {-1, -1, -1, 1, 2, -1, -1, -1},
1172 {-1, -1, -1, 4, -1, -1, -1, -1},
1173 {-1, -1, -1, 5, 7, -1, -1, -1},
1174 {-1, -1, -1, 2, -1, -1, -1, -1},
1175 { 6, 5, 4, 3, 2, 1, 7, 5},
1176 {-1, -1, -1, -1, -1, -1, -1, -1},
1177 {-1, -1, -1, -1, -1, -1, -1, -1},
1178 {-1, -1, -1, -1, -1, -1, -1, -1}},
1179 {{-1, 0, -1, 1, -1, 2, -1, -1},
1180 {-1, 4, -1, 5, -1, 6, -1, -1},
1181 {-1, 7, -1, 0, -1, 2, -1, -1},
1182 {-1, 6, -1, 3, -1, 6, -1, -1},
1183 {-1, 1, -1, 1, -1, 2, -1, -1},
1184 {-1, 3, -1, 5, -1, 0, -1, -1},
1185 {-1, 2, -1, 4, -1, 6, -1, -1},
1186 {-1, 3, -1, 6, -1, 7, -1, -1},
1187 {-1, -1, -1, -1, -1, -1, -1, -1},
1188 {-1, -1, -1, -1, -1, -1, -1, -1}},
1189 {{ 1, 1, 2, 2, 3, 3, 4, 4},
1190 { 5, 5, 6, 7, 6, 5, 5, -1},
1191 { 6, 4, 3, 3, 2, 2, 1, 6},
1192 { 4, 6, 5, 7, 6, 3, 1, -1},
1193 {-1, -1, -1, -1, -1, -1, -1, -1},
1194 {-1, -1, -1, -1, -1, -1, -1, -1},
1195 {-1, -1, -1, -1, -1, -1, -1, -1},
1196 {-1, -1, -1, -1, -1, -1, -1, -1},
1197 {-1, -1, -1, -1, -1, -1, -1, -1},
1198 {-1, -1, -1, -1, -1, -1, -1, -1}},
1199 {{ 7, 4, -1, 1, 2, -1, 4, 7},
1200 { 5, 5, -1, 2, -1, 4, 4, -1},
1201 {-1, 5, -1, 7, 7, -1, 4, -1},
1202 { 1, 0, 6, 7, 6, 0, 2, -1},
1203 {-1, 2, -1, 5, 3, -1, 1, -1},
1204 { 1, 1, -1, -1, -1, 2, 2, -1},
1205 { 6, 1, 4, -1, -1, 4, 2, 6},
1206 { 5, 3, -1, -1, -1, 3, 5, -1},
1207 {-1, -1, -1, -1, -1, -1, -1, -1},
1208 {-1, -1, -1, -1, -1, -1, -1, -1}},
1209 {{ 1, 5, 1, 0, 0, 1, 5, 1},
1210 { 1, 2, 5, -1, 5, 2, 1, -1},
1211 { 3, 6, 1, 2, 2, 1, 6, 3},
1212 { 4, 3, 4, -1, 4, 3, 4, -1},
1213 { 3, 4, 6, 5, 5, 6, 4, 3},
1214 { 0, 2, 3, -1, 3, 2, 0, -1},
1215 { 2, 3, 1, 5, 5, 1, 3, 2},
1216 {-1, -1, -1, -1, -1, -1, -1, -1},
1217 {-1, -1, -1, -1, -1, -1, -1, -1},
1218 {-1, -1, -1, -1, -1, -1, -1, -1}},
1219 {{ 3, 0, 2, 7, 5, 7, 6, 5},
1220 { 6, -1, 1, -1, 2, -1, 1, -1},
1221 {-1, 6, 4, 0, 3, 4, 5, -1},
1222 {-1, 5, -1, 1, -1, 4, -1, -1},
1223 {-1, 7, 3, 5, 6, 5, 3, -1},
1224 { 1, -1, 2, -1, 4, -1, 2, -1},
1225 { 6, 4, 4, 6, 6, 5, 5, 1},
1226 {-1, -1, -1, -1, -1, -1, -1, -1},
1227 {-1, -1, -1, -1, -1, -1, -1, -1},
1228 {-1, -1, -1, -1, -1, -1, -1, -1}}
1232 * type is the bubble number 0-7
1233 * fallx is the x axis movement for the falling bubble
1234 * fallvel is the initial upward velocity for the falling bubble
1235 * ingroup denotes a bubble that is part of a group to be removed
1236 * anchored denotes a bubble that is anchored to the ceiling
1247 /* the game context struct
1248 * score is the current score
1249 * level is the current level
1250 * angle is the current cannon direction
1251 * shots is the number of shots fired since last compression
1252 * compress is the height of the compressor
1253 * onboardcnt is the number of unique bubbles on the playing board
1254 * onboard is the unique bubbles on the playing board
1255 * nextinq is the pointer to the next bubble in the firing queue
1256 * queue is the circular buffer of bubbles to be fired
1257 * elapsedlvl is level elapsed time in 1/100s of seconds
1258 * elapsedshot is the shot elapsed time in 1/100s of seconds
1259 * startedshot is when the current shot began
1260 * playboard is the game playing board
1262 struct game_context
{
1269 int onboard
[NUM_BUBBLES
];
1271 int queue
[NUM_QUEUE
];
1275 struct tile playboard
[BB_HEIGHT
][BB_WIDTH
];
1278 static struct highscore highscores
[NUM_SCORES
];
1280 /* used to denote available resume info */
1281 static bool resume
= false;
1282 static bool resume_file
= false;
1283 static unsigned int highlevel
= 0; /* the highest level beaten */
1284 static unsigned int last_highlevel
= 0;
1286 static void bubbles_init(struct game_context
* bb
);
1287 static bool bubbles_nextlevel(struct game_context
* bb
);
1288 static void bubbles_getonboard(struct game_context
* bb
);
1289 static void bubbles_drawboard(struct game_context
* bb
);
1290 static int bubbles_fire(struct game_context
* bb
);
1291 static bool bubbles_collision(struct game_context
* bb
, int y
, int x
,
1292 int nearrow
, int nearcol
);
1293 static bool bubbles_ingroup(struct game_context
* bb
, int row
, int col
);
1294 static int bubbles_searchgroup(struct game_context
* bb
, int row
, int col
);
1295 static int bubbles_remove(struct game_context
* bb
);
1296 static void bubbles_anchored(struct game_context
* bb
, int row
, int col
);
1297 static int bubbles_fall(struct game_context
* bb
);
1298 static int bubbles_checklevel(struct game_context
* bb
);
1299 static void bubbles_recordscore(struct game_context
* bb
);
1300 static bool bubbles_loadgame(struct game_context
* bb
);
1301 static void bubbles_savegame(struct game_context
* bb
);
1302 static inline void bubbles_setcolors(void);
1303 static void bubbles_callback(void* param
);
1304 static int bubbles_handlebuttons(struct game_context
* bb
, bool animblock
,
1306 static int bubbles(struct game_context
* bb
);
1308 /*****************************************************************************
1309 * bubbles_init() initializes bubbles data structures.
1310 ******************************************************************************/
1311 static void bubbles_init(struct game_context
* bb
) {
1312 bubbles_setcolors();
1313 /* seed the rand generator */
1314 rb
->srand(*rb
->current_tick
);
1316 /* check for resumed game */
1324 bubbles_nextlevel(bb
);
1327 /*****************************************************************************
1328 * bubbles_nextlevel() sets up the game for the next level, returns false if
1329 * there are no more levels.
1330 ******************************************************************************/
1331 static bool bubbles_nextlevel(struct game_context
* bb
) {
1336 /* check if there are no more levels */
1337 if(bb
->level
> NUM_LEVELS
) return false;
1339 /* save highest level */
1340 if (bb
->level
-1 > highlevel
)
1341 highlevel
= bb
->level
-1;
1343 /* set up the play board */
1344 rb
->memset(bb
->playboard
, 0, sizeof(bb
->playboard
));
1345 for(i
=0; i
<BB_LEVEL_HEIGHT
; i
++) {
1346 for(j
=0; j
<BB_WIDTH
; j
++) {
1347 pos
= (int)level
[bb
->level
-1][i
][j
];
1348 if(pos
>=0 && pos
< NUM_BUBBLES
) {
1349 bb
->playboard
[i
][j
].type
= pos
;
1351 bb
->playboard
[i
][j
].type
= -1;
1355 for(i
=BB_LEVEL_HEIGHT
; i
<BB_HEIGHT
; i
++) {
1356 for(j
=0; j
<BB_WIDTH
; j
++) {
1357 bb
->playboard
[i
][j
].type
= -1;
1361 /* fill first bubbles in shot queue */
1362 bubbles_getonboard(bb
);
1363 for(i
=0; i
<NUM_QUEUE
; i
++) {
1364 bb
->queue
[i
] = bb
->onboard
[rb
->rand()%bb
->onboardcnt
];
1372 bb
->elapsedshot
= 0;
1377 /*****************************************************************************
1378 * bubbles_getonboard() determines which bubble types are on the play board.
1379 ******************************************************************************/
1380 static void bubbles_getonboard(struct game_context
* bb
) {
1385 rb
->memset(bb
->onboard
, -1, sizeof(bb
->onboard
));
1387 for(i
=0; i
<BB_HEIGHT
; i
++) {
1388 for(j
=0; j
<BB_WIDTH
; j
++) {
1389 if(bb
->playboard
[i
][j
].type
>= 0) {
1392 for(k
=0; k
<bb
->onboardcnt
; k
++) {
1393 if(bb
->playboard
[i
][j
].type
== bb
->onboard
[k
]) {
1400 bb
->onboard
[bb
->onboardcnt
] = bb
->playboard
[i
][j
].type
;
1404 if(bb
->onboardcnt
== NUM_BUBBLES
) return;
1410 /*****************************************************************************
1411 * bubbles_drawboard() draws the game board to the buffer but does not update
1413 ******************************************************************************/
1414 static void bubbles_drawboard(struct game_context
* bb
) {
1419 bool evenline
= false;
1420 char *level
= "Level";
1421 char *score
= "Score";
1422 char *next
= "Next";
1423 char *hurry
= "HURRY!";
1427 rb
->lcd_clear_display();
1428 int font
= rb
->screens
[SCREEN_MAIN
]->getfont();
1429 h
= rb
->font_get(font
)->height
+ 1;
1430 /* draw background */
1431 #ifdef HAVE_LCD_COLOR
1432 rb
->lcd_bitmap(bubbles_background
, 0, 0, LCD_WIDTH
, LCD_HEIGHT
);
1435 /* display play board */
1436 for(i
=0; i
<BB_HEIGHT
; i
++) {
1440 indent
= ROW_INDENT
;
1444 evenline
= !evenline
;
1446 for(j
=0; j
<colmax
; j
++) {
1447 if(bb
->playboard
[i
][j
].type
>= 0 && !bb
->playboard
[i
][j
].delete) {
1448 rb
->lcd_bitmap_part(bubbles_emblem
,
1449 0, EMBLEM_HEIGHT
*bb
->playboard
[i
][j
].type
,
1450 STRIDE( SCREEN_MAIN
,
1451 BMPWIDTH_bubbles_emblem
, BMPHEIGHT_bubbles_emblem
),
1452 XOFS
+indent
+BUBBLE_WIDTH
*j
+(BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2,
1453 YOFS
+ROW_HEIGHT
*i
+(BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2+bb
->compress
*ROW_HEIGHT
,
1454 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
1455 rb
->lcd_set_drawmode(DRMODE_FG
);
1456 rb
->lcd_mono_bitmap((const unsigned char *)bubbles_bubble
,
1457 XOFS
+indent
+BUBBLE_WIDTH
*j
,
1458 YOFS
+ROW_HEIGHT
*i
+bb
->compress
*ROW_HEIGHT
,
1459 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
1460 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1465 /* display bubble to be shot */
1466 rb
->lcd_bitmap_part(bubbles_emblem
,
1467 0, EMBLEM_HEIGHT
*bb
->queue
[bb
->nextinq
],
1468 STRIDE( SCREEN_MAIN
,
1469 BMPWIDTH_bubbles_emblem
, BMPHEIGHT_bubbles_emblem
),
1470 SHOTX
+(BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2,
1471 SHOTY
+(BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2,
1472 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
1473 rb
->lcd_set_drawmode(DRMODE_FG
);
1474 rb
->lcd_mono_bitmap((const unsigned char *)bubbles_bubble
,
1476 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
1477 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1479 /* display next bubble to be shot */
1481 rb
->lcd_bitmap_part(bubbles_emblem
,
1482 0, EMBLEM_HEIGHT
*bb
->queue
[(bb
->nextinq
+1)%NUM_QUEUE
],
1483 STRIDE( SCREEN_MAIN
,
1484 BMPWIDTH_bubbles_emblem
, BMPHEIGHT_bubbles_emblem
),
1485 XOFS
/2-BUBBLE_WIDTH
/2+(BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2,
1486 SHOTY
+(BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2,
1487 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
1488 rb
->lcd_set_drawmode(DRMODE_FG
);
1489 rb
->lcd_mono_bitmap((const unsigned char *)bubbles_bubble
,
1490 XOFS
/2-BUBBLE_WIDTH
/2, SHOTY
,
1491 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
1492 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1494 rb
->lcd_bitmap_part(bubbles_emblem
,
1495 0, EMBLEM_HEIGHT
*bb
->queue
[(bb
->nextinq
+1)%NUM_QUEUE
],
1496 STRIDE( SCREEN_MAIN
,
1497 BMPWIDTH_bubbles_emblem
, BMPHEIGHT_bubbles_emblem
),
1498 NEXT_BB_X
+ NEXT_BB_WIDTH
/2-BUBBLE_WIDTH
/2+(BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2,
1499 NEXT_BB_Y
+ (BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2 + h
,
1500 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
1501 rb
->lcd_set_drawmode(DRMODE_FG
);
1502 rb
->lcd_mono_bitmap((const unsigned char *)bubbles_bubble
,
1503 NEXT_BB_X
+ NEXT_BB_WIDTH
/2-BUBBLE_WIDTH
/2, NEXT_BB_Y
+ h
,
1504 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
1505 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1508 /* draw bounding lines */
1509 #ifndef HAVE_LCD_COLOR
1510 rb
->lcd_vline(XOFS
-1, 0, LCD_HEIGHT
);
1511 rb
->lcd_vline(XOFS
+BUBBLE_WIDTH
*BB_WIDTH
, 0, LCD_HEIGHT
);
1513 rb
->lcd_hline(XOFS
, XOFS
+BUBBLE_WIDTH
*BB_WIDTH
-1, YOFS
+bb
->compress
*ROW_HEIGHT
-1);
1514 rb
->lcd_hline(XOFS
, XOFS
+BUBBLE_WIDTH
*BB_WIDTH
-1,
1515 YOFS
+ROW_HEIGHT
*(BB_HEIGHT
-2)+BUBBLE_HEIGHT
);
1518 tipx
= SHOTX
+BUBBLE_WIDTH
/2+(((fp14_sin(bb
->angle
)>>4)*BUBBLE_WIDTH
*3/2)>>10);
1519 tipy
= SHOTY
+BUBBLE_HEIGHT
/2-(((fp14_cos(bb
->angle
)>>4)*BUBBLE_HEIGHT
*3/2)>>10);
1521 rb
->lcd_drawline(SHOTX
+BUBBLE_WIDTH
/2+(((fp14_sin(bb
->angle
)>>4)*BUBBLE_WIDTH
/2)>>10),
1522 SHOTY
+BUBBLE_HEIGHT
/2-(((fp14_cos(bb
->angle
)>>4)*BUBBLE_HEIGHT
/2)>>10),
1524 xlcd_filltriangle(tipx
, tipy
,
1525 tipx
+(((fp14_sin(bb
->angle
-135)>>4)*BUBBLE_WIDTH
/3)>>10),
1526 tipy
-(((fp14_cos(bb
->angle
-135)>>4)*BUBBLE_HEIGHT
/3)>>10),
1527 tipx
+(((fp14_sin(bb
->angle
+135)>>4)*BUBBLE_WIDTH
/3)>>10),
1528 tipy
-(((fp14_cos(bb
->angle
+135)>>4)*BUBBLE_HEIGHT
/3)>>10));
1531 rb
->snprintf(str
, 4, "%d", bb
->level
);
1532 rb
->lcd_getstringsize(level
, &w1
, NULL
);
1533 rb
->lcd_getstringsize(str
, &w2
, NULL
);
1535 rb
->lcd_putsxy(XOFS
/2-w1
/2, 2, level
);
1536 rb
->lcd_putsxy(XOFS
/2-w2
/2, 2+h
, str
);
1538 rb
->lcd_putsxy(LEVEL_TXT_X
+(LEVEL_TXT_WIDTH
/2-w1
/2), LEVEL_TXT_Y
, level
);
1539 rb
->lcd_putsxy(LEVEL_TXT_X
+(LEVEL_TXT_WIDTH
/2-w2
/2), LEVEL_TXT_Y
+h
, str
);
1542 rb
->snprintf(str
, 10, "%d", bb
->score
);
1543 rb
->lcd_getstringsize(score
, &w1
,NULL
);
1544 rb
->lcd_getstringsize(str
, &w2
, NULL
);
1546 rb
->lcd_putsxy(XOFS
/2-w1
/2, 29, score
);
1547 rb
->lcd_putsxy(XOFS
/2-w2
/2, 29+h
, str
);
1549 rb
->lcd_putsxy(SCORE_TXT_X
+(SCORE_TXT_WIDTH
/2-w1
/2), SCORE_TXT_Y
, score
);
1550 rb
->lcd_putsxy(SCORE_TXT_X
+(SCORE_TXT_WIDTH
/2-w2
/2), SCORE_TXT_Y
+h
, str
);
1553 rb
->lcd_getstringsize(next
, &w1
, NULL
);
1555 rb
->lcd_putsxy(XOFS
/2-w1
/2, SHOTY
-h
, next
);
1557 rb
->lcd_putsxy(NEXT_BB_X
+(NEXT_BB_WIDTH
/2-w1
/2), NEXT_BB_Y
, next
);
1561 if(bb
->elapsedshot
>= (MAX_SHOTTIME
*7)/10) {
1562 rb
->lcd_getstringsize(hurry
, &w1
, &h
);
1563 rb
->lcd_putsxy(LCD_WIDTH
/2-w1
/2, LCD_HEIGHT
/2-h
/2, hurry
);
1567 /*****************************************************************************
1568 * bubbles_fire() fires the current bubble, reloads the cannon, attaches
1569 * bubble to playboard, removes appropriate bubbles, and advances the
1571 ******************************************************************************/
1572 static int bubbles_fire(struct game_context
* bb
) {
1574 long shotxinc
, shotyinc
;
1575 long shotxofs
, shotyofs
;
1577 long tempxofs
, tempyofs
;
1578 int nearrow
, nearcol
;
1579 int lastrow
= BB_HEIGHT
-1;
1580 int lastcol
= (BB_WIDTH
-1)/2;
1582 long lasttick
, currenttick
;
1584 /* get current bubble */
1585 bubblecur
= bb
->queue
[bb
->nextinq
];
1586 shotxinc
= ((fp14_sin(bb
->angle
)>>4)*BUBBLE_WIDTH
)/3;
1587 shotyinc
= ((-1*(fp14_cos(bb
->angle
)>>4))*BUBBLE_HEIGHT
)/3;
1588 shotxofs
= shotyofs
= 0;
1590 /* advance the queue */
1591 bb
->queue
[bb
->nextinq
] = bb
->onboard
[rb
->rand()%bb
->onboardcnt
];
1592 bb
->nextinq
= (bb
->nextinq
+1)%NUM_QUEUE
;
1593 bubbles_drawboard(bb
);
1594 rb
->lcd_update_rect(0, 0, XOFS
, LCD_HEIGHT
);
1596 /* move the bubble across the play board */
1597 lasttick
= *rb
->current_tick
;
1600 /* move the bubble one step */
1601 shotyofs
+= shotyinc
;
1602 shotxofs
+= shotxinc
*shotxdirec
;
1604 /* check for bounce off sides */
1605 if(SHOTX
+(shotxofs
>>10) < XOFS
) {
1606 shotxofs
+= 2*((XOFS
<<10)-(((SHOTX
)<<10)+shotxofs
));
1608 } else if(SHOTX
+(shotxofs
>>10) > XOFS
+(BB_WIDTH
-1)*BUBBLE_WIDTH
) {
1609 shotxofs
-= 2*((((SHOTX
)<<10)+shotxofs
)-
1610 ((XOFS
<<10)+(((BB_WIDTH
-1)*BUBBLE_WIDTH
)<<10)));
1614 tempxofs
= shotxofs
>>10;
1615 tempyofs
= shotyofs
>>10;
1618 bubbles_drawboard(bb
);
1619 rb
->lcd_bitmap_part(bubbles_emblem
, 0, EMBLEM_HEIGHT
*bubblecur
,
1620 STRIDE( SCREEN_MAIN
,
1621 BMPWIDTH_bubbles_emblem
,
1622 BMPHEIGHT_bubbles_emblem
),
1623 SHOTX
+tempxofs
+(BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2,
1624 SHOTY
+tempyofs
+(BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2,
1625 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
1626 rb
->lcd_set_drawmode(DRMODE_FG
);
1627 rb
->lcd_mono_bitmap((const unsigned char *)bubbles_bubble
,
1628 SHOTX
+tempxofs
, SHOTY
+tempyofs
,
1629 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
1630 rb
->lcd_set_drawmode(DRMODE_SOLID
);
1631 rb
->lcd_update_rect(XOFS
, 0, BB_WIDTH
*BUBBLE_WIDTH
, LCD_HEIGHT
);
1633 /* find nearest position */
1634 nearrow
= ((SHOTY
+tempyofs
)-
1635 (YOFS
+bb
->compress
*ROW_HEIGHT
)+
1636 (ROW_HEIGHT
/2))/ROW_HEIGHT
;
1637 if(nearrow
>= BB_HEIGHT
) nearrow
= BB_HEIGHT
-1;
1639 if(nearrow
%2) { /* odd row */
1640 nearcol
= ((SHOTX
+tempxofs
)-
1642 (BUBBLE_WIDTH
/2))/BUBBLE_WIDTH
;
1643 if(nearcol
>= BB_WIDTH
-1) nearcol
= BB_WIDTH
-2;
1644 } else { /* even row */
1645 nearcol
= ((SHOTX
+tempxofs
)-XOFS
+(BUBBLE_WIDTH
/2))/BUBBLE_WIDTH
;
1646 if(nearcol
>= BB_WIDTH
) nearcol
= BB_WIDTH
-1;
1648 if(nearcol
< 0) nearcol
= 0;
1650 /* if nearest position is occupied attach to last position */
1651 if(bb
->playboard
[nearrow
][nearcol
].type
>= 0) {
1652 bb
->playboard
[lastrow
][lastcol
].type
= bubblecur
;
1656 /* save last position */
1660 /* if collision with neighbor then attach shot */
1661 if(bubbles_collision(bb
, YOFS
+SHOTY
+tempyofs
, SHOTX
+tempxofs
,
1662 nearrow
, nearcol
)) {
1663 bb
->playboard
[nearrow
][nearcol
].type
= bubblecur
;
1667 /* if at top then attach shot to the ceiling */
1668 if(nearrow
== 0 && SHOTY
+tempyofs
<= YOFS
+bb
->compress
*ROW_HEIGHT
) {
1669 bb
->playboard
[nearrow
][nearcol
].type
= bubblecur
;
1673 /* handle button events */
1674 buttonres
= bubbles_handlebuttons(bb
, true, 0);
1675 if(buttonres
!= BB_NONE
) return buttonres
;
1677 /* framerate limiting */
1678 currenttick
= *rb
->current_tick
;
1679 if(currenttick
-lasttick
< HZ
/MAX_FPS
) {
1680 rb
->sleep((HZ
/MAX_FPS
)-(currenttick
-lasttick
));
1684 lasttick
= currenttick
;
1687 bubbles_drawboard(bb
);
1690 /* clear appropriate bubbles from playing board */
1691 if(bubbles_ingroup(bb
, lastrow
, lastcol
)) {
1692 buttonres
= bubbles_remove(bb
);
1693 if(buttonres
!= BB_NONE
) return buttonres
;
1696 /* update shots and compress amount */
1698 if(bb
->shots
>= NUM_COMPRESS
) {
1706 /*****************************************************************************
1707 * bubbles_collision() determines if a fired bubble has collided with another
1709 ******************************************************************************/
1710 static bool bubbles_collision(struct game_context
* bb
, int y
, int x
,
1711 int nearrow
, int nearcol
) {
1713 int adj
= nearrow
%2;
1715 /* check neighbors */
1716 if(nearcol
-1 >= 0) {
1717 if(bb
->playboard
[nearrow
][nearcol
-1].type
>= 0) {
1718 nx
= XOFS
+(nearrow
%2 ? ROW_INDENT
: 0)+BUBBLE_WIDTH
*(nearcol
-1);
1719 ny
= YOFS
+ROW_HEIGHT
*nearrow
+bb
->compress
*ROW_HEIGHT
;
1720 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1724 if(nearcol
-1+adj
>= 0) {
1725 if(nearrow
-1 >= 0) {
1726 if(bb
->playboard
[nearrow
-1][nearcol
-1+adj
].type
>= 0) {
1727 nx
= XOFS
+((nearrow
-1)%2 ? ROW_INDENT
: 0)+
1728 BUBBLE_WIDTH
*(nearcol
-1+adj
);
1729 ny
= YOFS
+ROW_HEIGHT
*(nearrow
-1)+bb
->compress
*ROW_HEIGHT
;
1730 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1734 if(nearrow
+1 < BB_HEIGHT
) {
1735 if(bb
->playboard
[nearrow
+1][nearcol
-1+adj
].type
>= 0) {
1736 nx
= XOFS
+((nearrow
+1)%2 ? ROW_INDENT
: 0)+
1737 BUBBLE_WIDTH
*(nearcol
-1+adj
);
1738 ny
= YOFS
+ROW_HEIGHT
*(nearrow
+1)+bb
->compress
*ROW_HEIGHT
;
1739 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1744 if(nearcol
+adj
>= 0) {
1745 if(nearrow
-1 >= 0) {
1746 if(bb
->playboard
[nearrow
-1][nearcol
+adj
].type
>= 0) {
1747 nx
= XOFS
+((nearrow
-1)%2 ? ROW_INDENT
: 0)+
1748 BUBBLE_WIDTH
*(nearcol
+adj
);
1749 ny
= YOFS
+ROW_HEIGHT
*(nearrow
-1)+bb
->compress
*ROW_HEIGHT
;
1750 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1754 if(nearrow
+1 < BB_HEIGHT
) {
1755 if(bb
->playboard
[nearrow
+1][nearcol
+adj
].type
>= 0) {
1756 nx
= XOFS
+((nearrow
+1)%2 ? ROW_INDENT
: 0)+
1757 BUBBLE_WIDTH
*(nearcol
+adj
);
1758 ny
= YOFS
+ROW_HEIGHT
*(nearrow
+1)+bb
->compress
*ROW_HEIGHT
;
1759 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1764 if(nearcol
+1 < BB_WIDTH
-adj
) {
1765 if(bb
->playboard
[nearrow
][nearcol
+1].type
>= 0) {
1766 nx
= XOFS
+(nearrow
%2 ? ROW_INDENT
: 0)+BUBBLE_WIDTH
*(nearcol
+1);
1767 ny
= YOFS
+ROW_HEIGHT
*nearrow
+bb
->compress
*ROW_HEIGHT
;
1768 if((x
-nx
)*(x
-nx
)+(y
-ny
)*(y
-ny
) < MIN_DISTANCE
) return true;
1775 /*****************************************************************************
1776 * bubbles_ingroup() marks all bubbles that form the current group.
1777 ******************************************************************************/
1778 static bool bubbles_ingroup(struct game_context
* bb
, int row
, int col
) {
1782 count
= bubbles_searchgroup(bb
, row
, col
);
1784 /* unmark group if too small */
1786 for(i
=0; i
<BB_HEIGHT
; i
++) {
1787 for(j
=0; j
<BB_WIDTH
; j
++) {
1788 bb
->playboard
[i
][j
].ingroup
= false;
1798 /*****************************************************************************
1799 * bubbles_searchgroup() return the size of the group of bubbles of the same
1800 * type that the current bubble belongs to.
1801 ******************************************************************************/
1802 static int bubbles_searchgroup(struct game_context
* bb
, int row
, int col
) {
1804 int myrow
, mycol
, mytype
;
1810 } search
[(2*BB_WIDTH
-1)*(BB_HEIGHT
/2)];
1812 /* search initial bubble */
1813 bb
->playboard
[row
][col
].ingroup
= true;
1814 search
[count
].row
= row
;
1815 search
[count
].col
= col
;
1818 /* breadth-first search neighbors */
1819 for(i
=0; i
<count
; i
++) {
1820 myrow
= search
[i
].row
;
1821 mycol
= search
[i
].col
;
1822 mytype
= bb
->playboard
[myrow
][mycol
].type
;
1826 if(bb
->playboard
[myrow
][mycol
-1].type
== mytype
&&
1827 !bb
->playboard
[myrow
][mycol
-1].ingroup
) {
1828 bb
->playboard
[myrow
][mycol
-1].ingroup
= true;
1829 search
[count
].row
= myrow
;
1830 search
[count
].col
= mycol
-1;
1835 if(mycol
-1+adj
>= 0) {
1837 if(bb
->playboard
[myrow
-1][mycol
-1+adj
].type
== mytype
&&
1838 !bb
->playboard
[myrow
-1][mycol
-1+adj
].ingroup
) {
1839 bb
->playboard
[myrow
-1][mycol
-1+adj
].ingroup
= true;
1840 search
[count
].row
= myrow
-1;
1841 search
[count
].col
= mycol
-1+adj
;
1846 if(myrow
+1 < BB_HEIGHT
) {
1847 if(bb
->playboard
[myrow
+1][mycol
-1+adj
].type
== mytype
&&
1848 !bb
->playboard
[myrow
+1][mycol
-1+adj
].ingroup
) {
1849 bb
->playboard
[myrow
+1][mycol
-1+adj
].ingroup
= true;
1850 search
[count
].row
= myrow
+1;
1851 search
[count
].col
= mycol
-1+adj
;
1857 if(mycol
+adj
>= 0) {
1859 if(bb
->playboard
[myrow
-1][mycol
+adj
].type
== mytype
&&
1860 !bb
->playboard
[myrow
-1][mycol
+adj
].ingroup
) {
1861 bb
->playboard
[myrow
-1][mycol
+adj
].ingroup
= true;
1862 search
[count
].row
= myrow
-1;
1863 search
[count
].col
= mycol
+adj
;
1868 if(myrow
+1 < BB_HEIGHT
) {
1869 if(bb
->playboard
[myrow
+1][mycol
+adj
].type
== mytype
&&
1870 !bb
->playboard
[myrow
+1][mycol
+adj
].ingroup
) {
1871 bb
->playboard
[myrow
+1][mycol
+adj
].ingroup
= true;
1872 search
[count
].row
= myrow
+1;
1873 search
[count
].col
= mycol
+adj
;
1879 if(mycol
+1 < BB_WIDTH
-adj
) {
1880 if(bb
->playboard
[myrow
][mycol
+1].type
== mytype
&&
1881 !bb
->playboard
[myrow
][mycol
+1].ingroup
) {
1882 bb
->playboard
[myrow
][mycol
+1].ingroup
= true;
1883 search
[count
].row
= myrow
;
1884 search
[count
].col
= mycol
+1;
1893 /*****************************************************************************
1894 * bubbles_remove() removes all bubbles in the current group and all
1895 * unanchored bubbles from the play board.
1896 ******************************************************************************/
1897 static int bubbles_remove(struct game_context
* bb
) {
1901 /* determine all anchored bubbles */
1902 for(j
=0; j
<BB_WIDTH
; j
++) {
1903 if(bb
->playboard
[0][j
].type
>= 0 && !bb
->playboard
[0][j
].ingroup
) {
1904 bubbles_anchored(bb
, 0, j
);
1908 /* mark bubbles to be deleted */
1909 for(i
=0; i
<BB_HEIGHT
; i
++) {
1910 for(j
=0; j
<BB_WIDTH
; j
++) {
1911 if(bb
->playboard
[i
][j
].type
>= 0 &&
1912 (!bb
->playboard
[i
][j
].anchored
|| bb
->playboard
[i
][j
].ingroup
)) {
1913 bb
->playboard
[i
][j
].delete = true;
1918 /* animate falling bubbles */
1919 buttonres
= bubbles_fall(bb
);
1920 if(buttonres
!= BB_NONE
) return buttonres
;
1922 /* remove bubbles */
1923 for(i
=0; i
<BB_HEIGHT
; i
++) {
1924 for(j
=0; j
<BB_WIDTH
; j
++) {
1925 if(bb
->playboard
[i
][j
].delete) {
1926 bb
->playboard
[i
][j
].ingroup
= false;
1927 bb
->playboard
[i
][j
].type
= -1;
1928 bb
->playboard
[i
][j
].delete = false;
1930 bb
->playboard
[i
][j
].anchored
= false;
1935 bubbles_getonboard(bb
);
1940 /*****************************************************************************
1941 * bubbles_anchored() marks all bubbles that are anchored in some way to the
1943 ******************************************************************************/
1944 static void bubbles_anchored(struct game_context
* bb
, int row
, int col
) {
1946 int myrow
, mycol
, mytype
;
1952 } search
[(2*BB_WIDTH
-1)*(BB_HEIGHT
/2)];
1954 /* search initial bubble */
1955 bb
->playboard
[row
][col
].anchored
= true;
1956 search
[count
].row
= row
;
1957 search
[count
].col
= col
;
1960 /* breadth-first search neighbors */
1961 for(i
=0; i
<count
; i
++) {
1962 myrow
= search
[i
].row
;
1963 mycol
= search
[i
].col
;
1964 mytype
= bb
->playboard
[myrow
][mycol
].type
;
1968 if(bb
->playboard
[myrow
][mycol
-1].type
>= 0 &&
1969 !bb
->playboard
[myrow
][mycol
-1].ingroup
&&
1970 !bb
->playboard
[myrow
][mycol
-1].anchored
) {
1971 bb
->playboard
[myrow
][mycol
-1].anchored
= true;
1972 search
[count
].row
= myrow
;
1973 search
[count
].col
= mycol
-1;
1978 if(mycol
-1+adj
>= 0) {
1980 if(bb
->playboard
[myrow
-1][mycol
-1+adj
].type
>= 0 &&
1981 !bb
->playboard
[myrow
-1][mycol
-1+adj
].ingroup
&&
1982 !bb
->playboard
[myrow
-1][mycol
-1+adj
].anchored
) {
1983 bb
->playboard
[myrow
-1][mycol
-1+adj
].anchored
= true;
1984 search
[count
].row
= myrow
-1;
1985 search
[count
].col
= mycol
-1+adj
;
1990 if(myrow
+1 < BB_HEIGHT
) {
1991 if(bb
->playboard
[myrow
+1][mycol
-1+adj
].type
>= 0 &&
1992 !bb
->playboard
[myrow
+1][mycol
-1+adj
].ingroup
&&
1993 !bb
->playboard
[myrow
+1][mycol
-1+adj
].anchored
) {
1994 bb
->playboard
[myrow
+1][mycol
-1+adj
].anchored
= true;
1995 search
[count
].row
= myrow
+1;
1996 search
[count
].col
= mycol
-1+adj
;
2002 if(mycol
+adj
>= 0) {
2004 if(bb
->playboard
[myrow
-1][mycol
+adj
].type
>= 0 &&
2005 !bb
->playboard
[myrow
-1][mycol
+adj
].ingroup
&&
2006 !bb
->playboard
[myrow
-1][mycol
+adj
].anchored
) {
2007 bb
->playboard
[myrow
-1][mycol
+adj
].anchored
= true;
2008 search
[count
].row
= myrow
-1;
2009 search
[count
].col
= mycol
+adj
;
2014 if(myrow
+1 < BB_HEIGHT
) {
2015 if(bb
->playboard
[myrow
+1][mycol
+adj
].type
>= 0 &&
2016 !bb
->playboard
[myrow
+1][mycol
+adj
].ingroup
&&
2017 !bb
->playboard
[myrow
+1][mycol
+adj
].anchored
) {
2018 bb
->playboard
[myrow
+1][mycol
+adj
].anchored
= true;
2019 search
[count
].row
= myrow
+1;
2020 search
[count
].col
= mycol
+adj
;
2026 if(mycol
+1 < BB_WIDTH
-adj
) {
2027 if(bb
->playboard
[myrow
][mycol
+1].type
>= 0 &&
2028 !bb
->playboard
[myrow
][mycol
+1].ingroup
&&
2029 !bb
->playboard
[myrow
][mycol
+1].anchored
) {
2030 bb
->playboard
[myrow
][mycol
+1].anchored
= true;
2031 search
[count
].row
= myrow
;
2032 search
[count
].col
= mycol
+1;
2039 /*****************************************************************************
2040 * bubbles_fall() makes removed bubbles fall from the screen.
2041 ******************************************************************************/
2042 static int bubbles_fall(struct game_context
* bb
) {
2049 long lasttick
, currenttick
;
2051 /* give all falling bubbles an x axis movement */
2052 for(i
=0; i
<BB_HEIGHT
; i
++) {
2053 for(j
=0; j
<BB_WIDTH
; j
++) {
2054 if(bb
->playboard
[i
][j
].delete) {
2055 bb
->playboard
[i
][j
].fallx
= rb
->rand()%25 - 12;
2056 bb
->playboard
[i
][j
].fallvel
= rb
->rand()%5 + 6;
2061 /* draw bubbles falling off the screen
2062 * follows y=x^2-8x scaled to bubble size
2064 lasttick
= *rb
->current_tick
;
2066 for(count
=1; ;count
++) {
2068 bubbles_drawboard(bb
);
2070 for(i
=0; i
<BB_HEIGHT
; i
++) {
2071 for(j
=0; j
<BB_WIDTH
; j
++) {
2072 if(bb
->playboard
[i
][j
].delete) {
2073 indent
= (i
%2 ? ROW_INDENT
: 0);
2074 xofs
= ((bb
->playboard
[i
][j
].fallx
*count
)*BUBBLE_WIDTH
)/48;
2075 yofs
= ((count
*count
- bb
->playboard
[i
][j
].fallvel
*count
)*
2078 /* draw bubble if it is still on the screen */
2079 if(YOFS
+ROW_HEIGHT
*i
+bb
->compress
*ROW_HEIGHT
+yofs
2083 rb
->lcd_bitmap_part(bubbles_emblem
, 0,
2084 EMBLEM_HEIGHT
*bb
->playboard
[i
][j
].type
,
2085 STRIDE( SCREEN_MAIN
,
2086 BMPWIDTH_bubbles_emblem
,
2087 BMPHEIGHT_bubbles_emblem
),
2088 XOFS
+indent
+BUBBLE_WIDTH
*j
+
2089 (BUBBLE_WIDTH
-EMBLEM_WIDTH
)/2+xofs
,
2090 YOFS
+ROW_HEIGHT
*i
+(BUBBLE_HEIGHT
-EMBLEM_HEIGHT
)/2+
2091 bb
->compress
*ROW_HEIGHT
+yofs
,
2092 EMBLEM_WIDTH
, EMBLEM_HEIGHT
);
2093 rb
->lcd_set_drawmode(DRMODE_FG
);
2094 rb
->lcd_mono_bitmap(
2095 (const unsigned char *)bubbles_bubble
,
2096 XOFS
+indent
+BUBBLE_WIDTH
*j
+xofs
,
2097 YOFS
+ROW_HEIGHT
*i
+bb
->compress
*ROW_HEIGHT
+yofs
,
2098 BUBBLE_WIDTH
, BUBBLE_HEIGHT
);
2099 rb
->lcd_set_drawmode(DRMODE_SOLID
);
2107 /* break out if all bubbles are off the screen */
2108 if(!onscreen
) break;
2110 /* handle button events */
2111 buttonres
= bubbles_handlebuttons(bb
, true, 0);
2112 if(buttonres
!= BB_NONE
) return buttonres
;
2114 /* framerate limiting */
2115 currenttick
= *rb
->current_tick
;
2116 if(currenttick
-lasttick
< HZ
/MAX_FPS
) {
2117 rb
->sleep((HZ
/MAX_FPS
)-(currenttick
-lasttick
));
2121 lasttick
= currenttick
;
2127 /*****************************************************************************
2128 * bubbles_checklevel() checks the state of the playboard for a win or loss.
2129 ******************************************************************************/
2130 static int bubbles_checklevel(struct game_context
* bb
) {
2135 bubbles_drawboard(bb
);
2138 /* check for bubbles below cut off point */
2139 for(i
=0; i
<=bb
->compress
; i
++) {
2140 for(j
=0; j
<BB_WIDTH
; j
++) {
2141 if(bb
->playboard
[BB_HEIGHT
-1-i
][j
].type
>= 0) return BB_LOSE
;
2145 /* check for bubbles above cut off point */
2146 for(i
=0; i
<BB_HEIGHT
-1-bb
->compress
; i
++) {
2147 for(j
=0; j
<BB_WIDTH
; j
++) {
2148 if(bb
->playboard
[i
][j
].type
>= 0) return BB_NONE
;
2152 /* level complete, record score */
2153 points
= 100 - bb
->elapsedlvl
/100;
2155 bb
->score
+= points
;
2160 rb
->snprintf(str
, 12, "%d points", points
);
2161 rb
->splash(HZ
, str
);
2163 /* advance to the next level */
2164 if(!bubbles_nextlevel(bb
)) {
2168 bubbles_drawboard(bb
);
2170 rb
->snprintf(str
, 12, "Level %d", bb
->level
);
2171 rb
->splash(HZ
, str
);
2172 bubbles_drawboard(bb
);
2178 /*****************************************************************************
2179 * bubbles_recordscore() inserts a high score into the high scores list and
2180 * returns the high score position.
2181 ******************************************************************************/
2182 static void bubbles_recordscore(struct game_context
* bb
) {
2186 position
= highscore_update(bb
->score
, bb
->level
-1, "",
2187 highscores
, NUM_SCORES
);
2191 rb
->splash(HZ
*2, "New High Score");
2192 highscore_show(position
, highscores
, NUM_SCORES
, true);
2196 /*****************************************************************************
2197 * bubbles_loaddata() loads highest level beaten.
2198 ******************************************************************************/
2199 static void bubbles_loaddata(void) {
2202 last_highlevel
= highlevel
= 0;
2203 /* open data file */
2204 fd
= rb
->open(DATA_FILE
, O_RDONLY
);
2207 /* read in saved game */
2208 if (rb
->read(fd
, &highlevel
, sizeof(highlevel
)) < (long)sizeof(highlevel
))
2212 if (highlevel
>= NUM_LEVELS
)
2213 highlevel
= NUM_LEVELS
-1;
2214 last_highlevel
= highlevel
;
2219 /*****************************************************************************
2220 * bubbles_savedata() saves the current game state.
2221 ******************************************************************************/
2222 static void bubbles_savedata(void) {
2225 if (last_highlevel
>= highlevel
) /* no need to save */
2228 fd
= rb
->open(DATA_FILE
, O_WRONLY
|O_CREAT
, 0666);
2231 rb
->write(fd
, &highlevel
, sizeof(highlevel
));
2236 /*****************************************************************************
2237 * bubbles_loadgame() loads the saved game and returns load success.
2238 ******************************************************************************/
2239 static bool bubbles_loadgame(struct game_context
* bb
) {
2243 /* open game file */
2244 fd
= rb
->open(SAVE_FILE
, O_RDONLY
);
2245 if(fd
< 0) return false;
2247 /* read in saved game */
2248 if(rb
->read(fd
, bb
, sizeof(struct game_context
))
2249 < (long)sizeof(struct game_context
))
2259 /*****************************************************************************
2260 * bubbles_savegame() saves the current game state.
2261 ******************************************************************************/
2262 static void bubbles_savegame(struct game_context
* bb
) {
2265 if (!resume
) /* nothing to save */
2267 /* write out the game state to the save file */
2268 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
, 0666);
2271 rb
->splash(HZ
/2, "Failed to save game");
2274 if (rb
->write(fd
, bb
, sizeof(struct game_context
)) <= 0)
2276 rb
->splash(HZ
/2, "Failed to save game");
2282 /*****************************************************************************
2283 * bubbles_setcolors() set the foreground and background colors.
2284 ******************************************************************************/
2285 static inline void bubbles_setcolors(void) {
2286 #ifdef HAVE_LCD_COLOR
2287 rb
->lcd_set_background(LCD_RGBPACK(181,181,222));
2288 rb
->lcd_set_foreground(LCD_BLACK
);
2292 /*****************************************************************************
2293 * bubbles_callback() is the default event handler callback which is called
2294 * on usb connect and shutdown.
2295 ******************************************************************************/
2296 static void bubbles_callback(void* param
) {
2298 highscore_save(SCORE_FILE
, highscores
, NUM_SCORES
);
2301 /*****************************************************************************
2302 * bubbles_handlebuttons() handles button events during a game.
2303 ******************************************************************************/
2304 static int bubbles_handlebuttons(struct game_context
* bb
, bool animblock
,
2309 const struct button_mapping
*plugin_contexts
[]
2311 #ifdef HAVE_REMOTE_LCD
2318 button
= pluginlib_getaction(timeout
,plugin_contexts
,ARRAYLEN(plugin_contexts
));
2319 #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
2320 /* FIXME: Should probably check remote hold here */
2321 if (rb
->button_hold())
2322 button
= BUBBLES_PAUSE
;
2326 case BUBBLES_LEFT_REP
:
2327 if(bb
->angle
> MIN_ANGLE
) bb
->angle
-= ANGLE_STEP_REP
;
2328 case BUBBLES_LEFT
: /* change angle to the left */
2329 if(bb
->angle
> MIN_ANGLE
) bb
->angle
-= ANGLE_STEP
;
2332 case BUBBLES_RIGHT_REP
:
2333 if(bb
->angle
< MAX_ANGLE
) bb
->angle
+= ANGLE_STEP_REP
;
2334 case BUBBLES_RIGHT
: /* change angle to the right */
2335 if(bb
->angle
< MAX_ANGLE
) bb
->angle
+= ANGLE_STEP
;
2338 case BUBBLES_FIRE
: /* fire the shot */
2339 case BUBBLES_FIRE_REPEAT
:
2341 bb
->elapsedlvl
+= bb
->elapsedshot
;
2342 bb
->elapsedshot
= 0;
2343 buttonres
= bubbles_fire(bb
);
2344 if(buttonres
!= BB_NONE
) return buttonres
;
2345 buttonres
= bubbles_checklevel(bb
);
2346 if(buttonres
!= BB_NONE
) return buttonres
;
2347 bb
->startedshot
= *rb
->current_tick
;
2351 case BUBBLES_PAUSE
: /* pause the game */
2352 start
= *rb
->current_tick
;
2353 rb
->splash(0, "Paused");
2355 while(pluginlib_getaction(TIMEOUT_BLOCK
,plugin_contexts
,
2356 ARRAYLEN(plugin_contexts
))
2358 bb
->startedshot
+= *rb
->current_tick
-start
;
2359 bubbles_drawboard(bb
);
2364 case BUBBLES_QUIT2
: /* end the game */
2371 case ACTION_UNKNOWN
:
2372 case ACTION_NONE
: /* no button pressed */
2376 if(rb
->default_event_handler_ex(button
, bubbles_callback
,
2377 (void*) bb
) == SYS_USB_CONNECTED
)
2385 static int bubbles_menu_cb(int action
, const struct menu_item_ex
*this_item
)
2387 int i
= ((intptr_t)this_item
);
2388 if(action
== ACTION_REQUEST_MENUITEM
2389 && !resume
&& (i
==0))
2390 return ACTION_EXIT_MENUITEM
;
2394 /*****************************************************************************
2395 * bubbles_menu() is the initial menu at the start of the game.
2396 ******************************************************************************/
2397 static int bubbles_menu(struct game_context
* bb
) {
2398 static unsigned int startlevel
= 0;
2400 bool startgame
= false;
2402 MENUITEM_STRINGLIST(menu
,"Bubbles Menu",bubbles_menu_cb
,
2403 "Resume Game", "Start New Game",
2404 "Level", "High Scores", "Playback Control",
2405 "Quit without Saving", "Quit");
2408 switch (rb
->do_menu(&menu
, &selected
, NULL
, false))
2410 case 0: /* resume game */
2413 rb
->remove(SAVE_FILE
);
2414 resume_file
= false;
2416 case 1: /* new game */
2417 bb
->level
= startlevel
;
2420 resume_file
= false;
2422 case 2: /* choose level */
2424 rb
->set_int("Choose start level", "", UNIT_INT
, &startlevel
,
2425 NULL
, 1, 1, highlevel
+1, NULL
);
2428 case 3: /* High scores */
2429 highscore_show(-1, highscores
, NUM_SCORES
, true);
2431 case 4: /* Playback Control */
2432 playback_control(NULL
);
2434 case 5: /* quit but don't save */
2435 return BB_QUIT_WITHOUT_SAVING
;
2436 case 6: /* save and quit */
2438 case MENU_ATTACHED_USB
:
2439 bubbles_callback(bb
);
2446 /*****************************************************************************
2447 * bubbles() is the main game subroutine, it returns the final game status.
2448 ******************************************************************************/
2449 static int bubbles(struct game_context
* bb
) {
2453 /********************
2455 ********************/
2456 buttonres
= bubbles_menu(bb
);
2460 /********************
2462 ********************/
2464 bubbles_drawboard(bb
);
2467 /**********************
2469 **********************/
2470 bb
->startedshot
= *rb
->current_tick
;
2473 /* refresh the board */
2474 bubbles_drawboard(bb
);
2477 /* manange idle framerate */
2478 bb
->elapsedshot
= *rb
->current_tick
-bb
->startedshot
;
2480 if(MAX_SHOTTIME
-bb
->elapsedshot
< HZ
/2) {
2481 timeout
= MAX_SHOTTIME
-bb
->elapsedshot
;
2486 /* handle button events */
2487 buttonres
= bubbles_handlebuttons(bb
, false, timeout
);
2488 if(buttonres
!= BB_NONE
) return buttonres
;
2491 bb
->elapsedshot
= *rb
->current_tick
-bb
->startedshot
;
2493 if(bb
->elapsedshot
> MAX_SHOTTIME
) {
2494 bb
->elapsedlvl
+= bb
->elapsedshot
;
2495 bb
->elapsedshot
= 0;
2496 buttonres
= bubbles_fire(bb
);
2497 if(buttonres
!= BB_NONE
) return buttonres
;
2498 buttonres
= bubbles_checklevel(bb
);
2499 if(buttonres
!= BB_NONE
) return buttonres
;
2500 bb
->startedshot
= *rb
->current_tick
;
2505 /*****************************************************************************
2506 * plugin entry point.
2507 ******************************************************************************/
2508 enum plugin_status
plugin_start(const void* parameter
) {
2509 static struct game_context bb
;
2511 enum plugin_status ret
= PLUGIN_OK
;
2516 resume
= bubbles_loadgame(&bb
);
2517 resume_file
= resume
;
2519 highscore_load(SCORE_FILE
, highscores
, NUM_SCORES
);
2520 rb
->lcd_clear_display();
2524 rb
->lcd_set_backdrop(NULL
);
2526 rb
->lcd_setfont(FONT_SYSFIXED
);
2529 switch(bubbles(&bb
)){
2531 rb
->splash(HZ
*2, "You Win!");
2532 /* record high level */
2533 highlevel
= NUM_LEVELS
-1;
2534 /* record high score */
2535 bubbles_recordscore(&bb
);
2540 rb
->splash(HZ
*2, "Game Over");
2541 /* record high score */
2542 bubbles_recordscore(&bb
);
2543 /* fall through to BB_END */
2549 ret
= PLUGIN_USB_CONNECTED
;
2554 rb
->splash(HZ
/3, "Saving game data ...");
2555 bubbles_savegame(&bb
);
2557 highscore_save(SCORE_FILE
, highscores
, NUM_SCORES
);
2560 case BB_QUIT_WITHOUT_SAVING
:
2568 rb
->lcd_setfont(FONT_UI
);