summaryrefslogtreecommitdiff
path: root/apps/plugins/jewels.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/jewels.c')
-rw-r--r--apps/plugins/jewels.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index 725c036800..6c436cfb24 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -608,13 +608,6 @@ static void jewels_drawboard(struct game_context* bj) {
608 (LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2, 608 (LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2,
609 ((LCD_HEIGHT-10)-18)*tempscore/size+1); 609 ((LCD_HEIGHT-10)-18)*tempscore/size+1);
610#endif 610#endif
611
612 if (bj->type == GAME_TYPE_NORMAL) {
613 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score);
614 rb->lcd_getstringsize(str, &w, &h);
615 rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2,
616 LCD_HEIGHT-8, str);
617 }
618 611
619 /* print text */ 612 /* print text */
620 rb->lcd_getstringsize(title, &w, &h); 613 rb->lcd_getstringsize(title, &w, &h);
@@ -623,6 +616,12 @@ static void jewels_drawboard(struct game_context* bj) {
623 rb->lcd_getstringsize(str, &w, &h); 616 rb->lcd_getstringsize(str, &w, &h);
624 rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 10, str); 617 rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2, 10, str);
625 618
619 if (bj->type == GAME_TYPE_NORMAL) {
620 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score);
621 rb->lcd_getstringsize(str, &w, &h);
622 rb->lcd_putsxy(LCD_WIDTH-(LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2-w/2,
623 LCD_HEIGHT-8, str);
624 }
626 625
627#elif LCD_WIDTH < LCD_HEIGHT /* vertical layout */ 626#elif LCD_WIDTH < LCD_HEIGHT /* vertical layout */
628 627
@@ -653,15 +652,15 @@ static void jewels_drawboard(struct game_context* bj) {
653 (LCD_HEIGHT-14-(8*TILE_HEIGHT+YOFS))/2); 652 (LCD_HEIGHT-14-(8*TILE_HEIGHT+YOFS))/2);
654#endif 653#endif
655 654
655 /* print text */
656 rb->snprintf(str, 10, "%s %d", title, bj->level);
657 rb->lcd_putsxy(1, LCD_HEIGHT-10, str);
658
656 if (bj->type == GAME_TYPE_NORMAL) { 659 if (bj->type == GAME_TYPE_NORMAL) {
657 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); 660 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score);
658 rb->lcd_getstringsize(str, &w, &h); 661 rb->lcd_getstringsize(str, &w, &h);
659 rb->lcd_putsxy((LCD_WIDTH-2)-w, LCD_HEIGHT-10, str); 662 rb->lcd_putsxy((LCD_WIDTH-2)-w, LCD_HEIGHT-10, str);
660 } 663 }
661
662 /* print text */
663 rb->snprintf(str, 10, "%s %d", title, bj->level);
664 rb->lcd_putsxy(1, LCD_HEIGHT-10, str);
665 664
666 665
667#else /* square layout */ 666#else /* square layout */
@@ -694,6 +693,10 @@ static void jewels_drawboard(struct game_context* bj) {
694 (LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2, 693 (LCD_WIDTH-BJ_WIDTH*TILE_WIDTH)/2,
695 (8*TILE_HEIGHT+YOFS)*tempscore/size+1); 694 (8*TILE_HEIGHT+YOFS)*tempscore/size+1);
696#endif 695#endif
696
697 /* print text */
698 rb->snprintf(str, 10, "%s %d", title, bj->level);
699 rb->lcd_putsxy(1, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str);
697 700
698 if (bj->type == GAME_TYPE_NORMAL) { 701 if (bj->type == GAME_TYPE_NORMAL) {
699 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score); 702 rb->snprintf(str, 6, "%d", (bj->level-1)*LEVEL_PTS+bj->score);
@@ -702,10 +705,6 @@ static void jewels_drawboard(struct game_context* bj) {
702 LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str); 705 LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str);
703 } 706 }
704 707
705 /* print text */
706 rb->snprintf(str, 10, "%s %d", title, bj->level);
707 rb->lcd_putsxy(1, LCD_HEIGHT-(LCD_HEIGHT-(8*TILE_HEIGHT+YOFS))/2-3, str);
708
709#endif /* layout */ 708#endif /* layout */
710 709
711 rb->lcd_update(); 710 rb->lcd_update();
@@ -1363,7 +1362,7 @@ static void jewels_show_highscores(int position)
1363 rb->lcd_setfont(FONT_SYSFIXED); 1362 rb->lcd_setfont(FONT_SYSFIXED);
1364} 1363}
1365 1364
1366static int jewels_help(void) 1365static bool jewels_help(void)
1367{ 1366{
1368 rb->lcd_setfont(FONT_UI); 1367 rb->lcd_setfont(FONT_UI);
1369#define WORDS (sizeof help_text / sizeof (char*)) 1368#define WORDS (sizeof help_text / sizeof (char*))
@@ -1387,26 +1386,27 @@ static int jewels_help(void)
1387 static struct style_text formation[]={ 1386 static struct style_text formation[]={
1388 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1387 { 0, TEXT_CENTER|TEXT_UNDERLINE },
1389 { 2, C_RED }, 1388 { 2, C_RED },
1389 { 42, C_RED },
1390 { -1, 0 } 1390 { -1, 0 }
1391 }; 1391 };
1392 int button;
1392 1393
1393#ifdef HAVE_LCD_COLOR 1394#ifdef HAVE_LCD_COLOR
1394 rb->lcd_set_background(LCD_BLACK); 1395 rb->lcd_set_background(LCD_BLACK);
1395 rb->lcd_set_foreground(LCD_WHITE); 1396 rb->lcd_set_foreground(LCD_WHITE);
1396#endif 1397#endif
1397 if (display_text(WORDS, help_text, formation, NULL)==PLUGIN_USB_CONNECTED) 1398 if (display_text(WORDS, help_text, formation, NULL))
1398 return PLUGIN_USB_CONNECTED; 1399 return true;
1399 int button;
1400 do { 1400 do {
1401 button = rb->button_get(true); 1401 button = rb->button_get(true);
1402 if (button == SYS_USB_CONNECTED) { 1402 if (rb->default_event_handler (button) == SYS_USB_CONNECTED) {
1403 return PLUGIN_USB_CONNECTED; 1403 return true;
1404 } 1404 }
1405 } while( ( button == BUTTON_NONE ) 1405 } while( ( button == BUTTON_NONE )
1406 || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1406 || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
1407 rb->lcd_setfont(FONT_SYSFIXED); 1407 rb->lcd_setfont(FONT_SYSFIXED);
1408 1408
1409 return 0; 1409 return false;
1410} 1410}
1411 1411
1412static bool _ingame; 1412static bool _ingame;
@@ -1440,7 +1440,7 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
1440 "Help", 1440 "Help",
1441 "High Score", 1441 "High Score",
1442 "Playback Control", 1442 "Playback Control",
1443 "Save and Quit", 1443 "Quit without Saving",
1444 "Quit"); 1444 "Quit");
1445 1445
1446 while (1) { 1446 while (1) {
@@ -1455,7 +1455,8 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
1455 rb->set_option("Mode", &bj->tmp_type, INT, mode, 2, NULL); 1455 rb->set_option("Mode", &bj->tmp_type, INT, mode, 2, NULL);
1456 break; 1456 break;
1457 case 3: 1457 case 3:
1458 jewels_help(); 1458 if(jewels_help())
1459 return 1;
1459 break; 1460 break;
1460 case 4: 1461 case 4:
1461 jewels_show_highscores(NUM_SCORES); 1462 jewels_show_highscores(NUM_SCORES);
@@ -1464,13 +1465,13 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
1464 playback_control(NULL); 1465 playback_control(NULL);
1465 break; 1466 break;
1466 case 6: 1467 case 6:
1468 return 1;
1469 case 7:
1467 if (ingame) { 1470 if (ingame) {
1468 rb->splash(HZ*1, "Saving game ..."); 1471 rb->splash(HZ*1, "Saving game ...");
1469 jewels_savegame(bj); 1472 jewels_savegame(bj);
1470 } 1473 }
1471 return 1; 1474 return 1;
1472 case 7:
1473 return 1;
1474 case MENU_ATTACHED_USB: 1475 case MENU_ATTACHED_USB:
1475 return 1; 1476 return 1;
1476 default: 1477 default:
@@ -1622,6 +1623,7 @@ static int jewels_main(struct game_context* bj) {
1622 case GAME_TYPE_NORMAL: 1623 case GAME_TYPE_NORMAL:
1623 rb->splash(HZ*2, "Game Over!"); 1624 rb->splash(HZ*2, "Game Over!");
1624 rb->lcd_clear_display(); 1625 rb->lcd_clear_display();
1626 bj->score += (bj->level-1)*LEVEL_PTS;
1625 if (highscore_would_update(bj->score, highest, 1627 if (highscore_would_update(bj->score, highest,
1626 NUM_SCORES)) { 1628 NUM_SCORES)) {
1627 position=highscore_update(bj->score, 1629 position=highscore_update(bj->score,