Sokoban is a simple game, requiring the ability to move the cursor around the screen, and to reverse-video some characters. The game lets you move around, pushing ``packets'' into a ``store'' area. You cannot push two packets at a time, only one. When you have pushed all packets into store, you get a new screen.

This page looks at the structure of Sokoban, as a typical, real C program that has been released as source code onto the Internet. The main disadvantage is that it uses old K&R notations instead of ANSI C. Most programs under Unix still do.

In addition, there is very little internal doco. Each file should have author, name of file, date of modification, revision history, etc. none do. Each function should have purpose and a description of parameters. None do.

The files in Sokoban are

sokoban.h play.c save.c showscreen.c readscreen.c score.c sok.c

The file Makefile is used by ``make'' to build Sokoban.

The file sokoban.h contains lots of define'd symbols and data types.

The file play.c contains functions

play() testmove() domove() undomove() tmpsave() tmpreset()

The file readscreen.c contains functions


The file save.c contains functions

savegame() restoregame()

The file score.c contains functions

outputscore() makenewscore() getuserlevel() score() readscore() makescore() finduser() findpos() writescore() showscore() cp_entry()

The file showscreen.c contains functions

showscreen() mapchar() get_obj_addr() displevel() disppackets() dispmove() dispsave() disppushes() helpmessage() showhelp() makehelpwin() printhelpline()

The file sok.c contains functions

main() checkcmdline() gameloop() getpasswd() errmess() usage()
Creative Commons License Copyright © Jan Newmarch under the terms of the Creative Commons Attribution 2.1 Australia License.