1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Miguel A. Arévalo
11 * Color graphics from eboard
12 * GNUChess v2 chess engine Copyright (c) 1988 John Stanback
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 #if (MEMORYSIZE > 8) /* Lowmem doesn't have playback in chessbox */
27 #define HAVE_PLAYBACK_CONTROL
31 #ifdef HAVE_PLAYBACK_CONTROL
32 #include "lib/playback_control.h"
37 #include "chessbox_pgn.h"
39 /* type definitions */
46 /* External bitmaps */
47 extern const fb_data chessbox_pieces
[];
52 /* Tile size defined by the assigned bitmap */
53 #include "pluginbitmaps/chessbox_pieces.h"
54 #define TILE_WIDTH BMPWIDTH_chessbox_pieces
55 #define TILE_HEIGHT (BMPHEIGHT_chessbox_pieces/26)
57 /* Calculate Offsets */
58 #define XOFS ((LCD_WIDTH-8*TILE_WIDTH)/2)
59 #define YOFS ((LCD_HEIGHT-8*TILE_HEIGHT)/2)
62 #define SAVE_FILE PLUGIN_GAMES_DATA_DIR "/chessbox.save"
66 #define COMMAND_MOVE 1
67 #define COMMAND_PLAY 2
68 #define COMMAND_LEVEL 3
69 #define COMMAND_RESTART 4
70 #define COMMAND_QUIT 5
71 #define COMMAND_MENU 6
72 #define COMMAND_SAVE 7
73 #define COMMAND_RESTORE 8
74 #define COMMAND_RESUME 9
75 #define COMMAND_SELECT 10
76 #define COMMAND_NEXT 11
77 #define COMMAND_PREV 12
81 /* level+1's string */
82 const char *level_string
[] = { "Level 1: 60 moves / 5 min" ,
83 "Level 2: 60 moves / 15 min" ,
84 "Level 3: 60 moves / 30 min" ,
85 "Level 4: 40 moves / 30 min" ,
86 "Level 5: 40 moves / 60 min" ,
87 "Level 6: 40 moves / 120 min" ,
88 "Level 7: 40 moves / 240 min" ,
89 "Level 8: 1 move / 15 min" ,
90 "Level 9: 1 move / 60 min" ,
91 "Level 10: 1 move / 600 min" };
93 /* "While thinking" command */
94 int wt_command
= COMMAND_NOP
;
96 /* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */
97 void xy2cr ( short x
, short y
, short *c
, short *r
) {
98 if (computer
== black
) {
107 /* ---- get physical x y for a board column and row (e2 f.e.) ---- */
108 void cr2xy ( short c
, short r
, short *x
, short *y
) {
109 if ( computer
== black
) {
118 /* ---- Draw a complete board ---- */
119 static void cb_drawboard (void) {
120 short r
, c
, x
, y
;
121 short l
, piece
, p_color
;
124 rb
->lcd_clear_display();
126 for (r
= 0; r
< 8; r
++) {
127 for (c
= 0; c
< 8; c
++) {
131 cr2xy ( c
, r
, &x
, &y
);
132 if ( piece
== no_piece
) {
133 rb
->lcd_bitmap_part ( chessbox_pieces
, 0 ,
134 TILE_HEIGHT
* b_color
,
136 BMPWIDTH_chessbox_pieces
,
137 BMPHEIGHT_chessbox_pieces
) ,
138 XOFS
+ x
*TILE_WIDTH
,
139 YOFS
+ ( 7 - y
)*TILE_HEIGHT
,
143 rb
->lcd_bitmap_part ( chessbox_pieces
,
146 4 * TILE_HEIGHT
* ( piece
- 1 ) +
147 2 * TILE_HEIGHT
* p_color
+
148 TILE_HEIGHT
* b_color
,
150 BMPWIDTH_chessbox_pieces
,
151 BMPHEIGHT_chessbox_pieces
) ,
152 XOFS
+ x
*TILE_WIDTH
,
153 YOFS
+ (7 - y
)*TILE_HEIGHT
,
157 b_color
= (b_color
== 1) ? 0 : 1 ;
159 b_color
= (b_color
== 1) ? 0 : 1 ;
162 /* draw board limits */
163 #if (LCD_WIDTH > TILE_WIDTH*8) && (LCD_HEIGHT > TILE_HEIGHT*8)
164 rb
->lcd_drawrect(XOFS
- 1, YOFS
- 1, TILE_WIDTH
*8 + 2, TILE_HEIGHT
*8 + 2);
165 #elif LCD_WIDTH > TILE_WIDTH*8
166 rb
->lcd_vline(XOFS
- 1, 0, LCD_HEIGHT
- 1);
167 rb
->lcd_vline(XOFS
+ 8*TILE_WIDTH
, 0, LCD_HEIGHT
- 1);
168 #elif LCD_HEIGHT > TILE_HEIGHT*8
169 rb
->lcd_hline(0, LCD_WIDTH
- 1, YOFS
- 1);
170 rb
->lcd_hline(0, LCD_WIDTH
- 1, YOFS
+ TILE_HEIGHT
*8);
176 /* ---- Switch mark on board ---- */
177 void cb_switch ( short x
, short y
) {
178 rb
->lcd_set_drawmode ( DRMODE_COMPLEMENT
);
179 rb
->lcd_drawrect ( XOFS
+ x
*TILE_WIDTH
+ 1 ,
180 YOFS
+ ( 7 - y
)*TILE_HEIGHT
+1 ,
181 TILE_WIDTH
-2 , TILE_HEIGHT
-2 );
183 rb
->lcd_set_drawmode ( DRMODE_SOLID
);
186 /* ---- callback for capturing interaction while thinking ---- */
187 void cb_wt_callback ( void ) {
188 int button
= BUTTON_NONE
;
190 wt_command
= COMMAND_NOP
;
191 button
= rb
->button_get(false);
195 wt_command
= COMMAND_QUIT
;
200 wt_command
= COMMAND_MENU
;
204 wt_command
= COMMAND_PLAY
;
210 /* ---- set playing parameters depending on level ---- */
211 void cb_setlevel ( int lev
) {
212 Level
= (lev
> 7) ? 7 : ( (lev
< 1) ? 1 : lev
) ;
255 TCflag
= (TCmoves
> 1);
259 /* ---- increase playing level ---- */
260 void cb_levelup ( void ) {
264 cb_setlevel ( Level
+1 );
265 rb
->splash ( HZ
/2 , level_string
[Level
-1] );
268 /* ---- Save current position ---- */
269 void cb_saveposition ( void ) {
274 rb
->splash ( 0 , "Saving position" );
276 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
, 0666);
278 computer
++; rb
->write(fd
, &(computer
), sizeof(computer
)); computer
--;
279 opponent
++; rb
->write(fd
, &(opponent
), sizeof(opponent
)); opponent
--;
280 rb
->write(fd
, &(Game50
), sizeof(Game50
));
282 rb
->write(fd
, &(castld
[white
]), sizeof(castld
[white
]));
283 rb
->write(fd
, &(castld
[black
]), sizeof(castld
[black
]));
284 rb
->write(fd
, &(kingmoved
[white
]), sizeof(kingmoved
[white
]));
285 rb
->write(fd
, &(kingmoved
[black
]), sizeof(kingmoved
[black
]));
287 rb
->write(fd
, &(withbook
), sizeof(withbook
));
288 rb
->write(fd
, &(Level
), sizeof(Level
));
289 rb
->write(fd
, &(TCflag
), sizeof(TCflag
));
290 rb
->write(fd
, &(OperatorTime
), sizeof(OperatorTime
));
292 rb
->write(fd
, &(TimeControl
.clock
[white
]),
293 sizeof(TimeControl
.clock
[white
]) );
294 rb
->write(fd
, &(TimeControl
.clock
[black
]),
295 sizeof(TimeControl
.clock
[black
]) );
296 rb
->write(fd
, &(TimeControl
.moves
[white
]),
297 sizeof(TimeControl
.moves
[white
]) );
298 rb
->write(fd
, &(TimeControl
.moves
[black
]),
299 sizeof(TimeControl
.moves
[black
]) );
300 for (sq
= 0; sq
< 64; sq
++) {
301 if (color
[sq
] == neutral
) c
= 0; else c
= color
[sq
]+1;
302 temp
= 256*board
[sq
] + c
;
303 rb
->write(fd
, &(temp
), sizeof(temp
));
305 for (i
= 0; i
<= GameCnt
; i
++) {
306 if (GameList
[i
].color
== neutral
)
309 c
= GameList
[i
].color
+ 1;
310 rb
->write(fd
, &(GameList
[i
].gmove
), sizeof(GameList
[i
].gmove
));
311 rb
->write(fd
, &(GameList
[i
].score
), sizeof(GameList
[i
].score
));
312 rb
->write(fd
, &(GameList
[i
].depth
), sizeof(GameList
[i
].depth
));
313 rb
->write(fd
, &(GameList
[i
].nodes
), sizeof(GameList
[i
].nodes
));
314 rb
->write(fd
, &(GameList
[i
].time
), sizeof(GameList
[i
].time
));
315 rb
->write(fd
, &(GameList
[i
].piece
), sizeof(GameList
[i
].piece
));
316 rb
->write(fd
, &(c
), sizeof(c
));
321 /* ---- Restore saved position ---- */
322 void cb_restoreposition ( void ) {
327 if ( (fd
= rb
->open(SAVE_FILE
, O_RDONLY
)) >= 0 ) {
328 rb
->splash ( 0 , "Loading position" );
329 rb
->read(fd
, &(computer
), sizeof(computer
));
330 rb
->read(fd
, &(opponent
), sizeof(opponent
));
331 rb
->read(fd
, &(Game50
), sizeof(Game50
));
333 rb
->read(fd
, &(castld
[white
]), sizeof(castld
[white
]));
334 rb
->read(fd
, &(castld
[black
]), sizeof(castld
[black
]));
335 rb
->read(fd
, &(kingmoved
[white
]), sizeof(kingmoved
[white
]));
336 rb
->read(fd
, &(kingmoved
[black
]), sizeof(kingmoved
[black
]));
338 rb
->read(fd
, &(withbook
), sizeof(withbook
));
339 rb
->read(fd
, &(Level
), sizeof(Level
));
340 rb
->read(fd
, &(TCflag
), sizeof(TCflag
));
341 rb
->read(fd
, &(OperatorTime
), sizeof(OperatorTime
));
343 rb
->read(fd
, &(TimeControl
.clock
[white
]),
344 sizeof(TimeControl
.clock
[white
]));
345 rb
->read(fd
, &(TimeControl
.clock
[black
]),
346 sizeof(TimeControl
.clock
[black
]));
347 rb
->read(fd
, &(TimeControl
.moves
[white
]),
348 sizeof(TimeControl
.moves
[white
]));
349 rb
->read(fd
, &(TimeControl
.moves
[black
]),
350 sizeof(TimeControl
.moves
[black
]));
351 for (sq
= 0; sq
< 64; sq
++) {
352 rb
->read(fd
, &(m
), sizeof(m
));
353 board
[sq
] = (m
>> 8); color
[sq
] = (m
& 0xFF);
360 while (rb
->read(fd
, &(GameList
[++GameCnt
].gmove
),
361 sizeof(GameList
[GameCnt
].gmove
)) > 0) {
362 rb
->read(fd
, &(GameList
[GameCnt
].score
),
363 sizeof(GameList
[GameCnt
].score
));
364 rb
->read(fd
, &(GameList
[GameCnt
].depth
),
365 sizeof(GameList
[GameCnt
].depth
));
366 rb
->read(fd
, &(GameList
[GameCnt
].nodes
),
367 sizeof(GameList
[GameCnt
].nodes
));
368 rb
->read(fd
, &(GameList
[GameCnt
].time
),
369 sizeof(GameList
[GameCnt
].time
));
370 rb
->read(fd
, &(GameList
[GameCnt
].piece
),
371 sizeof(GameList
[GameCnt
].piece
));
372 rb
->read(fd
, &(GameList
[GameCnt
].color
),
373 sizeof(GameList
[GameCnt
].color
));
374 if (GameList
[GameCnt
].color
== 0)
375 GameList
[GameCnt
].color
= neutral
;
377 --GameList
[GameCnt
].color
;
380 if (TimeControl
.clock
[white
] > 0)
382 computer
--; opponent
--;
390 /* ---- show menu in viewer mode---- */
391 static int cb_menu_viewer(void)
395 bool menu_quit
= false;
397 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"Restart Game",
398 "Select Other Game", "Quit");
402 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
406 result
= COMMAND_RESTART
;
409 result
= COMMAND_SELECT
;
413 result
= COMMAND_QUIT
;
421 /* ---- get a command in game mode ---- */
422 struct cb_command
cb_get_viewer_command (void) {
424 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
428 button
= rb
->button_get(true);
432 result
.type
= COMMAND_QUIT
;
436 result
.type
= cb_menu_viewer();
439 result
.type
= COMMAND_PREV
;
442 result
.type
= COMMAND_NEXT
;
449 /* ---- viewer main loop ---- */
450 void cb_start_viewer(char* filename
){
451 struct pgn_game_node
*first_game
, *selected_game
;
452 struct pgn_ply_node
*curr_ply
;
453 bool exit_game
= false;
454 bool exit_viewer
= false;
455 struct cb_command command
;
457 first_game
= pgn_list_games(filename
);
458 if (first_game
== NULL
){
459 rb
->splash ( HZ
*2 , "No games found !" );
464 selected_game
= pgn_show_game_list(first_game
);
465 if (selected_game
== NULL
){
469 pgn_parse_game(filename
, selected_game
);
470 if (selected_game
->first_ply
!= NULL
) {
473 GNUChess_Initialize();
478 curr_ply
= selected_game
->first_ply
;
482 command
= cb_get_viewer_command ();
483 switch (command
.type
) {
485 /* unapply the previous ply */
486 if (curr_ply
->prev_node
!= NULL
){
487 curr_ply
= curr_ply
->prev_node
;
489 rb
->splash ( HZ
*2 , "At the begining of the game" );
492 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
493 = board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
494 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
495 = color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
496 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = no_piece
;
497 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = neutral
;
498 if (curr_ply
->taken_piece
!= no_piece
&& !curr_ply
->enpassant
){
499 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
500 = curr_ply
->taken_piece
;
501 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
502 = ((curr_ply
->player
==white
)?black
:white
);
504 if (curr_ply
->castle
){
505 if (curr_ply
->column_to
== 6){
506 /* castling kingside */
507 board
[locn
[curr_ply
->row_to
][7]] = rook
;
508 color
[locn
[curr_ply
->row_to
][7]] = curr_ply
->player
;
509 board
[locn
[curr_ply
->row_to
][5]] = no_piece
;
510 color
[locn
[curr_ply
->row_to
][5]] = neutral
;
512 /* castling queenside */
513 board
[locn
[curr_ply
->row_to
][0]] = rook
;
514 color
[locn
[curr_ply
->row_to
][0]] = curr_ply
->player
;
515 board
[locn
[curr_ply
->row_to
][3]] = no_piece
;
516 color
[locn
[curr_ply
->row_to
][3]] = neutral
;
519 if (curr_ply
->enpassant
){
520 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = pawn
;
521 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]]
522 = ((curr_ply
->player
==white
)?black
:white
);
524 if (curr_ply
->promotion
){
525 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = pawn
;
526 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
533 /* apply the current move */
534 if (curr_ply
->player
== neutral
){
535 rb
->splash ( HZ
*2 , "At the end of the game" );
538 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
539 = board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
540 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
541 = color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
542 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = no_piece
;
543 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = neutral
;
544 if (curr_ply
->castle
){
545 if (curr_ply
->column_to
== 6){
546 /* castling kingside */
547 board
[locn
[curr_ply
->row_to
][5]] = rook
;
548 color
[locn
[curr_ply
->row_to
][5]] = curr_ply
->player
;
549 board
[locn
[curr_ply
->row_to
][7]] = no_piece
;
550 color
[locn
[curr_ply
->row_to
][7]] = neutral
;
552 /* castling queenside */
553 board
[locn
[curr_ply
->row_to
][3]] = rook
;
554 color
[locn
[curr_ply
->row_to
][3]] = curr_ply
->player
;
555 board
[locn
[curr_ply
->row_to
][0]] = no_piece
;
556 color
[locn
[curr_ply
->row_to
][0]] = neutral
;
559 if (curr_ply
->enpassant
){
560 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = no_piece
;
561 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = neutral
;
563 if (curr_ply
->promotion
){
564 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
565 = curr_ply
->promotion_piece
;
566 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
569 if (curr_ply
->next_node
!= NULL
){
570 curr_ply
= curr_ply
->next_node
;
574 case COMMAND_RESTART
:
575 GNUChess_Initialize();
577 curr_ply
= selected_game
->first_ply
;
585 } while (!exit_game
&& !exit_viewer
);
587 rb
->splash ( HZ
*2 , "Error parsing game !");
589 } while (!exit_viewer
);
592 /* ---- show menu ---- */
593 static int cb_menu(void)
597 bool menu_quit
= false;
599 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"New Game","Resume Game",
600 "Save Game", "Restore Game",
601 #ifdef HAVE_PLAYBACK_CONTROL
608 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
612 result
= COMMAND_RESTART
;
615 result
= COMMAND_RESUME
;
619 result
= COMMAND_SAVE
;
623 result
= COMMAND_RESTORE
;
627 #ifdef HAVE_PLAYBACK_CONTROL
628 playback_control(NULL
);
632 result
= COMMAND_QUIT
;
640 /* ---- get a command in game mode ---- */
641 struct cb_command
cb_getcommand (void) {
642 static short x
= 4 , y
= 3 ;
644 int button
, lastbutton
= BUTTON_NONE
;
645 int marked
= false , from_marked
= false ;
646 short marked_x
= 0 , marked_y
= 0 ;
647 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
652 button
= rb
->button_get(true);
656 result
.type
= COMMAND_QUIT
;
660 result
.type
= cb_menu();
663 result
.type
= COMMAND_LEVEL
;
667 if (lastbutton
!= CB_PLAY_PRE
)
670 result
.type
= COMMAND_PLAY
;
673 if ( !from_marked
) cb_switch ( x
, y
);
680 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
683 from_marked
= false ;
688 if ( !from_marked
) cb_switch ( x
, y
);
695 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
698 from_marked
= false ;
703 if ( !from_marked
) cb_switch ( x
, y
);
710 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
713 from_marked
= false ;
718 if ( !from_marked
) cb_switch ( x
, y
);
725 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
728 from_marked
= false ;
734 if (lastbutton
!= CB_SELECT_PRE
)
738 xy2cr ( x
, y
, &c
, &r
);
740 if ( ( color
[l
]!=computer
) && ( board
[l
]!=no_piece
) ) {
747 if ( ( marked_x
== x
) && ( marked_y
== y
) ) {
751 xy2cr ( marked_x
, marked_y
, &c
, &r
);
752 result
.mv_s
[0] = 'a' + c
;
753 result
.mv_s
[1] = '1' + r
;
754 xy2cr ( x
, y
, &c
, &r
);
755 result
.mv_s
[2] = 'a' + c
;
756 result
.mv_s
[3] = '1' + r
;
757 result
.mv_s
[4] = '\00';
758 result
.type
= COMMAND_MOVE
;
764 if (button
!= BUTTON_NONE
)
770 /* ---- game main loop ---- */
771 void cb_play_game(void) {
772 struct cb_command command
;
773 struct pgn_game_node
*game
;
774 char move_buffer
[20];
779 /* load opening book, soon */
782 GNUChess_Initialize();
784 /* init PGN history data structures */
785 game
= pgn_init_game();
787 /* restore saved position, if saved */
788 cb_restoreposition();
789 /* TODO: save/restore the PGN history of unfinished games */
792 /* I don't like configscreens, start game inmediatly */
797 rb
->splash ( HZ
*3 , "Checkmate!" );
798 rb
->button_get(true);
799 pgn_store_game(game
);
800 GNUChess_Initialize();
801 game
= pgn_init_game();
804 command
= cb_getcommand ();
805 switch (command
.type
) {
807 if ( ! VerifyMove (opponent
, command
.mv_s
, 0 , &command
.mv
, move_buffer
) ) {
808 rb
->splash ( HZ
/2 , "Illegal move!" );
813 /* Add the ply to the PGN history (in algebraic notation) */
814 pgn_append_ply(game
, opponent
, move_buffer
, mate
);
816 rb
->splash ( 0 , "Thinking..." );
817 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
818 rb
->cpu_boost ( true );
820 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
821 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
822 rb
->cpu_boost ( false );
824 /* Add the ply to the PGN history (in algebraic notation) and check
825 * for the result of the game which is only calculated in SelectMove
827 if (move_buffer
[0] != '\0'){
828 pgn_append_ply(game
, computer
, move_buffer
, mate
);
830 pgn_set_result(game
, mate
);
833 if ( wt_command
== COMMAND_QUIT
) {
840 #ifdef COMMAND_RESTART
841 case COMMAND_RESTART
:
842 GNUChess_Initialize();
843 game
= pgn_init_game();
854 case COMMAND_RESTORE
:
855 /* watch out, it will reset the game if no previous game was saved! */
858 GNUChess_Initialize();
860 /* init PGN history data structures */
861 game
= pgn_init_game();
863 /* restore saved position, if saved */
864 cb_restoreposition();
869 if (opponent
== white
) {
876 rb
->splash ( 0 , "Thinking..." );
878 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
879 rb
->cpu_boost ( true );
881 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
882 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
883 rb
->cpu_boost ( false );
886 /* Add the ply to the PGN history (in algebraic notation) and check
887 * for the result of the game which is only calculated in SelectMove
889 if (move_buffer
[0] != '\0'){
890 pgn_append_ply(game
, computer
, move_buffer
, mate
);
892 pgn_set_result(game
, mate
);
895 if ( wt_command
== COMMAND_QUIT
) {
912 /* TODO: save/restore the PGN history of unfinished games */
913 rb
->lcd_setfont(FONT_UI
);
917 /*****************************************************************************
918 * plugin entry point.
919 ******************************************************************************/
920 enum plugin_status
plugin_start(const void* parameter
) {
925 rb
->lcd_set_backdrop(NULL
);
928 /* end of plugin init */
930 /* if the plugin was invoked as a viewer, parse the file and show the game list
931 * else, start playing a game
933 if (parameter
!= NULL
) {
934 cb_start_viewer((char *)parameter
);