FS#7209 - Make chessbox able to view games stored in PGN format

Attached to Project: Rockbox
Opened by Mauricio Peccorini (mpeccorini) - Thursday, 24 May 2007, 15:43 GMT
Last edited by Nils Wallménius (nls) - Tuesday, 29 May 2007, 16:33 GMT
Task Type Patches
Category Games
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The patch makes chessbox work both as a plugin and as a viewer. If the plugin is started like usual it will have the same behaviour. However, if a PGN file (a file with pgn extension) is selected in the file browser, the plugin will start as a viewer and will show the list of games contained in the file.

After the users selects a file, the board will be shown and the user will be able to replay the match using the left and right buttons (move forward and move backwards respectively)

At any time during the match, if the user presses the menu key combination, a small menu will be shown and it will allow him to restart the same game, choose a new game or quit the viewer.

-simple annotations (i.e.:?,!,?! and so forth are supported, but numeric annotation glyphs are not yet supported).
-variations of the main line of the game are not supported at all.
-full browsing of the game tags (event, site, white/black elo, etc) is not possible. Only white's name, black's name and date are shown ATM.
-The game list will be loaded in memory in it's entirety. While only the players names, date of match and line number in the file will be included in the list, if the number of games exceeds a couple thousand the player may crash.

-Efforts to support deviations to the format (like expressing castling with zeros instead of capital "O" letters) have been taken. However, after a game is selected, a file called chessbox.log will be left in the rocks folder. If a game is not parsed correctly, please send it to me (mpeccorini at yahoo dot com) and I will gladly fix the problem.
-To aid the developer in the tests, I'm attaching a PGN file with the history of the games the Salvadorean team played in the Chess Counter-Olympiad in Lybia 1976. They won the gold medal !
-Storing games played against the GNUChess engine will be supported in a future patch as well as switching between plugin and viewer modes.
This task depends upon

Closed by  Nils Wallménius (nls)
Tuesday, 29 May 2007, 16:33 GMT
Reason for closing:  Accepted
Additional comments about closing:  comitted
Comment by Nils Wallménius (nls) - Saturday, 26 May 2007, 19:51 GMT
The patch breakes compilation, in the cb_menu_viewer() function there's a variable missing.
If I add a int selection; it compiles fine.

The list where the games are displayed when I open the pgn file you attatched didn't let me
choose any other game than the first one.

And some minor nitpicks, the color of the selection in the list of games seems to be inversed instead
of reversed. Also we have a sort-of style rule that lines shouldn't be much longer than 80...

Other than this it seems to work nicely, the one game that i can select works nice and the regular gameplay does work too.
Comment by Mauricio Peccorini (mpeccorini) - Monday, 28 May 2007, 16:31 GMT
Everything fixed with the exception of a very few lines exceeding 80 characters, it really made sense to leave them that way or it would make them very hard to read.

Comment by Mauricio Peccorini (mpeccorini) - Monday, 28 May 2007, 20:44 GMT
Fixed the results where black won (0-1) to be passing as valid PGN tokens and making the simulator crash
Comment by Mauricio Peccorini (mpeccorini) - Monday, 28 May 2007, 23:38 GMT
Use the list widget to show the list of games in the file so it behaves as the rest of the lists in the system (thanks to Nils for the suggestion)