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 #ifdef HAVE_LCD_BITMAP
30 #include "chessbox_pgn.h"
32 /* type definitions */
39 /* External bitmaps */
40 extern const fb_data chessbox_pieces
[];
45 /* Tile size defined by the assigned bitmap */
46 #include "pluginbitmaps/chessbox_pieces.h"
47 #define TILE_WIDTH BMPWIDTH_chessbox_pieces
48 #define TILE_HEIGHT (BMPHEIGHT_chessbox_pieces/26)
50 /* Calculate Offsets */
51 #define XOFS ((LCD_WIDTH-8*TILE_WIDTH)/2)
52 #define YOFS ((LCD_HEIGHT-8*TILE_HEIGHT)/2)
55 #define SAVE_FILE PLUGIN_GAMES_DIR "/chessbox.save"
59 #define COMMAND_MOVE 1
60 #define COMMAND_PLAY 2
61 #define COMMAND_LEVEL 3
62 #define COMMAND_RESTART 4
63 #define COMMAND_QUIT 5
64 #define COMMAND_MENU 6
65 #define COMMAND_SAVE 7
66 #define COMMAND_RESTORE 8
67 #define COMMAND_RESUME 9
68 #define COMMAND_SELECT 10
69 #define COMMAND_NEXT 11
70 #define COMMAND_PREV 12
74 /* level+1's string */
75 const char *level_string
[] = { "Level 1: 60 moves / 5 min" ,
76 "Level 2: 60 moves / 15 min" ,
77 "Level 3: 60 moves / 30 min" ,
78 "Level 4: 40 moves / 30 min" ,
79 "Level 5: 40 moves / 60 min" ,
80 "Level 6: 40 moves / 120 min" ,
81 "Level 7: 40 moves / 240 min" ,
82 "Level 8: 1 move / 15 min" ,
83 "Level 9: 1 move / 60 min" ,
84 "Level 10: 1 move / 600 min" };
86 /* "While thinking" command */
87 int wt_command
= COMMAND_NOP
;
89 /* GCC wants this to be present for some targets */
90 void* memcpy(void* dst
, const void* src
, size_t size
)
92 return rb
->memcpy(dst
, src
, size
);
95 /* ---- Get the board column and row (e2 f.e.) for a physical x y ---- */
96 void xy2cr ( short x
, short y
, short *c
, short *r
) {
97 if (computer
== black
) {
106 /* ---- get physical x y for a board column and row (e2 f.e.) ---- */
107 void cr2xy ( short c
, short r
, short *x
, short *y
) {
108 if ( computer
== black
) {
117 /* ---- Draw a complete board ---- */
118 static void cb_drawboard (void) {
119 short r
, c
, x
, y
;
120 short l
, piece
, p_color
;
123 rb
->lcd_clear_display();
125 for (r
= 0; r
< 8; r
++) {
126 for (c
= 0; c
< 8; c
++) {
130 cr2xy ( c
, r
, &x
, &y
);
131 if ( piece
== no_piece
) {
132 rb
->lcd_bitmap_part ( chessbox_pieces
, 0 ,
133 TILE_HEIGHT
* b_color
,
135 XOFS
+ x
*TILE_WIDTH
,
136 YOFS
+ ( 7 - y
)*TILE_HEIGHT
,
140 rb
->lcd_bitmap_part ( chessbox_pieces
,
143 4 * TILE_HEIGHT
* ( piece
- 1 ) +
144 2 * TILE_HEIGHT
* p_color
+
145 TILE_HEIGHT
* b_color
,
147 XOFS
+ x
*TILE_WIDTH
,
148 YOFS
+ (7 - y
)*TILE_HEIGHT
,
152 b_color
= (b_color
== 1) ? 0 : 1 ;
154 b_color
= (b_color
== 1) ? 0 : 1 ;
157 /* draw board limits */
158 #if (LCD_WIDTH > TILE_WIDTH*8) && (LCD_HEIGHT > TILE_HEIGHT*8)
159 rb
->lcd_drawrect(XOFS
- 1, YOFS
- 1, TILE_WIDTH
*8 + 2, TILE_HEIGHT
*8 + 2);
160 #elif LCD_WIDTH > TILE_WIDTH*8
161 rb
->lcd_vline(XOFS
- 1, 0, LCD_HEIGHT
- 1);
162 rb
->lcd_vline(XOFS
+ 8*TILE_WIDTH
, 0, LCD_HEIGHT
- 1);
163 #elif LCD_HEIGHT > TILE_HEIGHT*8
164 rb
->lcd_hline(0, LCD_WIDTH
- 1, YOFS
- 1);
165 rb
->lcd_hline(0, LCD_WIDTH
- 1, YOFS
+ TILE_HEIGHT
*8);
171 /* ---- Switch mark on board ---- */
172 void cb_switch ( short x
, short y
) {
173 rb
->lcd_set_drawmode ( DRMODE_COMPLEMENT
);
174 rb
->lcd_drawrect ( XOFS
+ x
*TILE_WIDTH
+ 1 ,
175 YOFS
+ ( 7 - y
)*TILE_HEIGHT
+1 ,
176 TILE_WIDTH
-2 , TILE_HEIGHT
-2 );
178 rb
->lcd_set_drawmode ( DRMODE_SOLID
);
181 /* ---- callback for capturing interaction while thinking ---- */
182 void cb_wt_callback ( void ) {
183 int button
= BUTTON_NONE
;
185 wt_command
= COMMAND_NOP
;
186 button
= rb
->button_get(false);
190 wt_command
= COMMAND_QUIT
;
195 wt_command
= COMMAND_MENU
;
199 wt_command
= COMMAND_PLAY
;
205 /* ---- set playing parameters depending on level ---- */
206 void cb_setlevel ( int lev
) {
207 Level
= (lev
> 7) ? 7 : ( (lev
< 1) ? 1 : lev
) ;
250 TCflag
= (TCmoves
> 1);
254 /* ---- increase playing level ---- */
255 void cb_levelup ( void ) {
259 cb_setlevel ( Level
+1 );
260 rb
->splash ( HZ
/2 , level_string
[Level
-1] );
263 /* ---- Save current position ---- */
264 void cb_saveposition ( void ) {
269 rb
->splash ( 0 , "Saving position" );
271 fd
= rb
->open(SAVE_FILE
, O_WRONLY
|O_CREAT
);
273 computer
++; rb
->write(fd
, &(computer
), sizeof(computer
)); computer
--;
274 opponent
++; rb
->write(fd
, &(opponent
), sizeof(opponent
)); opponent
--;
275 rb
->write(fd
, &(Game50
), sizeof(Game50
));
277 rb
->write(fd
, &(castld
[white
]), sizeof(castld
[white
]));
278 rb
->write(fd
, &(castld
[black
]), sizeof(castld
[black
]));
279 rb
->write(fd
, &(kingmoved
[white
]), sizeof(kingmoved
[white
]));
280 rb
->write(fd
, &(kingmoved
[black
]), sizeof(kingmoved
[black
]));
282 rb
->write(fd
, &(withbook
), sizeof(withbook
));
283 rb
->write(fd
, &(Level
), sizeof(Level
));
284 rb
->write(fd
, &(TCflag
), sizeof(TCflag
));
285 rb
->write(fd
, &(OperatorTime
), sizeof(OperatorTime
));
287 rb
->write(fd
, &(TimeControl
.clock
[white
]),
288 sizeof(TimeControl
.clock
[white
]) );
289 rb
->write(fd
, &(TimeControl
.clock
[black
]),
290 sizeof(TimeControl
.clock
[black
]) );
291 rb
->write(fd
, &(TimeControl
.moves
[white
]),
292 sizeof(TimeControl
.moves
[white
]) );
293 rb
->write(fd
, &(TimeControl
.moves
[black
]),
294 sizeof(TimeControl
.moves
[black
]) );
295 for (sq
= 0; sq
< 64; sq
++) {
296 if (color
[sq
] == neutral
) c
= 0; else c
= color
[sq
]+1;
297 temp
= 256*board
[sq
] + c
;
298 rb
->write(fd
, &(temp
), sizeof(temp
));
300 for (i
= 0; i
<= GameCnt
; i
++) {
301 if (GameList
[i
].color
== neutral
)
304 c
= GameList
[i
].color
+ 1;
305 rb
->write(fd
, &(GameList
[i
].gmove
), sizeof(GameList
[i
].gmove
));
306 rb
->write(fd
, &(GameList
[i
].score
), sizeof(GameList
[i
].score
));
307 rb
->write(fd
, &(GameList
[i
].depth
), sizeof(GameList
[i
].depth
));
308 rb
->write(fd
, &(GameList
[i
].nodes
), sizeof(GameList
[i
].nodes
));
309 rb
->write(fd
, &(GameList
[i
].time
), sizeof(GameList
[i
].time
));
310 rb
->write(fd
, &(GameList
[i
].piece
), sizeof(GameList
[i
].piece
));
311 rb
->write(fd
, &(c
), sizeof(c
));
316 /* ---- Restore saved position ---- */
317 void cb_restoreposition ( void ) {
323 if ( (fd
= rb
->open(SAVE_FILE
, O_RDONLY
)) >= 0 ) {
324 rb
->splash ( 0 , "Loading position" );
325 rb
->read(fd
, &(computer
), sizeof(computer
));
326 rb
->read(fd
, &(opponent
), sizeof(opponent
));
327 rb
->read(fd
, &(Game50
), sizeof(Game50
));
329 rb
->read(fd
, &(castld
[white
]), sizeof(castld
[white
]));
330 rb
->read(fd
, &(castld
[black
]), sizeof(castld
[black
]));
331 rb
->read(fd
, &(kingmoved
[white
]), sizeof(kingmoved
[white
]));
332 rb
->read(fd
, &(kingmoved
[black
]), sizeof(kingmoved
[black
]));
334 rb
->read(fd
, &(withbook
), sizeof(withbook
));
335 rb
->read(fd
, &(Level
), sizeof(Level
));
336 rb
->read(fd
, &(TCflag
), sizeof(TCflag
));
337 rb
->read(fd
, &(OperatorTime
), sizeof(OperatorTime
));
339 rb
->read(fd
, &(TimeControl
.clock
[white
]),
340 sizeof(TimeControl
.clock
[white
]));
341 rb
->read(fd
, &(TimeControl
.clock
[black
]),
342 sizeof(TimeControl
.clock
[black
]));
343 rb
->read(fd
, &(TimeControl
.moves
[white
]),
344 sizeof(TimeControl
.moves
[white
]));
345 rb
->read(fd
, &(TimeControl
.moves
[black
]),
346 sizeof(TimeControl
.moves
[black
]));
347 for (sq
= 0; sq
< 64; sq
++) {
348 rb
->read(fd
, &(m
), sizeof(m
));
349 board
[sq
] = (m
>> 8); color
[sq
] = (m
& 0xFF);
355 GameCnt
= -1; c
= '?';
356 while (rb
->read(fd
, &(GameList
[++GameCnt
].gmove
),
357 sizeof(GameList
[GameCnt
].gmove
)) > 0) {
358 rb
->read(fd
, &(GameList
[GameCnt
].score
),
359 sizeof(GameList
[GameCnt
].score
));
360 rb
->read(fd
, &(GameList
[GameCnt
].depth
),
361 sizeof(GameList
[GameCnt
].depth
));
362 rb
->read(fd
, &(GameList
[GameCnt
].nodes
),
363 sizeof(GameList
[GameCnt
].nodes
));
364 rb
->read(fd
, &(GameList
[GameCnt
].time
),
365 sizeof(GameList
[GameCnt
].time
));
366 rb
->read(fd
, &(GameList
[GameCnt
].piece
),
367 sizeof(GameList
[GameCnt
].piece
));
368 rb
->read(fd
, &(GameList
[GameCnt
].color
),
369 sizeof(GameList
[GameCnt
].color
));
370 if (GameList
[GameCnt
].color
== 0)
371 GameList
[GameCnt
].color
= neutral
;
373 --GameList
[GameCnt
].color
;
376 if (TimeControl
.clock
[white
] > 0)
378 computer
--; opponent
--;
386 /* ---- show menu in viewer mode---- */
387 static int cb_menu_viewer(void)
391 bool menu_quit
= false;
393 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"Restart Game",
394 "Select Other Game", "Quit");
398 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
402 result
= COMMAND_RESTART
;
405 result
= COMMAND_SELECT
;
409 result
= COMMAND_QUIT
;
417 /* ---- get a command in game mode ---- */
418 struct cb_command
cb_get_viewer_command (void) {
420 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
424 button
= rb
->button_get(true);
428 result
.type
= COMMAND_QUIT
;
432 result
.type
= cb_menu_viewer();
435 result
.type
= COMMAND_PREV
;
438 result
.type
= COMMAND_NEXT
;
445 /* ---- viewer main loop ---- */
446 void cb_start_viewer(char* filename
){
447 struct pgn_game_node
*first_game
, *selected_game
;
448 struct pgn_ply_node
*curr_ply
;
449 bool exit_game
= false;
450 bool exit_viewer
= false;
451 struct cb_command command
;
453 first_game
= pgn_list_games(rb
, filename
);
454 if (first_game
== NULL
){
455 rb
->splash ( HZ
*2 , "No games found !" );
460 selected_game
= pgn_show_game_list(rb
, first_game
);
461 if (selected_game
== NULL
){
465 pgn_parse_game(rb
, filename
, selected_game
);
466 if (selected_game
->first_ply
!= NULL
) {
469 GNUChess_Initialize();
474 curr_ply
= selected_game
->first_ply
;
478 command
= cb_get_viewer_command ();
479 switch (command
.type
) {
481 /* unapply the previous ply */
482 if (curr_ply
->prev_node
!= NULL
){
483 curr_ply
= curr_ply
->prev_node
;
485 rb
->splash ( HZ
*2 , "At the begining of the game" );
488 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
489 = board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
490 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
491 = color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]];
492 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = no_piece
;
493 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]] = neutral
;
494 if (curr_ply
->taken_piece
!= no_piece
&& !curr_ply
->enpassant
){
495 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
496 = curr_ply
->taken_piece
;
497 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
498 = ((curr_ply
->player
==white
)?black
:white
);
500 if (curr_ply
->castle
){
501 if (curr_ply
->column_to
== 6){
502 /* castling kingside */
503 board
[locn
[curr_ply
->row_to
][7]] = rook
;
504 color
[locn
[curr_ply
->row_to
][7]] = curr_ply
->player
;
505 board
[locn
[curr_ply
->row_to
][5]] = no_piece
;
506 color
[locn
[curr_ply
->row_to
][5]] = neutral
;
508 /* castling queenside */
509 board
[locn
[curr_ply
->row_to
][0]] = rook
;
510 color
[locn
[curr_ply
->row_to
][0]] = curr_ply
->player
;
511 board
[locn
[curr_ply
->row_to
][3]] = no_piece
;
512 color
[locn
[curr_ply
->row_to
][3]] = neutral
;
515 if (curr_ply
->enpassant
){
516 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = pawn
;
517 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]]
518 = ((curr_ply
->player
==white
)?black
:white
);
520 if (curr_ply
->promotion
){
521 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = pawn
;
522 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]]
529 /* apply the current move */
530 if (curr_ply
->player
== neutral
){
531 rb
->splash ( HZ
*2 , "At the end of the game" );
534 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
535 = board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
536 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
537 = color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]];
538 board
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = no_piece
;
539 color
[locn
[curr_ply
->row_from
][curr_ply
->column_from
]] = neutral
;
540 if (curr_ply
->castle
){
541 if (curr_ply
->column_to
== 6){
542 /* castling kingside */
543 board
[locn
[curr_ply
->row_to
][5]] = rook
;
544 color
[locn
[curr_ply
->row_to
][5]] = curr_ply
->player
;
545 board
[locn
[curr_ply
->row_to
][7]] = no_piece
;
546 color
[locn
[curr_ply
->row_to
][7]] = neutral
;
548 /* castling queenside */
549 board
[locn
[curr_ply
->row_to
][3]] = rook
;
550 color
[locn
[curr_ply
->row_to
][3]] = curr_ply
->player
;
551 board
[locn
[curr_ply
->row_to
][0]] = no_piece
;
552 color
[locn
[curr_ply
->row_to
][0]] = neutral
;
555 if (curr_ply
->enpassant
){
556 board
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = no_piece
;
557 color
[locn
[curr_ply
->row_from
][curr_ply
->column_to
]] = neutral
;
559 if (curr_ply
->promotion
){
560 board
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
561 = curr_ply
->promotion_piece
;
562 color
[locn
[curr_ply
->row_to
][curr_ply
->column_to
]]
565 if (curr_ply
->next_node
!= NULL
){
566 curr_ply
= curr_ply
->next_node
;
570 case COMMAND_RESTART
:
571 GNUChess_Initialize();
573 curr_ply
= selected_game
->first_ply
;
581 } while (!exit_game
&& !exit_viewer
);
583 rb
->splash ( HZ
*2 , "Error parsing game !");
585 } while (!exit_viewer
);
588 /* ---- show menu ---- */
589 static int cb_menu(void)
593 bool menu_quit
= false;
595 MENUITEM_STRINGLIST(menu
,"Chessbox Menu",NULL
,"New Game","Resume Game",
596 "Save Game", "Restore Game", "Quit");
600 switch(rb
->do_menu(&menu
, &selection
, NULL
, false))
604 result
= COMMAND_RESTART
;
607 result
= COMMAND_RESUME
;
611 result
= COMMAND_SAVE
;
615 result
= COMMAND_RESTORE
;
619 result
= COMMAND_QUIT
;
627 /* ---- get a command in game mode ---- */
628 struct cb_command
cb_getcommand (void) {
629 static short x
= 4 , y
= 3 ;
631 int button
, lastbutton
= BUTTON_NONE
;
632 int marked
= false , from_marked
= false ;
633 short marked_x
= 0 , marked_y
= 0 ;
634 struct cb_command result
= { 0, {0,0,0,0,0}, 0 };
639 button
= rb
->button_get(true);
643 result
.type
= COMMAND_QUIT
;
647 result
.type
= cb_menu();
650 result
.type
= COMMAND_LEVEL
;
654 if (lastbutton
!= CB_PLAY_PRE
)
657 result
.type
= COMMAND_PLAY
;
660 if ( !from_marked
) cb_switch ( x
, y
);
667 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
670 from_marked
= false ;
675 if ( !from_marked
) cb_switch ( x
, y
);
682 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
685 from_marked
= false ;
690 if ( !from_marked
) cb_switch ( x
, y
);
697 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
700 from_marked
= false ;
705 if ( !from_marked
) cb_switch ( x
, y
);
712 if ( marked
&& ( marked_x
== x
) && ( marked_y
== y
) ) {
715 from_marked
= false ;
721 if (lastbutton
!= CB_SELECT_PRE
)
725 xy2cr ( x
, y
, &c
, &r
);
727 if ( ( color
[l
]!=computer
) && ( board
[l
]!=no_piece
) ) {
734 if ( ( marked_x
== x
) && ( marked_y
== y
) ) {
738 xy2cr ( marked_x
, marked_y
, &c
, &r
);
739 result
.mv_s
[0] = 'a' + c
;
740 result
.mv_s
[1] = '1' + r
;
741 xy2cr ( x
, y
, &c
, &r
);
742 result
.mv_s
[2] = 'a' + c
;
743 result
.mv_s
[3] = '1' + r
;
744 result
.mv_s
[4] = '\00';
745 result
.type
= COMMAND_MOVE
;
751 if (button
!= BUTTON_NONE
)
757 /* ---- game main loop ---- */
758 void cb_play_game(void) {
759 struct cb_command command
;
760 struct pgn_game_node
*game
;
761 char move_buffer
[20];
766 /* load opening book, soon */
769 GNUChess_Initialize();
771 /* init PGN history data structures */
772 game
= pgn_init_game(rb
);
774 /* restore saved position, if saved */
775 cb_restoreposition();
776 /* TODO: save/restore the PGN history of unfinished games */
779 /* I don't like configscreens, start game inmediatly */
784 rb
->splash ( HZ
*3 , "Checkmate!" );
785 rb
->button_get(true);
786 pgn_store_game(rb
, game
);
787 GNUChess_Initialize();
788 game
= pgn_init_game(rb
);
791 command
= cb_getcommand ();
792 switch (command
.type
) {
794 if ( ! VerifyMove (opponent
, command
.mv_s
, 0 , &command
.mv
, move_buffer
) ) {
795 rb
->splash ( HZ
/2 , "Illegal move!" );
800 /* Add the ply to the PGN history (in algebraic notation) */
801 pgn_append_ply(rb
, game
, opponent
, move_buffer
, mate
);
803 rb
->splash ( 0 , "Thinking..." );
804 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
805 rb
->cpu_boost ( true );
807 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
808 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
809 rb
->cpu_boost ( false );
811 /* Add the ply to the PGN history (in algebraic notation) and check
812 * for the result of the game which is only calculated in SelectMove
814 if (move_buffer
[0] != '\0'){
815 pgn_append_ply(rb
, game
, computer
, move_buffer
, mate
);
817 pgn_set_result(rb
, game
, mate
);
820 if ( wt_command
== COMMAND_QUIT
) {
827 #ifdef COMMAND_RESTART
828 case COMMAND_RESTART
:
829 GNUChess_Initialize();
830 game
= pgn_init_game(rb
);
841 case COMMAND_RESTORE
:
842 /* watch out, it will reset the game if no previous game was saved! */
845 GNUChess_Initialize();
847 /* init PGN history data structures */
848 game
= pgn_init_game(rb
);
850 /* restore saved position, if saved */
851 cb_restoreposition();
856 if (opponent
== white
) {
863 rb
->splash ( 0 , "Thinking..." );
865 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
866 rb
->cpu_boost ( true );
868 SelectMove ( computer
, 0 , cb_wt_callback
, move_buffer
);
869 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
870 rb
->cpu_boost ( false );
873 /* Add the ply to the PGN history (in algebraic notation) and check
874 * for the result of the game which is only calculated in SelectMove
876 if (move_buffer
[0] != '\0'){
877 pgn_append_ply(rb
, game
, computer
, move_buffer
, mate
);
879 pgn_set_result(rb
, game
, mate
);
882 if ( wt_command
== COMMAND_QUIT
) {
899 /* TODO: save/restore the PGN history of unfinished games */
900 rb
->lcd_setfont(FONT_UI
);
904 /*****************************************************************************
905 * plugin entry point.
906 ******************************************************************************/
907 enum plugin_status
plugin_start(const struct plugin_api
* api
, const void* parameter
) {
913 rb
->lcd_set_backdrop(NULL
);
916 /* end of plugin init */
918 /* if the plugin was invoked as a viewer, parse the file and show the game list
919 * else, start playing a game
921 if (parameter
!= NULL
) {
922 cb_start_viewer((char *)parameter
);
930 #endif /* HAVE_LCD_BITMAP */