diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/robotfindskitten.c | 87 |
1 files changed, 40 insertions, 47 deletions
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index e08c99c0cc..8100cd8520 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c | |||
@@ -411,7 +411,8 @@ static void play_animation(int input) | |||
411 | 411 | ||
412 | static void instructions() | 412 | static void instructions() |
413 | { | 413 | { |
414 | unsigned short row = 0, col = 0, len = 0, i = 0; | 414 | int y, space_w, width, height; |
415 | unsigned short x = 0, i = 0; | ||
415 | #define WORDS (sizeof instructions / sizeof (char*)) | 416 | #define WORDS (sizeof instructions / sizeof (char*)) |
416 | static char* instructions[] = { | 417 | static char* instructions[] = { |
417 | #if 0 | 418 | #if 0 |
@@ -424,27 +425,30 @@ static void instructions() | |||
424 | "The", "game", "ends", "when", "robotfindskitten.", "", "", | 425 | "The", "game", "ends", "when", "robotfindskitten.", "", "", |
425 | "Press", "any", "key", "to", "start", | 426 | "Press", "any", "key", "to", "start", |
426 | }; | 427 | }; |
428 | rb->lcd_clear_display(); | ||
429 | rb->lcd_getstringsize(" ", &space_w, &height); | ||
430 | y = 0; | ||
427 | for (i = 0; i < WORDS; i++) { | 431 | for (i = 0; i < WORDS; i++) { |
428 | len = rb->strlen(instructions[i]); | 432 | rb->lcd_getstringsize(instructions[i], &width, NULL); |
429 | /* Skip to next line if the current one can't fit the word */ | 433 | /* Skip to next line if the current one can't fit the word */ |
430 | if (col+len > X_MAX) { | 434 | if (x + width > LCD_WIDTH) { |
431 | col = 0; | 435 | x = 0; |
432 | row++; | 436 | y += height; |
433 | } | 437 | } |
434 | /* .. or if the word is the empty string */ | 438 | /* .. or if the word is the empty string */ |
435 | if (rb->strcmp(instructions[i], "") == 0) { | 439 | if (rb->strcmp(instructions[i], "") == 0) { |
436 | col = 0; | 440 | x = 0; |
437 | row++; | 441 | y += height; |
438 | continue; | 442 | continue; |
439 | } | 443 | } |
440 | /* We filled the screen */ | 444 | /* We filled the screen */ |
441 | if (row > Y_MAX) { | 445 | if (y + height > LCD_HEIGHT) { |
442 | row = 0; | 446 | y = 0; |
443 | pause(); | 447 | pause(); |
444 | rb->lcd_clear_display(); | 448 | rb->lcd_clear_display(); |
445 | } | 449 | } |
446 | rb->lcd_putsxy(SYSFONT_WIDTH*col, row*SYSFONT_HEIGHT, instructions[i]); | 450 | rb->lcd_putsxy(x, y, instructions[i]); |
447 | col += len + 1; | 451 | x += width + space_w; |
448 | } | 452 | } |
449 | pause(); | 453 | pause(); |
450 | } | 454 | } |
@@ -559,15 +563,6 @@ static void initialize_screen() | |||
559 | char buf[40]; | 563 | char buf[40]; |
560 | 564 | ||
561 | /* | 565 | /* |
562 | * Set up white-on-black screen on color targets | ||
563 | */ | ||
564 | #if LCD_DEPTH >= 16 | ||
565 | rb->lcd_set_backdrop(NULL); | ||
566 | rb->lcd_set_foreground(LCD_WHITE); | ||
567 | rb->lcd_set_background(LCD_BLACK); | ||
568 | #endif | ||
569 | |||
570 | /* | ||
571 | *Print the status portion of the screen. | 566 | *Print the status portion of the screen. |
572 | */ | 567 | */ |
573 | rb->lcd_clear_display(); | 568 | rb->lcd_clear_display(); |
@@ -600,42 +595,40 @@ static void initialize_screen() | |||
600 | /* this is the plugin entry point */ | 595 | /* this is the plugin entry point */ |
601 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 596 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
602 | { | 597 | { |
603 | (void)parameter; | 598 | (void)parameter; |
604 | rb = api; | 599 | rb = api; |
605 | 600 | ||
606 | exit_rfk = false; | 601 | exit_rfk = false; |
607 | 602 | ||
608 | rb->srand(*rb->current_tick); | 603 | rb->srand(*rb->current_tick); |
609 | 604 | ||
610 | initialize_arrays(); | 605 | initialize_arrays(); |
611 | 606 | ||
612 | /* | 607 | /* |
613 | * Now we initialize the various game objects. | 608 | * Now we initialize the various game objects. |
614 | */ | 609 | */ |
615 | initialize_robot(); | 610 | initialize_robot(); |
616 | initialize_kitten(); | 611 | initialize_kitten(); |
617 | initialize_bogus(); | 612 | initialize_bogus(); |
618 | 613 | ||
619 | /* | 614 | /* |
620 | * Set up white-on-black screen on color targets | 615 | * Set up white-on-black screen on color targets |
621 | */ | 616 | */ |
622 | #if LCD_DEPTH >= 16 | 617 | #if LCD_DEPTH >= 16 |
623 | rb->lcd_set_backdrop(NULL); | 618 | rb->lcd_set_backdrop(NULL); |
624 | rb->lcd_set_foreground(LCD_WHITE); | 619 | rb->lcd_set_foreground(LCD_WHITE); |
625 | rb->lcd_set_background(LCD_BLACK); | 620 | rb->lcd_set_background(LCD_BLACK); |
626 | #endif | 621 | #endif |
627 | rb->lcd_clear_display(); | ||
628 | rb->lcd_setfont(FONT_SYSFIXED); | ||
629 | 622 | ||
630 | /* | 623 | /* |
631 | * Run the game | 624 | * Run the game |
632 | */ | 625 | */ |
633 | instructions(); | 626 | instructions(); |
634 | 627 | ||
635 | initialize_screen(); | 628 | initialize_screen(); |
636 | 629 | ||
637 | play_game(); | 630 | play_game(); |
638 | 631 | ||
639 | rb->lcd_setfont(FONT_UI); | 632 | rb->lcd_setfont(FONT_UI); |
640 | return PLUGIN_OK; | 633 | return PLUGIN_OK; |
641 | } | 634 | } |