diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/chessbox/chessbox.c | 159 | ||||
-rw-r--r-- | apps/plugins/chessbox/chessbox_pgn.c | 54 | ||||
-rw-r--r-- | apps/plugins/chessbox/gnuchess.c | 4 |
3 files changed, 182 insertions, 35 deletions
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index c7cd94c7e1..52a1f2789b 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c | |||
@@ -78,16 +78,16 @@ extern const fb_data chessbox_pieces[]; | |||
78 | short plugin_mode; | 78 | short plugin_mode; |
79 | 79 | ||
80 | /* level+1's string */ | 80 | /* level+1's string */ |
81 | const char *level_string[] = { "Level 1: 60 moves / 5 min" , | 81 | const char *level_string[] = { ID2P(LANG_CHESSBOX_LEVEL_1) , |
82 | "Level 2: 60 moves / 15 min" , | 82 | ID2P(LANG_CHESSBOX_LEVEL_2) , |
83 | "Level 3: 60 moves / 30 min" , | 83 | ID2P(LANG_CHESSBOX_LEVEL_3) , |
84 | "Level 4: 40 moves / 30 min" , | 84 | ID2P(LANG_CHESSBOX_LEVEL_4) , |
85 | "Level 5: 40 moves / 60 min" , | 85 | ID2P(LANG_CHESSBOX_LEVEL_5) , |
86 | "Level 6: 40 moves / 120 min" , | 86 | ID2P(LANG_CHESSBOX_LEVEL_6) , |
87 | "Level 7: 40 moves / 240 min" , | 87 | ID2P(LANG_CHESSBOX_LEVEL_7) , |
88 | "Level 8: 1 move / 15 min" , | 88 | ID2P(LANG_CHESSBOX_LEVEL_8) , |
89 | "Level 9: 1 move / 60 min" , | 89 | ID2P(LANG_CHESSBOX_LEVEL_9) , |
90 | "Level 10: 1 move / 600 min" }; | 90 | ID2P(LANG_CHESSBOX_LEVEL_10) }; |
91 | 91 | ||
92 | /* "While thinking" command */ | 92 | /* "While thinking" command */ |
93 | int wt_command = COMMAND_NOP; | 93 | int wt_command = COMMAND_NOP; |
@@ -175,8 +175,35 @@ static void cb_drawboard (void) { | |||
175 | rb->lcd_update(); | 175 | rb->lcd_update(); |
176 | } | 176 | } |
177 | 177 | ||
178 | static short oldx, oldy = 0; | ||
179 | void cb_talk(short x, short y) | ||
180 | { | ||
181 | if (x != oldx || y != oldy) { | ||
182 | short c, r; | ||
183 | short l, piece, p_color; | ||
184 | |||
185 | rb->talk_shutup(); | ||
186 | cr2xy(x, y, &c, &r); | ||
187 | l = locn[r][c]; | ||
188 | piece = board[l]; | ||
189 | p_color = color[l]; | ||
190 | if (piece != no_piece) { | ||
191 | rb->talk_id (VOICE_WHITE + p_color, true); | ||
192 | if (piece >= pawn && piece <= king) { | ||
193 | rb->talk_id (VOICE_PAWN + piece - 1, true); | ||
194 | } | ||
195 | } | ||
196 | rb->talk_id (VOICE_CHAR_A + c, true); | ||
197 | rb->talk_id (VOICE_ONE + r, true); | ||
198 | oldx = x; | ||
199 | oldy = y; | ||
200 | } | ||
201 | } | ||
202 | |||
178 | /* ---- Switch mark on board ---- */ | 203 | /* ---- Switch mark on board ---- */ |
179 | static void cb_switch ( short x , short y ) { | 204 | static void cb_switch ( short x , short y ) { |
205 | if (rb->global_settings->talk_menu) | ||
206 | cb_talk(x, y); | ||
180 | rb->lcd_set_drawmode ( DRMODE_COMPLEMENT ); | 207 | rb->lcd_set_drawmode ( DRMODE_COMPLEMENT ); |
181 | rb->lcd_drawrect ( XOFS + x*TILE_WIDTH + 1 , | 208 | rb->lcd_drawrect ( XOFS + x*TILE_WIDTH + 1 , |
182 | YOFS + ( 7 - y )*TILE_HEIGHT +1 , | 209 | YOFS + ( 7 - y )*TILE_HEIGHT +1 , |
@@ -380,7 +407,7 @@ static void cb_saveposition ( void ) { | |||
380 | #ifdef CHESSBOX_SAVE_FILE_DBG | 407 | #ifdef CHESSBOX_SAVE_FILE_DBG |
381 | cb_saveposition_dbg(); | 408 | cb_saveposition_dbg(); |
382 | #endif | 409 | #endif |
383 | rb->splash ( 0 , "Saving position" ); | 410 | rb->splash ( 0 , ID2P(LANG_CHESSBOX_SAVING_POSITION) ); |
384 | 411 | ||
385 | fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); | 412 | fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); |
386 | 413 | ||
@@ -434,7 +461,7 @@ static void cb_restoreposition ( void ) { | |||
434 | unsigned short m; | 461 | unsigned short m; |
435 | 462 | ||
436 | if ( (fd = rb->open(SAVE_FILE, O_RDONLY)) >= 0 ) { | 463 | if ( (fd = rb->open(SAVE_FILE, O_RDONLY)) >= 0 ) { |
437 | rb->splash ( 0 , "Loading position" ); | 464 | rb->splash ( 0 , ID2P(LANG_CHESSBOX_LOADING_POSITION) ); |
438 | rb->read(fd, &(computer), sizeof(computer)); | 465 | rb->read(fd, &(computer), sizeof(computer)); |
439 | rb->read(fd, &(opponent), sizeof(opponent)); | 466 | rb->read(fd, &(opponent), sizeof(opponent)); |
440 | rb->read(fd, &(Game50), sizeof(Game50)); | 467 | rb->read(fd, &(Game50), sizeof(Game50)); |
@@ -503,8 +530,10 @@ static int cb_menu_viewer(void) | |||
503 | int result = 0; | 530 | int result = 0; |
504 | bool menu_quit = false; | 531 | bool menu_quit = false; |
505 | 532 | ||
506 | MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"Restart Game", | 533 | MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL, |
507 | "Select Other Game", "Quit"); | 534 | ID2P(LANG_CHESSBOX_MENU_RESTART_GAME), |
535 | ID2P(LANG_CHESSBOX_MENU_SELECT_OTHER_GAME), | ||
536 | ID2P(LANG_MENU_QUIT)); | ||
508 | 537 | ||
509 | while(!menu_quit) | 538 | while(!menu_quit) |
510 | { | 539 | { |
@@ -572,7 +601,7 @@ static void cb_start_viewer(char* filename){ | |||
572 | 601 | ||
573 | first_game = pgn_list_games(filename); | 602 | first_game = pgn_list_games(filename); |
574 | if (first_game == NULL){ | 603 | if (first_game == NULL){ |
575 | rb->splash ( HZ*2 , "No games found !" ); | 604 | rb->splash ( HZ*2 , ID2P(LANG_CHESSBOX_NO_GAMES) ); |
576 | return; | 605 | return; |
577 | } | 606 | } |
578 | 607 | ||
@@ -602,7 +631,7 @@ static void cb_start_viewer(char* filename){ | |||
602 | if (curr_ply->prev_node != NULL){ | 631 | if (curr_ply->prev_node != NULL){ |
603 | curr_ply = curr_ply->prev_node; | 632 | curr_ply = curr_ply->prev_node; |
604 | } else { | 633 | } else { |
605 | rb->splash ( HZ*2 , "At the begining of the game" ); | 634 | rb->splash ( HZ*2 , ID2P(LANG_CHESSBOX_GAME_BEGINNING) ); |
606 | break; | 635 | break; |
607 | } | 636 | } |
608 | board[locn[curr_ply->row_from][curr_ply->column_from]] | 637 | board[locn[curr_ply->row_from][curr_ply->column_from]] |
@@ -648,9 +677,39 @@ static void cb_start_viewer(char* filename){ | |||
648 | case COMMAND_NEXT: | 677 | case COMMAND_NEXT: |
649 | /* apply the current move */ | 678 | /* apply the current move */ |
650 | if (curr_ply->player == neutral){ | 679 | if (curr_ply->player == neutral){ |
651 | rb->splash ( HZ*2 , "At the end of the game" ); | 680 | rb->splash ( HZ*2 , ID2P(LANG_CHESSBOX_GAME_END) ); |
652 | break; | 681 | break; |
653 | } | 682 | } |
683 | if (rb->global_settings->talk_menu) { | ||
684 | rb->talk_id (VOICE_WHITE + curr_ply->player, false); | ||
685 | if (curr_ply->castle){ | ||
686 | rb->talk_id (VOICE_CHESSBOX_CASTLE, true); | ||
687 | if (curr_ply->column_to == 6){ | ||
688 | rb->talk_id (VOICE_CHESSBOX_KINGSIDE, true); | ||
689 | } else { | ||
690 | rb->talk_id (VOICE_CHESSBOX_QUEENSIDE, true); | ||
691 | } | ||
692 | } else { | ||
693 | rb->talk_id (VOICE_PAWN + | ||
694 | board[locn[curr_ply->row_from] | ||
695 | [curr_ply->column_from]] | ||
696 | - 1, true); | ||
697 | rb->talk_id (VOICE_CHAR_A + curr_ply->column_from, | ||
698 | true); | ||
699 | rb->talk_id (VOICE_ONE + curr_ply->row_from, true); | ||
700 | if (board[locn[curr_ply->row_to] | ||
701 | [curr_ply->column_to]] != no_piece) { | ||
702 | rb->talk_id (VOICE_CHESSBOX_CAPTURES, true); | ||
703 | rb->talk_id (VOICE_PAWN + | ||
704 | board[locn[curr_ply->row_to] | ||
705 | [curr_ply->column_to]] | ||
706 | - 1, true); | ||
707 | } | ||
708 | rb->talk_id (VOICE_CHAR_A + curr_ply->column_to, | ||
709 | true); | ||
710 | rb->talk_id (VOICE_ONE + curr_ply->row_to, true); | ||
711 | } | ||
712 | } | ||
654 | board[locn[curr_ply->row_to][curr_ply->column_to]] | 713 | board[locn[curr_ply->row_to][curr_ply->column_to]] |
655 | = board[locn[curr_ply->row_from][curr_ply->column_from]]; | 714 | = board[locn[curr_ply->row_from][curr_ply->column_from]]; |
656 | color[locn[curr_ply->row_to][curr_ply->column_to]] | 715 | color[locn[curr_ply->row_to][curr_ply->column_to]] |
@@ -677,6 +736,10 @@ static void cb_start_viewer(char* filename){ | |||
677 | color[locn[curr_ply->row_from][curr_ply->column_to]] = neutral; | 736 | color[locn[curr_ply->row_from][curr_ply->column_to]] = neutral; |
678 | } | 737 | } |
679 | if (curr_ply->promotion){ | 738 | if (curr_ply->promotion){ |
739 | if (rb->global_settings->talk_menu) | ||
740 | rb->talk_id (VOICE_PAWN + | ||
741 | curr_ply->promotion_piece - 1, | ||
742 | true); | ||
680 | board[locn[curr_ply->row_to][curr_ply->column_to]] | 743 | board[locn[curr_ply->row_to][curr_ply->column_to]] |
681 | = curr_ply->promotion_piece; | 744 | = curr_ply->promotion_piece; |
682 | color[locn[curr_ply->row_to][curr_ply->column_to]] | 745 | color[locn[curr_ply->row_to][curr_ply->column_to]] |
@@ -701,7 +764,7 @@ static void cb_start_viewer(char* filename){ | |||
701 | } | 764 | } |
702 | } while (!exit_game && !exit_viewer); | 765 | } while (!exit_game && !exit_viewer); |
703 | } else { | 766 | } else { |
704 | rb->splash ( HZ*2 , "Error parsing game !"); | 767 | rb->splash ( HZ*2 , ID2P(LANG_CHESSBOX_PGN_PARSE_ERROR)); |
705 | } | 768 | } |
706 | } while (!exit_viewer); | 769 | } while (!exit_viewer); |
707 | } | 770 | } |
@@ -713,12 +776,15 @@ static int cb_menu(void) | |||
713 | int result = 0; | 776 | int result = 0; |
714 | bool menu_quit = false; | 777 | bool menu_quit = false; |
715 | 778 | ||
716 | MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL,"New Game","Resume Game", | 779 | MENUITEM_STRINGLIST(menu,"Chessbox Menu",NULL, |
717 | "Save Game", "Restore Game", | 780 | ID2P(LANG_CHESSBOX_MENU_NEW_GAME), |
781 | ID2P(LANG_CHESSBOX_MENU_RESUME_GAME), | ||
782 | ID2P(LANG_CHESSBOX_MENU_SAVE_GAME), | ||
783 | ID2P(LANG_CHESSBOX_MENU_RESTORE_GAME), | ||
718 | #ifdef HAVE_PLAYBACK_CONTROL | 784 | #ifdef HAVE_PLAYBACK_CONTROL |
719 | "Playback Control", | 785 | ID2P(LANG_PLAYBACK_CONTROL), |
720 | #endif | 786 | #endif |
721 | "Quit"); | 787 | ID2P(LANG_MENU_QUIT)); |
722 | 788 | ||
723 | while(!menu_quit) | 789 | while(!menu_quit) |
724 | { | 790 | { |
@@ -813,6 +879,10 @@ static struct cb_command cb_getcommand (void) { | |||
813 | } | 879 | } |
814 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { | 880 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { |
815 | from_marked = true ; | 881 | from_marked = true ; |
882 | if (rb->global_settings->talk_menu) { | ||
883 | cb_talk(x, y); | ||
884 | rb->talk_id(VOICE_MARKED, true); | ||
885 | } | ||
816 | } else { | 886 | } else { |
817 | from_marked = false ; | 887 | from_marked = false ; |
818 | cb_switch ( x , y ); | 888 | cb_switch ( x , y ); |
@@ -831,6 +901,10 @@ static struct cb_command cb_getcommand (void) { | |||
831 | } | 901 | } |
832 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { | 902 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { |
833 | from_marked = true ; | 903 | from_marked = true ; |
904 | if (rb->global_settings->talk_menu) { | ||
905 | cb_talk(x, y); | ||
906 | rb->talk_id(VOICE_MARKED, true); | ||
907 | } | ||
834 | } else { | 908 | } else { |
835 | from_marked = false ; | 909 | from_marked = false ; |
836 | cb_switch ( x , y ); | 910 | cb_switch ( x , y ); |
@@ -849,6 +923,10 @@ static struct cb_command cb_getcommand (void) { | |||
849 | } | 923 | } |
850 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { | 924 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { |
851 | from_marked = true ; | 925 | from_marked = true ; |
926 | if (rb->global_settings->talk_menu) { | ||
927 | cb_talk(x, y); | ||
928 | rb->talk_id(VOICE_MARKED, true); | ||
929 | } | ||
852 | } else { | 930 | } else { |
853 | from_marked = false ; | 931 | from_marked = false ; |
854 | cb_switch ( x , y ); | 932 | cb_switch ( x , y ); |
@@ -867,6 +945,10 @@ static struct cb_command cb_getcommand (void) { | |||
867 | } | 945 | } |
868 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { | 946 | if ( marked && ( marked_x == x ) && ( marked_y == y ) ) { |
869 | from_marked = true ; | 947 | from_marked = true ; |
948 | if (rb->global_settings->talk_menu) { | ||
949 | cb_talk(x, y); | ||
950 | rb->talk_id(VOICE_MARKED, true); | ||
951 | } | ||
870 | } else { | 952 | } else { |
871 | from_marked = false ; | 953 | from_marked = false ; |
872 | cb_switch ( x , y ); | 954 | cb_switch ( x , y ); |
@@ -885,11 +967,15 @@ static struct cb_command cb_getcommand (void) { | |||
885 | from_marked = true ; | 967 | from_marked = true ; |
886 | marked_x = x; | 968 | marked_x = x; |
887 | marked_y = y; | 969 | marked_y = y; |
970 | if (rb->global_settings->talk_menu) | ||
971 | rb->talk_id(VOICE_MARKED, false); | ||
888 | } | 972 | } |
889 | } else { | 973 | } else { |
890 | if ( ( marked_x == x ) && ( marked_y == y ) ) { | 974 | if ( ( marked_x == x ) && ( marked_y == y ) ) { |
891 | marked = false; | 975 | marked = false; |
892 | from_marked = false; | 976 | from_marked = false; |
977 | if (rb->global_settings->talk_menu) | ||
978 | rb->talk_id(VOICE_UNMARKED, false); | ||
893 | } else { | 979 | } else { |
894 | xy2cr ( marked_x , marked_y , &c , &r ); | 980 | xy2cr ( marked_x , marked_y , &c , &r ); |
895 | result.mv_s[0] = 'a' + c; | 981 | result.mv_s[0] = 'a' + c; |
@@ -912,6 +998,23 @@ static struct cb_command cb_getcommand (void) { | |||
912 | 998 | ||
913 | } | 999 | } |
914 | 1000 | ||
1001 | /* Talk a move */ | ||
1002 | static void talk_move(char *move_buffer) | ||
1003 | { | ||
1004 | if (rb->global_settings->talk_menu) { | ||
1005 | rb->talk_id (VOICE_PAWN + | ||
1006 | board[locn[move_buffer[3]-'1'][move_buffer[2]-'a']] - 1, | ||
1007 | false); | ||
1008 | rb->talk_id(VOICE_CHAR_A + move_buffer[0] - 'a', true); | ||
1009 | rb->talk_id(VOICE_ONE + move_buffer[1] - '1', true); | ||
1010 | rb->talk_id(VOICE_CHAR_A + move_buffer[2] - 'a', true); | ||
1011 | rb->talk_id(VOICE_ONE + move_buffer[3] - '1', true); | ||
1012 | if (move_buffer[4] == '+' && !mate) { | ||
1013 | rb->talk_id(VOICE_CHESSBOX_CHECK, true); | ||
1014 | } | ||
1015 | } | ||
1016 | } | ||
1017 | |||
915 | /* ---- game main loop ---- */ | 1018 | /* ---- game main loop ---- */ |
916 | static void cb_play_game(void) { | 1019 | static void cb_play_game(void) { |
917 | struct cb_command command; | 1020 | struct cb_command command; |
@@ -939,7 +1042,8 @@ static void cb_play_game(void) { | |||
939 | 1042 | ||
940 | while (!exit) { | 1043 | while (!exit) { |
941 | if ( mate ) { | 1044 | if ( mate ) { |
942 | rb->splash ( HZ*3 , "Checkmate!" ); | 1045 | rb->talk_force_enqueue_next(); |
1046 | rb->splash ( HZ*3 , ID2P(LANG_CHESSBOX_CHECKMATE) ); | ||
943 | rb->button_get(true); | 1047 | rb->button_get(true); |
944 | pgn_store_game(game); | 1048 | pgn_store_game(game); |
945 | GNUChess_Initialize(); | 1049 | GNUChess_Initialize(); |
@@ -950,7 +1054,7 @@ static void cb_play_game(void) { | |||
950 | switch (command.type) { | 1054 | switch (command.type) { |
951 | case COMMAND_MOVE: | 1055 | case COMMAND_MOVE: |
952 | if ( ! VerifyMove (opponent, command.mv_s , 0 , &command.mv, move_buffer ) ) { | 1056 | if ( ! VerifyMove (opponent, command.mv_s , 0 , &command.mv, move_buffer ) ) { |
953 | rb->splash ( HZ/2 , "Illegal move!" ); | 1057 | rb->splash ( HZ/2 , ID2P(LANG_CHESSBOX_ILLEGAL_MOVE) ); |
954 | cb_drawboard(); | 1058 | cb_drawboard(); |
955 | } else { | 1059 | } else { |
956 | cb_drawboard(); | 1060 | cb_drawboard(); |
@@ -958,7 +1062,8 @@ static void cb_play_game(void) { | |||
958 | /* Add the ply to the PGN history (in algebraic notation) */ | 1062 | /* Add the ply to the PGN history (in algebraic notation) */ |
959 | pgn_append_ply(game, opponent, move_buffer, mate); | 1063 | pgn_append_ply(game, opponent, move_buffer, mate); |
960 | 1064 | ||
961 | rb->splash ( 0 , "Thinking..." ); | 1065 | talk_move(move_buffer); |
1066 | rb->splash ( 0 , ID2P(LANG_CHESSBOX_THINKING) ); | ||
962 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 1067 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
963 | rb->cpu_boost ( true ); | 1068 | rb->cpu_boost ( true ); |
964 | #endif | 1069 | #endif |
@@ -971,6 +1076,7 @@ static void cb_play_game(void) { | |||
971 | */ | 1076 | */ |
972 | if (move_buffer[0] != '\0'){ | 1077 | if (move_buffer[0] != '\0'){ |
973 | pgn_append_ply(game, computer, move_buffer, mate); | 1078 | pgn_append_ply(game, computer, move_buffer, mate); |
1079 | talk_move(move_buffer); | ||
974 | } else { | 1080 | } else { |
975 | pgn_set_result(game, mate); | 1081 | pgn_set_result(game, mate); |
976 | } | 1082 | } |
@@ -1016,7 +1122,7 @@ static void cb_play_game(void) { | |||
1016 | opponent = white; | 1122 | opponent = white; |
1017 | computer = black; | 1123 | computer = black; |
1018 | } | 1124 | } |
1019 | rb->splash ( 0 , "Thinking..." ); | 1125 | rb->splash ( 0 , ID2P(LANG_CHESSBOX_THINKING) ); |
1020 | ElapsedTime(1); | 1126 | ElapsedTime(1); |
1021 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 1127 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
1022 | rb->cpu_boost ( true ); | 1128 | rb->cpu_boost ( true ); |
@@ -1031,6 +1137,7 @@ static void cb_play_game(void) { | |||
1031 | */ | 1137 | */ |
1032 | if (move_buffer[0] != '\0'){ | 1138 | if (move_buffer[0] != '\0'){ |
1033 | pgn_append_ply(game, computer, move_buffer, mate); | 1139 | pgn_append_ply(game, computer, move_buffer, mate); |
1140 | talk_move(move_buffer); | ||
1034 | } else { | 1141 | } else { |
1035 | pgn_set_result(game, mate); | 1142 | pgn_set_result(game, mate); |
1036 | } | 1143 | } |
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index 4e16834f5c..39a24d6fa1 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c | |||
@@ -539,14 +539,21 @@ static void coords_to_pgn(struct pgn_ply_node* ply){ | |||
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | static const char* get_game_text(int selected_item, void *data, | 542 | static struct pgn_game_node *get_game_info(int selected_item, void *data){ |
543 | char *buffer, size_t buffer_len){ | ||
544 | int i; | 543 | int i; |
545 | struct pgn_game_node *temp_node = (struct pgn_game_node *)data; | 544 | struct pgn_game_node *temp_node = (struct pgn_game_node *)data; |
546 | 545 | ||
547 | for (i=0;i<selected_item && temp_node != NULL;i++){ | 546 | for (i=0;i<selected_item && temp_node != NULL;i++){ |
548 | temp_node = temp_node->next_node; | 547 | temp_node = temp_node->next_node; |
549 | } | 548 | } |
549 | |||
550 | return temp_node; | ||
551 | } | ||
552 | |||
553 | static const char* get_game_text(int selected_item, void *data, | ||
554 | char *buffer, size_t buffer_len){ | ||
555 | struct pgn_game_node *temp_node = get_game_info(selected_item, data); | ||
556 | |||
550 | if (temp_node == NULL){ | 557 | if (temp_node == NULL){ |
551 | return NULL; | 558 | return NULL; |
552 | } | 559 | } |
@@ -556,6 +563,35 @@ static const char* get_game_text(int selected_item, void *data, | |||
556 | return buffer; | 563 | return buffer; |
557 | } | 564 | } |
558 | 565 | ||
566 | static void say_player(const char *name, bool enqueue) { | ||
567 | if (!rb->strcasecmp(name, "player")) | ||
568 | rb->talk_id(VOICE_PLAYER, enqueue); | ||
569 | else if (!rb->strcasecmp(name, "gnuchess")) | ||
570 | rb->talk_id(VOICE_GNUCHESS, enqueue); | ||
571 | else | ||
572 | rb->talk_spell(name, enqueue); | ||
573 | } | ||
574 | |||
575 | static int speak_game_selection(int selected_item, void *data){ | ||
576 | struct pgn_game_node *temp_node = get_game_info(selected_item, data); | ||
577 | |||
578 | if (temp_node != NULL){ | ||
579 | say_player(temp_node->white_player, false); | ||
580 | say_player(temp_node->black_player, true); | ||
581 | if (temp_node->game_date[0] != '?') { | ||
582 | char buf[12]; | ||
583 | rb->strcpy(buf, temp_node->game_date); | ||
584 | buf[4] = 0; | ||
585 | buf[7] = 0; | ||
586 | rb->talk_id(LANG_MONTH_JANUARY + rb->atoi(&(buf[5])) - 1, true); | ||
587 | rb->talk_number(rb->atoi(&(buf[8])), true); | ||
588 | rb->talk_number(rb->atoi(buf), true); | ||
589 | } | ||
590 | } | ||
591 | |||
592 | return 0; | ||
593 | } | ||
594 | |||
559 | static void write_pgn_token(int fhandler, char *buffer, size_t *line_length){ | 595 | static void write_pgn_token(int fhandler, char *buffer, size_t *line_length){ |
560 | if (*line_length + rb->strlen(buffer) + 1 > 80){ | 596 | if (*line_length + rb->strlen(buffer) + 1 > 80){ |
561 | rb->fdprintf(fhandler,"\n"); | 597 | rb->fdprintf(fhandler,"\n"); |
@@ -636,14 +672,18 @@ struct pgn_game_node* pgn_show_game_list(struct pgn_game_node* first_game){ | |||
636 | 672 | ||
637 | 673 | ||
638 | rb->gui_synclist_init(&games_list, &get_game_text, first_game, false, 1, NULL); | 674 | rb->gui_synclist_init(&games_list, &get_game_text, first_game, false, 1, NULL); |
639 | rb->gui_synclist_set_title(&games_list, "Games", NOICON); | 675 | rb->gui_synclist_set_title(&games_list, rb->str(LANG_CHESSBOX_GAMES), NOICON); |
640 | rb->gui_synclist_set_icon_callback(&games_list, NULL); | 676 | rb->gui_synclist_set_icon_callback(&games_list, NULL); |
677 | if (rb->global_settings->talk_menu) | ||
678 | rb->gui_synclist_set_voice_callback(&games_list, speak_game_selection); | ||
641 | rb->gui_synclist_set_nb_items(&games_list, i); | 679 | rb->gui_synclist_set_nb_items(&games_list, i); |
642 | rb->gui_synclist_limit_scroll(&games_list, true); | 680 | rb->gui_synclist_limit_scroll(&games_list, true); |
643 | rb->gui_synclist_select_item(&games_list, 0); | 681 | rb->gui_synclist_select_item(&games_list, 0); |
644 | 682 | ||
683 | rb->gui_synclist_draw(&games_list); | ||
684 | rb->gui_synclist_speak_item(&games_list); | ||
685 | |||
645 | while (true) { | 686 | while (true) { |
646 | rb->gui_synclist_draw(&games_list); | ||
647 | curr_selection = rb->gui_synclist_get_sel_pos(&games_list); | 687 | curr_selection = rb->gui_synclist_get_sel_pos(&games_list); |
648 | button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); | 688 | button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); |
649 | if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){ | 689 | if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){ |
@@ -651,11 +691,7 @@ struct pgn_game_node* pgn_show_game_list(struct pgn_game_node* first_game){ | |||
651 | } | 691 | } |
652 | switch (button) { | 692 | switch (button) { |
653 | case ACTION_STD_OK: | 693 | case ACTION_STD_OK: |
654 | temp_node = first_game; | 694 | return get_game_info(curr_selection, first_game); |
655 | for (i=0;i<curr_selection && temp_node != NULL;i++){ | ||
656 | temp_node = temp_node->next_node; | ||
657 | } | ||
658 | return temp_node; | ||
659 | break; | 695 | break; |
660 | case ACTION_STD_CANCEL: | 696 | case ACTION_STD_CANCEL: |
661 | return NULL; | 697 | return NULL; |
diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c index 4b21cd785c..ff9bb99b91 100644 --- a/apps/plugins/chessbox/gnuchess.c +++ b/apps/plugins/chessbox/gnuchess.c | |||
@@ -1117,6 +1117,10 @@ static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt; | |||
1117 | for (index=0;index<5;index++){ | 1117 | for (index=0;index<5;index++){ |
1118 | move_buffer[index] = mvstr1[index]; | 1118 | move_buffer[index] = mvstr1[index]; |
1119 | } | 1119 | } |
1120 | if (SqAtakd(PieceList[(side==white)?black:white][0],side)){ | ||
1121 | move_buffer[4] = '+'; | ||
1122 | move_buffer[5] = '\0'; | ||
1123 | } | ||
1120 | 1124 | ||
1121 | if (score == -9999 || score == 9998) mate = true; | 1125 | if (score == -9999 || score == 9998) mate = true; |
1122 | if (mate) hint = 0; | 1126 | if (mate) hint = 0; |