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 ) {
328 if ( (fd
= rb
->open(SAVE_FILE
, O_RDONLY
)) >= 0 ) {
329 rb
->splash ( 0 , "Loading position" );
330 rb
->read(fd
, &(computer
), sizeof(computer
));
331 rb
->read(fd
, &(opponent
), sizeof(opponent
));
332 rb
->read(fd
, &(Game50
), sizeof(Game50
));
334 rb
->read(fd
, &(castld
[white
]), sizeof(castld
[white
]));
335 rb
->read(fd
, &(castld
[black
]), sizeof(castld
[black
]));
336 rb
->read(fd
, &(kingmoved
[white
]), sizeof(kingmoved
[white
]));
337 rb
->read(fd
, &(kingmoved
[black
]), sizeof(kingmoved
[black
]));
339 rb
->read(fd
, &(withbook
), sizeof(withbook
));
340 rb
->read(fd
, &(Level
), sizeof(Level
));
341 rb
->read(fd
, &(TCflag
), sizeof(TCflag
));
342 rb
->read(fd
, &(OperatorTime
), sizeof(OperatorTime
));
344 rb
->read(fd
, &(TimeControl
.clock
[white
]),
345 sizeof(TimeControl
.clock
[white
]));
346 rb
->read(fd
, &(TimeControl
.clock
[black
]),
347 sizeof(TimeControl
.clock
[black
]));
348 rb
->read(fd
, &(TimeControl
.moves
[white
]),
349 sizeof(TimeControl
.moves
[white
]));
350 rb
->read(fd
, &(TimeControl
.moves
[black
]),
351 sizeof(TimeControl
.moves
[black
]));
352 for (sq
= 0; sq
< 64; sq
++) {
353 rb
->read(fd
, &(m
), sizeof(m
));
354 board
[sq
] = (m
>> 8); color
[sq
] = (m
& 0xFF);
360 GameCnt
= -1; c
= '?';
361 while (rb
->read(fd
, &(GameList
[++GameCnt
].gmove
),
362 sizeof(GameList
[GameCnt
].gmove
)) > 0) {
363 rb
->read(fd
, &(GameList
[GameCnt
].score
),
364 sizeof(GameList
[GameCnt
].score
));
365 rb
->read(fd
, &(GameList
[GameCnt
].depth
),
366 sizeof(GameList
[GameCnt
].depth
));
367 rb
->read(fd
, &(GameList
[GameCnt
].nodes
),
368 sizeof(GameList
[GameCnt
].nodes
));
369 rb
->read(fd
, &(GameList
[GameCnt
].time
),
370 sizeof(GameList
[GameCnt
].time
));
371 rb
->read(fd
, &(GameList
[GameCnt
].piece
),
372 sizeof(GameList
[GameCnt
].piece
));
373 rb
->read(fd
, &(GameList
[GameCnt
].color
),
374 sizeof(GameList
[GameCnt
].color
));
375 if (GameList
[GameCnt
].color
== 0)
376 GameList
[GameCnt
].color
= neutral
;
378 --GameList
[GameCnt
].color
;
381 if (TimeControl
.clock
[white
] > 0)
383 computer
--; opponent
--;
391 /* ---- show menu in viewer mode---- */
392 static int cb_menu_viewer(void)
396 bool menu_quit
= false;
398 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"Restart Game",
399 "Select Other Game", "Quit");
403 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
407 result
= COMMAND_RESTART
;
410 result
= COMMAND_SELECT
;
414 result
= COMMAND_QUIT
;
422 /* ---- get a command in game mode ---- */
423 struct cb_command
cb_get_viewer_command (void) {
425 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
429 button
= rb
->button_get(true);
433 result
.type
= COMMAND_QUIT
;
437 result
.type
= cb_menu_viewer();
440 result
.type
= COMMAND_PREV
;
443 result
.type
= COMMAND_NEXT
;
450 /* ---- viewer main loop ---- */
451 void cb_start_viewer(char* filename
){
452 struct pgn_game_node
*first_game
, *selected_game
;
453 struct pgn_ply_node
*curr_ply
;
454 bool exit_game
= false;
455 bool exit_viewer
= false;
456 struct cb_command command
;
458 first_game
= pgn_list_games(filename
);
459 if (first_game
== NULL
){
460 rb
->splash ( HZ
*2 , "No games found !" );
465 selected_game
= pgn_show_game_list(first_game
);
466 if (selected_game
== NULL
){
470 pgn_parse_game(filename
, selected_game
);
471 if (selected_game
->first_ply
!= NULL
) {
474 GNUChess_Initialize();
479 curr_ply
= selected_game
->first_ply
;
483 command
= cb_get_viewer_command ();
484 switch (command
.type
) {
486 /* unapply the previous ply */
487 if (curr_ply
->prev_node
!= NULL
){
488 curr_ply
= curr_ply
->prev_node
;
490 rb
->splash ( HZ
*2 , "At the begining of the game" );
493 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
494 = board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
495 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
496 = color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
497 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = no_piece
;
498 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = neutral
;
499 if (curr_ply
->taken_piece
!= no_piece
&& !curr_ply
->enpassant
){
500 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
501 = curr_ply
->taken_piece
;
502 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
503 = ((curr_ply
->player
==white
)?black
:white
);
505 if (curr_ply
->castle
){
506 if (curr_ply
->column_to
== 6){
507 /* castling kingside */
508 board
[locn
[curr_ply
->row_to
][7]] = rook
;
509 color
[locn
[curr_ply
->row_to
][7]] = curr_ply
->player
;
510 board
[locn
[curr_ply
->row_to
][5]] = no_piece
;
511 color
[locn
[curr_ply
->row_to
][5]] = neutral
;
513 /* castling queenside */
514 board
[locn
[curr_ply
->row_to
][0]] = rook
;
515 color
[locn
[curr_ply
->row_to
][0]] = curr_ply
->player
;
516 board
[locn
[curr_ply
->row_to
][3]] = no_piece
;
517 color
[locn
[curr_ply
->row_to
][3]] = neutral
;
520 if (curr_ply
->enpassant
){
521 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = pawn
;
522 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]]
523 = ((curr_ply
->player
==white
)?black
:white
);
525 if (curr_ply
->promotion
){
526 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = pawn
;
527 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
534 /* apply the current move */
535 if (curr_ply
->player
== neutral
){
536 rb
->splash ( HZ
*2 , "At the end of the game" );
539 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
540 = board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
541 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
542 = color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
543 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = no_piece
;
544 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = neutral
;
545 if (curr_ply
->castle
){
546 if (curr_ply
->column_to
== 6){
547 /* castling kingside */
548 board
[locn
[curr_ply
->row_to
][5]] = rook
;
549 color
[locn
[curr_ply
->row_to
][5]] = curr_ply
->player
;
550 board
[locn
[curr_ply
->row_to
][7]] = no_piece
;
551 color
[locn
[curr_ply
->row_to
][7]] = neutral
;
553 /* castling queenside */
554 board
[locn
[curr_ply
->row_to
][3]] = rook
;
555 color
[locn
[curr_ply
->row_to
][3]] = curr_ply
->player
;
556 board
[locn
[curr_ply
->row_to
][0]] = no_piece
;
557 color
[locn
[curr_ply
->row_to
][0]] = neutral
;
560 if (curr_ply
->enpassant
){
561 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = no_piece
;
562 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = neutral
;
564 if (curr_ply
->promotion
){
565 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
566 = curr_ply
->promotion_piece
;
567 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
570 if (curr_ply
->next_node
!= NULL
){
571 curr_ply
= curr_ply
->next_node
;
575 case COMMAND_RESTART
:
576 GNUChess_Initialize();
578 curr_ply
= selected_game
->first_ply
;
586 } while (!exit_game
&& !exit_viewer
);
588 rb
->splash ( HZ
*2 , "Error parsing game !");
590 } while (!exit_viewer
);
593 /* ---- show menu ---- */
594 static int cb_menu(void)
598 bool menu_quit
= false;
600 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"New Game","Resume Game",
601 "Save Game", "Restore Game",
602 #ifdef HAVE_PLAYBACK_CONTROL
609 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
613 result
= COMMAND_RESTART
;
616 result
= COMMAND_RESUME
;
620 result
= COMMAND_SAVE
;
624 result
= COMMAND_RESTORE
;
628 #ifdef HAVE_PLAYBACK_CONTROL
629 playback_control(NULL
);
633 result
= COMMAND_QUIT
;
641 /* ---- get a command in game mode ---- */
642 struct cb_command
cb_getcommand (void) {
643 static short x
= 4 , y
= 3 ;
645 int button
, lastbutton
= BUTTON_NONE
;
646 int marked
= false , from_marked
= false ;
647 short marked_x
= 0 , marked_y
= 0 ;
648 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
653 button
= rb
->button_get(true);
657 result
.type
= COMMAND_QUIT
;
661 result
.type
= cb_menu();
664 result
.type
= COMMAND_LEVEL
;
668 if (lastbutton
!= CB_PLAY_PRE
)
671 result
.type
= COMMAND_PLAY
;
674 if ( !from_marked
) cb_switch ( x
, y
);
681 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
684 from_marked
= false ;
689 if ( !from_marked
) cb_switch ( x
, y
);
696 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
699 from_marked
= false ;
704 if ( !from_marked
) cb_switch ( x
, y
);
711 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
714 from_marked
= false ;
719 if ( !from_marked
) cb_switch ( x
, y
);
726 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
729 from_marked
= false ;
735 if (lastbutton
!= CB_SELECT_PRE
)
739 xy2cr ( x
, y
, &c
, &r
);
741 if ( ( color
[l
]!=computer
) && ( board
[l
]!=no_piece
) ) {
748 if ( ( marked_x
== x
) && ( marked_y
== y
) ) {
752 xy2cr ( marked_x
, marked_y
, &c
, &r
);
753 result
.mv_s
[0] = 'a' + c
;
754 result
.mv_s
[1] = '1' + r
;
755 xy2cr ( x
, y
, &c
, &r
);
756 result
.mv_s
[2] = 'a' + c
;
757 result
.mv_s
[3] = '1' + r
;
758 result
.mv_s
[4] = '\00';
759 result
.type
= COMMAND_MOVE
;
765 if (button
!= BUTTON_NONE
)
771 /* ---- game main loop ---- */
772 void cb_play_game(void) {
773 struct cb_command command
;
774 struct pgn_game_node
*game
;
775 char move_buffer
[20];
780 /* load opening book, soon */
783 GNUChess_Initialize();
785 /* init PGN history data structures */
786 game
= pgn_init_game();
788 /* restore saved position, if saved */
789 cb_restoreposition();
790 /* TODO: save/restore the PGN history of unfinished games */
793 /* I don't like configscreens, start game inmediatly */
798 rb
->splash ( HZ
*3 , "Checkmate!" );
799 rb
->button_get(true);
800 pgn_store_game(game
);
801 GNUChess_Initialize();
802 game
= pgn_init_game();
805 command
= cb_getcommand ();
806 switch (command
.type
) {
808 if ( ! VerifyMove (opponent
, command
.mv_s
, 0 , &command
.mv
, move_buffer
) ) {
809 rb
->splash ( HZ
/2 , "Illegal move!" );
814 /* Add the ply to the PGN history (in algebraic notation) */
815 pgn_append_ply(game
, opponent
, move_buffer
, mate
);
817 rb
->splash ( 0 , "Thinking..." );
818 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
819 rb
->cpu_boost ( true );
821 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
822 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
823 rb
->cpu_boost ( false );
825 /* Add the ply to the PGN history (in algebraic notation) and check
826 * for the result of the game which is only calculated in SelectMove
828 if (move_buffer
[0] != '\0'){
829 pgn_append_ply(game
, computer
, move_buffer
, mate
);
831 pgn_set_result(game
, mate
);
834 if ( wt_command
== COMMAND_QUIT
) {
841 #ifdef COMMAND_RESTART
842 case COMMAND_RESTART
:
843 GNUChess_Initialize();
844 game
= pgn_init_game();
855 case COMMAND_RESTORE
:
856 /* watch out, it will reset the game if no previous game was saved! */
859 GNUChess_Initialize();
861 /* init PGN history data structures */
862 game
= pgn_init_game();
864 /* restore saved position, if saved */
865 cb_restoreposition();
870 if (opponent
== white
) {
877 rb
->splash ( 0 , "Thinking..." );
879 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
880 rb
->cpu_boost ( true );
882 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
883 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
884 rb
->cpu_boost ( false );
887 /* Add the ply to the PGN history (in algebraic notation) and check
888 * for the result of the game which is only calculated in SelectMove
890 if (move_buffer
[0] != '\0'){
891 pgn_append_ply(game
, computer
, move_buffer
, mate
);
893 pgn_set_result(game
, mate
);
896 if ( wt_command
== COMMAND_QUIT
) {
913 /* TODO: save/restore the PGN history of unfinished games */
914 rb
->lcd_setfont(FONT_UI
);
918 /*****************************************************************************
919 * plugin entry point.
920 ******************************************************************************/
921 enum plugin_status
plugin_start(const void* parameter
) {
926 rb
->lcd_set_backdrop(NULL
);
929 /* end of plugin init */
931 /* if the plugin was invoked as a viewer, parse the file and show the game list
932 * else, start playing a game
934 if (parameter
!= NULL
) {
935 cb_start_viewer((char *)parameter
);