NH4: Store game state diffs in logs and save files

Every time a command is logged, the game now performs an in-memory save,
compares it to its previous one, and stores the base 64 encoded
difference in the game log.  These diffs aren't used for anything yet.

Diffs consist of copy, edit and seek commands encoded in the top 2 bits
of a 16 bit value and using the last 14 bits to store an associated
count (signed for seeks, otherwise unsigned).  Edit commands are also
followed by that many bytes of the differing data.

To help keep diffs efficient, tags marking sections of the save are
tracked.  The current state looks up tags from the previous state and
issues seek commands if the tracking position differs from where the tag
says it should be.  The current state also creates its own tags so the
next state can use them.  Tags are NOT saved, nor are they strictly
needed for correctness, but they help to reduce redundant diff output
where the same data exists in the current and previous state but
difference tracking reads them offset from one another.

Compared to NetHack4:

 * the comments now do a better job of explaining how these diffs work

 * diff commands are now an enum instead of defines

 * the tag linked list free code in mfree() has been rewritten to be
   simpler, also preventing an initial free(NULL)

 * some fixes for diff command/count encoding issues have been
   back-ported

Store gamestate diffs in log/savefiles
Alex Smith <ais523@bham.ac.uk>
77291079817c2831e764d1bb1832fc08fdbd4ec7